@claudexor/cli 3.3.11 → 3.3.13

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.
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Run-detail fetch wrappers + terminal projections, split from daemon-run.ts
3
+ * (complexity ratchet): everything here rides GET /runs/:id (or the run's
4
+ * terminal facts) and stays free of daemon lifecycle/enqueue concerns.
5
+ * Callers keep importing from daemon-run.js via its re-exports.
6
+ */
7
+ import { controlProblemError } from "./cli-error.js";
8
+ import { controlApiFetch, processExitCodeForRunStatus } from "./live.js";
9
+ import { outcomeExitCode } from "@claudexor/schema";
10
+ import { projectApplyEligibility, projectOutcomeBanner, } from "./run-detail-projections.js";
11
+ import { projectRunOutcomeFacts } from "./daemon-outcome.js";
12
+ import { readRunDetailResponse } from "./run-detail-response.js";
13
+ /** Daemon job state (= run lifecycle, D8) -> CLI exit code via the ONE
14
+ * projection owner: a succeeded lifecycle is 0 (a "Done · needs review" run
15
+ * included); everything else is 1. When the run's terminal outcome `facts` are
16
+ * available, the D-16 outcome-aware projection is used instead so a
17
+ * needs_input/incomplete work_state exits non-zero on a succeeded lifecycle. */
18
+ export function exitCodeForState(state, facts) {
19
+ if (facts)
20
+ return outcomeExitCode(facts);
21
+ return processExitCodeForRunStatus(state);
22
+ }
23
+ /** Server-derived plan readiness projection (mode=plan runs). */
24
+ export async function fetchPlanReadiness(addr, runId) {
25
+ if (!runId)
26
+ return null;
27
+ try {
28
+ const res = await controlApiFetch(addr, `/runs/${encodeURIComponent(runId)}`, {
29
+ headers: { authorization: `Bearer ${addr.token}` },
30
+ });
31
+ if (!res.ok)
32
+ return null;
33
+ const detail = (await res.json());
34
+ const v = detail["planReadiness"];
35
+ return v && typeof v === "object" ? v : null;
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ /** The plan run's open questions (D17), projected from GET /runs/:id — the
42
+ * SAME server artifact readiness derives from, never a client re-parse. Empty
43
+ * for ready/unverified plans and every non-plan run. */
44
+ export async function fetchPlanQuestions(addr, runId) {
45
+ if (!runId)
46
+ return [];
47
+ try {
48
+ const res = await controlApiFetch(addr, `/runs/${encodeURIComponent(runId)}`, {
49
+ headers: { authorization: `Bearer ${addr.token}` },
50
+ });
51
+ if (!res.ok)
52
+ return [];
53
+ const detail = (await res.json());
54
+ const v = detail["planQuestions"];
55
+ return Array.isArray(v) ? v : [];
56
+ }
57
+ catch {
58
+ return [];
59
+ }
60
+ }
61
+ /** Council membership + merge disclosure (INV-031) for a --council plan run;
62
+ * null for solo plans and non-plan runs. Server-projected — the CLI never
63
+ * re-derives membership. */
64
+ export async function fetchCouncil(addr, runId) {
65
+ if (!runId)
66
+ return null;
67
+ try {
68
+ const res = await controlApiFetch(addr, `/runs/${encodeURIComponent(runId)}`, {
69
+ headers: { authorization: `Bearer ${addr.token}` },
70
+ });
71
+ if (!res.ok)
72
+ return null;
73
+ const detail = (await res.json());
74
+ const v = detail["council"];
75
+ return v && typeof v === "object"
76
+ ? v
77
+ : null;
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ }
83
+ /**
84
+ * ONE GET /runs/:id for the terminal path (INV-120/122): fetch the run detail
85
+ * once and feed every pure projection below. Three-state semantics:
86
+ * a MISSING detail (404 / legacy run) and a transport-UNAVAILABLE detail both
87
+ * soft-fail to null (a hiccup must never eat a finished run's result), while a
88
+ * typed problem response — especially 500 run_facts_invalid, the server's
89
+ * verdict that the run's canonical receipt cannot be trusted — raises through
90
+ * the typed CLI failure path (controlProblemError -> renderCliFailure,
91
+ * non-zero exit) instead of masquerading as a legacy run. The per-projection
92
+ * `fetch*` wrappers stay for callers that need exactly one projection.
93
+ */
94
+ export async function fetchRunDetail(addr, runId) {
95
+ if (!runId)
96
+ return null;
97
+ let res;
98
+ try {
99
+ res = await controlApiFetch(addr, `/runs/${encodeURIComponent(runId)}`, {
100
+ headers: { authorization: `Bearer ${addr.token}` },
101
+ });
102
+ }
103
+ catch {
104
+ return null;
105
+ }
106
+ if (res.status === 404)
107
+ return null;
108
+ if (!res.ok) {
109
+ const body = await res.json().catch(() => ({}));
110
+ throw controlProblemError(res.status, body, `run detail failed (HTTP ${res.status})`);
111
+ }
112
+ return readRunDetailResponse(res);
113
+ }
114
+ export async function fetchApplyEligibility(addr, runId) {
115
+ return projectApplyEligibility(await fetchRunDetail(addr, runId));
116
+ }
117
+ /**
118
+ * The run's terminal outcome facts through fetchRunDetail's THREE-state
119
+ * semantics (INV-120/122): missing/legacy detail and transport loss project
120
+ * null (the lifecycle-only exit stands), while a typed problem response — the
121
+ * server's verdict that the terminal cannot be trusted (500 run_facts_invalid)
122
+ * — raises into the CLI failure path instead of silently exiting as if the
123
+ * facts never existed. Makes the direct-run CLI exit outcome-aware for a
124
+ * work_state veto (callers that need only this one projection).
125
+ */
126
+ export async function fetchRunOutcomeFacts(addr, runId) {
127
+ return projectRunOutcomeFacts(await fetchRunDetail(addr, runId));
128
+ }
129
+ /**
130
+ * The server-owned outcome banner for a run (D18): the single honest headline,
131
+ * derived by the control-plane projection owner. The CLI PRINTS it verbatim —
132
+ * it never re-derives a headline of its own, so model prose can never outrank
133
+ * the arbitrated truth. Null while the run is not terminal or unavailable.
134
+ */
135
+ export async function fetchOutcomeBanner(addr, runId) {
136
+ return projectOutcomeBanner(await fetchRunDetail(addr, runId));
137
+ }
138
+ /**
139
+ * Machine-readable reason for a non-clean DAEMON terminal (P2, D8). A
140
+ * needs-decision run (review blocked / checks failed) has a SUCCEEDED lifecycle
141
+ * and no `error`, so key the actionable decision hint on the run FACTS, not on
142
+ * the lifecycle; other non-succeeded lifecycles use the error or a reason
143
+ * label. A clean succeeded run returns undefined (no `summary` key emitted).
144
+ */
145
+ export function daemonOutcomeSummary(out) {
146
+ const facts = out.outcomeFacts ?? null;
147
+ const needsDecision = !!facts &&
148
+ facts.lifecycle === "succeeded" &&
149
+ (facts.review === "blocked" || facts.checks === "failed");
150
+ if (needsDecision) {
151
+ return `run needs a human decision — claudexor decision ${out.runId} --accept-risk | --rerun --feedback "..."`;
152
+ }
153
+ if (out.error)
154
+ return out.error;
155
+ if (exitCodeForState(out.status, facts) === 0)
156
+ return undefined;
157
+ return `run ${out.status}${facts?.reason ? ` (${facts.reason})` : ""}`;
158
+ }
159
+ //# sourceMappingURL=run-detail-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-detail-fetch.js","sourceRoot":"","sources":["../src/run-detail-fetch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAA0B,MAAM,WAAW,CAAC;AACjG,OAAO,EAAwB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;gFAIgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,KAA8B;IAC5E,IAAI,KAAK;QAAE,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED,iEAAiE;AACjE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAuB,EACvB,KAAa;IAEb,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,SAAS,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE;YAC5E,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE,EAAE;SACnD,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QACzB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AC,EAAE,EAAE,CAAC;AACzE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudexor/cli",
3
- "version": "3.3.11",
3
+ "version": "3.3.13",
4
4
  "license": "MIT",
5
5
  "description": "Claudexor CLI (claudexor). Thin surface over the orchestrator.",
6
6
  "type": "module",
@@ -10,28 +10,28 @@
10
10
  "dist"
11
11
  ],
12
12
  "dependencies": {
13
- "@claudexor/artifact-store": "3.3.11",
14
- "@claudexor/config": "3.3.11",
15
- "@claudexor/core": "3.3.11",
16
- "@claudexor/control-api": "3.3.11",
17
- "@claudexor/delivery": "3.3.11",
18
- "@claudexor/acp-server": "3.3.11",
19
- "@claudexor/gateway": "3.3.11",
20
- "@claudexor/journal": "3.3.11",
21
- "@claudexor/daemon": "3.3.11",
22
- "@claudexor/mcp-server": "3.3.11",
23
- "@claudexor/harness-claude": "3.3.11",
24
- "@claudexor/orchestrator": "3.3.11",
25
- "@claudexor/review": "3.3.11",
26
- "@claudexor/harness-codex": "3.3.11",
27
- "@claudexor/harness-cursor": "3.3.11",
28
- "@claudexor/harness-opencode": "3.3.11",
29
- "@claudexor/harness-raw-api": "3.3.11",
30
- "@claudexor/harness-fake": "3.3.11",
31
- "@claudexor/schema": "3.3.11",
32
- "@claudexor/util": "3.3.11",
33
- "@claudexor/secrets": "3.3.11",
34
- "@claudexor/workspace": "3.3.11"
13
+ "@claudexor/artifact-store": "3.3.13",
14
+ "@claudexor/config": "3.3.13",
15
+ "@claudexor/acp-server": "3.3.13",
16
+ "@claudexor/control-api": "3.3.13",
17
+ "@claudexor/core": "3.3.13",
18
+ "@claudexor/delivery": "3.3.13",
19
+ "@claudexor/daemon": "3.3.13",
20
+ "@claudexor/mcp-server": "3.3.13",
21
+ "@claudexor/gateway": "3.3.13",
22
+ "@claudexor/journal": "3.3.13",
23
+ "@claudexor/orchestrator": "3.3.13",
24
+ "@claudexor/review": "3.3.13",
25
+ "@claudexor/harness-claude": "3.3.13",
26
+ "@claudexor/harness-cursor": "3.3.13",
27
+ "@claudexor/harness-codex": "3.3.13",
28
+ "@claudexor/harness-fake": "3.3.13",
29
+ "@claudexor/harness-opencode": "3.3.13",
30
+ "@claudexor/harness-raw-api": "3.3.13",
31
+ "@claudexor/schema": "3.3.13",
32
+ "@claudexor/secrets": "3.3.13",
33
+ "@claudexor/workspace": "3.3.13",
34
+ "@claudexor/util": "3.3.13"
35
35
  },
36
36
  "repository": {
37
37
  "type": "git",