pi-daddy 0.49.5 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -1
- package/README.md +231 -27
- package/dist/governance/initiative-coordinator.d.ts +63 -0
- package/dist/governance/initiative-coordinator.d.ts.map +1 -0
- package/dist/governance/initiative-coordinator.js +364 -0
- package/dist/governance/initiative-coordinator.js.map +1 -0
- package/dist/governance/initiative-effects.d.ts +20 -0
- package/dist/governance/initiative-effects.d.ts.map +1 -0
- package/dist/governance/initiative-effects.js +108 -0
- package/dist/governance/initiative-effects.js.map +1 -0
- package/dist/governance/initiative-state.d.ts +13 -0
- package/dist/governance/initiative-state.d.ts.map +1 -0
- package/dist/governance/initiative-state.js +122 -0
- package/dist/governance/initiative-state.js.map +1 -0
- package/dist/governance/operation-artifact-io.d.ts +8 -0
- package/dist/governance/operation-artifact-io.d.ts.map +1 -0
- package/dist/governance/operation-artifact-io.js +95 -0
- package/dist/governance/operation-artifact-io.js.map +1 -0
- package/dist/governance/operation-artifact-scan.d.ts +13 -0
- package/dist/governance/operation-artifact-scan.d.ts.map +1 -0
- package/dist/governance/operation-artifact-scan.js +71 -0
- package/dist/governance/operation-artifact-scan.js.map +1 -0
- package/dist/governance/operation-artifacts.d.ts +53 -0
- package/dist/governance/operation-artifacts.d.ts.map +1 -0
- package/dist/governance/operation-artifacts.js +309 -0
- package/dist/governance/operation-artifacts.js.map +1 -0
- package/dist/governance/runtime-settlement.d.ts +2 -0
- package/dist/governance/runtime-settlement.d.ts.map +1 -1
- package/dist/governance/runtime-settlement.js +26 -0
- package/dist/governance/runtime-settlement.js.map +1 -1
- package/dist/governance/workspace-acceptance.d.ts +5 -0
- package/dist/governance/workspace-acceptance.d.ts.map +1 -1
- package/dist/governance/workspace-acceptance.js +16 -0
- package/dist/governance/workspace-acceptance.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel/dashboard-observation.d.ts +76 -0
- package/dist/kernel/dashboard-observation.d.ts.map +1 -0
- package/dist/kernel/dashboard-observation.js +49 -0
- package/dist/kernel/dashboard-observation.js.map +1 -0
- package/dist/kernel/dispatch-operation.d.ts +2 -0
- package/dist/kernel/dispatch-operation.d.ts.map +1 -1
- package/dist/kernel/dispatch-operation.js.map +1 -1
- package/dist/kernel/initiative.d.ts +94 -0
- package/dist/kernel/initiative.d.ts.map +1 -0
- package/dist/kernel/initiative.js +38 -0
- package/dist/kernel/initiative.js.map +1 -0
- package/dist/kernel/operation-artifact.d.ts +49 -0
- package/dist/kernel/operation-artifact.d.ts.map +1 -0
- package/dist/kernel/operation-artifact.js +4 -0
- package/dist/kernel/operation-artifact.js.map +1 -0
- package/dist/kernel/principal-binding.d.ts +4 -0
- package/dist/kernel/principal-binding.d.ts.map +1 -0
- package/dist/kernel/principal-binding.js +94 -0
- package/dist/kernel/principal-binding.js.map +1 -0
- package/dist/kernel/project-paths.d.ts +6 -0
- package/dist/kernel/project-paths.d.ts.map +1 -1
- package/dist/kernel/project-paths.js +12 -0
- package/dist/kernel/project-paths.js.map +1 -1
- package/dist/kernel/selected-definitions.d.ts.map +1 -1
- package/dist/kernel/selected-definitions.js +5 -91
- package/dist/kernel/selected-definitions.js.map +1 -1
- package/dist/kernel/workspace-diagnostics.d.ts +24 -0
- package/dist/kernel/workspace-diagnostics.d.ts.map +1 -0
- package/dist/kernel/workspace-diagnostics.js +81 -0
- package/dist/kernel/workspace-diagnostics.js.map +1 -0
- package/dist/products/activity-storage.d.ts +2 -0
- package/dist/products/activity-storage.d.ts.map +1 -0
- package/dist/products/activity-storage.js +119 -0
- package/dist/products/activity-storage.js.map +1 -0
- package/dist/products/activity-timeline.d.ts +4 -0
- package/dist/products/activity-timeline.d.ts.map +1 -1
- package/dist/products/activity-timeline.js +12 -0
- package/dist/products/activity-timeline.js.map +1 -1
- package/dist/products/dashboard-cli.d.ts +2 -0
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +50 -10
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-display-controls.d.ts.map +1 -1
- package/dist/products/dashboard-display-controls.js +72 -2
- package/dist/products/dashboard-display-controls.js.map +1 -1
- package/dist/products/dashboard-file-cache.d.ts +10 -0
- package/dist/products/dashboard-file-cache.d.ts.map +1 -0
- package/dist/products/dashboard-file-cache.js +38 -0
- package/dist/products/dashboard-file-cache.js.map +1 -0
- package/dist/products/dashboard-layout.d.ts +6 -0
- package/dist/products/dashboard-layout.d.ts.map +1 -0
- package/dist/products/dashboard-layout.js +45 -0
- package/dist/products/dashboard-layout.js.map +1 -0
- package/dist/products/dashboard-panels.d.ts +10 -0
- package/dist/products/dashboard-panels.d.ts.map +1 -0
- package/dist/products/dashboard-panels.js +319 -0
- package/dist/products/dashboard-panels.js.map +1 -0
- package/dist/products/dashboard-recap.d.ts +4 -0
- package/dist/products/dashboard-recap.d.ts.map +1 -0
- package/dist/products/dashboard-recap.js +47 -0
- package/dist/products/dashboard-recap.js.map +1 -0
- package/dist/products/dashboard-screen.d.ts +14 -1
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +217 -40
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +16 -2
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +64 -11
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/dashboard-settings.d.ts.map +1 -1
- package/dist/products/dashboard-settings.js +4 -6
- package/dist/products/dashboard-settings.js.map +1 -1
- package/dist/products/ecosystem-versions.d.ts +1 -1
- package/dist/products/ecosystem-versions.d.ts.map +1 -1
- package/extensions/activity-timeline.ts +3 -1
- package/extensions/artifact-bridge.ts +130 -0
- package/extensions/dashboard-live.ts +63 -0
- package/extensions/dashboard-observation.ts +39 -0
- package/extensions/dashboard-session-server.ts +45 -3
- package/extensions/dashboard-sources.ts +124 -0
- package/extensions/delegation-artifacts.ts +133 -0
- package/extensions/delegation-operations.ts +42 -13
- package/extensions/ecosystem-versions.ts +12 -5
- package/extensions/grants-command.ts +34 -6
- package/extensions/grants.ts +9 -20
- package/extensions/initiative-dashboard.ts +143 -0
- package/extensions/initiative-handoff.ts +59 -0
- package/extensions/initiative-runtime.ts +444 -0
- package/extensions/runtime-snapshot.ts +118 -2
- package/extensions/session-environment.ts +13 -1
- package/extensions/session.ts +28 -10
- package/extensions/workspace-diagnostics.ts +90 -0
- package/package.json +1 -1
- package/src/governance/initiative-coordinator.ts +416 -0
- package/src/governance/initiative-effects.ts +146 -0
- package/src/governance/initiative-state.ts +144 -0
- package/src/governance/operation-artifact-io.ts +103 -0
- package/src/governance/operation-artifact-scan.ts +77 -0
- package/src/governance/operation-artifacts.ts +363 -0
- package/src/governance/runtime-settlement.ts +28 -0
- package/src/governance/workspace-acceptance.ts +18 -0
- package/src/index.ts +13 -0
- package/src/kernel/dashboard-observation.ts +109 -0
- package/src/kernel/dispatch-operation.ts +2 -0
- package/src/kernel/initiative.ts +126 -0
- package/src/kernel/operation-artifact.ts +46 -0
- package/src/kernel/principal-binding.ts +104 -0
- package/src/kernel/project-paths.ts +16 -0
- package/src/kernel/selected-definitions.ts +5 -100
- package/src/kernel/workspace-diagnostics.ts +110 -0
- package/src/products/activity-storage.ts +128 -0
- package/src/products/activity-timeline.ts +11 -0
- package/src/products/dashboard-cli.ts +53 -10
- package/src/products/dashboard-display-controls.ts +63 -2
- package/src/products/dashboard-file-cache.ts +38 -0
- package/src/products/dashboard-layout.ts +50 -0
- package/src/products/dashboard-panels.ts +379 -0
- package/src/products/dashboard-recap.ts +48 -0
- package/src/products/dashboard-screen.ts +266 -43
- package/src/products/dashboard-session-client.ts +78 -14
- package/src/products/dashboard-settings.ts +4 -6
- package/src/products/ecosystem-versions.ts +2 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** Compose durable producer evidence with the existing live operation election. */
|
|
2
|
+
import type { OperationClaim, OperationRequest, OperationReference } from "../src/kernel/dispatch-operation.ts";
|
|
3
|
+
import type { OperationArtifactOutcome, OperationArtifactRef } from "../src/kernel/operation-artifact.ts";
|
|
4
|
+
import type { OperationArtifactStore } from "../src/governance/operation-artifacts.ts";
|
|
5
|
+
import type { GrantsSession } from "./session.ts";
|
|
6
|
+
const owners = new WeakMap<
|
|
7
|
+
OperationClaim,
|
|
8
|
+
{
|
|
9
|
+
store: OperationArtifactStore;
|
|
10
|
+
request: OperationRequest;
|
|
11
|
+
reference?: OperationArtifactRef;
|
|
12
|
+
publish?: (reference: OperationArtifactRef) => void;
|
|
13
|
+
}
|
|
14
|
+
>();
|
|
15
|
+
export function operationHistory(session: GrantsSession, operationId: string, includeFinal = true) {
|
|
16
|
+
return session.reloadLifecycle?.operationFinals?.artifacts?.history(operationId, includeFinal) ?? null;
|
|
17
|
+
}
|
|
18
|
+
export async function claimWithArtifact(
|
|
19
|
+
session: GrantsSession,
|
|
20
|
+
request: OperationRequest,
|
|
21
|
+
claim: () => Promise<OperationClaim>,
|
|
22
|
+
scope = session.reloadLifecycle?.operationFinals,
|
|
23
|
+
): Promise<OperationClaim> {
|
|
24
|
+
if (scope !== session.reloadLifecycle?.operationFinals) throw Error("Operation owner changed before admission");
|
|
25
|
+
const store = scope?.artifacts;
|
|
26
|
+
// Unit-only hosts without the extension lifecycle still exercise the pure live election.
|
|
27
|
+
if (!store) {
|
|
28
|
+
if (session.reloadLifecycle) throw Error("Durable operation owner is not ready; no dispatch started");
|
|
29
|
+
return claim();
|
|
30
|
+
}
|
|
31
|
+
const old = store.history(request.operationId, false);
|
|
32
|
+
if (old) {
|
|
33
|
+
if (old.requestDigest !== request.requestDigest) throw Error("Operation identity conflict with retained request");
|
|
34
|
+
const live = await session.autoMode!.operations!.read(request.operationId);
|
|
35
|
+
if (!live || live.executionId !== old.operation.executionId) return { reused: true, operation: old.operation };
|
|
36
|
+
}
|
|
37
|
+
if (scope !== session.reloadLifecycle?.operationFinals) throw Error("Operation owner changed before admission");
|
|
38
|
+
const initiative = session.initiativeOperations?.capture(request);
|
|
39
|
+
await initiative?.assertCurrent();
|
|
40
|
+
const owned = await claim();
|
|
41
|
+
if (owned.reused) {
|
|
42
|
+
if (old?.artifact && old.operation.executionId === owned.operation.executionId)
|
|
43
|
+
owned.operation.artifact = old.artifact;
|
|
44
|
+
return owned;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
if (scope !== session.reloadLifecycle?.operationFinals) throw Error("Operation owner changed during admission");
|
|
48
|
+
await initiative?.begin();
|
|
49
|
+
if (scope !== session.reloadLifecycle?.operationFinals)
|
|
50
|
+
throw Error("Operation owner changed during initiative admission");
|
|
51
|
+
const admission = store.admit(request);
|
|
52
|
+
if (!admission.created) throw Error("A retained operation already owns this attempt; no dispatch started");
|
|
53
|
+
} catch (error) {
|
|
54
|
+
await initiative?.notAdmitted().catch(() => undefined);
|
|
55
|
+
await owned.finish?.("not-started", { cleanup: { state: "not-started" } }).catch(() => undefined);
|
|
56
|
+
// This execution never left admission. Persist that original-owner fact even after selection revocation.
|
|
57
|
+
// A competing retained execution remains authoritative: never overwrite it with this occurrence's no-start.
|
|
58
|
+
try {
|
|
59
|
+
const admission = store.admit(request);
|
|
60
|
+
if (
|
|
61
|
+
admission.created ||
|
|
62
|
+
("operation" in admission &&
|
|
63
|
+
admission.operation.executionId === request.executionId &&
|
|
64
|
+
admission.requestDigest === request.requestDigest)
|
|
65
|
+
) {
|
|
66
|
+
const reference = store.finish(request, {
|
|
67
|
+
operation: {
|
|
68
|
+
...owned.operation,
|
|
69
|
+
state: "not-started",
|
|
70
|
+
runtime: { cleanup: { state: "not-started" } },
|
|
71
|
+
updatedAt: new Date().toISOString(),
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
try {
|
|
75
|
+
scope.publishArtifact?.(reference);
|
|
76
|
+
} catch {
|
|
77
|
+
/* optional reference hint */
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} catch {
|
|
81
|
+
/* Unavailable persistence remains uncertain; absence is never no-start proof. */
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
const state = { store, request: { ...request }, publish: scope.publishArtifact };
|
|
86
|
+
owners.set(owned, state);
|
|
87
|
+
const started = owned.started!;
|
|
88
|
+
owned.started = async (cwd, workspaceId) => {
|
|
89
|
+
await initiative?.assertCurrent({ cwd, workspaceId });
|
|
90
|
+
store.started(request, cwd, workspaceId);
|
|
91
|
+
await started(cwd, workspaceId);
|
|
92
|
+
owned.operation = { ...owned.operation, state: "running", cwd, workspaceId };
|
|
93
|
+
};
|
|
94
|
+
const finish = owned.finish!;
|
|
95
|
+
owned.finish = async (status, runtime) => {
|
|
96
|
+
await finish(status, runtime);
|
|
97
|
+
owned.operation = {
|
|
98
|
+
...owned.operation,
|
|
99
|
+
state: status,
|
|
100
|
+
...(runtime ? { runtime } : {}),
|
|
101
|
+
updatedAt: new Date().toISOString(),
|
|
102
|
+
};
|
|
103
|
+
if (!owners.get(owned)!.reference) retainOperationArtifact(owned, { operation: owned.operation });
|
|
104
|
+
owned.operation.artifact = owners.get(owned)!.reference;
|
|
105
|
+
if (status === "settled" && owned.operation.artifact) {
|
|
106
|
+
// Artifact retention happens before live settlement. Wake the selected work map only after both.
|
|
107
|
+
try {
|
|
108
|
+
initiative?.settled?.();
|
|
109
|
+
} catch {
|
|
110
|
+
/* A consumer can recover on its next work-map read. */
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return owned;
|
|
115
|
+
}
|
|
116
|
+
export function retainOperationArtifact(claim: OperationClaim, outcome: OperationArtifactOutcome) {
|
|
117
|
+
const owner = owners.get(claim);
|
|
118
|
+
if (!owner) return;
|
|
119
|
+
const reference = owner.store.finish(owner.request, outcome);
|
|
120
|
+
owner.reference = reference;
|
|
121
|
+
claim.operation.artifact = reference;
|
|
122
|
+
// Pi receives only a small reference, never duplicated full authored content.
|
|
123
|
+
try {
|
|
124
|
+
owner.publish?.(reference);
|
|
125
|
+
} catch {
|
|
126
|
+
/* Durable publication is authoritative; optional hints are recoverable. */
|
|
127
|
+
}
|
|
128
|
+
return reference;
|
|
129
|
+
}
|
|
130
|
+
export function operationArtifactReference(session: GrantsSession, operation: OperationReference) {
|
|
131
|
+
const historical = operationHistory(session, operation.operationId, false);
|
|
132
|
+
return historical?.operation.executionId === operation.executionId ? historical.artifact : undefined;
|
|
133
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/** Non-authorizing dispatch election. The elected caller still runs the ordinary governance path. */
|
|
2
|
+
import { claimWithArtifact, retainOperationArtifact } from "./delegation-artifacts.ts";
|
|
3
|
+
import { openOperationArtifacts, type OperationArtifactStore } from "../src/governance/operation-artifacts.ts";
|
|
4
|
+
import type { OperationArtifactRef } from "../src/kernel/operation-artifact.ts";
|
|
5
|
+
import { agentDir } from "../src/kernel/project-paths.ts";
|
|
2
6
|
import { createHash } from "node:crypto";
|
|
3
7
|
import { realpath } from "node:fs/promises";
|
|
4
8
|
import { Type } from "typebox";
|
|
@@ -22,21 +26,30 @@ const FINAL_BYTES = 4 * 1024 * 1024,
|
|
|
22
26
|
FINAL_ENTRIES = 128;
|
|
23
27
|
type Final = Extract<NonNullable<DelegationOutcome["final"]>, { state: "complete" }>;
|
|
24
28
|
export interface OperationFinalStore {
|
|
29
|
+
artifacts?: OperationArtifactStore;
|
|
30
|
+
publishArtifact?: (reference: OperationArtifactRef) => void;
|
|
25
31
|
lifecycle: object;
|
|
26
32
|
owner: string;
|
|
27
33
|
bytes: number;
|
|
28
34
|
entries: Map<string, { executionId: string; final: Final }>;
|
|
29
35
|
}
|
|
30
|
-
export function bindOperationFinals(
|
|
36
|
+
export function bindOperationFinals(
|
|
37
|
+
session: GrantsSession,
|
|
38
|
+
sessionId: string,
|
|
39
|
+
cwd: string,
|
|
40
|
+
publishArtifact?: (reference: OperationArtifactRef) => void,
|
|
41
|
+
) {
|
|
31
42
|
const owner = JSON.stringify([sessionId, cwd]),
|
|
32
43
|
old = session.reloadLifecycle.operationFinals;
|
|
33
44
|
if (!old || old.lifecycle !== session.reloadLifecycle || old.owner !== owner)
|
|
34
45
|
session.reloadLifecycle.operationFinals = {
|
|
46
|
+
artifacts: openOperationArtifacts(agentDir(), { sessionId, cwd }),
|
|
35
47
|
lifecycle: session.reloadLifecycle,
|
|
36
48
|
owner,
|
|
37
49
|
bytes: 0,
|
|
38
50
|
entries: new Map(),
|
|
39
51
|
};
|
|
52
|
+
session.reloadLifecycle.operationFinals!.publishArtifact = publishArtifact;
|
|
40
53
|
}
|
|
41
54
|
/** Capture before admitting work; a late child cannot write a replacement session's store. */
|
|
42
55
|
export function operationFinalScope(session: GrantsSession): object | undefined {
|
|
@@ -116,6 +129,7 @@ export async function claimDelegationOperation(
|
|
|
116
129
|
ctx: DelegationToolContext,
|
|
117
130
|
signal?: AbortSignal,
|
|
118
131
|
): Promise<OperationClaim | undefined> {
|
|
132
|
+
const operationScope = session.reloadLifecycle?.operationFinals;
|
|
119
133
|
const operationId = spec.operation_id;
|
|
120
134
|
if (operationId === undefined) return undefined;
|
|
121
135
|
assertDelegationAuthority(session);
|
|
@@ -164,16 +178,14 @@ export async function claimDelegationOperation(
|
|
|
164
178
|
),
|
|
165
179
|
)
|
|
166
180
|
.digest("hex");
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
signal,
|
|
176
|
-
);
|
|
181
|
+
const identity = {
|
|
182
|
+
operationId,
|
|
183
|
+
requestDigest,
|
|
184
|
+
executionId: ids.executionId,
|
|
185
|
+
cwd,
|
|
186
|
+
workspaceId: spec.workspace?.workspace_id ?? null,
|
|
187
|
+
};
|
|
188
|
+
return claimWithArtifact(session, identity, () => operations.claim(identity, signal), operationScope);
|
|
177
189
|
};
|
|
178
190
|
if (!denied) return elect();
|
|
179
191
|
|
|
@@ -230,13 +242,13 @@ export async function finishDelegationOperation(
|
|
|
230
242
|
finalScope: object | undefined,
|
|
231
243
|
) {
|
|
232
244
|
const cleanup = result.cleanup;
|
|
233
|
-
const state =
|
|
245
|
+
const state: OperationReference["state"] =
|
|
234
246
|
cleanup?.state === "settled"
|
|
235
247
|
? "settled"
|
|
236
248
|
: cleanup?.state === "not-started" || (!result.work && !result.final && !cleanup)
|
|
237
249
|
? "not-started"
|
|
238
250
|
: "uncertain";
|
|
239
|
-
|
|
251
|
+
const runtime: NonNullable<OperationReference["runtime"]> = {
|
|
240
252
|
work: result.work,
|
|
241
253
|
control: result.control,
|
|
242
254
|
...(result.final
|
|
@@ -267,7 +279,24 @@ export async function finishDelegationOperation(
|
|
|
267
279
|
},
|
|
268
280
|
}
|
|
269
281
|
: {}),
|
|
282
|
+
};
|
|
283
|
+
const operation = {
|
|
284
|
+
...claim.operation,
|
|
285
|
+
state,
|
|
286
|
+
runtime,
|
|
287
|
+
cwd: result.cwd ?? claim.operation.cwd,
|
|
288
|
+
workspaceId: result.workspaceId ?? claim.operation.workspaceId,
|
|
289
|
+
updatedAt: new Date().toISOString(),
|
|
290
|
+
};
|
|
291
|
+
retainOperationArtifact(claim, {
|
|
292
|
+
operation,
|
|
293
|
+
...(result.final?.state === "complete"
|
|
294
|
+
? { final: result.final }
|
|
295
|
+
: result.final?.diagnosticText !== undefined
|
|
296
|
+
? { partial: result.final.diagnosticText }
|
|
297
|
+
: {}),
|
|
270
298
|
});
|
|
299
|
+
await claim.finish!(state, runtime);
|
|
271
300
|
retainOperationFinal(session, claim, result, finalScope);
|
|
272
301
|
result.operation = {
|
|
273
302
|
...claim.operation,
|
|
@@ -18,6 +18,8 @@ const packages = [
|
|
|
18
18
|
{ id: "pi-daddy", label: "pi-daddy", names: ["pi-daddy"] },
|
|
19
19
|
{ id: "principal-pi-skills", label: "Principal", names: ["principal-pi-skills"] },
|
|
20
20
|
{ id: "skill-harness", label: "Harness", names: ["skill-harness", "skill-harness-monorepo"] },
|
|
21
|
+
{ id: "pi-scout-research", label: "Scout", names: ["pi-scout-research"] },
|
|
22
|
+
{ id: "bookie-pi-skills", label: "Bookie", names: ["pi-bookie", "bookie-pi-skills", "@bookie/pi-extension"] },
|
|
21
23
|
] as const;
|
|
22
24
|
interface LoadedPackage {
|
|
23
25
|
id: EcosystemPackageId;
|
|
@@ -74,7 +76,7 @@ export function createEcosystemVersionInventory(
|
|
|
74
76
|
if (!value || typeof value !== "object") return;
|
|
75
77
|
const item = value as LoadedPackage;
|
|
76
78
|
if (
|
|
77
|
-
!["principal-pi-skills", "skill-harness"].includes(item.id) ||
|
|
79
|
+
!["principal-pi-skills", "skill-harness", "pi-scout-research", "bookie-pi-skills"].includes(item.id) ||
|
|
78
80
|
typeof item.root !== "string" ||
|
|
79
81
|
!item.root.startsWith("/")
|
|
80
82
|
)
|
|
@@ -92,10 +94,11 @@ export function createEcosystemVersionInventory(
|
|
|
92
94
|
}
|
|
93
95
|
const rows: EcosystemVersionRow[] = packages.map((pkg) => {
|
|
94
96
|
const loaded = reports.filter((item) => item.id === pkg.id);
|
|
97
|
+
const npmName = (source: string) =>
|
|
98
|
+
pkg.names.find((name) => source === `npm:${name}` || source.startsWith(`npm:${name}@`));
|
|
95
99
|
const sources = configured.filter(
|
|
96
100
|
(item) =>
|
|
97
|
-
item.source
|
|
98
|
-
item.source.startsWith(`npm:${pkg.id}@`) ||
|
|
101
|
+
npmName(item.source) !== undefined ||
|
|
99
102
|
(item.installedPath !== undefined && ports.readVersion(item.installedPath, pkg.names) !== null) ||
|
|
100
103
|
loaded.some((x) => item.installedPath && resolve(item.installedPath) === resolve(x.root)),
|
|
101
104
|
);
|
|
@@ -116,7 +119,9 @@ export function createEcosystemVersionInventory(
|
|
|
116
119
|
pkg.id === "pi"
|
|
117
120
|
? ["pi update"]
|
|
118
121
|
: source?.source.startsWith("npm:") && !multiple
|
|
119
|
-
? [
|
|
122
|
+
? [
|
|
123
|
+
`pi install${source.scope === "project" ? " --local" : ""} npm:${npmName(source.source) ?? pkg.names[0]}@<version>`,
|
|
124
|
+
]
|
|
120
125
|
: ["pi list", "pi config"];
|
|
121
126
|
if (pkg.id === "principal-pi-skills" && root && !multiple) {
|
|
122
127
|
const installer = "'" + join(root, "scripts/install-agents.mjs").replaceAll("'", "'\\''") + "'";
|
|
@@ -145,7 +150,9 @@ export function createEcosystemVersionInventory(
|
|
|
145
150
|
? "This package did not report its loaded generation. Installed bytes alone do not establish the running version."
|
|
146
151
|
: pkg.id === "pi"
|
|
147
152
|
? "Restart Pi after changing its version."
|
|
148
|
-
: "
|
|
153
|
+
: (source?.source.startsWith("npm:")
|
|
154
|
+
? "Use an explicit npm version to replace a pin; pi update keeps pinned versions. Reload Pi after installation."
|
|
155
|
+
: "Observed local source; manage its selected path, then reload Pi. This is not a published-version check.") +
|
|
149
156
|
(pkg.id === "principal-pi-skills"
|
|
150
157
|
? " Agent installer commands are optional, for legacy installed agent definitions."
|
|
151
158
|
: ""),
|
|
@@ -53,6 +53,10 @@ export interface GrantsCommandContext {
|
|
|
53
53
|
unacceptedWorkspaces?: readonly string[];
|
|
54
54
|
/** Accept the registry's current ids. Injected, so this diagnostic does not become a governance path. */
|
|
55
55
|
acceptWorkspaces?: () => Promise<string[]>;
|
|
56
|
+
/** Read-only current routing owner inspection; never acquires approval, a pin or a writer lease. */
|
|
57
|
+
inspectWorkspace?: (id: string) => Promise<string>;
|
|
58
|
+
grantSource?: string;
|
|
59
|
+
storeCwd?: string;
|
|
56
60
|
observed: boolean;
|
|
57
61
|
depth: number;
|
|
58
62
|
maxDepth: number;
|
|
@@ -110,6 +114,7 @@ const KNOWN_SUBCOMMANDS: readonly string[] = [
|
|
|
110
114
|
"approvals",
|
|
111
115
|
"revoke",
|
|
112
116
|
"workspaces",
|
|
117
|
+
"workspace",
|
|
113
118
|
"models",
|
|
114
119
|
"auto",
|
|
115
120
|
];
|
|
@@ -190,6 +195,23 @@ export const grantsCommand = {
|
|
|
190
195
|
return;
|
|
191
196
|
}
|
|
192
197
|
|
|
198
|
+
if (sub === "workspace") {
|
|
199
|
+
if (words.length !== 2 || !/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(target) || target.length > 128) {
|
|
200
|
+
ctx.ui.notify("grants: use /grants workspace <id> for a read-only routing inspection.", "warning");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (!ctx.grants.inspectWorkspace) {
|
|
204
|
+
ctx.ui.notify("grants: workspace inspection is unavailable for this owner.", "warning");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
ctx.ui.notify(await ctx.grants.inspectWorkspace(target), "info");
|
|
209
|
+
} catch (error) {
|
|
210
|
+
ctx.ui.notify(`grants: workspace inspection unavailable — ${String(error)}`, "warning");
|
|
211
|
+
}
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
193
215
|
if (sub === "workspaces") {
|
|
194
216
|
// The one verb that WRITES, and it takes its ability to do so from the caller — the same shape
|
|
195
217
|
// `/grants init` uses, so this screen cannot become a governance path by accident.
|
|
@@ -201,7 +223,8 @@ export const grantsCommand = {
|
|
|
201
223
|
const accepted = await accept();
|
|
202
224
|
ctx.ui.notify(
|
|
203
225
|
`grants: accepted ${accepted.length} workspace id(s) — ${accepted.join(", ") || "(none)"}. ` +
|
|
204
|
-
`
|
|
226
|
+
`Accepted for the next root session; this owner's pin is unchanged, including after /reload. ` +
|
|
227
|
+
`Use /grants workspace <id> to inspect current routing. Ids added later require acceptance again.`,
|
|
205
228
|
"info",
|
|
206
229
|
);
|
|
207
230
|
return;
|
|
@@ -466,19 +489,21 @@ export const grantsCommand = {
|
|
|
466
489
|
// **Marked here rather than left to a join.** The catalog loads the UNNARROWED registry, so it
|
|
467
490
|
// lists an id nobody accepted; session start names it separately, and review pointed out that a
|
|
468
491
|
// reader has to put the two together. An id that cannot be routed to should not read as routable.
|
|
469
|
-
`
|
|
492
|
+
` registered ${catalog
|
|
470
493
|
.byKind("workspace")
|
|
471
494
|
.map((id) =>
|
|
472
|
-
(unacceptedWorkspaces ?? []).includes(id.slice("workspace:".length))
|
|
495
|
+
(unacceptedWorkspaces ?? []).includes(id.slice("workspace:".length))
|
|
496
|
+
? `${id} (NOT ACCEPTED when this owner pinned)`
|
|
497
|
+
: id,
|
|
473
498
|
)
|
|
474
|
-
.join(", ")} —
|
|
499
|
+
.join(", ")} — inspect /grants workspace <id>; registration alone is not active routing`,
|
|
475
500
|
// ADR-0042 made a destination pin a PRECONDITION for routing, and it had no operator surface at
|
|
476
501
|
// all: not here, not at session start, not in the README. An operator refused for want of a pin
|
|
477
502
|
// could not discover that the mechanism existed, let alone which ids it covered.
|
|
478
503
|
...(unacceptedWorkspaces && unacceptedWorkspaces.length > 0
|
|
479
504
|
? [
|
|
480
|
-
` unaccepted ${unacceptedWorkspaces.join(", ")} —
|
|
481
|
-
`
|
|
505
|
+
` unaccepted ${unacceptedWorkspaces.join(", ")} — unaccepted when this owner pinned. ` +
|
|
506
|
+
`Use /grants workspace <id> for current acceptance and activation state.`,
|
|
482
507
|
]
|
|
483
508
|
: []),
|
|
484
509
|
` pinned ${
|
|
@@ -500,6 +525,9 @@ export const grantsCommand = {
|
|
|
500
525
|
];
|
|
501
526
|
// Runs the REAL planner AND the real approval step over each definition, so this listing cannot
|
|
502
527
|
// disagree with what a spawn would do — the R-28 lesson, kept structural rather than remembered.
|
|
528
|
+
lines.push(
|
|
529
|
+
` grant source ${ctx.grants.grantSource ?? "unobserved"}; store directory ${ctx.grants.storeCwd ?? cwd}`,
|
|
530
|
+
);
|
|
503
531
|
const shown = [...definitions].slice(0, PREVIEW_LIMIT);
|
|
504
532
|
for (const [name] of shown) {
|
|
505
533
|
const { plan, approval } = await previewDelegation(name);
|
package/extensions/grants.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
* spawn triggered the human prompt, and `childEnv` clamps it to the grant again on the way out. Each
|
|
29
29
|
* child derives its own grant from the tool array of its first provider request.
|
|
30
30
|
*/
|
|
31
|
+
import { inspectSessionWorkspace } from "./workspace-diagnostics.ts";
|
|
31
32
|
import { registerRuntimeSnapshot } from "./runtime-snapshot.ts";
|
|
32
33
|
import { fileURLToPath } from "node:url";
|
|
33
34
|
import { homedir } from "node:os";
|
|
@@ -124,7 +125,7 @@ export default function (pi: ExtensionAPI, trustedSession?: GrantsSession) {
|
|
|
124
125
|
// isolated; it cannot carry state into another extension instance.
|
|
125
126
|
const owner = (ctx as { sessionManager?: object }).sessionManager ?? session;
|
|
126
127
|
const reload = bindReloadLifecycle(owner, session.reloadLifecycle);
|
|
127
|
-
session.reconcileEnvironment(reload.environment, reload.lifecycle);
|
|
128
|
+
session.reconcileEnvironment(reload.environment, reload.lifecycle, ctx.cwd);
|
|
128
129
|
session.ownerBound = true;
|
|
129
130
|
selectedReady = undefined;
|
|
130
131
|
selectedReportContext = ctx;
|
|
@@ -170,24 +171,8 @@ export default function (pi: ExtensionAPI, trustedSession?: GrantsSession) {
|
|
|
170
171
|
ctx.ui.notify(`grants: legacy ledger import failed: ${String(error)}`, "error");
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
|
-
// The
|
|
174
|
-
//
|
|
175
|
-
// that ordering, since whether `delegate` is registered is decided there. Almost always the two agree.
|
|
176
|
-
// When they do not, the session is governed by a different directory's decision than the one it is
|
|
177
|
-
// working in, which is exactly the confusion a grant must never cause, so it is said out loud rather
|
|
178
|
-
// than left to be inferred from a surprising refusal. Sync, so it is not the R-60 shape.
|
|
179
|
-
// Inside no try of its own, and that is deliberate: it is synchronous, so it cannot be the R-60 shape. A
|
|
180
|
-
// reviewer noted it sits before the try that contains `resolveExecutor` — which is the right order, because
|
|
181
|
-
// this warning is about WHICH directory's grant was read and must reach the operator even if everything
|
|
182
|
-
// after it fails.
|
|
183
|
-
if (session.storeCwd !== ctx.cwd && process.env[ENV_GRANT] === undefined) {
|
|
184
|
-
ctx.ui.notify(
|
|
185
|
-
`grants: this session's stored grant was read for ${session.storeCwd}, but pi is working in ` +
|
|
186
|
-
`${ctx.cwd}. A grant belongs to a directory, so run /grants init here, or set PI_DADDY_GRANT ` +
|
|
187
|
-
`explicitly — the environment always wins.`,
|
|
188
|
-
"warning",
|
|
189
|
-
);
|
|
190
|
-
}
|
|
174
|
+
// The owner-bound reconciliation already selected ctx.cwd before registering delegation tools.
|
|
175
|
+
// Preserve exact store identity; aliases do not silently borrow another spelling's saved authority.
|
|
191
176
|
try {
|
|
192
177
|
await reportGrantStoreRefusal(session, ctx.ui);
|
|
193
178
|
} catch (error) {
|
|
@@ -454,7 +439,8 @@ export default function (pi: ExtensionAPI, trustedSession?: GrantsSession) {
|
|
|
454
439
|
// read-only diagnostic may see is a decision, and `GrantsCommandContext` is where it is recorded.
|
|
455
440
|
handler: async (args, ctx) => {
|
|
456
441
|
// Auto controls and emergency revoke-all need no definition acquisition; OFF must remain reachable.
|
|
457
|
-
if (args.trim() !== "revoke --all" && args.trim().split(/\s+/)[0]
|
|
442
|
+
if (args.trim() !== "revoke --all" && !["auto", "workspace"].includes(args.trim().split(/\s+/)[0]))
|
|
443
|
+
await session.ensureDefinitions?.();
|
|
458
444
|
const autoView = await getDashboardControlState(session)
|
|
459
445
|
.then(({ auto }) => ({
|
|
460
446
|
autoModeEnabled: auto.enabled,
|
|
@@ -465,6 +451,9 @@ export default function (pi: ExtensionAPI, trustedSession?: GrantsSession) {
|
|
|
465
451
|
...ctx,
|
|
466
452
|
grants: {
|
|
467
453
|
cwd: session.cwd,
|
|
454
|
+
storeCwd: session.storeCwd,
|
|
455
|
+
grantSource: session.grantSource,
|
|
456
|
+
inspectWorkspace: (id: string) => inspectSessionWorkspace(session, id),
|
|
468
457
|
governed: session.governed,
|
|
469
458
|
ownGrant: session.ownGrant,
|
|
470
459
|
executor: session.executor,
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/** Cached owner observations. Refresh on state transitions, never on terminal redraw. */
|
|
2
|
+
import type { DashboardSourceSnapshot, DashboardContribution } from "../src/kernel/dashboard-observation.ts";
|
|
3
|
+
import type { InitiativeCoordinator } from "../src/governance/initiative-coordinator.ts";
|
|
4
|
+
import type { InitiativeTask, InitiativeTaskIdentity, InitiativeObservation } from "../src/kernel/initiative.ts";
|
|
5
|
+
import { artifactHash } from "../src/governance/operation-artifact-io.ts";
|
|
6
|
+
export function initiativeDashboard(
|
|
7
|
+
coordinator: InitiativeCoordinator,
|
|
8
|
+
tasks: InitiativeTask[],
|
|
9
|
+
now: () => number = Date.now,
|
|
10
|
+
) {
|
|
11
|
+
let sequence = 0,
|
|
12
|
+
snapshot: DashboardSourceSnapshot | undefined,
|
|
13
|
+
closed = false;
|
|
14
|
+
let pending: Promise<void> | undefined;
|
|
15
|
+
const metadata = coordinator.metadata();
|
|
16
|
+
const createdAt = new Date(now()).toISOString();
|
|
17
|
+
const last = new Map<
|
|
18
|
+
string,
|
|
19
|
+
{
|
|
20
|
+
revision: string;
|
|
21
|
+
observedAt: string;
|
|
22
|
+
stale: boolean;
|
|
23
|
+
observation: Omit<InitiativeObservation, "assertCurrent">;
|
|
24
|
+
}
|
|
25
|
+
>();
|
|
26
|
+
const selected = tasks.slice(0, 5).map((task) => structuredClone(task));
|
|
27
|
+
const key = (task: InitiativeTaskIdentity | InitiativeTask) => JSON.stringify([task.taskId, task.taskRevision]);
|
|
28
|
+
return {
|
|
29
|
+
/** Only a real owner read may supply facts; this cache is never consulted by admission or tools. */
|
|
30
|
+
record(
|
|
31
|
+
input: InitiativeTaskIdentity,
|
|
32
|
+
observation: Awaited<ReturnType<InitiativeCoordinator["observe"]>>,
|
|
33
|
+
revision: string,
|
|
34
|
+
) {
|
|
35
|
+
if (closed || input.initiativeId !== metadata.initiativeId || !selected.some((task) => key(task) === key(input)))
|
|
36
|
+
return;
|
|
37
|
+
if (observation.status !== "observed") {
|
|
38
|
+
last.delete(key(input));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { assertCurrent: recheck, ...facts } = observation;
|
|
42
|
+
void recheck;
|
|
43
|
+
last.set(key(input), {
|
|
44
|
+
revision,
|
|
45
|
+
observedAt: new Date(now()).toISOString(),
|
|
46
|
+
stale: false,
|
|
47
|
+
observation: structuredClone(facts),
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
invalidate(input?: InitiativeTaskIdentity) {
|
|
51
|
+
for (const [id, entry] of last) if (!input || id === key(input)) entry.stale = true;
|
|
52
|
+
if (snapshot)
|
|
53
|
+
snapshot = {
|
|
54
|
+
...snapshot,
|
|
55
|
+
items: snapshot.items.map((item) =>
|
|
56
|
+
item.kind === "work" && (!input || item.id === input.taskId.slice(0, 160))
|
|
57
|
+
? {
|
|
58
|
+
...item,
|
|
59
|
+
state: "unavailable",
|
|
60
|
+
details: item.details?.map((text, i) => (i === 3 ? `Stale: ${text}`.slice(0, 240) : text)),
|
|
61
|
+
}
|
|
62
|
+
: item,
|
|
63
|
+
),
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
snapshot: () => snapshot,
|
|
67
|
+
close() {
|
|
68
|
+
closed = true;
|
|
69
|
+
if (snapshot) snapshot = { ...snapshot, availability: "closed" };
|
|
70
|
+
},
|
|
71
|
+
refresh(): Promise<void> {
|
|
72
|
+
if (closed) return Promise.resolve();
|
|
73
|
+
if (pending) return pending;
|
|
74
|
+
pending = (async () => {
|
|
75
|
+
const items: DashboardContribution[] = [];
|
|
76
|
+
const meta = coordinator.metadata();
|
|
77
|
+
for (const task of selected) {
|
|
78
|
+
const retained = last.get(key(task));
|
|
79
|
+
const known = retained?.observation;
|
|
80
|
+
const stale =
|
|
81
|
+
retained?.stale ||
|
|
82
|
+
retained?.revision !== coordinator.revision() ||
|
|
83
|
+
(!!retained && now() - Date.parse(retained.observedAt) > 120000);
|
|
84
|
+
items.push({
|
|
85
|
+
id: task.taskId.slice(0, 160),
|
|
86
|
+
kind: "work",
|
|
87
|
+
label: task.taskId.slice(0, 180),
|
|
88
|
+
state:
|
|
89
|
+
!known || stale
|
|
90
|
+
? "unavailable"
|
|
91
|
+
: known.reconciliationRequired
|
|
92
|
+
? "unknown"
|
|
93
|
+
: known.execution === "running"
|
|
94
|
+
? "running"
|
|
95
|
+
: known.execution === "settled"
|
|
96
|
+
? "settled"
|
|
97
|
+
: "observed",
|
|
98
|
+
details: [
|
|
99
|
+
`Initiative scope: ${metadata.initiativeId.slice(0, 180)}`,
|
|
100
|
+
`Task revision: ${task.taskRevision}`,
|
|
101
|
+
`Last owner generation: ${known?.ownerGeneration ?? "unobserved"}; claim: ${known?.claim ?? "unavailable"}`,
|
|
102
|
+
retained
|
|
103
|
+
? `Last observed ${retained.observedAt}${stale ? "; stale" : ""}; effect ${task.effectScope}`
|
|
104
|
+
: `Not yet observed; effect ${task.effectScope}`,
|
|
105
|
+
...(known?.effectObservation
|
|
106
|
+
? [
|
|
107
|
+
`Target ${known.effectObservation.target.kind}: ${known.effectObservation.outcome}; ${known.effectObservation.provenance}`,
|
|
108
|
+
`Target identity: ${known.effectObservation.target.reference.slice(0, 215)}`,
|
|
109
|
+
]
|
|
110
|
+
: []),
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (closed) return;
|
|
115
|
+
items.unshift({
|
|
116
|
+
id: "scope",
|
|
117
|
+
kind: "status",
|
|
118
|
+
label: `Initiative ${metadata.initiativeId.slice(0, 190)}`,
|
|
119
|
+
state: "observed",
|
|
120
|
+
details: [
|
|
121
|
+
`${coordinator.recoveryOnly ? "Recovery-only observer" : "One-host coordinator"} generation ${meta.generation}`,
|
|
122
|
+
`${meta.knownSessions} known session(s); ${meta.recordedAttempts} recorded attempt(s)`,
|
|
123
|
+
`${tasks.length} selected task(s); first ${Math.min(5, tasks.length)} shown`,
|
|
124
|
+
"Last-observed facts only, not task acceptance or execution authority. Releases belong to their owner.",
|
|
125
|
+
],
|
|
126
|
+
});
|
|
127
|
+
snapshot = {
|
|
128
|
+
producer: "daddy-initiative",
|
|
129
|
+
producerVersion: "v1",
|
|
130
|
+
generation: `${meta.generation}:${artifactHash(metadata.initiativeId)}`,
|
|
131
|
+
sequence: ++sequence,
|
|
132
|
+
observedAt: [...last.values()].map((item) => item.observedAt).sort()[0] ?? createdAt,
|
|
133
|
+
staleAfterMs: 120000,
|
|
134
|
+
availability: "observed",
|
|
135
|
+
items,
|
|
136
|
+
};
|
|
137
|
+
})().finally(() => {
|
|
138
|
+
pending = undefined;
|
|
139
|
+
});
|
|
140
|
+
return pending;
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Owner-bound access to the exact visible final of a settled initiative task. */
|
|
2
|
+
import { openOperationArtifacts, readOperationArtifact } from "../src/governance/operation-artifacts.ts";
|
|
3
|
+
import type { InitiativeAttempt } from "../src/kernel/initiative.ts";
|
|
4
|
+
|
|
5
|
+
type ArtifactScope = { cwd: string; workspaceId: string | null };
|
|
6
|
+
export type HandoffScope = ArtifactScope & { taskId: string; taskRevision: string };
|
|
7
|
+
|
|
8
|
+
export async function retainedInitiativeHandoff(
|
|
9
|
+
directory: string,
|
|
10
|
+
attempt: InitiativeAttempt,
|
|
11
|
+
authorize: (scope: ArtifactScope) => Promise<void>,
|
|
12
|
+
) {
|
|
13
|
+
const store = openOperationArtifacts(directory, attempt.owner);
|
|
14
|
+
const history = store.history(attempt.operationId, false);
|
|
15
|
+
const artifact = history?.artifact,
|
|
16
|
+
op = history?.operation,
|
|
17
|
+
runtime = op?.runtime;
|
|
18
|
+
if (
|
|
19
|
+
!artifact ||
|
|
20
|
+
!op ||
|
|
21
|
+
attempt.state === "not-admitted" ||
|
|
22
|
+
history.requestDigest !== attempt.requestDigest ||
|
|
23
|
+
op.executionId !== attempt.executionId ||
|
|
24
|
+
op.state !== "settled" ||
|
|
25
|
+
runtime?.control === "failed" ||
|
|
26
|
+
runtime?.work !== "succeeded" ||
|
|
27
|
+
runtime.cleanup?.state !== "settled" ||
|
|
28
|
+
runtime.cleanup.executionId !== attempt.executionId ||
|
|
29
|
+
runtime.final?.state !== "complete" ||
|
|
30
|
+
!runtime.final.sha256
|
|
31
|
+
)
|
|
32
|
+
return;
|
|
33
|
+
const finalSha256 = runtime.final.sha256;
|
|
34
|
+
const scope = { cwd: op.cwd, workspaceId: op.workspaceId };
|
|
35
|
+
const readText = async () => {
|
|
36
|
+
await authorize(scope);
|
|
37
|
+
const { final } = readOperationArtifact(artifact, { agentDirectory: directory });
|
|
38
|
+
if (!final || final.sha256 !== finalSha256 || !final.text.trim()) throw Error("Exact retained handoff unavailable");
|
|
39
|
+
return final.text;
|
|
40
|
+
};
|
|
41
|
+
const assertCurrent = async () => {
|
|
42
|
+
await readText();
|
|
43
|
+
};
|
|
44
|
+
await assertCurrent();
|
|
45
|
+
return {
|
|
46
|
+
reference: {
|
|
47
|
+
owner: "pi-daddy" as const,
|
|
48
|
+
reference: {
|
|
49
|
+
kind: "retained-handoff" as const,
|
|
50
|
+
operationId: attempt.operationId,
|
|
51
|
+
executionId: attempt.executionId,
|
|
52
|
+
manifestSha256: artifact.manifest.sha256,
|
|
53
|
+
finalSha256,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
assertCurrent,
|
|
57
|
+
readText,
|
|
58
|
+
};
|
|
59
|
+
}
|