@wrongstack/acp 0.295.1 → 0.296.2
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/dist/agent/stdio-transport.d.ts.map +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/client/acp-message-routing.d.ts +2 -0
- package/dist/client/acp-message-routing.d.ts.map +1 -0
- package/dist/client/acp-session-callbacks.d.ts +12 -0
- package/dist/client/acp-session-callbacks.d.ts.map +1 -0
- package/dist/client/acp-session-content.d.ts +24 -0
- package/dist/client/acp-session-content.d.ts.map +1 -0
- package/dist/client/acp-session-errors.d.ts +13 -0
- package/dist/client/acp-session-errors.d.ts.map +1 -0
- package/dist/client/acp-session-types.d.ts +81 -0
- package/dist/client/acp-session-types.d.ts.map +1 -0
- package/dist/client/acp-session-updates.d.ts +18 -0
- package/dist/client/acp-session-updates.d.ts.map +1 -0
- package/dist/client/acp-session.d.ts +6 -171
- package/dist/client/acp-session.d.ts.map +1 -1
- package/dist/client.js +318 -313
- package/dist/client.js.map +3 -3
- package/dist/index.js +318 -313
- package/dist/index.js.map +3 -3
- package/dist/wrongstack-acp-agent.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-message-routing.d.ts","sourceRoot":"","sources":["../../src/client/acp-message-routing.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQzE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ACPMessage } from '../types/acp-messages.js';
|
|
2
|
+
import { type FileServer } from './file-server.js';
|
|
3
|
+
import type { PermissionPolicy } from './permission.js';
|
|
4
|
+
import type { TerminalServer } from './terminal-server.js';
|
|
5
|
+
export interface ACPResponseSender {
|
|
6
|
+
sendResult(id: string | number, result: unknown): Promise<void>;
|
|
7
|
+
sendErrorResponse(id: string | number, code: number, message: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare function handleAcpPermissionRequest(msg: ACPMessage, permissionPolicy: PermissionPolicy, sender: ACPResponseSender): Promise<void>;
|
|
10
|
+
export declare function handleAcpFsRequest(msg: ACPMessage, fileServer: FileServer, permissionPolicy: PermissionPolicy, sender: ACPResponseSender): Promise<void>;
|
|
11
|
+
export declare function handleAcpTerminalRequest(msg: ACPMessage, terminalServer: TerminalServer, permissionPolicy: PermissionPolicy, sender: ACPResponseSender): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=acp-session-callbacks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-session-callbacks.d.ts","sourceRoot":"","sources":["../../src/client/acp-session-callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,KAAK,UAAU,EAAW,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtF;AAED,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,UAAU,EACf,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,UAAU,EACf,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAyCf;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,UAAU,EACf,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAwEf"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ContentBlock, StopReason } from '../types/acp-v1.js';
|
|
2
|
+
import type { ACPSessionRunResult } from './acp-session-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a text ContentBlock. Convenience helper for callers of
|
|
5
|
+
* `session.prompt()`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function textContent(text: string): ContentBlock;
|
|
8
|
+
/**
|
|
9
|
+
* Create an image ContentBlock. Only send this if the agent's
|
|
10
|
+
* `promptCapabilities.image` is `true` (check via
|
|
11
|
+
* `session.getCapabilities().promptCapabilities?.image`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function imageContent(mimeType: string, data: string): ContentBlock;
|
|
14
|
+
/**
|
|
15
|
+
* Create an audio ContentBlock. Only send this if the agent's
|
|
16
|
+
* `promptCapabilities.audio` is `true` (check via
|
|
17
|
+
* `session.getCapabilities().promptCapabilities?.audio`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function audioContent(mimeType: string, data: string): ContentBlock;
|
|
20
|
+
export declare function extractText(block: unknown): string;
|
|
21
|
+
export declare function isRecord(v: unknown): v is Record<string, unknown>;
|
|
22
|
+
/** A fully-populated empty run result (used for pre-aborted short-circuits). */
|
|
23
|
+
export declare function emptyRunResult(stopReason: StopReason): ACPSessionRunResult;
|
|
24
|
+
//# sourceMappingURL=acp-session-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-session-content.d.ts","sourceRoot":"","sources":["../../src/client/acp-session-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAEzE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkBlD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjE;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,CAS1E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ACPSessionErrorKind } from './acp-session-types.js';
|
|
2
|
+
export declare class ACPSessionError extends Error {
|
|
3
|
+
readonly kind: ACPSessionErrorKind;
|
|
4
|
+
readonly cause: unknown;
|
|
5
|
+
constructor(kind: ACPSessionErrorKind, message: string, cause?: unknown);
|
|
6
|
+
}
|
|
7
|
+
export interface JsonRpcError {
|
|
8
|
+
code: number;
|
|
9
|
+
message: string;
|
|
10
|
+
data?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare function isJsonRpcError(v: unknown): v is JsonRpcError;
|
|
13
|
+
//# sourceMappingURL=acp-session-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-session-errors.d.ts","sourceRoot":"","sources":["../../src/client/acp-session-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,SAAkB,KAAK,EAAE,OAAO,CAAC;IACjC,YAAY,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAKtE;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,YAAY,CAO5D"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TrustActor, TrustAuthContext, TrustBoundary, TrustScope } from '@wrongstack/core/security';
|
|
2
|
+
import type { AnySessionUpdate, McpServer, PlanEntry, StopReason, ToolCallStatus, ToolKind, UsageCost } from '../types/acp-v1.js';
|
|
3
|
+
import type { PermissionPolicy } from './permission.js';
|
|
4
|
+
export interface ACPSessionOptions {
|
|
5
|
+
command: string;
|
|
6
|
+
args?: readonly string[] | undefined;
|
|
7
|
+
env?: Record<string, string> | undefined;
|
|
8
|
+
cwd?: string | undefined;
|
|
9
|
+
role?: string | undefined;
|
|
10
|
+
projectRoot: string;
|
|
11
|
+
timeoutMs?: number | undefined;
|
|
12
|
+
permissionPolicy?: PermissionPolicy | undefined;
|
|
13
|
+
trustBoundary?: TrustBoundary | undefined;
|
|
14
|
+
trustActor?: TrustActor | undefined;
|
|
15
|
+
trustScope?: TrustScope | undefined;
|
|
16
|
+
trustAuthContext?: TrustAuthContext | undefined;
|
|
17
|
+
fsTimeoutMs?: number | undefined;
|
|
18
|
+
terminalTimeoutMs?: number | undefined;
|
|
19
|
+
terminalOutputByteLimit?: number | undefined;
|
|
20
|
+
terminalMaxCount?: number | undefined;
|
|
21
|
+
mcpServers?: McpServer[] | undefined;
|
|
22
|
+
}
|
|
23
|
+
export interface ACPCapturedDiff {
|
|
24
|
+
path: string;
|
|
25
|
+
oldText: string | null;
|
|
26
|
+
newText: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ACPCapturedToolCall {
|
|
29
|
+
toolCallId: string;
|
|
30
|
+
title: string;
|
|
31
|
+
kind?: ToolKind | undefined;
|
|
32
|
+
status: ToolCallStatus;
|
|
33
|
+
rawOutput?: Record<string, unknown> | undefined;
|
|
34
|
+
rawInput?: Record<string, unknown> | undefined;
|
|
35
|
+
}
|
|
36
|
+
export interface ACPSessionRunResult {
|
|
37
|
+
text: string;
|
|
38
|
+
stopReason: StopReason;
|
|
39
|
+
hasText: boolean;
|
|
40
|
+
usage?: {
|
|
41
|
+
used: number;
|
|
42
|
+
size: number;
|
|
43
|
+
cost?: UsageCost | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
plan?: PlanEntry[] | undefined;
|
|
46
|
+
toolCalls: ACPCapturedToolCall[];
|
|
47
|
+
diffs: ACPCapturedDiff[];
|
|
48
|
+
thoughts: string;
|
|
49
|
+
}
|
|
50
|
+
export type ACPProgressHandler = (event: ACPProgressEvent) => void;
|
|
51
|
+
export type ACPProgressEvent = {
|
|
52
|
+
type: 'message';
|
|
53
|
+
text: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'thought';
|
|
56
|
+
text: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'tool_call';
|
|
59
|
+
toolCall: ACPCapturedToolCall;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'tool_call_update';
|
|
62
|
+
toolCall: ACPCapturedToolCall;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'diff';
|
|
65
|
+
diff: ACPCapturedDiff;
|
|
66
|
+
} | {
|
|
67
|
+
type: 'plan';
|
|
68
|
+
entries: PlanEntry[];
|
|
69
|
+
} | {
|
|
70
|
+
type: 'usage';
|
|
71
|
+
usage: {
|
|
72
|
+
used: number;
|
|
73
|
+
size: number;
|
|
74
|
+
cost?: UsageCost | undefined;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
type: 'raw';
|
|
78
|
+
update: AnySessionUpdate;
|
|
79
|
+
};
|
|
80
|
+
export type ACPSessionErrorKind = 'spawn_failed' | 'init_failed' | 'protocol_error' | 'session_create_failed' | 'prompt_failed' | 'auth_failed' | 'logout_failed' | 'aborted' | 'closed' | 'agent_died' | 'unsupported_capability';
|
|
81
|
+
//# sourceMappingURL=acp-session-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-session-types.d.ts","sourceRoot":"","sources":["../../src/client/acp-session-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,UAAU,EACV,cAAc,EACd,QAAQ,EACR,SAAS,EACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACzC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC1C,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,gBAAgB,CAAC,EAAE,gBAAgB,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B,KAAK,IAAI,CAAC;AAEnE,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,SAAS,EAAE,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;KAAE,CAAA;CAAE,GACtF;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,uBAAuB,GACvB,eAAe,GACf,aAAa,GACb,eAAe,GACf,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ACPMessage } from '../types/acp-messages.js';
|
|
2
|
+
import type { PlanEntry, UsageCost } from '../types/acp-v1.js';
|
|
3
|
+
import type { ACPCapturedDiff, ACPCapturedToolCall, ACPProgressEvent } from './acp-session-types.js';
|
|
4
|
+
export interface ACPSessionScratch {
|
|
5
|
+
text: string;
|
|
6
|
+
thoughts: string;
|
|
7
|
+
plan?: PlanEntry[];
|
|
8
|
+
usage?: {
|
|
9
|
+
used: number;
|
|
10
|
+
size: number;
|
|
11
|
+
cost?: UsageCost | undefined;
|
|
12
|
+
};
|
|
13
|
+
toolCalls: Map<string, ACPCapturedToolCall>;
|
|
14
|
+
diffs: ACPCapturedDiff[];
|
|
15
|
+
}
|
|
16
|
+
export declare function createSessionScratch(): ACPSessionScratch;
|
|
17
|
+
export declare function handleAcpSessionUpdate(msg: ACPMessage, scratch: ACPSessionScratch, emitProgress: (event: ACPProgressEvent) => void): void;
|
|
18
|
+
//# sourceMappingURL=acp-session-updates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-session-updates.d.ts","sourceRoot":"","sources":["../../src/client/acp-session-updates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAEV,SAAS,EAIT,SAAS,EACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;KAAE,CAAC;IACrE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC5C,KAAK,EAAE,eAAe,EAAE,CAAC;CAC1B;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAExD;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAC9C,IAAI,CAsDN"}
|
|
@@ -8,134 +8,13 @@
|
|
|
8
8
|
* Spec: https://agentclientprotocol.com/protocol/v1/overview
|
|
9
9
|
* Design: see ./acp-session.design.md in this directory.
|
|
10
10
|
*/
|
|
11
|
-
import type { TrustActor, TrustAuthContext, TrustBoundary, TrustScope } from '@wrongstack/core/security';
|
|
12
11
|
import { type ACPClientTransport } from '../agent/stdio-transport.js';
|
|
13
|
-
import { type AgentCapabilities, type
|
|
14
|
-
import { type PermissionPolicy } from './permission.js';
|
|
12
|
+
import { type AgentCapabilities, type AuthMethod, type ContentBlock, type McpServer, type SessionId, type SessionInfo } from '../types/acp-v1.js';
|
|
15
13
|
import { type WebSocketClientTransportOptions } from './websocket-transport.js';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
cwd?: string | undefined;
|
|
21
|
-
role?: string | undefined;
|
|
22
|
-
/** Sandbox root for fs/* and terminal/* methods. */
|
|
23
|
-
projectRoot: string;
|
|
24
|
-
/** Hard timeout for one prompt turn. Default 5 minutes. */
|
|
25
|
-
timeoutMs?: number | undefined;
|
|
26
|
-
/** Override the permission policy. */
|
|
27
|
-
permissionPolicy?: PermissionPolicy | undefined;
|
|
28
|
-
/** Shared authorization authority. Mutually exclusive with `permissionPolicy`. */
|
|
29
|
-
trustBoundary?: TrustBoundary | undefined;
|
|
30
|
-
/** Actor identity supplied to `trustBoundary`. Defaults to an ACP agent. */
|
|
31
|
-
trustActor?: TrustActor | undefined;
|
|
32
|
-
/** Base scope supplied to `trustBoundary`; callback session IDs are merged in. */
|
|
33
|
-
trustScope?: TrustScope | undefined;
|
|
34
|
-
/** Authentication evidence supplied to `trustBoundary`. */
|
|
35
|
-
trustAuthContext?: TrustAuthContext | undefined;
|
|
36
|
-
/** Per-fs-call timeout, default 30s. */
|
|
37
|
-
fsTimeoutMs?: number | undefined;
|
|
38
|
-
/** Per-terminal command timeout, default 5 minutes. */
|
|
39
|
-
terminalTimeoutMs?: number | undefined;
|
|
40
|
-
/** Per-terminal output byte cap, default 1 MiB. */
|
|
41
|
-
terminalOutputByteLimit?: number | undefined;
|
|
42
|
-
/** Maximum terminal records retained concurrently, default 32. */
|
|
43
|
-
terminalMaxCount?: number | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* MCP server configs to include in session/new, session/load, and
|
|
46
|
-
* session/resume. The agent will connect to these servers to provide
|
|
47
|
-
* additional tools.
|
|
48
|
-
*
|
|
49
|
-
* Stdio servers are always sent. HTTP/SSE servers are only sent if
|
|
50
|
-
* the agent advertises the corresponding mcpCapabilities.
|
|
51
|
-
*/
|
|
52
|
-
mcpServers?: McpServer[] | undefined;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* A captured file diff emitted by the agent during a turn (via a tool
|
|
56
|
-
* call's `diff` content). `oldText: null` means the file was created.
|
|
57
|
-
*/
|
|
58
|
-
export interface ACPCapturedDiff {
|
|
59
|
-
path: string;
|
|
60
|
-
oldText: string | null;
|
|
61
|
-
newText: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A captured tool call the agent ran during a turn. We collapse the
|
|
65
|
-
* `tool_call` + subsequent `tool_call_update` notifications for the same
|
|
66
|
-
* `toolCallId` into one record carrying its latest status.
|
|
67
|
-
*/
|
|
68
|
-
export interface ACPCapturedToolCall {
|
|
69
|
-
toolCallId: string;
|
|
70
|
-
title: string;
|
|
71
|
-
kind?: ToolKind | undefined;
|
|
72
|
-
status: ToolCallStatus;
|
|
73
|
-
/** Terminal/command output or text content surfaced by the tool, if any. */
|
|
74
|
-
rawOutput?: Record<string, unknown> | undefined;
|
|
75
|
-
rawInput?: Record<string, unknown> | undefined;
|
|
76
|
-
}
|
|
77
|
-
export interface ACPSessionRunResult {
|
|
78
|
-
text: string;
|
|
79
|
-
stopReason: StopReason;
|
|
80
|
-
hasText: boolean;
|
|
81
|
-
usage?: {
|
|
82
|
-
used: number;
|
|
83
|
-
size: number;
|
|
84
|
-
cost?: UsageCost | undefined;
|
|
85
|
-
} | undefined;
|
|
86
|
-
plan?: PlanEntry[] | undefined;
|
|
87
|
-
/** Tool calls the agent ran this turn (deduped by toolCallId). */
|
|
88
|
-
toolCalls: ACPCapturedToolCall[];
|
|
89
|
-
/** File diffs the agent produced this turn. */
|
|
90
|
-
diffs: ACPCapturedDiff[];
|
|
91
|
-
/** Agent "thinking" text emitted via thought_chunk, concatenated. */
|
|
92
|
-
thoughts: string;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Live progress callback. Invoked for every `session/update` notification
|
|
96
|
-
* the agent streams during a `prompt()` turn, in arrival order, BEFORE the
|
|
97
|
-
* turn resolves. Lets the host render tool activity / text deltas / diffs
|
|
98
|
-
* as they happen instead of waiting for the buffered final result.
|
|
99
|
-
*
|
|
100
|
-
* The raw `update` (the discriminated `session/update` payload) is passed
|
|
101
|
-
* through verbatim so callers can switch on `update.sessionUpdate`.
|
|
102
|
-
*/
|
|
103
|
-
export type ACPProgressHandler = (event: ACPProgressEvent) => void;
|
|
104
|
-
export type ACPProgressEvent = {
|
|
105
|
-
type: 'message';
|
|
106
|
-
text: string;
|
|
107
|
-
} | {
|
|
108
|
-
type: 'thought';
|
|
109
|
-
text: string;
|
|
110
|
-
} | {
|
|
111
|
-
type: 'tool_call';
|
|
112
|
-
toolCall: ACPCapturedToolCall;
|
|
113
|
-
} | {
|
|
114
|
-
type: 'tool_call_update';
|
|
115
|
-
toolCall: ACPCapturedToolCall;
|
|
116
|
-
} | {
|
|
117
|
-
type: 'diff';
|
|
118
|
-
diff: ACPCapturedDiff;
|
|
119
|
-
} | {
|
|
120
|
-
type: 'plan';
|
|
121
|
-
entries: PlanEntry[];
|
|
122
|
-
} | {
|
|
123
|
-
type: 'usage';
|
|
124
|
-
usage: {
|
|
125
|
-
used: number;
|
|
126
|
-
size: number;
|
|
127
|
-
cost?: UsageCost | undefined;
|
|
128
|
-
};
|
|
129
|
-
} | {
|
|
130
|
-
type: 'raw';
|
|
131
|
-
update: AnySessionUpdate;
|
|
132
|
-
};
|
|
133
|
-
export type ACPSessionErrorKind = 'spawn_failed' | 'init_failed' | 'protocol_error' | 'session_create_failed' | 'prompt_failed' | 'auth_failed' | 'logout_failed' | 'aborted' | 'closed' | 'agent_died' | 'unsupported_capability';
|
|
134
|
-
export declare class ACPSessionError extends Error {
|
|
135
|
-
readonly kind: ACPSessionErrorKind;
|
|
136
|
-
readonly cause: unknown;
|
|
137
|
-
constructor(kind: ACPSessionErrorKind, message: string, cause?: unknown);
|
|
138
|
-
}
|
|
14
|
+
import type { ACPProgressHandler, ACPSessionOptions, ACPSessionRunResult } from './acp-session-types.js';
|
|
15
|
+
export type { ACPCapturedDiff, ACPCapturedToolCall, ACPProgressEvent, ACPProgressHandler, ACPSessionErrorKind, ACPSessionOptions, ACPSessionRunResult, } from './acp-session-types.js';
|
|
16
|
+
export { ACPSessionError } from './acp-session-errors.js';
|
|
17
|
+
export { audioContent, imageContent, textContent } from './acp-session-content.js';
|
|
139
18
|
export declare class ACPSession {
|
|
140
19
|
private readonly transport;
|
|
141
20
|
private readonly fileServer;
|
|
@@ -324,56 +203,12 @@ export declare class ACPSession {
|
|
|
324
203
|
private sendResult;
|
|
325
204
|
/** Send a JSON-RPC 2.0 error response (no `method` field, per spec). */
|
|
326
205
|
private sendErrorResponse;
|
|
206
|
+
private responseSender;
|
|
327
207
|
private handleMessage;
|
|
328
|
-
private handleUpdate;
|
|
329
|
-
/**
|
|
330
|
-
* Fold a `tool_call` / `tool_call_update` notification into the scratch
|
|
331
|
-
* tool-call map (deduped by toolCallId), extract any `diff` content into
|
|
332
|
-
* the diffs list, and emit live progress.
|
|
333
|
-
*/
|
|
334
|
-
private captureToolCall;
|
|
335
208
|
private emitProgress;
|
|
336
209
|
/** Live progress handler installed for the duration of a `prompt()` turn. */
|
|
337
210
|
private progressHandler;
|
|
338
211
|
private scratch;
|
|
339
212
|
private resetScratch;
|
|
340
|
-
private handlePermissionRequest;
|
|
341
|
-
/**
|
|
342
|
-
* Enforce authorization at privileged callback sinks (fs/write,
|
|
343
|
-
* terminal/create). Unlike `handlePermissionRequest` which responds to
|
|
344
|
-
* agent-initiated `session/request_permission` messages, this method is
|
|
345
|
-
* called by the handler BEFORE dispatching to FileServer/TerminalServer,
|
|
346
|
-
* closing the gap where the agent simply skips the voluntary permission
|
|
347
|
-
* request and sends the privileged callback directly.
|
|
348
|
-
*
|
|
349
|
-
* Uses the session's permission policy. The default
|
|
350
|
-
* (`readOnlyPermissionPolicy`) auto-approves only side-effect-free tool
|
|
351
|
-
* calls (read/search/fetch/think) and rejects everything else — this is
|
|
352
|
-
* the safe-by-default posture. For trusted local agents (CLI `acp spawn`,
|
|
353
|
-
* Director fan-out), inject `defaultPermissionPolicy` to grant
|
|
354
|
-
* write/execute access.
|
|
355
|
-
*
|
|
356
|
-
* Returns true if the callback is authorized, false if denied.
|
|
357
|
-
*/
|
|
358
|
-
private authorizeCallback;
|
|
359
|
-
private handleFsRequest;
|
|
360
|
-
private handleTerminalRequest;
|
|
361
213
|
}
|
|
362
|
-
/**
|
|
363
|
-
* Create a text ContentBlock. Convenience helper for callers of
|
|
364
|
-
* `session.prompt()`.
|
|
365
|
-
*/
|
|
366
|
-
export declare function textContent(text: string): ContentBlock;
|
|
367
|
-
/**
|
|
368
|
-
* Create an image ContentBlock. Only send this if the agent's
|
|
369
|
-
* `promptCapabilities.image` is `true` (check via
|
|
370
|
-
* `session.getCapabilities().promptCapabilities?.image`).
|
|
371
|
-
*/
|
|
372
|
-
export declare function imageContent(mimeType: string, data: string): ContentBlock;
|
|
373
|
-
/**
|
|
374
|
-
* Create an audio ContentBlock. Only send this if the agent's
|
|
375
|
-
* `promptCapabilities.audio` is `true` (check via
|
|
376
|
-
* `session.getCapabilities().promptCapabilities?.audio`).
|
|
377
|
-
*/
|
|
378
|
-
export declare function audioContent(mimeType: string, data: string): ContentBlock;
|
|
379
214
|
//# sourceMappingURL=acp-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-session.d.ts","sourceRoot":"","sources":["../../src/client/acp-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"acp-session.d.ts","sourceRoot":"","sources":["../../src/client/acp-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,6BAA6B,CAAC;AAEvF,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAEV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAehC,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAYnF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoB;IACzC,OAAO,CAAC,YAAY,CAA6B;IAEjD,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,SAAS,CAA0B;IAC3C,gFAAgF;IAChF,OAA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