repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | /** |
| #2 | * Automaton Configuration |
| #3 | * |
| #4 | * Loads and saves the automaton's configuration from ~/.automaton/automaton.json |
| #5 | */ |
| #6 | import fs from "fs"; |
| #7 | import path from "path"; |
| #8 | import { DEFAULT_CONFIG } from "./types.js"; |
| #9 | import { getAutomatonDir } from "./identity/wallet.js"; |
| #10 | import { loadApiKeyFromConfig } from "./identity/provision.js"; |
| #11 | const CONFIG_FILENAME = "automaton.json"; |
| #12 | export function getConfigPath() { |
| #13 | return path.join(getAutomatonDir(), CONFIG_FILENAME); |
| #14 | } |
| #15 | /** |
| #16 | * Load the automaton config from disk. |
| #17 | * Merges with defaults for any missing fields. |
| #18 | */ |
| #19 | export function loadConfig() { |
| #20 | const configPath = getConfigPath(); |
| #21 | if (!fs.existsSync(configPath)) { |
| #22 | return null; |
| #23 | } |
| #24 | try { |
| #25 | const raw = JSON.parse(fs.readFileSync(configPath, "utf-8")); |
| #26 | const apiKey = raw.clawdApiKey || loadApiKeyFromConfig(); |
| #27 | return { |
| #28 | ...DEFAULT_CONFIG, |
| #29 | ...raw, |
| #30 | clawdApiKey: apiKey, |
| #31 | }; |
| #32 | } |
| #33 | catch { |
| #34 | return null; |
| #35 | } |
| #36 | } |
| #37 | /** |
| #38 | * Save the automaton config to disk. |
| #39 | */ |
| #40 | export function saveConfig(config) { |
| #41 | const dir = getAutomatonDir(); |
| #42 | if (!fs.existsSync(dir)) { |
| #43 | fs.mkdirSync(dir, { recursive: true, mode: 0o700 }); |
| #44 | } |
| #45 | const configPath = getConfigPath(); |
| #46 | fs.writeFileSync(configPath, JSON.stringify(config, null, 2), { |
| #47 | mode: 0o600, |
| #48 | }); |
| #49 | } |
| #50 | /** |
| #51 | * Resolve ~ paths to absolute paths. |
| #52 | */ |
| #53 | export function resolvePath(p) { |
| #54 | if (p.startsWith("~")) { |
| #55 | return path.join(process.env.HOME || "/root", p.slice(1)); |
| #56 | } |
| #57 | return p; |
| #58 | } |
| #59 | /** |
| #60 | * Create a fresh config from setup wizard inputs. |
| #61 | */ |
| #62 | export function createConfig(params) { |
| #63 | return { |
| #64 | name: params.name, |
| #65 | genesisPrompt: params.genesisPrompt, |
| #66 | creatorMessage: params.creatorMessage, |
| #67 | creatorAddress: params.creatorAddress, |
| #68 | registeredWithClawd: params.registeredWithClawd, |
| #69 | sandboxId: params.sandboxId, |
| #70 | clawdApiUrl: DEFAULT_CONFIG.clawdApiUrl, |
| #71 | clawdApiKey: params.apiKey, |
| #72 | inferenceModel: DEFAULT_CONFIG.inferenceModel, |
| #73 | maxTokensPerTurn: DEFAULT_CONFIG.maxTokensPerTurn, |
| #74 | heartbeatConfigPath: DEFAULT_CONFIG.heartbeatConfigPath, |
| #75 | dbPath: DEFAULT_CONFIG.dbPath, |
| #76 | logLevel: DEFAULT_CONFIG.logLevel, |
| #77 | walletAddress: params.walletAddress, |
| #78 | version: DEFAULT_CONFIG.version, |
| #79 | skillsDir: DEFAULT_CONFIG.skillsDir, |
| #80 | maxChildren: DEFAULT_CONFIG.maxChildren, |
| #81 | parentAddress: params.parentAddress, |
| #82 | }; |
| #83 | } |
| #84 | //# sourceMappingURL=config.js.map |