@anhlp/alp-runtime 0.0.0-stage → 0.0.1-beta.3

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 (97) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +7 -0
  3. package/README.md +6 -2
  4. package/dist/acp-transport.d.ts +130 -0
  5. package/dist/acp-transport.js +511 -0
  6. package/dist/antigravity-transport.d.ts +82 -0
  7. package/dist/antigravity-transport.js +619 -0
  8. package/dist/board-domain.d.ts +56 -0
  9. package/dist/board-domain.js +157 -0
  10. package/dist/board.d.ts +21 -0
  11. package/dist/board.js +69 -0
  12. package/dist/catalog.d.ts +31 -0
  13. package/dist/catalog.js +38 -0
  14. package/dist/claude-transport.d.ts +174 -0
  15. package/dist/claude-transport.js +734 -0
  16. package/dist/contracts.d.ts +170 -0
  17. package/dist/contracts.js +5 -0
  18. package/dist/events.d.ts +1 -0
  19. package/dist/events.js +0 -0
  20. package/dist/github.d.ts +10 -0
  21. package/dist/github.js +39 -0
  22. package/dist/handoff.d.ts +36 -0
  23. package/dist/handoff.js +73 -0
  24. package/dist/index.d.ts +26 -0
  25. package/dist/index.js +78 -0
  26. package/dist/language.d.ts +41 -0
  27. package/dist/language.js +68 -0
  28. package/dist/live.d.ts +48 -0
  29. package/dist/live.js +45 -0
  30. package/dist/mailbox.d.ts +24 -0
  31. package/dist/mailbox.js +36 -0
  32. package/dist/mcp-tools.d.ts +115 -0
  33. package/dist/mcp-tools.js +71 -0
  34. package/dist/permission-path.d.ts +2 -0
  35. package/dist/permission-path.js +44 -0
  36. package/dist/process-info.d.ts +14 -0
  37. package/dist/process-info.js +32 -0
  38. package/dist/providers.d.ts +28 -0
  39. package/dist/providers.js +71 -0
  40. package/dist/recall.d.ts +42 -0
  41. package/dist/recall.js +60 -0
  42. package/dist/resolve.d.ts +121 -0
  43. package/dist/resolve.js +238 -0
  44. package/dist/runtime-context.d.ts +43 -0
  45. package/dist/runtime-context.js +61 -0
  46. package/dist/runtime.d.ts +4 -0
  47. package/dist/runtime.js +3131 -0
  48. package/dist/session-config.d.ts +1997 -0
  49. package/dist/session-config.js +205 -0
  50. package/dist/session-state.d.ts +150 -0
  51. package/dist/session-state.js +0 -0
  52. package/dist/tool-detail.d.ts +81 -0
  53. package/dist/tool-detail.js +332 -0
  54. package/dist/tool-results.d.ts +12 -0
  55. package/dist/tool-results.js +25 -0
  56. package/dist/tools.d.ts +682 -0
  57. package/dist/tools.js +377 -0
  58. package/dist/transport.d.ts +47 -0
  59. package/dist/transport.js +169 -0
  60. package/dist/usage.d.ts +25 -0
  61. package/dist/usage.js +60 -0
  62. package/dist/workspace.d.ts +101 -0
  63. package/dist/workspace.js +259 -0
  64. package/dist/worktree-domain.d.ts +88 -0
  65. package/dist/worktree-domain.js +196 -0
  66. package/package.json +254 -4
  67. package/src/acp-transport.ts +508 -0
  68. package/src/antigravity-transport.ts +667 -0
  69. package/src/board-domain.ts +185 -0
  70. package/src/board.ts +80 -0
  71. package/src/catalog.ts +32 -0
  72. package/src/claude-transport.ts +843 -0
  73. package/src/contracts.ts +172 -0
  74. package/src/events.ts +1 -0
  75. package/src/github.ts +37 -0
  76. package/src/handoff.ts +86 -0
  77. package/src/index.ts +28 -0
  78. package/src/language.ts +102 -0
  79. package/src/live.ts +86 -0
  80. package/src/mailbox.ts +46 -0
  81. package/src/mcp-tools.ts +73 -0
  82. package/src/permission-path.ts +37 -0
  83. package/src/process-info.ts +40 -0
  84. package/src/providers.ts +84 -0
  85. package/src/recall.ts +85 -0
  86. package/src/resolve.ts +230 -0
  87. package/src/runtime-context.ts +49 -0
  88. package/src/runtime.ts +3765 -0
  89. package/src/session-config.ts +304 -0
  90. package/src/session-state.ts +151 -0
  91. package/src/tool-detail.ts +397 -0
  92. package/src/tool-results.ts +26 -0
  93. package/src/tools.ts +381 -0
  94. package/src/transport.ts +116 -0
  95. package/src/usage.ts +79 -0
  96. package/src/workspace.ts +318 -0
  97. package/src/worktree-domain.ts +216 -0
