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,379 @@
|
|
|
1
|
+
/** Six current-session destinations share stable row identities; contributions are labels, never authority. */
|
|
2
|
+
import type { DashboardContribution, DashboardSourceSnapshot } from "../kernel/dashboard-observation.ts";
|
|
3
|
+
import type { DashboardItem, DashboardScreenOptions } from "./dashboard-screen.ts";
|
|
4
|
+
import { dashboardText, friendlyStatus } from "./dashboard-screen.ts";
|
|
5
|
+
import { previewWidth, sectionHeading } from "./dashboard-layout.ts";
|
|
6
|
+
import { activityTaskKey } from "./activity-timeline.ts";
|
|
7
|
+
export type DashboardDestination = "now" | "work" | "reviews" | "activity" | "evidence" | "settings";
|
|
8
|
+
export const DASHBOARD_DESTINATIONS: DashboardDestination[] = [
|
|
9
|
+
"now",
|
|
10
|
+
"work",
|
|
11
|
+
"reviews",
|
|
12
|
+
"activity",
|
|
13
|
+
"evidence",
|
|
14
|
+
"settings",
|
|
15
|
+
];
|
|
16
|
+
const clean = (s: string) => dashboardText(s).replace(/\s+/g, " ").trim();
|
|
17
|
+
export function staleSource(source: DashboardSourceSnapshot, options: DashboardScreenOptions): boolean {
|
|
18
|
+
return (
|
|
19
|
+
options.connected === false ||
|
|
20
|
+
source.availability === "closed" ||
|
|
21
|
+
(options.now?.getTime() ?? Date.now()) - Date.parse(source.observedAt) > source.staleAfterMs
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const sourceKey = (source: DashboardSourceSnapshot, item: DashboardContribution) =>
|
|
26
|
+
`source:${source.producer}:${source.generation}:${item.id}`;
|
|
27
|
+
|
|
28
|
+
/** A current request for review takes precedence over general workflow suggestions. */
|
|
29
|
+
function sessionNext(options: DashboardScreenOptions) {
|
|
30
|
+
const current = options.session!.observation!.sources.filter((source) => !staleSource(source, options));
|
|
31
|
+
const recommendations = current.flatMap((source) =>
|
|
32
|
+
source.items.filter((item) => item.kind === "next").map((item) => ({ item, source })),
|
|
33
|
+
);
|
|
34
|
+
for (const next of recommendations) {
|
|
35
|
+
if (next.item.state !== "approval-wait") continue;
|
|
36
|
+
const reviews = next.source.items.filter(
|
|
37
|
+
(item) =>
|
|
38
|
+
item.kind === "review" &&
|
|
39
|
+
item.state === "approval-wait" &&
|
|
40
|
+
!(next.source.producer === "bookie" && reviewTotals(item)) &&
|
|
41
|
+
(!next.item.reference || item.reference === next.item.reference),
|
|
42
|
+
);
|
|
43
|
+
if (reviews.length === 1) return { ...next, reviewKey: sourceKey(next.source, reviews[0]!) };
|
|
44
|
+
}
|
|
45
|
+
const general = recommendations.filter(({ item }) => item.state !== "approval-wait" || !item.reference);
|
|
46
|
+
const next =
|
|
47
|
+
general.find(({ item }) => ["dependency-wait", "failed", "unknown", "unavailable"].includes(item.state)) ??
|
|
48
|
+
general[0];
|
|
49
|
+
return next && { ...next, reviewKey: undefined };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function sessionNextLines(options: DashboardScreenOptions): [string, string] {
|
|
53
|
+
if (options.connected === false) return ["NEXT", "Reconnect to the parent Pi session for current work."];
|
|
54
|
+
if (options.session?.pendingApprovals.length)
|
|
55
|
+
return ["NEXT · Permission", "Respond to the permission request in the parent Pi session."];
|
|
56
|
+
const next = sessionNext(options);
|
|
57
|
+
if (!next) {
|
|
58
|
+
const sources = options.session!.observation!.sources;
|
|
59
|
+
if (sources.length && sources.every((source) => staleSource(source, options)))
|
|
60
|
+
return ["NEXT", "Waiting for a current status from Pi."];
|
|
61
|
+
}
|
|
62
|
+
return [
|
|
63
|
+
next?.reviewKey ? "NEXT · [3] Reviews" : "NEXT",
|
|
64
|
+
next ? clean(next.item.label) : "No current next step reported.",
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
function contributionDetails(item: DashboardContribution, source: string, stale: boolean): string[] {
|
|
68
|
+
const details = item.details ?? [];
|
|
69
|
+
if (!source.startsWith("bookie@") || item.kind !== "review" || item.state !== "approval-wait") return details;
|
|
70
|
+
const open = details.find((line) => line.startsWith("Open /bookie-work review"));
|
|
71
|
+
if (stale)
|
|
72
|
+
return details.filter(
|
|
73
|
+
(line) => !line.startsWith("Open /bookie-work review") && !line.startsWith("Record your review decision"),
|
|
74
|
+
);
|
|
75
|
+
return open ? [open, ...details.filter((line) => line !== open)] : details;
|
|
76
|
+
}
|
|
77
|
+
const row = (
|
|
78
|
+
item: DashboardContribution,
|
|
79
|
+
key: string,
|
|
80
|
+
source: string,
|
|
81
|
+
stale = false,
|
|
82
|
+
label = item.label,
|
|
83
|
+
taskReview?: DashboardContribution,
|
|
84
|
+
): DashboardItem => {
|
|
85
|
+
const details = contributionDetails(item, source, stale);
|
|
86
|
+
const handoff = taskReview ?? item;
|
|
87
|
+
const pendingTask = source.startsWith("bookie@") && item.kind === "work" && item.state === "approval-wait";
|
|
88
|
+
const currentHandoff =
|
|
89
|
+
!stale &&
|
|
90
|
+
source.startsWith("bookie@") &&
|
|
91
|
+
handoff.kind === "review" &&
|
|
92
|
+
handoff.state === "approval-wait" &&
|
|
93
|
+
!reviewTotals(handoff);
|
|
94
|
+
const brief = currentHandoff
|
|
95
|
+
? contributionDetails(handoff, source, stale).filter(
|
|
96
|
+
(line) =>
|
|
97
|
+
!/^(?:\/|[A-Za-z]:[\\/]|(?:Reference|Source|Observed at):)/i.test(line) &&
|
|
98
|
+
!/\b[a-f0-9]{64}\b/i.test(line) &&
|
|
99
|
+
line !== "Output: handoff",
|
|
100
|
+
)
|
|
101
|
+
: [];
|
|
102
|
+
const openInstruction = brief.indexOf("Open /bookie-work review to read the saved handoff.");
|
|
103
|
+
if (openInstruction >= 0) {
|
|
104
|
+
const choice = taskReview && (label === item.label ? label : item.label.split("/").at(-1));
|
|
105
|
+
brief.splice(
|
|
106
|
+
openInstruction,
|
|
107
|
+
1,
|
|
108
|
+
"In your main Pi chat, run",
|
|
109
|
+
"/bookie-work review",
|
|
110
|
+
...(choice ? [`If asked, select ${choice}.`] : []),
|
|
111
|
+
);
|
|
112
|
+
const decision = brief.indexOf("Record your review decision for this output in the selected project.");
|
|
113
|
+
if (decision >= 0) brief[decision] = "Read the output and record your decision.";
|
|
114
|
+
}
|
|
115
|
+
if (currentHandoff && !brief.length) brief.push("Awaiting a review decision for this output.");
|
|
116
|
+
if (!currentHandoff && pendingTask)
|
|
117
|
+
brief.push(
|
|
118
|
+
stale
|
|
119
|
+
? "Last seen awaiting a decision. Check the parent Pi session for current status."
|
|
120
|
+
: "A decision is pending. Check the selected task in the parent Pi session for its review evidence.",
|
|
121
|
+
);
|
|
122
|
+
return {
|
|
123
|
+
key,
|
|
124
|
+
label,
|
|
125
|
+
status: stale ? "last-observed" : item.state,
|
|
126
|
+
elapsed: "",
|
|
127
|
+
agent: item.kind === "work",
|
|
128
|
+
...(source.startsWith("bookie@") && reviewTotals(item) ? { reviewSummary: true } : {}),
|
|
129
|
+
...(brief.length ? { briefDetails: brief } : {}),
|
|
130
|
+
details: [
|
|
131
|
+
...(stale ? ["Last recorded details. Current state is unknown."] : []),
|
|
132
|
+
...details,
|
|
133
|
+
...(label !== item.label ? [item.label] : []),
|
|
134
|
+
`Observed state: ${item.state}${stale ? " (stale/disconnected)" : ""}`,
|
|
135
|
+
`Source: ${source}`,
|
|
136
|
+
...(item.reference ? [`Reference: ${item.reference}`] : []),
|
|
137
|
+
...(taskReview?.reference ? [`Saved handoff reference: ${taskReview.reference}`] : []),
|
|
138
|
+
...(item.kind === "review"
|
|
139
|
+
? [
|
|
140
|
+
item.state === "approval-wait"
|
|
141
|
+
? "The reviewer decides on this output."
|
|
142
|
+
: "A reported judgment is not execution authority or overall task acceptance.",
|
|
143
|
+
]
|
|
144
|
+
: []),
|
|
145
|
+
"Reported observations do not grant execution authority or task approval.",
|
|
146
|
+
...(stale ? ["Current liveness/applicability unknown; no automatic retry."] : []),
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const reviewTotals = (item: DashboardContribution) =>
|
|
152
|
+
item.kind === "review" && item.id === "reviews" && item.label === "Selected output judgment observations";
|
|
153
|
+
|
|
154
|
+
// Bookie publishes work with its task revision and the corresponding review with its output digest.
|
|
155
|
+
// Only the task ID within this one observation links the two records.
|
|
156
|
+
function reviewForTask(item: DashboardContribution, source: DashboardSourceSnapshot, stale: boolean) {
|
|
157
|
+
if (
|
|
158
|
+
stale ||
|
|
159
|
+
source.producer !== "bookie" ||
|
|
160
|
+
item.kind !== "work" ||
|
|
161
|
+
item.state !== "approval-wait" ||
|
|
162
|
+
!item.reference
|
|
163
|
+
)
|
|
164
|
+
return;
|
|
165
|
+
const matches = source.items.filter(
|
|
166
|
+
(candidate) =>
|
|
167
|
+
candidate.id === `review-${item.id}` &&
|
|
168
|
+
candidate.kind === "review" &&
|
|
169
|
+
candidate.state === "approval-wait" &&
|
|
170
|
+
candidate.reference,
|
|
171
|
+
);
|
|
172
|
+
return matches.length === 1 ? matches[0] : undefined;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// A Bookie task can publish its canonical document path as its only label.
|
|
176
|
+
// Abbreviate unambiguous sibling names while keeping the full path in Details.
|
|
177
|
+
function bookieLabel(item: DashboardContribution, source: DashboardSourceSnapshot): string {
|
|
178
|
+
if (reviewTotals(item)) return "Review totals";
|
|
179
|
+
if (item.kind !== "work" || !item.label.startsWith("/")) return item.label;
|
|
180
|
+
const name = (label: string) => label.split("/").at(-1)?.replace(/\.md$/i, "").replace(/[-_]+/g, " ");
|
|
181
|
+
const title = name(item.label);
|
|
182
|
+
if (
|
|
183
|
+
!title ||
|
|
184
|
+
!item.label.endsWith(".md") ||
|
|
185
|
+
source.items.some((other) => other.kind === "work" && other.id !== item.id && name(other.label) === title)
|
|
186
|
+
)
|
|
187
|
+
return item.label;
|
|
188
|
+
return title;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function rowText(item: DashboardItem, destination: DashboardDestination, selected: boolean): string {
|
|
192
|
+
const label = clean(item.label);
|
|
193
|
+
const marker = selected ? "> " : " ";
|
|
194
|
+
if (item.status === "last-observed") return `${marker}Last seen · ${label}`;
|
|
195
|
+
if (item.reviewSummary) return marker + label;
|
|
196
|
+
const waitingForReview = destination === "reviews" && item.status === "approval-wait";
|
|
197
|
+
const described = waitingForReview && /^ready for review[:\s]/i.test(label);
|
|
198
|
+
const status = described ? "" : ` · ${waitingForReview ? "Awaiting review" : friendlyStatus(clean(item.status))}`;
|
|
199
|
+
return `${marker}${label}${status}${item.elapsed ? " " + item.elapsed : ""}`;
|
|
200
|
+
}
|
|
201
|
+
export function sessionDashboardItems(options: DashboardScreenOptions): DashboardItem[] {
|
|
202
|
+
const observed = options.session!.observation!;
|
|
203
|
+
const destination = options.screen.destination ?? "now";
|
|
204
|
+
const staleOwner = options.connected === false;
|
|
205
|
+
const wanted =
|
|
206
|
+
destination === "work"
|
|
207
|
+
? ["work"]
|
|
208
|
+
: destination === "reviews"
|
|
209
|
+
? ["review"]
|
|
210
|
+
: destination === "evidence"
|
|
211
|
+
? ["evidence"]
|
|
212
|
+
: destination === "activity"
|
|
213
|
+
? ["status"]
|
|
214
|
+
: ["work", "status"];
|
|
215
|
+
const published = observed.sources.flatMap((source) =>
|
|
216
|
+
source.items
|
|
217
|
+
.filter(
|
|
218
|
+
(item) =>
|
|
219
|
+
wanted.includes(item.kind) &&
|
|
220
|
+
!(
|
|
221
|
+
destination === "reviews" &&
|
|
222
|
+
!options.screen.expanded &&
|
|
223
|
+
source.producer === "bookie" &&
|
|
224
|
+
reviewTotals(item) &&
|
|
225
|
+
source.items.some((other) => other.kind === "review" && other.id !== item.id)
|
|
226
|
+
) &&
|
|
227
|
+
!(source.producer === "daddy-initiative" && item.id === "scope" && ["now", "work"].includes(destination)),
|
|
228
|
+
)
|
|
229
|
+
.map((item) => {
|
|
230
|
+
const stale = staleSource(source, options);
|
|
231
|
+
return row(
|
|
232
|
+
item,
|
|
233
|
+
sourceKey(source, item),
|
|
234
|
+
`${source.producer}@${source.producerVersion} · seq ${source.sequence} · ${source.observedAt}`,
|
|
235
|
+
stale,
|
|
236
|
+
source.producer === "bookie" ? bookieLabel(item, source) : item.label,
|
|
237
|
+
reviewForTask(item, source, stale),
|
|
238
|
+
);
|
|
239
|
+
}),
|
|
240
|
+
);
|
|
241
|
+
if (destination === "reviews") {
|
|
242
|
+
const first = sessionNext(options)?.reviewKey;
|
|
243
|
+
const priority = (item: DashboardItem) =>
|
|
244
|
+
item.key === first ? 2 : Number(item.status === "approval-wait" && !item.reviewSummary);
|
|
245
|
+
return published.sort((a, b) => priority(b) - priority(a));
|
|
246
|
+
}
|
|
247
|
+
if (destination === "evidence")
|
|
248
|
+
return [
|
|
249
|
+
...(observed.artifacts ?? []).map((a) => ({
|
|
250
|
+
key: `artifact:${a.executionId}`,
|
|
251
|
+
label: a.operationId,
|
|
252
|
+
status: "retained",
|
|
253
|
+
elapsed: "",
|
|
254
|
+
details: [
|
|
255
|
+
`Producer: pi-daddy`,
|
|
256
|
+
`Execution: ${a.executionId}`,
|
|
257
|
+
`Manifest SHA-256: ${a.sha256}`,
|
|
258
|
+
"Producer reference observed in this session; payload not loaded by the dashboard.",
|
|
259
|
+
"Retained is not reviewed, applicable or approved. Use the authorized artifact resolver for content.",
|
|
260
|
+
],
|
|
261
|
+
})),
|
|
262
|
+
...published,
|
|
263
|
+
];
|
|
264
|
+
if (destination === "activity")
|
|
265
|
+
return [
|
|
266
|
+
...(observed.activity ?? [])
|
|
267
|
+
.slice()
|
|
268
|
+
.reverse()
|
|
269
|
+
.map((item) =>
|
|
270
|
+
row(item, `activity:${observed.generation}:${item.id}`, `Pi owner · ${observed.sessionId}`, staleOwner),
|
|
271
|
+
),
|
|
272
|
+
...published,
|
|
273
|
+
];
|
|
274
|
+
const native = options.items.map((item) =>
|
|
275
|
+
staleOwner
|
|
276
|
+
? {
|
|
277
|
+
...item,
|
|
278
|
+
status: "last-observed",
|
|
279
|
+
details: [...item.details, "Owner disconnected; current child liveness is unknown."],
|
|
280
|
+
}
|
|
281
|
+
: item,
|
|
282
|
+
);
|
|
283
|
+
const activity = options.session?.activity;
|
|
284
|
+
const parentShown =
|
|
285
|
+
activity && native.some((item) => item.taskKey === activityTaskKey(activity.rootId, activity.taskId));
|
|
286
|
+
const items = [
|
|
287
|
+
...(observed.turn && !parentShown
|
|
288
|
+
? [row(observed.turn, `owner:${observed.generation}:${observed.turn.id}`, "Pi owner", staleOwner)]
|
|
289
|
+
: []),
|
|
290
|
+
...native,
|
|
291
|
+
...published,
|
|
292
|
+
];
|
|
293
|
+
items.sort((a, b) => workGroups.indexOf(workGroup(a)) - workGroups.indexOf(workGroup(b)));
|
|
294
|
+
return items;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const workGroups = ["PERMISSION REQUESTS", "YOUR DECISIONS", "NEEDS ATTENTION", "IN PROGRESS", "OTHER WORK", "HISTORY"];
|
|
298
|
+
function workGroup(item: DashboardItem): string {
|
|
299
|
+
if (item.approval) return "PERMISSION REQUESTS";
|
|
300
|
+
if (item.status === "approval-wait") return "YOUR DECISIONS";
|
|
301
|
+
if (["needs-you", "failed", "refused", "incomplete", "dependency-wait"].includes(item.status))
|
|
302
|
+
return "NEEDS ATTENTION";
|
|
303
|
+
if (["running", "active", "starting", "authorised", "cancel-requested"].includes(item.status)) return "IN PROGRESS";
|
|
304
|
+
if (["settled", "completed", "finished", "cancelled", "historical", "last-observed"].includes(item.status))
|
|
305
|
+
return "HISTORY";
|
|
306
|
+
return "OTHER WORK";
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function listHeading(item: DashboardItem, destination: DashboardDestination) {
|
|
310
|
+
if (destination === "now" || destination === "work") return workGroup(item);
|
|
311
|
+
if (destination === "reviews")
|
|
312
|
+
return item.status === "approval-wait" && !item.reviewSummary ? "AWAITING REVIEW" : "REVIEW RECORDS";
|
|
313
|
+
return destination === "evidence" ? "SAVED REFERENCES" : "SESSION ACTIVITY";
|
|
314
|
+
}
|
|
315
|
+
export function sessionPanelLines(options: DashboardScreenOptions, items: DashboardItem[], width: number): string[] {
|
|
316
|
+
const observation = options.session!.observation!,
|
|
317
|
+
screen = options.screen;
|
|
318
|
+
const destination = screen.destination ?? "now";
|
|
319
|
+
const sourceRows = observation.sources.flatMap((s) => s.items.map((item) => ({ source: s, item })));
|
|
320
|
+
const lines: string[] = [];
|
|
321
|
+
const initiative = observation.sources.find((source) => source.producer === "daddy-initiative");
|
|
322
|
+
const scope = initiative?.items.find((item) => item.id === "scope");
|
|
323
|
+
if (scope && (destination === "now" || destination === "work")) {
|
|
324
|
+
lines.push(`SELECTED ${scope.label}${staleSource(initiative!, options) ? " (last observed)" : ""}`);
|
|
325
|
+
if (destination === "work" && scope.details?.[1]) lines.push(scope.details[1]);
|
|
326
|
+
}
|
|
327
|
+
if (destination === "now") {
|
|
328
|
+
const goals = sourceRows.filter((x) => x.item.kind === "goal");
|
|
329
|
+
const goal = goals.find((x) => !staleSource(x.source, options)) ?? goals[0];
|
|
330
|
+
if (goal) {
|
|
331
|
+
const name =
|
|
332
|
+
!screen.expanded && goal.source.producer === "bookie"
|
|
333
|
+
? goal.item.label.replace(/^\/projects\/([^/]+)\/project\.md$/, "$1")
|
|
334
|
+
: goal.item.label;
|
|
335
|
+
lines.push(
|
|
336
|
+
`Goal · ${clean(name)} (${goal.source.producer}${staleSource(goal.source, options) ? "; stale" : ""})`,
|
|
337
|
+
);
|
|
338
|
+
} else if (options.current) lines.push(`Goal · ${clean(options.current)}`);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (!items.length)
|
|
342
|
+
lines.push(
|
|
343
|
+
destination === "reviews"
|
|
344
|
+
? options.connected === false || observation.sources.some((s) => staleSource(s, options))
|
|
345
|
+
? "Current reviews unknown. Check the parent Pi session."
|
|
346
|
+
: "No reviews reported. [2] Work shows task progress."
|
|
347
|
+
: destination === "evidence"
|
|
348
|
+
? "No current-session result references observed."
|
|
349
|
+
: "No observations for this view.",
|
|
350
|
+
);
|
|
351
|
+
const left = previewWidth(destination, Boolean(screen.expanded), width);
|
|
352
|
+
const rows: string[] = [];
|
|
353
|
+
for (let start = 0; start < items.length;) {
|
|
354
|
+
const group = listHeading(items[start]!, destination);
|
|
355
|
+
let end = start + 1;
|
|
356
|
+
while (end < items.length && listHeading(items[end]!, destination) === group) end++;
|
|
357
|
+
rows.push(sectionHeading(`${group} · ${end - start}`, left ?? width));
|
|
358
|
+
for (const item of items.slice(start, end)) rows.push(rowText(item, destination, item.key === screen.selectedKey));
|
|
359
|
+
start = end;
|
|
360
|
+
}
|
|
361
|
+
lines.push(...rows);
|
|
362
|
+
if (screen.expanded && left === undefined) lines.push("Expanded layout needs 96 columns; same selection retained.");
|
|
363
|
+
if (destination === "now" && screen.expanded) {
|
|
364
|
+
lines.push(sectionHeading("COMPONENTS", width));
|
|
365
|
+
for (const producer of ["principal", "bookie", "scout", "skill-harness"]) {
|
|
366
|
+
const streams = observation.sources.filter(
|
|
367
|
+
(x) => x.producer === producer || (producer === "scout" && x.producer.startsWith("scout-")),
|
|
368
|
+
);
|
|
369
|
+
const stale = streams.filter((s) => staleSource(s, options)).length;
|
|
370
|
+
const status = !streams.length
|
|
371
|
+
? "status adapter unavailable"
|
|
372
|
+
: `${streams.length - stale} observed${stale ? `; ${stale} last observed / stale` : ""}`;
|
|
373
|
+
lines.push(`${producer}: ${status}`);
|
|
374
|
+
}
|
|
375
|
+
const resource = observation.resources;
|
|
376
|
+
lines.push(`Parent RSS: ${(resource.rssBytes / 1024 / 1024).toFixed(1)} MiB`, "Host and child memory: unknown");
|
|
377
|
+
}
|
|
378
|
+
return lines;
|
|
379
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { DashboardContribution } from "../kernel/dashboard-observation.ts";
|
|
2
|
+
import { staleSource } from "./dashboard-panels.ts";
|
|
3
|
+
import { truncate } from "./dashboard-render.ts";
|
|
4
|
+
import { dashboardText, type DashboardScreenOptions } from "./dashboard-screen.ts";
|
|
5
|
+
|
|
6
|
+
function eventLine(event: DashboardContribution): string {
|
|
7
|
+
const label = dashboardText(event.label).replace(/\s+/g, " ").trim();
|
|
8
|
+
if (label === "agent_start") return "Parent turn started";
|
|
9
|
+
if (label === "agent_end") return "Parent turn ended";
|
|
10
|
+
const tool = /^(.*): tool (start|end)$/.exec(label);
|
|
11
|
+
const name = truncate(tool?.[1] || label || "Event", 80);
|
|
12
|
+
if (event.state === "failed") return `${name} failed`;
|
|
13
|
+
return tool ? `${name} ${tool[2] === "start" ? "started" : "finished"}` : name;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Current owner hook events, newest first. Producer snapshots can describe current state only. */
|
|
17
|
+
export function sessionRecapLines(options: DashboardScreenOptions): string[] {
|
|
18
|
+
const session = options.session;
|
|
19
|
+
const observed = session?.observation;
|
|
20
|
+
if (!session || !observed)
|
|
21
|
+
return [
|
|
22
|
+
options.connected === false
|
|
23
|
+
? "Disconnected · no observed session activity."
|
|
24
|
+
: "No session activity has been observed.",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const lines: string[] = [];
|
|
28
|
+
if (options.connected === false) {
|
|
29
|
+
lines.push("Disconnected · last observed activity");
|
|
30
|
+
} else {
|
|
31
|
+
const work = observed.sources.find((source) => source.producer === "bookie" && !staleSource(source, options));
|
|
32
|
+
const ready = work?.items.filter(
|
|
33
|
+
(item) => item.kind === "review" && item.id !== "reviews" && item.state === "approval-wait" && item.reference,
|
|
34
|
+
).length;
|
|
35
|
+
const waiting = work?.items.filter((item) => item.kind === "work" && item.state === "dependency-wait").length;
|
|
36
|
+
if (session.pendingApprovals.length) lines.push(`Pending permissions: ${session.pendingApprovals.length}`);
|
|
37
|
+
if (ready) lines.push(`Ready for review · ${ready} shown by Bookie`);
|
|
38
|
+
if (waiting) lines.push(`Waiting on a dependency · ${waiting} shown by Bookie`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const recent = (observed.activity ?? []).slice(-5).reverse();
|
|
42
|
+
lines.push(
|
|
43
|
+
...(recent.length
|
|
44
|
+
? ["Recent activity · newest first", ...recent.map(eventLine)]
|
|
45
|
+
: ["No recent session events recorded."]),
|
|
46
|
+
);
|
|
47
|
+
return lines;
|
|
48
|
+
}
|