the-campfire 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.
Files changed (180) hide show
  1. package/bin/cli.ts +182 -0
  2. package/dist/apple-touch-icon.png +0 -0
  3. package/dist/assets/MermaidDiagram-By1J3Whj.js +2 -0
  4. package/dist/assets/_basePickBy-Dq6gnD-p.js +1 -0
  5. package/dist/assets/_baseUniq-SpgN6cGc.js +1 -0
  6. package/dist/assets/arc-D9SEA8dX.js +1 -0
  7. package/dist/assets/architectureDiagram-VXUJARFQ-CoTcwLeR.js +36 -0
  8. package/dist/assets/blockDiagram-VD42YOAC-Dvc63voV.js +122 -0
  9. package/dist/assets/c4Diagram-YG6GDRKO-tuDcG4_4.js +10 -0
  10. package/dist/assets/channel-CxhcHn7S.js +1 -0
  11. package/dist/assets/chunk-4BX2VUAB-x1hChYu9.js +1 -0
  12. package/dist/assets/chunk-55IACEB6-BX6HWnWP.js +1 -0
  13. package/dist/assets/chunk-B4BG7PRW-B4IlF03G.js +165 -0
  14. package/dist/assets/chunk-DI55MBZ5-TpYb5rLg.js +220 -0
  15. package/dist/assets/chunk-FMBD7UC4-DZX4LUPx.js +15 -0
  16. package/dist/assets/chunk-QN33PNHL-CuQs0NDY.js +1 -0
  17. package/dist/assets/chunk-QZHKN3VN-CygWwVx8.js +1 -0
  18. package/dist/assets/chunk-TZMSLE5B-CtI-IdKV.js +1 -0
  19. package/dist/assets/classDiagram-2ON5EDUG-BM0LptJF.js +1 -0
  20. package/dist/assets/classDiagram-v2-WZHVMYZB-BM0LptJF.js +1 -0
  21. package/dist/assets/clone-C6kt1rE7.js +1 -0
  22. package/dist/assets/cose-bilkent-S5V4N54A-PdySs991.js +1 -0
  23. package/dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
  24. package/dist/assets/dagre-6UL2VRFP-J0SxEiEu.js +4 -0
  25. package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  26. package/dist/assets/diagram-PSM6KHXK-CW0HLXaH.js +24 -0
  27. package/dist/assets/diagram-QEK2KX5R-DADHF-k4.js +43 -0
  28. package/dist/assets/diagram-S2PKOQOG-9S0-PC3S.js +24 -0
  29. package/dist/assets/erDiagram-Q2GNP2WA-BEHAiY_q.js +60 -0
  30. package/dist/assets/flowDiagram-NV44I4VS-Cu6n9Xnd.js +162 -0
  31. package/dist/assets/ganttDiagram-JELNMOA3-Cr_BHryu.js +267 -0
  32. package/dist/assets/gitGraphDiagram-V2S2FVAM-D5pT35v5.js +65 -0
  33. package/dist/assets/graph-DKRbrxcs.js +1 -0
  34. package/dist/assets/index-Byjg9zgI.css +32 -0
  35. package/dist/assets/index-Cwj3m0hT.js +284 -0
  36. package/dist/assets/infoDiagram-HS3SLOUP-BaJlrgKV.js +2 -0
  37. package/dist/assets/init-Gi6I4Gst.js +1 -0
  38. package/dist/assets/journeyDiagram-XKPGCS4Q-CXC4-DJv.js +139 -0
  39. package/dist/assets/kanban-definition-3W4ZIXB7-BtHBu9cx.js +89 -0
  40. package/dist/assets/katex-BlHpptmG.js +261 -0
  41. package/dist/assets/layout-DnxSwLDJ.js +1 -0
  42. package/dist/assets/linear-CWbbIT8l.js +1 -0
  43. package/dist/assets/mermaid.core-DXn1cFAK.js +256 -0
  44. package/dist/assets/mindmap-definition-VGOIOE7T-BR8br1hs.js +68 -0
  45. package/dist/assets/ordinal-BENe2yWM.js +1 -0
  46. package/dist/assets/pieDiagram-ADFJNKIX-B7RmXV7I.js +30 -0
  47. package/dist/assets/quadrantDiagram-AYHSOK5B-DK0FhyV_.js +7 -0
  48. package/dist/assets/requirementDiagram-UZGBJVZJ-3zAGxSpL.js +64 -0
  49. package/dist/assets/sankeyDiagram-TZEHDZUN-DZppKtjc.js +10 -0
  50. package/dist/assets/sequenceDiagram-WL72ISMW-D1x3r3wV.js +145 -0
  51. package/dist/assets/stateDiagram-FKZM4ZOC-2ByD08Vq.js +1 -0
  52. package/dist/assets/stateDiagram-v2-4FDKWEC3-Vm1cYjgV.js +1 -0
  53. package/dist/assets/timeline-definition-IT6M3QCI-l5S35biR.js +61 -0
  54. package/dist/assets/treemap-GDKQZRPO-DIPadPiF.js +162 -0
  55. package/dist/assets/xychartDiagram-PRI3JC2R-9GUvwS2b.js +7 -0
  56. package/dist/favicon.svg +3 -0
  57. package/dist/fonts/Geist-Variable.woff2 +0 -0
  58. package/dist/fonts/GeistMono-Variable.woff2 +0 -0
  59. package/dist/icon-192.png +0 -0
  60. package/dist/icon-512.png +0 -0
  61. package/dist/index.html +33 -0
  62. package/dist/logo-codex.svg +14 -0
  63. package/dist/logo.svg +3 -0
  64. package/dist/manifest.json +26 -0
  65. package/dist/og-image.png +0 -0
  66. package/dist/sw.js +130 -0
  67. package/package.json +92 -0
  68. package/server/ADAPTERS.md +121 -0
  69. package/server/adapter-registry-types.ts +28 -0
  70. package/server/adapter-registry.ts +293 -0
  71. package/server/adapter-types.ts +51 -0
  72. package/server/agent-executor.ts +249 -0
  73. package/server/agent-mcp-bridge.ts +148 -0
  74. package/server/agent-mcp-stdio.ts +171 -0
  75. package/server/agent-mcp-tools.ts +76 -0
  76. package/server/agent-store.ts +183 -0
  77. package/server/agent-types.ts +79 -0
  78. package/server/aider-adapter.ts +525 -0
  79. package/server/auth.ts +153 -0
  80. package/server/auto-namer.ts +132 -0
  81. package/server/capability-discovery.ts +431 -0
  82. package/server/claude-container-auth.ts +40 -0
  83. package/server/claude-stdio-adapter.ts +452 -0
  84. package/server/clawhub-export.ts +218 -0
  85. package/server/cli-launcher.ts +1613 -0
  86. package/server/codex-adapter.ts +1987 -0
  87. package/server/codex-container-auth.ts +40 -0
  88. package/server/codex-home.ts +26 -0
  89. package/server/collective-intelligence.ts +401 -0
  90. package/server/commands-discovery.ts +160 -0
  91. package/server/constants.ts +5 -0
  92. package/server/container-manager.ts +328 -0
  93. package/server/cron-scheduler.ts +243 -0
  94. package/server/cron-store.ts +149 -0
  95. package/server/cron-types.ts +63 -0
  96. package/server/deliberation-engine.ts +323 -0
  97. package/server/embedding.ts +89 -0
  98. package/server/env-manager.ts +146 -0
  99. package/server/environment-detector.ts +106 -0
  100. package/server/environment-rules.ts +106 -0
  101. package/server/gallery-store.ts +216 -0
  102. package/server/gallery-types.ts +52 -0
  103. package/server/gallery-votes.ts +101 -0
  104. package/server/git-utils.ts +384 -0
  105. package/server/github-pr.ts +379 -0
  106. package/server/goose-adapter.ts +929 -0
  107. package/server/image-pull-manager.ts +144 -0
  108. package/server/index.ts +363 -0
  109. package/server/linear-project-manager.ts +78 -0
  110. package/server/moltbook-client.ts +160 -0
  111. package/server/openclaw-adapter.ts +916 -0
  112. package/server/openclaw-channel/channel.ts +188 -0
  113. package/server/openclaw-channel/index.ts +68 -0
  114. package/server/openclaw-channel/package.json +19 -0
  115. package/server/openclaw-channel/types.ts +93 -0
  116. package/server/opencode-adapter.ts +951 -0
  117. package/server/openhands-adapter.ts +775 -0
  118. package/server/orchestrator-executor.ts +184 -0
  119. package/server/orchestrator-store.ts +106 -0
  120. package/server/orchestrator-types.ts +86 -0
  121. package/server/path-resolver.ts +168 -0
  122. package/server/pr-poller.ts +162 -0
  123. package/server/proactive-keepalive.ts +121 -0
  124. package/server/prompt-manager.ts +103 -0
  125. package/server/protocol-monitor.ts +197 -0
  126. package/server/race-controller.ts +295 -0
  127. package/server/race-store.ts +82 -0
  128. package/server/recorder.ts +359 -0
  129. package/server/recording-hub/compat-validator.ts +122 -0
  130. package/server/recording-hub/diagnostics.ts +289 -0
  131. package/server/recording-hub/hub-routes.ts +146 -0
  132. package/server/recording-hub/hub-store.ts +224 -0
  133. package/server/replay.ts +78 -0
  134. package/server/routes/adapter-routes.ts +31 -0
  135. package/server/routes/agent-mcp-routes.ts +35 -0
  136. package/server/routes/agent-routes.ts +185 -0
  137. package/server/routes/auth-routes.ts +101 -0
  138. package/server/routes/ci-routes.ts +165 -0
  139. package/server/routes/commands-routes.ts +94 -0
  140. package/server/routes/cron-routes.ts +100 -0
  141. package/server/routes/env-routes.ts +50 -0
  142. package/server/routes/folder-routes.ts +56 -0
  143. package/server/routes/fs-routes.ts +403 -0
  144. package/server/routes/gallery-routes.ts +410 -0
  145. package/server/routes/git-routes.ts +108 -0
  146. package/server/routes/index.ts +62 -0
  147. package/server/routes/linear-routes.ts +254 -0
  148. package/server/routes/monitor-routes.ts +11 -0
  149. package/server/routes/orchestrator-routes.ts +210 -0
  150. package/server/routes/prompt-routes.ts +47 -0
  151. package/server/routes/race-routes.ts +103 -0
  152. package/server/routes/recording-routes.ts +101 -0
  153. package/server/routes/route-deps.ts +32 -0
  154. package/server/routes/session-routes.ts +560 -0
  155. package/server/routes/settings-routes.ts +108 -0
  156. package/server/routes/skills-routes.ts +52 -0
  157. package/server/routes/system-routes.ts +243 -0
  158. package/server/routes/webhook-routes.ts +135 -0
  159. package/server/routes.ts +44 -0
  160. package/server/security-middleware.ts +100 -0
  161. package/server/semantic-memory.ts +389 -0
  162. package/server/service.ts +733 -0
  163. package/server/session-folders.ts +107 -0
  164. package/server/session-git-info.ts +89 -0
  165. package/server/session-linear-issues.ts +94 -0
  166. package/server/session-names.ts +67 -0
  167. package/server/session-store.ts +169 -0
  168. package/server/session-types.ts +415 -0
  169. package/server/settings-manager.ts +120 -0
  170. package/server/shared-context.ts +401 -0
  171. package/server/skills-manager.ts +250 -0
  172. package/server/sub-session-manager.ts +263 -0
  173. package/server/terminal-manager.ts +185 -0
  174. package/server/update-checker.ts +114 -0
  175. package/server/usage-limits.ts +192 -0
  176. package/server/webhook-manager.ts +228 -0
  177. package/server/webhook-store.ts +168 -0
  178. package/server/webhook-types.ts +66 -0
  179. package/server/worktree-tracker.ts +84 -0
  180. package/server/ws-bridge.ts +2322 -0
