@wrongstack/acp 0.306.4 → 0.307.1
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/protocol-handler.d.ts +3 -49
- package/dist/agent/protocol-session-management.d.ts +36 -0
- package/dist/agent/protocol-session-ops.d.ts +59 -0
- package/dist/agent.js +430 -517
- package/dist/client/acp-session-ops.d.ts +33 -0
- package/dist/client/acp-session.d.ts +1 -98
- package/dist/client.js +242 -300
- package/dist/index.js +677 -822
- package/dist/wrongstack-acp-agent.js +430 -517
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ProtocolHandlerOptions, WRONGSTACK_VERSION } from './protocol-contract.js';
|
|
2
|
+
import { errorToJsonRpc } from './protocol-session-ops.js';
|
|
2
3
|
export type { AgentCapabilities, ClientCapabilities, PromptCapabilities, ProtocolHandlerOptions, RunTurn, RunTurnApi, RunTurnInput, RunTurnPermissionRequest, RunTurnResult, SessionConfigOption, SessionMode, SessionPersistence, SessionState, } from './protocol-contract.js';
|
|
3
4
|
export { WRONGSTACK_VERSION };
|
|
4
5
|
export declare class ACPProtocolHandler {
|
|
@@ -37,73 +38,26 @@ export declare class ACPProtocolHandler {
|
|
|
37
38
|
/** Abort all active turns and drop session state. */
|
|
38
39
|
close(): void;
|
|
39
40
|
private disposeSession;
|
|
41
|
+
private sessionContext;
|
|
40
42
|
private handleRequest;
|
|
41
43
|
private handleInitialize;
|
|
42
44
|
private handleAuthenticate;
|
|
43
45
|
private handleLogout;
|
|
44
|
-
private handleSessionNew;
|
|
45
|
-
private handleSessionLoad;
|
|
46
46
|
private handleSessionResume;
|
|
47
47
|
private handleSessionClose;
|
|
48
48
|
private handleSessionDelete;
|
|
49
|
-
private handleSessionFork;
|
|
50
49
|
private handleProvidersList;
|
|
51
50
|
private handleProvidersSet;
|
|
52
51
|
private handleProvidersDisable;
|
|
53
52
|
private handleMcpMessage;
|
|
54
|
-
private handleSessionPrompt;
|
|
55
|
-
private handleSetMode;
|
|
56
|
-
private handleSetConfigOption;
|
|
57
53
|
private handleSessionList;
|
|
58
54
|
private handleNotification;
|
|
59
55
|
private sendNotification;
|
|
60
|
-
|
|
56
|
+
private sendResult;
|
|
61
57
|
private persist;
|
|
62
58
|
private sendError;
|
|
63
|
-
/**
|
|
64
|
-
* Allocate a session id (WS-015).
|
|
65
|
-
*
|
|
66
|
-
* This was `this.nextId++`, so ids were `sess_1`, `sess_2`, … — and the
|
|
67
|
-
* handler has no per-connection ownership: any caller that names a session
|
|
68
|
-
* id can `session/load`, `session/prompt`, `session/cancel` or
|
|
69
|
-
* `session/delete` it. Over stdio that is academic (one client per process),
|
|
70
|
-
* but the agent also serves over HTTP, where a guessable id is the whole
|
|
71
|
-
* authorization story for any local process or page that reaches the port.
|
|
72
|
-
*
|
|
73
|
-
* Random ids do not create ownership — they remove the trivial enumeration
|
|
74
|
-
* that made its absence exploitable. Real per-connection ownership is the
|
|
75
|
-
* larger fix and is noted in the WS-015 test file.
|
|
76
|
-
*
|
|
77
|
-
* The counter is retained: it keeps ids ordered for debugging and guarantees
|
|
78
|
-
* uniqueness within a process even in the (impossible) event of a UUID
|
|
79
|
-
* collision. The random half is what makes the id unguessable.
|
|
80
|
-
*/
|
|
81
|
-
/**
|
|
82
|
-
* Resolve a client-supplied `cwd` for a session, or `null` when it is not
|
|
83
|
-
* usable (WS-015).
|
|
84
|
-
*
|
|
85
|
-
* `session/new`, `session/load` and `session/fork` all took `params.cwd`
|
|
86
|
-
* with a single `typeof === 'string'` check and nothing else. That value is
|
|
87
|
-
* the working directory the agent then reads, writes and executes in.
|
|
88
|
-
*
|
|
89
|
-
* SCOPE, deliberately stated: this does NOT confine the session to a root.
|
|
90
|
-
* In ACP the client IS the editor and legitimately names its own workspace —
|
|
91
|
-
* Zed and JetBrains pass the project root — so a fixed boundary here would
|
|
92
|
-
* break the integration this package exists for. What it enforces is that
|
|
93
|
-
* the directory is absolute and actually exists as a directory: a relative
|
|
94
|
-
* or missing `cwd` is a bug or an attack under either reading, and silently
|
|
95
|
-
* running the agent somewhere other than where the client asked is worse
|
|
96
|
-
* than refusing. Confinement, if wanted, belongs in an operator-set option
|
|
97
|
-
* on top of this, not in place of it.
|
|
98
|
-
*/
|
|
99
|
-
private resolveSessionCwd;
|
|
100
59
|
private allocId;
|
|
101
60
|
}
|
|
102
|
-
declare function errorToJsonRpc(err: unknown): {
|
|
103
|
-
code: number;
|
|
104
|
-
message: string;
|
|
105
|
-
data?: unknown;
|
|
106
|
-
};
|
|
107
61
|
/** Internal deterministic seam used by the per-file coverage suite. */
|
|
108
62
|
export declare const protocolHandlerCoverage: {
|
|
109
63
|
errorToJsonRpc: typeof errorToJsonRpc;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ClientCapabilities, RunTurn, SessionConfigOption, SessionMode, SessionPersistence, SessionState } from './protocol-contract.js';
|
|
2
|
+
export interface ProtocolSessionContext {
|
|
3
|
+
sessions: Map<string, SessionState>;
|
|
4
|
+
maxSessions: number;
|
|
5
|
+
defaultCwd: string;
|
|
6
|
+
modes: readonly SessionMode[];
|
|
7
|
+
configOptions: readonly SessionConfigOption[];
|
|
8
|
+
store: SessionPersistence | undefined;
|
|
9
|
+
replayFor: ((sessionId: string) => Array<{
|
|
10
|
+
sessionUpdate: string;
|
|
11
|
+
content: unknown;
|
|
12
|
+
}>) | undefined;
|
|
13
|
+
seedFor: ((sessionId: string, history: Array<{
|
|
14
|
+
sessionUpdate: string;
|
|
15
|
+
content: unknown;
|
|
16
|
+
}>) => void) | undefined;
|
|
17
|
+
onSessionNew: (state: SessionState) => void;
|
|
18
|
+
allocId: () => string;
|
|
19
|
+
persist: (state: SessionState, history?: Array<{
|
|
20
|
+
sessionUpdate: string;
|
|
21
|
+
content: unknown;
|
|
22
|
+
}>) => Promise<void>;
|
|
23
|
+
sendNotification: (params: unknown) => Promise<void>;
|
|
24
|
+
sendError: (id: string | number, code: number, message: string, data?: unknown) => Promise<void>;
|
|
25
|
+
sendResult: (id: string | number, result: unknown) => Promise<void>;
|
|
26
|
+
request: (method: string, params: unknown, timeoutMs?: number) => Promise<unknown>;
|
|
27
|
+
runTurn: RunTurn;
|
|
28
|
+
clientCapabilities: ClientCapabilities;
|
|
29
|
+
}
|
|
30
|
+
export declare function handleSessionNewOp(ctx: ProtocolSessionContext, id: string | number, params: unknown): Promise<boolean>;
|
|
31
|
+
export declare function handleSessionLoadOp(ctx: ProtocolSessionContext, id: string | number, params: unknown): Promise<boolean>;
|
|
32
|
+
export declare function handleSessionForkOp(ctx: ProtocolSessionContext, id: string | number, params: unknown): Promise<boolean>;
|
|
33
|
+
export declare function handleSessionPromptOp(ctx: ProtocolSessionContext, id: string | number, params: unknown): Promise<boolean>;
|
|
34
|
+
export declare function handleSetModeOp(ctx: ProtocolSessionContext, id: string | number, params: unknown): Promise<boolean>;
|
|
35
|
+
export declare function handleSetConfigOptionOp(ctx: ProtocolSessionContext, id: string | number, params: unknown): Promise<boolean>;
|
|
36
|
+
//# sourceMappingURL=protocol-session-management.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ClientCapabilities, type RunTurnApi, type SessionConfigOption, type SessionMode } from './protocol-contract.js';
|
|
2
|
+
export declare const WRONGSTACK_AUTH_METHODS: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
type: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
}[];
|
|
9
|
+
/** Single global mode id, sufficient for v1. */
|
|
10
|
+
export declare const DEFAULT_MODE_ID = "code";
|
|
11
|
+
export declare const DEFAULT_MAX_SESSIONS = 64;
|
|
12
|
+
export declare const DEFAULT_MODES: readonly SessionMode[];
|
|
13
|
+
export declare function resolveSessionCwd(requested: string): Promise<string | null>;
|
|
14
|
+
export declare function errorToJsonRpc(err: unknown): {
|
|
15
|
+
code: number;
|
|
16
|
+
message: string;
|
|
17
|
+
data?: unknown;
|
|
18
|
+
};
|
|
19
|
+
export declare function createRunTurnApi(sessionId: string, clientCapabilities: ClientCapabilities, request: (method: string, params: unknown) => Promise<unknown>): RunTurnApi;
|
|
20
|
+
export declare function buildInitializeResult(agentName: string, modes: readonly SessionMode[], configOptions: readonly SessionConfigOption[]): {
|
|
21
|
+
protocolVersion: 1;
|
|
22
|
+
agentCapabilities: {
|
|
23
|
+
loadSession: boolean;
|
|
24
|
+
promptCapabilities: {
|
|
25
|
+
image: boolean;
|
|
26
|
+
audio: boolean;
|
|
27
|
+
embeddedContext: boolean;
|
|
28
|
+
};
|
|
29
|
+
mcpCapabilities: {
|
|
30
|
+
http: boolean;
|
|
31
|
+
sse: boolean;
|
|
32
|
+
};
|
|
33
|
+
sessionCapabilities: {
|
|
34
|
+
close: {};
|
|
35
|
+
list: {};
|
|
36
|
+
delete: {};
|
|
37
|
+
resume: {};
|
|
38
|
+
fork: {};
|
|
39
|
+
};
|
|
40
|
+
auth: {
|
|
41
|
+
logout: {};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
agentInfo: {
|
|
45
|
+
name: string;
|
|
46
|
+
title: string;
|
|
47
|
+
version: string;
|
|
48
|
+
};
|
|
49
|
+
authMethods: {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
type: string;
|
|
54
|
+
args: string[];
|
|
55
|
+
}[];
|
|
56
|
+
modes: readonly SessionMode[];
|
|
57
|
+
configOptions: readonly SessionConfigOption[];
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=protocol-session-ops.d.ts.map
|