c7be324083
Cherry-pick of KeygraphHQ/shannon#295 (581c208). Upstream changes: removes router mode from CLI/worker, adds provider extensions, new report-output-provider and checkpoint-provider interfaces, refactored workflow orchestration. Conflicts resolved: kept our README.md, CLAUDE.md, and deleted compose files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
998 B
TypeScript
30 lines
998 B
TypeScript
/** TOML config writer for ~/.shannon/config.toml. */
|
|
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { stringify } from 'smol-toml';
|
|
import { getConfigFile } from '../home.js';
|
|
|
|
// === Types ===
|
|
|
|
export interface ShannonConfig {
|
|
core?: { max_tokens?: number };
|
|
anthropic?: { api_key?: string; oauth_token?: string };
|
|
custom_base_url?: { base_url?: string; auth_token?: string };
|
|
bedrock?: { use?: boolean; region?: string; token?: string };
|
|
vertex?: { use?: boolean; region?: string; project_id?: string; key_path?: string };
|
|
models?: { small?: string; medium?: string; large?: string };
|
|
}
|
|
|
|
// === File Operations ===
|
|
|
|
/** Write the config to ~/.shannon/config.toml with 0o600 permissions. */
|
|
export function saveConfig(config: ShannonConfig): void {
|
|
const configPath = getConfigFile();
|
|
const dir = path.dirname(configPath);
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
|
|
const content = stringify(config);
|
|
fs.writeFileSync(configPath, content, { mode: 0o600 });
|
|
}
|