pi-daddy 0.51.0 → 0.53.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 +11 -0
- package/README.md +33 -42
- 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 +28 -6
- 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-display-controls.js +3 -3
- package/dist/products/dashboard-display-controls.js.map +1 -1
- package/dist/products/dashboard-handshake.d.ts +2 -0
- package/dist/products/dashboard-handshake.d.ts.map +1 -1
- package/dist/products/dashboard-handshake.js +39 -43
- package/dist/products/dashboard-handshake.js.map +1 -1
- package/dist/products/dashboard-herdr.d.ts.map +1 -1
- package/dist/products/dashboard-herdr.js +7 -1
- package/dist/products/dashboard-herdr.js.map +1 -1
- 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 +6 -2
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +104 -37
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +10 -6
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +14 -10
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/dashboard-settings.d.ts +10 -1
- package/dist/products/dashboard-settings.d.ts.map +1 -1
- package/dist/products/dashboard-settings.js +26 -1
- package/dist/products/dashboard-settings.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/dashboard-session-server.ts +6 -1
- package/extensions/dashboard-settings.ts +15 -1
- 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/grants.ts +10 -4
- package/extensions/run-delegation.ts +2 -0
- package/extensions/runtime-snapshot.ts +8 -4
- package/extensions/session-report.ts +4 -0
- package/extensions/session.ts +4 -3
- package/package.json +2 -2
- 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 +37 -8
- package/src/products/dashboard-components.ts +219 -0
- package/src/products/dashboard-display-controls.ts +3 -3
- package/src/products/dashboard-handshake.ts +45 -49
- package/src/products/dashboard-herdr.ts +9 -1
- 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 +115 -39
- package/src/products/dashboard-session-client.ts +23 -12
- package/src/products/dashboard-settings.ts +36 -2
- 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
|
+
}
|
|
@@ -93,9 +93,9 @@ export function createDashboardDisplayControls(details: boolean, ledger: boolean
|
|
|
93
93
|
screen.manualScroll = false;
|
|
94
94
|
const delta = key === "up" || key === "k" ? -1 : 1;
|
|
95
95
|
if (screen.view === "settings") {
|
|
96
|
-
const
|
|
97
|
-
screen.settingKey
|
|
98
|
-
|
|
96
|
+
const keys = screen.settingKeys ?? DASHBOARD_SETTING_KEYS;
|
|
97
|
+
const index = keys.indexOf(screen.settingKey ?? "auto");
|
|
98
|
+
screen.settingKey = keys[Math.max(0, Math.min(keys.length - 1, index + delta))];
|
|
99
99
|
} else if (screen.view === "versions") {
|
|
100
100
|
const rows = screen.versionRows ?? [],
|
|
101
101
|
index = rows.findIndex((row) => row.id === screen.versionId);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { userInfo } from "node:os";
|
|
4
5
|
import {
|
|
5
6
|
DASHBOARD_PLUGIN_ID,
|
|
6
7
|
dashboardHerdrExec,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
} from "./dashboard-herdr.ts";
|
|
14
15
|
import { DASHBOARD_PROTOCOL_VERSION } from "./dashboard-cli.ts";
|
|
15
16
|
import type { HerdrExec } from "../executors/herdr-cli.ts";
|
|
17
|
+
import { withFileLock } from "../governance/file-lock.ts";
|
|
16
18
|
import { defaultActivityTimelinePath, parseActivityTimeline, renderActivityTimeline } from "./activity-timeline.ts";
|
|
17
19
|
|
|
18
20
|
export type DashboardPromptChoice = "not-now" | "never";
|
|
@@ -73,6 +75,8 @@ export interface DashboardHandshakeInput {
|
|
|
73
75
|
ledgerPath?: string;
|
|
74
76
|
pluginRoot: string;
|
|
75
77
|
preferencePath: string;
|
|
78
|
+
/** Supply an isolated OS account home when testing a shared Herdr registry. */
|
|
79
|
+
registryOwnerHome?: string;
|
|
76
80
|
paneStatePath: string;
|
|
77
81
|
sessionEndpoint?: { socketPath: string; token: string };
|
|
78
82
|
ui: DashboardHandshakeUI;
|
|
@@ -91,61 +95,53 @@ export async function offerDashboardHandshake(input: DashboardHandshakeInput): P
|
|
|
91
95
|
const preference = await loadPreference(input.preferencePath);
|
|
92
96
|
if (preference) return "suppressed";
|
|
93
97
|
const plugin = await inspectDashboardPlugin(exec, input.pluginRoot);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
exec,
|
|
99
|
-
host: host.host,
|
|
100
|
-
ledgerPath: input.ledgerPath ?? "",
|
|
101
|
-
cwd: input.cwd,
|
|
102
|
-
statePath: input.paneStatePath,
|
|
103
|
-
pluginRoot: input.pluginRoot,
|
|
104
|
-
allowInactive: true,
|
|
105
|
-
sessionEndpoint: input.sessionEndpoint,
|
|
106
|
-
});
|
|
107
|
-
input.ui.notify(`pi-daddy dashboard ${opened.kind} in pane ${opened.paneId} without changing focus.`, "info");
|
|
108
|
-
return "already-installed";
|
|
109
|
-
}
|
|
110
|
-
const replacingDifferentPackage = plugin.state === "incompatible" && plugin.incompatibility === "package-root";
|
|
111
|
-
if (plugin.state !== "absent" && !replacingDifferentPackage) {
|
|
98
|
+
if (plugin.plugin?.enabled === false) return "suppressed";
|
|
99
|
+
const replacing =
|
|
100
|
+
plugin.state === "incompatible" && plugin.incompatibility === "package-root" && plugin.plugin?.enabled === true;
|
|
101
|
+
if (plugin.state !== "compatible" && plugin.state !== "absent" && !replacing) {
|
|
112
102
|
input.ui.notify(`pi-daddy dashboard: ${plugin.diagnostic}`, "error");
|
|
113
103
|
return "failed";
|
|
114
104
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
if (!choices.includes(choice ?? "")) {
|
|
125
|
-
// Escape, timeout and UI teardown return undefined. None is an operator choice, so none may become a
|
|
126
|
-
// durable preference merely because the dialog disappeared.
|
|
127
|
-
input.ui.notify("pi-daddy dashboard: installation prompt dismissed; no preference was stored.", "info");
|
|
128
|
-
return "deferred";
|
|
129
|
-
}
|
|
130
|
-
if (choice !== affirmative) {
|
|
131
|
-
if (replacingDifferentPackage) {
|
|
132
|
-
input.ui.notify("pi-daddy dashboard: existing link unchanged; no preference was stored.", "info");
|
|
105
|
+
if (replacing) {
|
|
106
|
+
const choice = await input.ui.select(
|
|
107
|
+
"The dashboard is linked to another Pi Daddy installation. Use this installation's dashboard instead?",
|
|
108
|
+
["Relink and open", "Not now", "Keep existing link"],
|
|
109
|
+
);
|
|
110
|
+
if (choice !== "Relink and open") {
|
|
111
|
+
if (choice === "Keep existing link") await savePreference(input.preferencePath, "never");
|
|
112
|
+
input.ui.notify("pi-daddy dashboard: kept the existing dashboard link.", "info");
|
|
133
113
|
return "deferred";
|
|
134
114
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
115
|
+
}
|
|
116
|
+
let outcome: DashboardHandshakeOutcome = "already-installed";
|
|
117
|
+
if (plugin.state !== "compatible") {
|
|
118
|
+
// Herdr plugin links are shared across Pi profiles. Lock once per OS account,
|
|
119
|
+
// independently of Pi settings, environment HOME, and the bundled plugin path.
|
|
120
|
+
const registryLock = resolve(
|
|
121
|
+
input.registryOwnerHome ?? userInfo().homedir,
|
|
122
|
+
".cache",
|
|
123
|
+
"pi-daddy",
|
|
124
|
+
"herdr-plugin-registry",
|
|
142
125
|
);
|
|
143
|
-
|
|
126
|
+
await mkdir(dirname(registryLock), { recursive: true, mode: 0o700 });
|
|
127
|
+
outcome = await withFileLock(registryLock, "dashboard setup", async () => {
|
|
128
|
+
if (await loadPreference(input.preferencePath)) return "suppressed" as const;
|
|
129
|
+
const current = await inspectDashboardPlugin(exec, input.pluginRoot);
|
|
130
|
+
if (current.state === "compatible") return "already-installed" as const;
|
|
131
|
+
if (
|
|
132
|
+
current.state !== plugin.state ||
|
|
133
|
+
current.incompatibility !== plugin.incompatibility ||
|
|
134
|
+
current.plugin?.plugin_root !== plugin.plugin?.plugin_root ||
|
|
135
|
+
current.plugin?.enabled !== plugin.plugin?.enabled
|
|
136
|
+
)
|
|
137
|
+
throw Error("The dashboard installation changed during startup. Reopen the dashboard to inspect it.");
|
|
138
|
+
await linkDashboardPlugin(input.pluginRoot, exec);
|
|
139
|
+
const linked = await inspectDashboardPlugin(exec, input.pluginRoot);
|
|
140
|
+
if (linked.state !== "compatible") throw new Error(linked.diagnostic);
|
|
141
|
+
return "installed" as const;
|
|
142
|
+
});
|
|
143
|
+
if (outcome === "suppressed") return outcome;
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
await linkDashboardPlugin(input.pluginRoot, exec);
|
|
147
|
-
const linked = await inspectDashboardPlugin(exec, input.pluginRoot);
|
|
148
|
-
if (linked.state !== "compatible") throw new Error(linked.diagnostic);
|
|
149
145
|
const opened = await openOrReuseDashboard({
|
|
150
146
|
exec,
|
|
151
147
|
host: host.host,
|
|
@@ -157,7 +153,7 @@ export async function offerDashboardHandshake(input: DashboardHandshakeInput): P
|
|
|
157
153
|
sessionEndpoint: input.sessionEndpoint,
|
|
158
154
|
});
|
|
159
155
|
input.ui.notify(`pi-daddy dashboard ${opened.kind} in pane ${opened.paneId} without changing focus.`, "info");
|
|
160
|
-
return
|
|
156
|
+
return outcome;
|
|
161
157
|
} catch (error) {
|
|
162
158
|
input.ui.notify(
|
|
163
159
|
`pi-daddy dashboard setup failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -127,7 +127,15 @@ export async function inspectDashboardPlugin(
|
|
|
127
127
|
try {
|
|
128
128
|
const parsed = parseReply(await exec(["plugin", "list", "--json"]));
|
|
129
129
|
if (parsed.error) return { state: "unavailable", diagnostic: `Herdr plugin registry unavailable: ${parsed.error}` };
|
|
130
|
-
|
|
130
|
+
if (
|
|
131
|
+
!Array.isArray(parsed.result?.plugins) ||
|
|
132
|
+
!parsed.result.plugins.every((row) => typeof row?.plugin_id === "string")
|
|
133
|
+
)
|
|
134
|
+
return {
|
|
135
|
+
state: "unavailable",
|
|
136
|
+
diagnostic: "Herdr returned an unreadable plugin list. Check the Herdr connection.",
|
|
137
|
+
};
|
|
138
|
+
const plugins = parsed.result.plugins as Record<string, unknown>[];
|
|
131
139
|
const plugin = plugins.find((candidate) => candidate.plugin_id === DASHBOARD_PLUGIN_ID);
|
|
132
140
|
if (!plugin) return { state: "absent", diagnostic: `Herdr plugin ${DASHBOARD_PLUGIN_ID} is not installed.` };
|
|
133
141
|
// Protocol and provenance both precede enabled state. A root-only repair is offered only when the
|
|
@@ -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;
|