@armadra/agent 0.13.0 → 0.15.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.
- package/CHANGELOG.md +16 -0
- package/CHANGELOG.zh-CN.md +16 -0
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/dist/bridge/pi/args.d.ts +19 -0
- package/dist/bridge/pi/args.js +96 -0
- package/dist/bridge/pi/capabilities.d.ts +57 -0
- package/dist/bridge/pi/capabilities.js +65 -0
- package/dist/bridge/pi/config.d.ts +28 -0
- package/dist/bridge/pi/config.js +67 -0
- package/dist/bridge/pi/elicit.d.ts +23 -0
- package/dist/bridge/pi/elicit.js +86 -0
- package/dist/bridge/pi/entry.d.ts +14 -0
- package/dist/bridge/pi/entry.js +59 -0
- package/dist/bridge/pi/events.d.ts +62 -0
- package/dist/bridge/pi/events.js +223 -0
- package/dist/bridge/pi/gate.d.ts +42 -0
- package/dist/bridge/pi/gate.js +69 -0
- package/dist/bridge/pi/mcp.d.ts +17 -0
- package/dist/bridge/pi/mcp.js +49 -0
- package/dist/bridge/pi/prompt.d.ts +8 -0
- package/dist/bridge/pi/prompt.js +26 -0
- package/dist/bridge/pi/replay.d.ts +10 -0
- package/dist/bridge/pi/replay.js +87 -0
- package/dist/bridge/pi/server.d.ts +61 -0
- package/dist/bridge/pi/server.js +240 -0
- package/dist/bridge/pi/session.d.ts +112 -0
- package/dist/bridge/pi/session.js +497 -0
- package/dist/bridge/pi/tools.d.ts +36 -0
- package/dist/bridge/pi/tools.js +129 -0
- package/dist/bundle/ama.cjs +2398 -562
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +7 -0
- package/dist/drivers/catalog.js +23 -1
- package/dist/drivers/native/pi-extension.d.ts +39 -0
- package/dist/drivers/native/pi-extension.js +100 -0
- package/dist/drivers/native/pi-rpc-core.d.ts +49 -0
- package/dist/drivers/native/pi-rpc-core.js +108 -0
- package/dist/drivers/native/pi-rpc.d.ts +4 -1
- package/dist/drivers/native/pi-rpc.js +40 -76
- package/dist/i18n/catalog.d.ts +56 -0
- package/dist/i18n/catalog.js +3 -0
- package/dist/i18n/messages/bridge.d.ts +123 -0
- package/dist/i18n/messages/bridge.js +123 -0
- package/dist/i18n/messages/cli-help.js +4 -0
- package/docs/README.md +6 -6
- package/docs/en/README.md +1 -1
- package/docs/en/reference/acp.md +87 -9
- package/docs/guides/agents.md +3 -0
- package/docs/reference/acp.md +87 -9
- package/package.json +1 -1
- package/dist/drivers/native/pi-gate.d.ts +0 -19
- package/dist/drivers/native/pi-gate.js +0 -39
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ama --mode acp --bridge pi` 的 ACP 服务端(#254):把 Pi 的 RPC 会话暴露为 ACP Agent。
|
|
3
|
+
*
|
|
4
|
+
* - `initialize`:`loadSession`、`sessionCapabilities {resume, close}`(不报 `list`:Pi 的 RPC 没有列会话的命令,
|
|
5
|
+
* 桥也不读 Pi 的会话目录)、`mcpCapabilities {http}`、`authMethods: []`(在 Pi 里用 `/login`);
|
|
6
|
+
* - `session/new|load|resume`:用 `--session-id` 起 `pi --mode rpc`,ACP sessionId 就是 Pi 的会话 id;load / resume
|
|
7
|
+
* 的会话在 Pi 里没有消息就当不存在(Pi 会静默新建),答 -32002 并收掉进程;load 回放历史,resume 不回放;
|
|
8
|
+
* - Pi 低于下限答 `pi_outdated`、找不到答 `pi_missing`(`error.data.code`);高于已验证区间或读不出版本照跑,
|
|
9
|
+
* stderr 一行,答复 `_meta["armadra.pi"] = { version, verified: false }`;
|
|
10
|
+
* - 四个权限模式(`modes`,`session/set_mode` 立即生效)由审批闸实现;客户端的 `mcpServers` 写进 `bridge.json`
|
|
11
|
+
* 交给 Pi 内置的 MCP;`session/request_permission` 只发给客户端,桥从不代答。
|
|
12
|
+
*/
|
|
13
|
+
import { randomUUID } from "node:crypto";
|
|
14
|
+
import { isAbsolute } from "node:path";
|
|
15
|
+
import { AMA_VERSION } from "../../version.js";
|
|
16
|
+
import { ACP_METHODS, ACP_PROTOCOL_VERSION, RPC_ERRORS, } from "../../drivers/acp/types.js";
|
|
17
|
+
import { RpcError } from "../../drivers/jsonrpc.js";
|
|
18
|
+
import { PI_CONFIG_ENV, writePiExtension } from "../../drivers/native/pi-extension.js";
|
|
19
|
+
import { ProgramProbe } from "../../drivers/probe.js";
|
|
20
|
+
import { spawnTransport } from "../../drivers/process.js";
|
|
21
|
+
import { msg } from "../../i18n/index.js";
|
|
22
|
+
import { clientCapabilitiesOf } from "../../modes/acp/acp-connection.js";
|
|
23
|
+
import { PI_FLOOR, PI_PACKAGE, PI_VERIFIED, piVersionInfo, } from "./capabilities.js";
|
|
24
|
+
import { piMcpPlan } from "./mcp.js";
|
|
25
|
+
import { PiBridgeSession } from "./session.js";
|
|
26
|
+
export const BRIDGE_AGENT_CAPABILITIES = {
|
|
27
|
+
loadSession: true,
|
|
28
|
+
promptCapabilities: { image: true, audio: false, embeddedContext: true },
|
|
29
|
+
mcpCapabilities: { http: true, sse: false },
|
|
30
|
+
sessionCapabilities: { resume: {}, close: {} },
|
|
31
|
+
};
|
|
32
|
+
function str(params, key) {
|
|
33
|
+
const value = params[key];
|
|
34
|
+
if (typeof value !== "string" || value === "")
|
|
35
|
+
throw new RpcError(RPC_ERRORS.invalidParams, msg().bridge.session.missingParam(key));
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
export class PiBridgeServer {
|
|
39
|
+
options;
|
|
40
|
+
peer;
|
|
41
|
+
pool = new Map();
|
|
42
|
+
launching;
|
|
43
|
+
constructor(options) {
|
|
44
|
+
this.options = options;
|
|
45
|
+
this.peer = options.connection.peer;
|
|
46
|
+
}
|
|
47
|
+
get sessions() {
|
|
48
|
+
return this.pool;
|
|
49
|
+
}
|
|
50
|
+
handleNotification(method, params) {
|
|
51
|
+
if (method === ACP_METHODS.sessionCancel) {
|
|
52
|
+
const id = params?.["sessionId"];
|
|
53
|
+
if (typeof id === "string")
|
|
54
|
+
this.pool.get(id)?.cancel();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async handle(method, params, ctx) {
|
|
58
|
+
switch (method) {
|
|
59
|
+
case ACP_METHODS.initialize:
|
|
60
|
+
return this.initialize(params);
|
|
61
|
+
case ACP_METHODS.sessionNew:
|
|
62
|
+
return this.open("new", params, ctx);
|
|
63
|
+
case ACP_METHODS.sessionLoad:
|
|
64
|
+
return this.open("load", params, ctx);
|
|
65
|
+
case ACP_METHODS.sessionResume:
|
|
66
|
+
return this.open("resume", params, ctx);
|
|
67
|
+
case ACP_METHODS.sessionClose:
|
|
68
|
+
return this.close(params);
|
|
69
|
+
case ACP_METHODS.sessionPrompt:
|
|
70
|
+
return this.prompt(params, ctx);
|
|
71
|
+
case ACP_METHODS.sessionSetMode:
|
|
72
|
+
this.session(params).setMode(str(params, "modeId"));
|
|
73
|
+
return {};
|
|
74
|
+
case ACP_METHODS.sessionSetConfigOption:
|
|
75
|
+
return this.setConfigOption(params);
|
|
76
|
+
default:
|
|
77
|
+
throw new RpcError(RPC_ERRORS.methodNotFound, `method not found: ${method}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
initialize(params) {
|
|
81
|
+
if (typeof params["protocolVersion"] !== "number")
|
|
82
|
+
throw new RpcError(RPC_ERRORS.invalidParams, msg().bridge.session.missingParam("protocolVersion"));
|
|
83
|
+
this.options.connection.markInitialized(clientCapabilitiesOf(params));
|
|
84
|
+
return {
|
|
85
|
+
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
86
|
+
agentCapabilities: BRIDGE_AGENT_CAPABILITIES,
|
|
87
|
+
authMethods: [],
|
|
88
|
+
agentInfo: { name: "ama", title: "ama (Pi bridge)", version: AMA_VERSION },
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
session(params) {
|
|
92
|
+
const id = str(params, "sessionId");
|
|
93
|
+
const session = this.pool.get(id);
|
|
94
|
+
if (session === undefined)
|
|
95
|
+
throw new RpcError(RPC_ERRORS.resourceNotFound, msg().bridge.session.notOpen(id));
|
|
96
|
+
return session;
|
|
97
|
+
}
|
|
98
|
+
/** 找 `pi` 并读版本;整个进程只做一次。 */
|
|
99
|
+
launch() {
|
|
100
|
+
this.launching ??= this.locate();
|
|
101
|
+
return this.launching;
|
|
102
|
+
}
|
|
103
|
+
async locate() {
|
|
104
|
+
const m = msg().bridge.pi;
|
|
105
|
+
const probe = this.options.deps?.probe ?? new ProgramProbe({ env: this.options.env });
|
|
106
|
+
const located = await probe.locate("pi");
|
|
107
|
+
if (located === undefined)
|
|
108
|
+
throw new RpcError(RPC_ERRORS.internalError, m.missing(PI_PACKAGE), {
|
|
109
|
+
code: "pi_missing",
|
|
110
|
+
package: PI_PACKAGE,
|
|
111
|
+
});
|
|
112
|
+
const info = piVersionInfo(located.version);
|
|
113
|
+
if (info.status === "unsupported")
|
|
114
|
+
throw new RpcError(RPC_ERRORS.internalError, m.outdated(located.version, PI_FLOOR, PI_PACKAGE), {
|
|
115
|
+
code: "pi_outdated",
|
|
116
|
+
installed: located.version,
|
|
117
|
+
minimum: PI_FLOOR,
|
|
118
|
+
package: PI_PACKAGE,
|
|
119
|
+
});
|
|
120
|
+
if (info.status === "newer")
|
|
121
|
+
this.options.log(m.unverified(located.version, PI_VERIFIED));
|
|
122
|
+
if (info.status === "unknown")
|
|
123
|
+
this.options.log(m.versionUnknown(PI_VERIFIED));
|
|
124
|
+
return { path: located.path, info };
|
|
125
|
+
}
|
|
126
|
+
async open(kind, params, ctx) {
|
|
127
|
+
const cwd = str(params, "cwd");
|
|
128
|
+
if (!isAbsolute(cwd))
|
|
129
|
+
throw new RpcError(RPC_ERRORS.invalidParams, msg().bridge.session.invalidCwd(cwd));
|
|
130
|
+
const requested = kind === "new" ? randomUUID() : str(params, "sessionId");
|
|
131
|
+
const launch = await this.launch();
|
|
132
|
+
const existing = this.pool.get(requested);
|
|
133
|
+
if (existing !== undefined) {
|
|
134
|
+
if (kind === "load")
|
|
135
|
+
await existing.replay();
|
|
136
|
+
return this.opened(kind, existing, launch);
|
|
137
|
+
}
|
|
138
|
+
const env = { ...this.options.env };
|
|
139
|
+
// 子进程是 pi,不是 ama
|
|
140
|
+
delete env["AMA"];
|
|
141
|
+
delete env["AI_AGENT"];
|
|
142
|
+
// MCP 透传:客户端的 mcpServers 写进 bridge.json,扩展加载时交给 Pi 内置的 MCP(ama 自己不说 MCP)
|
|
143
|
+
const mcp = piMcpPlan(params["mcpServers"]);
|
|
144
|
+
if (mcp.skipped.length > 0)
|
|
145
|
+
this.options.log(msg().bridge.pi.mcpSkipped(mcp.skipped.join(", ")));
|
|
146
|
+
const gate = writePiExtension({ mcpServers: mcp.servers });
|
|
147
|
+
if (gate.configPath !== undefined)
|
|
148
|
+
env[PI_CONFIG_ENV] = gate.configPath;
|
|
149
|
+
const transport = (this.options.deps?.spawn ?? ((spec) => spawnTransport(spec)))({
|
|
150
|
+
program: launch.path,
|
|
151
|
+
args: [
|
|
152
|
+
"--mode",
|
|
153
|
+
"rpc",
|
|
154
|
+
"--session-id",
|
|
155
|
+
requested,
|
|
156
|
+
"-e",
|
|
157
|
+
gate.path,
|
|
158
|
+
...this.options.passthrough,
|
|
159
|
+
],
|
|
160
|
+
cwd,
|
|
161
|
+
env,
|
|
162
|
+
});
|
|
163
|
+
let session;
|
|
164
|
+
session = new PiBridgeSession({
|
|
165
|
+
id: requested,
|
|
166
|
+
cwd,
|
|
167
|
+
transport,
|
|
168
|
+
info: launch.info,
|
|
169
|
+
emit: (update) => void this.peer.notify(ACP_METHODS.sessionUpdate, { sessionId: session.sessionId, update }),
|
|
170
|
+
log: this.options.log,
|
|
171
|
+
mcpServers: mcp.names,
|
|
172
|
+
askPermission: (request, signal) => this.peer.request(ACP_METHODS.requestPermission, request, signal),
|
|
173
|
+
canElicit: () => this.options.connection.clientCapabilities.elicitation !== undefined,
|
|
174
|
+
askElicitation: (request, signal) => this.peer.request(ACP_METHODS.elicitationCreate, request, signal),
|
|
175
|
+
...(this.options.deps !== undefined ? { deps: this.options.deps } : {}),
|
|
176
|
+
dispose: () => gate.dispose(),
|
|
177
|
+
});
|
|
178
|
+
try {
|
|
179
|
+
await session.start(ctx?.signal);
|
|
180
|
+
if (kind !== "new" && session.existingMessages === 0)
|
|
181
|
+
throw new RpcError(RPC_ERRORS.resourceNotFound, msg().bridge.session.notFound(requested));
|
|
182
|
+
this.pool.set(session.sessionId, session);
|
|
183
|
+
if (kind === "load")
|
|
184
|
+
await session.replay();
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
await session.close();
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
return this.opened(kind, session, launch);
|
|
191
|
+
}
|
|
192
|
+
/** new / load / resume 的答复;答复发出后再公布用量。 */
|
|
193
|
+
opened(kind, session, launch) {
|
|
194
|
+
setImmediate(() => void session.reportUsage());
|
|
195
|
+
const configOptions = session.configOptions();
|
|
196
|
+
const capabilities = session.capabilities();
|
|
197
|
+
return {
|
|
198
|
+
...(kind === "new" ? { sessionId: session.sessionId } : {}),
|
|
199
|
+
modes: session.modes(),
|
|
200
|
+
...(configOptions.length > 0 ? { configOptions } : {}),
|
|
201
|
+
_meta: {
|
|
202
|
+
"armadra.pi": {
|
|
203
|
+
...(launch.info.version !== undefined ? { version: launch.info.version } : {}),
|
|
204
|
+
verified: launch.info.status === "verified",
|
|
205
|
+
...(capabilities !== undefined ? { capabilities } : {}),
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
async prompt(params, ctx) {
|
|
211
|
+
const session = this.session(params);
|
|
212
|
+
const onAbort = () => session.cancel();
|
|
213
|
+
ctx?.signal.addEventListener("abort", onAbort, { once: true });
|
|
214
|
+
try {
|
|
215
|
+
return await session.prompt(params["prompt"]);
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
ctx?.signal.removeEventListener("abort", onAbort);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async setConfigOption(params) {
|
|
222
|
+
const session = this.session(params);
|
|
223
|
+
const value = params["value"];
|
|
224
|
+
if (typeof value !== "string")
|
|
225
|
+
throw new RpcError(RPC_ERRORS.invalidParams, msg().bridge.session.missingParam("value"));
|
|
226
|
+
return { configOptions: await session.setConfigOption(str(params, "configId"), value) };
|
|
227
|
+
}
|
|
228
|
+
async close(params) {
|
|
229
|
+
const session = this.session(params);
|
|
230
|
+
this.pool.delete(session.sessionId);
|
|
231
|
+
await session.close();
|
|
232
|
+
return {};
|
|
233
|
+
}
|
|
234
|
+
/** 连接结束:关掉全部会话。 */
|
|
235
|
+
async dispose() {
|
|
236
|
+
const sessions = [...this.pool.values()];
|
|
237
|
+
this.pool.clear();
|
|
238
|
+
await Promise.allSettled(sessions.map((s) => s.close()));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一个 ACP 会话 = 一个 `pi --mode rpc --session-id <id>` 子进程(#254)。
|
|
3
|
+
*
|
|
4
|
+
* - 握手:`get_state`(当前模型、推理强度、消息数)、`get_available_models`、`get_available_thinking_levels`;
|
|
5
|
+
* 没有可用模型 → `pi_no_model`;
|
|
6
|
+
* - 回合:`prompt` → 应答 `disposition`(`handled` 不等回合)→ 事件流 → `agent_settled` 结束;
|
|
7
|
+
* `aborted` 为真或本端已取消 → `cancelled`;assistant 的 `stopReason` 为 `length` → `max_tokens`,`error` → JSON-RPC 错误;
|
|
8
|
+
* 运行中再来的 prompt 答 busy;答复的 `usage` 是本回合累加;
|
|
9
|
+
* - 取消:撤回挂起的审批与征询,发 `abort`,15 秒看门狗(过了关 stdin 再杀进程树);
|
|
10
|
+
* - 用量:开会话、回合结束与换模型之后发 `usage_update`(`get_session_stats` 的上下文占用与窗口、费用)。
|
|
11
|
+
*/
|
|
12
|
+
import { type DriverDeps } from "../../drivers/base.js";
|
|
13
|
+
import { type AcpPromptResult, type AcpElicitationParams, type AcpElicitationResult, type AcpRequestPermissionParams, type AcpRequestPermissionResult, type AcpSessionConfigOption, type AcpSessionModeState, type AcpSessionUpdate } from "../../drivers/acp/types.js";
|
|
14
|
+
import { PiRpcCore } from "../../drivers/native/pi-rpc-core.js";
|
|
15
|
+
import { type AgentTransport } from "../../drivers/process.js";
|
|
16
|
+
import type { PiVersionInfo } from "./capabilities.js";
|
|
17
|
+
import { PiEventMapper } from "./events.js";
|
|
18
|
+
export interface SessionInit {
|
|
19
|
+
id: string;
|
|
20
|
+
cwd: string;
|
|
21
|
+
transport: AgentTransport;
|
|
22
|
+
info: PiVersionInfo;
|
|
23
|
+
/** `session/update`(带本会话 id)。 */
|
|
24
|
+
emit(update: AcpSessionUpdate): void;
|
|
25
|
+
/** stderr 一行诊断。 */
|
|
26
|
+
log(message: string): void;
|
|
27
|
+
/** 客户端给的 MCP 服务器名。 */
|
|
28
|
+
mcpServers: readonly string[];
|
|
29
|
+
deps?: Pick<DriverDeps, "cancelGraceMs" | "setTimer"> & {
|
|
30
|
+
statusWaitMs?: number;
|
|
31
|
+
};
|
|
32
|
+
/** `session/request_permission`:只发给客户端,桥从不代答;`signal` abort 时撤回请求。 */
|
|
33
|
+
askPermission(params: AcpRequestPermissionParams, signal: AbortSignal): Promise<AcpRequestPermissionResult>;
|
|
34
|
+
/** 客户端声明了 `elicitation`(没声明时其它扩展的对话框直接取消)。 */
|
|
35
|
+
canElicit(): boolean;
|
|
36
|
+
/** `elicitation/create`:只发给客户端;`signal` abort 时撤回请求。 */
|
|
37
|
+
askElicitation(params: AcpElicitationParams, signal: AbortSignal): Promise<AcpElicitationResult>;
|
|
38
|
+
/** 关闭后清理(临时目录)。 */
|
|
39
|
+
dispose(): void;
|
|
40
|
+
}
|
|
41
|
+
export declare class PiBridgeSession {
|
|
42
|
+
private readonly init;
|
|
43
|
+
readonly core: PiRpcCore;
|
|
44
|
+
readonly mapper: PiEventMapper;
|
|
45
|
+
private id;
|
|
46
|
+
private configState;
|
|
47
|
+
private messageCount;
|
|
48
|
+
private running;
|
|
49
|
+
private settle;
|
|
50
|
+
private readonly exitWaiters;
|
|
51
|
+
private interrupted;
|
|
52
|
+
private closed;
|
|
53
|
+
private lastUsage;
|
|
54
|
+
private mode;
|
|
55
|
+
/** 挂起的 `session/request_permission`(取消与关闭时撤回)。 */
|
|
56
|
+
private readonly asks;
|
|
57
|
+
/** 桥自己拒绝的调用 → 回给模型的理由(扩展随后用 editor 对话框来取)。 */
|
|
58
|
+
private readonly denials;
|
|
59
|
+
/** 扩展报告的工具名(`setStatus`);没收到为 undefined。 */
|
|
60
|
+
private tools;
|
|
61
|
+
private resolveStatus;
|
|
62
|
+
private readonly statusSeen;
|
|
63
|
+
constructor(init: SessionInit);
|
|
64
|
+
get sessionId(): string;
|
|
65
|
+
get isRunning(): boolean;
|
|
66
|
+
get existingMessages(): number;
|
|
67
|
+
/** 握手:取状态、模型与推理强度;没有可用模型抛 `pi_no_model`。 */
|
|
68
|
+
start(signal?: AbortSignal): Promise<void>;
|
|
69
|
+
private request;
|
|
70
|
+
private refreshLevels;
|
|
71
|
+
configOptions(): AcpSessionConfigOption[];
|
|
72
|
+
/** `session/set_config_option`:返回全部配置项的新状态;换模型之后重取推理强度并发 `config_option_update`。 */
|
|
73
|
+
setConfigOption(id: string, value: string): Promise<AcpSessionConfigOption[]>;
|
|
74
|
+
private change;
|
|
75
|
+
/** 改动之后以 `get_state` 为准(Pi 可能把推理强度夹到模型支持的范围)。 */
|
|
76
|
+
private syncState;
|
|
77
|
+
/** `session/load`:把已有消息回放成更新。 */
|
|
78
|
+
replay(): Promise<void>;
|
|
79
|
+
/** `usage_update`:上下文占用与窗口、累计费用(USD);同值不重发,拿不到不发。 */
|
|
80
|
+
reportUsage(): Promise<void>;
|
|
81
|
+
prompt(blocks: unknown): Promise<AcpPromptResult>;
|
|
82
|
+
private run;
|
|
83
|
+
private complete;
|
|
84
|
+
/** `session/cancel`:撤回挂起的审批、发 `abort`,看门狗兜底。 */
|
|
85
|
+
cancel(): void;
|
|
86
|
+
/** 撤回挂起的审批与征询(客户端收到 `$/cancel_request`);Pi 一侧按拒绝 / 取消应答。 */
|
|
87
|
+
private cancelPending;
|
|
88
|
+
close(): Promise<void>;
|
|
89
|
+
private exitedError;
|
|
90
|
+
private exitPromise;
|
|
91
|
+
private onExit;
|
|
92
|
+
private onRecord;
|
|
93
|
+
/** 当前模式与可选模式(`session/new|load|resume` 的 `modes`)。 */
|
|
94
|
+
modes(): AcpSessionModeState;
|
|
95
|
+
/** `session/set_mode`:立即生效(闸每次调用都问桥)。 */
|
|
96
|
+
setMode(id: string): void;
|
|
97
|
+
/** 扩展报告的能力:Pi 里有没有 `todo` / `subagent` / `questionnaire` 工具;没收到报告为 undefined。 */
|
|
98
|
+
capabilities(): {
|
|
99
|
+
todo: boolean;
|
|
100
|
+
subagent: boolean;
|
|
101
|
+
questionnaire: boolean;
|
|
102
|
+
} | undefined;
|
|
103
|
+
/** 扩展 UI 请求:审批闸与拒绝理由、能力报告;其它对话框本批取消(后续批次接上征询)。 */
|
|
104
|
+
private onUiRequest;
|
|
105
|
+
/** 其它扩展的对话框 → 征询(客户端声明了 `elicitation` 才转,否则取消并在 stderr 说一行)。 */
|
|
106
|
+
private onDialog;
|
|
107
|
+
private onStatus;
|
|
108
|
+
/** 审批闸:按模式放行、拒绝,或把请求交给客户端(人)。返回是否放行。 */
|
|
109
|
+
private onGate;
|
|
110
|
+
/** `session/request_permission`(allow_once / reject_once);客户端取消、出错或会话取消都按拒绝。 */
|
|
111
|
+
private askHuman;
|
|
112
|
+
}
|