@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.
@@ -0,0 +1,33 @@
1
+ import type { AgentCapabilities, McpServer, SessionId, SessionInfo } from '../types/acp-v1.js';
2
+ import type { ACPSessionOptions } from './acp-session-types.js';
3
+ export declare function filterMcpServers(agentCapabilities: AgentCapabilities, servers?: McpServer[]): McpServer[];
4
+ export interface ACPSessionOpContext {
5
+ closed: boolean;
6
+ sessionId: SessionId | null;
7
+ agentCapabilities: AgentCapabilities;
8
+ opts: ACPSessionOptions;
9
+ allocId: () => number;
10
+ sendRequest: (id: number, method: string, params: unknown, timeoutMs?: number) => Promise<unknown>;
11
+ setSessionId: (id: SessionId | null) => void;
12
+ resetScratch: () => void;
13
+ closeSession: () => Promise<void>;
14
+ }
15
+ export declare function executeLoadSession(ctx: ACPSessionOpContext, sessionId: SessionId, mcpServers?: McpServer[], cwd?: string): Promise<void>;
16
+ export declare function executeResumeSession(ctx: ACPSessionOpContext, sessionId: SessionId, mcpServers?: McpServer[], cwd?: string): Promise<void>;
17
+ export declare function executeListSessions(ctx: ACPSessionOpContext, cursor?: string, cwd?: string): Promise<{
18
+ sessions: SessionInfo[];
19
+ nextCursor?: string | undefined;
20
+ }>;
21
+ export declare function executeDeleteSession(ctx: ACPSessionOpContext, sessionId: SessionId): Promise<void>;
22
+ export declare function executeForkSession(ctx: ACPSessionOpContext, sourceSessionId: SessionId, cwd?: string, mcpServers?: McpServer[]): Promise<SessionId>;
23
+ export declare function executeSetMode(ctx: ACPSessionOpContext, sessionId: SessionId, modeId: string): Promise<void>;
24
+ export declare function executeSetConfigOption(ctx: ACPSessionOpContext, sessionId: SessionId, configId: string, value: string): Promise<void>;
25
+ export declare function executeListProviders(ctx: ACPSessionOpContext): Promise<{
26
+ providers: unknown[];
27
+ currentProviderId: string | null;
28
+ }>;
29
+ export declare function executeSetProvider(ctx: ACPSessionOpContext, providerId: string, config?: Record<string, unknown>): Promise<void>;
30
+ export declare function executeDisableProvider(ctx: ACPSessionOpContext): Promise<void>;
31
+ export declare function executeMcpMessage(ctx: ACPSessionOpContext, connectionId: string, message: Record<string, unknown>): Promise<unknown>;
32
+ export declare function executeCreateSession(ctx: ACPSessionOpContext): Promise<SessionId>;
33
+ //# sourceMappingURL=acp-session-ops.d.ts.map
@@ -77,9 +77,6 @@ export declare class ACPSession {
77
77
  /**
78
78
  * Authenticate with the agent using one of the advertised auth methods.
79
79
  * Call this AFTER start() and BEFORE any session/new call.
80
- *
81
- * Throws ACPSessionError('auth_failed') if the agent rejects the
82
- * authentication or if the methodId is not in the advertised list.
83
80
  */
84
81
  authenticate(methodId: string): Promise<void>;
85
82
  /**
@@ -87,129 +84,35 @@ export declare class ACPSession {
87
84
  * Only callable if the agent advertises `auth.logout` capability.
88
85
  */
89
86
  logout(): Promise<void>;
90
- /**
91
- * Load an existing session. The agent replays the conversation history
92
- * via session/update notifications before responding.
93
- *
94
- * Only works if the agent advertises `loadSession` capability.
95
- *
96
- * @param sessionId - The session to load
97
- * @param mcpServers - Optional MCP servers (defaults to options.mcpServers)
98
- * @param cwd - Optional working directory (defaults to options.cwd or projectRoot)
99
- */
87
+ private opContext;
100
88
  loadSession(sessionId: SessionId, mcpServers?: McpServer[], cwd?: string): Promise<void>;
101
- /**
102
- * Resume an existing session without replaying history.
103
- *
104
- * Only works if the agent advertises `sessionCapabilities.resume`.
105
- *
106
- * @param sessionId - The session to resume
107
- * @param mcpServers - Optional MCP servers (defaults to options.mcpServers)
108
- * @param cwd - Optional working directory (defaults to options.cwd or projectRoot)
109
- */
110
89
  resumeSession(sessionId: SessionId, mcpServers?: McpServer[], cwd?: string): Promise<void>;
111
- /**
112
- * List existing sessions known to the agent.
113
- *
114
- * Only works if the agent advertises `sessionCapabilities.list`.
115
- */
116
90
  listSessions(cursor?: string, cwd?: string): Promise<{
117
91
  sessions: SessionInfo[];
118
92
  nextCursor?: string | undefined;
119
93
  }>;
120
- /**
121
- * Delete a session from the agent's session list.
122
- *
123
- * Only works if the agent advertises `sessionCapabilities.delete`.
124
- */
125
94
  deleteSession(sessionId: SessionId): Promise<void>;
126
- /**
127
- * Fork a session — create a new session from an existing one.
128
- */
129
95
  forkSession(sourceSessionId: SessionId, cwd?: string, mcpServers?: McpServer[]): Promise<SessionId>;
130
- /**
131
- * Set the active mode for a session.
132
- */
133
96
  setMode(sessionId: SessionId, modeId: string): Promise<void>;
134
- /**
135
- * Set a configuration option for a session.
136
- */
137
97
  setConfigOption(sessionId: SessionId, configId: string, value: string): Promise<void>;
138
- /**
139
- * List available providers and the current provider.
140
- */
141
98
  listProviders(): Promise<{
142
99
  providers: unknown[];
143
100
  currentProviderId: string | null;
144
101
  }>;
145
- /**
146
- * Send an MCP message to the agent for routing.
147
- */
148
102
  mcpMessage(connectionId: string, message: Record<string, unknown>): Promise<unknown>;
149
- /**
150
- * Set the active provider for the agent.
151
- */
152
103
  setProvider(providerId: string, config?: Record<string, unknown>): Promise<void>;
153
- /**
154
- * Disable the current provider.
155
- */
156
104
  disableProvider(): Promise<void>;
157
- /**
158
- * Run one prompt turn. Creates a session if needed, sends the
159
- * prompt, streams session/update notifications, and resolves with
160
- * the agent's response.
161
- *
162
- * @param blocks - Content blocks to send. Use `textContent()` for plain
163
- * text, or include ImageContent/AudioContent if the agent's
164
- * `promptCapabilities` allow it.
165
- * @param signal - AbortSignal for cancellation.
166
- *
167
- * Cancellation: if `signal` aborts mid-prompt, we send
168
- * `session/cancel` (a notification per spec) and keep accepting
169
- * updates until the agent returns with `stopReason: 'cancelled'`.
170
- * The result is the same shape as a normal turn, with
171
- * `stopReason === 'cancelled'`.
172
- */
173
105
  prompt(blocks: ContentBlock[], signal: AbortSignal, onProgress?: ACPProgressHandler): Promise<ACPSessionRunResult>;
174
- private createSession;
175
- /**
176
- * Close the current session gracefully (if the agent supports it).
177
- *
178
- * Sends `session/close` JSON-RPC request, then clears the local
179
- * session id. Best-effort — errors are swallowed so the caller can
180
- * always proceed to transport teardown.
181
- */
182
106
  private closeSession;
183
- /** Tear down the session and kill the child process. */
184
107
  close(): Promise<void>;
185
- /**
186
- * Filter MCP servers according to agent capabilities.
187
- * - Stdio servers are always included.
188
- * - HTTP servers are only included if agent supports mcpCapabilities.http.
189
- * - SSE servers are only included if agent supports mcpCapabilities.sse.
190
- */
191
- private filterMcpServers;
192
108
  private allocId;
193
109
  private sendRequest;
194
- /**
195
- * Send a JSON-RPC 2.0 success response to an agent-initiated request.
196
- *
197
- * Per JSON-RPC 2.0 (and the official ACP SDK's message router) a Response
198
- * object MUST carry `jsonrpc: "2.0"` and MUST NOT carry a `method` field —
199
- * the SDK classifies any object with a `method` key as a Request and drops
200
- * it as a response, so an agent's `fs/*`, `terminal/*`, or
201
- * `session/request_permission` callback would hang forever. The legacy
202
- * `ACPMessage` type predates v1 (requires `method`, lacks `jsonrpc`), so we
203
- * build the correct wire object and cast at the boundary.
204
- */
205
110
  private sendResult;
206
- /** Send a JSON-RPC 2.0 error response (no `method` field, per spec). */
207
111
  private sendErrorResponse;
208
112
  private responseSender;
209
113
  private callbackOptions;
210
114
  private handleMessage;
211
115
  private emitProgress;
212
- /** Live progress handler installed for the duration of a `prompt()` turn. */
213
116
  private progressHandler;
214
117
  private scratch;
215
118
  private resetScratch;