@armadra/agent 0.12.0 → 0.14.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/dist/ai/fake/fake-provider.d.ts +6 -0
- package/dist/ai/fake/fake-provider.js +46 -0
- package/dist/ai/fake/fake-script.d.ts +8 -1
- package/dist/ai/fake/fake-script.js +5 -1
- 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 +2426 -559
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +7 -0
- package/dist/codemode/host-side.d.ts +7 -0
- package/dist/codemode/host-side.js +7 -2
- package/dist/drivers/catalog.js +1 -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 +2 -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
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - 回合:`prompt` → 响应 `disposition`(`handled` 时没有运行,直接结束)→ 事件流 → `agent_settled`
|
|
8
8
|
* 结束(`aborted` 为真即中断);运行中追加用 `steer`;中断 `abort`(15 s 看门狗)。
|
|
9
|
-
* - 审批:pi 自己不问人,ama 以 `-e` 加载审批闸({@link
|
|
9
|
+
* - 审批:pi 自己不问人,ama 以 `-e` 加载审批闸({@link PI_EXTENSION_SOURCE}),只读内置工具以外的调用
|
|
10
10
|
* 经 `extension_ui_request{confirm, title: "ama-approval"}` 到这里:plan / allowlist 直接拒绝(并以
|
|
11
11
|
* `--tools` 只开只读工具),auto-edit / auto / full-auto 放行 `edit` / `write`,其余交给人(只交给人,
|
|
12
12
|
* 不代答)。其它扩展的对话框(select / input / editor / 别的 confirm)一律取消并提示。
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
import { randomUUID } from "node:crypto";
|
|
17
17
|
import { resolve as resolvePath } from "node:path";
|
|
18
18
|
import { AmaError } from "../../errors.js";
|
|
19
|
-
import { createLineReader } from "../../modes/rpc/jsonl.js";
|
|
20
19
|
import { armCancelWatchdog, isReadOnlyMode, probeCandidate, spawnOf, } from "../base.js";
|
|
21
20
|
import { stderrHint } from "../process.js";
|
|
22
21
|
import { TurnCollector, oneLine } from "../turn.js";
|
|
23
|
-
import { PI_GATE_TITLE, PI_READ_ONLY_TOOLS,
|
|
22
|
+
import { PI_GATE_TITLE, PI_READ_ONLY_TOOLS, PI_REASON_TITLE, writePiExtension, } from "./pi-extension.js";
|
|
23
|
+
import { PiRpcCore } from "./pi-rpc-core.js";
|
|
24
24
|
import { msg } from "../../i18n/index.js";
|
|
25
25
|
const DIALOG_METHODS = new Set(["select", "confirm", "input", "editor"]);
|
|
26
26
|
/** auto-edit 及更宽的模式下不问人的文件编辑工具。 */
|
|
@@ -52,7 +52,7 @@ export function piToolKind(tool) {
|
|
|
52
52
|
return "other";
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function piToolTitle(tool, input) {
|
|
55
|
+
export function piToolTitle(tool, input) {
|
|
56
56
|
if (typeof input["command"] === "string")
|
|
57
57
|
return `$ ${oneLine(input["command"], 100)}`;
|
|
58
58
|
if (typeof input["path"] === "string")
|
|
@@ -61,7 +61,7 @@ function piToolTitle(tool, input) {
|
|
|
61
61
|
return `${tool} ${oneLine(input["pattern"], 80)}`;
|
|
62
62
|
return tool;
|
|
63
63
|
}
|
|
64
|
-
function textOf(message) {
|
|
64
|
+
export function textOf(message) {
|
|
65
65
|
const content = message["content"];
|
|
66
66
|
if (typeof content === "string")
|
|
67
67
|
return content;
|
|
@@ -87,7 +87,7 @@ export class PiRpcDriver {
|
|
|
87
87
|
async open(options) {
|
|
88
88
|
const probed = await probeCandidate(this.candidate, this.deps);
|
|
89
89
|
const sessionId = options.resume ?? randomUUID();
|
|
90
|
-
const gate =
|
|
90
|
+
const gate = writePiExtension();
|
|
91
91
|
const transport = spawnOf(this.deps)({
|
|
92
92
|
program: probed.path ?? this.candidate.program,
|
|
93
93
|
args: [...this.candidate.args, ...piArgs(options, sessionId, gate.path)],
|
|
@@ -115,8 +115,7 @@ class PiSession {
|
|
|
115
115
|
deps;
|
|
116
116
|
dispose;
|
|
117
117
|
notices = [];
|
|
118
|
-
|
|
119
|
-
pending = new Map();
|
|
118
|
+
core;
|
|
120
119
|
permissions = new Set();
|
|
121
120
|
turn;
|
|
122
121
|
hooks;
|
|
@@ -126,7 +125,6 @@ class PiSession {
|
|
|
126
125
|
lastAssistant;
|
|
127
126
|
interrupted = false;
|
|
128
127
|
closed = false;
|
|
129
|
-
exited = false;
|
|
130
128
|
exitWaiters = new Set();
|
|
131
129
|
constructor(agentId, id, transport, options, deps, dispose) {
|
|
132
130
|
this.agentId = agentId;
|
|
@@ -135,8 +133,15 @@ class PiSession {
|
|
|
135
133
|
this.options = options;
|
|
136
134
|
this.deps = deps;
|
|
137
135
|
this.dispose = dispose;
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
this.core = new PiRpcCore({
|
|
137
|
+
transport,
|
|
138
|
+
onEvent: (record) => this.onRecord(record),
|
|
139
|
+
onUiRequest: (record) => void this.onDialog(record),
|
|
140
|
+
onExit: (error) => this.onExit(error),
|
|
141
|
+
onNonJson: () => this.deps.log?.("debug", msg().drivers.agent.nonJson(this.agentId)),
|
|
142
|
+
exitMessage: (hint) => `${this.agentId} process exited${hint !== "" ? `: ${hint}` : ""}`,
|
|
143
|
+
timeoutMessage: (command) => `${this.agentId} did not answer ${command} in time`,
|
|
144
|
+
});
|
|
140
145
|
}
|
|
141
146
|
get sessionId() {
|
|
142
147
|
return this.id;
|
|
@@ -149,13 +154,13 @@ class PiSession {
|
|
|
149
154
|
signal.addEventListener("abort", () => reject(new Error("aborted")), { once: true });
|
|
150
155
|
});
|
|
151
156
|
void aborted.catch(() => undefined);
|
|
152
|
-
const state = await Promise.race([this.request({ type: "get_state" }), aborted]);
|
|
157
|
+
const state = await Promise.race([this.core.request({ type: "get_state" }), aborted]);
|
|
153
158
|
const data = (state["data"] ?? {});
|
|
154
159
|
if (typeof data["sessionId"] === "string" && data["sessionId"] !== "")
|
|
155
160
|
this.id = data["sessionId"];
|
|
156
161
|
}
|
|
157
162
|
async prompt(content, hooks) {
|
|
158
|
-
if (this.closed || this.exited)
|
|
163
|
+
if (this.closed || this.core.exited)
|
|
159
164
|
throw new AmaError("agent_closed", `${this.agentId} session is closed`);
|
|
160
165
|
if (this.running !== undefined)
|
|
161
166
|
throw new AmaError("busy", `${this.agentId} is already running`);
|
|
@@ -183,7 +188,7 @@ class PiSession {
|
|
|
183
188
|
// 先让出一拍:`this.running` 赋值之后再写命令(同步回显的对端里事件可能立刻到达并触发 cancel)
|
|
184
189
|
await Promise.resolve();
|
|
185
190
|
const settled = new Promise((resolve) => (this.settle = resolve));
|
|
186
|
-
const response = await this.request({ type: "prompt", ...this.message(content) });
|
|
191
|
+
const response = await this.core.request({ type: "prompt", ...this.message(content) });
|
|
187
192
|
if (response["success"] !== true)
|
|
188
193
|
throw new AmaError("agent_failed", `${this.agentId} rejected the prompt: ${oneLine(String(response["error"] ?? "unknown"), 300)}`);
|
|
189
194
|
const disposition = (response["data"] ?? {})["disposition"];
|
|
@@ -194,9 +199,9 @@ class PiSession {
|
|
|
194
199
|
return this.complete(turn, aborted);
|
|
195
200
|
}
|
|
196
201
|
async steer(content) {
|
|
197
|
-
if (this.closed || this.exited)
|
|
202
|
+
if (this.closed || this.core.exited)
|
|
198
203
|
throw new AmaError("agent_closed", `${this.agentId} session is closed`);
|
|
199
|
-
await this.request({ type: "steer", ...this.message(content) });
|
|
204
|
+
await this.core.request({ type: "steer", ...this.message(content) });
|
|
200
205
|
}
|
|
201
206
|
async cancel() {
|
|
202
207
|
const running = this.running;
|
|
@@ -205,7 +210,7 @@ class PiSession {
|
|
|
205
210
|
this.interrupted = true;
|
|
206
211
|
for (const c of this.permissions)
|
|
207
212
|
c.abort();
|
|
208
|
-
void this.request({ type: "abort" }).catch(() => undefined);
|
|
213
|
+
void this.core.request({ type: "abort" }).catch(() => undefined);
|
|
209
214
|
armCancelWatchdog(this.transport, running.catch(() => undefined), this.deps);
|
|
210
215
|
}
|
|
211
216
|
async close() {
|
|
@@ -216,7 +221,7 @@ class PiSession {
|
|
|
216
221
|
c.abort();
|
|
217
222
|
if (this.running !== undefined) {
|
|
218
223
|
this.interrupted = true;
|
|
219
|
-
this.write({ type: "abort" });
|
|
224
|
+
this.core.write({ type: "abort" });
|
|
220
225
|
}
|
|
221
226
|
try {
|
|
222
227
|
await this.transport.terminate();
|
|
@@ -261,11 +266,11 @@ class PiSession {
|
|
|
261
266
|
}
|
|
262
267
|
/** `get_session_stats.contextUsage` → 上下文占用与窗口(拿不到就算了)。 */
|
|
263
268
|
async reportContext(turn) {
|
|
264
|
-
if (this.exited)
|
|
269
|
+
if (this.core.exited)
|
|
265
270
|
return;
|
|
266
271
|
try {
|
|
267
272
|
const stats = await Promise.race([
|
|
268
|
-
this.request({ type: "get_session_stats" }),
|
|
273
|
+
this.core.request({ type: "get_session_stats" }),
|
|
269
274
|
new Promise((resolve) => setTimeout(() => resolve({}), 5_000).unref()),
|
|
270
275
|
]);
|
|
271
276
|
const usage = ((stats["data"] ?? {})["contextUsage"] ?? {});
|
|
@@ -284,70 +289,24 @@ class PiSession {
|
|
|
284
289
|
}
|
|
285
290
|
exitPromise() {
|
|
286
291
|
return new Promise((_, reject) => {
|
|
287
|
-
if (this.exited)
|
|
288
|
-
reject(this.exitError());
|
|
292
|
+
if (this.core.exited)
|
|
293
|
+
reject(this.core.exitError());
|
|
289
294
|
else
|
|
290
295
|
this.exitWaiters.add(reject);
|
|
291
296
|
});
|
|
292
297
|
}
|
|
293
|
-
|
|
294
|
-
const hint = stderrHint(this.transport);
|
|
295
|
-
return new AmaError("agent_exited", `${this.agentId} process exited${hint !== "" ? `: ${hint}` : ""}`);
|
|
296
|
-
}
|
|
297
|
-
request(command) {
|
|
298
|
-
if (this.exited)
|
|
299
|
-
return Promise.reject(this.exitError());
|
|
300
|
-
const id = `ama-${this.nextId++}`;
|
|
301
|
-
return new Promise((resolve, reject) => {
|
|
302
|
-
this.pending.set(id, { resolve, reject });
|
|
303
|
-
this.write({ id, ...command });
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
write(record) {
|
|
307
|
-
if (this.exited)
|
|
308
|
-
return;
|
|
309
|
-
this.transport.stdin.write(`${JSON.stringify(record)}\n`);
|
|
310
|
-
}
|
|
311
|
-
onExit() {
|
|
312
|
-
this.exited = true;
|
|
313
|
-
const error = this.exitError();
|
|
314
|
-
for (const p of this.pending.values())
|
|
315
|
-
p.reject(error);
|
|
316
|
-
this.pending.clear();
|
|
298
|
+
onExit(error) {
|
|
317
299
|
for (const reject of this.exitWaiters)
|
|
318
300
|
reject(error);
|
|
319
301
|
this.exitWaiters.clear();
|
|
320
302
|
for (const c of this.permissions)
|
|
321
303
|
c.abort();
|
|
322
304
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
catch {
|
|
329
|
-
this.deps.log?.("debug", msg().drivers.agent.nonJson(this.agentId));
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
switch (record["type"]) {
|
|
333
|
-
case "response": {
|
|
334
|
-
const id = record["id"];
|
|
335
|
-
const pending = typeof id === "string" ? this.pending.get(id) : undefined;
|
|
336
|
-
if (pending === undefined || typeof id !== "string")
|
|
337
|
-
return;
|
|
338
|
-
this.pending.delete(id);
|
|
339
|
-
pending.resolve(record);
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
case "agent_settled":
|
|
343
|
-
this.settle?.(record["aborted"] === true);
|
|
344
|
-
return;
|
|
345
|
-
case "extension_ui_request":
|
|
346
|
-
void this.onDialog(record);
|
|
347
|
-
return;
|
|
348
|
-
default:
|
|
349
|
-
this.onEvent(record);
|
|
350
|
-
}
|
|
305
|
+
onRecord(record) {
|
|
306
|
+
if (record["type"] === "agent_settled")
|
|
307
|
+
this.settle?.(record["aborted"] === true);
|
|
308
|
+
else
|
|
309
|
+
this.onEvent(record);
|
|
351
310
|
}
|
|
352
311
|
onEvent(record) {
|
|
353
312
|
const turn = this.turn;
|
|
@@ -427,17 +386,22 @@ class PiSession {
|
|
|
427
386
|
});
|
|
428
387
|
return;
|
|
429
388
|
}
|
|
389
|
+
// 审批闸被拒绝后向 ama 取理由的 editor:驱动没有自定义理由,静默取消(扩展用默认句)
|
|
390
|
+
if (method === "editor" && record["title"] === PI_REASON_TITLE) {
|
|
391
|
+
this.core.write({ type: "extension_ui_response", id, cancelled: true });
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
430
394
|
if (method !== "confirm" || record["title"] !== PI_GATE_TITLE) {
|
|
431
395
|
this.turn?.push({
|
|
432
396
|
type: "notice",
|
|
433
397
|
level: "warn",
|
|
434
398
|
text: msg().drivers.agent.extensionDialog(this.agentId, oneLine(String(record["title"] ?? method), 80)),
|
|
435
399
|
});
|
|
436
|
-
this.write({ type: "extension_ui_response", id, cancelled: true });
|
|
400
|
+
this.core.write({ type: "extension_ui_response", id, cancelled: true });
|
|
437
401
|
return;
|
|
438
402
|
}
|
|
439
403
|
const confirmed = await this.decide(record);
|
|
440
|
-
this.write({ type: "extension_ui_response", id, confirmed });
|
|
404
|
+
this.core.write({ type: "extension_ui_response", id, confirmed });
|
|
441
405
|
}
|
|
442
406
|
async decide(record) {
|
|
443
407
|
let call;
|
package/dist/i18n/catalog.d.ts
CHANGED
|
@@ -2374,6 +2374,62 @@ declare const en: {
|
|
|
2374
2374
|
authTerminal: (name: string, command: string) => string;
|
|
2375
2375
|
};
|
|
2376
2376
|
};
|
|
2377
|
+
bridge: {
|
|
2378
|
+
args: {
|
|
2379
|
+
unknownOption: (option: string) => string;
|
|
2380
|
+
needsValue: (option: string) => string;
|
|
2381
|
+
unsupportedBridge: (value: string) => string;
|
|
2382
|
+
needsAcpMode: string;
|
|
2383
|
+
ownedFlag: (flag: string) => string;
|
|
2384
|
+
};
|
|
2385
|
+
pi: {
|
|
2386
|
+
missing: (pkg: string) => string;
|
|
2387
|
+
outdated: (installed: string, minimum: string, pkg: string) => string;
|
|
2388
|
+
unverified: (version: string, range: string) => string;
|
|
2389
|
+
versionUnknown: (range: string) => string;
|
|
2390
|
+
noModel: string;
|
|
2391
|
+
startFailed: (error: string) => string;
|
|
2392
|
+
exited: (hint: string) => string;
|
|
2393
|
+
promptRejected: (error: string) => string;
|
|
2394
|
+
turnFailed: (error: string) => string;
|
|
2395
|
+
commandTimedOut: (command: string) => string;
|
|
2396
|
+
cancelGraceExpired: string;
|
|
2397
|
+
dialogUnsupported: (title: string) => string;
|
|
2398
|
+
mcpFailed: (error: string) => string;
|
|
2399
|
+
mcpSkipped: (names: string) => string;
|
|
2400
|
+
};
|
|
2401
|
+
modes: {
|
|
2402
|
+
default: string;
|
|
2403
|
+
"auto-edit": string;
|
|
2404
|
+
plan: string;
|
|
2405
|
+
"full-auto": string;
|
|
2406
|
+
};
|
|
2407
|
+
session: {
|
|
2408
|
+
notFound: (id: string) => string;
|
|
2409
|
+
notOpen: (id: string) => string;
|
|
2410
|
+
busy: string;
|
|
2411
|
+
unknownMode: (mode: string) => string;
|
|
2412
|
+
invalidCwd: (cwd: string) => string;
|
|
2413
|
+
missingParam: (key: string) => string;
|
|
2414
|
+
promptNotArray: string;
|
|
2415
|
+
};
|
|
2416
|
+
config: {
|
|
2417
|
+
model: string;
|
|
2418
|
+
thoughtLevel: string;
|
|
2419
|
+
unknownOption: (id: string) => string;
|
|
2420
|
+
invalidValue: (id: string, value: string) => string;
|
|
2421
|
+
setFailed: (id: string, error: string) => string;
|
|
2422
|
+
levels: {
|
|
2423
|
+
off: string;
|
|
2424
|
+
minimal: string;
|
|
2425
|
+
low: string;
|
|
2426
|
+
medium: string;
|
|
2427
|
+
high: string;
|
|
2428
|
+
xhigh: string;
|
|
2429
|
+
max: string;
|
|
2430
|
+
};
|
|
2431
|
+
};
|
|
2432
|
+
};
|
|
2377
2433
|
};
|
|
2378
2434
|
/** 运行期取用的目录形状:en 的形状、叶子放宽为 string / 同签名函数。 */
|
|
2379
2435
|
export type Catalog = Messages<typeof en>;
|
package/dist/i18n/catalog.js
CHANGED
|
@@ -26,6 +26,7 @@ import * as memory from "./messages/memory.js";
|
|
|
26
26
|
import * as auth from "./messages/auth.js";
|
|
27
27
|
import * as settings from "./messages/settings.js";
|
|
28
28
|
import * as acp from "./messages/acp.js";
|
|
29
|
+
import * as bridge from "./messages/bridge.js";
|
|
29
30
|
const en = {
|
|
30
31
|
cli: cli.en,
|
|
31
32
|
subcommands: subcommands.en,
|
|
@@ -47,6 +48,7 @@ const en = {
|
|
|
47
48
|
auth: auth.en,
|
|
48
49
|
settings: settings.en,
|
|
49
50
|
acp: acp.en,
|
|
51
|
+
bridge: bridge.en,
|
|
50
52
|
};
|
|
51
53
|
const zh = {
|
|
52
54
|
cli: cli.zh,
|
|
@@ -69,6 +71,7 @@ const zh = {
|
|
|
69
71
|
auth: auth.zh,
|
|
70
72
|
settings: settings.zh,
|
|
71
73
|
acp: acp.zh,
|
|
74
|
+
bridge: bridge.zh,
|
|
72
75
|
};
|
|
73
76
|
export const CATALOGS = { en, zh };
|
|
74
77
|
/** 领域名(一级命名空间)。 */
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 消息目录:bridge(`ama --mode acp --bridge pi`,键名规范见 docs/guides/i18n.md)。[#254]
|
|
3
|
+
*
|
|
4
|
+
* en 是形状源;zh 用 `satisfies Messages<typeof en>`。桥只翻译给人看的文案(ACP 错误信息、stderr 诊断、
|
|
5
|
+
* 配置项名称);`_meta`、id、value 等机器字段与发给 Pi 的一切固定英文,不走这里。
|
|
6
|
+
*/
|
|
7
|
+
export declare const en: {
|
|
8
|
+
/** 命令行用法错误。 */
|
|
9
|
+
args: {
|
|
10
|
+
unknownOption: (option: string) => string;
|
|
11
|
+
needsValue: (option: string) => string;
|
|
12
|
+
unsupportedBridge: (value: string) => string;
|
|
13
|
+
needsAcpMode: string;
|
|
14
|
+
ownedFlag: (flag: string) => string;
|
|
15
|
+
};
|
|
16
|
+
/** Pi 的探测与版本。 */
|
|
17
|
+
pi: {
|
|
18
|
+
missing: (pkg: string) => string;
|
|
19
|
+
outdated: (installed: string, minimum: string, pkg: string) => string;
|
|
20
|
+
unverified: (version: string, range: string) => string;
|
|
21
|
+
versionUnknown: (range: string) => string;
|
|
22
|
+
noModel: string;
|
|
23
|
+
startFailed: (error: string) => string;
|
|
24
|
+
exited: (hint: string) => string;
|
|
25
|
+
promptRejected: (error: string) => string;
|
|
26
|
+
turnFailed: (error: string) => string;
|
|
27
|
+
commandTimedOut: (command: string) => string;
|
|
28
|
+
cancelGraceExpired: string;
|
|
29
|
+
dialogUnsupported: (title: string) => string;
|
|
30
|
+
mcpFailed: (error: string) => string;
|
|
31
|
+
mcpSkipped: (names: string) => string;
|
|
32
|
+
};
|
|
33
|
+
/** 权限模式的一行说明(名称沿用 ama 的显示名)。 */
|
|
34
|
+
modes: {
|
|
35
|
+
default: string;
|
|
36
|
+
"auto-edit": string;
|
|
37
|
+
plan: string;
|
|
38
|
+
"full-auto": string;
|
|
39
|
+
};
|
|
40
|
+
/** ACP 会话。 */
|
|
41
|
+
session: {
|
|
42
|
+
notFound: (id: string) => string;
|
|
43
|
+
notOpen: (id: string) => string;
|
|
44
|
+
busy: string;
|
|
45
|
+
unknownMode: (mode: string) => string;
|
|
46
|
+
invalidCwd: (cwd: string) => string;
|
|
47
|
+
missingParam: (key: string) => string;
|
|
48
|
+
promptNotArray: string;
|
|
49
|
+
};
|
|
50
|
+
/** 配置项(给人看的名称)。 */
|
|
51
|
+
config: {
|
|
52
|
+
model: string;
|
|
53
|
+
thoughtLevel: string;
|
|
54
|
+
unknownOption: (id: string) => string;
|
|
55
|
+
invalidValue: (id: string, value: string) => string;
|
|
56
|
+
setFailed: (id: string, error: string) => string;
|
|
57
|
+
levels: {
|
|
58
|
+
off: string;
|
|
59
|
+
minimal: string;
|
|
60
|
+
low: string;
|
|
61
|
+
medium: string;
|
|
62
|
+
high: string;
|
|
63
|
+
xhigh: string;
|
|
64
|
+
max: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export declare const zh: {
|
|
69
|
+
args: {
|
|
70
|
+
unknownOption: (option: string) => string;
|
|
71
|
+
needsValue: (option: string) => string;
|
|
72
|
+
unsupportedBridge: (value: string) => string;
|
|
73
|
+
needsAcpMode: string;
|
|
74
|
+
ownedFlag: (flag: string) => string;
|
|
75
|
+
};
|
|
76
|
+
pi: {
|
|
77
|
+
missing: (pkg: string) => string;
|
|
78
|
+
outdated: (installed: string, minimum: string, pkg: string) => string;
|
|
79
|
+
unverified: (version: string, range: string) => string;
|
|
80
|
+
versionUnknown: (range: string) => string;
|
|
81
|
+
noModel: string;
|
|
82
|
+
startFailed: (error: string) => string;
|
|
83
|
+
exited: (hint: string) => string;
|
|
84
|
+
promptRejected: (error: string) => string;
|
|
85
|
+
turnFailed: (error: string) => string;
|
|
86
|
+
commandTimedOut: (command: string) => string;
|
|
87
|
+
cancelGraceExpired: string;
|
|
88
|
+
dialogUnsupported: (title: string) => string;
|
|
89
|
+
mcpFailed: (error: string) => string;
|
|
90
|
+
mcpSkipped: (names: string) => string;
|
|
91
|
+
};
|
|
92
|
+
modes: {
|
|
93
|
+
default: string;
|
|
94
|
+
"auto-edit": string;
|
|
95
|
+
plan: string;
|
|
96
|
+
"full-auto": string;
|
|
97
|
+
};
|
|
98
|
+
session: {
|
|
99
|
+
notFound: (id: string) => string;
|
|
100
|
+
notOpen: (id: string) => string;
|
|
101
|
+
busy: string;
|
|
102
|
+
unknownMode: (mode: string) => string;
|
|
103
|
+
invalidCwd: (cwd: string) => string;
|
|
104
|
+
missingParam: (key: string) => string;
|
|
105
|
+
promptNotArray: string;
|
|
106
|
+
};
|
|
107
|
+
config: {
|
|
108
|
+
model: string;
|
|
109
|
+
thoughtLevel: string;
|
|
110
|
+
unknownOption: (id: string) => string;
|
|
111
|
+
invalidValue: (id: string, value: string) => string;
|
|
112
|
+
setFailed: (id: string, error: string) => string;
|
|
113
|
+
levels: {
|
|
114
|
+
off: string;
|
|
115
|
+
minimal: string;
|
|
116
|
+
low: string;
|
|
117
|
+
medium: string;
|
|
118
|
+
high: string;
|
|
119
|
+
xhigh: string;
|
|
120
|
+
max: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 消息目录:bridge(`ama --mode acp --bridge pi`,键名规范见 docs/guides/i18n.md)。[#254]
|
|
3
|
+
*
|
|
4
|
+
* en 是形状源;zh 用 `satisfies Messages<typeof en>`。桥只翻译给人看的文案(ACP 错误信息、stderr 诊断、
|
|
5
|
+
* 配置项名称);`_meta`、id、value 等机器字段与发给 Pi 的一切固定英文,不走这里。
|
|
6
|
+
*/
|
|
7
|
+
export const en = {
|
|
8
|
+
/** 命令行用法错误。 */
|
|
9
|
+
args: {
|
|
10
|
+
unknownOption: (option) => `--bridge pi: unknown option ${option}`,
|
|
11
|
+
needsValue: (option) => `${option} needs a value`,
|
|
12
|
+
unsupportedBridge: (value) => `--bridge only supports pi (got ${value})`,
|
|
13
|
+
needsAcpMode: "--bridge pi requires --mode acp",
|
|
14
|
+
ownedFlag: (flag) => `${flag} is managed by the bridge and cannot be passed through to pi after --`,
|
|
15
|
+
},
|
|
16
|
+
/** Pi 的探测与版本。 */
|
|
17
|
+
pi: {
|
|
18
|
+
missing: (pkg) => `pi is not installed or not on PATH; install it with: npm i -g ${pkg}`,
|
|
19
|
+
outdated: (installed, minimum, pkg) => `pi ${installed} is older than the minimum ${minimum}; update it with: npm i -g ${pkg}`,
|
|
20
|
+
unverified: (version, range) => `pi ${version} is outside the verified range ${range}; running with the newest known capabilities`,
|
|
21
|
+
versionUnknown: (range) => `could not read the pi version (verified range ${range}); running with the newest known capabilities`,
|
|
22
|
+
noModel: "pi has no usable model; sign in with /login in pi (or configure a model), then try again",
|
|
23
|
+
startFailed: (error) => `pi failed to start (${error})`,
|
|
24
|
+
exited: (hint) => `pi exited${hint === "" ? "" : `: ${hint}`}`,
|
|
25
|
+
promptRejected: (error) => `pi rejected the prompt: ${error}`,
|
|
26
|
+
turnFailed: (error) => `pi turn failed: ${error}`,
|
|
27
|
+
commandTimedOut: (command) => `pi did not answer ${command} in time`,
|
|
28
|
+
cancelGraceExpired: "pi did not stop within the grace period after cancel; closing the process",
|
|
29
|
+
dialogUnsupported: (title) => `an extension in pi asked for input (${title}), but the client does not support elicitation; cancelled`,
|
|
30
|
+
mcpFailed: (error) => `could not hand an MCP server to pi: ${error}`,
|
|
31
|
+
mcpSkipped: (names) => `ignoring MCP servers the bridge cannot pass to pi (only stdio and http are supported): ${names}`,
|
|
32
|
+
},
|
|
33
|
+
/** 权限模式的一行说明(名称沿用 ama 的显示名)。 */
|
|
34
|
+
modes: {
|
|
35
|
+
default: "Ask before writing files or running commands",
|
|
36
|
+
"auto-edit": "Accept file edits automatically; still ask before commands",
|
|
37
|
+
plan: "Read-only: pi may read and search but changes nothing",
|
|
38
|
+
"full-auto": "Allow everything (dangerous commands still ask)",
|
|
39
|
+
},
|
|
40
|
+
/** ACP 会话。 */
|
|
41
|
+
session: {
|
|
42
|
+
notFound: (id) => `session ${id} not found in pi`,
|
|
43
|
+
notOpen: (id) => `session ${id} is not open in this connection; send session/load or session/resume first`,
|
|
44
|
+
busy: "a prompt is already running in this session",
|
|
45
|
+
unknownMode: (mode) => `unknown mode: ${mode}`,
|
|
46
|
+
invalidCwd: (cwd) => `cwd must be an absolute path (got ${cwd})`,
|
|
47
|
+
missingParam: (key) => `missing ${key}`,
|
|
48
|
+
promptNotArray: "prompt must be an array of content blocks",
|
|
49
|
+
},
|
|
50
|
+
/** 配置项(给人看的名称)。 */
|
|
51
|
+
config: {
|
|
52
|
+
model: "Model",
|
|
53
|
+
thoughtLevel: "Thinking level",
|
|
54
|
+
unknownOption: (id) => `unknown config option: ${id}`,
|
|
55
|
+
invalidValue: (id, value) => `invalid value for config option ${id}: ${value}`,
|
|
56
|
+
setFailed: (id, error) => `pi could not change ${id}: ${error}`,
|
|
57
|
+
levels: {
|
|
58
|
+
off: "Off",
|
|
59
|
+
minimal: "Minimal",
|
|
60
|
+
low: "Low",
|
|
61
|
+
medium: "Medium",
|
|
62
|
+
high: "High",
|
|
63
|
+
xhigh: "Extra high",
|
|
64
|
+
max: "Max",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
export const zh = {
|
|
69
|
+
args: {
|
|
70
|
+
unknownOption: (option) => `--bridge pi:未知选项 ${option}`,
|
|
71
|
+
needsValue: (option) => `${option} 需要一个值`,
|
|
72
|
+
unsupportedBridge: (value) => `--bridge 只支持 pi(收到 ${value})`,
|
|
73
|
+
needsAcpMode: "--bridge pi 需要配合 --mode acp",
|
|
74
|
+
ownedFlag: (flag) => `${flag} 由桥自己管理,不能经 -- 之后透传给 pi`,
|
|
75
|
+
},
|
|
76
|
+
pi: {
|
|
77
|
+
missing: (pkg) => `没有找到 pi(未安装或不在 PATH 里);用 npm i -g ${pkg} 安装`,
|
|
78
|
+
outdated: (installed, minimum, pkg) => `pi ${installed} 低于最低版本 ${minimum};用 npm i -g ${pkg} 更新`,
|
|
79
|
+
unverified: (version, range) => `pi ${version} 超出已验证区间 ${range};按已知的最新能力运行`,
|
|
80
|
+
versionUnknown: (range) => `读不出 pi 的版本(已验证区间 ${range});按已知的最新能力运行`,
|
|
81
|
+
noModel: "pi 没有可用模型;请在 pi 里用 /login 登录(或配置模型)后再试",
|
|
82
|
+
startFailed: (error) => `pi 启动失败(${error})`,
|
|
83
|
+
exited: (hint) => `pi 已退出${hint === "" ? "" : `:${hint}`}`,
|
|
84
|
+
promptRejected: (error) => `pi 拒绝了这条提示:${error}`,
|
|
85
|
+
turnFailed: (error) => `pi 这一轮出错:${error}`,
|
|
86
|
+
commandTimedOut: (command) => `pi 没有及时回应 ${command}`,
|
|
87
|
+
cancelGraceExpired: "取消后 pi 没有在宽限期内停下;关闭进程",
|
|
88
|
+
dialogUnsupported: (title) => `pi 里的扩展要求输入(${title}),但客户端不支持征询;已取消`,
|
|
89
|
+
mcpFailed: (error) => `无法把 MCP 服务器交给 pi:${error}`,
|
|
90
|
+
mcpSkipped: (names) => `忽略桥无法交给 pi 的 MCP 服务器(只支持 stdio 与 http):${names}`,
|
|
91
|
+
},
|
|
92
|
+
modes: {
|
|
93
|
+
default: "写文件、执行命令前询问",
|
|
94
|
+
"auto-edit": "自动接受文件编辑,执行命令仍询问",
|
|
95
|
+
plan: "只读:pi 可以读和搜索,但不改任何东西",
|
|
96
|
+
"full-auto": "全部放行(危险命令仍询问)",
|
|
97
|
+
},
|
|
98
|
+
session: {
|
|
99
|
+
notFound: (id) => `pi 里没有会话 ${id}`,
|
|
100
|
+
notOpen: (id) => `会话 ${id} 没有在本连接中打开;先发 session/load 或 session/resume`,
|
|
101
|
+
busy: "这个会话里已有提示在运行",
|
|
102
|
+
unknownMode: (mode) => `未知模式:${mode}`,
|
|
103
|
+
invalidCwd: (cwd) => `cwd 必须是绝对路径(收到 ${cwd})`,
|
|
104
|
+
missingParam: (key) => `缺少 ${key}`,
|
|
105
|
+
promptNotArray: "prompt 应为内容块数组",
|
|
106
|
+
},
|
|
107
|
+
config: {
|
|
108
|
+
model: "模型",
|
|
109
|
+
thoughtLevel: "思考级别",
|
|
110
|
+
unknownOption: (id) => `未知配置项:${id}`,
|
|
111
|
+
invalidValue: (id, value) => `配置项 ${id} 的值无效:${value}`,
|
|
112
|
+
setFailed: (id, error) => `pi 无法修改 ${id}:${error}`,
|
|
113
|
+
levels: {
|
|
114
|
+
off: "关",
|
|
115
|
+
minimal: "最低",
|
|
116
|
+
low: "低",
|
|
117
|
+
medium: "中",
|
|
118
|
+
high: "高",
|
|
119
|
+
xhigh: "超高",
|
|
120
|
+
max: "最大",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
@@ -25,6 +25,8 @@ Modes
|
|
|
25
25
|
≤ 5 MB each); in the interactive UI write @image-path or paste an image path
|
|
26
26
|
--mode rpc stdio JSONL protocol (for embedding)
|
|
27
27
|
--mode acp ACP server (driven by Zed / JetBrains / Armadra)
|
|
28
|
+
--mode acp --bridge pi [-- <pi args>]
|
|
29
|
+
ACP server for an installed Pi (no ama key or model needed)
|
|
28
30
|
--max-cost <USD> Dollar limit for one run (estimated from catalog prices); stops the run,
|
|
29
31
|
-p exits with 8
|
|
30
32
|
--tui-mode <mode> Display mode; only regular (main screen) for now
|
|
@@ -149,6 +151,8 @@ export const zh = {
|
|
|
149
151
|
交互界面里写 @图片路径 或粘贴图片路径
|
|
150
152
|
--mode rpc stdio JSONL 协议(供嵌入)
|
|
151
153
|
--mode acp ACP 服务端(供 Zed / JetBrains / Armadra 驱动)
|
|
154
|
+
--mode acp --bridge pi [-- <pi 参数>]
|
|
155
|
+
把本机的 Pi 暴露为 ACP 服务端(不需要 ama 的 key 与模型)
|
|
152
156
|
--max-cost <USD> 一次运行的美元上限(按目录价估算);到限结束运行,-p 退出码 8
|
|
153
157
|
--tui-mode <模式> 显示模式,第一期只有 regular(主屏)
|
|
154
158
|
--quiet-startup <档> 启动画面:normal | header | silent
|
package/docs/README.md
CHANGED
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
|
|
35
35
|
## reference/ 协议与格式
|
|
36
36
|
|
|
37
|
-
| 文档 | 内容
|
|
38
|
-
| ------------------------------------------- |
|
|
39
|
-
| [RPC 协议](reference/rpc.md) | `ama --mode rpc` 的 stdio JSONL 命令、响应与事件
|
|
40
|
-
| [ACP](reference/acp.md) | `ama --mode acp`
|
|
41
|
-
| [宿主适配器 API](reference/host-api.md) | `@armadra/agent/host`:注册工具、审批、注入消息、状态
|
|
42
|
-
| [会话文件格式](reference/session-format.md) | JSONL 条目树、头、条目类型与版本
|
|
37
|
+
| 文档 | 内容 |
|
|
38
|
+
| ------------------------------------------- | ---------------------------------------------------------------------- |
|
|
39
|
+
| [RPC 协议](reference/rpc.md) | `ama --mode rpc` 的 stdio JSONL 命令、响应与事件 |
|
|
40
|
+
| [ACP](reference/acp.md) | `ama --mode acp` 服务端、Pi 的 ACP 桥、登录方法、偏差,以及 ACP 客户端 |
|
|
41
|
+
| [宿主适配器 API](reference/host-api.md) | `@armadra/agent/host`:注册工具、审批、注入消息、状态 |
|
|
42
|
+
| [会话文件格式](reference/session-format.md) | JSONL 条目树、头、条目类型与版本 |
|
|
43
43
|
|
|
44
44
|
## design/ 目标设计
|
|
45
45
|
|
package/docs/en/README.md
CHANGED
|
@@ -24,7 +24,7 @@ When a translation and the Chinese version differ, the Chinese version is author
|
|
|
24
24
|
| [Permissions](guides/permissions.md) | The six modes, decision order, auto's three tiers |
|
|
25
25
|
| [Sessions](guides/sessions.md) | Stats, search, `--from`, export, traces, checkpoints |
|
|
26
26
|
| [RPC protocol](reference/rpc.md) | `ama --mode rpc`: stdio JSONL commands, responses and events |
|
|
27
|
-
| [ACP](reference/acp.md) | `ama --mode acp`, sign-in methods, deviations, the ACP client
|
|
27
|
+
| [ACP](reference/acp.md) | `ama --mode acp`, the Pi ACP bridge, sign-in methods, deviations, the ACP client |
|
|
28
28
|
| [Host adapter API](reference/host-api.md) | `@armadra/agent/host`: tools, approvals, injected messages, status |
|
|
29
29
|
|
|
30
30
|
## Chinese only
|