pi-daddy 0.58.0 → 0.59.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 +7 -0
- package/dist/governance/operation-artifacts.d.ts +2 -0
- package/dist/governance/operation-artifacts.d.ts.map +1 -1
- package/dist/governance/operation-artifacts.js +48 -44
- package/dist/governance/operation-artifacts.js.map +1 -1
- package/dist/governance/operation-recovery.d.ts +18 -0
- package/dist/governance/operation-recovery.d.ts.map +1 -0
- package/dist/governance/operation-recovery.js +47 -0
- package/dist/governance/operation-recovery.js.map +1 -0
- package/dist/products/dashboard-activity.d.ts +2 -0
- package/dist/products/dashboard-activity.d.ts.map +1 -1
- package/dist/products/dashboard-activity.js +7 -1
- package/dist/products/dashboard-activity.js.map +1 -1
- package/dist/products/dashboard-panels.d.ts.map +1 -1
- package/dist/products/dashboard-panels.js +7 -2
- package/dist/products/dashboard-panels.js.map +1 -1
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +5 -3
- package/dist/products/dashboard-screen.js.map +1 -1
- package/extensions/dashboard-live.ts +1 -1
- package/extensions/definition-describe.ts +50 -4
- package/extensions/delegate-chain.ts +8 -6
- package/extensions/delegation.ts +14 -8
- package/extensions/operation-recovery-bridge.ts +100 -0
- package/extensions/runtime-snapshot.ts +9 -0
- package/package.json +1 -1
- package/src/governance/operation-artifacts.ts +51 -41
- package/src/governance/operation-recovery.ts +68 -0
- package/src/products/dashboard-activity.ts +8 -1
- package/src/products/dashboard-panels.ts +7 -2
- package/src/products/dashboard-screen.ts +5 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Historical producer facts only. No owner adoption, admission, retry or execution authority. */
|
|
2
|
+
import type { OperationArtifactOwner } from "../kernel/operation-artifact.ts";
|
|
3
|
+
import { readOperationHistory, type OperationArtifactHistory } from "./operation-artifacts.ts";
|
|
4
|
+
import { readRuntimeExecutionSettlement } from "./runtime-settlement.ts";
|
|
5
|
+
|
|
6
|
+
export interface OperationRecoverySource {
|
|
7
|
+
owner: OperationArtifactOwner;
|
|
8
|
+
operationId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OperationRecoveryObservation extends Partial<OperationArtifactHistory> {
|
|
11
|
+
admission: "present" | "absent";
|
|
12
|
+
result: "present" | "absent";
|
|
13
|
+
cleanup: { state: "settled" | "not-started" | "unknown" };
|
|
14
|
+
/** Positive immutable terminal evidence for this exact attempt, never permission for another attempt. */
|
|
15
|
+
noStartProven: boolean;
|
|
16
|
+
}
|
|
17
|
+
export async function readOperationRecovery(
|
|
18
|
+
agentDirectory: string,
|
|
19
|
+
source: OperationRecoverySource,
|
|
20
|
+
): Promise<OperationRecoveryObservation> {
|
|
21
|
+
const retained = readOperationHistory(agentDirectory, source.owner, source.operationId);
|
|
22
|
+
if (!retained)
|
|
23
|
+
return {
|
|
24
|
+
admission: "absent",
|
|
25
|
+
result: "absent",
|
|
26
|
+
cleanup: { state: "unknown" },
|
|
27
|
+
noStartProven: false,
|
|
28
|
+
reason: "No retained admission for this exact owner and operation; absence is not no-start proof.",
|
|
29
|
+
};
|
|
30
|
+
const before = JSON.stringify(retained);
|
|
31
|
+
const { operation, artifact, final, partial } = retained;
|
|
32
|
+
const runtime = operation.runtime;
|
|
33
|
+
const terminalNoStart =
|
|
34
|
+
!!artifact &&
|
|
35
|
+
operation.state === "not-started" &&
|
|
36
|
+
runtime?.cleanup?.state === "not-started" &&
|
|
37
|
+
(runtime.cleanup.executionId === undefined || runtime.cleanup.executionId === operation.executionId) &&
|
|
38
|
+
runtime.cleanup.receiptPath === undefined &&
|
|
39
|
+
(runtime.work === undefined || runtime.work === "unknown") &&
|
|
40
|
+
runtime.final === undefined &&
|
|
41
|
+
!final &&
|
|
42
|
+
!partial;
|
|
43
|
+
let settlement: "settled" | "not-started" | "unknown" = "unknown";
|
|
44
|
+
try {
|
|
45
|
+
settlement = await readRuntimeExecutionSettlement(
|
|
46
|
+
agentDirectory,
|
|
47
|
+
source.owner.sessionId,
|
|
48
|
+
source.owner.cwd,
|
|
49
|
+
operation.executionId,
|
|
50
|
+
);
|
|
51
|
+
} catch {
|
|
52
|
+
// A missing or invalid journal cannot strengthen the immutable result or prove no execution.
|
|
53
|
+
}
|
|
54
|
+
if (JSON.stringify(readOperationHistory(agentDirectory, source.owner, source.operationId)) !== before)
|
|
55
|
+
throw Error("operation recovery evidence changed during read");
|
|
56
|
+
const contradictory = operation.state === "not-started" && (!terminalNoStart || settlement === "settled");
|
|
57
|
+
const noStartProven = terminalNoStart && !contradictory;
|
|
58
|
+
return {
|
|
59
|
+
...retained,
|
|
60
|
+
admission: "present",
|
|
61
|
+
result: artifact ? "present" : "absent",
|
|
62
|
+
cleanup: { state: contradictory ? "unknown" : noStartProven ? "not-started" : settlement },
|
|
63
|
+
noStartProven,
|
|
64
|
+
...(contradictory
|
|
65
|
+
? { reason: "The retained no-start record contains conflicting or incomplete execution evidence." }
|
|
66
|
+
: {}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -10,6 +10,8 @@ const clean = (value: string) =>
|
|
|
10
10
|
.trim();
|
|
11
11
|
|
|
12
12
|
export function activityTaskTitle(task: TimelineTask): string {
|
|
13
|
+
if (activityTaskStatus(task) === "turn-ended")
|
|
14
|
+
return task.trigger?.type === "custom" ? "Extension turn ended" : "Pi turn ended";
|
|
13
15
|
const lastAction = task.lastEvent?.kind === "tool_started" || task.status !== "active";
|
|
14
16
|
const observed = lastAction
|
|
15
17
|
? (safeDashboardSummary(task.lastPurpose) ?? (task.lastEvent?.tool ? toolPurpose(task.lastEvent.tool) : undefined))
|
|
@@ -22,6 +24,11 @@ export function activityTaskTitle(task: TimelineTask): string {
|
|
|
22
24
|
return task.status === "active" ? "Pi is working on your request" : "Pi handled your request";
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
/** A settled parent response says nothing about delivery; child execution outcomes remain distinct. */
|
|
28
|
+
export function activityTaskStatus(task: TimelineTask): string {
|
|
29
|
+
return !task.agent && !task.parentTaskId && task.status === "finished" ? "turn-ended" : task.status;
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
/** Ledger entries retain authoritative state and identity. Only the same owner's matching execution may add a title. */
|
|
26
33
|
export function applyOwnerTaskTitles(items: DashboardItem[], tasks: TimelineTask[], rootId: string): DashboardItem[] {
|
|
27
34
|
const known = new Map(tasks.filter((task) => task.rootId === rootId && task.agent).map((task) => [task.id, task]));
|
|
@@ -55,7 +62,7 @@ export function activityStoryItems(
|
|
|
55
62
|
if (raw === "agent_start" || raw === "agent_end") starts.clear();
|
|
56
63
|
stories.push({
|
|
57
64
|
events: [event],
|
|
58
|
-
label: raw === "agent_start" ? "Pi started a turn" : raw === "agent_end" ? "Pi
|
|
65
|
+
label: raw === "agent_start" ? "Pi started a turn" : raw === "agent_end" ? "Pi turn ended" : raw,
|
|
59
66
|
status: "observed",
|
|
60
67
|
calls: 1,
|
|
61
68
|
});
|
|
@@ -312,7 +312,12 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
312
312
|
...input,
|
|
313
313
|
...components.filter(needsUserInput),
|
|
314
314
|
...(ownerTurn && !parentShown
|
|
315
|
-
? [
|
|
315
|
+
? [
|
|
316
|
+
{
|
|
317
|
+
...row(ownerTurn, `owner:${observed.generation}:${ownerTurn.id}`, "Pi owner", staleOwner),
|
|
318
|
+
...(ownerTurn.state === "settled" && !staleOwner ? { label: "Pi turn ended", status: "turn-ended" } : {}),
|
|
319
|
+
},
|
|
320
|
+
]
|
|
316
321
|
: []),
|
|
317
322
|
...tasks,
|
|
318
323
|
...bookieOpenChoices(options),
|
|
@@ -386,7 +391,7 @@ function workGroup(item: DashboardItem): string {
|
|
|
386
391
|
if (item.status === "dependency-wait") return "Waiting on a dependency";
|
|
387
392
|
if (item.status === "incomplete") return "Outcome unknown";
|
|
388
393
|
if (["running", "active", "starting", "authorised", "cancel-requested"].includes(item.status)) return "In progress";
|
|
389
|
-
if (["settled", "completed", "finished", "cancelled", "failed", "refused"].includes(item.status))
|
|
394
|
+
if (["turn-ended", "settled", "completed", "finished", "cancelled", "failed", "refused"].includes(item.status))
|
|
390
395
|
return "Recently finished";
|
|
391
396
|
return "Other tasks";
|
|
392
397
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
DASHBOARD_DESTINATIONS,
|
|
10
10
|
type DashboardDestination,
|
|
11
11
|
} from "./dashboard-panels.ts";
|
|
12
|
-
import { activityTaskTitle } from "./dashboard-activity.ts";
|
|
12
|
+
import { activityTaskStatus, activityTaskTitle } from "./dashboard-activity.ts";
|
|
13
13
|
import { versionLines } from "./dashboard-components.ts";
|
|
14
14
|
import { sessionRecapLines } from "./dashboard-recap.ts";
|
|
15
15
|
import { colorSessionLine, previewWidth, sectionHeading } from "./dashboard-layout.ts";
|
|
@@ -114,6 +114,7 @@ export const friendlyStatus = (status: string) =>
|
|
|
114
114
|
"approval-wait": "Awaiting decision",
|
|
115
115
|
"dependency-wait": "Waiting on dependency",
|
|
116
116
|
"last-observed": "Last seen",
|
|
117
|
+
"turn-ended": "Ended",
|
|
117
118
|
settled: "Finished",
|
|
118
119
|
completed: "Finished",
|
|
119
120
|
finished: "Finished",
|
|
@@ -166,7 +167,7 @@ export function activityDashboardItems(
|
|
|
166
167
|
label: human
|
|
167
168
|
? activityTaskTitle(task)
|
|
168
169
|
: `${task.agent || (task.trigger?.type === "custom" ? "Extension turn" : "User turn")} [${aliases.selector(task)}]`,
|
|
169
|
-
status: task
|
|
170
|
+
status: activityTaskStatus(task),
|
|
170
171
|
updatedAt: task.endedAt ?? task.lastEvent?.at ?? task.startedAt,
|
|
171
172
|
elapsed: elapsed(Date.parse(task.endedAt ?? now.toISOString()) - Date.parse(task.startedAt)),
|
|
172
173
|
observation: task.lastEvent
|
|
@@ -176,7 +177,8 @@ export function activityDashboardItems(
|
|
|
176
177
|
skills: task.skills.length > 0,
|
|
177
178
|
details: [
|
|
178
179
|
`Task: ${aliases.selector(task)}`,
|
|
179
|
-
`State: ${friendlyStatus(task
|
|
180
|
+
`State: ${friendlyStatus(activityTaskStatus(task))} (observation, not acceptance)`,
|
|
181
|
+
...(task.lastPurpose ? [`Last action: ${clean(task.lastPurpose)}`] : []),
|
|
180
182
|
...(task.trigger?.type === "custom" ? [`Trigger: extension message (${task.trigger.customType})`] : []),
|
|
181
183
|
...(task.cwd ? [`Working directory: ${task.cwd}`] : ["Working directory: not recorded"]),
|
|
182
184
|
...(task.lastEvent
|