cueclaw 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,158 +0,0 @@
1
- // src/config.ts
2
- import { readFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
3
- import { join } from "path";
4
- import { homedir } from "os";
5
- import { parse as parseYaml } from "yaml";
6
- import { z } from "zod/v4";
7
-
8
- // src/types.ts
9
- var CueclawError = class extends Error {
10
- constructor(message, code) {
11
- super(message);
12
- this.code = code;
13
- this.name = "CueclawError";
14
- }
15
- };
16
- var PlannerError = class extends CueclawError {
17
- constructor(message) {
18
- super(message, "PLANNER_ERROR");
19
- }
20
- };
21
- var ExecutorError = class extends CueclawError {
22
- constructor(message) {
23
- super(message, "EXECUTOR_ERROR");
24
- }
25
- };
26
- var ConfigError = class extends CueclawError {
27
- constructor(message) {
28
- super(message, "CONFIG_ERROR");
29
- }
30
- };
31
-
32
- // src/config.ts
33
- var ConfigSchema = z.object({
34
- claude: z.object({
35
- api_key: z.string(),
36
- base_url: z.string().url().default("https://api.anthropic.com"),
37
- planner: z.object({ model: z.string().default("claude-sonnet-4-6") }).default({ model: "claude-sonnet-4-6" }),
38
- executor: z.object({ model: z.string().default("claude-sonnet-4-6") }).default({ model: "claude-sonnet-4-6" })
39
- }),
40
- identity: z.object({ name: z.string() }).optional(),
41
- whatsapp: z.object({
42
- enabled: z.boolean().default(false),
43
- auth_dir: z.string().default("~/.cueclaw/auth/whatsapp"),
44
- allowed_jids: z.array(z.string()).default([])
45
- }).optional(),
46
- telegram: z.object({
47
- enabled: z.boolean().default(false),
48
- token: z.string().optional(),
49
- allowed_users: z.array(z.string()).default([])
50
- }).optional(),
51
- logging: z.object({
52
- level: z.enum(["debug", "info", "warn", "error"]).default("info"),
53
- dir: z.string().default("~/.cueclaw/logs")
54
- }).optional(),
55
- container: z.object({
56
- enabled: z.boolean().default(false),
57
- image: z.string().default("cueclaw-agent:latest"),
58
- timeout: z.number().default(18e5),
59
- max_output_size: z.number().default(10485760),
60
- idle_timeout: z.number().default(18e5),
61
- network: z.enum(["none", "host", "bridge"]).default("none")
62
- }).optional()
63
- });
64
- function cueclawHome() {
65
- return join(homedir(), ".cueclaw");
66
- }
67
- function ensureCueclawHome() {
68
- const home = cueclawHome();
69
- const dirs = [home, join(home, "db"), join(home, "logs"), join(home, "auth")];
70
- for (const dir of dirs) {
71
- mkdirSync(dir, { recursive: true });
72
- }
73
- }
74
- function interpolateEnvVars(value) {
75
- return value.replace(/\$\{(\w+)\}/g, (_match, name) => {
76
- return process.env[name] ?? "";
77
- });
78
- }
79
- function interpolateObject(obj) {
80
- if (typeof obj === "string") return interpolateEnvVars(obj);
81
- if (Array.isArray(obj)) return obj.map(interpolateObject);
82
- if (obj !== null && typeof obj === "object") {
83
- const result = {};
84
- for (const [key, value] of Object.entries(obj)) {
85
- result[key] = interpolateObject(value);
86
- }
87
- return result;
88
- }
89
- return obj;
90
- }
91
- function loadYamlFile(path) {
92
- if (!existsSync(path)) return null;
93
- const content = readFileSync(path, "utf-8");
94
- const parsed = parseYaml(content);
95
- return parsed && typeof parsed === "object" ? parsed : null;
96
- }
97
- function deepMerge(target, source) {
98
- const result = { ...target };
99
- for (const [key, value] of Object.entries(source)) {
100
- if (value !== null && typeof value === "object" && !Array.isArray(value) && result[key] !== null && typeof result[key] === "object" && !Array.isArray(result[key])) {
101
- result[key] = deepMerge(result[key], value);
102
- } else {
103
- result[key] = value;
104
- }
105
- }
106
- return result;
107
- }
108
- function loadConfig() {
109
- const globalPath = join(cueclawHome(), "config.yaml");
110
- const localPath = join(process.cwd(), ".cueclaw", "config.yaml");
111
- let merged = {};
112
- const globalConfig = loadYamlFile(globalPath);
113
- if (globalConfig) merged = deepMerge(merged, globalConfig);
114
- const localConfig = loadYamlFile(localPath);
115
- if (localConfig) merged = deepMerge(merged, localConfig);
116
- if (process.env["ANTHROPIC_API_KEY"]) {
117
- merged.claude = merged.claude ?? {};
118
- merged.claude.api_key = process.env["ANTHROPIC_API_KEY"];
119
- }
120
- merged = interpolateObject(merged);
121
- const result = ConfigSchema.safeParse(merged);
122
- if (!result.success) {
123
- const issues = result.error.issues.map((i) => ` ${i.path.join(".")}: ${i.message}`).join("\n");
124
- throw new ConfigError(`Invalid configuration:
125
- ${issues}`);
126
- }
127
- return result.data;
128
- }
129
- var DEFAULT_CONFIG = `# CueClaw Configuration
130
- # See docs/config.md for all options
131
-
132
- claude:
133
- api_key: \${ANTHROPIC_API_KEY}
134
- planner:
135
- model: claude-sonnet-4-6
136
- executor:
137
- model: claude-sonnet-4-6
138
-
139
- logging:
140
- level: info
141
- `;
142
- function createDefaultConfig() {
143
- const configPath = join(cueclawHome(), "config.yaml");
144
- if (!existsSync(configPath)) {
145
- ensureCueclawHome();
146
- writeFileSync(configPath, DEFAULT_CONFIG, "utf-8");
147
- }
148
- }
149
-
150
- export {
151
- PlannerError,
152
- ExecutorError,
153
- ConfigError,
154
- cueclawHome,
155
- ensureCueclawHome,
156
- loadConfig,
157
- createDefaultConfig
158
- };
@@ -1,12 +0,0 @@
1
- import {
2
- createDefaultConfig,
3
- cueclawHome,
4
- ensureCueclawHome,
5
- loadConfig
6
- } from "./chunk-JRHM3Z4C.js";
7
- export {
8
- createDefaultConfig,
9
- cueclawHome,
10
- ensureCueclawHome,
11
- loadConfig
12
- };
@@ -1,10 +0,0 @@
1
- import {
2
- MessageRouter
3
- } from "./chunk-GMHDL4CG.js";
4
- import "./chunk-D77G7ABJ.js";
5
- import "./chunk-K4PGB2DU.js";
6
- import "./chunk-JRHM3Z4C.js";
7
- import "./chunk-E7BP6DMO.js";
8
- export {
9
- MessageRouter
10
- };