@claudexor/control-api 3.1.1 → 3.1.2
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/budget-valuation.d.ts +23 -0
- package/dist/budget-valuation.d.ts.map +1 -0
- package/dist/budget-valuation.js +90 -0
- package/dist/budget-valuation.js.map +1 -0
- package/dist/daemon-server.d.ts +5 -62
- package/dist/daemon-server.d.ts.map +1 -1
- package/dist/daemon-server.js +61 -59
- package/dist/daemon-server.js.map +1 -1
- package/dist/decision-rerun.d.ts.map +1 -1
- package/dist/decision-rerun.js +8 -1
- package/dist/decision-rerun.js.map +1 -1
- package/dist/delegation-control.d.ts +23 -0
- package/dist/delegation-control.d.ts.map +1 -0
- package/dist/delegation-control.js +81 -0
- package/dist/delegation-control.js.map +1 -0
- package/dist/run-record.d.ts +49 -0
- package/dist/run-record.d.ts.map +1 -0
- package/dist/run-record.js +61 -0
- package/dist/run-record.js.map +1 -0
- package/dist/run-retry-routes.js +26 -1
- package/dist/run-retry-routes.js.map +1 -1
- package/dist/run-start.d.ts.map +1 -1
- package/dist/run-start.js +5 -0
- package/dist/run-start.js.map +1 -1
- package/dist/run-timeline.d.ts.map +1 -1
- package/dist/run-timeline.js +1 -0
- package/dist/run-timeline.js.map +1 -1
- package/dist/thread-projection.d.ts +6 -1
- package/dist/thread-projection.d.ts.map +1 -1
- package/dist/thread-projection.js +19 -1
- package/dist/thread-projection.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure subscription-VALUATION fold over a run's events (QA-023c/QA-017b),
|
|
3
|
+
* independent of the cash truth. The owner-locked ledger settles native-
|
|
4
|
+
* subscription work to cash $0 while accumulating its token valuation on
|
|
5
|
+
* `budget.cash.valuation_usd` (last-wins, cumulative). An UNKNOWN valuation (no
|
|
6
|
+
* usage ever reported — e.g. a Cursor draft) stays NULL and is never coerced to
|
|
7
|
+
* a fake $0. The legacy fallback for runs predating budget.cash is the summed
|
|
8
|
+
* `budget.observation` spend.
|
|
9
|
+
*/
|
|
10
|
+
export declare function budgetValuationFromEvents(events: Record<string, unknown>[]): {
|
|
11
|
+
valuationUsd: number | null;
|
|
12
|
+
valuationKnowledge: "exact" | "estimated" | "unknown";
|
|
13
|
+
};
|
|
14
|
+
export declare function normalizeLegacyBudgetComponents(budget: {
|
|
15
|
+
estimated?: boolean;
|
|
16
|
+
spend_usd?: number | null;
|
|
17
|
+
valuation_usd?: number | null;
|
|
18
|
+
valuation_knowledge?: "exact" | "estimated" | "unknown";
|
|
19
|
+
} | null, events: Record<string, unknown>[], folded: ReturnType<typeof budgetValuationFromEvents>): typeof folded & {
|
|
20
|
+
cashEstimated: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare function cashEstimatedFromLedgerEvent(payload: Record<string, unknown>): boolean;
|
|
23
|
+
//# sourceMappingURL=budget-valuation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-valuation.d.ts","sourceRoot":"","sources":["../src/budget-valuation.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAC5E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kBAAkB,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;CACvD,CAuCA;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE;IACN,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;CACzD,GAAG,IAAI,EACR,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACjC,MAAM,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,GACnD,OAAO,MAAM,GAAG;IAAE,aAAa,EAAE,OAAO,CAAA;CAAE,CA4B5C;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAStF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { eventPayload } from "./run-timeline.js";
|
|
2
|
+
/**
|
|
3
|
+
* Pure subscription-VALUATION fold over a run's events (QA-023c/QA-017b),
|
|
4
|
+
* independent of the cash truth. The owner-locked ledger settles native-
|
|
5
|
+
* subscription work to cash $0 while accumulating its token valuation on
|
|
6
|
+
* `budget.cash.valuation_usd` (last-wins, cumulative). An UNKNOWN valuation (no
|
|
7
|
+
* usage ever reported — e.g. a Cursor draft) stays NULL and is never coerced to
|
|
8
|
+
* a fake $0. The legacy fallback for runs predating budget.cash is the summed
|
|
9
|
+
* `budget.observation` spend.
|
|
10
|
+
*/
|
|
11
|
+
export function budgetValuationFromEvents(events) {
|
|
12
|
+
let valuationUsd = null;
|
|
13
|
+
let valuationKnowledge = "unknown";
|
|
14
|
+
let sawLedgerValuation = false;
|
|
15
|
+
let observation = 0;
|
|
16
|
+
let sawObservation = false;
|
|
17
|
+
for (const ev of events) {
|
|
18
|
+
const payload = eventPayload(ev);
|
|
19
|
+
if (ev["type"] === "budget.cash") {
|
|
20
|
+
const val = payload["valuation_usd"];
|
|
21
|
+
if (typeof val === "number" && Number.isFinite(val)) {
|
|
22
|
+
sawLedgerValuation = true;
|
|
23
|
+
const knowledge = payload["valuation_knowledge"];
|
|
24
|
+
if (knowledge === "exact" || knowledge === "estimated" || knowledge === "unknown") {
|
|
25
|
+
valuationKnowledge = knowledge;
|
|
26
|
+
valuationUsd = knowledge === "unknown" ? null : val;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Legacy budget.cash had no valuation-specific knowledge. A positive
|
|
30
|
+
// token valuation is safely estimated; zero alone cannot prove that
|
|
31
|
+
// valuation evidence existed.
|
|
32
|
+
valuationKnowledge = val > 0 ? "estimated" : "unknown";
|
|
33
|
+
valuationUsd = val > 0 ? val : null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (ev["type"] === "budget.observation" && payload["kind"] === "spend") {
|
|
39
|
+
const usd = payload["usd"];
|
|
40
|
+
if (typeof usd === "number" && Number.isFinite(usd)) {
|
|
41
|
+
observation += usd;
|
|
42
|
+
sawObservation = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!sawLedgerValuation && sawObservation) {
|
|
47
|
+
valuationUsd = observation;
|
|
48
|
+
valuationKnowledge = "estimated";
|
|
49
|
+
}
|
|
50
|
+
return { valuationUsd, valuationKnowledge };
|
|
51
|
+
}
|
|
52
|
+
export function normalizeLegacyBudgetComponents(budget, events, folded) {
|
|
53
|
+
let cashEstimated = budget?.estimated ?? false;
|
|
54
|
+
let { valuationUsd, valuationKnowledge } = folded;
|
|
55
|
+
const knowledge = budget?.valuation_knowledge;
|
|
56
|
+
const valuation = budget?.valuation_usd;
|
|
57
|
+
const componentAwareEvent = events.some((event) => {
|
|
58
|
+
if (event["type"] !== "budget.cash")
|
|
59
|
+
return false;
|
|
60
|
+
const value = eventPayload(event)["valuation_knowledge"];
|
|
61
|
+
return value === "exact" || value === "estimated" || value === "unknown";
|
|
62
|
+
});
|
|
63
|
+
if (knowledge && typeof valuation === "number" && Number.isFinite(valuation)) {
|
|
64
|
+
valuationKnowledge = knowledge;
|
|
65
|
+
valuationUsd = knowledge === "unknown" ? null : valuation;
|
|
66
|
+
}
|
|
67
|
+
else if (valuationUsd === null && typeof valuation === "number" && valuation > 0) {
|
|
68
|
+
valuationUsd = valuation;
|
|
69
|
+
valuationKnowledge = "estimated";
|
|
70
|
+
}
|
|
71
|
+
if (knowledge === undefined &&
|
|
72
|
+
!componentAwareEvent &&
|
|
73
|
+
cashEstimated &&
|
|
74
|
+
budget?.spend_usd === 0 &&
|
|
75
|
+
typeof valuation === "number" &&
|
|
76
|
+
valuation > 0) {
|
|
77
|
+
cashEstimated = false;
|
|
78
|
+
}
|
|
79
|
+
return { valuationUsd, valuationKnowledge, cashEstimated };
|
|
80
|
+
}
|
|
81
|
+
export function cashEstimatedFromLedgerEvent(payload) {
|
|
82
|
+
const estimated = payload["estimated"] === true;
|
|
83
|
+
const legacyExactZero = payload["valuation_knowledge"] === undefined &&
|
|
84
|
+
estimated &&
|
|
85
|
+
payload["cash_spend_usd"] === 0 &&
|
|
86
|
+
typeof payload["valuation_usd"] === "number" &&
|
|
87
|
+
payload["valuation_usd"] > 0;
|
|
88
|
+
return estimated && !legacyExactZero;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=budget-valuation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-valuation.js","sourceRoot":"","sources":["../src/budget-valuation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAiC;IAIzE,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,kBAAkB,GAAsC,SAAS,CAAC;IACtE,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;QACjC,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,aAAa,EAAE,CAAC;YACjC,MAAM,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;YACrC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CA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AC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAAgC;IAC3E,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAChD,MAAM,eAAe,GACnB,OAAO,CAAC,qBAAqB,CAAC,KAAK,SAAS;QAC5C,SAAS;QACT,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC;QAC/B,OAAO,OAAO,CAAC,eAAe,CAAC,KAAK,QAAQ;QAC5C,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,SAAS,IAAI,CAAC,eAAe,CAAC;AACvC,CAAC"}
|
package/dist/daemon-server.d.ts
CHANGED
|
@@ -1,58 +1,11 @@
|
|
|
1
1
|
import { verifyAndDeliver } from "@claudexor/delivery";
|
|
2
|
+
import { type ControlOperatorDecisionRecord, type DaemonFacadeClient } from "./run-record.js";
|
|
3
|
+
export { type ControlOperatorDecisionRecord, type DaemonFacadeClient, type DaemonRunRecord, } from "./run-record.js";
|
|
2
4
|
import { type DeliveryCommandServices } from "./run-apply-routes.js";
|
|
3
5
|
export { normalizeRunStartRequest } from "./run-start.js";
|
|
4
6
|
import { type MaintenanceRouteServices } from "./maintenance-routes.js";
|
|
5
7
|
import { type ResourceRouteServices } from "./resource-routes.js";
|
|
6
8
|
import { ControlAuthReadinessRefreshRequest, ResourceAttachmentRef, ControlSetupJobCreateRequest, type ControlRunStartRequest, ControlTrustUpdateRequest, type ControlPendingInteraction } from "@claudexor/schema";
|
|
7
|
-
export interface DaemonRunRecord {
|
|
8
|
-
id: string;
|
|
9
|
-
state: string;
|
|
10
|
-
runId?: string;
|
|
11
|
-
taskId?: string;
|
|
12
|
-
runDir?: string;
|
|
13
|
-
error?: string;
|
|
14
|
-
/** Machine-readable code of a typed pre-start refusal (e.g. the trust gate's
|
|
15
|
-
* trust_full_access_required) — surfaces key remedies on the CODE and the
|
|
16
|
-
* turn-turn route maps it to a client-actionable 4xx (W24). */
|
|
17
|
-
errorCode?: string;
|
|
18
|
-
/** HTTP status persisted from the typed throw (refusal semantics are born
|
|
19
|
-
* at the throw); the turn route serves it verbatim when 400-599. */
|
|
20
|
-
errorStatus?: number;
|
|
21
|
-
/** Retryability persisted from the typed throw. `false` marks a pre-start
|
|
22
|
-
* refusal that Exact Retry can never repair (plan_not_ready — the frozen
|
|
23
|
-
* planRef replays the same open questions, INV-081); absent = no claim. */
|
|
24
|
-
errorRetryable?: boolean;
|
|
25
|
-
params?: unknown;
|
|
26
|
-
createdAt?: string;
|
|
27
|
-
startedAt?: string;
|
|
28
|
-
finishedAt?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface ControlOperatorDecisionRecord {
|
|
31
|
-
action: "accept_risk" | "override_needs_human";
|
|
32
|
-
findingIds: string[];
|
|
33
|
-
acceptedRisks: string[];
|
|
34
|
-
patchSha256: string;
|
|
35
|
-
decidedAt: string;
|
|
36
|
-
}
|
|
37
|
-
export interface DaemonFacadeClient {
|
|
38
|
-
enqueue(params: unknown, options?: {
|
|
39
|
-
idempotencyKey?: string;
|
|
40
|
-
clientId?: string;
|
|
41
|
-
idempotencyRequest?: unknown;
|
|
42
|
-
operation?: string;
|
|
43
|
-
}): Promise<{
|
|
44
|
-
id: string;
|
|
45
|
-
state: string;
|
|
46
|
-
}>;
|
|
47
|
-
findAccepted?(params: unknown, options: {
|
|
48
|
-
idempotencyKey: string;
|
|
49
|
-
clientId?: string;
|
|
50
|
-
operation?: string;
|
|
51
|
-
}): Promise<DaemonRunRecord | null>;
|
|
52
|
-
status(id: string): Promise<DaemonRunRecord>;
|
|
53
|
-
list(): Promise<DaemonRunRecord[]>;
|
|
54
|
-
cancel(id: string): Promise<unknown>;
|
|
55
|
-
}
|
|
56
9
|
export interface DaemonControlApiOptions {
|
|
57
10
|
token: string;
|
|
58
11
|
daemon: DaemonFacadeClient;
|
|
@@ -214,6 +167,9 @@ export declare class DaemonControlApiServer {
|
|
|
214
167
|
private waitForRunStart;
|
|
215
168
|
private respondToAcceptedJob;
|
|
216
169
|
private findRun;
|
|
170
|
+
/** Persisted Delegate-only descendant graph. `parentRunId` alone is broader
|
|
171
|
+
* thread/retry lineage and deliberately does not participate. */
|
|
172
|
+
private delegatedDescendants;
|
|
217
173
|
/**
|
|
218
174
|
* GET /v2/runs (QA-052): a bounded, newest-first, keyset-paginated page of run
|
|
219
175
|
* summaries. Ordering, filtering, and slicing all happen on the raw daemon
|
|
@@ -297,17 +253,4 @@ export declare class DaemonControlApiServer {
|
|
|
297
253
|
}
|
|
298
254
|
export declare function runListFingerprintProbeCountForTests(): number;
|
|
299
255
|
export declare function resetRunListFingerprintProbeCountForTests(): void;
|
|
300
|
-
/**
|
|
301
|
-
* Pure subscription-VALUATION fold over a run's events (QA-023c/QA-017b),
|
|
302
|
-
* independent of the cash truth. The owner-locked ledger settles native-
|
|
303
|
-
* subscription work to cash $0 while accumulating its token valuation on
|
|
304
|
-
* `budget.cash.valuation_usd` (last-wins, cumulative). An UNKNOWN valuation (no
|
|
305
|
-
* usage ever reported — e.g. a Cursor draft) stays NULL and is never coerced to
|
|
306
|
-
* a fake $0. The legacy fallback for runs predating budget.cash is the summed
|
|
307
|
-
* `budget.observation` spend. Vendor token valuation is at best an estimate.
|
|
308
|
-
*/
|
|
309
|
-
export declare function budgetValuationFromEvents(events: Record<string, unknown>[]): {
|
|
310
|
-
valuationUsd: number | null;
|
|
311
|
-
valuationKnowledge: "exact" | "estimated" | "unknown";
|
|
312
|
-
};
|
|
313
256
|
//# sourceMappingURL=daemon-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-server.d.ts","sourceRoot":"","sources":["../src/daemon-server.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"daemon-server.d.ts","sourceRoot":"","sources":["../src/daemon-server.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAo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,CAAC,iBAAiB,CAAS;IAElD,OAAO,CAAC,kBAAkB;IAiB1B;yEACqE;IACrE,wBAAwB,IAAI,MAAM;IAIlC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAyBhC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,WAAW;YAgBL,YAAY;IAoB1B,OAAO,CAAC,sBAAsB;CAO/B;AA6ED,wBAAgB,oCAAoC,IAAI,MAAM,CAE7D;AACD,wBAAgB,yCAAyC,IAAI,IAAI,CAEhE"}
|
package/dist/daemon-server.js
CHANGED
|
@@ -8,12 +8,16 @@ import { safeArtifactPath, safeArtifactRoot } from "./artifact-paths.js";
|
|
|
8
8
|
import { TERMINAL_STATES } from "./sse-shared.js";
|
|
9
9
|
import { streamRunEvents } from "./run-events-stream.js";
|
|
10
10
|
import { boundedArtifactText, outputReadyState, primaryOutput } from "./primary-output.js";
|
|
11
|
+
import { budgetValuationFromEvents, cashEstimatedFromLedgerEvent, normalizeLegacyBudgetComponents, } from "./budget-valuation.js";
|
|
11
12
|
import { controlWebEvidence, eventPayload, evidenceLevel, latestPlanProgress, readRunEvents, readRunEventsWithIntegrity, timelineEvents, } from "./run-timeline.js";
|
|
12
|
-
import {
|
|
13
|
+
import { projectTurnRunCards } from "./thread-projection.js";
|
|
14
|
+
import { projectSession, projectThread, projectTurn } from "./thread-projection.js";
|
|
13
15
|
import { chainThreadMutation, handleThreadTurnCreate, handleThreadTurnRetry, } from "./thread-turn-routes.js";
|
|
14
16
|
import { assertThreadIdle, threadIdOfRun } from "./thread-mutation.js";
|
|
15
17
|
import { handleThreadLifecycleRoutes, } from "./thread-lifecycle-routes.js";
|
|
16
18
|
import * as runStart from "./run-start.js";
|
|
19
|
+
import { cancelDelegationFamily } from "./delegation-control.js";
|
|
20
|
+
import { directDelegatedChildrenFromRecords, delegatedDescendantsFromRecords, paramsRecord, } from "./run-record.js";
|
|
17
21
|
import { handleRunRetryRoute } from "./run-retry-routes.js";
|
|
18
22
|
import { handleRunApplyRoutes, runIdempotentDelivery, } from "./run-apply-routes.js";
|
|
19
23
|
import { rerunWithFeedback } from "./decision-rerun.js";
|
|
@@ -30,7 +34,7 @@ import { assertOnlyQueryParams, optionalBooleanQuery, singleQuery } from "./quer
|
|
|
30
34
|
import { lruGet, lruSet, parseRunListQuery, selectRunListPage, } from "./run-list.js";
|
|
31
35
|
import { controlProblemError, normalizeRequestValidationError, revertRefusedProblem, thrownProblemCode, } from "./problem-response.js";
|
|
32
36
|
import { handleSecurityRoute } from "./security-routes.js";
|
|
33
|
-
import { PlanQuestionsArtifact, CouncilProjection, derivePlanReadiness, ControlAuthReadinessRefreshRequest, ControlAuthReadinessRefreshResponse, ControlProblem, AccessProfile, AgentCapabilityCatalog, ControlHarnessListResponse, ControlHarnessModelsResponse, ControlSetupJob, ControlSetupJobCreateRequest, ControlSetupJobEvent, ControlSetupJobSnapshot, isTerminalControlSetupJobState, ControlSetupJobListFilter, ControlSetupJobListResponse, ControlRunStartInfo, ControlRunControlRequest, ControlRunControlResponse, ControlReviewerPanelEntry, ControlRunDetail, ControlRunListResponse, ControlRunSummary, ControlRunResult, ControlBudgetSnapshot, PaidBudget, ControlSettingsSnapshot, ControlSettingsUpdateRequest, ControlQuotaResponse, ControlCredentialProfilesResponse, ControlCredentialProfileCreateRequest, ControlCredentialProfileCreateResponse, ControlCredentialProfileUpdateRequest, ControlCredentialProfileUpdateResponse, ControlCredentialProfileDeleteResponse, ControlInteractionAnswerRequest, ControlInteractionAnswerResponse, ControlRunDecisionRequest, ControlRunDecisionResponse, ControlThreadCreateRequest, ControlThreadTurnRequest, ControlThreadUpdateRequest, ControlThreadDetail, ControlThreadListResponse, DecisionRecord, ModeKind, RoutingGoal, ReviewFinding, RunDeliveryState, RunFailure, RunTelemetry, StructuredOutputConformance, TaskContract, ProtectedPathApproval, isTerminalLifecycle, needsDecision, needsOperatorAttention, requiredActionsFor, outcomeBanner, outcomeFactsFromFailure, TestCommandInvocation, WorkProduct, } from "@claudexor/schema";
|
|
37
|
+
import { PlanQuestionsArtifact, CouncilProjection, derivePlanReadiness, ControlAuthReadinessRefreshRequest, ControlAuthReadinessRefreshResponse, ControlProblem, AccessProfile, AgentCapabilityCatalog, ControlHarnessListResponse, ControlHarnessModelsResponse, ControlSetupJob, ControlSetupJobCreateRequest, ControlSetupJobEvent, ControlSetupJobSnapshot, isTerminalControlSetupJobState, ControlSetupJobListFilter, ControlSetupJobListResponse, ControlRunStartInfo, ControlRunControlRequest, ControlRunControlResponse, ControlReviewerPanelEntry, ControlRunDetail, ControlRunListResponse, ControlRunSummary, ControlRunResult, ControlBudgetSnapshot, PaidBudget, ControlSettingsSnapshot, ControlSettingsUpdateRequest, ControlQuotaResponse, ControlCredentialProfilesResponse, ControlCredentialProfileCreateRequest, ControlCredentialProfileCreateResponse, ControlCredentialProfileUpdateRequest, ControlCredentialProfileUpdateResponse, ControlCredentialProfileDeleteResponse, ControlInteractionAnswerRequest, ControlInteractionAnswerResponse, ControlRunDecisionRequest, ControlRunDecisionResponse, ControlThreadCreateRequest, ControlThreadTurnRequest, ControlThreadUpdateRequest, ControlThreadDetail, ControlThreadListResponse, DecisionRecord, Id, ModeKind, RoutingGoal, ReviewFinding, RunDeliveryState, RunFailure, RunTelemetry, StructuredOutputConformance, TaskContract, ProtectedPathApproval, isTerminalLifecycle, needsDecision, needsOperatorAttention, requiredActionsFor, outcomeBanner, outcomeFactsFromFailure, TestCommandInvocation, WorkProduct, } from "@claudexor/schema";
|
|
34
38
|
import { resolveControlProtocol } from "./operation-catalog.js";
|
|
35
39
|
import { assertNoInlineSecretValues, containsSecretLikeToken, errorCode, noProjectRepoRoot, nowIso, redactSecrets, sha256, } from "@claudexor/util";
|
|
36
40
|
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
@@ -423,7 +427,9 @@ export class DaemonControlApiServer {
|
|
|
423
427
|
// Fence order: cursor FIRST, every projection (pending interactions
|
|
424
428
|
// included) after it — see the detailFor doc comment.
|
|
425
429
|
const lastSeq = rec.runDir ? lastSeqInFile(join(rec.runDir, "events.jsonl")) : 0;
|
|
426
|
-
|
|
430
|
+
const parentRunId = rec.runId ?? rec.id;
|
|
431
|
+
const children = directDelegatedChildrenFromRecords(parentRunId, await this.opts.daemon.list()).map((candidate) => this.summarizeRunOrDiagnostic(candidate));
|
|
432
|
+
return this.json(res, 200, detailFor(rec, this.pendingInteractionsFor(rec), lastSeq, this.validOperatorDecisionFor(rec), children));
|
|
427
433
|
}
|
|
428
434
|
const interactionAnswerMatch = /^\/runs\/([^/]+)\/interactions\/([^/]+)\/answer$/.exec(path);
|
|
429
435
|
if (method === "POST" && interactionAnswerMatch) {
|
|
@@ -533,15 +539,7 @@ export class DaemonControlApiServer {
|
|
|
533
539
|
const runs = await this.opts.daemon.list();
|
|
534
540
|
const byRun = new Map(runs.map((r) => [r.runId ?? r.id, r]));
|
|
535
541
|
const thread = detail.thread;
|
|
536
|
-
const cards =
|
|
537
|
-
for (const turn of detail.turns) {
|
|
538
|
-
const runId = turn.run_id ?? null;
|
|
539
|
-
if (runId && !cards.has(runId)) {
|
|
540
|
-
const rec = byRun.get(runId);
|
|
541
|
-
if (rec)
|
|
542
|
-
cards.set(runId, turnRunCard(this.summarizeRunOrDiagnostic(rec)));
|
|
543
|
-
}
|
|
544
|
-
}
|
|
542
|
+
const cards = projectTurnRunCards(detail.turns, runs, (record) => this.summarizeRunOrDiagnostic(record));
|
|
545
543
|
const headRec = byRun.get(thread.head_run_id ?? "");
|
|
546
544
|
const headNeedsHuman = headRec ? this.runNeedsAttention(headRec) : false;
|
|
547
545
|
return this.json(res, 200, ControlThreadDetail.parse({
|
|
@@ -1040,13 +1038,30 @@ export class DaemonControlApiServer {
|
|
|
1040
1038
|
error: `run is ${rec.state}; ${body.control.kind} has nothing to stop`,
|
|
1041
1039
|
});
|
|
1042
1040
|
}
|
|
1043
|
-
|
|
1041
|
+
let activeDescendants;
|
|
1042
|
+
try {
|
|
1043
|
+
const cancelled = await cancelDelegationFamily({
|
|
1044
|
+
daemon: this.opts.daemon,
|
|
1045
|
+
parent: rec,
|
|
1046
|
+
descendantsAfterFence: () => this.delegatedDescendants(rec.runId ?? rec.id),
|
|
1047
|
+
pollMs: this.opts.pollMs,
|
|
1048
|
+
});
|
|
1049
|
+
activeDescendants = cancelled.descendants;
|
|
1050
|
+
}
|
|
1051
|
+
catch (error) {
|
|
1052
|
+
appendRunAuditEvent(rec, "control.rejected", {
|
|
1053
|
+
control: body.control,
|
|
1054
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
1055
|
+
});
|
|
1056
|
+
return this.requestError(res, error);
|
|
1057
|
+
}
|
|
1044
1058
|
appendRunAuditEvent(rec, "control.applied", { control: body.control });
|
|
1045
1059
|
return this.json(res, 200, ControlRunControlResponse.parse({
|
|
1046
1060
|
accepted: true,
|
|
1047
1061
|
status: "applied",
|
|
1048
1062
|
runId: rec.runId ?? rec.id,
|
|
1049
|
-
|
|
1063
|
+
cascadeRunIds: activeDescendants.map((child) => child.runId ?? child.id),
|
|
1064
|
+
message: `${body.control.kind} requested${activeDescendants.length ? ` for parent and ${activeDescendants.length} delegated descendant(s)` : ""}`,
|
|
1050
1065
|
}));
|
|
1051
1066
|
}
|
|
1052
1067
|
const eventsMatch = /^\/runs\/([^/]+)\/events$/.exec(path);
|
|
@@ -1298,6 +1313,11 @@ export class DaemonControlApiServer {
|
|
|
1298
1313
|
const runs = await this.opts.daemon.list();
|
|
1299
1314
|
return runs.find((r) => r.id === id || r.runId === id) ?? null;
|
|
1300
1315
|
}
|
|
1316
|
+
/** Persisted Delegate-only descendant graph. `parentRunId` alone is broader
|
|
1317
|
+
* thread/retry lineage and deliberately does not participate. */
|
|
1318
|
+
async delegatedDescendants(parentRunId) {
|
|
1319
|
+
return delegatedDescendantsFromRecords(parentRunId, await this.opts.daemon.list());
|
|
1320
|
+
}
|
|
1301
1321
|
/**
|
|
1302
1322
|
* GET /v2/runs (QA-052): a bounded, newest-first, keyset-paginated page of run
|
|
1303
1323
|
* summaries. Ordering, filtering, and slicing all happen on the raw daemon
|
|
@@ -1521,11 +1541,22 @@ export class DaemonControlApiServer {
|
|
|
1521
1541
|
return this.summarizeRunLive(rec);
|
|
1522
1542
|
}
|
|
1523
1543
|
catch (err) {
|
|
1544
|
+
const delegatedFromRunId = Id.safeParse(paramsRecord(rec)["delegatedFromRunId"]);
|
|
1545
|
+
let waitingOnUser = false;
|
|
1546
|
+
try {
|
|
1547
|
+
waitingOnUser = this.pendingInteractionsFor(rec).length > 0;
|
|
1548
|
+
}
|
|
1549
|
+
catch {
|
|
1550
|
+
// The diagnostic row remains fail-soft even when interaction state is
|
|
1551
|
+
// also corrupt; false is the only safe fallback without evidence.
|
|
1552
|
+
}
|
|
1524
1553
|
return ControlRunSummary.parse({
|
|
1525
1554
|
jobId: rec.id,
|
|
1526
1555
|
runId: rec.runId ?? rec.id,
|
|
1556
|
+
...(delegatedFromRunId.success ? { delegatedFromRunId: delegatedFromRunId.data } : {}),
|
|
1557
|
+
waitingOnUser,
|
|
1527
1558
|
state: "failed",
|
|
1528
|
-
error: `unprojectable job record: ${err instanceof Error ? err.message : String(err)}
|
|
1559
|
+
error: redactSecrets(`unprojectable job record: ${err instanceof Error ? err.message : String(err)}`),
|
|
1529
1560
|
});
|
|
1530
1561
|
}
|
|
1531
1562
|
}
|
|
@@ -1572,11 +1603,6 @@ export class DaemonControlApiServer {
|
|
|
1572
1603
|
}
|
|
1573
1604
|
}
|
|
1574
1605
|
/* ---- Thread projections (engine snake_case -> control camelCase) ---- */
|
|
1575
|
-
function paramsRecord(rec) {
|
|
1576
|
-
return rec.params && typeof rec.params === "object" && !Array.isArray(rec.params)
|
|
1577
|
-
? rec.params
|
|
1578
|
-
: {};
|
|
1579
|
-
}
|
|
1580
1606
|
function projectMetadata(rec) {
|
|
1581
1607
|
const p = paramsRecord(rec);
|
|
1582
1608
|
const scope = p["scope"];
|
|
@@ -1894,6 +1920,13 @@ function summarizeRun(rec, eventsSnapshot) {
|
|
|
1894
1920
|
return ControlRunSummary.parse({
|
|
1895
1921
|
jobId: rec.id,
|
|
1896
1922
|
runId: rec.runId ?? rec.id,
|
|
1923
|
+
parentRunId: (typeof p["parentRunId"] === "string" ? p["parentRunId"] : null) ??
|
|
1924
|
+
task?.run_lineage.parent_run_id ??
|
|
1925
|
+
null,
|
|
1926
|
+
delegatedFromRunId: (typeof p["delegatedFromRunId"] === "string" ? p["delegatedFromRunId"] : null) ??
|
|
1927
|
+
task?.run_lineage.delegated_from_run_id ??
|
|
1928
|
+
null,
|
|
1929
|
+
delegation: telemetry?.delegation ?? null,
|
|
1897
1930
|
taskId: rec.taskId,
|
|
1898
1931
|
state: rec.state,
|
|
1899
1932
|
runDir: rec.runDir,
|
|
@@ -1989,7 +2022,7 @@ function controlRoute(telemetry, p) {
|
|
|
1989
2022
|
verified: observed !== null,
|
|
1990
2023
|
};
|
|
1991
2024
|
}
|
|
1992
|
-
function detailFor(rec, pendingInteractions = [], cursor, operator = null) {
|
|
2025
|
+
function detailFor(rec, pendingInteractions = [], cursor, operator = null, children = []) {
|
|
1993
2026
|
// Snapshot fence: capture the event cursor BEFORE building any projection.
|
|
1994
2027
|
// The fence promise is "every event with seq <= lastSeq is reflected" — a
|
|
1995
2028
|
// cursor read AFTER the projections could skip an event that landed in
|
|
@@ -2017,6 +2050,7 @@ function detailFor(rec, pendingInteractions = [], cursor, operator = null) {
|
|
|
2017
2050
|
const planProjection = planProjectionFor(rec, summary.mode);
|
|
2018
2051
|
return ControlRunDetail.parse({
|
|
2019
2052
|
summary: { ...summary, waitingOnUser: pendingInteractions.length > 0 },
|
|
2053
|
+
children,
|
|
2020
2054
|
// Server-owned outcome headline (D18), from the single projection owner —
|
|
2021
2055
|
// surfaces render it verbatim above model prose, never re-derive it.
|
|
2022
2056
|
outcomeBanner: outcomeBanner(summary.outcomeFacts ?? null, {
|
|
@@ -2074,42 +2108,6 @@ function parseAccessMaybe(value) {
|
|
|
2074
2108
|
const parsed = AccessProfile.safeParse(value);
|
|
2075
2109
|
return parsed.success ? parsed.data : undefined;
|
|
2076
2110
|
}
|
|
2077
|
-
/**
|
|
2078
|
-
* Pure subscription-VALUATION fold over a run's events (QA-023c/QA-017b),
|
|
2079
|
-
* independent of the cash truth. The owner-locked ledger settles native-
|
|
2080
|
-
* subscription work to cash $0 while accumulating its token valuation on
|
|
2081
|
-
* `budget.cash.valuation_usd` (last-wins, cumulative). An UNKNOWN valuation (no
|
|
2082
|
-
* usage ever reported — e.g. a Cursor draft) stays NULL and is never coerced to
|
|
2083
|
-
* a fake $0. The legacy fallback for runs predating budget.cash is the summed
|
|
2084
|
-
* `budget.observation` spend. Vendor token valuation is at best an estimate.
|
|
2085
|
-
*/
|
|
2086
|
-
export function budgetValuationFromEvents(events) {
|
|
2087
|
-
let valuationUsd = null;
|
|
2088
|
-
let observation = 0;
|
|
2089
|
-
let sawObservation = false;
|
|
2090
|
-
for (const ev of events) {
|
|
2091
|
-
const payload = eventPayload(ev);
|
|
2092
|
-
if (ev["type"] === "budget.cash") {
|
|
2093
|
-
const val = payload["valuation_usd"];
|
|
2094
|
-
if (typeof val === "number" && Number.isFinite(val))
|
|
2095
|
-
valuationUsd = val;
|
|
2096
|
-
continue;
|
|
2097
|
-
}
|
|
2098
|
-
if (ev["type"] === "budget.observation" && payload["kind"] === "spend") {
|
|
2099
|
-
const usd = payload["usd"];
|
|
2100
|
-
if (typeof usd === "number" && Number.isFinite(usd)) {
|
|
2101
|
-
observation += usd;
|
|
2102
|
-
sawObservation = true;
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
if (valuationUsd === null && sawObservation)
|
|
2107
|
-
valuationUsd = observation;
|
|
2108
|
-
return {
|
|
2109
|
-
valuationUsd,
|
|
2110
|
-
valuationKnowledge: valuationUsd === null ? "unknown" : "estimated",
|
|
2111
|
-
};
|
|
2112
|
-
}
|
|
2113
2111
|
/** Typed severity per event type — no string matching over event names. */
|
|
2114
2112
|
function budgetSnapshot(rec, decision, eventsSnapshot, integrity) {
|
|
2115
2113
|
const p = paramsRecord(rec);
|
|
@@ -2126,7 +2124,9 @@ function budgetSnapshot(rec, decision, eventsSnapshot, integrity) {
|
|
|
2126
2124
|
let source = spendUsd === null ? "unknown" : "decision";
|
|
2127
2125
|
// Subscription VALUATION (QA-023c/QA-017b) beside cash — computed by the pure
|
|
2128
2126
|
// event fold so an UNKNOWN valuation stays null, never a fabricated $0.
|
|
2129
|
-
const
|
|
2127
|
+
const normalized = normalizeLegacyBudgetComponents(decision?.budget_summary ?? null, evs, budgetValuationFromEvents(evs));
|
|
2128
|
+
let { valuationUsd, valuationKnowledge } = normalized;
|
|
2129
|
+
estimated = normalized.cashEstimated;
|
|
2130
2130
|
if (spendUsd === null) {
|
|
2131
2131
|
// The CASH truth for a decision-less run (plan/ask/explore — they never
|
|
2132
2132
|
// write a decision record) is the ledger's own `budget.cash` disclosure:
|
|
@@ -2147,8 +2147,10 @@ function budgetSnapshot(rec, decision, eventsSnapshot, integrity) {
|
|
|
2147
2147
|
const payload = eventPayload(ev);
|
|
2148
2148
|
if (ev["type"] === "budget.cash") {
|
|
2149
2149
|
const cash = payload["cash_spend_usd"];
|
|
2150
|
-
if (typeof cash === "number" && Number.isFinite(cash))
|
|
2150
|
+
if (typeof cash === "number" && Number.isFinite(cash)) {
|
|
2151
2151
|
lastCash = cash;
|
|
2152
|
+
estimated = cashEstimatedFromLedgerEvent(payload);
|
|
2153
|
+
}
|
|
2152
2154
|
continue;
|
|
2153
2155
|
}
|
|
2154
2156
|
if (ev["type"] === "budget.observation" && payload["kind"] === "spend") {
|