@claudexor/cli 3.0.3 → 3.1.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/LICENSE +1 -1
- package/dist/about-command.d.ts +32 -0
- package/dist/about-command.d.ts.map +1 -0
- package/dist/about-command.js +40 -0
- package/dist/about-command.js.map +1 -0
- package/dist/acp-surface-runner.d.ts +12 -0
- package/dist/acp-surface-runner.d.ts.map +1 -1
- package/dist/acp-surface-runner.js +113 -11
- package/dist/acp-surface-runner.js.map +1 -1
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +2 -1
- package/dist/capabilities.js.map +1 -1
- package/dist/claudexord.d.ts +21 -0
- package/dist/claudexord.d.ts.map +1 -1
- package/dist/claudexord.js +96 -8
- package/dist/claudexord.js.map +1 -1
- package/dist/cli-error.d.ts +97 -0
- package/dist/cli-error.d.ts.map +1 -0
- package/dist/cli-error.js +308 -0
- package/dist/cli-error.js.map +1 -0
- package/dist/cli-io.d.ts +9 -0
- package/dist/cli-io.d.ts.map +1 -1
- package/dist/cli-io.js +10 -1
- package/dist/cli-io.js.map +1 -1
- package/dist/cli.js +105 -110
- package/dist/cli.js.map +1 -1
- package/dist/codex-device-login.d.ts +117 -0
- package/dist/codex-device-login.d.ts.map +1 -0
- package/dist/codex-device-login.js +227 -0
- package/dist/codex-device-login.js.map +1 -0
- package/dist/command-flags.d.ts.map +1 -1
- package/dist/command-flags.js +4 -3
- package/dist/command-flags.js.map +1 -1
- package/dist/command-help.d.ts +46 -0
- package/dist/command-help.d.ts.map +1 -0
- package/dist/command-help.js +92 -0
- package/dist/command-help.js.map +1 -0
- package/dist/command-registry.d.ts +2 -0
- package/dist/command-registry.d.ts.map +1 -1
- package/dist/command-registry.js +11 -4
- package/dist/command-registry.js.map +1 -1
- package/dist/control-services.d.ts +45 -18
- package/dist/control-services.d.ts.map +1 -1
- package/dist/control-services.js +56 -30
- package/dist/control-services.js.map +1 -1
- package/dist/credential-commands.d.ts.map +1 -1
- package/dist/credential-commands.js +44 -1
- package/dist/credential-commands.js.map +1 -1
- package/dist/daemon-outcome.d.ts +24 -0
- package/dist/daemon-outcome.d.ts.map +1 -0
- package/dist/daemon-outcome.js +59 -0
- package/dist/daemon-outcome.js.map +1 -0
- package/dist/daemon-run.d.ts +23 -4
- package/dist/daemon-run.d.ts.map +1 -1
- package/dist/daemon-run.js +66 -27
- package/dist/daemon-run.js.map +1 -1
- package/dist/delegation-belt-descriptor.d.ts +31 -13
- package/dist/delegation-belt-descriptor.d.ts.map +1 -1
- package/dist/delegation-belt-descriptor.js +43 -15
- package/dist/delegation-belt-descriptor.js.map +1 -1
- package/dist/live.d.ts +13 -1
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +56 -7
- package/dist/live.js.map +1 -1
- package/dist/mcp-runner.d.ts.map +1 -1
- package/dist/mcp-runner.js +60 -6
- package/dist/mcp-runner.js.map +1 -1
- package/dist/native-login.d.ts +10 -1
- package/dist/native-login.d.ts.map +1 -1
- package/dist/native-login.js +32 -10
- package/dist/native-login.js.map +1 -1
- package/dist/ops-commands.d.ts.map +1 -1
- package/dist/ops-commands.js +42 -51
- package/dist/ops-commands.js.map +1 -1
- package/dist/plan-implement-readiness.d.ts +32 -0
- package/dist/plan-implement-readiness.d.ts.map +1 -0
- package/dist/plan-implement-readiness.js +51 -0
- package/dist/plan-implement-readiness.js.map +1 -0
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +73 -20
- package/dist/plugins.js.map +1 -1
- package/dist/project-command.d.ts +15 -0
- package/dist/project-command.d.ts.map +1 -1
- package/dist/project-command.js +75 -20
- package/dist/project-command.js.map +1 -1
- package/dist/quota-command.d.ts.map +1 -1
- package/dist/quota-command.js +2 -6
- package/dist/quota-command.js.map +1 -1
- package/dist/release-command.d.ts.map +1 -1
- package/dist/release-command.js +31 -6
- package/dist/release-command.js.map +1 -1
- package/dist/release.d.ts +41 -10
- package/dist/release.d.ts.map +1 -1
- package/dist/release.js +70 -48
- package/dist/release.js.map +1 -1
- package/dist/repo-asset-authority.d.ts +93 -0
- package/dist/repo-asset-authority.d.ts.map +1 -0
- package/dist/repo-asset-authority.js +178 -0
- package/dist/repo-asset-authority.js.map +1 -0
- package/dist/review-command.d.ts.map +1 -1
- package/dist/review-command.js +2 -6
- package/dist/review-command.js.map +1 -1
- package/dist/settings-command.d.ts.map +1 -1
- package/dist/settings-command.js +2 -6
- package/dist/settings-command.js.map +1 -1
- package/dist/settings-service.d.ts +51 -2
- package/dist/settings-service.d.ts.map +1 -1
- package/dist/settings-service.js +126 -2
- package/dist/settings-service.js.map +1 -1
- package/dist/setup-job-store.d.ts +14 -3
- package/dist/setup-job-store.d.ts.map +1 -1
- package/dist/setup-job-store.js +24 -4
- package/dist/setup-job-store.js.map +1 -1
- package/dist/setup-jobs.d.ts +14 -4
- package/dist/setup-jobs.d.ts.map +1 -1
- package/dist/setup-jobs.js +204 -23
- package/dist/setup-jobs.js.map +1 -1
- package/dist/setup-login-inline.d.ts +69 -0
- package/dist/setup-login-inline.d.ts.map +1 -0
- package/dist/setup-login-inline.js +206 -0
- package/dist/setup-login-inline.js.map +1 -0
- package/dist/setup-login-protocol.d.ts +3 -2
- package/dist/setup-login-protocol.d.ts.map +1 -1
- package/dist/setup-login-protocol.js +16 -1
- package/dist/setup-login-protocol.js.map +1 -1
- package/dist/setup-login-runner.d.ts +9 -0
- package/dist/setup-login-runner.d.ts.map +1 -1
- package/dist/setup-login-runner.js +212 -5
- package/dist/setup-login-runner.js.map +1 -1
- package/dist/thread-delivery.d.ts.map +1 -1
- package/dist/thread-delivery.js +3 -1
- package/dist/thread-delivery.js.map +1 -1
- package/package.json +23 -23
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D-17 Ф4 primary codex login flow: typed device-code auth over the official
|
|
3
|
+
* codex app-server, with NO Terminal handoff.
|
|
4
|
+
*
|
|
5
|
+
* This module is the transport CORE only — a pure JSON-RPC auth driver over an
|
|
6
|
+
* injected connection. It is consumed by the detached setup-login runner worker
|
|
7
|
+
* (setup-login-runner.ts), which hosts the `codex app-server --stdio` child in
|
|
8
|
+
* the SAME detached process group the Terminal flow uses, so every existing
|
|
9
|
+
* evidence semantic (process-group identity, execution permit, restart
|
|
10
|
+
* adoption, result sidecar) is preserved (ARCHITECTURE §Interactive runs).
|
|
11
|
+
*
|
|
12
|
+
* The transport reuses the request/response + notification patterns proven by
|
|
13
|
+
* the codex QUOTA app-server client (codex-quota-source.ts): initialize →
|
|
14
|
+
* initialized notification → typed method calls, with vendor diagnostics never
|
|
15
|
+
* treated as protocol authority.
|
|
16
|
+
*
|
|
17
|
+
* SECRET DISCIPLINE (INV-062, D-17): the one-time `userCode` is a TRANSIENT
|
|
18
|
+
* disclosure. It rides the runner's transient device-code sidecar and a
|
|
19
|
+
* read-time snapshot projection ONLY; it is NEVER journaled, logged, or written
|
|
20
|
+
* to the durable result receipt. The durable authority persists only THAT a
|
|
21
|
+
* code exists (see {@link deviceCodeDurableMarker}), mirroring how the tee'd
|
|
22
|
+
* URL/code disclosure of the Terminal flow keeps the code out of the journal.
|
|
23
|
+
*/
|
|
24
|
+
/** One incoming/outgoing JSON-RPC frame. Responses carry a numeric `id`;
|
|
25
|
+
* notifications carry a `method` and no `id`. */
|
|
26
|
+
export interface JsonRpcFrame {
|
|
27
|
+
id?: number;
|
|
28
|
+
method?: string;
|
|
29
|
+
params?: unknown;
|
|
30
|
+
result?: unknown;
|
|
31
|
+
error?: {
|
|
32
|
+
code?: number;
|
|
33
|
+
message?: string;
|
|
34
|
+
} | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Minimal duplex JSON-RPC connection the driver runs over. The runner wires
|
|
38
|
+
* this to the `codex app-server --stdio` child's stdio; tests inject a fake
|
|
39
|
+
* that scripts typed frames. Keeping the driver above this seam is what makes
|
|
40
|
+
* the capability-probe and completion logic unit-testable with no real codex.
|
|
41
|
+
*/
|
|
42
|
+
export interface CodexAppServerConnection {
|
|
43
|
+
/** Write one JSON-RPC frame to the app-server. */
|
|
44
|
+
send(frame: JsonRpcFrame): void;
|
|
45
|
+
/** Register the sole incoming-frame handler (responses + notifications). */
|
|
46
|
+
onFrame(handler: (frame: JsonRpcFrame) => void): void;
|
|
47
|
+
/** Register the transport-fault/close handler (process exit, stdio error). */
|
|
48
|
+
onClose(handler: (error?: Error) => void): void;
|
|
49
|
+
/** Best-effort teardown of the underlying transport. */
|
|
50
|
+
close(): void;
|
|
51
|
+
}
|
|
52
|
+
/** Transient device-code disclosure. `userCode` MUST NOT be journaled/logged. */
|
|
53
|
+
export interface DeviceCodeDisclosure {
|
|
54
|
+
loginId: string;
|
|
55
|
+
verificationUrl: string;
|
|
56
|
+
/** TRANSIENT one-time code — sidecar + read-time projection only. */
|
|
57
|
+
userCode: string;
|
|
58
|
+
}
|
|
59
|
+
/** Durable, journal-safe marker: proves a code was disclosed WITHOUT the code
|
|
60
|
+
* or its verification URL. This — and only this — is what the runner's result
|
|
61
|
+
* receipt / the daemon journal may carry about the device-code disclosure. */
|
|
62
|
+
export interface DeviceCodeDurableMarker {
|
|
63
|
+
disclosed: true;
|
|
64
|
+
}
|
|
65
|
+
export declare function deviceCodeDurableMarker(_disclosure: DeviceCodeDisclosure): DeviceCodeDurableMarker;
|
|
66
|
+
/** Result of attempting to start a device-code login. */
|
|
67
|
+
export type DeviceLoginStart = {
|
|
68
|
+
kind: "started";
|
|
69
|
+
disclosure: DeviceCodeDisclosure;
|
|
70
|
+
/** Await the vendor's completion signal; cancels on abort. */
|
|
71
|
+
awaitCompletion(): Promise<DeviceLoginCompletion>;
|
|
72
|
+
} | {
|
|
73
|
+
/** Typed capability probe: the installed app-server lacks the auth
|
|
74
|
+
* methods (JSON-RPC method-not-found). The runner maps this to the
|
|
75
|
+
* `device_auth_unsupported` result so the daemon demotes to the legacy
|
|
76
|
+
* Terminal fallback — no stdout regex. */
|
|
77
|
+
kind: "not_supported";
|
|
78
|
+
detail: string;
|
|
79
|
+
};
|
|
80
|
+
export type DeviceLoginCompletion = {
|
|
81
|
+
kind: "completed";
|
|
82
|
+
} | {
|
|
83
|
+
kind: "cancelled";
|
|
84
|
+
} | {
|
|
85
|
+
kind: "failed";
|
|
86
|
+
detail: string;
|
|
87
|
+
};
|
|
88
|
+
export type CodexDeviceLoginFlow = "chatgptDeviceCode" | "chatgpt";
|
|
89
|
+
export interface CodexDeviceLoginOptions {
|
|
90
|
+
/** `chatgptDeviceCode` (primary) or `chatgpt` (secondary browser-callback,
|
|
91
|
+
* surfaces an `authUrl` rather than a one-time code). */
|
|
92
|
+
flow?: CodexDeviceLoginFlow;
|
|
93
|
+
/** Abort awaiting completion (deadline/cancel); triggers account/login/cancel. */
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
/** Per-request timeout for the initialize/start handshake (default 8s). */
|
|
96
|
+
requestTimeoutMs?: number;
|
|
97
|
+
now?: () => number;
|
|
98
|
+
setTimeoutFn?: typeof setTimeout;
|
|
99
|
+
clearTimeoutFn?: typeof clearTimeout;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Drive the codex app-server through the typed device-code auth handshake.
|
|
103
|
+
*
|
|
104
|
+
* initialize → initialized → account/login/start {type} →
|
|
105
|
+
* error(method-not-found) → not_supported (capability probe fallback)
|
|
106
|
+
* error(other) → throws (runner classifies as failure)
|
|
107
|
+
* result{loginId,verificationUrl,userCode} → started + awaitCompletion()
|
|
108
|
+
*
|
|
109
|
+
* awaitCompletion resolves on an `account/login/completed` notification for the
|
|
110
|
+
* disclosed loginId (or an `account/updated` notification reporting an
|
|
111
|
+
* authenticated account), and on abort sends `account/login/cancel {loginId}`.
|
|
112
|
+
*/
|
|
113
|
+
export declare function startCodexDeviceLogin(connection: CodexAppServerConnection, options?: CodexDeviceLoginOptions): Promise<DeviceLoginStart>;
|
|
114
|
+
/** Map a notification to a completion outcome, or null if it is not terminal
|
|
115
|
+
* for THIS login. Vendor prose is never classified — only typed fields. */
|
|
116
|
+
export declare function classifyCompletion(method: string, params: unknown, loginId: string): DeviceLoginCompletion | null;
|
|
117
|
+
//# sourceMappingURL=codex-device-login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-device-login.d.ts","sourceRoot":"","sources":["../src/codex-device-login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;iDACiD;AACjD,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACpD;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,kDAAkD;IAClD,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,4EAA4E;IAC5E,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI,CAAC;IACtD,8EAA8E;IAC9E,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IAChD,wDAAwD;IACxD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,iFAAiF;AACjF,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;8EAE8E;AAC9E,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,oBAAoB,GAChC,uBAAuB,CAIzB;AAED,yDAAyD;AACzD,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,oBAAoB,CAAC;IACjC,8DAA8D;IAC9D,eAAe,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACnD,GACD;IACE;;;8CAG0C;IAC1C,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,MAAM,MAAM,qBAAqB,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,SAAS,CAAC;AAEnE,MAAM,WAAW,uBAAuB;IACtC;6DACyD;IACzD,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,kFAAkF;IAClF,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,UAAU,CAAC;IACjC,cAAc,CAAC,EAAE,OAAO,YAAY,CAAC;CACtC;AAKD;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,wBAAwB,EACpC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CAiJ3B;AAED;2EAC2E;AAC3E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,MAAM,GACd,qBAAqB,GAAG,IAAI,CAwB9B"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D-17 Ф4 primary codex login flow: typed device-code auth over the official
|
|
3
|
+
* codex app-server, with NO Terminal handoff.
|
|
4
|
+
*
|
|
5
|
+
* This module is the transport CORE only — a pure JSON-RPC auth driver over an
|
|
6
|
+
* injected connection. It is consumed by the detached setup-login runner worker
|
|
7
|
+
* (setup-login-runner.ts), which hosts the `codex app-server --stdio` child in
|
|
8
|
+
* the SAME detached process group the Terminal flow uses, so every existing
|
|
9
|
+
* evidence semantic (process-group identity, execution permit, restart
|
|
10
|
+
* adoption, result sidecar) is preserved (ARCHITECTURE §Interactive runs).
|
|
11
|
+
*
|
|
12
|
+
* The transport reuses the request/response + notification patterns proven by
|
|
13
|
+
* the codex QUOTA app-server client (codex-quota-source.ts): initialize →
|
|
14
|
+
* initialized notification → typed method calls, with vendor diagnostics never
|
|
15
|
+
* treated as protocol authority.
|
|
16
|
+
*
|
|
17
|
+
* SECRET DISCIPLINE (INV-062, D-17): the one-time `userCode` is a TRANSIENT
|
|
18
|
+
* disclosure. It rides the runner's transient device-code sidecar and a
|
|
19
|
+
* read-time snapshot projection ONLY; it is NEVER journaled, logged, or written
|
|
20
|
+
* to the durable result receipt. The durable authority persists only THAT a
|
|
21
|
+
* code exists (see {@link deviceCodeDurableMarker}), mirroring how the tee'd
|
|
22
|
+
* URL/code disclosure of the Terminal flow keeps the code out of the journal.
|
|
23
|
+
*/
|
|
24
|
+
export function deviceCodeDurableMarker(_disclosure) {
|
|
25
|
+
// Deliberately drops loginId, verificationUrl, and userCode: the journal
|
|
26
|
+
// records THAT a code exists, never the code (D-17, INV-062).
|
|
27
|
+
return { disclosed: true };
|
|
28
|
+
}
|
|
29
|
+
/** JSON-RPC "method not found" — the capability-probe signal. */
|
|
30
|
+
const METHOD_NOT_FOUND = -32601;
|
|
31
|
+
/**
|
|
32
|
+
* Drive the codex app-server through the typed device-code auth handshake.
|
|
33
|
+
*
|
|
34
|
+
* initialize → initialized → account/login/start {type} →
|
|
35
|
+
* error(method-not-found) → not_supported (capability probe fallback)
|
|
36
|
+
* error(other) → throws (runner classifies as failure)
|
|
37
|
+
* result{loginId,verificationUrl,userCode} → started + awaitCompletion()
|
|
38
|
+
*
|
|
39
|
+
* awaitCompletion resolves on an `account/login/completed` notification for the
|
|
40
|
+
* disclosed loginId (or an `account/updated` notification reporting an
|
|
41
|
+
* authenticated account), and on abort sends `account/login/cancel {loginId}`.
|
|
42
|
+
*/
|
|
43
|
+
export async function startCodexDeviceLogin(connection, options = {}) {
|
|
44
|
+
const flow = options.flow ?? "chatgptDeviceCode";
|
|
45
|
+
const requestTimeoutMs = options.requestTimeoutMs ?? 8_000;
|
|
46
|
+
const setTimeoutFn = options.setTimeoutFn ?? setTimeout;
|
|
47
|
+
const clearTimeoutFn = options.clearTimeoutFn ?? clearTimeout;
|
|
48
|
+
const pending = new Map();
|
|
49
|
+
const notificationHandlers = new Set();
|
|
50
|
+
let transportError = null;
|
|
51
|
+
const failAll = (error) => {
|
|
52
|
+
transportError ??= error;
|
|
53
|
+
for (const entry of pending.values()) {
|
|
54
|
+
clearTimeoutFn(entry.timer);
|
|
55
|
+
entry.reject(transportError);
|
|
56
|
+
}
|
|
57
|
+
pending.clear();
|
|
58
|
+
};
|
|
59
|
+
connection.onClose((error) => failAll(error ?? new Error("codex app-server closed")));
|
|
60
|
+
connection.onFrame((frame) => {
|
|
61
|
+
if (typeof frame.id === "number") {
|
|
62
|
+
const entry = pending.get(frame.id);
|
|
63
|
+
if (!entry)
|
|
64
|
+
return;
|
|
65
|
+
clearTimeoutFn(entry.timer);
|
|
66
|
+
pending.delete(frame.id);
|
|
67
|
+
entry.resolve(frame);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (typeof frame.method === "string") {
|
|
71
|
+
for (const handler of notificationHandlers)
|
|
72
|
+
handler(frame.method, frame.params);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const request = (id, method, params) => new Promise((resolve, reject) => {
|
|
76
|
+
if (transportError) {
|
|
77
|
+
reject(transportError);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const timer = setTimeoutFn(() => {
|
|
81
|
+
pending.delete(id);
|
|
82
|
+
reject(new Error(`${method} timed out`));
|
|
83
|
+
}, requestTimeoutMs);
|
|
84
|
+
pending.set(id, { resolve, reject, timer });
|
|
85
|
+
connection.send({ id, method, params });
|
|
86
|
+
});
|
|
87
|
+
await request(1, "initialize", {
|
|
88
|
+
clientInfo: { name: "claudexor", version: "2" },
|
|
89
|
+
capabilities: {},
|
|
90
|
+
});
|
|
91
|
+
connection.send({ method: "initialized", params: null });
|
|
92
|
+
// Register a completion BUFFER before sending account/login/start. A
|
|
93
|
+
// connection that delivers the start RESPONSE and a matching
|
|
94
|
+
// `account/login/completed` notification synchronously in ONE input turn would
|
|
95
|
+
// otherwise drop the completion: the real completion handler cannot be
|
|
96
|
+
// installed until loginId is known, which is only AFTER this response resolves
|
|
97
|
+
// (a later microtask). The buffer captures any notification that arrives
|
|
98
|
+
// during the handshake; it is replayed through the classifier once loginId is
|
|
99
|
+
// known, so awaitCompletion() can never hang past a vendor success.
|
|
100
|
+
const bufferedNotifications = [];
|
|
101
|
+
const bufferHandler = (method, params) => {
|
|
102
|
+
bufferedNotifications.push({ method, params });
|
|
103
|
+
};
|
|
104
|
+
notificationHandlers.add(bufferHandler);
|
|
105
|
+
const startFrame = await request(2, "account/login/start", { type: flow });
|
|
106
|
+
// No `await` runs between here and where the real completion handler replaces
|
|
107
|
+
// the buffer below, so no notification can arrive unbuffered/unhandled in the
|
|
108
|
+
// gap; stop buffering now that the handshake response has been consumed.
|
|
109
|
+
notificationHandlers.delete(bufferHandler);
|
|
110
|
+
if (startFrame.error) {
|
|
111
|
+
if (startFrame.error.code === METHOD_NOT_FOUND) {
|
|
112
|
+
return {
|
|
113
|
+
kind: "not_supported",
|
|
114
|
+
detail: startFrame.error.message ??
|
|
115
|
+
"codex app-server does not expose account/login/start (typed device-code auth)",
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
throw new Error(`codex app-server refused account/login/start: ${startFrame.error.message ?? "unknown error"}`);
|
|
119
|
+
}
|
|
120
|
+
const disclosure = parseDisclosure(startFrame.result);
|
|
121
|
+
if (!disclosure) {
|
|
122
|
+
throw new Error("codex app-server login/start result is missing loginId/verificationUrl");
|
|
123
|
+
}
|
|
124
|
+
const loginId = disclosure.loginId;
|
|
125
|
+
const readTransportError = () => transportError;
|
|
126
|
+
// Listen for completion EAGERLY (before awaitCompletion is called) so a
|
|
127
|
+
// `completed`/`updated` notification that races the caller is never lost.
|
|
128
|
+
let settledOutcome = null;
|
|
129
|
+
let deliver = null;
|
|
130
|
+
const onAbort = () => {
|
|
131
|
+
// Cancel the pending login so the vendor releases the device code, then
|
|
132
|
+
// report the honest cancellation to the runner.
|
|
133
|
+
try {
|
|
134
|
+
connection.send({ method: "account/login/cancel", params: { loginId } });
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
/* transport already gone */
|
|
138
|
+
}
|
|
139
|
+
settle({ kind: "cancelled" });
|
|
140
|
+
};
|
|
141
|
+
const settle = (outcome) => {
|
|
142
|
+
if (settledOutcome)
|
|
143
|
+
return;
|
|
144
|
+
settledOutcome = outcome;
|
|
145
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
146
|
+
deliver?.(outcome);
|
|
147
|
+
};
|
|
148
|
+
connection.onClose((error) => settle({ kind: "failed", detail: (error ?? new Error("codex app-server closed")).message }));
|
|
149
|
+
const completionHandler = (method, params) => {
|
|
150
|
+
const outcome = classifyCompletion(method, params, loginId);
|
|
151
|
+
if (outcome)
|
|
152
|
+
settle(outcome);
|
|
153
|
+
};
|
|
154
|
+
notificationHandlers.add(completionHandler);
|
|
155
|
+
// Replay any notification buffered DURING the start handshake (e.g. a
|
|
156
|
+
// completion delivered synchronously with the start response, before loginId
|
|
157
|
+
// was known). settle() is idempotent, so a racing live notification and a
|
|
158
|
+
// replayed one cannot double-settle.
|
|
159
|
+
for (const buffered of bufferedNotifications) {
|
|
160
|
+
const outcome = classifyCompletion(buffered.method, buffered.params, loginId);
|
|
161
|
+
if (outcome)
|
|
162
|
+
settle(outcome);
|
|
163
|
+
}
|
|
164
|
+
if (options.signal?.aborted)
|
|
165
|
+
onAbort();
|
|
166
|
+
else
|
|
167
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
168
|
+
const pendingError = readTransportError();
|
|
169
|
+
if (pendingError && !settledOutcome)
|
|
170
|
+
settle({ kind: "failed", detail: pendingError.message });
|
|
171
|
+
const awaitCompletion = () => new Promise((resolve) => {
|
|
172
|
+
if (settledOutcome)
|
|
173
|
+
resolve(settledOutcome);
|
|
174
|
+
else
|
|
175
|
+
deliver = resolve;
|
|
176
|
+
});
|
|
177
|
+
return { kind: "started", disclosure, awaitCompletion };
|
|
178
|
+
}
|
|
179
|
+
/** Map a notification to a completion outcome, or null if it is not terminal
|
|
180
|
+
* for THIS login. Vendor prose is never classified — only typed fields. */
|
|
181
|
+
export function classifyCompletion(method, params, loginId) {
|
|
182
|
+
const record = asRecord(params);
|
|
183
|
+
if (method === "account/login/completed") {
|
|
184
|
+
// Match the disclosed login when the vendor echoes an id; a bare completion
|
|
185
|
+
// is accepted (single in-flight login per app-server).
|
|
186
|
+
const frameLoginId = record ? asString(record["loginId"]) : null;
|
|
187
|
+
if (frameLoginId !== null && frameLoginId !== loginId)
|
|
188
|
+
return null;
|
|
189
|
+
const success = record ? record["success"] : undefined;
|
|
190
|
+
if (success === false) {
|
|
191
|
+
return { kind: "failed", detail: "codex reported the device-code login did not succeed" };
|
|
192
|
+
}
|
|
193
|
+
return { kind: "completed" };
|
|
194
|
+
}
|
|
195
|
+
if (method === "account/updated") {
|
|
196
|
+
// An authenticated account transition is a positive completion signal for a
|
|
197
|
+
// login that never emits a dedicated completed notification.
|
|
198
|
+
const authenticated = record !== null &&
|
|
199
|
+
(record["authenticated"] === true ||
|
|
200
|
+
asString(record["authMethod"]) !== null ||
|
|
201
|
+
asRecord(record["account"]) !== null);
|
|
202
|
+
return authenticated ? { kind: "completed" } : null;
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
function parseDisclosure(result) {
|
|
207
|
+
const record = asRecord(result);
|
|
208
|
+
if (!record)
|
|
209
|
+
return null;
|
|
210
|
+
const loginId = asString(record["loginId"]);
|
|
211
|
+
const verificationUrl = asString(record["verificationUrl"]) ?? asString(record["authUrl"]) ?? asString(record["url"]);
|
|
212
|
+
if (!loginId || !verificationUrl)
|
|
213
|
+
return null;
|
|
214
|
+
// `userCode` is absent for the browser-callback (`chatgpt`) flow; keep an
|
|
215
|
+
// empty string so the AuthSheet can render the URL-only card.
|
|
216
|
+
const userCode = asString(record["userCode"]) ?? "";
|
|
217
|
+
return { loginId, verificationUrl, userCode };
|
|
218
|
+
}
|
|
219
|
+
function asRecord(value) {
|
|
220
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
221
|
+
? value
|
|
222
|
+
: null;
|
|
223
|
+
}
|
|
224
|
+
function asString(value) {
|
|
225
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=codex-device-login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-device-login.js","sourceRoot":"","sources":["../src/codex-device-login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA4CH,MAAM,UAAU,uBAAuB,CACrC,WAAiC;IAEjC,yEAAyE;IACzE,8DAA8D;IAC9D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC;AAqCD,iEAAiE;AACjE,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAAoC,EACpC,UAAmC,EAAE;IAErC,MAAM,IAAI,GAAyB,OAAO,CAAC,IAAI,IAAI,mBAAmB,CAAC;IACvE,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,KAAK,CAAC;IAC3D,MAAM,YAAY,GAAG,O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E,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-flags.d.ts","sourceRoot":"","sources":["../src/command-flags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,mFAAmF;AACnF,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAqCtC,CAAC;AA2BF,eAAO,MAAM,wBAAwB,UAA+C,CAAC;AAErF,eAAO,MAAM,SAAS,EAAE,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"command-flags.d.ts","sourceRoot":"","sources":["../src/command-flags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,mFAAmF;AACnF,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAqCtC,CAAC;AA2BF,eAAO,MAAM,wBAAwB,UAA+C,CAAC;AAErF,eAAO,MAAM,SAAS,EAAE,SAAS,WAAW,EAmJ3C,CAAC"}
|
package/dist/command-flags.js
CHANGED
|
@@ -57,7 +57,7 @@ const FROZEN_REVIEW_FLAGS = [
|
|
|
57
57
|
];
|
|
58
58
|
export const FROZEN_REVIEW_FLAG_NAMES = FROZEN_REVIEW_FLAGS.map((flag) => flag.name);
|
|
59
59
|
export const CLI_FLAGS = [
|
|
60
|
-
valueFlag("harness", "<id[,id...]>", "Force harness
|
|
60
|
+
valueFlag("harness", "<id[,id...]>", "Force the eligible pool; one explicit harness also becomes the effective primary"),
|
|
61
61
|
valueFlag("route", "<local_session|api_key>", "Credential route filter for route-annotated model lists (models command)"),
|
|
62
62
|
valueFlag("mode", "<mode>", "agent verb: ask | plan | agent (strategies are flags, not modes);\n apply verb: delivery mode apply | commit | branch | pr"),
|
|
63
63
|
valueFlag("n", "<N>", "Best-of-N width (agent): N isolated candidates + cross-review"),
|
|
@@ -75,7 +75,7 @@ export const CLI_FLAGS = [
|
|
|
75
75
|
valueFlag("max-usd", "<amount>", "Hard per-run spend cap (USD)"),
|
|
76
76
|
valueFlag("max-seconds", "<n>", "Hard wall-clock deadline for the whole run (seconds); on expiry the run is cancelled (wall_clock_exceeded)"),
|
|
77
77
|
valueFlag("deny-path", "<glob>", "Glob no candidate may touch at all (repeatable); isolated runs only — a violating patch is blocked before delivery"),
|
|
78
|
-
valueFlag("output-schema", "<file>", "JSON Schema file the run's final answer must conform to; engine-validated into final/output.json with a typed conformance receipt"),
|
|
78
|
+
valueFlag("output-schema", "<file>", "JSON Schema file the run's final answer must conform to; supports $schema http://json-schema.org/draft-07/schema# and https://json-schema.org/draft/2020-12/schema (omitted $schema defaults to draft-07); engine-validated into final/output.json with a typed conformance receipt"),
|
|
79
79
|
valueFlag("max-turns", "<n>", "Per-run turn cap (beats per-harness settings)"),
|
|
80
80
|
valueFlag("prompt-file", "<file>", "Read the prompt from a file (or pass `-` to read stdin)"),
|
|
81
81
|
valueFlag("thread", "<id>", "Continue an existing thread (runs land as its next turn)"),
|
|
@@ -90,7 +90,7 @@ export const CLI_FLAGS = [
|
|
|
90
90
|
valueFlag("web", "<mode>", "External web/search policy: off|auto|cached|live"),
|
|
91
91
|
valueFlag("model", "<id>", "Model hint forwarded to the selected harness route"),
|
|
92
92
|
valueFlag("effort", "<level>", "Reasoning effort hint: low|medium|high|xhigh|max"),
|
|
93
|
-
valueFlag("primary-harness", "<id>", "
|
|
93
|
+
valueFlag("primary-harness", "<id>", "Explicitly bias single-route modes and first candidate choice; must belong to the pool"),
|
|
94
94
|
valueFlag("portfolio", "<id>", "Removed in v2; always errors (use --routing-goal)"),
|
|
95
95
|
valueFlag("routing-goal", "<goal>", "Routing goal: auto|quality|economy"),
|
|
96
96
|
valueFlag("profile", "<profile-id>", "Credential profile for this run (INV-135); unknown/disabled ids refuse, never default"),
|
|
@@ -105,6 +105,7 @@ export const CLI_FLAGS = [
|
|
|
105
105
|
booleanFlag("browser-redirect", "Codex login: opt into the localhost-callback flow instead of the device-auth default"),
|
|
106
106
|
booleanFlag("dry-run", "Plugin: show lifecycle actions; apply: check patch without mutating"),
|
|
107
107
|
booleanFlag("force", "Reapply verified Claudexor-owned plugin drift; never overwrites unowned files"),
|
|
108
|
+
valueFlag("display-name", "<name>", "profiles add: human-readable label for the new credential profile"),
|
|
108
109
|
valueFlag("from-env", "<VAR>", null),
|
|
109
110
|
booleanFlag("allow-full-access", null),
|
|
110
111
|
booleanFlag("revoke-full-access", null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-flags.js","sourceRoot":"","sources":["../src/command-flags.ts"],"names":[],"mappings":"AAeA,mFAAmF;AACnF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,SAAS;IACT,iBAAiB;IACjB,GAAG;IACH,UAAU;IACV,aAAa;IACb,QAAQ;IACR,UAAU;IACV,SAAS;IACT,WAAW;IACX,MAAM;IACN,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F,WAAW,CACT,OAAO,EACP,+EAA+E,CAChF;IACD,SAAS,CACP,cAAc,EACd,QAAQ,EACR,mEAAmE,CACpE;IACD,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC;IACpC,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC;IACtC,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC;IACvC,SAAS,CAAC,gBAAgB,EAAE,WAAW,EAAE,IAAI,CAAC;IAC9C,SAAS,CAAC,YAAY,EAAE,eAAe,EAAE,IAAI,CAAC;IAC9C,SAAS,CAAC,aAAa,EAAE,iBAAiB,EAAE,IAAI,CAAC;IACjD,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC;IAChC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC;IAC7B,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC;IAC3B,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC;IACvC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC;IAC1B,SAAS,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC;IACpC,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC;IACvC,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC;IACrC,WAAW,CAAC,SAAS,EAAE,uBAAuB,CAAC;CAChD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scoped-command help (QA-057): `claudexor <cmd> --help` resolves the command
|
|
3
|
+
* FIRST and prints that command's own usage from the registry — never the whole
|
|
4
|
+
* global help — and a typo'd verb with `--help` is a usage error (exit 2), not a
|
|
5
|
+
* silent exit-0 global-help print. Lives beside the registry (its one source of
|
|
6
|
+
* truth) but off the registry's ratcheted line budget.
|
|
7
|
+
*/
|
|
8
|
+
import { type CliCommandSpec, type CliFlagKind, type CliMutability } from "./command-registry.js";
|
|
9
|
+
/** Resolve a command spec by id or alias (the one owner of verb resolution). */
|
|
10
|
+
export declare function findCommand(commandId: string): CliCommandSpec | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Scoped `claudexor <cmd> --help` text: the command's own usage line, its
|
|
13
|
+
* declared flags (always including the global affordances), and any extra usage
|
|
14
|
+
* lines — never the whole global help. Generated from the registry.
|
|
15
|
+
*/
|
|
16
|
+
export declare function renderCommandHelp(cmd: CliCommandSpec): string;
|
|
17
|
+
export interface CommandHelpJson {
|
|
18
|
+
readonly ok: true;
|
|
19
|
+
readonly version: string;
|
|
20
|
+
readonly command: {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly aliases: readonly string[];
|
|
23
|
+
readonly usage: string;
|
|
24
|
+
readonly summary: string;
|
|
25
|
+
readonly flags: readonly string[];
|
|
26
|
+
readonly mutability: CliMutability;
|
|
27
|
+
readonly stability: "stable" | "experimental";
|
|
28
|
+
readonly recovery: boolean;
|
|
29
|
+
};
|
|
30
|
+
readonly flags: readonly {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly kind: CliFlagKind;
|
|
33
|
+
readonly value_hint: string | null;
|
|
34
|
+
readonly description: string | null;
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
/** Machine-readable scoped help (`claudexor <cmd> --help --json`). */
|
|
38
|
+
export declare function commandHelpJson(version: string, cmd: CliCommandSpec): CommandHelpJson;
|
|
39
|
+
/**
|
|
40
|
+
* Handle a `--help` request that has already been detected. A bare or `help`
|
|
41
|
+
* verb prints the global help; a known verb prints its scoped help; a typo'd
|
|
42
|
+
* verb throws a usage error (the projector renders it, exit 2). Returns the
|
|
43
|
+
* success exit code (0) after printing.
|
|
44
|
+
*/
|
|
45
|
+
export declare function handleHelpRequest(commandId: string, positionalCount: number, json: boolean, version: string): number;
|
|
46
|
+
//# sourceMappingURL=command-help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-help.d.ts","sourceRoot":"","sources":["../src/command-help.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH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,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,MAAM,CAaR"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scoped-command help (QA-057): `claudexor <cmd> --help` resolves the command
|
|
3
|
+
* FIRST and prints that command's own usage from the registry — never the whole
|
|
4
|
+
* global help — and a typo'd verb with `--help` is a usage error (exit 2), not a
|
|
5
|
+
* silent exit-0 global-help print. Lives beside the registry (its one source of
|
|
6
|
+
* truth) but off the registry's ratcheted line budget.
|
|
7
|
+
*/
|
|
8
|
+
import { CLI_COMMANDS, CLI_FLAGS, helpJson, padded, renderHelp, usageLabel, } from "./command-registry.js";
|
|
9
|
+
import { printJson } from "./cli-io.js";
|
|
10
|
+
import { usageError } from "./cli-error.js";
|
|
11
|
+
/** Resolve a command spec by id or alias (the one owner of verb resolution). */
|
|
12
|
+
export function findCommand(commandId) {
|
|
13
|
+
return CLI_COMMANDS.find((c) => c.id === commandId || (c.aliases ?? []).includes(commandId));
|
|
14
|
+
}
|
|
15
|
+
/** The flags a command exposes plus the always-available global affordances. */
|
|
16
|
+
function scopedFlagSpecs(cmd) {
|
|
17
|
+
const names = [...new Set([...cmd.flags, "json", "help"])];
|
|
18
|
+
return names
|
|
19
|
+
.map((name) => CLI_FLAGS.find((f) => f.name === name))
|
|
20
|
+
.filter((f) => f !== undefined);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Scoped `claudexor <cmd> --help` text: the command's own usage line, its
|
|
24
|
+
* declared flags (always including the global affordances), and any extra usage
|
|
25
|
+
* lines — never the whole global help. Generated from the registry.
|
|
26
|
+
*/
|
|
27
|
+
export function renderCommandHelp(cmd) {
|
|
28
|
+
const lines = [];
|
|
29
|
+
lines.push(`Usage: ${usageLabel(cmd)}`);
|
|
30
|
+
lines.push(` ${cmd.summary}`);
|
|
31
|
+
for (const extra of cmd.extraUsageLines ?? []) {
|
|
32
|
+
lines.push(padded(` ${extra.text}`, extra.help));
|
|
33
|
+
}
|
|
34
|
+
const specs = scopedFlagSpecs(cmd).filter((f) => f.help !== null);
|
|
35
|
+
if (specs.length > 0) {
|
|
36
|
+
lines.push("");
|
|
37
|
+
lines.push("Flags:");
|
|
38
|
+
for (const flag of specs) {
|
|
39
|
+
const label = flag.kind === "value" ? `--${flag.name} ${flag.valueHint ?? "<value>"}` : `--${flag.name}`;
|
|
40
|
+
lines.push(padded(label, flag.help, 25));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return lines.join("\n") + "\n";
|
|
44
|
+
}
|
|
45
|
+
/** Machine-readable scoped help (`claudexor <cmd> --help --json`). */
|
|
46
|
+
export function commandHelpJson(version, cmd) {
|
|
47
|
+
return {
|
|
48
|
+
ok: true,
|
|
49
|
+
version,
|
|
50
|
+
command: {
|
|
51
|
+
id: cmd.id,
|
|
52
|
+
aliases: cmd.aliases ?? [],
|
|
53
|
+
usage: usageLabel(cmd),
|
|
54
|
+
summary: cmd.summary,
|
|
55
|
+
flags: cmd.flags,
|
|
56
|
+
mutability: cmd.mutability,
|
|
57
|
+
stability: cmd.stability,
|
|
58
|
+
recovery: cmd.recovery === true,
|
|
59
|
+
},
|
|
60
|
+
flags: scopedFlagSpecs(cmd).map((f) => ({
|
|
61
|
+
name: f.name,
|
|
62
|
+
kind: f.kind,
|
|
63
|
+
value_hint: f.valueHint ?? null,
|
|
64
|
+
description: f.help === null ? null : f.help.replace(/\n\s+/g, " "),
|
|
65
|
+
})),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Handle a `--help` request that has already been detected. A bare or `help`
|
|
70
|
+
* verb prints the global help; a known verb prints its scoped help; a typo'd
|
|
71
|
+
* verb throws a usage error (the projector renders it, exit 2). Returns the
|
|
72
|
+
* success exit code (0) after printing.
|
|
73
|
+
*/
|
|
74
|
+
export function handleHelpRequest(commandId, positionalCount, json, version) {
|
|
75
|
+
if (commandId === "help" || positionalCount === 0) {
|
|
76
|
+
if (json)
|
|
77
|
+
printJson(helpJson(version));
|
|
78
|
+
else
|
|
79
|
+
process.stdout.write(renderHelp(version));
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
const spec = findCommand(commandId);
|
|
83
|
+
if (!spec) {
|
|
84
|
+
throw usageError(`claudexor: unknown command '${commandId}' (see \`claudexor help\`)`);
|
|
85
|
+
}
|
|
86
|
+
if (json)
|
|
87
|
+
printJson(commandHelpJson(version, spec));
|
|
88
|
+
else
|
|
89
|
+
process.stdout.write(renderCommandHelp(spec));
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=command-help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-help.js","sourceRoot":"","sources":["../src/command-help.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,YAAY,EACZ,SAAS,EAKT,QAAQ,EACR,MAAM,EACN,UAAU,EACV,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,gFAAgF;AAChF,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAC/F,CAAC;AAED,gFAAgF;AAChF,SAAS,eAAe,CAAC,GAAmB;IAC1C,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,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AClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,UAAU,CAAC,+BAA+B,SAAS,4BAA4B,CAAC,CAAC;IACzF,CAAC;IACD,IAAI,IAAI;QAAE,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;;QAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -33,6 +33,8 @@ export declare function commandFlagScopeError(commandId: string, flagNames: read
|
|
|
33
33
|
export declare function hostFallbackExamples(): readonly string[];
|
|
34
34
|
/** Post-run recovery verbs (inspect/follow/apply/decision). */
|
|
35
35
|
export declare function recoveryVerbs(): readonly string[];
|
|
36
|
+
export declare function usageLabel(cmd: CliCommandSpec): string;
|
|
37
|
+
export declare function padded(left: string, help: string, column?: number): string;
|
|
36
38
|
/** The `claudexor help` text — generated, never hand-edited. */
|
|
37
39
|
export declare function renderHelp(version: string): string;
|
|
38
40
|
/** The REPL `/help` text — generated from REPL_COMMANDS. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-registry.d.ts","sourceRoot":"","sources":["../src/command-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEnF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,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