xonecas.io
7814
Ta

tiny-c-agent / files

tiny-c-agent / src / config.h

1.7 KB
1// tiny config: schema, defaults, and loading/merging of config files.
2
3#ifndef TINY_CONFIG_H
4#define TINY_CONFIG_H
5
6#include <stdbool.h>
7#include <stddef.h>
8
9typedef enum {
10    TINY_THEME_TOKYO_NIGHT,
11    TINY_THEME_AUTO,
12} tiny_theme;
13
14typedef enum {
15    TINY_API_OPENAI_COMPLETIONS,
16    TINY_API_OPENAI_RESPONSES,
17    TINY_API_ANTHROPIC_MESSAGES,
18    TINY_API_GOOGLE_GENERATIVE_AI,
19} tiny_api;
20
21typedef struct {
22    char *id;
23    char *name;      // NULL when the config omits it; callers fall back to id.
24    char *base_url;
25    tiny_api api;
26    char **models;
27    size_t models_len;
28} tiny_provider;
29
30typedef struct {
31    tiny_theme theme;
32    char *provider;       // NULL when unset.
33    char *model;          // NULL when unset.
34    char *effort;         // NULL when unset; otherwise off/minimal/low/medium/high/xhigh/max.
35    char *system_prompt;  // NULL when unset.
36    bool discover_agent_files;
37    char **skills_dirs;
38    size_t skills_dirs_len;
39    char *sessions_dir;   // Always resolved.
40    tiny_provider *custom_providers;
41    size_t custom_providers_len;
42} tiny_config;
43
44// Loads the config. The global config is always read; when cli_path is not NULL
45// its keys override the global ones. Returns NULL on failure and, if err is not
46// NULL, stores a malloc'd message there (the caller frees it).
47tiny_config *tiny_config_load(const char *cli_path, char **err);
48
49// Merges the given keys into the global config file, leaving other keys
50// untouched. A NULL argument leaves that key unchanged. Written atomically.
51// Returns 0, or -1 with *err set.
52int tiny_config_save(const char *provider, const char *model, const char *effort, char **err);
53
54void tiny_config_free(tiny_config *cfg);
55
56#endif