@bbigbang/runtime-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.
- package/dist/acp/client.d.ts +101 -0
- package/dist/acp/client.js +747 -0
- package/dist/acp/jsonrpc.d.ts +31 -0
- package/dist/acp/jsonrpc.js +18 -0
- package/dist/acp/stdio.d.ts +15 -0
- package/dist/acp/stdio.js +201 -0
- package/dist/acp/types.d.ts +171 -0
- package/dist/acp/types.js +1 -0
- package/dist/db/db.d.ts +3 -0
- package/dist/db/db.js +10 -0
- package/dist/db/deliveryCheckpointStore.d.ts +21 -0
- package/dist/db/deliveryCheckpointStore.js +28 -0
- package/dist/db/migrations.d.ts +2 -0
- package/dist/db/migrations.js +6196 -0
- package/dist/db/uiPrefStore.d.ts +4 -0
- package/dist/db/uiPrefStore.js +18 -0
- package/dist/gateway/bindingRuntime.d.ts +113 -0
- package/dist/gateway/bindingRuntime.js +1267 -0
- package/dist/gateway/history.d.ts +7 -0
- package/dist/gateway/history.js +146 -0
- package/dist/gateway/sessionStore.d.ts +79 -0
- package/dist/gateway/sessionStore.js +126 -0
- package/dist/gateway/toolAuth.d.ts +36 -0
- package/dist/gateway/toolAuth.js +372 -0
- package/dist/gateway/types.d.ts +79 -0
- package/dist/gateway/types.js +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +19 -0
- package/dist/logging.d.ts +7 -0
- package/dist/logging.js +28 -0
- package/dist/runtime/lock.d.ts +5 -0
- package/dist/runtime/lock.js +87 -0
- package/dist/runtime/workspaceLockManager.d.ts +23 -0
- package/dist/runtime/workspaceLockManager.js +141 -0
- package/dist/tools/workspace.d.ts +1 -0
- package/dist/tools/workspace.js +13 -0
- package/package.json +38 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Db } from '../db/db.js';
|
|
2
|
+
import type { ToolAuth, ToolKind } from '../gateway/toolAuth.js';
|
|
3
|
+
import { WorkspaceLockManager } from '../runtime/workspaceLockManager.js';
|
|
4
|
+
import { type JsonRpcId } from './jsonrpc.js';
|
|
5
|
+
import { type StdioProcess } from './stdio.js';
|
|
6
|
+
import type { InitializeResult, NewSessionParams, NewSessionResult, PromptParams, PromptResult, RequestPermissionParams } from './types.js';
|
|
7
|
+
export type AcpRun = {
|
|
8
|
+
runId: string;
|
|
9
|
+
sessionKey: string;
|
|
10
|
+
createdAtMs: number;
|
|
11
|
+
};
|
|
12
|
+
export type PermissionRequest = {
|
|
13
|
+
requestId: JsonRpcId;
|
|
14
|
+
sessionKey: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
params: RequestPermissionParams;
|
|
17
|
+
createdAtMs: number;
|
|
18
|
+
};
|
|
19
|
+
export type PermissionDecision = {
|
|
20
|
+
kind: 'selected';
|
|
21
|
+
optionId: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'cancelled';
|
|
24
|
+
};
|
|
25
|
+
export type ClientToolEvent = {
|
|
26
|
+
phase: 'start' | 'end' | 'error';
|
|
27
|
+
method: string;
|
|
28
|
+
params: unknown;
|
|
29
|
+
result?: unknown;
|
|
30
|
+
error?: string;
|
|
31
|
+
};
|
|
32
|
+
export type AcpClientEvents = {
|
|
33
|
+
onSessionUpdate?: (run: AcpRun, sessionId: string, update: any, eventSeq: number) => void;
|
|
34
|
+
onPermissionRequest?: (req: PermissionRequest) => void;
|
|
35
|
+
onClientTool?: (run: AcpRun, event: ClientToolEvent) => void;
|
|
36
|
+
onTaskUpdate?: (run: AcpRun, task: {
|
|
37
|
+
title: string;
|
|
38
|
+
detail?: string;
|
|
39
|
+
silent?: boolean;
|
|
40
|
+
}) => void;
|
|
41
|
+
onAgentStderr?: (line: string) => void;
|
|
42
|
+
};
|
|
43
|
+
export declare class AcpClient {
|
|
44
|
+
private readonly db;
|
|
45
|
+
private readonly workspaceRoot;
|
|
46
|
+
private readonly agentCommand;
|
|
47
|
+
private readonly agentArgs;
|
|
48
|
+
private readonly toolAuth;
|
|
49
|
+
private readonly defaultAllowTools;
|
|
50
|
+
private disabledToolKinds;
|
|
51
|
+
private readonly workspaceLockManager;
|
|
52
|
+
private readonly rpc;
|
|
53
|
+
private nextId;
|
|
54
|
+
private readonly pending;
|
|
55
|
+
private currentRun;
|
|
56
|
+
private readonly runSeq;
|
|
57
|
+
private readonly pendingLocalPermissions;
|
|
58
|
+
private readonly events;
|
|
59
|
+
constructor(params: {
|
|
60
|
+
db: Db;
|
|
61
|
+
workspaceRoot: string;
|
|
62
|
+
agentCommand: string;
|
|
63
|
+
agentArgs: string[];
|
|
64
|
+
toolAuth?: ToolAuth;
|
|
65
|
+
defaultAllowTools?: boolean;
|
|
66
|
+
disabledToolKinds?: ToolKind[];
|
|
67
|
+
events?: AcpClientEvents;
|
|
68
|
+
rpc?: StdioProcess;
|
|
69
|
+
env?: Record<string, string>;
|
|
70
|
+
workspaceLockManager?: WorkspaceLockManager;
|
|
71
|
+
});
|
|
72
|
+
close(): void;
|
|
73
|
+
setDisabledToolKinds(disabledToolKinds?: ToolKind[]): void;
|
|
74
|
+
private initPromise;
|
|
75
|
+
initialize(): Promise<InitializeResult>;
|
|
76
|
+
newSession(params: NewSessionParams): Promise<NewSessionResult>;
|
|
77
|
+
prompt(run: AcpRun, params: PromptParams, timeoutMs?: number): Promise<PromptResult>;
|
|
78
|
+
notifyCancel(sessionId: string): void;
|
|
79
|
+
respondPermission(req: PermissionRequest, decision: PermissionDecision): Promise<void>;
|
|
80
|
+
private handleMessage;
|
|
81
|
+
private handleAgentRequest;
|
|
82
|
+
private request;
|
|
83
|
+
private rejectPendingRequest;
|
|
84
|
+
private rejectAllPending;
|
|
85
|
+
private rejectAllLocalPermissions;
|
|
86
|
+
private makeTransportError;
|
|
87
|
+
private respond;
|
|
88
|
+
private respondError;
|
|
89
|
+
private appendEvent;
|
|
90
|
+
private getExistingRunSeq;
|
|
91
|
+
private ensureAuthorized;
|
|
92
|
+
private readonly terminals;
|
|
93
|
+
private withWorkspaceWriteLock;
|
|
94
|
+
private acquireWorkspaceWriteLock;
|
|
95
|
+
private terminalCreate;
|
|
96
|
+
private terminalOutput;
|
|
97
|
+
private terminalWaitForExit;
|
|
98
|
+
private terminalKill;
|
|
99
|
+
private terminalRelease;
|
|
100
|
+
private killChild;
|
|
101
|
+
}
|