@qlairoslabs/acp-client 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qlairoslabs/acp-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Embeddable Agent Client Protocol (ACP) client library with degraded PTY fallback.",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
@@ -16,6 +16,7 @@
16
16
  },
17
17
  "keywords": [
18
18
  "acp",
19
+ "agnostic acp client",
19
20
  "agent-client-protocol",
20
21
  "ai-agent",
21
22
  "coding-agent",
@@ -23,6 +24,7 @@
23
24
  "codex",
24
25
  "claude",
25
26
  "kimi",
27
+ "opencode",
26
28
  "repl",
27
29
  "bun"
28
30
  ],
@@ -10,6 +10,7 @@
10
10
  // agent dies on switch). Mode-swap (degrade/upgrade) stays within one AgentSession.
11
11
 
12
12
  import { AgentController, type AgentMode } from "./controller.ts";
13
+ import type * as schema from "@agentclientprotocol/sdk";
13
14
  import type { Adapter } from "./adapters.ts";
14
15
  import type { AgentClient, Bridgeable, BridgeOptions, InterruptOptions } from "./agent-client.ts";
15
16
  import type { Capabilities } from "./capabilities.ts";
@@ -35,6 +36,8 @@ export interface AgentSessionConfig {
35
36
  execPrefix?: string[];
36
37
  env?: Record<string, string>;
37
38
  cwd?: string;
39
+ /** Default MCP servers bound at session creation/switch, unless a call overrides them. */
40
+ mcpServers?: schema.McpServer[];
38
41
  defaultPermission?: "approve" | "cancel";
39
42
  clientInfo?: { name: string; title?: string; version?: string };
40
43
  logger?: Logger;
@@ -75,6 +78,7 @@ export class AgentSession implements AgentClient, Bridgeable {
75
78
  env: config.env,
76
79
  cwd: config.cwd,
77
80
  sessionId: config.agentSessionId,
81
+ mcpServers: config.mcpServers,
78
82
  defaultPermission: config.defaultPermission,
79
83
  clientInfo: config.clientInfo,
80
84
  logger: config.logger,
package/src/controller.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AcpClient, type AcpClientConfig, type ConnectResult, type SwitchSessionOptions } from "./client.ts";
2
+ import type * as schema from "@agentclientprotocol/sdk";
2
3
  import type { Adapter } from "./adapters.ts";
3
4
  import type { AgentClient, Bridgeable, BridgeOptions, InterruptOptions } from "./agent-client.ts";
4
5
  import type { Capabilities } from "./capabilities.ts";
@@ -33,6 +34,8 @@ export interface AgentControllerConfig {
33
34
  cwd?: string;
34
35
  /** Session id to load on start(). */
35
36
  sessionId?: string;
37
+ /** Default MCP servers bound at session creation/switch, unless a call overrides them. */
38
+ mcpServers?: schema.McpServer[];
36
39
  defaultPermission?: "approve" | "cancel";
37
40
  clientInfo?: AcpClientConfig["clientInfo"];
38
41
  logger?: Logger;
@@ -211,9 +214,11 @@ export class AgentController implements AgentClient {
211
214
  return this.requireAcp().authenticate(methodId, handlers);
212
215
  }
213
216
 
214
- /** Force a fresh session (e.g. after /login). */
215
- newSession(): Promise<ConnectResult> {
216
- return this.requireAcp().newSession();
217
+ /** Force a fresh session (e.g. after /login). mcpServers defaults to config.mcpServers. */
218
+ newSession(options: { mcpServers?: schema.McpServer[] } = {}): Promise<ConnectResult> {
219
+ return this.requireAcp().newSession({
220
+ mcpServers: options.mcpServers ?? this.config.mcpServers,
221
+ });
217
222
  }
218
223
 
219
224
  listSessions(): Promise<SessionListPage> {
@@ -221,15 +226,24 @@ export class AgentController implements AgentClient {
221
226
  }
222
227
 
223
228
  loadSession(sessionId: string, options: SwitchSessionOptions = {}): Promise<ConnectResult> {
224
- return this.requireAcp().loadSession(sessionId, options);
229
+ return this.requireAcp().loadSession(sessionId, {
230
+ ...options,
231
+ mcpServers: options.mcpServers ?? this.config.mcpServers,
232
+ });
225
233
  }
226
234
 
227
235
  resumeSession(sessionId: string, options: SwitchSessionOptions = {}): Promise<ConnectResult> {
228
- return this.requireAcp().resumeSession(sessionId, options);
236
+ return this.requireAcp().resumeSession(sessionId, {
237
+ ...options,
238
+ mcpServers: options.mcpServers ?? this.config.mcpServers,
239
+ });
229
240
  }
230
241
 
231
242
  forkSession(sessionId: string, options: SwitchSessionOptions = {}): Promise<ConnectResult> {
232
- return this.requireAcp().forkSession(sessionId, options);
243
+ return this.requireAcp().forkSession(sessionId, {
244
+ ...options,
245
+ mcpServers: options.mcpServers ?? this.config.mcpServers,
246
+ });
233
247
  }
234
248
 
235
249
  setConfig(configId: string, value: unknown): Promise<void> {
@@ -368,7 +382,7 @@ export class AgentController implements AgentClient {
368
382
  }
369
383
  let result: ConnectResult;
370
384
  try {
371
- result = await client.startSession();
385
+ result = await client.startSession({ mcpServers: this.config.mcpServers });
372
386
  } catch (err) {
373
387
  this.config.logger?.warn("session_start_failed", { error: String(err) });
374
388
  result = { sessionId: "", resumed: false };