@automatalabs/acp-agents 0.9.1 → 0.10.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.
@@ -1,4 +1,4 @@
1
- import { ClientSideConnection, type ContentBlock, type PromptResponse, type RequestPermissionResponse, type SessionConfigOption, type SessionNotification } from "@agentclientprotocol/sdk";
1
+ import { type ContentBlock, type PromptRequest, type PromptResponse, type RequestPermissionResponse, type SessionConfigOption, type SessionNotification, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse } from "@agentclientprotocol/sdk";
2
2
  import type { TSchema } from "typebox";
3
3
  import { type AgentHistoryEntry, type McpServerConfig } from "@automatalabs/shared-types";
4
4
  import type { Backend, BackendId, StructuredSource } from "./backend.js";
@@ -92,8 +92,9 @@ export interface PooledConnectionDeps {
92
92
  */
93
93
  export declare class PooledConnection {
94
94
  readonly backendId: BackendId;
95
- /** The held ACP connection; SessionHandles drive their session/* calls through it. */
96
- readonly rpc: ClientSideConnection;
95
+ /** The held ACP connection (fluent client() app); session/* calls go through its
96
+ * `agent` ClientContext via the typed wrappers below. */
97
+ private readonly connection;
97
98
  private readonly backend;
98
99
  private readonly child;
99
100
  private readonly client;
@@ -138,6 +139,10 @@ export declare class PooledConnection {
138
139
  * synchronously (before the first await) so the pool's load accounting is race-free.
139
140
  */
140
141
  openSession(opts: AcpSessionOptions): Promise<SessionHandle>;
142
+ /** session/prompt on this connection, raced against process death. */
143
+ prompt(request: PromptRequest): Promise<PromptResponse>;
144
+ /** session/set_config_option on this connection, raced against process death. */
145
+ setSessionConfigOption(request: SetSessionConfigOptionRequest): Promise<SetSessionConfigOptionResponse>;
141
146
  /** Best-effort ACP cancel for one session (wired to opts.signal). The PROCESS stays pooled. */
142
147
  cancelSession(sessionId: string): Promise<void>;
143
148
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"acp-client.d.ts","sourceRoot":"","sources":["../src/acp-client.ts"],"names":[],"mappings":"AAwBA,OAAO,EACL,oB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AAC;IAgBjF;;;;;;;OAOG;YACW,mBAAmB;IA4CjC,sFAAsF;YACxE,iBAAiB;IAS/B,yEAAyE;IACnE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAoB7G,2DAA2D;IAC3D,eAAe,IAAI,MAAM;IAIzB,qFAAqF;IACrF,mBAAmB,IAAI,OAAO;IAI9B,gGAAgG;IAC1F,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,6EAA6E;IACvE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
@@ -16,13 +16,13 @@
16
16
  // per-session accumulator (SessionState) by `sessionId`.
17
17
  //
18
18
  // Draining: ACP delivers a prompt turn as session/update notifications followed by the
19
- // session/prompt response, in wire order on one stream. Our Client handlers are synchronous
20
- // (they only push into the routed session's arrays), so by the time `rpc.prompt(...)` resolves,
21
- // every update for THAT session's turn has already been folded into its accumulator — even while
22
- // other sessions' updates interleave on the same wire.
19
+ // session/prompt response, in wire order on one stream. Our client handlers are synchronous
20
+ // (they only push into the routed session's arrays), so by the time the session/prompt request
21
+ // resolves, every update for THAT session's turn has already been folded into its accumulator —
22
+ // even while other sessions' updates interleave on the same wire.
23
23
  import { spawn } from "node:child_process";
24
24
  import { Readable, Writable } from "node:stream";
25
- import { ClientSideConnection, CLIENT_METHODS, ndJsonStream, PROTOCOL_VERSION, RequestError, } from "@agentclientprotocol/sdk";
25
+ import { AGENT_METHODS, client, CLIENT_METHODS, ndJsonStream, PROTOCOL_VERSION, RequestError, } from "@agentclientprotocol/sdk";
26
26
  import { META_KEYS, WorkflowError, WorkflowErrorCode, } from "@automatalabs/shared-types";
27
27
  import { adaptPromptContent, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
28
28
  import { emitSessionUpdate } from "./events.js";
@@ -132,9 +132,10 @@ class SessionState {
132
132
  settle(cancelledPermissionResponse());
133
133
  }
134
134
  }
135
- /** The single ACP Client handler for one pooled connection. It ROUTES every notification and
136
- * permission request to the per-session SessionState by `sessionId`, so one process can serve
137
- * many concurrent sessions without their streams crossing. */
135
+ /** The single client-side handler set for one pooled connection (registered on the SDK's fluent
136
+ * client() app). It ROUTES every notification and permission request to the per-session
137
+ * SessionState by `sessionId`, so one process can serve many concurrent sessions without their
138
+ * streams crossing. */
138
139
  class MultiplexClient {
139
140
  backendId;
140
141
  onEvent;
@@ -354,8 +355,9 @@ function toolNameFromMeta(meta) {
354
355
  */
355
356
  export class PooledConnection {
356
357
  backendId;
357
- /** The held ACP connection; SessionHandles drive their session/* calls through it. */
358
- rpc;
358
+ /** The held ACP connection (fluent client() app); session/* calls go through its
359
+ * `agent` ClientContext via the typed wrappers below. */
360
+ connection;
359
361
  backend;
360
362
  child;
361
363
  client;
@@ -402,14 +404,39 @@ export class PooledConnection {
402
404
  this.resolveDead = resolve;
403
405
  });
404
406
  const stream = ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout));
405
- this.rpc = new ClientSideConnection(() => this.client, stream);
407
+ // The fluent client() app: every inbound agent->client request/notification is registered
408
+ // here and dispatched to the MultiplexClient router. All request handlers are registered
409
+ // unconditionally — MultiplexClient.dispatch() answers a method the consumer provided no
410
+ // handler for with the same -32601 "not advertised" error as before, so behavior is
411
+ // identical to the previous Client-interface wiring.
412
+ //
413
+ // ORDER MATTERS: the two accumulation-feeding notifications MUST be registered FIRST.
414
+ // The SDK Connection runs only the first matching handler synchronously inside the
415
+ // read-loop turn; later handlers each cost a microtask hop, which lets an in-flight
416
+ // session/prompt RESPONSE continuation overtake a session/update notification that
417
+ // arrived before it on the wire. Registering session/update (and the Claude raw-message
418
+ // channel) first preserves the drain contract this file documents — every update for a
419
+ // turn is folded into its accumulator before that turn's prompt() resolves — exactly as
420
+ // the SDK's own (deprecated) ClientSideConnection wrapper registered them.
421
+ this.connection = client({ name: CLIENT_INFO.name })
422
+ .onNotification(CLIENT_METHODS.session_update, ({ params }) => this.client.sessionUpdate(params))
423
+ .onNotification(CLAUDE_RAW_MESSAGE_METHOD, (params) => (params ?? {}), ({ params }) => this.client.extNotification(CLAUDE_RAW_MESSAGE_METHOD, params))
424
+ .onRequest(CLIENT_METHODS.session_request_permission, ({ params }) => this.client.requestPermission(params))
425
+ .onRequest(CLIENT_METHODS.fs_read_text_file, ({ params }) => this.client.readTextFile(params))
426
+ .onRequest(CLIENT_METHODS.fs_write_text_file, ({ params }) => this.client.writeTextFile(params))
427
+ .onRequest(CLIENT_METHODS.terminal_create, ({ params }) => this.client.createTerminal(params))
428
+ .onRequest(CLIENT_METHODS.terminal_output, ({ params }) => this.client.terminalOutput(params))
429
+ .onRequest(CLIENT_METHODS.terminal_release, ({ params }) => this.client.releaseTerminal(params))
430
+ .onRequest(CLIENT_METHODS.terminal_wait_for_exit, ({ params }) => this.client.waitForTerminalExit(params))
431
+ .onRequest(CLIENT_METHODS.terminal_kill, ({ params }) => this.client.killTerminal(params))
432
+ .connect(stream);
406
433
  // Death detection. The connection's `signal` aborts the INSTANT the underlying stream closes
407
434
  // (process crash or our own dispose) — in the SAME close() that rejects pending requests — so
408
435
  // it is the earliest, DETERMINISTIC death signal: a connection is marked dead and evicted
409
436
  // before its in-flight prompt's rejection even propagates, so a concurrent acquire can never
410
437
  // hand out a connection whose process has already died. The child 'exit'/'error' events are a
411
438
  // belt-and-suspenders backstop (and carry the exit code for a clearer message).
412
- this.rpc.signal.addEventListener("abort", () => this.die(new Error(`ACP agent (${this.backendId}) connection closed${this.stderrSuffix()}`)), { once: true });
439
+ this.connection.signal.addEventListener("abort", () => this.die(new Error(`ACP agent (${this.backendId}) connection closed${this.stderrSuffix()}`)), { once: true });
413
440
  child.once("error", (err) => this.die(err));
414
441
  child.once("exit", (code, sig) => {
415
442
  this.die(new Error(`ACP agent (${this.backendId}) process exited (code=${code}, signal=${sig})${this.stderrSuffix()}`));
@@ -486,7 +513,7 @@ export class PooledConnection {
486
513
  });
487
514
  try {
488
515
  const response = await Promise.race([
489
- this.race(this.rpc.initialize({
516
+ this.race(this.connection.agent.request(AGENT_METHODS.initialize, {
490
517
  protocolVersion: PROTOCOL_VERSION,
491
518
  // Truthful advertisement: computed from the consumer-provided handlers registered on
492
519
  // this runner. Omitted flags are unsupported; false flags are never sent deliberately.
@@ -550,7 +577,7 @@ export class PooledConnection {
550
577
  mcpServers: opts.mcpServers ?? [],
551
578
  ...(meta ? { _meta: meta } : {}),
552
579
  };
553
- const response = await this.race(this.rpc.newSession(request));
580
+ const response = await this.race(this.connection.agent.request(AGENT_METHODS.session_new, request));
554
581
  this.client.register(response.sessionId, state);
555
582
  return new SessionHandle(this, response.sessionId, state, response.configOptions ?? [], opts);
556
583
  }
@@ -559,13 +586,21 @@ export class PooledConnection {
559
586
  throw error;
560
587
  }
561
588
  }
589
+ /** session/prompt on this connection, raced against process death. */
590
+ prompt(request) {
591
+ return this.race(this.connection.agent.request(AGENT_METHODS.session_prompt, request));
592
+ }
593
+ /** session/set_config_option on this connection, raced against process death. */
594
+ setSessionConfigOption(request) {
595
+ return this.race(this.connection.agent.request(AGENT_METHODS.session_set_config_option, request));
596
+ }
562
597
  /** Best-effort ACP cancel for one session (wired to opts.signal). The PROCESS stays pooled. */
563
598
  async cancelSession(sessionId) {
564
599
  this.client.settlePendingPermissions(sessionId);
565
600
  if (!this._alive)
566
601
  return;
567
602
  try {
568
- await this.rpc.cancel({ sessionId });
603
+ await this.connection.agent.notify(AGENT_METHODS.session_cancel, { sessionId });
569
604
  }
570
605
  catch {
571
606
  // best-effort: the session settles as "cancelled" regardless.
@@ -583,7 +618,7 @@ export class PooledConnection {
583
618
  if (!this.negotiated?.supportsClose || !this._alive)
584
619
  return;
585
620
  try {
586
- await this.race(withTimeout(this.rpc.closeSession({ sessionId }), CLOSE_SESSION_TIMEOUT_MS));
621
+ await this.race(withTimeout(this.connection.agent.request(AGENT_METHODS.session_close, { sessionId }), CLOSE_SESSION_TIMEOUT_MS));
587
622
  }
588
623
  catch {
589
624
  // best-effort: the session is already untracked; the process stays pooled.
@@ -758,7 +793,11 @@ export class SessionHandle {
758
793
  }
759
794
  /** Set one session config option via the wire method and adopt the echoed catalog. */
760
795
  async applyConfigOption(configId, value) {
761
- const response = await this.pooled.race(this.pooled.rpc.setSessionConfigOption({ sessionId: this.sessionId, configId, value }));
796
+ const response = await this.pooled.setSessionConfigOption({
797
+ sessionId: this.sessionId,
798
+ configId,
799
+ value,
800
+ });
762
801
  this.configOptions = response.configOptions;
763
802
  }
764
803
  /** Send a prompt turn and drain it; returns the final PromptResponse. */
@@ -776,7 +815,7 @@ export class SessionHandle {
776
815
  prompt: typeof prompt === "string" ? [{ type: "text", text: prompt }] : prompt,
777
816
  ...(gatedMeta ? { _meta: gatedMeta } : {}),
778
817
  };
779
- const response = await this.pooled.race(this.pooled.rpc.prompt(request));
818
+ const response = await this.pooled.prompt(request);
780
819
  this.state.usage.recordPromptUsage(response.usage);
781
820
  return response;
782
821
  }
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@automatalabs/acp-agents",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "license": "Apache-2.0",
5
+ "engines": {
6
+ "node": ">=22"
7
+ },
5
8
  "repository": {
6
9
  "type": "git",
7
10
  "url": "git+https://github.com/VikashLoomba/agentprism-workflows.git",
@@ -24,11 +27,11 @@
24
27
  "access": "public"
25
28
  },
26
29
  "dependencies": {
27
- "@agentclientprotocol/sdk": "1.1.0",
28
- "@agentclientprotocol/claude-agent-acp": "0.55.0",
30
+ "@agentclientprotocol/sdk": "^1.2.0",
31
+ "@agentclientprotocol/claude-agent-acp": "0.56.0",
29
32
  "@automatalabs/codex-acp": "1.3.0",
30
33
  "typebox": "1.3.2",
31
- "@automatalabs/shared-types": "0.7.0"
34
+ "@automatalabs/shared-types": "0.8.0"
32
35
  },
33
36
  "scripts": {
34
37
  "build": "tsc -b",