@causyne/agent 1.19.0 → 1.20.5
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.
- package/README.md +0 -18
- package/package.json +1 -1
- package/src/acp/client.js +2 -1
- package/src/acp/client.ts +2 -1
- package/src/acp/server.js +5 -6
- package/src/acp/server.ts +4 -6
- package/src/agentLoop.d.ts +1 -0
- package/src/agentLoop.js +505 -241
- package/src/agentLoop.ts +527 -258
- package/src/agentPolicy.js +9 -0
- package/src/agentPolicy.ts +9 -0
- package/src/approvalPolicy.js +55 -0
- package/src/approvalPolicy.ts +66 -0
- package/src/browser/browserRuntime.js +217 -14
- package/src/browser/browserRuntime.ts +255 -14
- package/src/browser/causyneBrowser.js +1215 -68
- package/src/browser/causyneBrowser.ts +1340 -72
- package/src/cliMode.js +66 -37
- package/src/commands.js +343 -72
- package/src/config.js +22 -12
- package/src/continuum/ingest.js +1 -1
- package/src/continuum/ingest.ts +1 -1
- package/src/continuum/ui/continuumPicker.js +18 -1
- package/src/continuum/ui/continuumPicker.ts +19 -1
- package/src/dynamicCatalogue.js +87 -20
- package/src/dynamicCatalogue.ts +85 -15
- package/src/launchIntent.js +40 -0
- package/src/launchIntent.ts +49 -0
- package/src/memoryManager.js +36 -8
- package/src/modelCatalogue.js +2 -0
- package/src/planCache.js +320 -11
- package/src/planCache.ts +402 -13
- package/src/providers/acp.js +67 -1
- package/src/providers/acp.ts +65 -2
- package/src/providers/antigravity.d.ts +5 -1
- package/src/providers/antigravity.js +643 -32
- package/src/providers/antigravity.ts +671 -33
- package/src/providers/base.d.ts +9 -0
- package/src/providers/factory.js +2 -0
- package/src/providers/pi.js +157 -0
- package/src/providers/pi.ts +144 -0
- package/src/provisioning/capabilityProvisioner.js +17 -0
- package/src/provisioning/capabilityTools.js +1 -1
- package/src/sandbox.js +30 -39
- package/src/sessionJournal.js +66 -10
- package/src/sessionJournal.ts +84 -10
- package/src/taskShape.js +9 -9
- package/src/taskShape.ts +9 -9
- package/src/timeMachine.js +124 -0
- package/src/timeMachine.ts +141 -0
- package/src/toolPacks.js +4 -10
- package/src/tools/archive.js +196 -59
- package/src/tools/archive.ts +220 -0
- package/src/tools/browserAutomator.js +78 -9
- package/src/tools/browserAutomator.ts +90 -9
- package/src/tools/desktopOpen.js +114 -31
- package/src/tools/desktopOpen.ts +144 -0
- package/src/tools/gitExec.js +5 -3
- package/src/tools/nativeEngine.js +4 -3
- package/src/tools/nativeEngine.ts +5 -3
- package/src/tools/openSourceToolProvisioner.js +5 -4
- package/src/tools/openSourceToolProvisioner.ts +5 -4
- package/src/tools/registry.js +3 -0
- package/src/tools/screenshot.js +55 -71
- package/src/tools/screenshot.ts +70 -0
- package/src/tools/sysRun.js +284 -117
- package/src/tools/sysRun.ts +347 -0
- package/src/tools/toolSelfRepair.js +109 -2
- package/src/tools/toolSelfRepair.ts +100 -2
- package/src/tools/updatePlan.js +49 -1
- package/src/tools/updatePlan.ts +43 -1
- package/src/tools/viewImage.js +93 -78
- package/src/tools/viewImage.ts +116 -0
- package/src/tools/webFetch.js +20 -6
- package/src/tools/webFetch.ts +26 -6
- package/src/tui/block.d.ts +1 -0
- package/src/tui/chatRenderer.d.ts +21 -0
- package/src/tui/chatRenderer.js +118 -45
- package/src/tui/clipboardSync.js +28 -1
- package/src/tui/clipboardSync.ts +26 -1
- package/src/tui/codeProgress.js +299 -0
- package/src/tui/codeProgress.ts +304 -0
- package/src/tui/codeStreamRenderer.js +116 -0
- package/src/tui/codeStreamRenderer.ts +124 -0
- package/src/tui/commandPresentation.js +11 -0
- package/src/tui/commandPresentation.ts +18 -0
- package/src/tui/completion.js +45 -13
- package/src/tui/composerControls.js +66 -0
- package/src/tui/composerControls.ts +78 -0
- package/src/tui/diff.d.ts +2 -0
- package/src/tui/home.js +4 -2
- package/src/tui/homeTransition.js +21 -0
- package/src/tui/homeTransition.ts +27 -0
- package/src/tui/homeView.js +62 -0
- package/src/tui/homeView.ts +91 -0
- package/src/tui/layout.js +46 -0
- package/src/tui/layout.ts +52 -0
- package/src/tui/messageActionPlacement.js +16 -0
- package/src/tui/messageActionPlacement.ts +25 -0
- package/src/tui/messageInteraction.js +221 -0
- package/src/tui/messageInteraction.ts +275 -0
- package/src/tui/modelPicker.js +13 -0
- package/src/tui/modelPicker.ts +12 -0
- package/src/tui/mouseHover.js +6 -0
- package/src/tui/mouseHover.ts +5 -0
- package/src/tui/prompt.js +199 -52
- package/src/tui/resizeRecovery.js +15 -0
- package/src/tui/resizeRecovery.ts +27 -0
- package/src/tui/scrollInteraction.js +97 -0
- package/src/tui/scrollInteraction.ts +189 -0
- package/src/tui/sessionLayout.js +12 -0
- package/src/tui/sessionLayout.ts +12 -0
- package/src/tui/sessionPicker.js +280 -0
- package/src/tui/sessionPicker.ts +364 -0
- package/src/tui/sessionSidebar.js +78 -0
- package/src/tui/sessionSidebar.ts +95 -0
- package/src/tui/setup.js +1 -1
- package/src/tui/setup.ts +1 -1
- package/src/tui/stageSurface.js +128 -57
- package/src/tui/statusLine.js +5 -5
- package/src/tui/text.d.ts +5 -0
- package/src/tui/textLayout.js +23 -0
- package/src/tui/textLayout.ts +28 -0
- package/src/tui/viewport.js +204 -279
- package/src/tui/viewport.ts +326 -0
- package/src/types/contracts.ts +54 -0
- package/src/utils/paths.js +5 -4
- package/src/utils/paths.ts +5 -5
package/src/providers/acp.js
CHANGED
|
@@ -19,6 +19,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
19
19
|
activeSessionId = null;
|
|
20
20
|
currentTurnChunkHandler = null;
|
|
21
21
|
currentTurnReasoningHandler = null;
|
|
22
|
+
currentTurnNativeActionHandler = null;
|
|
23
|
+
liveFileActions = new Map();
|
|
22
24
|
constructor(config = {}) {
|
|
23
25
|
super(config);
|
|
24
26
|
const providerStr = String(config.provider || '').toLowerCase().trim();
|
|
@@ -63,7 +65,7 @@ export class AcpProvider extends LLMProvider {
|
|
|
63
65
|
}
|
|
64
66
|
formatConversation(messages, tools = []) {
|
|
65
67
|
const lines = [];
|
|
66
|
-
lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.');
|
|
68
|
+
lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. If the user writes in English, you must respond strictly in English. Default to English for all responses and reasoning. Never default to Indonesian.');
|
|
67
69
|
if (tools && tools.length > 0) {
|
|
68
70
|
const toolSummaries = tools.map(t => {
|
|
69
71
|
const name = t.name || t.function?.name || 'unknown';
|
|
@@ -74,6 +76,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
74
76
|
}).join('\n');
|
|
75
77
|
lines.push(`[Available Tools]\nYou may invoke tools when needed by outputting:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\n\n${toolSummaries}`);
|
|
76
78
|
}
|
|
79
|
+
const seenToolOutputs = new Set();
|
|
80
|
+
const seenAssistantCalls = new Set();
|
|
77
81
|
for (const msg of messages) {
|
|
78
82
|
const role = msg.role === 'user'
|
|
79
83
|
? 'User'
|
|
@@ -91,10 +95,22 @@ export class AcpProvider extends LLMProvider {
|
|
|
91
95
|
else if (Array.isArray(msg.content)) {
|
|
92
96
|
text = msg.content.map((c) => typeof c === 'string' ? c : (c?.text || '')).filter(Boolean).join('\n');
|
|
93
97
|
}
|
|
98
|
+
if (msg.role === 'tool' && text.trim()) {
|
|
99
|
+
const normalized = text.trim();
|
|
100
|
+
if (seenToolOutputs.has(normalized)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
seenToolOutputs.add(normalized);
|
|
104
|
+
}
|
|
94
105
|
if (msg.tool_calls && Array.isArray(msg.tool_calls)) {
|
|
95
106
|
for (const tc of msg.tool_calls) {
|
|
96
107
|
const fn = tc.function || {};
|
|
97
108
|
const fnArgs = typeof fn.arguments === 'string' ? fn.arguments : JSON.stringify(fn.arguments || {});
|
|
109
|
+
const callSig = `${fn.name}:${fnArgs}`;
|
|
110
|
+
if (seenAssistantCalls.has(callSig)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
seenAssistantCalls.add(callSig);
|
|
98
114
|
text += `\n<tool_call>{"name": "${fn.name}", "arguments": ${fnArgs}}</tool_call>`;
|
|
99
115
|
}
|
|
100
116
|
}
|
|
@@ -124,6 +140,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
124
140
|
}).join('\n');
|
|
125
141
|
pending.push(`[Available Tools]\nYou may invoke tools when needed by outputting:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\n\n${toolSummaries}`);
|
|
126
142
|
}
|
|
143
|
+
const seenToolOutputs = new Set();
|
|
144
|
+
const seenAssistantCalls = new Set();
|
|
127
145
|
for (const msg of messages) {
|
|
128
146
|
const role = this._roleLabel(msg);
|
|
129
147
|
let text = '';
|
|
@@ -133,10 +151,22 @@ export class AcpProvider extends LLMProvider {
|
|
|
133
151
|
else if (Array.isArray(msg.content)) {
|
|
134
152
|
text = msg.content.map((c) => typeof c === 'string' ? c : (c?.text || '')).filter(Boolean).join('\n');
|
|
135
153
|
}
|
|
154
|
+
if (msg.role === 'tool' && text.trim()) {
|
|
155
|
+
const normalized = text.trim();
|
|
156
|
+
if (seenToolOutputs.has(normalized)) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
seenToolOutputs.add(normalized);
|
|
160
|
+
}
|
|
136
161
|
if (msg.tool_calls && Array.isArray(msg.tool_calls)) {
|
|
137
162
|
for (const tc of msg.tool_calls) {
|
|
138
163
|
const fn = tc.function || {};
|
|
139
164
|
const fnArgs = typeof fn.arguments === 'string' ? fn.arguments : JSON.stringify(fn.arguments || {});
|
|
165
|
+
const callSig = `${fn.name}:${fnArgs}`;
|
|
166
|
+
if (seenAssistantCalls.has(callSig)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
seenAssistantCalls.add(callSig);
|
|
140
170
|
text += `\n<tool_call>{"name": "${fn.name}", "arguments": ${fnArgs}}</tool_call>`;
|
|
141
171
|
}
|
|
142
172
|
}
|
|
@@ -263,6 +293,37 @@ export class AcpProvider extends LLMProvider {
|
|
|
263
293
|
this.currentTurnReasoningHandler(thought);
|
|
264
294
|
}
|
|
265
295
|
}
|
|
296
|
+
else if (updateObj.sessionUpdate === 'agent_message_chunk') {
|
|
297
|
+
const text = updateObj.content?.type === 'text' ? updateObj.content.text : '';
|
|
298
|
+
if (text && this.currentTurnChunkHandler)
|
|
299
|
+
this.currentTurnChunkHandler(text);
|
|
300
|
+
}
|
|
301
|
+
else if (updateObj.sessionUpdate === 'tool_call' || updateObj.sessionUpdate === 'tool_call_update') {
|
|
302
|
+
const id = String(updateObj.toolCallId || '');
|
|
303
|
+
const earlier = this.liveFileActions.get(id);
|
|
304
|
+
const kind = updateObj.kind || (earlier?.name === 'fs_edit' ? 'edit' : earlier?.name === 'fs_delete' ? 'delete' : earlier?.name === 'fs_move' ? 'move' : '');
|
|
305
|
+
const name = kind === 'edit' ? 'fs_edit' : kind === 'delete' ? 'fs_delete' : kind === 'move' ? 'fs_move' : '';
|
|
306
|
+
if (name && id) {
|
|
307
|
+
const diff = Array.isArray(updateObj.content)
|
|
308
|
+
? updateObj.content.find((item) => item?.type === 'diff')
|
|
309
|
+
: null;
|
|
310
|
+
const input = updateObj.rawInput && typeof updateObj.rawInput === 'object' ? updateObj.rawInput : {};
|
|
311
|
+
const parameters = {
|
|
312
|
+
...(earlier?.parameters || {}), ...input,
|
|
313
|
+
...(diff?.path ? { path: diff.path } : {}),
|
|
314
|
+
...(diff?.newText ? { content: diff.newText } : {}),
|
|
315
|
+
...(updateObj.locations?.[0]?.path ? { path: updateObj.locations[0].path } : {})
|
|
316
|
+
};
|
|
317
|
+
const status = updateObj.status === 'completed' ? 'completed' : updateObj.status === 'failed' ? 'failed' : 'running';
|
|
318
|
+
const action = { name, status, parameters,
|
|
319
|
+
detail: String(parameters.path || updateObj.title || '') };
|
|
320
|
+
if (status === 'running')
|
|
321
|
+
this.liveFileActions.set(id, action);
|
|
322
|
+
else
|
|
323
|
+
this.liveFileActions.delete(id);
|
|
324
|
+
this.currentTurnNativeActionHandler?.(action);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
266
327
|
else if ('textDelta' in updateObj) {
|
|
267
328
|
const delta = updateObj.textDelta;
|
|
268
329
|
if (delta && typeof delta === 'string' && this.currentTurnChunkHandler) {
|
|
@@ -305,6 +366,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
305
366
|
async chat(messages, options = {}) {
|
|
306
367
|
this.currentTurnChunkHandler = options.onChunk || null;
|
|
307
368
|
this.currentTurnReasoningHandler = options.onReasoningChunk || null;
|
|
369
|
+
this.currentTurnNativeActionHandler = options.onNativeAction || null;
|
|
370
|
+
this.liveFileActions.clear();
|
|
308
371
|
try {
|
|
309
372
|
const { client, sessionId } = await this.getOrCreateClient();
|
|
310
373
|
const supportsImages = client.agentCapabilities?.promptCapabilities?.image === true;
|
|
@@ -344,6 +407,9 @@ export class AcpProvider extends LLMProvider {
|
|
|
344
407
|
}
|
|
345
408
|
finally {
|
|
346
409
|
this.currentTurnChunkHandler = null;
|
|
410
|
+
this.currentTurnReasoningHandler = null;
|
|
411
|
+
this.currentTurnNativeActionHandler = null;
|
|
412
|
+
this.liveFileActions.clear();
|
|
347
413
|
}
|
|
348
414
|
}
|
|
349
415
|
}
|
package/src/providers/acp.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
|
-
import { LLMProvider, type ProviderConfig, type ChatOptions, type ChatResponse, type ChatResponseToolCall } from './base.js';
|
|
3
|
+
import { LLMProvider, type ProviderConfig, type ChatOptions, type ChatResponse, type ChatResponseToolCall, type ChatResponseAction } from './base.js';
|
|
4
4
|
import { AcpClient } from '../acp/client.js';
|
|
5
5
|
import { getPeerProfile } from '../acp/peerProfiles.js';
|
|
6
6
|
import { BUILTIN_PEER_PRESETS } from '../acp/agentCatalog.js';
|
|
@@ -21,6 +21,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
21
21
|
private activeSessionId: string | null = null;
|
|
22
22
|
private currentTurnChunkHandler: ((chunk: string) => void) | null = null;
|
|
23
23
|
private currentTurnReasoningHandler: ((chunk: string) => void) | null = null;
|
|
24
|
+
private currentTurnNativeActionHandler: ((action: ChatResponseAction) => void) | null = null;
|
|
25
|
+
private readonly liveFileActions = new Map<string, ChatResponseAction>();
|
|
24
26
|
|
|
25
27
|
constructor(config: ProviderConfig = {}) {
|
|
26
28
|
super(config);
|
|
@@ -66,7 +68,7 @@ export class AcpProvider extends LLMProvider {
|
|
|
66
68
|
|
|
67
69
|
formatConversation(messages: any[], tools: any[] = []): string {
|
|
68
70
|
const lines: string[] = [];
|
|
69
|
-
lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.');
|
|
71
|
+
lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. If the user writes in English, you must respond strictly in English. Default to English for all responses and reasoning. Never default to Indonesian.');
|
|
70
72
|
|
|
71
73
|
if (tools && tools.length > 0) {
|
|
72
74
|
const toolSummaries = tools.map(t => {
|
|
@@ -78,6 +80,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
78
80
|
}).join('\n');
|
|
79
81
|
lines.push(`[Available Tools]\nYou may invoke tools when needed by outputting:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\n\n${toolSummaries}`);
|
|
80
82
|
}
|
|
83
|
+
const seenToolOutputs = new Set<string>();
|
|
84
|
+
const seenAssistantCalls = new Set<string>();
|
|
81
85
|
for (const msg of messages) {
|
|
82
86
|
const role = msg.role === 'user'
|
|
83
87
|
? 'User'
|
|
@@ -96,10 +100,23 @@ export class AcpProvider extends LLMProvider {
|
|
|
96
100
|
text = msg.content.map((c: any) => typeof c === 'string' ? c : (c?.text || '')).filter(Boolean).join('\n');
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
if (msg.role === 'tool' && text.trim()) {
|
|
104
|
+
const normalized = text.trim();
|
|
105
|
+
if (seenToolOutputs.has(normalized)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
seenToolOutputs.add(normalized);
|
|
109
|
+
}
|
|
110
|
+
|
|
99
111
|
if (msg.tool_calls && Array.isArray(msg.tool_calls)) {
|
|
100
112
|
for (const tc of msg.tool_calls) {
|
|
101
113
|
const fn = tc.function || {};
|
|
102
114
|
const fnArgs = typeof fn.arguments === 'string' ? fn.arguments : JSON.stringify(fn.arguments || {});
|
|
115
|
+
const callSig = `${fn.name}:${fnArgs}`;
|
|
116
|
+
if (seenAssistantCalls.has(callSig)) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
seenAssistantCalls.add(callSig);
|
|
103
120
|
text += `\n<tool_call>{"name": "${fn.name}", "arguments": ${fnArgs}}</tool_call>`;
|
|
104
121
|
}
|
|
105
122
|
}
|
|
@@ -133,6 +150,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
133
150
|
pending.push(`[Available Tools]\nYou may invoke tools when needed by outputting:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\n\n${toolSummaries}`);
|
|
134
151
|
}
|
|
135
152
|
|
|
153
|
+
const seenToolOutputs = new Set<string>();
|
|
154
|
+
const seenAssistantCalls = new Set<string>();
|
|
136
155
|
for (const msg of messages) {
|
|
137
156
|
const role = this._roleLabel(msg);
|
|
138
157
|
let text = '';
|
|
@@ -142,10 +161,23 @@ export class AcpProvider extends LLMProvider {
|
|
|
142
161
|
text = msg.content.map((c: any) => typeof c === 'string' ? c : (c?.text || '')).filter(Boolean).join('\n');
|
|
143
162
|
}
|
|
144
163
|
|
|
164
|
+
if (msg.role === 'tool' && text.trim()) {
|
|
165
|
+
const normalized = text.trim();
|
|
166
|
+
if (seenToolOutputs.has(normalized)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
seenToolOutputs.add(normalized);
|
|
170
|
+
}
|
|
171
|
+
|
|
145
172
|
if (msg.tool_calls && Array.isArray(msg.tool_calls)) {
|
|
146
173
|
for (const tc of msg.tool_calls) {
|
|
147
174
|
const fn = tc.function || {};
|
|
148
175
|
const fnArgs = typeof fn.arguments === 'string' ? fn.arguments : JSON.stringify(fn.arguments || {});
|
|
176
|
+
const callSig = `${fn.name}:${fnArgs}`;
|
|
177
|
+
if (seenAssistantCalls.has(callSig)) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
seenAssistantCalls.add(callSig);
|
|
149
181
|
text += `\n<tool_call>{"name": "${fn.name}", "arguments": ${fnArgs}}</tool_call>`;
|
|
150
182
|
}
|
|
151
183
|
}
|
|
@@ -269,6 +301,32 @@ export class AcpProvider extends LLMProvider {
|
|
|
269
301
|
if (thought && this.currentTurnReasoningHandler) {
|
|
270
302
|
this.currentTurnReasoningHandler(thought);
|
|
271
303
|
}
|
|
304
|
+
} else if (updateObj.sessionUpdate === 'agent_message_chunk') {
|
|
305
|
+
const text = updateObj.content?.type === 'text' ? updateObj.content.text : '';
|
|
306
|
+
if (text && this.currentTurnChunkHandler) this.currentTurnChunkHandler(text);
|
|
307
|
+
} else if (updateObj.sessionUpdate === 'tool_call' || updateObj.sessionUpdate === 'tool_call_update') {
|
|
308
|
+
const id = String(updateObj.toolCallId || '');
|
|
309
|
+
const earlier = this.liveFileActions.get(id);
|
|
310
|
+
const kind = updateObj.kind || (earlier?.name === 'fs_edit' ? 'edit' : earlier?.name === 'fs_delete' ? 'delete' : earlier?.name === 'fs_move' ? 'move' : '');
|
|
311
|
+
const name = kind === 'edit' ? 'fs_edit' : kind === 'delete' ? 'fs_delete' : kind === 'move' ? 'fs_move' : '';
|
|
312
|
+
if (name && id) {
|
|
313
|
+
const diff = Array.isArray(updateObj.content)
|
|
314
|
+
? updateObj.content.find((item: any) => item?.type === 'diff')
|
|
315
|
+
: null;
|
|
316
|
+
const input = updateObj.rawInput && typeof updateObj.rawInput === 'object' ? updateObj.rawInput : {};
|
|
317
|
+
const parameters: Record<string, unknown> = {
|
|
318
|
+
...(earlier?.parameters || {}), ...input,
|
|
319
|
+
...(diff?.path ? { path: diff.path } : {}),
|
|
320
|
+
...(diff?.newText ? { content: diff.newText } : {}),
|
|
321
|
+
...(updateObj.locations?.[0]?.path ? { path: updateObj.locations[0].path } : {})
|
|
322
|
+
};
|
|
323
|
+
const status = updateObj.status === 'completed' ? 'completed' : updateObj.status === 'failed' ? 'failed' : 'running';
|
|
324
|
+
const action: ChatResponseAction = { name, status, parameters,
|
|
325
|
+
detail: String(parameters.path || updateObj.title || '') };
|
|
326
|
+
if (status === 'running') this.liveFileActions.set(id, action);
|
|
327
|
+
else this.liveFileActions.delete(id);
|
|
328
|
+
this.currentTurnNativeActionHandler?.(action);
|
|
329
|
+
}
|
|
272
330
|
} else if ('textDelta' in updateObj) {
|
|
273
331
|
const delta = updateObj.textDelta;
|
|
274
332
|
if (delta && typeof delta === 'string' && this.currentTurnChunkHandler) {
|
|
@@ -314,6 +372,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
314
372
|
override async chat(messages: any[], options: ChatOptions = {}): Promise<ChatResponse> {
|
|
315
373
|
this.currentTurnChunkHandler = options.onChunk || null;
|
|
316
374
|
this.currentTurnReasoningHandler = options.onReasoningChunk || null;
|
|
375
|
+
this.currentTurnNativeActionHandler = options.onNativeAction || null;
|
|
376
|
+
this.liveFileActions.clear();
|
|
317
377
|
try {
|
|
318
378
|
const { client, sessionId } = await this.getOrCreateClient();
|
|
319
379
|
|
|
@@ -355,6 +415,9 @@ export class AcpProvider extends LLMProvider {
|
|
|
355
415
|
throw new Error(`ACP Peer Agent (${this.peerId}) Error: ${msg}. Make sure "${this.command}" is installed and running.`);
|
|
356
416
|
} finally {
|
|
357
417
|
this.currentTurnChunkHandler = null;
|
|
418
|
+
this.currentTurnReasoningHandler = null;
|
|
419
|
+
this.currentTurnNativeActionHandler = null;
|
|
420
|
+
this.liveFileActions.clear();
|
|
358
421
|
}
|
|
359
422
|
}
|
|
360
423
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
export const BASELINE_ANTIGRAVITY_MODELS: Record<string, string>;
|
|
1
2
|
export const ANTIGRAVITY_MODELS: string[];
|
|
2
3
|
export const ANTIGRAVITY_MODEL_IDS: Record<string, string>;
|
|
3
4
|
export const ANTIGRAVITY_LABEL_BY_ID: Record<string, string>;
|
|
4
|
-
export function
|
|
5
|
+
export function registerAntigravityModel(slug: string, label?: string): void;
|
|
6
|
+
export function parseAgyModelsOutput(stdout: string): Array<{ id: string; label: string }>;
|
|
7
|
+
export function resolveAgyModelId(model: string | null | undefined): string;
|
|
8
|
+
export function resolveAgyEffort(model: string | null | undefined): string;
|
|
5
9
|
export function isAntigravityProvider(provider: string | null | undefined): boolean;
|
|
6
10
|
export function resolveAgyBinary(): string;
|
|
7
11
|
export class AntigravityProvider {
|