@@ -0,0 +1,332 @@
1
+ // packages/runtime/src/tool-detail.ts
2
+ var DETAIL_TEXT_CHARS = 65536;
3
+ var DETAIL_FILE_PATHS = 200;
4
+ var DETAIL_WEB_RESULTS = 50;
5
+ var ERROR_CHARS = 2e3;
6
+ var TOOL_FAILED = "Tool call failed";
7
+ var DETAIL_TYPES = ["shell", "read", "edit", "write", "search", "fetch", "sub_agent", "plan", "plain_text", "unknown"];
8
+ function clipText(text, max = DETAIL_TEXT_CHARS) {
9
+ if (text.length <= max) return text;
10
+ const marker = /\n… \(\d+ more characters\)$/.exec(text);
11
+ if (marker && marker.index <= max) return text;
12
+ const end = /[\uD800-\uDBFF]/.test(text[max - 1] ?? "") ? max - 1 : max;
13
+ return `${text.slice(0, end)}
14
+ \u2026 (${text.length - end} more characters)`;
15
+ }
16
+ function boundDetail(detail) {
17
+ if (detail.type === "shell" || detail.type === "unknown") return detail;
18
+ const bounded = {};
19
+ let cut = false;
20
+ for (const [key, value] of Object.entries(detail)) {
21
+ if (value === void 0) continue;
22
+ if (typeof value === "string") bounded[key] = key === "type" ? value : clipText(value);
23
+ else if (key === "filePaths" && Array.isArray(value)) {
24
+ bounded[key] = value.slice(0, DETAIL_FILE_PATHS).map((entry) => clipText(String(entry)));
25
+ cut = value.length > DETAIL_FILE_PATHS;
26
+ } else if (key === "webResults" && Array.isArray(value)) {
27
+ bounded[key] = value.slice(0, DETAIL_WEB_RESULTS).map((entry) => ({ title: clipText(entry.title), url: clipText(entry.url) }));
28
+ } else bounded[key] = value;
29
+ }
30
+ if (cut) bounded.truncated = true;
31
+ return bounded;
32
+ }
33
+ function toolError(text) {
34
+ const value = typeof text === "string" ? text.trim().replace(/^<tool_use_error>([\s\S]*)<\/tool_use_error>$/, "$1").trim() : "";
35
+ return value ? clipText(value, ERROR_CHARS) : TOOL_FAILED;
36
+ }
37
+ var str = (value) => typeof value === "string" && value.trim() ? value : void 0;
38
+ var int = (value) => typeof value === "number" && Number.isInteger(value) ? value : void 0;
39
+ var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
40
+ var pathOf = (input) => str(input?.file_path) ?? str(input?.filePath) ?? str(input?.path) ?? str(input?.notebook_path) ?? str(input?.AbsolutePath) ?? str(input?.TargetFile);
41
+ var defined = (value) => Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
42
+ var typed = (detail) => boundDetail(defined(detail));
43
+ function resultText(content) {
44
+ if (typeof content === "string") return content;
45
+ if (Array.isArray(content)) {
46
+ const parts = content.map((part) => typeof part === "string" ? part : typeof part?.text === "string" ? part.text : "").filter(Boolean);
47
+ return parts.length ? parts.join("\n") : void 0;
48
+ }
49
+ return void 0;
50
+ }
51
+ var READ_GUTTER = /^\s*(\d+)(?:\t|→)(.*)$/;
52
+ function stripReadGutter(text) {
53
+ const body = text.replace(/\r\n/g, "\n").replace(/\n*<system-reminder>[\s\S]*?<\/system-reminder>\s*$/g, "");
54
+ const out = [];
55
+ let start;
56
+ let previous;
57
+ for (const line of body.split("\n")) {
58
+ if (!line) {
59
+ out.push(line);
60
+ continue;
61
+ }
62
+ const match = READ_GUTTER.exec(line);
63
+ if (!match) return void 0;
64
+ const number = Number.parseInt(match[1], 10);
65
+ if (previous !== void 0 && number !== previous + 1) return void 0;
66
+ start ??= number;
67
+ previous = number;
68
+ out.push(match[2]);
69
+ }
70
+ return start === void 0 ? void 0 : { content: out.join("\n"), startLine: start };
71
+ }
72
+ function structuredPatch(patch) {
73
+ if (!Array.isArray(patch) || !patch.length) return void 0;
74
+ const hunks = patch.map((hunk) => {
75
+ const lines = Array.isArray(hunk?.lines) ? hunk.lines.map(String) : [];
76
+ return [`@@ -${hunk?.oldStart ?? 0},${hunk?.oldLines ?? 0} +${hunk?.newStart ?? 0},${hunk?.newLines ?? 0} @@`, ...lines].join("\n");
77
+ });
78
+ return `${hunks.join("\n")}
79
+ `;
80
+ }
81
+ function replacementsDiff(edits) {
82
+ const side = (text, mark) => String(text ?? "").split("\n").map((line) => `${mark}${line}`);
83
+ return `${edits.map((edit) => ["@@", ...side(edit.old_string, "-"), ...side(edit.new_string, "+")].join("\n")).join("\n")}
84
+ `;
85
+ }
86
+ var TODO_MARK = { completed: "[x]", in_progress: "[~]", pending: "[ ]" };
87
+ function claudeToolDetail(name, rawInput, result) {
88
+ if (name === "Bash") return void 0;
89
+ const input = record(rawInput) ?? {};
90
+ const ok = result && !result.error;
91
+ const text = ok ? result.text : void 0;
92
+ const out = ok ? record(result.structured) : void 0;
93
+ const unknown = () => ({ type: "unknown", input: rawInput ?? null, output: result?.text ?? null });
94
+ const filePath = pathOf(input);
95
+ switch (name) {
96
+ case "Read": {
97
+ if (!filePath) return unknown();
98
+ const file = out?.type === "text" ? record(out.file) : void 0;
99
+ const stripped = file ? void 0 : text !== void 0 ? stripReadGutter(text) : void 0;
100
+ const content = typeof file?.content === "string" ? file.content : stripped?.content ?? text;
101
+ return typed({ type: "read", filePath, content, offset: int(file?.startLine) ?? stripped?.startLine ?? int(input.offset), limit: int(input.limit) });
102
+ }
103
+ case "Write":
104
+ if (!filePath) return unknown();
105
+ return typed({ type: "write", filePath, content: typeof input.content === "string" ? input.content : void 0 });
106
+ case "Edit":
107
+ if (!filePath) return unknown();
108
+ return typed({ type: "edit", filePath, oldString: typeof input.old_string === "string" ? input.old_string : void 0, newString: typeof input.new_string === "string" ? input.new_string : void 0, unifiedDiff: structuredPatch(out?.structuredPatch) });
109
+ case "MultiEdit": {
110
+ if (!filePath) return unknown();
111
+ const edits = Array.isArray(input.edits) ? input.edits.filter(record) : [];
112
+ if (edits.length === 1) return typed({ type: "edit", filePath, oldString: str(edits[0].old_string) ?? void 0, newString: typeof edits[0].new_string === "string" ? edits[0].new_string : void 0, unifiedDiff: structuredPatch(out?.structuredPatch) });
113
+ return typed({ type: "edit", filePath, unifiedDiff: structuredPatch(out?.structuredPatch) ?? (edits.length ? replacementsDiff(edits) : void 0) });
114
+ }
115
+ case "NotebookEdit":
116
+ if (!filePath) return unknown();
117
+ return typed({ type: "edit", filePath, oldString: typeof out?.old_source === "string" ? out.old_source : void 0, newString: input.edit_mode === "delete" ? void 0 : typeof input.new_source === "string" ? input.new_source : void 0 });
118
+ case "Grep": {
119
+ const query = str(input.pattern);
120
+ if (!query) return unknown();
121
+ const structured = out && Array.isArray(out.filenames);
122
+ return typed({
123
+ type: "search",
124
+ query,
125
+ toolName: "grep",
126
+ content: structured ? typeof out.content === "string" ? out.content : void 0 : text,
127
+ filePaths: structured && out.filenames.length ? out.filenames.map(String) : void 0,
128
+ numFiles: structured ? int(out.numFiles) : void 0,
129
+ numMatches: structured ? int(out.numMatches) : void 0
130
+ });
131
+ }
132
+ case "Glob": {
133
+ const query = str(input.pattern);
134
+ if (!query) return unknown();
135
+ const structured = out && Array.isArray(out.filenames);
136
+ return typed({
137
+ type: "search",
138
+ query,
139
+ toolName: "glob",
140
+ content: structured ? void 0 : text,
141
+ filePaths: structured && out.filenames.length ? out.filenames.map(String) : void 0,
142
+ numFiles: structured ? int(out.numFiles) : void 0,
143
+ truncated: structured && typeof out.truncated === "boolean" ? out.truncated : void 0
144
+ });
145
+ }
146
+ case "WebFetch": {
147
+ const url = str(input.url) ?? str(out?.url);
148
+ if (!url) return unknown();
149
+ return typed({ type: "fetch", url, prompt: str(input.prompt), result: typeof out?.result === "string" ? out.result : text, code: int(out?.code) });
150
+ }
151
+ case "WebSearch": {
152
+ const query = str(input.query) ?? str(out?.query);
153
+ if (!query) return unknown();
154
+ const entries = Array.isArray(out?.results) ? out.results : [];
155
+ const webResults = entries.flatMap((entry) => Array.isArray(record(entry)?.content) ? entry.content : []).filter((hit) => typeof hit?.title === "string" && typeof hit?.url === "string").map((hit) => ({ title: hit.title, url: hit.url }));
156
+ const notes = entries.filter((entry) => typeof entry === "string");
157
+ return typed({ type: "search", query, toolName: "web_search", webResults: webResults.length ? webResults : void 0, content: out ? notes.length ? notes.join("\n") : void 0 : text });
158
+ }
159
+ case "Task":
160
+ case "Agent": {
161
+ const report = out && Array.isArray(out.content) ? resultText(out.content) : text;
162
+ return typed({ type: "sub_agent", subAgentType: str(input.subagent_type), description: str(input.description) ?? str(input.prompt), log: report });
163
+ }
164
+ case "ExitPlanMode":
165
+ return str(input.plan) ? typed({ type: "plan", text: input.plan }) : unknown();
166
+ case "Skill":
167
+ return str(input.skill) ? typed({ type: "plain_text", label: input.skill, text }) : unknown();
168
+ case "TodoWrite": {
169
+ const todos = Array.isArray(input.todos) ? input.todos.filter(record) : [];
170
+ if (!todos.length) return unknown();
171
+ return typed({ type: "plain_text", label: "Todos", text: todos.map((todo) => `${TODO_MARK[todo.status] ?? "[ ]"} ${String(todo.content ?? todo.activeForm ?? "")}`).join("\n") });
172
+ }
173
+ default:
174
+ return unknown();
175
+ }
176
+ }
177
+ function acpText(content) {
178
+ const parts = (Array.isArray(content) ? content : []).map((part) => part?.type === "content" && part.content?.type === "text" ? part.content.text : "").filter(Boolean);
179
+ return parts.length ? parts.join("\n") : void 0;
180
+ }
181
+ function acpToolDetail(call) {
182
+ const kind = call.kind ?? "other";
183
+ if (kind === "execute") return void 0;
184
+ const input = record(call.rawInput);
185
+ const output = record(call.rawOutput);
186
+ const locations = (Array.isArray(call.locations) ? call.locations : []).map(record).filter((entry) => Boolean(str(entry?.path)));
187
+ const diffs = (Array.isArray(call.content) ? call.content : []).map(record).filter((part) => part?.type === "diff" && Boolean(str(part.path)));
188
+ const text = acpText(call.content) ?? (typeof call.rawOutput === "string" ? call.rawOutput : str(output?.output) ?? str(output?.content));
189
+ const title = str(call.title);
190
+ const filePath = locations[0]?.path ?? pathOf(input);
191
+ const unknown = () => ({ type: "unknown", input: call.rawInput ?? null, output: call.rawOutput ?? text ?? null });
192
+ switch (kind) {
193
+ case "read":
194
+ if (!filePath) return unknown();
195
+ return typed({ type: "read", filePath, content: text, offset: int(input?.offset) ?? int(input?.line) ?? int(locations[0]?.line), limit: int(input?.limit) });
196
+ case "edit":
197
+ case "delete": {
198
+ const diff = diffs[0];
199
+ if (diff) {
200
+ const oldText = typeof diff.oldText === "string" ? diff.oldText : void 0;
201
+ const newText = typeof diff.newText === "string" ? diff.newText : void 0;
202
+ if (oldText === void 0 && newText !== void 0 && kind === "edit") return typed({ type: "write", filePath: diff.path, content: newText });
203
+ return typed({ type: "edit", filePath: diff.path, oldString: oldText, newString: kind === "delete" ? void 0 : newText });
204
+ }
205
+ if (!filePath) return unknown();
206
+ const oldString = str(input?.old_string) ?? str(input?.oldText) ?? str(input?.old_str);
207
+ const newString = str(input?.new_string) ?? str(input?.newText) ?? str(input?.new_str);
208
+ const unifiedDiff = str(input?.diff) ?? str(input?.patch) ?? str(input?.unified_diff);
209
+ if (kind === "edit" && !oldString && !unifiedDiff && typeof input?.content === "string") return typed({ type: "write", filePath, content: input.content });
210
+ return typed({ type: "edit", filePath, oldString, newString, unifiedDiff });
211
+ }
212
+ case "move": {
213
+ const from = filePath ?? str(input?.from) ?? str(input?.source);
214
+ const to = locations[1]?.path ?? str(input?.to) ?? str(input?.destination) ?? str(input?.new_path);
215
+ if (!from) return unknown();
216
+ return typed({ type: "plain_text", label: title ?? "Move", text: to ? `${from} \u2192 ${to}` : from });
217
+ }
218
+ case "search": {
219
+ const query = str(input?.query) ?? str(input?.pattern) ?? str(input?.q) ?? title;
220
+ if (!query) return unknown();
221
+ const paths = locations.map((entry) => entry.path);
222
+ return typed({ type: "search", query, toolName: "search", content: text, filePaths: paths.length ? paths : void 0 });
223
+ }
224
+ case "fetch": {
225
+ const url = str(input?.url);
226
+ if (url) return typed({ type: "fetch", url, prompt: str(input?.prompt), result: text });
227
+ const query = str(input?.query) ?? str(input?.q);
228
+ if (query) return typed({ type: "search", query, toolName: "web_search", content: text });
229
+ return unknown();
230
+ }
231
+ case "think":
232
+ return typed({ type: "plain_text", label: title ?? "Thinking", text: text ?? str(input?.thought) ?? str(input?.text) });
233
+ default:
234
+ return unknown();
235
+ }
236
+ }
237
+ function antigravityToolDetail(info) {
238
+ const tool = record(info);
239
+ const parameters = record(tool?.parameters) ?? {};
240
+ const output = typeof tool?.output === "string" && tool.output ? tool.output : void 0;
241
+ const filePath = str(parameters.AbsolutePath) ?? str(parameters.TargetFile);
242
+ switch (tool?.name) {
243
+ case "run_command":
244
+ if (typeof parameters.CommandLine === "string") return { type: "shell", command: parameters.CommandLine, ...str(parameters.Cwd) ? { cwd: parameters.Cwd } : {}, output: output ?? "" };
245
+ break;
246
+ case "view_file":
247
+ if (filePath) return typed({ type: "read", filePath, content: output, offset: int(parameters.StartLine), limit: int(parameters.EndLine) !== void 0 && int(parameters.StartLine) !== void 0 ? parameters.EndLine - parameters.StartLine + 1 : void 0 });
248
+ break;
249
+ case "write_to_file":
250
+ if (filePath) return typed({ type: "write", filePath, content: typeof parameters.CodeContent === "string" ? parameters.CodeContent : void 0 });
251
+ break;
252
+ case "replace_file_content":
253
+ case "multi_replace_file_content":
254
+ if (filePath) return typed({ type: "edit", filePath, oldString: typeof parameters.TargetContent === "string" ? parameters.TargetContent : void 0, newString: typeof parameters.ReplacementContent === "string" ? parameters.ReplacementContent : void 0 });
255
+ break;
256
+ }
257
+ return { type: "unknown", input: tool?.parameters ?? null, output: tool?.error?.message ?? output ?? null };
258
+ }
259
+ function withHeaders(path, diff) {
260
+ if (/^(--- |diff --git )/.test(diff)) return diff;
261
+ if (diff.startsWith("+++ ")) return `--- a/${path}
262
+ ${diff}`;
263
+ return `--- a/${path}
264
+ +++ b/${path}
265
+ ${diff}`;
266
+ }
267
+ var looksLikeDiff = (text) => /^(@@ |--- |\+\+\+ |diff --git )/.test(text);
268
+ function changeDiff(kind, diff) {
269
+ if (kind !== "add" && kind !== "delete" || !diff || looksLikeDiff(diff)) return diff;
270
+ const lines = diff.replace(/\r\n?/g, "\n").replace(/\n$/, "").split("\n");
271
+ const n = lines.length;
272
+ return kind === "add" ? `@@ -0,0 +1,${n} @@
273
+ ${lines.map((line) => `+${line}`).join("\n")}
274
+ ` : `@@ -1,${n} +0,0 @@
275
+ ${lines.map((line) => `-${line}`).join("\n")}
276
+ `;
277
+ }
278
+ function codexToolCall(item, done) {
279
+ const raw = String(item?.status ?? "");
280
+ const status = raw === "inProgress" || !raw && !done ? "running" : raw === "failed" || raw === "declined" ? "failed" : "completed";
281
+ const failed = (error) => status === "failed" ? { error: toolError(error) } : {};
282
+ if (item?.type === "fileChange") {
283
+ const changes = (Array.isArray(item.changes) ? item.changes : []).filter((change) => str(change?.path));
284
+ if (!changes.length) return { name: "apply_patch", status, detail: { type: "unknown", input: item.changes ?? null, output: null }, ...failed() };
285
+ let detail;
286
+ if (changes.length === 1) {
287
+ const [change] = changes;
288
+ const diff = typeof change.diff === "string" ? change.diff : "";
289
+ const kind = change.kind?.type ?? change.kind;
290
+ detail = kind === "add" && !looksLikeDiff(diff) ? typed({ type: "write", filePath: change.path, content: diff || void 0 }) : typed({ type: "edit", filePath: change.path, unifiedDiff: changeDiff(kind, diff) || void 0 });
291
+ } else {
292
+ const diff = changes.map((change) => {
293
+ const text = typeof change.diff === "string" ? changeDiff(change.kind?.type ?? change.kind, change.diff) : "";
294
+ return text ? withHeaders(change.path, text.endsWith("\n") ? text : `${text}
295
+ `) : `--- a/${change.path}
296
+ +++ b/${change.path}
297
+ `;
298
+ }).join("");
299
+ detail = typed({ type: "edit", filePath: changes[0].path, unifiedDiff: diff });
300
+ }
301
+ return { name: "apply_patch", status, detail, ...failed() };
302
+ }
303
+ if (item?.type === "webSearch") {
304
+ const query = str(item.query) ?? str(item.action?.query) ?? (Array.isArray(item.action?.queries) ? str(item.action.queries[0]) : void 0) ?? "";
305
+ return { name: "web_search", status, detail: typed({ type: "search", query, toolName: "web_search" }), ...failed() };
306
+ }
307
+ if (item?.type === "mcpToolCall") {
308
+ return { name: `mcp__${String(item.server ?? "")}__${String(item.tool ?? "")}`, status, detail: { type: "unknown", input: item.arguments ?? null, output: item.result ?? null }, ...failed(item.error?.message) };
309
+ }
310
+ if (item?.type === "collabAgentToolCall") {
311
+ return { name: "Sub-agent", status, detail: typed({ type: "sub_agent", subAgentType: "Sub-agent", description: str(item.prompt) }), ...failed(item.error?.message) };
312
+ }
313
+ return void 0;
314
+ }
315
+ export {
316
+ DETAIL_FILE_PATHS,
317
+ DETAIL_TEXT_CHARS,
318
+ DETAIL_TYPES,
319
+ DETAIL_WEB_RESULTS,
320
+ ERROR_CHARS,
321
+ TOOL_FAILED,
322
+ acpText,
323
+ acpToolDetail,
324
+ antigravityToolDetail,
325
+ boundDetail,
326
+ claudeToolDetail,
327
+ clipText,
328
+ codexToolCall,
329
+ resultText,
330
+ stripReadGutter,
331
+ toolError
332
+ };
@@ -0,0 +1,12 @@
1
+ export declare const errorData: (error: unknown) => {
2
+ code?: string | undefined;
3
+ message: string;
4
+ };
5
+ export declare const toolResult: (success: boolean, value: unknown) => {
6
+ success: boolean;
7
+ contentItems: {
8
+ type: string;
9
+ text: string;
10
+ }[];
11
+ };
12
+ export declare const plainObject: (value: unknown, keys: string[]) => value is Record<string, any>;
@@ -0,0 +1,25 @@
1
+ // packages/runtime/src/tool-results.ts
2
+ import { promptSafe } from "@anhlp/alp-core/promptsafe";
3
+ import { scrubText } from "@anhlp/alp-core/log";
4
+ var errorData = (error) => ({
5
+ // It reaches timelines, run logs and clients: a provider's complaint may quote a credential.
6
+ message: scrubText(error instanceof Error ? error.message : String(error)),
7
+ // A transport marks a request the provider may have received before it failed (ALPD §66).
8
+ ...error?.outcomeUnknown ? { code: "outcome_unknown" } : {}
9
+ });
10
+ var toolResult = (success, value) => ({
11
+ success,
12
+ contentItems: [
13
+ {
14
+ type: "inputText",
15
+ // Results carry what other agents wrote and commands printed.
16
+ text: promptSafe(JSON.stringify(value))
17
+ }
18
+ ]
19
+ });
20
+ var plainObject = (value, keys) => !!value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).every((key) => keys.includes(key));
21
+ export {
22
+ errorData,
23
+ plainObject,
24
+ toolResult
25
+ };