codebuff-agent-acp 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.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Pure conversions between ACP content and Codebuff's message model.
3
+ *
4
+ * Kept side-effect-free and isolated from the agent so they're trivial to test.
5
+ */
6
+ /**
7
+ * Convert an ACP user prompt (a list of content blocks) into Codebuff's
8
+ * `{ prompt, content }`. Text / resource references become the prompt string;
9
+ * images become Codebuff multimodal `content`.
10
+ */
11
+ export function promptToCodebuff(blocks) {
12
+ const textParts = [];
13
+ const content = [];
14
+ for (const block of blocks) {
15
+ switch (block.type) {
16
+ case "text":
17
+ if (block.text)
18
+ textParts.push(block.text);
19
+ break;
20
+ case "image":
21
+ if (block.data) {
22
+ content.push({
23
+ type: "image",
24
+ image: block.data,
25
+ mediaType: block.mimeType ?? "image/png",
26
+ });
27
+ }
28
+ break;
29
+ case "resource_link": {
30
+ const uri = block.uri;
31
+ const name = block.name;
32
+ const ref = uri ?? name;
33
+ if (ref) {
34
+ const p = ref.startsWith("file://")
35
+ ? decodeURIComponent(ref.slice("file://".length))
36
+ : ref;
37
+ textParts.push(`@${p}`);
38
+ }
39
+ break;
40
+ }
41
+ case "resource": {
42
+ const text = block.resource?.text;
43
+ if (typeof text === "string")
44
+ textParts.push(text);
45
+ break;
46
+ }
47
+ default:
48
+ break;
49
+ }
50
+ }
51
+ const prompt = textParts.join("\n\n").trim() || " ";
52
+ return { prompt, content };
53
+ }
54
+ /** Extract readable text from a Codebuff run output. */
55
+ export function textFromOutput(output) {
56
+ switch (output.type) {
57
+ case "error":
58
+ return `⚠️ ${output.message}`;
59
+ case "structuredOutput":
60
+ try {
61
+ return `\`\`\`json\n${JSON.stringify(output.value, null, 2)}\n\`\`\``;
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ case "lastMessage":
67
+ return partsToText(output.value);
68
+ case "allMessages": {
69
+ const messages = output.value ?? [];
70
+ const lastAssistant = [...messages]
71
+ .reverse()
72
+ .find((m) => m.role === "assistant");
73
+ return lastAssistant ? partsToText(lastAssistant.content) : undefined;
74
+ }
75
+ default:
76
+ return undefined;
77
+ }
78
+ }
79
+ /** Flatten Codebuff message content parts into a single text string. */
80
+ export function partsToText(value) {
81
+ if (typeof value === "string")
82
+ return value;
83
+ if (!Array.isArray(value))
84
+ return undefined;
85
+ const out = [];
86
+ for (const part of value) {
87
+ const text = part?.text;
88
+ if (typeof text === "string")
89
+ out.push(text);
90
+ }
91
+ const joined = out.join("");
92
+ return joined.length > 0 ? joined : undefined;
93
+ }
94
+ //# sourceMappingURL=converters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.js","sourceRoot":"","sources":["../src/converters.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA2B;IAI1D,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,MAAM;gBACT,IAAI,KAAK,CAAC,IAAI;oBAAE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3C,MAAM;YACR,KAAK,OAAO;gBACV,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;oBACf,OAAO,CAAC,IAAI,CAAC;wBACX,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,KAAK,CAAC,IAAI;wBACjB,SAAS,EAAE,KAAK,CAAC,QAAQ,IAAI,WAAW;qBACzC,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM;YACR,KAAK,eAAe,EAAE,CAAC;gBACrB,MAAM,GAAG,GAAI,KAA0B,CAAC,GAAG,CAAC;gBAC5C,MAAM,IAAI,GAAI,KAA2B,CAAC,IAAI,CAAC;gBAC/C,MA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Q,GACX,MAAM,CAAC,KAAqD,IAAI,EAAE,CAAC;YACtE,MAAM,aAAa,GAAG,CAAC,GAAG,QAAQ,CAAC;iBAChC,OAAO,EAAE;iBACT,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;YACvC,OAAO,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxE,CAAC;QACD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAI,IAA0B,EAAE,IAAI,CAAC;QAC/C,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC"}
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Stdio entry point for the Codebuff ACP agent.
4
+ *
5
+ * stdout carries ACP JSON-RPC messages to the client; everything else is
6
+ * redirected to stderr so logs never corrupt the protocol stream.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Stdio entry point for the Codebuff ACP agent.
4
+ *
5
+ * stdout carries ACP JSON-RPC messages to the client; everything else is
6
+ * redirected to stderr so logs never corrupt the protocol stream.
7
+ */
8
+ import { Readable, Writable } from "node:stream";
9
+ import * as acp from "@agentclientprotocol/sdk";
10
+ import { runAcp } from "./agent.js";
11
+ import packageJson from "../package.json" with { type: "json" };
12
+ if (process.argv.includes("--version") || process.argv.includes("-v")) {
13
+ console.log(packageJson.version);
14
+ process.exit(0);
15
+ }
16
+ // stdout is the protocol channel — divert all logging to stderr.
17
+ console.log = console.error;
18
+ console.info = console.error;
19
+ console.warn = console.error;
20
+ console.debug = console.error;
21
+ process.on("unhandledRejection", (reason, promise) => {
22
+ console.error("Unhandled Rejection at:", promise, "reason:", reason);
23
+ });
24
+ const stream = acp.ndJsonStream(Writable.toWeb(process.stdout), Readable.toWeb(process.stdin));
25
+ const { connection, agent } = runAcp(stream);
26
+ async function shutdown() {
27
+ agent.dispose();
28
+ connection.close();
29
+ process.exit(0);
30
+ }
31
+ connection.closed.then(shutdown).catch(shutdown);
32
+ process.on("SIGTERM", () => void shutdown());
33
+ process.on("SIGINT", () => void shutdown());
34
+ // Keep the process alive while the connection is open.
35
+ process.stdin.resume();
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEhE,IAAI,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,EAAE,CAAC,CAAC;AAC7C,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC;AAE5C,uDAAuD;AACvD,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC"}
package/dist/lib.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { CodebuffAcpAgent, registerAcpHandlers, runAcp, type CodebuffAcpAgentOptions, type CodebuffClientLike, } from "./agent.js";
2
+ export { promptToCodebuff, textFromOutput, partsToText, type AgentOutput, } from "./converters.js";
3
+ export { saveSession, loadSessionRecord, listSessionRecords, deleteSession, titleFromPrompt, type SessionRecord, } from "./sessions.js";
4
+ export { isGatedTool, toolKind, toolTitle, toolLocations, toolScopeDescription, } from "./mapping.js";
5
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,EACN,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,aAAa,EACb,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
package/dist/lib.js ADDED
@@ -0,0 +1,6 @@
1
+ // Library entry point: re-exports the agent for programmatic use.
2
+ export { CodebuffAcpAgent, registerAcpHandlers, runAcp, } from "./agent.js";
3
+ export { promptToCodebuff, textFromOutput, partsToText, } from "./converters.js";
4
+ export { saveSession, loadSessionRecord, listSessionRecords, deleteSession, titleFromPrompt, } from "./sessions.js";
5
+ export { isGatedTool, toolKind, toolTitle, toolLocations, toolScopeDescription, } from "./mapping.js";
6
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,GAGP,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,WAAW,GAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,eAAe,GAEhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,aAAa,EACb,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Pure helpers that translate Codebuff tool calls into ACP tool-call shapes.
3
+ *
4
+ * Codebuff reports tool calls as `{ toolName, input, toolCallId }`. ACP models
5
+ * them as a `tool_call` / `tool_call_update` carrying `{ title, kind, status,
6
+ * locations, rawInput, rawOutput }`. These helpers bridge the two without any
7
+ * protocol I/O, so they're easy to unit-test.
8
+ */
9
+ import type { ToolKind } from "@agentclientprotocol/sdk";
10
+ type ToolInput = Record<string, any>;
11
+ export declare function isGatedTool(toolName: string): boolean;
12
+ export declare function toolKind(toolName: string): ToolKind;
13
+ /** Build a short, human-readable title for a tool call. */
14
+ export declare function toolTitle(toolName: string, input: ToolInput): string;
15
+ /** Filesystem locations a tool call touches, for client "follow-along" UIs. */
16
+ export declare function toolLocations(toolName: string, input: ToolInput): Array<{
17
+ path: string;
18
+ }>;
19
+ /** A reasonable guess at the "primary" argument, used as a permission scope hint. */
20
+ export declare function toolScopeDescription(toolName: string, input: ToolInput): string;
21
+ export {};
22
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAarC,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAkCD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAQnD;AASD,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAwDpE;AAWD,+EAA+E;AAC/E,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,SAAS,GACf,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAoCzB;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,SAAS,GACf,MAAM,CASR"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Pure helpers that translate Codebuff tool calls into ACP tool-call shapes.
3
+ *
4
+ * Codebuff reports tool calls as `{ toolName, input, toolCallId }`. ACP models
5
+ * them as a `tool_call` / `tool_call_update` carrying `{ title, kind, status,
6
+ * locations, rawInput, rawOutput }`. These helpers bridge the two without any
7
+ * protocol I/O, so they're easy to unit-test.
8
+ */
9
+ /** Tools that mutate the filesystem or shell and so warrant a permission prompt. */
10
+ const GATED_TOOLS = new Set([
11
+ "run_terminal_command",
12
+ "write_file",
13
+ "propose_write_file",
14
+ "str_replace",
15
+ "propose_str_replace",
16
+ "apply_patch",
17
+ "run_file_change_hooks",
18
+ ]);
19
+ export function isGatedTool(toolName) {
20
+ return GATED_TOOLS.has(toolName);
21
+ }
22
+ const READ_TOOLS = new Set([
23
+ "read_files",
24
+ "read_subtree",
25
+ "list_directory",
26
+ "lookup_agent_info",
27
+ ]);
28
+ const SEARCH_TOOLS = new Set(["find_files", "glob", "code_search"]);
29
+ const FETCH_TOOLS = new Set(["web_search", "read_docs"]);
30
+ const EXEC_TOOLS = new Set(["run_terminal_command", "browser_logs", "skill"]);
31
+ const EDIT_TOOLS = new Set([
32
+ "write_file",
33
+ "propose_write_file",
34
+ "str_replace",
35
+ "propose_str_replace",
36
+ "apply_patch",
37
+ "run_file_change_hooks",
38
+ ]);
39
+ const THINK_TOOLS = new Set([
40
+ "think_deeply",
41
+ "create_plan",
42
+ "write_todos",
43
+ "add_subgoal",
44
+ "update_subgoal",
45
+ "task_completed",
46
+ "end_turn",
47
+ "set_output",
48
+ "suggest_followups",
49
+ "add_message",
50
+ "set_messages",
51
+ "ask_user",
52
+ ]);
53
+ export function toolKind(toolName) {
54
+ if (READ_TOOLS.has(toolName))
55
+ return "read";
56
+ if (SEARCH_TOOLS.has(toolName))
57
+ return "search";
58
+ if (FETCH_TOOLS.has(toolName))
59
+ return "fetch";
60
+ if (EXEC_TOOLS.has(toolName))
61
+ return "execute";
62
+ if (EDIT_TOOLS.has(toolName))
63
+ return "edit";
64
+ if (THINK_TOOLS.has(toolName))
65
+ return "think";
66
+ return "other";
67
+ }
68
+ function firstString(...values) {
69
+ for (const v of values) {
70
+ if (typeof v === "string" && v.length > 0)
71
+ return v;
72
+ }
73
+ return undefined;
74
+ }
75
+ /** Build a short, human-readable title for a tool call. */
76
+ export function toolTitle(toolName, input) {
77
+ switch (toolName) {
78
+ case "run_terminal_command":
79
+ return `$ ${input.command ?? ""}`.trim();
80
+ case "write_file":
81
+ case "propose_write_file":
82
+ return `Write ${input.path ?? ""}`.trim();
83
+ case "str_replace":
84
+ case "propose_str_replace":
85
+ return `Edit ${input.path ?? ""}`.trim();
86
+ case "apply_patch": {
87
+ const op = input.operation ?? {};
88
+ const verb = op.type === "delete_file"
89
+ ? "Delete"
90
+ : op.type === "create_file"
91
+ ? "Create"
92
+ : "Edit";
93
+ return `${verb} ${op.path ?? ""}`.trim();
94
+ }
95
+ case "read_files":
96
+ return `Read ${pathsLabel(input.paths)}`;
97
+ case "read_subtree":
98
+ return `Read subtree ${pathsLabel(input.paths)}`;
99
+ case "list_directory":
100
+ return `List ${input.path ?? ""}`.trim();
101
+ case "find_files":
102
+ return `Find files: ${input.prompt ?? ""}`.trim();
103
+ case "glob":
104
+ return `Glob ${input.pattern ?? ""}`.trim();
105
+ case "code_search":
106
+ return `Search "${input.pattern ?? ""}"`.trim();
107
+ case "web_search":
108
+ return `Web search "${input.query ?? ""}"`.trim();
109
+ case "read_docs":
110
+ return `Docs: ${input.libraryTitle ?? ""}`.trim();
111
+ case "run_file_change_hooks":
112
+ return `Change hooks ${pathsLabel(input.files)}`;
113
+ case "spawn_agents":
114
+ case "spawn_agent_inline": {
115
+ const agents = input.agents ?? [];
116
+ return `Spawn ${agents
117
+ .map((a) => a.agent_type)
118
+ .filter(Boolean)
119
+ .join(", ") || "agent"}`;
120
+ }
121
+ case "ask_user":
122
+ return "Ask user";
123
+ case "write_todos":
124
+ return "Update plan";
125
+ default:
126
+ return toolName;
127
+ }
128
+ }
129
+ function pathsLabel(paths) {
130
+ if (!Array.isArray(paths))
131
+ return "";
132
+ const list = paths.filter((p) => typeof p === "string");
133
+ if (list.length === 0)
134
+ return "";
135
+ return list.length <= 2
136
+ ? list.join(", ")
137
+ : `${list[0]} +${list.length - 1} more`;
138
+ }
139
+ /** Filesystem locations a tool call touches, for client "follow-along" UIs. */
140
+ export function toolLocations(toolName, input) {
141
+ const out = [];
142
+ const push = (p) => {
143
+ if (typeof p === "string" && p.length > 0)
144
+ out.push({ path: p });
145
+ };
146
+ switch (toolName) {
147
+ case "write_file":
148
+ case "propose_write_file":
149
+ case "str_replace":
150
+ case "propose_str_replace":
151
+ push(input.path);
152
+ break;
153
+ case "apply_patch":
154
+ push(input.operation?.path);
155
+ break;
156
+ case "read_files":
157
+ case "read_subtree":
158
+ case "run_file_change_hooks":
159
+ (Array.isArray(input.paths)
160
+ ? input.paths
161
+ : Array.isArray(input.files)
162
+ ? input.files
163
+ : []).forEach(push);
164
+ break;
165
+ case "list_directory":
166
+ push(input.path);
167
+ break;
168
+ case "code_search":
169
+ case "glob":
170
+ push(input.cwd);
171
+ break;
172
+ default:
173
+ break;
174
+ }
175
+ return out;
176
+ }
177
+ /** A reasonable guess at the "primary" argument, used as a permission scope hint. */
178
+ export function toolScopeDescription(toolName, input) {
179
+ const loc = toolLocations(toolName, input)
180
+ .map((l) => l.path)
181
+ .join(", ");
182
+ if (loc)
183
+ return loc;
184
+ return (firstString(input.command, input.pattern, input.query, input.prompt) ??
185
+ toolName);
186
+ }
187
+ //# sourceMappingURL=mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,oFAAoF;AACpF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,sBAAsB;IACtB,YAAY;IACZ,oBAAoB;IACpB,aAAa;IACb,qBAAqB;IACrB,aAAa;IACb,uBAAuB;CACxB,CAAC,CAAC;AAEH,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,mBAAmB;CACpB,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AACpE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACzD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;AAC9E,MAA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AAgB;IAEhB,MAAM,GAAG,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC;SACvC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAClB,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,OAAO,CACL,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;QACpE,QAAQ,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Disk-backed session store.
3
+ *
4
+ * Codebuff's resumable conversation state is the JSON `RunState` returned by
5
+ * `client.run()`. We persist it (plus a little metadata) per session so that
6
+ * ACP clients can reopen, list, fork, and resume threads across restarts —
7
+ * mirroring what `claude-agent-acp` does with Claude's session files.
8
+ */
9
+ import type { RunState } from "@codebuff/sdk";
10
+ export interface SessionRecord {
11
+ sessionId: string;
12
+ cwd: string;
13
+ /** Best-effort title derived from the first user prompt. */
14
+ title: string | null;
15
+ createdAt: number;
16
+ updatedAt: number;
17
+ /** Codebuff resumable state. Absent until the first completed turn. */
18
+ runState?: RunState;
19
+ }
20
+ export declare function saveSession(record: SessionRecord): Promise<void>;
21
+ export declare function loadSessionRecord(sessionId: string): Promise<SessionRecord | undefined>;
22
+ export declare function deleteSession(sessionId: string): Promise<void>;
23
+ export declare function listSessionRecords(): Promise<SessionRecord[]>;
24
+ /** Truncate a prompt into a readable session title. */
25
+ export declare function titleFromPrompt(prompt: string): string;
26
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAuBD,wBAAsB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAItE;AAED,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAQpC;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOpE;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAmBnE;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAItD"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Disk-backed session store.
3
+ *
4
+ * Codebuff's resumable conversation state is the JSON `RunState` returned by
5
+ * `client.run()`. We persist it (plus a little metadata) per session so that
6
+ * ACP clients can reopen, list, fork, and resume threads across restarts —
7
+ * mirroring what `claude-agent-acp` does with Claude's session files.
8
+ */
9
+ import { promises as fs } from "node:fs";
10
+ import * as os from "node:os";
11
+ import * as path from "node:path";
12
+ /**
13
+ * Where session files live. Read lazily on each call so tests (and changing
14
+ * `CODEBUFF_ACP_HOME`) are respected without a process restart.
15
+ */
16
+ function storeDir() {
17
+ const home = process.env.CODEBUFF_ACP_HOME;
18
+ return home
19
+ ? path.join(home, "sessions")
20
+ : path.join(os.homedir(), ".codebuff-acp", "sessions");
21
+ }
22
+ function fileFor(sessionId) {
23
+ // Guard against path traversal — session ids are opaque to us.
24
+ const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "");
25
+ return path.join(storeDir(), `${safe}.json`);
26
+ }
27
+ async function ensureStore() {
28
+ await fs.mkdir(storeDir(), { recursive: true });
29
+ }
30
+ export async function saveSession(record) {
31
+ await ensureStore();
32
+ record.updatedAt = Date.now();
33
+ await fs.writeFile(fileFor(record.sessionId), JSON.stringify(record), "utf8");
34
+ }
35
+ export async function loadSessionRecord(sessionId) {
36
+ try {
37
+ const raw = await fs.readFile(fileFor(sessionId), "utf8");
38
+ return JSON.parse(raw);
39
+ }
40
+ catch (err) {
41
+ if (err.code === "ENOENT")
42
+ return undefined;
43
+ throw err;
44
+ }
45
+ }
46
+ export async function deleteSession(sessionId) {
47
+ try {
48
+ await fs.unlink(fileFor(sessionId));
49
+ }
50
+ catch (err) {
51
+ if (err.code === "ENOENT")
52
+ return;
53
+ throw err;
54
+ }
55
+ }
56
+ export async function listSessionRecords() {
57
+ let entries;
58
+ try {
59
+ entries = await fs.readdir(storeDir());
60
+ }
61
+ catch (err) {
62
+ if (err.code === "ENOENT")
63
+ return [];
64
+ throw err;
65
+ }
66
+ const records = [];
67
+ for (const entry of entries) {
68
+ if (!entry.endsWith(".json"))
69
+ continue;
70
+ try {
71
+ const raw = await fs.readFile(path.join(storeDir(), entry), "utf8");
72
+ records.push(JSON.parse(raw));
73
+ }
74
+ catch {
75
+ // Skip corrupt files rather than failing the whole listing.
76
+ }
77
+ }
78
+ return records.sort((a, b) => b.updatedAt - a.updatedAt);
79
+ }
80
+ /** Truncate a prompt into a readable session title. */
81
+ export function titleFromPrompt(prompt) {
82
+ const cleaned = prompt.replace(/\s+/g, " ").trim();
83
+ if (cleaned.length === 0)
84
+ return "New session";
85
+ return cleaned.length > 80 ? cleaned.slice(0, 79) + "…" : cleaned;
86
+ }
87
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAA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,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;AAC3D,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,aAAa,CAAC;IAC/C,OAAO,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AACpE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "codebuff-agent-acp",
3
+ "version": "0.1.0",
4
+ "description": "Use the Codebuff agent engine from any ACP-compatible client",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "main": "dist/lib.js",
10
+ "types": "dist/lib.d.ts",
11
+ "bin": {
12
+ "codebuff-agent-acp": "dist/index.js"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/lib.d.ts",
17
+ "import": "./dist/lib.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist/",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc",
27
+ "start": "node dist/index.js",
28
+ "dev": "tsx src/index.ts",
29
+ "typecheck": "tsc -p tsconfig.test.json --noEmit",
30
+ "lint": "oxlint src tests examples",
31
+ "lint:fix": "oxlint src tests examples --fix",
32
+ "format": "oxfmt src tests examples",
33
+ "format:check": "oxfmt --check src tests examples",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
36
+ "check": "npm run typecheck && npm run lint && npm run format:check && npm run test",
37
+ "prepublishOnly": "npm run build"
38
+ },
39
+ "keywords": [
40
+ "codebuff",
41
+ "freebuff",
42
+ "acp",
43
+ "agent",
44
+ "agent-client-protocol",
45
+ "zed"
46
+ ],
47
+ "homepage": "https://github.com/dvaJi/codebuff-agent-acp#readme",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/dvaJi/codebuff-agent-acp.git"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/dvaJi/codebuff-agent-acp/issues"
54
+ },
55
+ "author": {
56
+ "name": "Francisco Pizarro",
57
+ "email": "francisco_p@outlook.com"
58
+ },
59
+ "license": "Apache-2.0",
60
+ "engines": {
61
+ "node": ">=20"
62
+ },
63
+ "dependencies": {
64
+ "@agentclientprotocol/sdk": "^1.3.0",
65
+ "@codebuff/sdk": "^0.10.7"
66
+ },
67
+ "devDependencies": {
68
+ "@types/node": "^26.1.1",
69
+ "oxfmt": "^0.59.0",
70
+ "oxlint": "^1.74.0",
71
+ "tsx": "^4.23.1",
72
+ "typescript": "^7.0.2",
73
+ "vitest": "^4.1.10"
74
+ }
75
+ }