@armadra/agent 0.6.4 → 0.6.5

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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ English · [简体中文](CHANGELOG.zh-CN.md)
5
5
  > This file is in English starting with 0.6.0. Release notes for 0.1 through 0.5.1 are in Chinese in
6
6
  > [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md). New entries go into both files.
7
7
 
8
+ ## 0.6.5 (2026-10-03)
9
+
10
+ - **`AcpClient` can pass MCP servers when opening a session**: `newSession`, `resumeSession` and `loadSession` take an
11
+ optional third argument `{ mcpServers }` that is forwarded as-is in `session/new|resume|load` (default still `[]`, the
12
+ wire is unchanged when it is omitted). `AcpClient.features.mcpServers` lets a host detect support. ama itself still
13
+ sends none. Docs: docs/acp.md "As a client".
14
+
8
15
  ## 0.6.4 (2026-10-03)
9
16
 
10
17
  - **Interrupt and send now**: while a run is in progress, Enter still queues the message as a steer (delivered at the next
@@ -4,6 +4,12 @@
4
4
 
5
5
  > 从 0.6.0 起 [CHANGELOG.md](CHANGELOG.md) 为英文,本文件保留中文记录(0.1–0.5.1 的完整历史在此)。新条目两份都要加。
6
6
 
7
+ ## 0.6.5(2026-10-03)
8
+
9
+ - **`AcpClient` 开会话可传 MCP 服务器**:`newSession`、`resumeSession`、`loadSession` 新增可选的第三个参数
10
+ `{ mcpServers }`,原样随 `session/new|resume|load` 发出(缺省仍是 `[]`,不传时线路不变);宿主用
11
+ `AcpClient.features.mcpServers` 检测是否支持。ama 自己仍不传。文档:docs/acp.md「作为客户端」。
12
+
7
13
  ## 0.6.4(2026-10-03)
8
14
 
9
15
  - **打断并立即发送**:运行中按 Enter 仍是排队插话(等下一个投递点送达),新增 `Ctrl+X`(键位动作 `app.message.interrupt`)立即中止
@@ -41,7 +41,7 @@ var AMA_VERSION;
41
41
  var init_version = __esm({
42
42
  "src/version.ts"() {
43
43
  "use strict";
44
- AMA_VERSION = true ? "0.6.4" : readPackageVersion();
44
+ AMA_VERSION = true ? "0.6.5" : readPackageVersion();
45
45
  }
46
46
  });
47
47
 
@@ -30738,6 +30738,9 @@ var init_jsonrpc = __esm({
30738
30738
  });
30739
30739
 
30740
30740
  // src/drivers/acp/client.ts
30741
+ function mcpServersOf(options) {
30742
+ return [...options?.mcpServers ?? []];
30743
+ }
30741
30744
  function unattendedOutcome(params) {
30742
30745
  const reject2 = params.options.find((o) => o.kind === "reject_once");
30743
30746
  return {
@@ -30769,6 +30772,11 @@ var init_client = __esm({
30769
30772
  });
30770
30773
  }
30771
30774
  options;
30775
+ /**
30776
+ * 本版客户端支持的可选能力,供宿主做特性检测(旧版没有这个字段):
30777
+ * - `mcpServers`:开会话时可经 {@link AcpSessionOptions} 传 MCP 服务器。
30778
+ */
30779
+ static features = { mcpServers: true };
30772
30780
  peer;
30773
30781
  /** sessionId → 挂起权限请求的取消器。 */
30774
30782
  pendingPermissions = /* @__PURE__ */ new Map();
@@ -30818,16 +30826,28 @@ var init_client = __esm({
30818
30826
  supportsImages() {
30819
30827
  return this.agentCapabilities.promptCapabilities?.image === true;
30820
30828
  }
30821
- newSession(cwd, signal) {
30822
- return this.peer.request(ACP_METHODS.sessionNew, { cwd, mcpServers: [] }, signal);
30829
+ newSession(cwd, signal, options) {
30830
+ return this.peer.request(
30831
+ ACP_METHODS.sessionNew,
30832
+ { cwd, mcpServers: mcpServersOf(options) },
30833
+ signal
30834
+ );
30823
30835
  }
30824
30836
  /** 不回放历史(优先,R13:v2 计划取消 load)。 */
30825
- resumeSession(sessionId, cwd, signal) {
30826
- return this.peer.request(ACP_METHODS.sessionResume, { sessionId, cwd, mcpServers: [] }, signal);
30837
+ resumeSession(sessionId, cwd, signal, options) {
30838
+ return this.peer.request(
30839
+ ACP_METHODS.sessionResume,
30840
+ { sessionId, cwd, mcpServers: mcpServersOf(options) },
30841
+ signal
30842
+ );
30827
30843
  }
30828
30844
  /** 回放历史(以 session/update 通知)。 */
30829
- loadSession(sessionId, cwd, signal) {
30830
- return this.peer.request(ACP_METHODS.sessionLoad, { sessionId, cwd, mcpServers: [] }, signal);
30845
+ loadSession(sessionId, cwd, signal, options) {
30846
+ return this.peer.request(
30847
+ ACP_METHODS.sessionLoad,
30848
+ { sessionId, cwd, mcpServers: mcpServersOf(options) },
30849
+ signal
30850
+ );
30831
30851
  }
30832
30852
  listSessions(cwd, cursor) {
30833
30853
  return this.peer.request(ACP_METHODS.sessionList, {
@@ -8,8 +8,10 @@
8
8
  * 没有处理器时按无人值守回首个 `reject_once`(没有则 cancelled)。
9
9
  * - `cancel(sessionId)` 发 `session/cancel` 通知,并让该会话所有挂起的权限请求回 `cancelled`
10
10
  * (规范要求:客户端取消回合后必须以 cancelled 回答挂起的请求)。
11
+ * - 开会话(new / resume / load)的 `mcpServers` 缺省为空数组;宿主可经 {@link AcpSessionOptions}
12
+ * 传入,原样转发。
11
13
  */
12
- import { type AcpAgentCapabilities, type AcpContentBlock, type AcpImplementationInfo, type AcpInitializeResult, type AcpListSessionsResult, type AcpLoadSessionResult, type AcpNewSessionResult, type AcpPromptResult, type AcpRequestPermissionParams, type AcpRequestPermissionResult, type AcpSessionNotification } from "./types.js";
14
+ import { type AcpAgentCapabilities, type AcpContentBlock, type AcpImplementationInfo, type AcpInitializeResult, type AcpListSessionsResult, type AcpLoadSessionResult, type AcpNewSessionResult, type AcpPromptResult, type AcpRequestPermissionParams, type AcpRequestPermissionResult, type AcpSessionNotification, type AcpSessionOptions } from "./types.js";
13
15
  export interface AcpClientHandlers {
14
16
  onUpdate?(notification: AcpSessionNotification): void;
15
17
  /** `signal`:该会话被 cancel、连接关闭时 abort(此时应尽快回 cancelled)。 */
@@ -26,6 +28,13 @@ export interface AcpClientOptions extends AcpClientHandlers {
26
28
  export declare function unattendedOutcome(params: AcpRequestPermissionParams): AcpRequestPermissionResult;
27
29
  export declare class AcpClient {
28
30
  private readonly options;
31
+ /**
32
+ * 本版客户端支持的可选能力,供宿主做特性检测(旧版没有这个字段):
33
+ * - `mcpServers`:开会话时可经 {@link AcpSessionOptions} 传 MCP 服务器。
34
+ */
35
+ static readonly features: {
36
+ readonly mcpServers: true;
37
+ };
29
38
  private readonly peer;
30
39
  /** sessionId → 挂起权限请求的取消器。 */
31
40
  private readonly pendingPermissions;
@@ -41,11 +50,11 @@ export declare class AcpClient {
41
50
  supportsList(): boolean;
42
51
  supportsClose(): boolean;
43
52
  supportsImages(): boolean;
44
- newSession(cwd: string, signal?: AbortSignal): Promise<AcpNewSessionResult>;
53
+ newSession(cwd: string, signal?: AbortSignal, options?: AcpSessionOptions): Promise<AcpNewSessionResult>;
45
54
  /** 不回放历史(优先,R13:v2 计划取消 load)。 */
46
- resumeSession(sessionId: string, cwd: string, signal?: AbortSignal): Promise<AcpLoadSessionResult>;
55
+ resumeSession(sessionId: string, cwd: string, signal?: AbortSignal, options?: AcpSessionOptions): Promise<AcpLoadSessionResult>;
47
56
  /** 回放历史(以 session/update 通知)。 */
48
- loadSession(sessionId: string, cwd: string, signal?: AbortSignal): Promise<AcpLoadSessionResult>;
57
+ loadSession(sessionId: string, cwd: string, signal?: AbortSignal, options?: AcpSessionOptions): Promise<AcpLoadSessionResult>;
49
58
  listSessions(cwd?: string, cursor?: string): Promise<AcpListSessionsResult>;
50
59
  closeSession(sessionId: string): Promise<unknown>;
51
60
  prompt(sessionId: string, prompt: AcpContentBlock[], signal?: AbortSignal): Promise<AcpPromptResult>;
@@ -8,9 +8,15 @@
8
8
  * 没有处理器时按无人值守回首个 `reject_once`(没有则 cancelled)。
9
9
  * - `cancel(sessionId)` 发 `session/cancel` 通知,并让该会话所有挂起的权限请求回 `cancelled`
10
10
  * (规范要求:客户端取消回合后必须以 cancelled 回答挂起的请求)。
11
+ * - 开会话(new / resume / load)的 `mcpServers` 缺省为空数组;宿主可经 {@link AcpSessionOptions}
12
+ * 传入,原样转发。
11
13
  */
12
14
  import { JsonRpcPeer, RpcError } from "../jsonrpc.js";
13
15
  import { ACP_METHODS, ACP_PROTOCOL_VERSION, RPC_ERRORS, } from "./types.js";
16
+ /** 开会话参数里的 `mcpServers`:拷一份,缺省空数组。 */
17
+ function mcpServersOf(options) {
18
+ return [...(options?.mcpServers ?? [])];
19
+ }
14
20
  /** 无人值守的回答:首个 reject_once,没有就 cancelled。 */
15
21
  export function unattendedOutcome(params) {
16
22
  const reject = params.options.find((o) => o.kind === "reject_once");
@@ -22,6 +28,11 @@ export function unattendedOutcome(params) {
22
28
  }
23
29
  export class AcpClient {
24
30
  options;
31
+ /**
32
+ * 本版客户端支持的可选能力,供宿主做特性检测(旧版没有这个字段):
33
+ * - `mcpServers`:开会话时可经 {@link AcpSessionOptions} 传 MCP 服务器。
34
+ */
35
+ static features = { mcpServers: true };
25
36
  peer;
26
37
  /** sessionId → 挂起权限请求的取消器。 */
27
38
  pendingPermissions = new Map();
@@ -85,16 +96,16 @@ export class AcpClient {
85
96
  supportsImages() {
86
97
  return this.agentCapabilities.promptCapabilities?.image === true;
87
98
  }
88
- newSession(cwd, signal) {
89
- return this.peer.request(ACP_METHODS.sessionNew, { cwd, mcpServers: [] }, signal);
99
+ newSession(cwd, signal, options) {
100
+ return this.peer.request(ACP_METHODS.sessionNew, { cwd, mcpServers: mcpServersOf(options) }, signal);
90
101
  }
91
102
  /** 不回放历史(优先,R13:v2 计划取消 load)。 */
92
- resumeSession(sessionId, cwd, signal) {
93
- return this.peer.request(ACP_METHODS.sessionResume, { sessionId, cwd, mcpServers: [] }, signal);
103
+ resumeSession(sessionId, cwd, signal, options) {
104
+ return this.peer.request(ACP_METHODS.sessionResume, { sessionId, cwd, mcpServers: mcpServersOf(options) }, signal);
94
105
  }
95
106
  /** 回放历史(以 session/update 通知)。 */
96
- loadSession(sessionId, cwd, signal) {
97
- return this.peer.request(ACP_METHODS.sessionLoad, { sessionId, cwd, mcpServers: [] }, signal);
107
+ loadSession(sessionId, cwd, signal, options) {
108
+ return this.peer.request(ACP_METHODS.sessionLoad, { sessionId, cwd, mcpServers: mcpServersOf(options) }, signal);
98
109
  }
99
110
  listSessions(cwd, cursor) {
100
111
  return this.peer.request(ACP_METHODS.sessionList, {
@@ -111,8 +111,28 @@ export interface AcpInitializeResult {
111
111
  authMethods?: AcpAuthMethod[];
112
112
  agentInfo?: AcpImplementationInfo;
113
113
  }
114
- /** ama 不向外部 Agent 传 MCP 服务器(Skills 不做 MCP),总是空数组。 */
115
- export type AcpMcpServer = Record<string, unknown>;
114
+ /** `session/new.mcpServers[].env` 的一项。 */
115
+ export type AcpEnvVariable = {
116
+ name: string;
117
+ value: string;
118
+ };
119
+ /** stdio 传输的 MCP 服务器:ACP v1 要求每个 Agent 都支持这一种。 */
120
+ export type AcpStdioMcpServer = {
121
+ name: string;
122
+ command: string;
123
+ args: string[];
124
+ env: AcpEnvVariable[];
125
+ };
126
+ /**
127
+ * 交给外部 Agent 的 MCP 服务器。ama 自己不加(Skills 不做 MCP),缺省是空数组;宿主(如 Armadra)
128
+ * 经 {@link AcpSessionOptions} 传入的原样转发,http / sse 变体不在这里解释。
129
+ */
130
+ export type AcpMcpServer = AcpStdioMcpServer | Record<string, unknown>;
131
+ /** `AcpClient.newSession` / `resumeSession` / `loadSession` 的可选项。 */
132
+ export interface AcpSessionOptions {
133
+ /** 随 `session/new|resume|load` 发给 Agent;缺省空数组。 */
134
+ mcpServers?: readonly AcpMcpServer[];
135
+ }
116
136
  export interface AcpSessionMode {
117
137
  id: string;
118
138
  name: string;
package/docs/acp.md CHANGED
@@ -64,6 +64,9 @@ stdin 关闭后等已开始的运行结束再退出(0);SIGINT / SIGTERM
64
64
  - `session/request_permission` 交给 `onPermission`;没有处理器时回首个 `reject_once`(无人值守)。
65
65
  - `cancel(sessionId)` 发 `session/cancel`,并让该会话挂起的权限请求回 `cancelled`(规范要求)。
66
66
  - 只接受 Agent 自己给出的 `optionId`。
67
+ - 开会话(`newSession` / `resumeSession` / `loadSession`)的 `mcpServers` 缺省为空数组;宿主可传第三个参数
68
+ `{ mcpServers }`(如 stdio 的 `{ name, command, args, env: [{ name, value }] }`),原样转发给 Agent。
69
+ `AcpClient.features.mcpServers === true` 表示支持(旧版没有 `features`)。ama 自己作客户端时仍不传。
67
70
 
68
71
  `AcpDriver` 在客户端之上实现驱动契约(`AgentDriver`):续接优先 `session/resume`,其次 `session/load`(回放的历史丢弃),都不支持就新开并提示;按 ama 模式 `session/set_mode`,只读模式找不到对应模式 id 时拒绝启动。
69
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armadra/agent",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "A coding and coordination agent that runs standalone or embedded in Armadra",
5
5
  "type": "module",
6
6
  "keywords": [