pi-daddy 0.51.0 → 0.52.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 +6 -0
- package/README.md +11 -32
- package/dist/governance/approval-prompt.d.ts +4 -0
- package/dist/governance/approval-prompt.d.ts.map +1 -1
- package/dist/governance/approval-prompt.js +4 -5
- package/dist/governance/approval-prompt.js.map +1 -1
- package/dist/governance/permission-question.d.ts +4 -0
- package/dist/governance/permission-question.d.ts.map +1 -0
- package/dist/governance/permission-question.js +102 -0
- package/dist/governance/permission-question.js.map +1 -0
- package/dist/kernel/chain.d.ts +1 -0
- package/dist/kernel/chain.d.ts.map +1 -1
- package/dist/kernel/chain.js.map +1 -1
- package/dist/kernel/dashboard-observation.d.ts +15 -5
- package/dist/kernel/dashboard-observation.d.ts.map +1 -1
- package/dist/kernel/dashboard-observation.js.map +1 -1
- package/dist/products/activity-summary.d.ts +8 -0
- package/dist/products/activity-summary.d.ts.map +1 -0
- package/dist/products/activity-summary.js +101 -0
- package/dist/products/activity-summary.js.map +1 -0
- package/dist/products/activity-timeline.d.ts +4 -1
- package/dist/products/activity-timeline.d.ts.map +1 -1
- package/dist/products/activity-timeline.js +9 -1
- package/dist/products/activity-timeline.js.map +1 -1
- package/dist/products/dashboard-activity.d.ts +9 -0
- package/dist/products/dashboard-activity.d.ts.map +1 -0
- package/dist/products/dashboard-activity.js +119 -0
- package/dist/products/dashboard-activity.js.map +1 -0
- package/dist/products/dashboard-cli.d.ts +2 -1
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +8 -5
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-components.d.ts +10 -0
- package/dist/products/dashboard-components.d.ts.map +1 -0
- package/dist/products/dashboard-components.js +196 -0
- package/dist/products/dashboard-components.js.map +1 -0
- package/dist/products/dashboard-layout.js +20 -4
- package/dist/products/dashboard-layout.js.map +1 -1
- package/dist/products/dashboard-panels.d.ts.map +1 -1
- package/dist/products/dashboard-panels.js +128 -67
- package/dist/products/dashboard-panels.js.map +1 -1
- package/dist/products/dashboard-recap.d.ts +1 -1
- package/dist/products/dashboard-recap.d.ts.map +1 -1
- package/dist/products/dashboard-recap.js +12 -16
- package/dist/products/dashboard-recap.js.map +1 -1
- package/dist/products/dashboard-screen.d.ts +5 -2
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +92 -36
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +6 -5
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/ecosystem-versions.d.ts +2 -0
- package/dist/products/ecosystem-versions.d.ts.map +1 -1
- package/extensions/activity-timeline.ts +7 -1
- package/extensions/approvals.ts +7 -0
- package/extensions/dashboard-live.ts +45 -5
- package/extensions/dashboard-observation.ts +1 -3
- package/extensions/delegate-chain.ts +2 -0
- package/extensions/delegation-artifacts.ts +26 -4
- package/extensions/delegation-operations.ts +12 -4
- package/extensions/delegation.ts +4 -0
- package/extensions/ecosystem-versions.ts +25 -3
- package/extensions/execute-child.ts +4 -0
- package/extensions/run-delegation.ts +2 -0
- package/extensions/runtime-snapshot.ts +8 -4
- package/extensions/session.ts +2 -2
- package/package.json +1 -1
- package/src/governance/approval-prompt.ts +7 -6
- package/src/governance/permission-question.ts +108 -0
- package/src/kernel/chain.ts +1 -0
- package/src/kernel/dashboard-observation.ts +15 -1
- package/src/products/activity-summary.ts +101 -0
- package/src/products/activity-timeline.ts +11 -0
- package/src/products/dashboard-activity.ts +136 -0
- package/src/products/dashboard-cli.ts +20 -6
- package/src/products/dashboard-components.ts +219 -0
- package/src/products/dashboard-layout.ts +27 -6
- package/src/products/dashboard-panels.ts +128 -76
- package/src/products/dashboard-recap.ts +15 -15
- package/src/products/dashboard-screen.ts +101 -38
- package/src/products/dashboard-session-client.ts +7 -1
- package/src/products/ecosystem-versions.ts +2 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/** Human readouts from observations already held by the parent. Rendering starts no probes. */
|
|
2
|
+
import type {
|
|
3
|
+
DashboardContribution,
|
|
4
|
+
DashboardSavedEvidence,
|
|
5
|
+
DashboardSourceSnapshot,
|
|
6
|
+
} from "../kernel/dashboard-observation.ts";
|
|
7
|
+
import type { DashboardItem, DashboardScreenOptions } from "./dashboard-screen.ts";
|
|
8
|
+
import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
|
|
9
|
+
import { safeDashboardSummary } from "./activity-summary.ts";
|
|
10
|
+
|
|
11
|
+
type KnownSource = "bookie" | "scout-local" | "scout-worker";
|
|
12
|
+
|
|
13
|
+
export function isComponentObservation(source: DashboardSourceSnapshot, item: DashboardContribution): boolean {
|
|
14
|
+
return (
|
|
15
|
+
(source.producer === "scout-local" || source.producer === "scout-worker") &&
|
|
16
|
+
item.id === "research" &&
|
|
17
|
+
item.kind === "work"
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function current(source: DashboardSourceSnapshot, options: DashboardScreenOptions): boolean {
|
|
22
|
+
const age = (options.now?.getTime() ?? Date.now()) - Date.parse(source.observedAt);
|
|
23
|
+
return (
|
|
24
|
+
options.connected !== false &&
|
|
25
|
+
source.availability === "observed" &&
|
|
26
|
+
Number.isFinite(age) &&
|
|
27
|
+
age >= 0 &&
|
|
28
|
+
age <= source.staleAfterMs
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function scoutDescription(worker: boolean, item: DashboardContribution): [string, string] {
|
|
33
|
+
switch (item.state) {
|
|
34
|
+
case "observed":
|
|
35
|
+
return worker
|
|
36
|
+
? ["Docker untested", "Pi has loaded the research worker. No Docker or internet check was reported."]
|
|
37
|
+
: ["Available", "Pi has loaded the local research tools. Source availability depends on the selected catalog."];
|
|
38
|
+
case "running":
|
|
39
|
+
return worker
|
|
40
|
+
? ["Preparing research", "Scout is preparing or running a research worker. A result is still pending."]
|
|
41
|
+
: ["Research in progress", "Scout is working with the selected sources."];
|
|
42
|
+
case "settled":
|
|
43
|
+
return [
|
|
44
|
+
"Brief saved",
|
|
45
|
+
worker
|
|
46
|
+
? "Scout saved the brief and confirmed worker cleanup. The report does not identify whether it used the internet."
|
|
47
|
+
: "Scout saved a local brief. Open Saved results to inspect the source record.",
|
|
48
|
+
];
|
|
49
|
+
case "failed":
|
|
50
|
+
return ["Last attempt failed", "Open the Scout tool result in the main Pi chat for the reason."];
|
|
51
|
+
case "unknown":
|
|
52
|
+
return [
|
|
53
|
+
"Outcome unknown",
|
|
54
|
+
worker
|
|
55
|
+
? "Check the last Scout tool result and Docker cleanup before starting more research."
|
|
56
|
+
: "Check the last Scout tool result in the main Pi chat.",
|
|
57
|
+
];
|
|
58
|
+
case "unavailable":
|
|
59
|
+
return ["Unavailable", "Open the Scout tool result in the main Pi chat for the reported issue."];
|
|
60
|
+
case "dependency-wait":
|
|
61
|
+
return ["Waiting on a dependency", "Scout is waiting for a required part of the task."];
|
|
62
|
+
case "approval-wait":
|
|
63
|
+
return ["Waiting for you", "Check the request in the main Pi chat."];
|
|
64
|
+
case "cancel-requested":
|
|
65
|
+
return ["Stopping", "Scout has received a cancellation request. Cleanup is still pending."];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function componentItem(producer: KnownSource, options: DashboardScreenOptions): DashboardItem | undefined {
|
|
70
|
+
const bookie = producer === "bookie";
|
|
71
|
+
const worker = producer === "scout-worker";
|
|
72
|
+
const title = bookie ? "Bookie memory" : worker ? "Scout research worker" : "Scout local sources";
|
|
73
|
+
const source = options.session?.observation?.sources.find((s) => s.producer === producer);
|
|
74
|
+
const pkg = options.session?.versions?.rows.find((r) => r.id === (bookie ? "bookie-pi-skills" : "pi-scout-research"));
|
|
75
|
+
if (!source && !(pkg?.source || pkg?.loadedVersion || pkg?.installedVersion || pkg?.state === "multiple")) return;
|
|
76
|
+
const item = source?.items.find((i) => isComponentObservation(source, i));
|
|
77
|
+
let state = "observed",
|
|
78
|
+
status: string,
|
|
79
|
+
explanation: string;
|
|
80
|
+
if (options.connected === false || (source && !current(source, options))) {
|
|
81
|
+
state = "last-observed";
|
|
82
|
+
status = "Live status unknown";
|
|
83
|
+
const lastReport = item
|
|
84
|
+
? scoutDescription(worker, item)[0]
|
|
85
|
+
: bookie && source?.items.some((i) => i.kind === "goal" && i.id === "scope")
|
|
86
|
+
? "Project connected"
|
|
87
|
+
: undefined;
|
|
88
|
+
explanation = (lastReport ? `Last report: ${lastReport}. ` : "") + "Check the main Pi chat for current status.";
|
|
89
|
+
} else if (bookie && source?.items.length) {
|
|
90
|
+
status = "Project connected";
|
|
91
|
+
explanation = "Bookie is sharing the selected project’s work with Pi.";
|
|
92
|
+
} else if (item) {
|
|
93
|
+
state = item.state;
|
|
94
|
+
[status, explanation] = scoutDescription(worker, item);
|
|
95
|
+
} else if (bookie && (pkg?.commandAvailable || pkg?.loadedVersion)) {
|
|
96
|
+
status = "Available · no project reported";
|
|
97
|
+
explanation = "Run /bookie-work in the main Pi chat to select a project and plan.";
|
|
98
|
+
} else {
|
|
99
|
+
status =
|
|
100
|
+
pkg?.state === "multiple"
|
|
101
|
+
? "Multiple installations"
|
|
102
|
+
: pkg?.installedVersion
|
|
103
|
+
? "Installed · no live report"
|
|
104
|
+
: "No live report";
|
|
105
|
+
explanation = bookie
|
|
106
|
+
? "Check for /bookie-work in the main Pi chat and select a project. Open Versions for installation details."
|
|
107
|
+
: "Check the loaded Scout extension in the main Pi chat. Research readiness has not been reported.";
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
key: `component:${producer}`,
|
|
111
|
+
label: `${title} · ${status}`,
|
|
112
|
+
status: state,
|
|
113
|
+
elapsed: "",
|
|
114
|
+
briefDetails: [explanation],
|
|
115
|
+
details: [
|
|
116
|
+
explanation,
|
|
117
|
+
...(source
|
|
118
|
+
? [`Source: ${source.producer} · ${source.producerVersion}`, `Last update: ${source.observedAt}`]
|
|
119
|
+
: []),
|
|
120
|
+
...(item?.details ?? []),
|
|
121
|
+
...(pkg?.installedVersion ? [`Installed version: ${pkg.installedVersion}`] : []),
|
|
122
|
+
...(pkg?.loadedVersion ? [`Running version: ${pkg.loadedVersion}`] : []),
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function componentItems(options: DashboardScreenOptions): DashboardItem[] {
|
|
128
|
+
return (["bookie", "scout-local", "scout-worker"] as const)
|
|
129
|
+
.map((id) => componentItem(id, options))
|
|
130
|
+
.filter((item): item is DashboardItem => item !== undefined);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function versionLines(row: EcosystemVersionRow, selected: boolean, options: DashboardScreenOptions): string[] {
|
|
134
|
+
const prefix = selected ? "> " : " ";
|
|
135
|
+
const bookieSource =
|
|
136
|
+
row.id === "bookie-pi-skills" && options.session?.observation?.sources.find((s) => s.producer === "bookie");
|
|
137
|
+
let detail: string;
|
|
138
|
+
if (options.connected === false) detail = "Last seen. Reconnect for the running version.";
|
|
139
|
+
else if (row.state === "multiple") detail = "Multiple installations. Open details to check the sources.";
|
|
140
|
+
else if (row.loadedVersion && row.installedVersion && row.loadedVersion !== row.installedVersion)
|
|
141
|
+
detail = `Running ${row.loadedVersion}. ${row.id === "pi" ? "Restart" : "Reload"} Pi to use the installed version.`;
|
|
142
|
+
else if (row.loadedVersion) detail = `Running ${row.loadedVersion}`;
|
|
143
|
+
else if (row.commandAvailable || (bookieSource && current(bookieSource, options)))
|
|
144
|
+
detail = "Active in Pi. Running version unreported.";
|
|
145
|
+
else detail = row.installedVersion ? "Pi has not reported a running version." : "No running version reported.";
|
|
146
|
+
return [
|
|
147
|
+
prefix +
|
|
148
|
+
row.label +
|
|
149
|
+
(row.installedVersion ? ` · Installed ${row.installedVersion}` : " · Installation unconfirmed"),
|
|
150
|
+
" " + detail,
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function savedEvidenceItem(artifact: DashboardSavedEvidence, index: number): DashboardItem {
|
|
155
|
+
const result = artifact.description;
|
|
156
|
+
const role = result?.agent?.replace(/[-_]/g, " ");
|
|
157
|
+
const who = role ? role.charAt(0).toUpperCase() + role.slice(1) : "Agent";
|
|
158
|
+
const kind =
|
|
159
|
+
result?.content === "answer" ? "answer" : result?.content === "partial" ? "partial output" : "run record";
|
|
160
|
+
const label = result?.summary ? `${who} · ${result.summary}` : result ? `${who} ${kind}` : `Run record ${index + 1}`;
|
|
161
|
+
const status =
|
|
162
|
+
result?.state === "not-started"
|
|
163
|
+
? "Did not start"
|
|
164
|
+
: result?.state === "uncertain"
|
|
165
|
+
? "Outcome uncertain"
|
|
166
|
+
: result?.state === "failed"
|
|
167
|
+
? "Run failed"
|
|
168
|
+
: result?.content === "partial"
|
|
169
|
+
? "Partial output saved"
|
|
170
|
+
: "Saved";
|
|
171
|
+
const brief =
|
|
172
|
+
result?.content === "answer"
|
|
173
|
+
? `Pi saved the final answer from this ${role ?? "agent"} run.`
|
|
174
|
+
: result?.content === "partial"
|
|
175
|
+
? "Pi saved partial output from this run."
|
|
176
|
+
: "Pi saved a record of this run. Open source details for its exact reference.";
|
|
177
|
+
return {
|
|
178
|
+
key: `artifact:${artifact.executionId}`,
|
|
179
|
+
label,
|
|
180
|
+
status,
|
|
181
|
+
elapsed: "",
|
|
182
|
+
briefDetails: [brief, ...(result?.observedAt ? [`Recorded: ${result.observedAt}`] : [])],
|
|
183
|
+
details: [
|
|
184
|
+
`Operation: ${artifact.operationId}`,
|
|
185
|
+
`Execution: ${artifact.executionId}`,
|
|
186
|
+
`Manifest SHA-256: ${artifact.sha256}`,
|
|
187
|
+
"Producer: pi-daddy",
|
|
188
|
+
"A saved record alone gives no review or approval verdict.",
|
|
189
|
+
],
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function publishedEvidenceItem(
|
|
194
|
+
source: DashboardSourceSnapshot,
|
|
195
|
+
evidence: DashboardContribution,
|
|
196
|
+
display: DashboardItem,
|
|
197
|
+
): DashboardItem {
|
|
198
|
+
const scout = source.producer === "scout-worker" || source.producer === "scout-local";
|
|
199
|
+
const author = scout ? "Scout" : source.producer === "bookie" ? "Bookie" : "A connected tool";
|
|
200
|
+
const readable = safeDashboardSummary(evidence.label);
|
|
201
|
+
const title =
|
|
202
|
+
scout && evidence.id === "brief"
|
|
203
|
+
? source.producer === "scout-worker"
|
|
204
|
+
? "Scout research brief"
|
|
205
|
+
: "Scout local brief"
|
|
206
|
+
: readable && !/\S[/\\]\S|\b(?:sha\d*|principal):/i.test(readable)
|
|
207
|
+
? readable
|
|
208
|
+
: `${author === "A connected tool" ? "Tool" : author} evidence record`;
|
|
209
|
+
return {
|
|
210
|
+
...display,
|
|
211
|
+
label: title,
|
|
212
|
+
status: display.status === "observed" ? (evidence.reference ? "Reference saved" : "Recorded") : display.status,
|
|
213
|
+
briefDetails: [
|
|
214
|
+
`${author} reported this ${scout && evidence.id === "brief" ? "research brief" : "result"} in this session.`,
|
|
215
|
+
...(evidence.reference ? ["Open source details for the exact reference."] : []),
|
|
216
|
+
],
|
|
217
|
+
details: [...display.details, ...(title !== evidence.label ? [`Original label: ${evidence.label}`] : [])],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
@@ -7,8 +7,8 @@ export function sectionHeading(title: string, width: number): string {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function previewWidth(destination: string, expanded: boolean, width: number): number | undefined {
|
|
10
|
-
if (width <
|
|
11
|
-
return Math.min(
|
|
10
|
+
if (width < 82 || (!expanded && (width < 92 || !["now", "work", "reviews"].includes(destination)))) return;
|
|
11
|
+
return Math.min(84, Math.floor(width * 0.57));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const sgr = (value: string, code: string) => (value ? `\x1b[${code}m${value}\x1b[0m` : "");
|
|
@@ -38,11 +38,32 @@ function paintCell(cell: string): string {
|
|
|
38
38
|
const rule = /^(.*?) (─{3,})$/.exec(text);
|
|
39
39
|
if (rule) {
|
|
40
40
|
const title = rule[1]!;
|
|
41
|
-
const attention =
|
|
42
|
-
|
|
41
|
+
const attention = /^(?:Next step|Needs |Waiting for your review|NEXT ACTION)/i.test(title);
|
|
42
|
+
return (
|
|
43
|
+
sgr(
|
|
43
44
|
title,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
attention ? "1;33" : /^(Recently finished|Saved results|What happened)/.test(title) ? "1;32" : "1;36",
|
|
46
|
+
) +
|
|
47
|
+
" " +
|
|
48
|
+
sgr(rule[2]!, "36") +
|
|
49
|
+
padding
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (/^ /.test(text)) {
|
|
53
|
+
const status =
|
|
54
|
+
/( · )(Failed|Blocked|Run failed|Last attempt failed|Unavailable|Awaiting decision|Needs you|Live status unknown|Running|Finished|Saved|Available)(?= |$| ·)/;
|
|
55
|
+
return (
|
|
56
|
+
text.replace(status, (_, separator, state) => {
|
|
57
|
+
const color = /Failed|failed|Blocked|Unavailable/.test(state)
|
|
58
|
+
? "1;31"
|
|
59
|
+
: /Awaiting|Needs you|unknown/.test(state)
|
|
60
|
+
? "33"
|
|
61
|
+
: state === "Running"
|
|
62
|
+
? "36"
|
|
63
|
+
: "32";
|
|
64
|
+
return separator + sgr(state, color);
|
|
65
|
+
}) + padding
|
|
66
|
+
);
|
|
46
67
|
}
|
|
47
68
|
if (text === "/bookie-work review") return sgr(text, "1;36") + padding;
|
|
48
69
|
if (/^(?:!|LAST OBSERVED|Disconnected)/.test(text)) return sgr(text, "1;33") + padding;
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import type { DashboardContribution, DashboardSourceSnapshot } from "../kernel/dashboard-observation.ts";
|
|
3
3
|
import type { DashboardItem, DashboardScreenOptions } from "./dashboard-screen.ts";
|
|
4
4
|
import { dashboardText, friendlyStatus } from "./dashboard-screen.ts";
|
|
5
|
+
import { activityStoryItems } from "./dashboard-activity.ts";
|
|
6
|
+
import {
|
|
7
|
+
componentItems,
|
|
8
|
+
isComponentObservation,
|
|
9
|
+
publishedEvidenceItem,
|
|
10
|
+
savedEvidenceItem,
|
|
11
|
+
} from "./dashboard-components.ts";
|
|
5
12
|
import { previewWidth, sectionHeading } from "./dashboard-layout.ts";
|
|
6
13
|
import { activityTaskKey } from "./activity-timeline.ts";
|
|
7
14
|
export type DashboardDestination = "now" | "work" | "reviews" | "activity" | "evidence" | "settings";
|
|
@@ -191,8 +198,10 @@ function bookieLabel(item: DashboardContribution, source: DashboardSourceSnapsho
|
|
|
191
198
|
function rowText(item: DashboardItem, destination: DashboardDestination, selected: boolean): string {
|
|
192
199
|
const label = clean(item.label);
|
|
193
200
|
const marker = selected ? "> " : " ";
|
|
201
|
+
if (item.key.startsWith("component:")) return marker + label;
|
|
194
202
|
if (item.status === "last-observed") return `${marker}Last seen · ${label}`;
|
|
195
203
|
if (item.reviewSummary) return marker + label;
|
|
204
|
+
if (item.key.startsWith("activity:") && item.status === "observed") return marker + label;
|
|
196
205
|
const waitingForReview = destination === "reviews" && item.status === "approval-wait";
|
|
197
206
|
const described = waitingForReview && /^ready for review[:\s]/i.test(label);
|
|
198
207
|
const status = described ? "" : ` · ${waitingForReview ? "Awaiting review" : friendlyStatus(clean(item.status))}`;
|
|
@@ -211,12 +220,13 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
211
220
|
? ["evidence"]
|
|
212
221
|
: destination === "activity"
|
|
213
222
|
? ["status"]
|
|
214
|
-
: ["work"
|
|
223
|
+
: ["work"];
|
|
215
224
|
const published = observed.sources.flatMap((source) =>
|
|
216
225
|
source.items
|
|
217
226
|
.filter(
|
|
218
227
|
(item) =>
|
|
219
228
|
wanted.includes(item.kind) &&
|
|
229
|
+
!isComponentObservation(source, item) &&
|
|
220
230
|
!(
|
|
221
231
|
destination === "reviews" &&
|
|
222
232
|
!options.screen.expanded &&
|
|
@@ -228,14 +238,17 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
228
238
|
)
|
|
229
239
|
.map((item) => {
|
|
230
240
|
const stale = staleSource(source, options);
|
|
231
|
-
|
|
241
|
+
const linked = reviewForTask(item, source, stale);
|
|
242
|
+
const display = row(
|
|
232
243
|
item,
|
|
233
244
|
sourceKey(source, item),
|
|
234
245
|
`${source.producer}@${source.producerVersion} · seq ${source.sequence} · ${source.observedAt}`,
|
|
235
246
|
stale,
|
|
236
247
|
source.producer === "bookie" ? bookieLabel(item, source) : item.label,
|
|
237
|
-
|
|
248
|
+
linked,
|
|
238
249
|
);
|
|
250
|
+
if (linked) display.relatedReviewKey = sourceKey(source, linked);
|
|
251
|
+
return item.kind === "evidence" ? publishedEvidenceItem(source, item, display) : display;
|
|
239
252
|
}),
|
|
240
253
|
);
|
|
241
254
|
if (destination === "reviews") {
|
|
@@ -244,33 +257,9 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
244
257
|
item.key === first ? 2 : Number(item.status === "approval-wait" && !item.reviewSummary);
|
|
245
258
|
return published.sort((a, b) => priority(b) - priority(a));
|
|
246
259
|
}
|
|
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
|
-
];
|
|
260
|
+
if (destination === "evidence") return [...(observed.artifacts ?? []).map(savedEvidenceItem), ...published];
|
|
264
261
|
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
|
-
];
|
|
262
|
+
return [...activityStoryItems(observed.activity ?? [], observed.generation, staleOwner), ...published];
|
|
274
263
|
const native = options.items.map((item) =>
|
|
275
264
|
staleOwner
|
|
276
265
|
? {
|
|
@@ -283,34 +272,98 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
283
272
|
const activity = options.session?.activity;
|
|
284
273
|
const parentShown =
|
|
285
274
|
activity && native.some((item) => item.taskKey === activityTaskKey(activity.rootId, activity.taskId));
|
|
275
|
+
const ownerTurn = observed.turn;
|
|
276
|
+
const tasks = native.map((item) => {
|
|
277
|
+
// A running parent can supply a more recent public tool purpose than its persisted start record.
|
|
278
|
+
if (
|
|
279
|
+
activity &&
|
|
280
|
+
item.taskKey === activityTaskKey(activity.rootId, activity.taskId) &&
|
|
281
|
+
ownerTurn?.state === "running" &&
|
|
282
|
+
!staleOwner &&
|
|
283
|
+
["running", "active"].includes(item.status)
|
|
284
|
+
)
|
|
285
|
+
return { ...item, label: ownerTurn.label };
|
|
286
|
+
return item;
|
|
287
|
+
});
|
|
286
288
|
const items = [
|
|
287
|
-
...(
|
|
288
|
-
? [row(
|
|
289
|
+
...(ownerTurn && !parentShown
|
|
290
|
+
? [row(ownerTurn, `owner:${observed.generation}:${ownerTurn.id}`, "Pi owner", staleOwner)]
|
|
289
291
|
: []),
|
|
290
|
-
...
|
|
292
|
+
...tasks,
|
|
291
293
|
...published,
|
|
292
294
|
];
|
|
293
|
-
items.sort((a, b) =>
|
|
294
|
-
|
|
295
|
+
items.sort((a, b) => {
|
|
296
|
+
const rank = workGroups.indexOf(workGroup(a)) - workGroups.indexOf(workGroup(b));
|
|
297
|
+
return rank || (workGroup(a) === "Recently finished" ? (b.updatedAt ?? "").localeCompare(a.updatedAt ?? "") : 0);
|
|
298
|
+
});
|
|
299
|
+
if (destination !== "now") return items;
|
|
300
|
+
// Tasks has the complete queue. Keep the overview navigable even after a long session.
|
|
301
|
+
// A producer may publish a review without a matching task or a recommended next action.
|
|
302
|
+
const represented = new Set(items.map((i) => i.relatedReviewKey).filter(Boolean));
|
|
303
|
+
for (const source of observed.sources) {
|
|
304
|
+
if (staleSource(source, options)) continue;
|
|
305
|
+
for (const review of source.items) {
|
|
306
|
+
const key = sourceKey(source, review);
|
|
307
|
+
if (
|
|
308
|
+
review.kind === "review" &&
|
|
309
|
+
review.state === "approval-wait" &&
|
|
310
|
+
review.reference &&
|
|
311
|
+
!reviewTotals(review) &&
|
|
312
|
+
!represented.has(key)
|
|
313
|
+
)
|
|
314
|
+
items.push(row(review, key, `${source.producer}@${source.producerVersion}`));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const nextReview = sessionNext(options)?.reviewKey;
|
|
318
|
+
if (nextReview) {
|
|
319
|
+
const index = items.findIndex((i) => i.relatedReviewKey === nextReview || i.key === nextReview);
|
|
320
|
+
// Keep task rows ahead of independent review rows; Reviews opens the exact recommended output.
|
|
321
|
+
if (index > 0 && items[index]?.relatedReviewKey === nextReview) items.unshift(items.splice(index, 1)[0]!);
|
|
322
|
+
}
|
|
323
|
+
const shown = workGroups.flatMap((group) => {
|
|
324
|
+
const matches = items.filter((item) => workGroup(item) === group);
|
|
325
|
+
return matches.slice(0, group === "Recently finished" ? 2 : 3);
|
|
326
|
+
});
|
|
327
|
+
const recent = shown.some((i) => workGroup(i) === "Recently finished")
|
|
328
|
+
? []
|
|
329
|
+
: activityStoryItems(observed.activity ?? [], observed.generation, staleOwner).slice(0, 2);
|
|
330
|
+
return [...shown, ...recent, ...componentItems(options)];
|
|
295
331
|
}
|
|
296
332
|
|
|
297
|
-
const workGroups = [
|
|
333
|
+
const workGroups = [
|
|
334
|
+
"Needs your permission",
|
|
335
|
+
"Needs your decision",
|
|
336
|
+
"Needs attention",
|
|
337
|
+
"In progress",
|
|
338
|
+
"Other tasks",
|
|
339
|
+
"Recently finished",
|
|
340
|
+
"Last known",
|
|
341
|
+
"Tools",
|
|
342
|
+
];
|
|
298
343
|
function workGroup(item: DashboardItem): string {
|
|
299
|
-
if (item.
|
|
300
|
-
if (item.
|
|
344
|
+
if (item.key.startsWith("component:")) return "Tools";
|
|
345
|
+
if (item.key.startsWith("activity:")) return "Latest activity";
|
|
346
|
+
if (["last-observed", "historical"].includes(item.status)) return "Last known";
|
|
347
|
+
if (item.approval) return "Needs your permission";
|
|
348
|
+
if (item.status === "approval-wait") return "Needs your decision";
|
|
301
349
|
if (["needs-you", "failed", "refused", "incomplete", "dependency-wait"].includes(item.status))
|
|
302
|
-
return "
|
|
303
|
-
if (["running", "active", "starting", "authorised", "cancel-requested"].includes(item.status)) return "
|
|
350
|
+
return "Needs attention";
|
|
351
|
+
if (["running", "active", "starting", "authorised", "cancel-requested"].includes(item.status)) return "In progress";
|
|
304
352
|
if (["settled", "completed", "finished", "cancelled", "historical", "last-observed"].includes(item.status))
|
|
305
|
-
return "
|
|
306
|
-
return "
|
|
353
|
+
return "Recently finished";
|
|
354
|
+
return "Other tasks";
|
|
307
355
|
}
|
|
308
356
|
|
|
309
357
|
function listHeading(item: DashboardItem, destination: DashboardDestination) {
|
|
310
|
-
if (destination === "now" || destination === "work")
|
|
358
|
+
if (destination === "now" || destination === "work")
|
|
359
|
+
return destination === "work" && workGroup(item) === "Recently finished" ? "Finished" : workGroup(item);
|
|
311
360
|
if (destination === "reviews")
|
|
312
|
-
return item.status === "approval-wait" && !item.reviewSummary ? "
|
|
313
|
-
return destination === "evidence"
|
|
361
|
+
return item.status === "approval-wait" && !item.reviewSummary ? "Waiting for your review" : "Review records";
|
|
362
|
+
return destination === "evidence"
|
|
363
|
+
? "Saved results"
|
|
364
|
+
: item.key.startsWith("source:")
|
|
365
|
+
? "Current reports"
|
|
366
|
+
: "What happened";
|
|
314
367
|
}
|
|
315
368
|
export function sessionPanelLines(options: DashboardScreenOptions, items: DashboardItem[], width: number): string[] {
|
|
316
369
|
const observation = options.session!.observation!,
|
|
@@ -320,58 +373,57 @@ export function sessionPanelLines(options: DashboardScreenOptions, items: Dashbo
|
|
|
320
373
|
const lines: string[] = [];
|
|
321
374
|
const initiative = observation.sources.find((source) => source.producer === "daddy-initiative");
|
|
322
375
|
const scope = initiative?.items.find((item) => item.id === "scope");
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
376
|
+
const roomy = options.height >= 22;
|
|
377
|
+
if (destination === "work") {
|
|
378
|
+
lines.push("All session tasks, grouped by status.");
|
|
379
|
+
if (scope) {
|
|
380
|
+
lines.push(`Selected ${clean(scope.label)}${staleSource(initiative!, options) ? " (last known)" : ""}`);
|
|
381
|
+
if (scope.details?.[1]) lines.push(scope.details[1]);
|
|
382
|
+
}
|
|
326
383
|
}
|
|
327
384
|
if (destination === "now") {
|
|
328
385
|
const goals = sourceRows.filter((x) => x.item.kind === "goal");
|
|
329
386
|
const goal = goals.find((x) => !staleSource(x.source, options)) ?? goals[0];
|
|
330
387
|
if (goal) {
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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)}`);
|
|
388
|
+
const project = goal.source.producer === "bookie" && /^\/projects\/([^/]+)\/project\.md$/.exec(goal.item.label);
|
|
389
|
+
lines.push(project ? `Project · ${clean(project[1]!)}` : `Goal · ${clean(goal.item.label)}`);
|
|
390
|
+
if (staleSource(goal.source, options)) lines[lines.length - 1] += " (last known)";
|
|
391
|
+
}
|
|
339
392
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
lines.push(
|
|
393
|
+
if (!items.length) {
|
|
394
|
+
const fallback =
|
|
343
395
|
destination === "reviews"
|
|
344
396
|
? options.connected === false || observation.sources.some((s) => staleSource(s, options))
|
|
345
|
-
? "Current reviews unknown. Check the
|
|
346
|
-
: "No reviews
|
|
397
|
+
? "Current reviews unknown. Check the main Pi chat."
|
|
398
|
+
: "No reviews waiting. Open [2] Tasks to see progress."
|
|
347
399
|
: destination === "evidence"
|
|
348
|
-
? "No
|
|
349
|
-
:
|
|
350
|
-
|
|
400
|
+
? "No saved results reported to this dashboard."
|
|
401
|
+
: destination === "activity"
|
|
402
|
+
? "No activity has been recorded in this session yet."
|
|
403
|
+
: "No tasks reported for this session yet.";
|
|
404
|
+
lines.push(fallback);
|
|
405
|
+
}
|
|
351
406
|
const left = previewWidth(destination, Boolean(screen.expanded), width);
|
|
352
407
|
const rows: string[] = [];
|
|
353
408
|
for (let start = 0; start < items.length;) {
|
|
354
409
|
const group = listHeading(items[start]!, destination);
|
|
355
410
|
let end = start + 1;
|
|
356
411
|
while (end < items.length && listHeading(items[end]!, destination) === group) end++;
|
|
357
|
-
|
|
412
|
+
if (roomy && (rows.length || lines.length)) rows.push("");
|
|
413
|
+
const count = destination === "now" ? "" : ` · ${end - start}`;
|
|
414
|
+
rows.push(sectionHeading(group + count, left ?? width));
|
|
358
415
|
for (const item of items.slice(start, end)) rows.push(rowText(item, destination, item.key === screen.selectedKey));
|
|
359
416
|
start = end;
|
|
360
417
|
}
|
|
361
418
|
lines.push(...rows);
|
|
362
|
-
if (
|
|
419
|
+
if (destination === "now" && options.height >= 18 && items.some((i) => !i.key.startsWith("component:"))) {
|
|
420
|
+
if (roomy) lines.push("");
|
|
421
|
+
lines.push("[2] Tasks · See the full task list");
|
|
422
|
+
}
|
|
423
|
+
if (screen.expanded && left === undefined)
|
|
424
|
+
lines.push("Side-by-side layout needs 82 columns; same selection retained.");
|
|
363
425
|
if (destination === "now" && screen.expanded) {
|
|
364
|
-
lines.push(sectionHeading("
|
|
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
|
-
}
|
|
426
|
+
lines.push(sectionHeading("Resource details", width));
|
|
375
427
|
const resource = observation.resources;
|
|
376
428
|
lines.push(`Parent RSS: ${(resource.rssBytes / 1024 / 1024).toFixed(1)} MiB`, "Host and child memory: unknown");
|
|
377
429
|
}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { activityStoryItems } from "./dashboard-activity.ts";
|
|
2
2
|
import { staleSource } from "./dashboard-panels.ts";
|
|
3
|
-
import {
|
|
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
|
-
}
|
|
3
|
+
import type { DashboardScreenOptions } from "./dashboard-screen.ts";
|
|
15
4
|
|
|
16
5
|
/** Current owner hook events, newest first. Producer snapshots can describe current state only. */
|
|
17
6
|
export function sessionRecapLines(options: DashboardScreenOptions): string[] {
|
|
@@ -38,10 +27,21 @@ export function sessionRecapLines(options: DashboardScreenOptions): string[] {
|
|
|
38
27
|
if (waiting) lines.push(`Waiting on a dependency · ${waiting} shown by Bookie`);
|
|
39
28
|
}
|
|
40
29
|
|
|
41
|
-
const recent = (observed.activity ?? []).slice(
|
|
30
|
+
const recent = activityStoryItems(observed.activity ?? [], observed.generation, false).slice(0, 5);
|
|
42
31
|
lines.push(
|
|
43
32
|
...(recent.length
|
|
44
|
-
? [
|
|
33
|
+
? [
|
|
34
|
+
"Recent activity · newest first",
|
|
35
|
+
...recent.map((item) =>
|
|
36
|
+
item.status === "failed"
|
|
37
|
+
? `Failed · ${item.label}`
|
|
38
|
+
: item.status === "finished"
|
|
39
|
+
? `Finished · ${item.label}`
|
|
40
|
+
: item.status === "Started"
|
|
41
|
+
? `Started · ${item.label}`
|
|
42
|
+
: item.label,
|
|
43
|
+
),
|
|
44
|
+
]
|
|
45
45
|
: ["No recent session events recorded."]),
|
|
46
46
|
);
|
|
47
47
|
return lines;
|