pi-daddy 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/governance/operation-artifacts.d.ts +2 -0
- package/dist/governance/operation-artifacts.d.ts.map +1 -1
- package/dist/governance/operation-artifacts.js +48 -44
- package/dist/governance/operation-artifacts.js.map +1 -1
- package/dist/governance/operation-recovery.d.ts +18 -0
- package/dist/governance/operation-recovery.d.ts.map +1 -0
- package/dist/governance/operation-recovery.js +47 -0
- package/dist/governance/operation-recovery.js.map +1 -0
- package/dist/kernel/dashboard-observation.d.ts +40 -0
- package/dist/kernel/dashboard-observation.d.ts.map +1 -1
- package/dist/kernel/dashboard-observation.js +42 -3
- package/dist/kernel/dashboard-observation.js.map +1 -1
- package/dist/products/dashboard-activity.d.ts +2 -0
- package/dist/products/dashboard-activity.d.ts.map +1 -1
- package/dist/products/dashboard-activity.js +7 -1
- package/dist/products/dashboard-activity.js.map +1 -1
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +1 -1
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-components.d.ts.map +1 -1
- package/dist/products/dashboard-components.js +57 -8
- package/dist/products/dashboard-components.js.map +1 -1
- package/dist/products/dashboard-inventory-view.d.ts +9 -0
- package/dist/products/dashboard-inventory-view.d.ts.map +1 -0
- package/dist/products/dashboard-inventory-view.js +44 -0
- package/dist/products/dashboard-inventory-view.js.map +1 -0
- package/dist/products/dashboard-layout.js +4 -3
- 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 +14 -5
- package/dist/products/dashboard-panels.js.map +1 -1
- package/dist/products/dashboard-screen.d.ts +2 -0
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +14 -7
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +4 -2
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +24 -7
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/extensions/dashboard-live.ts +1 -1
- package/extensions/dashboard-session-server.ts +4 -0
- package/extensions/dashboard-source-refresh.ts +95 -0
- package/extensions/dashboard-sources.ts +42 -4
- package/extensions/definition-describe.ts +50 -4
- package/extensions/delegate-chain.ts +8 -6
- package/extensions/delegation.ts +14 -8
- package/extensions/operation-recovery-bridge.ts +100 -0
- package/extensions/runtime-snapshot.ts +10 -0
- package/extensions/session.ts +1 -0
- package/package.json +1 -1
- package/src/governance/operation-artifacts.ts +51 -41
- package/src/governance/operation-recovery.ts +68 -0
- package/src/kernel/dashboard-observation.ts +86 -4
- package/src/products/dashboard-activity.ts +8 -1
- package/src/products/dashboard-cli.ts +1 -0
- package/src/products/dashboard-components.ts +57 -9
- package/src/products/dashboard-inventory-view.ts +44 -0
- package/src/products/dashboard-layout.ts +6 -4
- package/src/products/dashboard-panels.ts +16 -5
- package/src/products/dashboard-screen.ts +16 -7
- package/src/products/dashboard-session-client.ts +31 -11
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
export const DASHBOARD_SOURCE_EVENT = "pi-daddy:dashboard-source:v1";
|
|
3
3
|
export const DASHBOARD_SOURCE_LIMIT = 8;
|
|
4
4
|
export const DASHBOARD_SOURCE_BYTES = 4096;
|
|
5
|
+
export const DASHBOARD_INVENTORY_BYTES = 8192;
|
|
6
|
+
export const DASHBOARD_INVENTORY_ENTRIES = 12;
|
|
7
|
+
export const DASHBOARD_RESPONSE_BYTES = 64 * 1024 + DASHBOARD_SOURCE_LIMIT * DASHBOARD_INVENTORY_BYTES;
|
|
5
8
|
export type DashboardContributionKind = "goal" | "next" | "work" | "review" | "evidence" | "status";
|
|
6
9
|
export type DashboardObservedState =
|
|
7
10
|
| "observed"
|
|
@@ -26,20 +29,58 @@ export interface DashboardContribution {
|
|
|
26
29
|
export const isBookieChoice = (producer: string, item: DashboardContribution) =>
|
|
27
30
|
producer === "bookie-memory" && item.id.startsWith("open-choice-");
|
|
28
31
|
|
|
32
|
+
export interface DashboardInventoryEntry {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
summary: string;
|
|
36
|
+
details?: string[];
|
|
37
|
+
/** Exact display reference only; opening inventory never dereferences it or grants access. */
|
|
38
|
+
reference?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface DashboardInventory {
|
|
41
|
+
scope: string;
|
|
42
|
+
state: "available" | "empty" | "unavailable" | "unknown";
|
|
43
|
+
summary: string;
|
|
44
|
+
/** Exact visible total only when known. Omit it for an incomplete or unauthorized scan. */
|
|
45
|
+
count?: number;
|
|
46
|
+
/** The displayed/enumerated entries are a bounded selection; count may still be exact. */
|
|
47
|
+
limited: boolean;
|
|
48
|
+
entries: DashboardInventoryEntry[];
|
|
49
|
+
}
|
|
29
50
|
export interface DashboardSourceUpdate {
|
|
30
51
|
sequence: number;
|
|
31
52
|
items: DashboardContribution[];
|
|
53
|
+
/** Send only after the registration reply advertises capabilities.inventory === 1. */
|
|
54
|
+
inventory?: DashboardInventory;
|
|
55
|
+
}
|
|
56
|
+
export interface DashboardSourceRefresh {
|
|
57
|
+
state: "idle" | "checking" | "failed";
|
|
58
|
+
attemptedAt?: string;
|
|
59
|
+
nextAttemptAt?: string;
|
|
32
60
|
}
|
|
61
|
+
/** Return a fresh bounded observation; never publish from inside the refresh callback. */
|
|
62
|
+
export type DashboardSourceRefreshCallback = (request: {
|
|
63
|
+
signal: AbortSignal;
|
|
64
|
+
}) => DashboardSourceUpdate | undefined | Promise<DashboardSourceUpdate | undefined>;
|
|
33
65
|
/** Trusted in-process registration. Callbacks are never serialized to a model or terminal client. */
|
|
34
66
|
export type DashboardSourceRegistrationReply =
|
|
35
67
|
| { version: 1; ok: false; reason: string }
|
|
36
|
-
| {
|
|
68
|
+
| {
|
|
69
|
+
version: 1;
|
|
70
|
+
ok: true;
|
|
71
|
+
generation: string;
|
|
72
|
+
capabilities?: { inventory: 1; refresh: 1 };
|
|
73
|
+
publish(update: DashboardSourceUpdate): boolean;
|
|
74
|
+
close(): void;
|
|
75
|
+
};
|
|
37
76
|
export interface DashboardSourceRegistration {
|
|
38
77
|
version: 1;
|
|
39
78
|
sessionId: string;
|
|
40
79
|
cwd: string;
|
|
41
80
|
producer: string;
|
|
42
81
|
producerVersion: string;
|
|
82
|
+
/** Authorized metadata reads only, with cancellation; no automatic work or model calls. */
|
|
83
|
+
refresh?: DashboardSourceRefreshCallback;
|
|
43
84
|
reply(value: DashboardSourceRegistrationReply): void;
|
|
44
85
|
}
|
|
45
86
|
export interface DashboardSourceSnapshot extends DashboardSourceUpdate {
|
|
@@ -49,6 +90,7 @@ export interface DashboardSourceSnapshot extends DashboardSourceUpdate {
|
|
|
49
90
|
observedAt: string;
|
|
50
91
|
staleAfterMs: number;
|
|
51
92
|
availability: "observed" | "closed";
|
|
93
|
+
refresh?: DashboardSourceRefresh;
|
|
52
94
|
}
|
|
53
95
|
/** Session-local display metadata from the same elected child that published the reference. */
|
|
54
96
|
export interface DashboardResultDescription {
|
|
@@ -87,14 +129,53 @@ export interface DashboardOwnerObservation {
|
|
|
87
129
|
}
|
|
88
130
|
const object = (x: unknown): x is Record<string, unknown> => !!x && typeof x === "object" && !Array.isArray(x);
|
|
89
131
|
const bounded = (x: unknown, max: number): x is string => typeof x === "string" && x.length > 0 && x.length <= max;
|
|
132
|
+
export function validDashboardInventory(value: unknown): value is DashboardInventory {
|
|
133
|
+
if (
|
|
134
|
+
!object(value) ||
|
|
135
|
+
Object.keys(value).some((k) => !["scope", "state", "summary", "count", "limited", "entries"].includes(k)) ||
|
|
136
|
+
!bounded(value.scope, 160) ||
|
|
137
|
+
!bounded(value.summary, 480) ||
|
|
138
|
+
!["available", "empty", "unavailable", "unknown"].includes(String(value.state)) ||
|
|
139
|
+
typeof value.limited !== "boolean" ||
|
|
140
|
+
!Array.isArray(value.entries) ||
|
|
141
|
+
value.entries.length > DASHBOARD_INVENTORY_ENTRIES ||
|
|
142
|
+
(value.count !== undefined && (!Number.isSafeInteger(value.count) || Number(value.count) < value.entries.length)) ||
|
|
143
|
+
(value.state === "empty" && (value.entries.length > 0 || value.limited || value.count !== 0)) ||
|
|
144
|
+
(["unavailable", "unknown"].includes(String(value.state)) &&
|
|
145
|
+
(value.entries.length > 0 || value.count !== undefined))
|
|
146
|
+
)
|
|
147
|
+
return false;
|
|
148
|
+
const ids = new Set<string>();
|
|
149
|
+
for (const entry of value.entries) {
|
|
150
|
+
if (
|
|
151
|
+
!object(entry) ||
|
|
152
|
+
Object.keys(entry).some((k) => !["id", "title", "summary", "details", "reference"].includes(k)) ||
|
|
153
|
+
!bounded(entry.id, 160) ||
|
|
154
|
+
ids.has(entry.id) ||
|
|
155
|
+
!bounded(entry.title, 160) ||
|
|
156
|
+
!bounded(entry.summary, 480) ||
|
|
157
|
+
(entry.reference !== undefined && !bounded(entry.reference, 512)) ||
|
|
158
|
+
(entry.details !== undefined &&
|
|
159
|
+
(!Array.isArray(entry.details) || entry.details.length > 6 || !entry.details.every((x) => bounded(x, 480))))
|
|
160
|
+
)
|
|
161
|
+
return false;
|
|
162
|
+
ids.add(entry.id);
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
return Buffer.byteLength(JSON.stringify(value)) <= DASHBOARD_INVENTORY_BYTES;
|
|
166
|
+
} catch {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
90
170
|
export function validDashboardSourceUpdate(value: unknown): value is DashboardSourceUpdate {
|
|
91
171
|
if (
|
|
92
172
|
!object(value) ||
|
|
93
|
-
Object.keys(value).some((k) => !["sequence", "items"].includes(k)) ||
|
|
173
|
+
Object.keys(value).some((k) => !["sequence", "items", "inventory"].includes(k)) ||
|
|
94
174
|
!Number.isSafeInteger(value.sequence) ||
|
|
95
175
|
Number(value.sequence) < 0 ||
|
|
96
176
|
!Array.isArray(value.items) ||
|
|
97
|
-
value.items.length > 8
|
|
177
|
+
value.items.length > 8 ||
|
|
178
|
+
(value.inventory !== undefined && !validDashboardInventory(value.inventory))
|
|
98
179
|
)
|
|
99
180
|
return false;
|
|
100
181
|
const ids = new Set<string>();
|
|
@@ -125,7 +206,8 @@ export function validDashboardSourceUpdate(value: unknown): value is DashboardSo
|
|
|
125
206
|
ids.add(row.id);
|
|
126
207
|
}
|
|
127
208
|
try {
|
|
128
|
-
if (Buffer.byteLength(JSON.stringify(value)) > DASHBOARD_SOURCE_BYTES)
|
|
209
|
+
if (Buffer.byteLength(JSON.stringify({ sequence: value.sequence, items: value.items })) > DASHBOARD_SOURCE_BYTES)
|
|
210
|
+
return false;
|
|
129
211
|
} catch {
|
|
130
212
|
return false;
|
|
131
213
|
}
|
|
@@ -10,6 +10,8 @@ const clean = (value: string) =>
|
|
|
10
10
|
.trim();
|
|
11
11
|
|
|
12
12
|
export function activityTaskTitle(task: TimelineTask): string {
|
|
13
|
+
if (activityTaskStatus(task) === "turn-ended")
|
|
14
|
+
return task.trigger?.type === "custom" ? "Extension turn ended" : "Pi turn ended";
|
|
13
15
|
const lastAction = task.lastEvent?.kind === "tool_started" || task.status !== "active";
|
|
14
16
|
const observed = lastAction
|
|
15
17
|
? (safeDashboardSummary(task.lastPurpose) ?? (task.lastEvent?.tool ? toolPurpose(task.lastEvent.tool) : undefined))
|
|
@@ -22,6 +24,11 @@ export function activityTaskTitle(task: TimelineTask): string {
|
|
|
22
24
|
return task.status === "active" ? "Pi is working on your request" : "Pi handled your request";
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
/** A settled parent response says nothing about delivery; child execution outcomes remain distinct. */
|
|
28
|
+
export function activityTaskStatus(task: TimelineTask): string {
|
|
29
|
+
return !task.agent && !task.parentTaskId && task.status === "finished" ? "turn-ended" : task.status;
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
/** Ledger entries retain authoritative state and identity. Only the same owner's matching execution may add a title. */
|
|
26
33
|
export function applyOwnerTaskTitles(items: DashboardItem[], tasks: TimelineTask[], rootId: string): DashboardItem[] {
|
|
27
34
|
const known = new Map(tasks.filter((task) => task.rootId === rootId && task.agent).map((task) => [task.id, task]));
|
|
@@ -55,7 +62,7 @@ export function activityStoryItems(
|
|
|
55
62
|
if (raw === "agent_start" || raw === "agent_end") starts.clear();
|
|
56
63
|
stories.push({
|
|
57
64
|
events: [event],
|
|
58
|
-
label: raw === "agent_start" ? "Pi started a turn" : raw === "agent_end" ? "Pi
|
|
65
|
+
label: raw === "agent_start" ? "Pi started a turn" : raw === "agent_end" ? "Pi turn ended" : raw,
|
|
59
66
|
status: "observed",
|
|
60
67
|
calls: 1,
|
|
61
68
|
});
|
|
@@ -382,6 +382,7 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
382
382
|
["now", "work"].includes(display.screen.destination ?? "now");
|
|
383
383
|
await connection.refresh(
|
|
384
384
|
interactive && editingChoice ? "picker" : interactive && showsChoices ? "list" : undefined,
|
|
385
|
+
interactive,
|
|
385
386
|
);
|
|
386
387
|
const jev = connection.state.snapshot?.settings?.jev;
|
|
387
388
|
if (notice === JEV_CONSENT_NOTICE && jev && !jev.pending) notice = dashboardJevNotice(jev);
|
|
@@ -9,12 +9,15 @@ import { validChoiceId } from "../kernel/dashboard-choice.ts";
|
|
|
9
9
|
import { isBookieChoice } from "../kernel/dashboard-observation.ts";
|
|
10
10
|
import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
|
|
11
11
|
import { safeDashboardSummary } from "./activity-summary.ts";
|
|
12
|
+
import { inventoryPresentation, observationAge } from "./dashboard-inventory-view.ts";
|
|
12
13
|
|
|
13
14
|
const BOOKIE_LIMIT_MESSAGE = "Only a bounded selection of saved open choices could be displayed.";
|
|
14
15
|
|
|
15
16
|
type KnownSource = "bookie" | "scout-local" | "scout-worker";
|
|
16
17
|
|
|
17
18
|
export function isComponentObservation(source: DashboardSourceSnapshot, item: DashboardContribution): boolean {
|
|
19
|
+
if (["bookie-memory", "scout-local", "scout-worker"].includes(source.producer) && item.id === "availability")
|
|
20
|
+
return item.kind === "status";
|
|
18
21
|
if (source.producer === "bookie-memory") return item.id === "project-memory" && item.kind === "work";
|
|
19
22
|
return (
|
|
20
23
|
(source.producer === "scout-local" || source.producer === "scout-worker") &&
|
|
@@ -71,6 +74,15 @@ function scoutDescription(worker: boolean, item: DashboardContribution): [string
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
function memoryDescription(item: DashboardContribution | undefined, partial: boolean): [string, string] {
|
|
78
|
+
if (item?.state === "observed")
|
|
79
|
+
return ["Ready in this folder", "Bookie can save and recall routine notes for this workspace."];
|
|
80
|
+
return [
|
|
81
|
+
item?.state === "unavailable" ? "Memory unavailable" : partial ? "Notes partially checked" : "Cannot check notes",
|
|
82
|
+
item?.details?.[0] ?? "The current project notes could not be checked. Previous history is not confirmed empty.",
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
/** Choices are current project observations; a saved question never creates a live input request. */
|
|
75
87
|
export function bookieOpenChoices(options: DashboardScreenOptions): DashboardItem[] {
|
|
76
88
|
const source = options.session?.observation?.sources.find((s) => s.producer === "bookie-memory");
|
|
@@ -125,8 +137,7 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
|
|
|
125
137
|
const workSource = sources?.find((s) => s.producer === producer);
|
|
126
138
|
const memory = bookie
|
|
127
139
|
? sources?.find(
|
|
128
|
-
(s) =>
|
|
129
|
-
s.producer === "bookie-memory" && s.items.some((i) => isComponentObservation(s, i) && i.state === "observed"),
|
|
140
|
+
(s) => s.producer === "bookie-memory" && s.items.some((i) => isComponentObservation(s, i) && i.kind === "work"),
|
|
130
141
|
)
|
|
131
142
|
: undefined;
|
|
132
143
|
const source =
|
|
@@ -134,27 +145,48 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
|
|
|
134
145
|
|
|
135
146
|
const pkg = options.session?.versions?.rows.find((r) => r.id === (bookie ? "bookie-pi-skills" : "pi-scout-research"));
|
|
136
147
|
if (!source && !(pkg?.source || pkg?.loadedVersion || pkg?.installedVersion || pkg?.state === "multiple")) return;
|
|
137
|
-
const item = source?.items.find((i) => isComponentObservation(source, i));
|
|
148
|
+
const item = source?.items.find((i) => isComponentObservation(source, i) && i.kind === "work");
|
|
149
|
+
const availability = source?.items.find((i) => i.id === "availability" && i.kind === "status");
|
|
138
150
|
let state = "observed",
|
|
139
151
|
status: string,
|
|
140
152
|
explanation: string;
|
|
141
153
|
if (
|
|
142
154
|
options.connected === false ||
|
|
155
|
+
source?.refresh?.state === "failed" ||
|
|
143
156
|
(source &&
|
|
144
157
|
!current(source, options) &&
|
|
145
158
|
!(source.producer === "bookie-memory" && options.session?.auto.enabled === false))
|
|
146
159
|
) {
|
|
147
160
|
state = "last-observed";
|
|
148
|
-
status =
|
|
161
|
+
status =
|
|
162
|
+
options.connected === false
|
|
163
|
+
? "Disconnected"
|
|
164
|
+
: source?.availability === "closed"
|
|
165
|
+
? "Status connection ended"
|
|
166
|
+
: source?.refresh?.state === "checking"
|
|
167
|
+
? "Checking status"
|
|
168
|
+
: source?.refresh?.state === "failed"
|
|
169
|
+
? "Status check unavailable"
|
|
170
|
+
: "Status update overdue";
|
|
149
171
|
const lastReport =
|
|
150
172
|
source?.producer === "bookie-memory"
|
|
151
|
-
?
|
|
173
|
+
? memoryDescription(item, source.inventory?.state === "available")[0]
|
|
152
174
|
: item
|
|
153
175
|
? scoutDescription(worker, item)[0]
|
|
154
176
|
: bookie && source?.items.some((i) => i.kind === "goal" && i.id === "scope")
|
|
155
177
|
? "Project connected"
|
|
156
178
|
: undefined;
|
|
157
|
-
explanation =
|
|
179
|
+
explanation =
|
|
180
|
+
(lastReport ? `Last report: ${lastReport}. ` : "") +
|
|
181
|
+
(options.connected === false
|
|
182
|
+
? "Reconnect to Pi to check current availability."
|
|
183
|
+
: source?.availability === "closed"
|
|
184
|
+
? "The producer's status connection is no longer active."
|
|
185
|
+
: source?.refresh?.state === "checking"
|
|
186
|
+
? "A fresh status check is in progress."
|
|
187
|
+
: source?.refresh?.state === "failed"
|
|
188
|
+
? "The producer could not return a current report; a later refresh can try again."
|
|
189
|
+
: "The previous report expired. Current availability has not yet been rechecked.");
|
|
158
190
|
} else if (
|
|
159
191
|
bookie &&
|
|
160
192
|
options.session &&
|
|
@@ -171,11 +203,15 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
|
|
|
171
203
|
: "Auto starts off by default.";
|
|
172
204
|
explanation = `${origin} Turn Auto on in Settings for automatic notes in this folder, or use /bookie-context to select memory manually. A session toggle does not change the startup setting.`;
|
|
173
205
|
} else if (source?.producer === "bookie-memory") {
|
|
174
|
-
|
|
175
|
-
explanation =
|
|
206
|
+
state = item?.state ?? "unknown";
|
|
207
|
+
[status, explanation] = memoryDescription(item, source.inventory?.state === "available");
|
|
176
208
|
} else if (bookie && source?.items.length) {
|
|
177
209
|
status = "Project connected";
|
|
178
210
|
explanation = "Bookie is sharing the selected project’s work with Pi.";
|
|
211
|
+
} else if (availability) {
|
|
212
|
+
state = availability.state;
|
|
213
|
+
status = availability.label;
|
|
214
|
+
explanation = availability.details?.[0] ?? "Current availability reported by Scout.";
|
|
179
215
|
} else if (item) {
|
|
180
216
|
state = item.state;
|
|
181
217
|
[status, explanation] = scoutDescription(worker, item);
|
|
@@ -197,17 +233,29 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
|
|
|
197
233
|
const isMemory = source?.producer === "bookie-memory";
|
|
198
234
|
const limited =
|
|
199
235
|
isMemory && state === "observed" && options.session?.auto.enabled && sourceDetails.includes(BOOKIE_LIMIT_MESSAGE);
|
|
200
|
-
const
|
|
236
|
+
const explanationLines = limited
|
|
201
237
|
? [explanation, "Bookie could only show part of this project’s open choices."]
|
|
202
238
|
: [explanation];
|
|
239
|
+
const canShowInventory = source && current(source, options) && (!bookie || options.session?.auto.enabled);
|
|
240
|
+
const showInventory = canShowInventory && source.refresh?.state !== "failed";
|
|
241
|
+
const inventory = inventoryPresentation(showInventory ? source.inventory : undefined);
|
|
242
|
+
const age = observationAge(source, options.now?.getTime() ?? Date.now());
|
|
243
|
+
const briefDetails = [
|
|
244
|
+
...explanationLines,
|
|
245
|
+
...(source?.inventory || state === "last-observed" ? [age] : []),
|
|
246
|
+
...inventory.content,
|
|
247
|
+
];
|
|
203
248
|
return {
|
|
204
249
|
key: `component:${producer}`,
|
|
205
250
|
label: `${title} · ${status}`,
|
|
206
251
|
status: state,
|
|
207
252
|
elapsed: "",
|
|
208
253
|
briefDetails,
|
|
254
|
+
...(source?.inventory && showInventory ? { browse: true, previewLines: inventory.preview } : {}),
|
|
209
255
|
details: [
|
|
210
256
|
...briefDetails,
|
|
257
|
+
age,
|
|
258
|
+
...inventory.references,
|
|
211
259
|
...(source
|
|
212
260
|
? [`Source: ${source.producer} · ${source.producerVersion}`, `Last update: ${source.observedAt}`]
|
|
213
261
|
: []),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Human content previews from an authorized, current producer snapshot; rendering performs no reads. */
|
|
2
|
+
import type { DashboardInventory, DashboardSourceSnapshot } from "../kernel/dashboard-observation.ts";
|
|
3
|
+
import { dashboardText } from "./dashboard-screen.ts";
|
|
4
|
+
import { truncate } from "./dashboard-render.ts";
|
|
5
|
+
|
|
6
|
+
const clean = (text: string) => dashboardText(text).replace(/\s+/g, " ").trim();
|
|
7
|
+
|
|
8
|
+
export function inventoryPresentation(inventory: DashboardInventory | undefined) {
|
|
9
|
+
if (!inventory) return { preview: [] as string[], content: [] as string[], references: [] as string[] };
|
|
10
|
+
const entries = inventory.state === "available" ? inventory.entries : [];
|
|
11
|
+
const summary = clean(inventory.summary);
|
|
12
|
+
const coverage = inventory.limited
|
|
13
|
+
? inventory.count === undefined
|
|
14
|
+
? "Showing a bounded selection; this is not the full inventory."
|
|
15
|
+
: `Showing ${entries.length} of ${inventory.count} saved items.`
|
|
16
|
+
: undefined;
|
|
17
|
+
return {
|
|
18
|
+
preview: [truncate(summary, 110), ...entries.slice(0, 2).map((entry) => `• ${truncate(clean(entry.title), 90)}`)],
|
|
19
|
+
content: [
|
|
20
|
+
`Scope: ${clean(inventory.scope)}`,
|
|
21
|
+
summary,
|
|
22
|
+
...(coverage ? [coverage] : []),
|
|
23
|
+
...entries.flatMap((entry, index) => [
|
|
24
|
+
"",
|
|
25
|
+
`${index + 1}. ${clean(entry.title)}`,
|
|
26
|
+
` ${clean(entry.summary)}`,
|
|
27
|
+
...(entry.details ?? []).map((line) => ` ${clean(line)}`),
|
|
28
|
+
]),
|
|
29
|
+
],
|
|
30
|
+
references: entries.flatMap((entry) =>
|
|
31
|
+
entry.reference ? [`${clean(entry.title)}: ${clean(entry.reference)}`] : [],
|
|
32
|
+
),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function observationAge(source: DashboardSourceSnapshot | undefined, now: number): string {
|
|
37
|
+
if (!source) return "No status report received yet.";
|
|
38
|
+
const age = now - Date.parse(source.observedAt);
|
|
39
|
+
if (!Number.isFinite(age) || age < 0) return "The last update time could not be verified.";
|
|
40
|
+
if (age < 10_000) return "Updated just now.";
|
|
41
|
+
if (age < 60_000) return `Updated ${Math.floor(age / 1000)}s ago.`;
|
|
42
|
+
if (age < 3_600_000) return `Updated ${Math.floor(age / 60_000)}m ago.`;
|
|
43
|
+
return `Updated ${Math.floor(age / 3_600_000)}h ago.`;
|
|
44
|
+
}
|
|
@@ -50,17 +50,19 @@ function paintCell(cell: string): string {
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
if (/^ /.test(text)) {
|
|
53
|
-
const status =
|
|
54
|
-
|
|
53
|
+
const status = new RegExp(
|
|
54
|
+
"( · )(Failed|Blocked|Run failed|Last attempt failed|Unavailable|Awaiting decision|Needs you|" +
|
|
55
|
+
"Disconnected|Checking status|Status update overdue|Status check unavailable|Running|Finished|Saved|Available|Ready[^·]*)(?= |$| ·)",
|
|
56
|
+
);
|
|
55
57
|
return (
|
|
56
58
|
text.replace(status, (_, separator, state) => {
|
|
57
59
|
const color = /^(Failed|Blocked|Last attempt failed|Run failed)$/.test(state)
|
|
58
60
|
? "90"
|
|
59
61
|
: state === "Unavailable"
|
|
60
62
|
? "1;31"
|
|
61
|
-
: /Awaiting|Needs you|
|
|
63
|
+
: /Awaiting|Needs you|Disconnected|overdue|unavailable/.test(state)
|
|
62
64
|
? "33"
|
|
63
|
-
: state
|
|
65
|
+
: /Running|Checking/.test(state)
|
|
64
66
|
? "36"
|
|
65
67
|
: "32";
|
|
66
68
|
return separator + sgr(state, color);
|
|
@@ -312,7 +312,12 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
312
312
|
...input,
|
|
313
313
|
...components.filter(needsUserInput),
|
|
314
314
|
...(ownerTurn && !parentShown
|
|
315
|
-
? [
|
|
315
|
+
? [
|
|
316
|
+
{
|
|
317
|
+
...row(ownerTurn, `owner:${observed.generation}:${ownerTurn.id}`, "Pi owner", staleOwner),
|
|
318
|
+
...(ownerTurn.state === "settled" && !staleOwner ? { label: "Pi turn ended", status: "turn-ended" } : {}),
|
|
319
|
+
},
|
|
320
|
+
]
|
|
316
321
|
: []),
|
|
317
322
|
...tasks,
|
|
318
323
|
...bookieOpenChoices(options),
|
|
@@ -367,13 +372,15 @@ const workGroups = [
|
|
|
367
372
|
"Other tasks",
|
|
368
373
|
"Recently finished",
|
|
369
374
|
"Last known",
|
|
370
|
-
"
|
|
375
|
+
"Memory",
|
|
376
|
+
"Research",
|
|
371
377
|
];
|
|
372
378
|
export function needsUserInput(item: DashboardItem): boolean {
|
|
373
379
|
return !item.reviewSummary && ["needs-you", "approval-wait"].includes(item.status);
|
|
374
380
|
}
|
|
375
381
|
function workGroup(item: DashboardItem): string {
|
|
376
|
-
if (item.key.startsWith("component:"))
|
|
382
|
+
if (item.key.startsWith("component:"))
|
|
383
|
+
return needsUserInput(item) ? "Needs your decision" : item.key === "component:bookie" ? "Memory" : "Research";
|
|
377
384
|
if (item.key.startsWith("activity:")) return "Latest activity";
|
|
378
385
|
if (["last-observed", "historical"].includes(item.status)) return "Last known";
|
|
379
386
|
if (needsUserInput(item)) {
|
|
@@ -384,7 +391,7 @@ function workGroup(item: DashboardItem): string {
|
|
|
384
391
|
if (item.status === "dependency-wait") return "Waiting on a dependency";
|
|
385
392
|
if (item.status === "incomplete") return "Outcome unknown";
|
|
386
393
|
if (["running", "active", "starting", "authorised", "cancel-requested"].includes(item.status)) return "In progress";
|
|
387
|
-
if (["settled", "completed", "finished", "cancelled", "failed", "refused"].includes(item.status))
|
|
394
|
+
if (["turn-ended", "settled", "completed", "finished", "cancelled", "failed", "refused"].includes(item.status))
|
|
388
395
|
return "Recently finished";
|
|
389
396
|
return "Other tasks";
|
|
390
397
|
}
|
|
@@ -449,7 +456,11 @@ export function sessionPanelLines(options: DashboardScreenOptions, items: Dashbo
|
|
|
449
456
|
if (roomy && (rows.length || lines.length)) rows.push("");
|
|
450
457
|
const count = destination === "now" ? "" : ` · ${end - start}`;
|
|
451
458
|
rows.push(sectionHeading(group + count, left ?? width));
|
|
452
|
-
for (const item of items.slice(start, end))
|
|
459
|
+
for (const item of items.slice(start, end)) {
|
|
460
|
+
rows.push(rowText(item, destination, item.key === screen.selectedKey));
|
|
461
|
+
for (const line of (item.previewLines ?? []).slice(0, options.height >= 28 ? 3 : 2))
|
|
462
|
+
rows.push(` ${clean(line)}`);
|
|
463
|
+
}
|
|
453
464
|
start = end;
|
|
454
465
|
}
|
|
455
466
|
lines.push(...rows);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
DASHBOARD_DESTINATIONS,
|
|
10
10
|
type DashboardDestination,
|
|
11
11
|
} from "./dashboard-panels.ts";
|
|
12
|
-
import { activityTaskTitle } from "./dashboard-activity.ts";
|
|
12
|
+
import { activityTaskStatus, activityTaskTitle } from "./dashboard-activity.ts";
|
|
13
13
|
import { versionLines } from "./dashboard-components.ts";
|
|
14
14
|
import { sessionRecapLines } from "./dashboard-recap.ts";
|
|
15
15
|
import { colorSessionLine, previewWidth, sectionHeading } from "./dashboard-layout.ts";
|
|
@@ -29,6 +29,8 @@ export interface DashboardItem {
|
|
|
29
29
|
updatedAt?: string;
|
|
30
30
|
details: string[];
|
|
31
31
|
briefDetails?: string[];
|
|
32
|
+
previewLines?: string[];
|
|
33
|
+
browse?: boolean;
|
|
32
34
|
reviewSummary?: boolean;
|
|
33
35
|
relatedReviewKey?: string;
|
|
34
36
|
observation?: string;
|
|
@@ -112,6 +114,7 @@ export const friendlyStatus = (status: string) =>
|
|
|
112
114
|
"approval-wait": "Awaiting decision",
|
|
113
115
|
"dependency-wait": "Waiting on dependency",
|
|
114
116
|
"last-observed": "Last seen",
|
|
117
|
+
"turn-ended": "Ended",
|
|
115
118
|
settled: "Finished",
|
|
116
119
|
completed: "Finished",
|
|
117
120
|
finished: "Finished",
|
|
@@ -164,7 +167,7 @@ export function activityDashboardItems(
|
|
|
164
167
|
label: human
|
|
165
168
|
? activityTaskTitle(task)
|
|
166
169
|
: `${task.agent || (task.trigger?.type === "custom" ? "Extension turn" : "User turn")} [${aliases.selector(task)}]`,
|
|
167
|
-
status: task
|
|
170
|
+
status: activityTaskStatus(task),
|
|
168
171
|
updatedAt: task.endedAt ?? task.lastEvent?.at ?? task.startedAt,
|
|
169
172
|
elapsed: elapsed(Date.parse(task.endedAt ?? now.toISOString()) - Date.parse(task.startedAt)),
|
|
170
173
|
observation: task.lastEvent
|
|
@@ -174,7 +177,8 @@ export function activityDashboardItems(
|
|
|
174
177
|
skills: task.skills.length > 0,
|
|
175
178
|
details: [
|
|
176
179
|
`Task: ${aliases.selector(task)}`,
|
|
177
|
-
`State: ${friendlyStatus(task
|
|
180
|
+
`State: ${friendlyStatus(activityTaskStatus(task))} (observation, not acceptance)`,
|
|
181
|
+
...(task.lastPurpose ? [`Last action: ${clean(task.lastPurpose)}`] : []),
|
|
178
182
|
...(task.trigger?.type === "custom" ? [`Trigger: extension message (${task.trigger.customType})`] : []),
|
|
179
183
|
...(task.cwd ? [`Working directory: ${task.cwd}`] : ["Working directory: not recorded"]),
|
|
180
184
|
...(task.lastEvent
|
|
@@ -249,7 +253,8 @@ function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | und
|
|
|
249
253
|
if (view === "choice") return choiceKeys(screen);
|
|
250
254
|
if (view === "main") {
|
|
251
255
|
if (selected?.choice) return ["↑↓ select · Enter answer", "d details · q close"];
|
|
252
|
-
const
|
|
256
|
+
const action = selected?.browse ? "browse" : "details";
|
|
257
|
+
const keys = selected ? (brief ? `↑↓ · Enter ${action}` : `↑↓ select · Enter ${action}`) : "1–6 views";
|
|
253
258
|
return [keys + (brief ? " · ?" : " · ? help"), "r recap · q close"];
|
|
254
259
|
}
|
|
255
260
|
if (view === "versions" || view === "settings")
|
|
@@ -522,9 +527,13 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
522
527
|
sectionHeading(
|
|
523
528
|
screen.sourceDetails
|
|
524
529
|
? "SOURCE RECORD"
|
|
525
|
-
:
|
|
526
|
-
?
|
|
527
|
-
|
|
530
|
+
: selected.browse
|
|
531
|
+
? selected.key === "component:bookie"
|
|
532
|
+
? "SAVED NOTES"
|
|
533
|
+
: "SAVED RESEARCH"
|
|
534
|
+
: (selected.briefDetails && selected.status === "approval-wait") || selected.approval
|
|
535
|
+
? "NEXT ACTION"
|
|
536
|
+
: "DETAILS",
|
|
528
537
|
width,
|
|
529
538
|
),
|
|
530
539
|
]
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type DashboardChoiceDetail,
|
|
5
5
|
type DashboardChoiceTarget,
|
|
6
6
|
} from "../kernel/dashboard-choice.ts";
|
|
7
|
-
import type
|
|
7
|
+
import { DASHBOARD_RESPONSE_BYTES, type DashboardOwnerObservation } from "../kernel/dashboard-observation.ts";
|
|
8
8
|
import type { DashboardSettingsSnapshot, JevEditAction } from "./dashboard-settings.ts";
|
|
9
9
|
import type { EcosystemVersions } from "./ecosystem-versions.ts";
|
|
10
10
|
import { createConnection } from "node:net";
|
|
@@ -25,6 +25,7 @@ interface DashboardSessionReply extends DashboardSessionSnapshot {
|
|
|
25
25
|
choiceDetail?: DashboardChoiceDetail;
|
|
26
26
|
choiceSaved?: true;
|
|
27
27
|
choiceRefreshRequested?: true;
|
|
28
|
+
sourceRefreshRequested?: true;
|
|
28
29
|
}
|
|
29
30
|
class ChoiceDeclined extends Error {
|
|
30
31
|
readonly stale: boolean;
|
|
@@ -39,7 +40,7 @@ class ChoiceDeclined extends Error {
|
|
|
39
40
|
}
|
|
40
41
|
export type DashboardSessionAction = (
|
|
41
42
|
| DashboardChoiceAction
|
|
42
|
-
| { action: "get"; refreshChoices?: true }
|
|
43
|
+
| { action: "get"; refreshChoices?: true; refreshSources?: true }
|
|
43
44
|
| { action: "set"; edits: string }
|
|
44
45
|
| { action: "set-auto"; enabled: boolean }
|
|
45
46
|
| { action: "set-jev"; enabled: boolean }
|
|
@@ -63,7 +64,8 @@ export async function dashboardSessionRequest(
|
|
|
63
64
|
socket.once("error", reject);
|
|
64
65
|
socket.on("data", (chunk) => {
|
|
65
66
|
output += chunk;
|
|
66
|
-
if (output
|
|
67
|
+
if (Buffer.byteLength(output) > DASHBOARD_RESPONSE_BYTES)
|
|
68
|
+
socket.destroy(new Error("dashboard session response too large"));
|
|
67
69
|
});
|
|
68
70
|
socket.once("end", () => {
|
|
69
71
|
try {
|
|
@@ -127,6 +129,18 @@ export function createDashboardConnection(
|
|
|
127
129
|
let choiceInterest = 0,
|
|
128
130
|
consumedInterest = 0;
|
|
129
131
|
const retired = new Set<string>();
|
|
132
|
+
const disconnect = () => {
|
|
133
|
+
state.snapshot = undefined;
|
|
134
|
+
const previous = state.lastObserved;
|
|
135
|
+
if (previous?.observation)
|
|
136
|
+
state.lastObserved = {
|
|
137
|
+
...previous,
|
|
138
|
+
observation: {
|
|
139
|
+
...previous.observation,
|
|
140
|
+
sources: previous.observation.sources.map(({ inventory: _inventory, ...source }) => source),
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
};
|
|
130
144
|
const accept = (snapshot: DashboardSessionSnapshot) => {
|
|
131
145
|
const previous = state.lastObserved?.observation,
|
|
132
146
|
next = snapshot.observation;
|
|
@@ -187,24 +201,30 @@ export function createDashboardConnection(
|
|
|
187
201
|
requestChoiceRefresh() {
|
|
188
202
|
choiceInterest++;
|
|
189
203
|
},
|
|
190
|
-
async refresh(visibleChoices?: "picker" | "list") {
|
|
204
|
+
async refresh(visibleChoices?: "picker" | "list", visibleSources = false) {
|
|
191
205
|
if (!request || state.pending) return;
|
|
192
206
|
const observed = generation,
|
|
193
207
|
order = ++poll;
|
|
194
208
|
try {
|
|
195
209
|
const interest = choiceInterest;
|
|
196
210
|
const wanted = visibleChoices === "picker" || (visibleChoices === "list" && interest !== consumedInterest);
|
|
197
|
-
const {
|
|
198
|
-
|
|
199
|
-
|
|
211
|
+
const {
|
|
212
|
+
choiceRefreshRequested,
|
|
213
|
+
sourceRefreshRequested: _sourceRefreshRequested,
|
|
214
|
+
...snapshot
|
|
215
|
+
} = await request({
|
|
216
|
+
action: "get",
|
|
217
|
+
...(wanted ? { refreshChoices: true } : {}),
|
|
218
|
+
...(visibleSources ? { refreshSources: true } : {}),
|
|
219
|
+
});
|
|
200
220
|
if (choiceRefreshRequested) consumedInterest = Math.max(consumedInterest, interest);
|
|
201
221
|
if (generation === observed && order === poll && !accept(snapshot)) {
|
|
202
|
-
|
|
222
|
+
disconnect();
|
|
203
223
|
state.error = "Owner observation is stale or unavailable; controls disabled until a fresh reply.";
|
|
204
224
|
}
|
|
205
225
|
} catch (error) {
|
|
206
226
|
if (generation === observed && order === poll) {
|
|
207
|
-
|
|
227
|
+
disconnect();
|
|
208
228
|
state.error = `Controls unavailable; showing last observation: ${error instanceof Error ? error.message : String(error)}`;
|
|
209
229
|
}
|
|
210
230
|
}
|
|
@@ -264,12 +284,12 @@ export function createDashboardConnection(
|
|
|
264
284
|
return true;
|
|
265
285
|
} catch (error) {
|
|
266
286
|
if (action.action === "answer-choice" && error instanceof ChoiceDeclined) {
|
|
267
|
-
if (error.stale)
|
|
287
|
+
if (error.stale) disconnect();
|
|
268
288
|
state.acknowledgment.state = "refused";
|
|
269
289
|
state.error = error.message;
|
|
270
290
|
return false;
|
|
271
291
|
}
|
|
272
|
-
|
|
292
|
+
disconnect();
|
|
273
293
|
state.acknowledgment.state = "unconfirmed";
|
|
274
294
|
state.error =
|
|
275
295
|
action.action === "answer-choice"
|