@chances-ai/cli 6.0.1 → 7.0.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/dist/boot/dispose.d.ts +13 -0
- package/dist/boot/dispose.d.ts.map +1 -0
- package/dist/boot/dispose.js +74 -0
- package/dist/boot/dispose.js.map +1 -0
- package/dist/commands/acp.d.ts +3 -0
- package/dist/commands/acp.d.ts.map +1 -0
- package/dist/commands/acp.js +39 -0
- package/dist/commands/acp.js.map +1 -0
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +7 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/rpc.d.ts +12 -0
- package/dist/commands/rpc.d.ts.map +1 -0
- package/dist/commands/rpc.js +67 -0
- package/dist/commands/rpc.js.map +1 -0
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +14 -66
- package/dist/entrypoints/cli.js.map +1 -1
- package/package.json +18 -17
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AppContext } from "./load-runtime.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tear down everything the runtime context owns, in the order that matters
|
|
4
|
+
* (5.1): background tasks → PTY sessions → MCP → plugins → OTel. Each disposer
|
|
5
|
+
* is best-effort — a failure is logged and never masks the others or the
|
|
6
|
+
* command's own outcome. Idempotent: a second call is a no-op.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from `main()` so the single dispose sequence has one owner; the
|
|
9
|
+
* RPC/ACP transports invoke it from inside their shutdown (before flush/close)
|
|
10
|
+
* and `main()`'s finally then finds it already done.
|
|
11
|
+
*/
|
|
12
|
+
export declare function disposeRuntime(ctx: AppContext): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=dispose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispose.d.ts","sourceRoot":"","sources":["../../src/boot/dispose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AASpD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDnE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Contexts already torn down — makes `disposeRuntime` idempotent so it can be
|
|
2
|
+
* called BOTH by an RPC/ACP host's `EngineHost.dispose` (so teardown frames
|
|
3
|
+
* reach the client before the transport flushes/closes — 5.2 Round-2 S1) AND
|
|
4
|
+
* by `main()`'s `finally` (the canonical owner for every other command),
|
|
5
|
+
* without double-disposing. */
|
|
6
|
+
const disposed = new WeakSet();
|
|
7
|
+
/**
|
|
8
|
+
* Tear down everything the runtime context owns, in the order that matters
|
|
9
|
+
* (5.1): background tasks → PTY sessions → MCP → plugins → OTel. Each disposer
|
|
10
|
+
* is best-effort — a failure is logged and never masks the others or the
|
|
11
|
+
* command's own outcome. Idempotent: a second call is a no-op.
|
|
12
|
+
*
|
|
13
|
+
* Extracted from `main()` so the single dispose sequence has one owner; the
|
|
14
|
+
* RPC/ACP transports invoke it from inside their shutdown (before flush/close)
|
|
15
|
+
* and `main()`'s finally then finds it already done.
|
|
16
|
+
*/
|
|
17
|
+
export async function disposeRuntime(ctx) {
|
|
18
|
+
if (disposed.has(ctx))
|
|
19
|
+
return;
|
|
20
|
+
disposed.add(ctx);
|
|
21
|
+
// Background tasks dispose FIRST so any in-flight child engine stops driving
|
|
22
|
+
// the bus and gate before MCP servers (which may serve the child's tools)
|
|
23
|
+
// tear down.
|
|
24
|
+
if (ctx.backgroundTasks) {
|
|
25
|
+
try {
|
|
26
|
+
await ctx.backgroundTasks.dispose();
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
ctx.logger.warn(`background tasks dispose failed: ${e.message}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// (5.1) PTY sessions AFTER background tasks (the subagent drain already
|
|
33
|
+
// SIGTERM-grace-killed child-owned ones; this catches the parent's
|
|
34
|
+
// survivors) and BEFORE MCP. 2 s deadline; survivors are logged.
|
|
35
|
+
if (ctx.ptySessions) {
|
|
36
|
+
try {
|
|
37
|
+
const result = await ctx.ptySessions.dispose(2_000);
|
|
38
|
+
if (result.survivors.length > 0) {
|
|
39
|
+
ctx.logger.warn(`pty dispose: ${result.survivors.length} session(s) past 2 s deadline: ${result.survivors.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
ctx.logger.warn(`pty sessions dispose failed: ${e.message}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (ctx.mcp) {
|
|
47
|
+
try {
|
|
48
|
+
await ctx.mcp.dispose();
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
ctx.logger.warn(`mcp dispose failed: ${e.message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (ctx.plugins) {
|
|
55
|
+
try {
|
|
56
|
+
await ctx.plugins.dispose();
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
ctx.logger.warn(`plugin dispose failed: ${e.message}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// (3.6) OTel LAST so it observes every lifecycle frame the other disposers
|
|
63
|
+
// emit. `dispose()` force-closes open spans, forceFlushes, and shuts down
|
|
64
|
+
// bounded by a 5 s deadline.
|
|
65
|
+
if (ctx.otel) {
|
|
66
|
+
try {
|
|
67
|
+
await ctx.otel.dispose();
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
ctx.logger.warn(`otel dispose failed: ${e.message}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=dispose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispose.js","sourceRoot":"","sources":["../../src/boot/dispose.ts"],"names":[],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EAAE,CAAC;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAwB,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA2B,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IACD,2EAA2E;IAC3E,0EAA0E;IAC1E,6BAA6B;IAC7B,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAyB,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp.d.ts","sourceRoot":"","sources":["../../src/commands/acp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,eAAO,MAAM,UAAU,EAAE,UAiCxB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Readable, Writable } from "node:stream";
|
|
2
|
+
import { installStdoutGuard, runAcp } from "@chances-ai/rpc";
|
|
3
|
+
import { makeEngineHost } from "./rpc.js";
|
|
4
|
+
export const acpCommand = {
|
|
5
|
+
name: "acp",
|
|
6
|
+
description: "Run the agent as a Zed Agent Client Protocol (ACP) agent over stdio.",
|
|
7
|
+
async run(ctx) {
|
|
8
|
+
if (!ctx)
|
|
9
|
+
throw new Error("acp requires a runtime context");
|
|
10
|
+
// The ACP SDK owns stdout for JSON-RPC; keep stray console.* on stderr.
|
|
11
|
+
const guard = installStdoutGuard();
|
|
12
|
+
const input = Readable.toWeb(process.stdin);
|
|
13
|
+
const output = Writable.toWeb(process.stdout);
|
|
14
|
+
const onSignal = () => {
|
|
15
|
+
try {
|
|
16
|
+
process.stdin.push(null);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// already ended.
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
process.once("SIGINT", onSignal);
|
|
23
|
+
process.once("SIGTERM", onSignal);
|
|
24
|
+
try {
|
|
25
|
+
const code = await runAcp({ host: makeEngineHost(ctx), input, output });
|
|
26
|
+
if (code === 2) {
|
|
27
|
+
process.stderr.write("ACP mode requires the optional '@agentclientprotocol/sdk' package.\n" +
|
|
28
|
+
"Install it: npm install @agentclientprotocol/sdk\n");
|
|
29
|
+
}
|
|
30
|
+
return code;
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
process.removeListener("SIGINT", onSignal);
|
|
34
|
+
process.removeListener("SIGTERM", onSignal);
|
|
35
|
+
guard.restore();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=acp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp.js","sourceRoot":"","sources":["../../src/commands/acp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAe;IACpC,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,sEAAsE;IACnF,KAAK,CAAC,GAAG,CAAC,GAAG;QACX,IAA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|
/** Environment self-check: runtime, native load status, providers, workspace. */
|
|
4
|
-
export declare function runDoctor(ctx: AppContext): number
|
|
4
|
+
export declare function runDoctor(ctx: AppContext): Promise<number>;
|
|
5
5
|
export declare const doctorCommand: CliCommand;
|
|
6
6
|
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,iFAAiF;AACjF,wBAAsB,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAgChE;AAED,eAAO,MAAM,aAAa,EAAE,UAO3B,CAAC"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { KNOWN_MODELS } from "@chances-ai/ai";
|
|
2
2
|
import { native } from "@chances-ai/native";
|
|
3
|
+
import { loadAcpSdk } from "@chances-ai/rpc";
|
|
3
4
|
/** Environment self-check: runtime, native load status, providers, workspace. */
|
|
4
|
-
export function runDoctor(ctx) {
|
|
5
|
+
export async function runDoctor(ctx) {
|
|
5
6
|
const configured = KNOWN_MODELS.filter((p) => ctx.auth.hasCredentials(p.id));
|
|
6
7
|
const missing = KNOWN_MODELS.filter((p) => !ctx.auth.hasCredentials(p.id));
|
|
7
8
|
const diag = native.loaderDiagnostic();
|
|
9
|
+
// (5.2) `chances rpc` is always available; `chances acp` needs the optional
|
|
10
|
+
// ACP SDK. Probe it the same way the adapter does.
|
|
11
|
+
const acpReady = (await loadAcpSdk()) !== null;
|
|
8
12
|
const nativeLine = diag.loaded
|
|
9
13
|
? `loaded (${diag.expectedSentinel} at ${diag.attemptedPath})`
|
|
10
14
|
: `JS fallback — reason=${diag.reason ?? "unknown"} (expected ${diag.expectedSentinel} at ${diag.attemptedPath})`;
|
|
@@ -21,6 +25,7 @@ export function runDoctor(ctx) {
|
|
|
21
25
|
`models available : ${ctx.registry.all().length}`,
|
|
22
26
|
`keys configured : ${configured.map((p) => p.id).join(", ") || "none"}`,
|
|
23
27
|
`keys missing : ${missing.map((p) => `${p.id} (${p.envKey})`).join(", ") || "none"}`,
|
|
28
|
+
`rpc / acp : rpc ready; acp ${acpReady ? "ready (@agentclientprotocol/sdk present)" : "unavailable — install @agentclientprotocol/sdk"}`,
|
|
24
29
|
];
|
|
25
30
|
if (!diag.loaded && diag.message) {
|
|
26
31
|
lines.push("", "Native diagnostic:", diag.message);
|
|
@@ -31,7 +36,7 @@ export function runDoctor(ctx) {
|
|
|
31
36
|
export const doctorCommand = {
|
|
32
37
|
name: "doctor",
|
|
33
38
|
description: "Print runtime, provider, and workspace diagnostics.",
|
|
34
|
-
run(ctx) {
|
|
39
|
+
async run(ctx) {
|
|
35
40
|
if (!ctx)
|
|
36
41
|
throw new Error("doctor requires a runtime context");
|
|
37
42
|
return runDoctor(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,SAAS,C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AAC,MAAM,EAAE;QACjD,sBAAsB,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE;QACxE,sBAAsB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE;QACxF,qCAAqC,QAAQ,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,gDAAgD,EAAE;KAChJ,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAe;IACvC,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,qDAAqD;IAClE,KAAK,CAAC,GAAG,CAAC,GAAG;QACX,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAC/D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type EngineHost } from "@chances-ai/rpc";
|
|
2
|
+
import type { AppContext } from "../boot/load-runtime.js";
|
|
3
|
+
import type { CliCommand } from "./registry.js";
|
|
4
|
+
/** EngineHost over the shared runtime context. `dispose` runs the canonical,
|
|
5
|
+
* idempotent runtime teardown (`disposeRuntime`) so the RpcServer/ACP shutdown
|
|
6
|
+
* disposes producers BEFORE flushing/closing the wire — teardown frames (a
|
|
7
|
+
* background subagent's last `tool_chunk`, MCP/plugin logs) reach the client
|
|
8
|
+
* (5.2 Round-2 S1). `main()`'s finally calls the same function afterwards and
|
|
9
|
+
* finds it already done (the WeakSet guard makes it a no-op). */
|
|
10
|
+
export declare function makeEngineHost(ctx: AppContext): EngineHost;
|
|
11
|
+
export declare const rpcCommand: CliCommand;
|
|
12
|
+
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../src/commands/rpc.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD;;;;;iEAKiE;AACjE,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAgB1D;AAED,eAAO,MAAM,UAAU,EAAE,UAmCxB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SessionManager } from "@chances-ai/session";
|
|
2
|
+
import { BoundedNdjsonWriter, RpcServer, installStdoutGuard, linesFromStream, } from "@chances-ai/rpc";
|
|
3
|
+
import { buildEngine } from "../boot/create-app.js";
|
|
4
|
+
import { disposeRuntime } from "../boot/dispose.js";
|
|
5
|
+
import cliPkg from "../../package.json" with { type: "json" };
|
|
6
|
+
/** EngineHost over the shared runtime context. `dispose` runs the canonical,
|
|
7
|
+
* idempotent runtime teardown (`disposeRuntime`) so the RpcServer/ACP shutdown
|
|
8
|
+
* disposes producers BEFORE flushing/closing the wire — teardown frames (a
|
|
9
|
+
* background subagent's last `tool_chunk`, MCP/plugin logs) reach the client
|
|
10
|
+
* (5.2 Round-2 S1). `main()`'s finally calls the same function afterwards and
|
|
11
|
+
* finds it already done (the WeakSet guard makes it a no-op). */
|
|
12
|
+
export function makeEngineHost(ctx) {
|
|
13
|
+
return {
|
|
14
|
+
build(resolver) {
|
|
15
|
+
const session = SessionManager.create("rpc");
|
|
16
|
+
const engine = buildEngine(ctx, session, resolver);
|
|
17
|
+
return {
|
|
18
|
+
runTurn: (prompt, token) => engine.runTurn(prompt, token),
|
|
19
|
+
bus: ctx.bus,
|
|
20
|
+
selection: ctx.selection,
|
|
21
|
+
sessionId: session.id,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
listModels: () => ctx.registry.all().map((m) => ({ provider: m.provider, model: m.id })),
|
|
25
|
+
dispose: () => disposeRuntime(ctx),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export const rpcCommand = {
|
|
29
|
+
name: "rpc",
|
|
30
|
+
description: "Run the agent as a Stable RPC server (NDJSON over stdio). Use --yes to auto-approve tools.",
|
|
31
|
+
async run(ctx, args) {
|
|
32
|
+
if (!ctx)
|
|
33
|
+
throw new Error("rpc requires a runtime context");
|
|
34
|
+
const writer = new BoundedNdjsonWriter(process.stdout);
|
|
35
|
+
// stdout carries ONLY protocol frames — redirect stray console.* to stderr.
|
|
36
|
+
const guard = installStdoutGuard();
|
|
37
|
+
const server = new RpcServer({
|
|
38
|
+
host: makeEngineHost(ctx),
|
|
39
|
+
writer,
|
|
40
|
+
agent: { name: cliPkg.name, version: cliPkg.version },
|
|
41
|
+
autoApprove: args.yes,
|
|
42
|
+
logSink: (line) => process.stderr.write(line),
|
|
43
|
+
});
|
|
44
|
+
// SIGINT/SIGTERM: end stdin so `run()` returns and `main()`'s finally
|
|
45
|
+
// disposes ctx. `server.run`'s own finally runs the graceful shutdown
|
|
46
|
+
// (cancel turn, deny pending permissions, flush).
|
|
47
|
+
const onSignal = () => {
|
|
48
|
+
try {
|
|
49
|
+
process.stdin.push(null);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// already ended — the for-await will terminate on its own.
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
process.once("SIGINT", onSignal);
|
|
56
|
+
process.once("SIGTERM", onSignal);
|
|
57
|
+
try {
|
|
58
|
+
return await server.run(linesFromStream(process.stdin));
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
process.removeListener("SIGINT", onSignal);
|
|
62
|
+
process.removeListener("SIGTERM", onSignal);
|
|
63
|
+
guard.restore();
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/commands/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,eAAe,GAGhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE9D;;;;;iEAKiE;AACjE,MAAM,UAAU,cAAc,CAAC,GAAe;IAC5C,OAAO;QACL,KAAK,CAAC,QAA4B;YAChC,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;YACnD,OAAO;gBACL,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;gBACzD,GAAG,EAAE,GAAG,CAAC,GAAG;gBACZ,SAAS,EAAE,GAAG,CAAC,SAAS;gBACxB,SAAS,EAAE,OAAO,C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YAC7D,CAAC;QACH,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAClC,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC3C,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC5C,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/entrypoints/cli.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/entrypoints/cli.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAWvE,OAAO,EAAe,SAAS,EAAE,YAAY,EAAkB,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AA2D1D,oDAAoD;AACpD,wBAAgB,oBAAoB,IAAI,eAAe,CAatD;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAE1B,yEAAyE;AACzE,wBAAsB,IAAI,CACxB,IAAI,GAAE,MAAM,EAA0B,EACtC,aAAa,GAAE,aAA2B,GACzC,OAAO,CAAC,MAAM,CAAC,CA2CjB;AAED,0EAA0E;AAC1E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/entrypoints/cli.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { loadRuntime } from "../boot/load-runtime.js";
|
|
2
|
+
import { disposeRuntime } from "../boot/dispose.js";
|
|
2
3
|
import { chatCommand } from "../commands/chat.js";
|
|
3
4
|
import { doctorCommand } from "../commands/doctor.js";
|
|
4
5
|
import { sessionCommand } from "../commands/session.js";
|
|
5
6
|
import { configCommand } from "../commands/config.js";
|
|
6
7
|
import { statsCommand } from "../commands/stats.js";
|
|
7
8
|
import { discoverCommand } from "../commands/discover.js";
|
|
9
|
+
import { rpcCommand } from "../commands/rpc.js";
|
|
10
|
+
import { acpCommand } from "../commands/acp.js";
|
|
8
11
|
import { helpCommand, printHelp, printVersion, versionCommand } from "../commands/version.js";
|
|
9
12
|
import { CommandRegistry } from "../commands/registry.js";
|
|
10
13
|
function parseArgs(argv) {
|
|
@@ -58,6 +61,8 @@ export function buildCommandRegistry() {
|
|
|
58
61
|
registry.register(sessionCommand);
|
|
59
62
|
registry.register(statsCommand);
|
|
60
63
|
registry.register(discoverCommand);
|
|
64
|
+
registry.register(rpcCommand);
|
|
65
|
+
registry.register(acpCommand);
|
|
61
66
|
registry.register(helpCommand);
|
|
62
67
|
registry.register(versionCommand);
|
|
63
68
|
return registry;
|
|
@@ -96,72 +101,15 @@ export async function main(argv = process.argv.slice(2), loadRuntimeFn = loadRun
|
|
|
96
101
|
return await cmd.run(ctx, cliArgs, registry);
|
|
97
102
|
}
|
|
98
103
|
finally {
|
|
99
|
-
// Plugins / MCP servers / background tasks may hold file
|
|
100
|
-
// child processes, sockets, or unlinked AbortControllers.
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
// then runs BEFORE plugin dispose so its child processes' SIGTERM
|
|
109
|
-
// lands while the bus is still alive to log the result.
|
|
110
|
-
if (ctx.backgroundTasks) {
|
|
111
|
-
try {
|
|
112
|
-
await ctx.backgroundTasks.dispose();
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
ctx.logger.warn(`background tasks dispose failed: ${e.message}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// (5.1) PTY sessions dispose AFTER background tasks (the subagent
|
|
119
|
-
// drain in `task-tool.ts` already SIGTERM-grace-killed the
|
|
120
|
-
// child-owned ones; this catches the parent's surviving sessions)
|
|
121
|
-
// and BEFORE MCP (parent's PTY sessions may depend on PATH-based
|
|
122
|
-
// commands that an MCP server set up). 2 s deadline matches
|
|
123
|
-
// backgroundTasks for shape uniformity. Survivors are logged but
|
|
124
|
-
// never block shutdown.
|
|
125
|
-
if (ctx.ptySessions) {
|
|
126
|
-
try {
|
|
127
|
-
const result = await ctx.ptySessions.dispose(2_000);
|
|
128
|
-
if (result.survivors.length > 0) {
|
|
129
|
-
ctx.logger.warn(`pty dispose: ${result.survivors.length} session(s) past 2 s deadline: ${result.survivors.join(", ")}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (e) {
|
|
133
|
-
ctx.logger.warn(`pty sessions dispose failed: ${e.message}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (ctx.mcp) {
|
|
137
|
-
try {
|
|
138
|
-
await ctx.mcp.dispose();
|
|
139
|
-
}
|
|
140
|
-
catch (e) {
|
|
141
|
-
ctx.logger.warn(`mcp dispose failed: ${e.message}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (ctx.plugins) {
|
|
145
|
-
try {
|
|
146
|
-
await ctx.plugins.dispose();
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
ctx.logger.warn(`plugin dispose failed: ${e.message}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// (3.6 — codex Round-1 SHOULD-FIX #2) OTel exporter disposes LAST so
|
|
153
|
-
// it observes every lifecycle frame the other disposers emit (MCP
|
|
154
|
-
// tool:result cancellations, plugin shutdown logs). `dispose()` force-
|
|
155
|
-
// closes still-open spans (codex MUST-FIX #5), `forceFlush`es the
|
|
156
|
-
// OTLP batch, and shuts down the provider — bounded by a 5 s deadline.
|
|
157
|
-
if (ctx.otel) {
|
|
158
|
-
try {
|
|
159
|
-
await ctx.otel.dispose();
|
|
160
|
-
}
|
|
161
|
-
catch (e) {
|
|
162
|
-
ctx.logger.warn(`otel dispose failed: ${e.message}`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
104
|
+
// Plugins / MCP servers / background tasks / PTY sessions may hold file
|
|
105
|
+
// handles, child processes, sockets, or unlinked AbortControllers. Tear
|
|
106
|
+
// them down regardless of how the command finished, in the order that
|
|
107
|
+
// matters (bg → pty → mcp → plugins → otel). `disposeRuntime` is the
|
|
108
|
+
// single owner of that sequence and is idempotent: the `rpc`/`acp`
|
|
109
|
+
// transports already call it from inside their own shutdown (so teardown
|
|
110
|
+
// frames reach the client before the wire closes — 5.2 Round-2 S1), and
|
|
111
|
+
// this call then finds the work already done.
|
|
112
|
+
await disposeRuntime(ctx);
|
|
165
113
|
}
|
|
166
114
|
}
|
|
167
115
|
/** Exported so tests can pre-build a registry without invoking main(). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/entrypoints/cli.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAA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nE,sCAAsC;IACtC,MAAM,qBAAqB,GAAG,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;IAC/E,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC;QAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,qBAAqB;KACtB,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;YAAS,CAAC;QACT,wEAAwE;QACxE,wEAAwE;QACxE,sEAAsE;QACtE,qEAAqE;QACrE,mEAAmE;QACnE,yEAAyE;QACzE,wEAAwE;QACxE,8CAA8C;QAC9C,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chances-ai/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"chances": "./dist/entrypoints/cli-node.js",
|
|
@@ -14,22 +14,23 @@
|
|
|
14
14
|
"@ai-sdk/google": "^1.2.0",
|
|
15
15
|
"@ai-sdk/openai": "^1.3.0",
|
|
16
16
|
"@ai-sdk/openai-compatible": "^0.2.0",
|
|
17
|
-
"@chances-ai/agents": "
|
|
18
|
-
"@chances-ai/ai": "
|
|
19
|
-
"@chances-ai/config": "
|
|
20
|
-
"@chances-ai/core": "
|
|
21
|
-
"@chances-ai/lsp": "
|
|
22
|
-
"@chances-ai/mcp": "
|
|
23
|
-
"@chances-ai/memory": "
|
|
24
|
-
"@chances-ai/native": "
|
|
25
|
-
"@chances-ai/plugin-api": "
|
|
26
|
-
"@chances-ai/plugin-logger": "
|
|
27
|
-
"@chances-ai/
|
|
28
|
-
"@chances-ai/
|
|
29
|
-
"@chances-ai/
|
|
30
|
-
"@chances-ai/telemetry
|
|
31
|
-
"@chances-ai/
|
|
32
|
-
"@chances-ai/
|
|
17
|
+
"@chances-ai/agents": "7.0.0",
|
|
18
|
+
"@chances-ai/ai": "7.0.0",
|
|
19
|
+
"@chances-ai/config": "7.0.0",
|
|
20
|
+
"@chances-ai/core": "7.0.0",
|
|
21
|
+
"@chances-ai/lsp": "7.0.0",
|
|
22
|
+
"@chances-ai/mcp": "7.0.0",
|
|
23
|
+
"@chances-ai/memory": "7.0.0",
|
|
24
|
+
"@chances-ai/native": "7.0.0",
|
|
25
|
+
"@chances-ai/plugin-api": "7.0.0",
|
|
26
|
+
"@chances-ai/plugin-logger": "7.0.0",
|
|
27
|
+
"@chances-ai/rpc": "7.0.0",
|
|
28
|
+
"@chances-ai/runtime": "7.0.0",
|
|
29
|
+
"@chances-ai/session": "7.0.0",
|
|
30
|
+
"@chances-ai/telemetry": "7.0.0",
|
|
31
|
+
"@chances-ai/telemetry-otel": "7.0.0",
|
|
32
|
+
"@chances-ai/tools": "7.0.0",
|
|
33
|
+
"@chances-ai/tui": "7.0.0",
|
|
33
34
|
"ai": "^4.3.0",
|
|
34
35
|
"ink": "^5.0.1",
|
|
35
36
|
"react": "^18.3.1",
|