@causyne/agent 1.20.11 → 1.20.13
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/LICENSE +1 -1
- package/docs/ARCHITECTURE.md +24 -1
- package/package.json +1 -1
- package/src/acp/client.js +9 -2
- package/src/acp/client.ts +11 -2
- package/src/acp/protocol.ts +9 -0
- package/src/agentLoop.js +504 -119
- package/src/agentLoop.ts +477 -121
- package/src/browser/browserRuntime.js +47 -0
- package/src/browser/browserRuntime.ts +45 -0
- package/src/browser/causyneBrowser.js +60 -31
- package/src/browser/causyneBrowser.ts +37 -12
- package/src/browser/workspacePreview.js +52 -0
- package/src/browser/workspacePreview.ts +49 -0
- package/src/core/planCache.js +5 -0
- package/src/core/planCache.ts +5 -0
- package/src/decisionPolicy.js +9 -0
- package/src/decisionPolicy.ts +8 -0
- package/src/historyPruner.js +251 -0
- package/src/historyPruner.ts +263 -0
- package/src/infra/atomicWriter.js +49 -0
- package/src/infra/atomicWriter.ts +63 -0
- package/src/infra/telemetry.js +38 -0
- package/src/infra/telemetry.ts +68 -0
- package/src/observer/coldObserver.js +12 -7
- package/src/observer/coldObserver.ts +12 -7
- package/src/observer/evidence.js +8 -2
- package/src/observer/evidence.ts +9 -2
- package/src/outputRecovery.js +36 -0
- package/src/outputRecovery.ts +33 -0
- package/src/providers/acp.js +114 -46
- package/src/providers/acp.ts +129 -46
- package/src/providers/antigravity.js +264 -82
- package/src/providers/antigravity.ts +273 -87
- package/src/providers/antigravityBridge.js +58 -0
- package/src/providers/antigravityBridge.ts +51 -0
- package/src/providers/base.d.ts +9 -0
- package/src/providers/budgetEnforcer.js +110 -0
- package/src/providers/budgetEnforcer.ts +122 -0
- package/src/providers/collaborationPolicy.js +6 -0
- package/src/providers/collaborationPolicy.ts +7 -0
- package/src/providers/loopGuard.js +84 -0
- package/src/providers/loopGuard.ts +105 -0
- package/src/providers/pi.js +19 -6
- package/src/providers/pi.ts +19 -7
- package/src/providers/toolContracts.js +36 -0
- package/src/providers/toolContracts.ts +48 -0
- package/src/session/sidechainEvents.js +49 -0
- package/src/session/sidechainEvents.ts +98 -0
- package/src/skillsManager.d.ts +1 -0
- package/src/smartToolsUse.js +123 -4
- package/src/smartToolsUse.ts +136 -4
- package/src/subagent/sidechainHarness.js +66 -0
- package/src/subagent/sidechainHarness.ts +91 -0
- package/src/taskContinuation.js +12 -0
- package/src/taskContinuation.ts +13 -0
- package/src/tokenTracker.js +406 -539
- package/src/tokenTracker.ts +569 -0
- package/src/toolPacks.d.ts +2 -0
- package/src/toolPacks.js +1 -1
- package/src/tools/argumentValidation.js +56 -0
- package/src/tools/argumentValidation.ts +50 -0
- package/src/tools/browserAutomator.js +2 -2
- package/src/tools/browserAutomator.ts +3 -2
- package/src/tools/deferredMcpSearch.js +188 -201
- package/src/tools/deferredMcpSearch.ts +250 -0
- package/src/tools/generateMediaViaApi.js +305 -331
- package/src/tools/generateMediaViaApi.ts +330 -0
- package/src/tools/historyPruner.js +5 -0
- package/src/tools/historyPruner.ts +5 -0
- package/src/tools/payloadSanitizer.js +92 -0
- package/src/tools/payloadSanitizer.ts +113 -0
- package/src/tools/registry.d.ts +1 -0
- package/src/tools/sysRun.js +47 -18
- package/src/tools/sysRun.ts +52 -20
- package/src/tools/toolOutputStore.js +180 -0
- package/src/tools/toolOutputStore.ts +209 -0
- package/src/tools/toolSelfRepair.js +26 -1
- package/src/tools/toolSelfRepair.ts +25 -1
- package/src/tui/chatRenderer.d.ts +1 -0
- package/src/tui/chatRenderer.js +4 -2
- package/src/tui/codeStreamRenderer.js +36 -8
- package/src/tui/codeStreamRenderer.ts +38 -8
- package/src/tui/stageSurface.js +1 -0
- package/src/tui/text.js +4 -1
- package/src/tokenTracker.d.ts +0 -1
package/LICENSE
CHANGED
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -26,7 +26,30 @@ Peer agents (OpenCode, Claude Code, Codex, Gemini CLI, Cursor, Antigravity) are
|
|
|
26
26
|
providers in the same sense as an HTTP API, addressed as `acp/<peer>`: the
|
|
27
27
|
user's existing CLI login is the credential, the peer's own `models` command
|
|
28
28
|
supplies the catalogue, and the session is billed by that subscription — Causyne
|
|
29
|
-
|
|
29
|
+
cannot determine the monetary cost when the peer does not expose its invoice.
|
|
30
|
+
|
|
31
|
+
### Connected-agent capability preservation
|
|
32
|
+
|
|
33
|
+
Causyne is intended for worldwide distribution. Tool routing is independent of
|
|
34
|
+
the developer's machine and complements each connected agent's configured
|
|
35
|
+
capabilities. It does not force a tool-less peer profile or disable inherited
|
|
36
|
+
MCPs, native tools, skills, or project instructions to promote host tools.
|
|
37
|
+
|
|
38
|
+
Antigravity CLI starts in the selected workspace using the user's normal agent
|
|
39
|
+
configuration. ACP permission requests are routed to the host's authorization
|
|
40
|
+
policy; client file operations use scoped, audited host services. Configured
|
|
41
|
+
client MCP servers can be supplied at session creation. Pi RPC retains the
|
|
42
|
+
peer's native tool, extension, MCP, skill, and project-context configuration.
|
|
43
|
+
Native action updates remain visible and budgeted; native actions are not
|
|
44
|
+
silently executed twice through host-tool mapping.
|
|
45
|
+
|
|
46
|
+
Client-provided ACP terminal methods are not yet implemented or advertised;
|
|
47
|
+
this does not disable terminal tools implemented by a peer itself. The
|
|
48
|
+
Antigravity stream-json adapter remains text-only for host image payloads.
|
|
49
|
+
Preserving capabilities does not invent support missing from a transport or
|
|
50
|
+
bypass user authorization. Account settings are not rewritten. Diagnostic
|
|
51
|
+
conversations never define normal-session permissions. Token usage, cache reads,
|
|
52
|
+
and unavailable subscription pricing remain distinct measurements.
|
|
30
53
|
|
|
31
54
|
`LocalCLIConnection` is a local rendering/event adapter, not an inbound network
|
|
32
55
|
connection. `emitEvent` feeds the terminal. Tools can execute host commands;
|
package/package.json
CHANGED
package/src/acp/client.js
CHANGED
|
@@ -115,8 +115,8 @@ export class AcpClient {
|
|
|
115
115
|
const detail = this.stderrTail.trim() || `exit code ${code ?? 'null'}${exitSignal ? ` signal ${exitSignal}` : ''}`;
|
|
116
116
|
this.failAll(new Error(`agent process exited: ${detail}`));
|
|
117
117
|
});
|
|
118
|
-
const hasFsRead = Boolean(this.options.fsReadHandler || this.options.cwd);
|
|
119
|
-
const hasFsWrite = Boolean(this.options.fsWriteHandler || this.options.cwd);
|
|
118
|
+
const hasFsRead = this.options.allowHostTools !== false && Boolean(this.options.fsReadHandler || this.options.cwd);
|
|
119
|
+
const hasFsWrite = this.options.allowHostTools !== false && Boolean(this.options.fsWriteHandler || this.options.cwd);
|
|
120
120
|
const params = {
|
|
121
121
|
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
122
122
|
clientCapabilities: {
|
|
@@ -230,6 +230,7 @@ export class AcpClient {
|
|
|
230
230
|
}, this.options.promptTimeoutMs ?? 15 * 60 * 1000, signal);
|
|
231
231
|
return {
|
|
232
232
|
stopReason: response?.stopReason ?? 'end_turn',
|
|
233
|
+
...(response?.usage ? { usage: response.usage } : {}),
|
|
233
234
|
text: collected
|
|
234
235
|
};
|
|
235
236
|
}
|
|
@@ -339,6 +340,12 @@ export class AcpClient {
|
|
|
339
340
|
}
|
|
340
341
|
}
|
|
341
342
|
async handleServerRequest(request) {
|
|
343
|
+
if (this.options.allowHostTools === false
|
|
344
|
+
&& (request.method === ACP_METHODS.READ_TEXT_FILE || request.method === ACP_METHODS.WRITE_TEXT_FILE)) {
|
|
345
|
+
this.write({ jsonrpc: '2.0', id: request.id,
|
|
346
|
+
error: { code: ACP_ERROR_CODES.INVALID_REQUEST, message: 'Use the advertised Causyne tools for host file access.' } });
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
342
349
|
if (request.method === ACP_METHODS.REQUEST_PERMISSION) {
|
|
343
350
|
const handler = this.options.permissionHandler;
|
|
344
351
|
if (!handler) {
|
package/src/acp/client.ts
CHANGED
|
@@ -38,6 +38,7 @@ export interface AcpClientOptions {
|
|
|
38
38
|
env?: NodeJS.ProcessEnv;
|
|
39
39
|
clientVersion?: string;
|
|
40
40
|
promptTimeoutMs?: number;
|
|
41
|
+
allowHostTools?: boolean;
|
|
41
42
|
permissionHandler?: (request: RequestPermissionRequest) => Promise<RequestPermissionResponse['outcome']>;
|
|
42
43
|
onUpdate?: (sessionId: string, update: SessionUpdate) => void;
|
|
43
44
|
fsReadHandler?: (filePath: string, options?: { line?: number; limit?: number }) => Promise<string>;
|
|
@@ -47,6 +48,7 @@ export interface AcpClientOptions {
|
|
|
47
48
|
export interface AcpPromptResult {
|
|
48
49
|
stopReason: PromptResponse['stopReason'];
|
|
49
50
|
text: string;
|
|
51
|
+
usage?: PromptResponse['usage'];
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
interface PendingRequest {
|
|
@@ -182,8 +184,8 @@ export class AcpClient {
|
|
|
182
184
|
this.failAll(new Error(`agent process exited: ${detail}`));
|
|
183
185
|
});
|
|
184
186
|
|
|
185
|
-
const hasFsRead = Boolean(this.options.fsReadHandler || this.options.cwd);
|
|
186
|
-
const hasFsWrite = Boolean(this.options.fsWriteHandler || this.options.cwd);
|
|
187
|
+
const hasFsRead = this.options.allowHostTools !== false && Boolean(this.options.fsReadHandler || this.options.cwd);
|
|
188
|
+
const hasFsWrite = this.options.allowHostTools !== false && Boolean(this.options.fsWriteHandler || this.options.cwd);
|
|
187
189
|
|
|
188
190
|
const params: InitializeRequest = {
|
|
189
191
|
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
@@ -299,6 +301,7 @@ export class AcpClient {
|
|
|
299
301
|
}, this.options.promptTimeoutMs ?? 15 * 60 * 1000, signal);
|
|
300
302
|
return {
|
|
301
303
|
stopReason: response?.stopReason ?? 'end_turn',
|
|
304
|
+
...(response?.usage ? { usage: response.usage } : {}),
|
|
302
305
|
text: collected
|
|
303
306
|
};
|
|
304
307
|
} finally {
|
|
@@ -400,6 +403,12 @@ export class AcpClient {
|
|
|
400
403
|
}
|
|
401
404
|
|
|
402
405
|
private async handleServerRequest(request: JsonRpcRequest): Promise<void> {
|
|
406
|
+
if (this.options.allowHostTools === false
|
|
407
|
+
&& (request.method === ACP_METHODS.READ_TEXT_FILE || request.method === ACP_METHODS.WRITE_TEXT_FILE)) {
|
|
408
|
+
this.write({ jsonrpc: '2.0', id: request.id,
|
|
409
|
+
error: { code: ACP_ERROR_CODES.INVALID_REQUEST, message: 'Use the advertised Causyne tools for host file access.' } });
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
403
412
|
if (request.method === ACP_METHODS.REQUEST_PERMISSION) {
|
|
404
413
|
const handler = this.options.permissionHandler;
|
|
405
414
|
if (!handler) {
|
package/src/acp/protocol.ts
CHANGED
|
@@ -264,6 +264,15 @@ export type StopReason = 'end_turn' | 'max_tokens' | 'max_turn_requests' | 'refu
|
|
|
264
264
|
|
|
265
265
|
export interface PromptResponse {
|
|
266
266
|
stopReason: StopReason;
|
|
267
|
+
usage?: AcpUsage;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface AcpUsage {
|
|
271
|
+
inputTokens: number;
|
|
272
|
+
outputTokens: number;
|
|
273
|
+
cachedReadTokens?: number;
|
|
274
|
+
cachedWriteTokens?: number;
|
|
275
|
+
thoughtTokens?: number;
|
|
267
276
|
}
|
|
268
277
|
|
|
269
278
|
export interface SetSessionModeRequest {
|