@@ -0,0 +1,183 @@
1
+ import {
2
+ mkdirSync,
3
+ readdirSync,
4
+ readFileSync,
5
+ writeFileSync,
6
+ unlinkSync,
7
+ existsSync,
8
+ appendFileSync,
9
+ } from "node:fs";
10
+ import { join } from "node:path";
11
+ import { homedir } from "node:os";
12
+ import type { AgentProfile, AgentProfileCreateInput, AgentExecution } from "./agent-types.js";
13
+
14
+ // ─── Paths ──────────────────────────────────────────────────────────────────
15
+
16
+ const CAMPFIRE_DIR = join(homedir(), ".campfire");
17
+ const AGENTS_DIR = join(CAMPFIRE_DIR, "agents");
18
+ const RUNS_DIR = join(CAMPFIRE_DIR, "agent-runs");
19
+
20
+ function ensureDir(dir: string): void {
21
+ mkdirSync(dir, { recursive: true });
22
+ }
23
+
24
+ function profilePath(id: string): string {
25
+ return join(AGENTS_DIR, `${id}.json`);
26
+ }
27
+
28
+ function runsPath(agentId: string): string {
29
+ return join(RUNS_DIR, `${agentId}.jsonl`);
30
+ }
31
+
32
+ // ─── Helpers ────────────────────────────────────────────────────────────────
33
+
34
+ function slugify(name: string): string {
35
+ return name
36
+ .toLowerCase()
37
+ .replaceAll(/\s+/g, "-")
38
+ .replaceAll(/[^a-z0-9-]/g, "")
39
+ .replaceAll(/-+/g, "-")
40
+ .replaceAll(/^-|-$/g, "");
41
+ }
42
+
43
+ // ─── Agent Profile CRUD ─────────────────────────────────────────────────────
44
+
45
+ export function listAgents(): AgentProfile[] {
46
+ ensureDir(AGENTS_DIR);
47
+ try {
48
+ const files = readdirSync(AGENTS_DIR).filter((f) => f.endsWith(".json"));
49
+ const agents: AgentProfile[] = [];
50
+ for (const file of files) {
51
+ try {
52
+ const raw = readFileSync(join(AGENTS_DIR, file), "utf-8");
53
+ agents.push(JSON.parse(raw));
54
+ } catch {
55
+ // Skip corrupt files
56
+ }
57
+ }
58
+ agents.sort((a, b) => a.name.localeCompare(b.name));
59
+ return agents;
60
+ } catch {
61
+ return [];
62
+ }
63
+ }
64
+
65
+ export function getAgent(id: string): AgentProfile | null {
66
+ ensureDir(AGENTS_DIR);
67
+ try {
68
+ const raw = readFileSync(profilePath(id), "utf-8");
69
+ return JSON.parse(raw) as AgentProfile;
70
+ } catch {
71
+ return null;
72
+ }
73
+ }
74
+
75
+ export function createAgent(data: AgentProfileCreateInput): AgentProfile {
76
+ if (!data.name?.trim()) throw new Error("Agent name is required");
77
+ if (!data.prompt?.trim()) throw new Error("Agent prompt is required");
78
+ if (!data.cwd?.trim()) throw new Error("Agent working directory is required");
79
+
80
+ const id = slugify(data.name.trim());
81
+ if (!id) throw new Error("Agent name must contain alphanumeric characters");
82
+
83
+ ensureDir(AGENTS_DIR);
84
+ if (existsSync(profilePath(id))) {
85
+ throw new Error(`An agent with a similar name already exists ("${id}")`);
86
+ }
87
+
88
+ const now = Date.now();
89
+ const agent: AgentProfile = {
90
+ ...data,
91
+ id,
92
+ name: data.name.trim(),
93
+ prompt: data.prompt.trim(),
94
+ cwd: data.cwd.trim(),
95
+ createdAt: now,
96
+ updatedAt: now,
97
+ consecutiveFailures: 0,
98
+ totalRuns: 0,
99
+ };
100
+ writeFileSync(profilePath(id), JSON.stringify(agent, null, 2), "utf-8");
101
+ return agent;
102
+ }
103
+
104
+ export function updateAgent(
105
+ id: string,
106
+ updates: Partial<AgentProfile>,
107
+ ): AgentProfile | null {
108
+ ensureDir(AGENTS_DIR);
109
+ const existing = getAgent(id);
110
+ if (!existing) return null;
111
+
112
+ const newName = updates.name?.trim() || existing.name;
113
+ const newId = slugify(newName);
114
+ if (!newId) throw new Error("Agent name must contain alphanumeric characters");
115
+
116
+ if (newId !== id && existsSync(profilePath(newId))) {
117
+ throw new Error(`An agent with a similar name already exists ("${newId}")`);
118
+ }
119
+
120
+ const agent: AgentProfile = {
121
+ ...existing,
122
+ ...updates,
123
+ id: newId,
124
+ name: newName,
125
+ updatedAt: Date.now(),
126
+ createdAt: existing.createdAt,
127
+ };
128
+
129
+ if (newId !== id) {
130
+ try { unlinkSync(profilePath(id)); } catch { /* ok */ }
131
+ }
132
+
133
+ writeFileSync(profilePath(newId), JSON.stringify(agent, null, 2), "utf-8");
134
+ return agent;
135
+ }
136
+
137
+ export function deleteAgent(id: string): boolean {
138
+ ensureDir(AGENTS_DIR);
139
+ if (!existsSync(profilePath(id))) return false;
140
+ try {
141
+ unlinkSync(profilePath(id));
142
+ return true;
143
+ } catch {
144
+ return false;
145
+ }
146
+ }
147
+
148
+ // ─── Execution History ──────────────────────────────────────────────────────
149
+
150
+ export function appendExecution(execution: AgentExecution): void {
151
+ ensureDir(RUNS_DIR);
152
+ appendFileSync(runsPath(execution.agentId), JSON.stringify(execution) + "\n", "utf-8");
153
+ }
154
+
155
+ export function updateExecution(
156
+ agentId: string,
157
+ sessionId: string,
158
+ updates: Partial<AgentExecution>,
159
+ ): void {
160
+ const executions = listExecutions(agentId);
161
+ const idx = executions.findIndex((e) => e.sessionId === sessionId);
162
+ if (idx < 0) return;
163
+ executions[idx] = { ...executions[idx], ...updates };
164
+ ensureDir(RUNS_DIR);
165
+ const content = executions.map((e) => JSON.stringify(e)).join("\n") + "\n";
166
+ writeFileSync(runsPath(agentId), content, "utf-8");
167
+ }
168
+
169
+ export function listExecutions(agentId: string, limit = 50): AgentExecution[] {
170
+ ensureDir(RUNS_DIR);
171
+ try {
172
+ const raw = readFileSync(runsPath(agentId), "utf-8");
173
+ const lines = raw.trim().split("\n").filter(Boolean);
174
+ const executions: AgentExecution[] = [];
175
+ for (const line of lines) {
176
+ try { executions.push(JSON.parse(line)); } catch { /* skip */ }
177
+ }
178
+ executions.sort((a, b) => b.startedAt - a.startedAt);
179
+ return executions.slice(0, limit);
180
+ } catch {
181
+ return [];
182
+ }
183
+ }
@@ -0,0 +1,79 @@
1
+ import type { BackendType, McpServerConfig } from "./session-types.js";
2
+
3
+ // ─── Agent Profile ─────────────────────────────────────────────────────────
4
+
5
+ export interface AgentProfile {
6
+ /** Unique slug-based ID (derived from name) */
7
+ id: string;
8
+ /** Human-readable name */
9
+ name: string;
10
+ /** Short description of purpose */
11
+ description: string;
12
+ /** Emoji or short string icon */
13
+ icon?: string;
14
+ /** Which AI backend to use */
15
+ backendType: BackendType;
16
+ /** Model identifier (e.g. "claude-sonnet-4-6") */
17
+ model: string;
18
+ /** Permission level — defaults to "bypassPermissions" for autonomy */
19
+ permissionMode: string;
20
+ /** Working directory path */
21
+ cwd: string;
22
+ /** Prompt template — supports {{input}} placeholder for trigger input */
23
+ prompt: string;
24
+
25
+ // ── Triggers ──
26
+ triggers?: {
27
+ webhook?: { enabled: boolean };
28
+ schedule?: {
29
+ enabled: boolean;
30
+ expression: string;
31
+ recurring: boolean;
32
+ };
33
+ };
34
+
35
+ // ── Environment ──
36
+ /** Reference to ~/.campfire/envs/ profile */
37
+ envSlug?: string;
38
+ /** Inline environment variable overrides */
39
+ env?: Record<string, string>;
40
+
41
+ // ── MCP ──
42
+ mcpServers?: Record<string, McpServerConfig>;
43
+
44
+ // ── Backend-specific ──
45
+ codexInternetAccess?: boolean;
46
+
47
+ // ── State ──
48
+ enabled: boolean;
49
+
50
+ // ── Tracking ──
51
+ createdAt: number;
52
+ updatedAt: number;
53
+ lastRunAt?: number;
54
+ lastSessionId?: string;
55
+ totalRuns: number;
56
+ consecutiveFailures: number;
57
+ }
58
+
59
+ // ─── Execution Record ──────────────────────────────────────────────────────
60
+
61
+ export interface AgentExecution {
62
+ executionId: string;
63
+ agentId: string;
64
+ sessionId: string;
65
+ input?: string;
66
+ trigger: "manual" | "webhook" | "schedule";
67
+ startedAt: number;
68
+ completedAt?: number;
69
+ success?: boolean;
70
+ error?: string;
71
+ costUsd?: number;
72
+ }
73
+
74
+ // ─── Input Types ───────────────────────────────────────────────────────────
75
+
76
+ export type AgentProfileCreateInput = Omit<
77
+ AgentProfile,
78
+ "id" | "createdAt" | "updatedAt" | "consecutiveFailures" | "totalRuns" | "lastRunAt" | "lastSessionId"
79
+ >;