pi-daddy 0.62.0 → 0.63.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 +10 -0
- package/README.md +28 -3
- package/contracts/task-history/v1/README.md +76 -0
- package/contracts/task-history/v1/dispatch.ts +38 -0
- package/contracts/task-history/v1/observation.schema.json +73 -0
- package/contracts/task-history/v1/producer.ts +48 -0
- package/dist/governance/runtime-settlement.d.ts +8 -1
- package/dist/governance/runtime-settlement.d.ts.map +1 -1
- package/dist/governance/runtime-settlement.js +42 -4
- package/dist/governance/runtime-settlement.js.map +1 -1
- package/dist/governance/task-dispatch.d.ts +85 -0
- package/dist/governance/task-dispatch.d.ts.map +1 -0
- package/dist/governance/task-dispatch.js +342 -0
- package/dist/governance/task-dispatch.js.map +1 -0
- package/dist/kernel/context-handoff.d.ts +14 -0
- package/dist/kernel/context-handoff.d.ts.map +1 -1
- package/dist/kernel/context-handoff.js +17 -0
- package/dist/kernel/context-handoff.js.map +1 -1
- package/dist/kernel/dashboard-choice.d.ts +5 -0
- package/dist/kernel/dashboard-choice.d.ts.map +1 -1
- package/dist/kernel/dashboard-choice.js.map +1 -1
- package/dist/kernel/dashboard-observation.d.ts +31 -0
- package/dist/kernel/dashboard-observation.d.ts.map +1 -1
- package/dist/kernel/dashboard-observation.js +33 -1
- package/dist/kernel/dashboard-observation.js.map +1 -1
- package/dist/kernel/dashboard-request.d.ts +4 -0
- package/dist/kernel/dashboard-request.d.ts.map +1 -0
- package/dist/kernel/dashboard-request.js +8 -0
- package/dist/kernel/dashboard-request.js.map +1 -0
- package/dist/kernel/delegate.d.ts.map +1 -1
- package/dist/kernel/delegate.js +24 -8
- package/dist/kernel/delegate.js.map +1 -1
- package/dist/products/dashboard-choice-picker.d.ts +2 -0
- package/dist/products/dashboard-choice-picker.d.ts.map +1 -1
- package/dist/products/dashboard-choice-picker.js +46 -18
- package/dist/products/dashboard-choice-picker.js.map +1 -1
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +31 -4
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-components.d.ts +2 -0
- package/dist/products/dashboard-components.d.ts.map +1 -1
- package/dist/products/dashboard-components.js +81 -0
- package/dist/products/dashboard-components.js.map +1 -1
- package/dist/products/dashboard-panels.d.ts.map +1 -1
- package/dist/products/dashboard-panels.js +7 -2
- package/dist/products/dashboard-panels.js.map +1 -1
- package/dist/products/dashboard-screen.d.ts +2 -0
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +12 -3
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +8 -0
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +54 -26
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/dashboard-task-controls.d.ts +6 -0
- package/dist/products/dashboard-task-controls.d.ts.map +1 -0
- package/dist/products/dashboard-task-controls.js +27 -0
- package/dist/products/dashboard-task-controls.js.map +1 -0
- package/extensions/dashboard-choice-controls.ts +33 -1
- package/extensions/dashboard-session-server.ts +67 -4
- package/extensions/dashboard-sources.ts +21 -2
- package/extensions/definition-describe.ts +3 -1
- package/extensions/delegate-chain.ts +6 -0
- package/extensions/delegation-artifacts.ts +34 -0
- package/extensions/delegation-operations.ts +30 -1
- package/extensions/delegation.ts +26 -2
- package/extensions/execute-child.ts +4 -0
- package/extensions/grants.ts +3 -0
- package/extensions/run-delegation.ts +58 -6
- package/extensions/runtime-snapshot.ts +23 -17
- package/extensions/session.ts +4 -0
- package/extensions/task-dispatch-controller.ts +384 -0
- package/extensions/task-inline-control.ts +21 -0
- package/extensions/task-worktree-writer.ts +55 -0
- package/package.json +1 -1
- package/src/governance/runtime-settlement.ts +44 -2
- package/src/governance/task-dispatch.ts +427 -0
- package/src/kernel/context-handoff.ts +19 -0
- package/src/kernel/dashboard-choice.ts +7 -1
- package/src/kernel/dashboard-observation.ts +67 -2
- package/src/kernel/dashboard-request.ts +8 -0
- package/src/kernel/delegate.ts +33 -14
- package/src/products/dashboard-choice-picker.ts +51 -16
- package/src/products/dashboard-cli.ts +33 -4
- package/src/products/dashboard-components.ts +84 -0
- package/src/products/dashboard-panels.ts +6 -1
- package/src/products/dashboard-screen.ts +14 -3
- package/src/products/dashboard-session-client.ts +79 -28
- package/src/products/dashboard-task-controls.ts +34 -0
|
@@ -10,11 +10,15 @@ export interface ChoicePicker {
|
|
|
10
10
|
draft: string;
|
|
11
11
|
detail?: DashboardChoiceDetail;
|
|
12
12
|
error?: string;
|
|
13
|
+
canReclassify?: boolean;
|
|
14
|
+
reclassifying?: boolean;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
function current(screen: DashboardScreenState, picker: ChoicePicker) {
|
|
16
|
-
const
|
|
18
|
+
const item = screen.items.find((item) => item.key === screen.selectedKey);
|
|
19
|
+
const choice = item?.choice;
|
|
17
20
|
return (
|
|
21
|
+
(!picker.reclassifying || item?.reclassifyChoice === true) &&
|
|
18
22
|
choice?.choiceId === picker.target.choiceId &&
|
|
19
23
|
choice.sourceGeneration === picker.target.sourceGeneration &&
|
|
20
24
|
choice.expectedOwner.sessionId === picker.target.expectedOwner.sessionId &&
|
|
@@ -24,9 +28,10 @@ function current(screen: DashboardScreenState, picker: ChoicePicker) {
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export function openChoice(screen: DashboardScreenState): boolean {
|
|
27
|
-
const
|
|
31
|
+
const item = screen.items.find((item) => item.key === screen.selectedKey);
|
|
32
|
+
const target = item?.choice;
|
|
28
33
|
if (!target) return false;
|
|
29
|
-
screen.picker = { target, phase: "loading", index: 0, draft: "" };
|
|
34
|
+
screen.picker = { target, phase: "loading", index: 0, draft: "", canReclassify: item?.reclassifyChoice === true };
|
|
30
35
|
screen.view = "choice";
|
|
31
36
|
screen.offset = 0;
|
|
32
37
|
screen.manualScroll = false;
|
|
@@ -100,13 +105,17 @@ export function choiceKey(
|
|
|
100
105
|
return;
|
|
101
106
|
}
|
|
102
107
|
if (picker.phase !== "options") return;
|
|
103
|
-
const
|
|
108
|
+
const later = detail.options.length + 1;
|
|
109
|
+
const last = later + (picker.canReclassify ? 1 : 0);
|
|
104
110
|
if (["up", "down", "k", "j"].includes(key)) {
|
|
105
111
|
picker.index = Math.max(0, Math.min(last, picker.index + (key === "up" || key === "k" ? -1 : 1)));
|
|
106
112
|
screen.manualScroll = false;
|
|
107
113
|
} else if (key === "return") {
|
|
108
|
-
if (picker.index ===
|
|
109
|
-
else
|
|
114
|
+
if (picker.index === later) close(screen);
|
|
115
|
+
else {
|
|
116
|
+
picker.reclassifying = picker.canReclassify === true && picker.index === later + 1;
|
|
117
|
+
picker.phase = picker.index === detail.options.length ? "custom" : "confirm";
|
|
118
|
+
}
|
|
110
119
|
screen.offset = 0;
|
|
111
120
|
screen.manualScroll = false;
|
|
112
121
|
}
|
|
@@ -119,7 +128,7 @@ export function choiceKeys(screen: DashboardScreenState): string[] {
|
|
|
119
128
|
case "custom":
|
|
120
129
|
return ["Enter review · Esc cancel"];
|
|
121
130
|
case "confirm":
|
|
122
|
-
return ["Enter save to Bookie", "e edit · Esc cancel"];
|
|
131
|
+
return [screen.picker.reclassifying ? "Enter confirm correction" : "Enter save to Bookie", "e edit · Esc cancel"];
|
|
123
132
|
case "refused":
|
|
124
133
|
return ["r review again · e edit", "Esc cancel"];
|
|
125
134
|
case "saving":
|
|
@@ -138,8 +147,12 @@ export function choiceBody(screen: DashboardScreenState): string[] {
|
|
|
138
147
|
picker.draft = "";
|
|
139
148
|
if (picker.phase !== "saving" && picker.phase !== "saved") picker.phase = "unavailable";
|
|
140
149
|
}
|
|
141
|
-
if (picker.phase === "saved")
|
|
142
|
-
|
|
150
|
+
if (picker.phase === "saved")
|
|
151
|
+
return picker.reclassifying
|
|
152
|
+
? ["Removed from Open choices.", "Original note retained. No answer recorded."]
|
|
153
|
+
: ["Answer saved in Bookie."];
|
|
154
|
+
if (picker.phase === "saving")
|
|
155
|
+
return [picker.reclassifying ? "Saving the correction in Bookie…" : "Saving your answer in Bookie…"];
|
|
143
156
|
if (picker.phase === "loading") return ["Reading this choice from Bookie…"];
|
|
144
157
|
if (picker.phase === "unavailable" || !picker.detail)
|
|
145
158
|
return [
|
|
@@ -148,15 +161,25 @@ export function choiceBody(screen: DashboardScreenState): string[] {
|
|
|
148
161
|
];
|
|
149
162
|
const detail = picker.detail;
|
|
150
163
|
const issues = picker.error ? [picker.error, ""] : [];
|
|
164
|
+
if (picker.phase === "options") {
|
|
165
|
+
picker.canReclassify = screen.items.find((item) => item.key === screen.selectedKey)?.reclassifyChoice === true;
|
|
166
|
+
picker.index = Math.min(picker.index, detail.options.length + 1 + (picker.canReclassify ? 1 : 0));
|
|
167
|
+
}
|
|
151
168
|
if (picker.phase === "custom") return [...issues, detail.label, "", "Write your own answer", picker.draft + "▏"];
|
|
152
169
|
if (picker.phase === "confirm" || picker.phase === "refused")
|
|
153
170
|
return [
|
|
154
171
|
...issues,
|
|
155
172
|
detail.label,
|
|
156
173
|
"",
|
|
157
|
-
"Save this answer in Bookie?",
|
|
174
|
+
picker.reclassifying ? "Not a separate decision?" : "Save this answer in Bookie?",
|
|
158
175
|
"",
|
|
159
|
-
|
|
176
|
+
...(picker.reclassifying
|
|
177
|
+
? [
|
|
178
|
+
"Remove only this item from Open choices.",
|
|
179
|
+
"The original note stays in memory.",
|
|
180
|
+
"No answer will be recorded.",
|
|
181
|
+
]
|
|
182
|
+
: [detail.options[picker.index] ?? picker.draft.trim()]),
|
|
160
183
|
];
|
|
161
184
|
return [
|
|
162
185
|
detail.label,
|
|
@@ -170,6 +193,9 @@ export function choiceBody(screen: DashboardScreenState): string[] {
|
|
|
170
193
|
),
|
|
171
194
|
(picker.index === detail.options.length ? "> " : " ") + "Write my own answer",
|
|
172
195
|
(picker.index === detail.options.length + 1 ? "> " : " ") + "Decide later",
|
|
196
|
+
...(picker.canReclassify
|
|
197
|
+
? [(picker.index === detail.options.length + 2 ? "> " : " ") + "Not a separate decision"]
|
|
198
|
+
: []),
|
|
173
199
|
...(detail.recommendation
|
|
174
200
|
? [
|
|
175
201
|
"",
|
|
@@ -202,12 +228,19 @@ export async function saveChoice(screen: DashboardScreenState, connection: Choic
|
|
|
202
228
|
const picker = screen.picker;
|
|
203
229
|
if (!picker || picker.phase !== "saving" || !picker.detail || !current(screen, picker)) return;
|
|
204
230
|
const option = picker.detail.options[picker.index];
|
|
205
|
-
const
|
|
206
|
-
action: "answer-choice",
|
|
231
|
+
const target = {
|
|
207
232
|
...picker.target,
|
|
208
233
|
revision: picker.detail.revision,
|
|
209
|
-
|
|
210
|
-
|
|
234
|
+
};
|
|
235
|
+
const saved = await connection.change(
|
|
236
|
+
picker.reclassifying
|
|
237
|
+
? { action: "reclassify-choice", ...target }
|
|
238
|
+
: {
|
|
239
|
+
action: "answer-choice",
|
|
240
|
+
...target,
|
|
241
|
+
answer: option === undefined ? { custom: picker.draft.trim() } : { option },
|
|
242
|
+
},
|
|
243
|
+
);
|
|
211
244
|
if (saved) {
|
|
212
245
|
picker.phase = "saved";
|
|
213
246
|
picker.detail = undefined;
|
|
@@ -223,6 +256,8 @@ export async function saveChoice(screen: DashboardScreenState, connection: Choic
|
|
|
223
256
|
connection.state.error ??
|
|
224
257
|
(connection.state.acknowledgment?.state === "refused"
|
|
225
258
|
? connection.state.acknowledgment.effect
|
|
226
|
-
:
|
|
259
|
+
: picker.reclassifying
|
|
260
|
+
? "Bookie could not confirm the correction."
|
|
261
|
+
: "Bookie could not save this answer.");
|
|
227
262
|
}
|
|
228
263
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { taskControlRequest } from "./dashboard-task-controls.ts";
|
|
2
3
|
import { inspectChoice, saveChoice } from "./dashboard-choice-picker.ts";
|
|
3
4
|
import type { DashboardAcknowledgment } from "./dashboard-session-client.ts";
|
|
4
5
|
import { dashboardFile, dashboardTimeline, dashboardSelectedDetail } from "./dashboard-file-cache.ts";
|
|
@@ -446,12 +447,21 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
446
447
|
drawing = false;
|
|
447
448
|
});
|
|
448
449
|
};
|
|
449
|
-
|
|
450
|
+
let commandOwner: DashboardSessionSnapshot | undefined;
|
|
451
|
+
const runCommand = async (line: string, target: DashboardSessionSnapshot | undefined): Promise<void> => {
|
|
450
452
|
const trimmed = line.trim();
|
|
451
453
|
if (trimmed.startsWith("m ")) {
|
|
452
454
|
notice = (await connection.change({ action: "set", edits: trimmed.slice(2).trim() }))
|
|
453
455
|
? "Session models updated"
|
|
454
456
|
: connection.state.error || "Session controls unavailable";
|
|
457
|
+
} else if (trimmed === "task" || trimmed.startsWith("task ")) {
|
|
458
|
+
const action = taskControlRequest(target, trimmed);
|
|
459
|
+
notice =
|
|
460
|
+
typeof action === "string"
|
|
461
|
+
? action
|
|
462
|
+
: (await connection.change(action))
|
|
463
|
+
? "Task control saved. See the selected task for execution and cleanup."
|
|
464
|
+
: connection.state.error || "Task control unavailable";
|
|
455
465
|
} else if (trimmed.startsWith("limit ")) {
|
|
456
466
|
const edit = /^limit (wall|idle) ([0-9]+)$/.exec(trimmed);
|
|
457
467
|
if (!edit) notice = "Use limit wall <seconds> or limit idle <seconds>; 0 restores default";
|
|
@@ -478,13 +488,29 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
478
488
|
else if (key.name === "return") {
|
|
479
489
|
const line = command;
|
|
480
490
|
command = undefined;
|
|
481
|
-
void runCommand(line);
|
|
491
|
+
void runCommand(line, commandOwner);
|
|
482
492
|
} else if (key.name === "backspace") command = [...command].slice(0, -1).join("");
|
|
483
493
|
else if (text && !key.ctrl && !key.meta && !/[\p{Cc}\p{Cf}]/u.test(text) && command.length < 2048)
|
|
484
494
|
command += text;
|
|
485
495
|
redraw();
|
|
486
496
|
return;
|
|
487
497
|
}
|
|
498
|
+
const selectedTask = display.screen.items.find((item) => item.key === display.screen.selectedKey);
|
|
499
|
+
if (
|
|
500
|
+
display.screen.view === "details" &&
|
|
501
|
+
selectedTask?.dispatchTaskId &&
|
|
502
|
+
!key.ctrl &&
|
|
503
|
+
!key.meta &&
|
|
504
|
+
selectedTask.dispatchTaskId === connection.state.snapshot?.taskDispatch?.taskId
|
|
505
|
+
) {
|
|
506
|
+
const shortcut = ({ p: "pause", c: "cancel", u: "resume", b: "budget " } as Record<string, string>)[text ?? ""];
|
|
507
|
+
if (shortcut) {
|
|
508
|
+
commandOwner = connection.state.snapshot;
|
|
509
|
+
command = "task " + shortcut;
|
|
510
|
+
redraw();
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
488
514
|
let action = display.key(
|
|
489
515
|
key.name === "return"
|
|
490
516
|
? "return"
|
|
@@ -520,7 +546,10 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
520
546
|
stop();
|
|
521
547
|
return;
|
|
522
548
|
}
|
|
523
|
-
if (action === "command")
|
|
549
|
+
if (action === "command") {
|
|
550
|
+
commandOwner = connection.state.snapshot;
|
|
551
|
+
command = "";
|
|
552
|
+
}
|
|
524
553
|
if (action === "setting") {
|
|
525
554
|
const selected = display.screen.settingKey ?? "auto";
|
|
526
555
|
const settings = connection.state.snapshot?.settings;
|
|
@@ -606,7 +635,7 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
606
635
|
} else {
|
|
607
636
|
input = createInterface({ input: process.stdin, output: process.stdout, terminal: false });
|
|
608
637
|
input.on("line", (line) => {
|
|
609
|
-
void runCommand(line);
|
|
638
|
+
void runCommand(line, connection.state.snapshot);
|
|
610
639
|
});
|
|
611
640
|
}
|
|
612
641
|
await new Promise<void>((settle) => {
|
|
@@ -101,6 +101,7 @@ export function bookieOpenChoices(options: DashboardScreenOptions): DashboardIte
|
|
|
101
101
|
key: `source:${source.producer}:${source.generation}:${i.id}`,
|
|
102
102
|
label: i.label,
|
|
103
103
|
status: "open-choice",
|
|
104
|
+
...(canAnswer && options.session?.choiceControls?.reclassify === true ? { reclassifyChoice: true as const } : {}),
|
|
104
105
|
...(canAnswer && validChoiceId(i.id)
|
|
105
106
|
? {
|
|
106
107
|
choice: {
|
|
@@ -266,6 +267,89 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
|
|
|
266
267
|
};
|
|
267
268
|
}
|
|
268
269
|
|
|
270
|
+
/** Task summaries are visible only while the granting Bookie source is current. */
|
|
271
|
+
export function currentTaskItem(options: DashboardScreenOptions): DashboardItem | undefined {
|
|
272
|
+
const source = options.session?.observation?.sources.find((s) => s.producer === "bookie-memory");
|
|
273
|
+
const history = source?.taskHistory;
|
|
274
|
+
if (!history || !source || !current(source, options) || source.refresh?.state === "failed") return;
|
|
275
|
+
const last = history.lastObservation;
|
|
276
|
+
const recent = last ? [`Last recorded · ${last.label}`] : [];
|
|
277
|
+
const progress = history.recentProgress ?? [];
|
|
278
|
+
const checkpoint = history.lastCheckpoint;
|
|
279
|
+
const capture = checkpoint
|
|
280
|
+
? [
|
|
281
|
+
checkpoint.state === "published"
|
|
282
|
+
? "Checkpoint saved to private history"
|
|
283
|
+
: "Checkpoint captured · awaiting publication",
|
|
284
|
+
]
|
|
285
|
+
: [];
|
|
286
|
+
const policy = options.session?.taskDispatch;
|
|
287
|
+
const controls = policy?.taskId === history.taskId && policy.counts ? policy : undefined;
|
|
288
|
+
const dispatch = controls
|
|
289
|
+
? [
|
|
290
|
+
`Task dispatch · ${controls.state} · ${controls.outstanding} awaiting cleanup`,
|
|
291
|
+
`${controls.admitted} total attempts · ${controls.limit === null ? "no shared cap" : "shared limit " + controls.limit}`,
|
|
292
|
+
...Object.entries(controls.counts)
|
|
293
|
+
.filter(([owner, c]) => owner === "pi-daddy" || c.admitted || c.limit !== null)
|
|
294
|
+
.map(
|
|
295
|
+
([owner, c]) =>
|
|
296
|
+
`${owner}: ${c.admitted} admitted · ${c.limit === null ? "no attempt cap" : "limit " + c.limit}`,
|
|
297
|
+
),
|
|
298
|
+
]
|
|
299
|
+
: [];
|
|
300
|
+
const details = [
|
|
301
|
+
...capture,
|
|
302
|
+
...(checkpoint
|
|
303
|
+
? [
|
|
304
|
+
`${checkpoint.files} files · ${checkpoint.missing} missing · ${checkpoint.excluded} excluded · captured ${checkpoint.capturedAt}`,
|
|
305
|
+
]
|
|
306
|
+
: []),
|
|
307
|
+
...(progress.length
|
|
308
|
+
? [
|
|
309
|
+
"Recent reported progress",
|
|
310
|
+
...progress.map((row) => `${row.label} · ${row.state} · ${row.owner} · ${row.recordedAt}`),
|
|
311
|
+
]
|
|
312
|
+
: []),
|
|
313
|
+
...dispatch,
|
|
314
|
+
...(controls?.inherited ? ["Shared with this task’s parent. Select the parent task to change controls."] : []),
|
|
315
|
+
...(!controls ? ["Task dispatch controls unavailable in this session."] : []),
|
|
316
|
+
...(controls?.observedAt ? ["Dispatch state checked " + controls.observedAt] : []),
|
|
317
|
+
...recent,
|
|
318
|
+
...(last ? [`Reported by ${last.owner} · ${last.recordedAt}`, `Recorded state: ${last.state}`] : []),
|
|
319
|
+
`${history.observations} recorded observation${history.observations === 1 ? "" : "s"} from connected tools.`,
|
|
320
|
+
"History coverage is partial. An owner can finish while Bookie is unavailable.",
|
|
321
|
+
"Open the producing tool’s receipt to verify a delivery.",
|
|
322
|
+
];
|
|
323
|
+
return {
|
|
324
|
+
...(controls && !controls.inherited ? { dispatchTaskId: history.taskId } : {}),
|
|
325
|
+
key: `selected-task:${source.generation}:${history.taskId}`,
|
|
326
|
+
label: history.title,
|
|
327
|
+
status: "selected",
|
|
328
|
+
elapsed: "",
|
|
329
|
+
previewLines: [
|
|
330
|
+
...dispatch.slice(0, 1),
|
|
331
|
+
...(progress.length
|
|
332
|
+
? ["Last reported step · " + progress[0]!.label]
|
|
333
|
+
: recent.length
|
|
334
|
+
? recent
|
|
335
|
+
: ["No owner observations recorded yet."]),
|
|
336
|
+
...capture,
|
|
337
|
+
],
|
|
338
|
+
briefDetails: details,
|
|
339
|
+
details: [
|
|
340
|
+
...details,
|
|
341
|
+
`Task: ${history.taskId}`,
|
|
342
|
+
"In Pi, /bookie-task switch opens other task histories.",
|
|
343
|
+
...(controls && !controls.inherited
|
|
344
|
+
? [
|
|
345
|
+
":task pause stops new task operations. :task cancel also signals participating workers.",
|
|
346
|
+
":task resume allows new work. :task budget [task|pi-daddy|scout|harness|jev] <attempts|off> sets an owner cap.",
|
|
347
|
+
]
|
|
348
|
+
: []),
|
|
349
|
+
],
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
269
353
|
export function componentItems(options: DashboardScreenOptions): DashboardItem[] {
|
|
270
354
|
return (["bookie", "scout-local", "scout-worker"] as const)
|
|
271
355
|
.map((id) => componentItem(id, options))
|
|
@@ -7,6 +7,7 @@ import { activityStoryItems } from "./dashboard-activity.ts";
|
|
|
7
7
|
import {
|
|
8
8
|
bookieOpenChoices,
|
|
9
9
|
componentItems,
|
|
10
|
+
currentTaskItem,
|
|
10
11
|
isComponentObservation,
|
|
11
12
|
publishedEvidenceItem,
|
|
12
13
|
savedEvidenceItem,
|
|
@@ -200,7 +201,7 @@ function bookieLabel(item: DashboardContribution, source: DashboardSourceSnapsho
|
|
|
200
201
|
function rowText(item: DashboardItem, destination: DashboardDestination, selected: boolean): string {
|
|
201
202
|
const label = clean(item.label);
|
|
202
203
|
const marker = selected ? "> " : " ";
|
|
203
|
-
if (item.key.startsWith("component:")) return marker + label;
|
|
204
|
+
if (item.key.startsWith("component:") || item.key.startsWith("selected-task:")) return marker + label;
|
|
204
205
|
if (item.status === "last-observed") return `${marker}Last seen · ${label}`;
|
|
205
206
|
if (item.reviewSummary) return marker + label;
|
|
206
207
|
if (item.key.startsWith("activity:") && item.status === "observed") return marker + label;
|
|
@@ -308,7 +309,9 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
308
309
|
},
|
|
309
310
|
]
|
|
310
311
|
: [];
|
|
312
|
+
const selectedTask = currentTaskItem(options);
|
|
311
313
|
const items = [
|
|
314
|
+
...(selectedTask ? [selectedTask] : []),
|
|
312
315
|
...input,
|
|
313
316
|
...components.filter(needsUserInput),
|
|
314
317
|
...(ownerTurn && !parentShown
|
|
@@ -362,6 +365,7 @@ export function sessionDashboardItems(options: DashboardScreenOptions): Dashboar
|
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
const workGroups = [
|
|
368
|
+
"Current task",
|
|
365
369
|
"Needs your permission",
|
|
366
370
|
"Needs your decision",
|
|
367
371
|
"Needs your input",
|
|
@@ -379,6 +383,7 @@ export function needsUserInput(item: DashboardItem): boolean {
|
|
|
379
383
|
return !item.reviewSummary && ["needs-you", "approval-wait"].includes(item.status);
|
|
380
384
|
}
|
|
381
385
|
function workGroup(item: DashboardItem): string {
|
|
386
|
+
if (item.key.startsWith("selected-task:")) return "Current task";
|
|
382
387
|
if (item.key.startsWith("component:"))
|
|
383
388
|
return needsUserInput(item) ? "Needs your decision" : item.key === "component:bookie" ? "Memory" : "Research";
|
|
384
389
|
if (item.key.startsWith("activity:")) return "Latest activity";
|
|
@@ -42,7 +42,9 @@ export interface DashboardItem {
|
|
|
42
42
|
observation?: string;
|
|
43
43
|
taskKey?: string;
|
|
44
44
|
timelinePath?: string;
|
|
45
|
+
dispatchTaskId?: string;
|
|
45
46
|
choice?: DashboardChoiceTarget;
|
|
47
|
+
reclassifyChoice?: true;
|
|
46
48
|
approval?: boolean;
|
|
47
49
|
skills?: boolean;
|
|
48
50
|
agent?: boolean;
|
|
@@ -252,7 +254,7 @@ function sessionLocation(screen: DashboardScreenState, width: number): string {
|
|
|
252
254
|
versions: "Versions",
|
|
253
255
|
"version-details": "Version details",
|
|
254
256
|
recap: "Session recap",
|
|
255
|
-
choice: "
|
|
257
|
+
choice: "Project choice",
|
|
256
258
|
"work-mode": "Work mode",
|
|
257
259
|
};
|
|
258
260
|
const name = destinationNames[destination];
|
|
@@ -269,6 +271,8 @@ function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | und
|
|
|
269
271
|
const view = screen.view;
|
|
270
272
|
const brief = width < 34;
|
|
271
273
|
if (view === "choice") return choiceKeys(screen);
|
|
274
|
+
if (view === "details" && selected?.dispatchTaskId)
|
|
275
|
+
return ["p Pause · c Cancel · u Resume · b Budget", "Enter confirms command · Esc back"];
|
|
272
276
|
if (view === "work-mode") return ["↑↓ select · Enter/Space change", "Apply saves · Esc cancels"];
|
|
273
277
|
if (view === "main") {
|
|
274
278
|
if (selected?.choice) return ["↑↓ select · Enter answer", "d details · q close"];
|
|
@@ -391,7 +395,9 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
391
395
|
fixed.push(...wrapDashboardLines(["In the current Pi chat, run /grants dashboard."], width));
|
|
392
396
|
} else if (screen.view !== "choice" && (options.notice || options.problem))
|
|
393
397
|
fixed.push(`! ${clean(options.notice || options.problem || "")}`);
|
|
394
|
-
const ack = options.acknowledgment?.action
|
|
398
|
+
const ack = ["answer-choice", "reclassify-choice"].includes(options.acknowledgment?.action ?? "")
|
|
399
|
+
? undefined
|
|
400
|
+
: options.acknowledgment;
|
|
395
401
|
if (ack?.state === "unconfirmed") {
|
|
396
402
|
const setting =
|
|
397
403
|
(
|
|
@@ -402,6 +408,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
402
408
|
set: "model",
|
|
403
409
|
"set-limit": "limit",
|
|
404
410
|
"set-work-mode": "work mode",
|
|
411
|
+
"task-dispatch": "task control",
|
|
405
412
|
} as Record<string, string>
|
|
406
413
|
)[ack.action] ?? "setting";
|
|
407
414
|
fixed.push(
|
|
@@ -460,7 +467,11 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
460
467
|
"r: recent session activity and review counts",
|
|
461
468
|
"Wide terminals preview the selected item. x shows more session information.",
|
|
462
469
|
"x in a review detail: show or hide its source and exact reference",
|
|
463
|
-
|
|
470
|
+
session?.taskDispatch?.inherited && !disconnected
|
|
471
|
+
? "Select the parent task in Bookie to change shared dispatch controls."
|
|
472
|
+
: session?.taskDispatch && !disconnected
|
|
473
|
+
? ":task pause, :task cancel, :task resume, :task budget [owner] <attempts|off> control registered operations."
|
|
474
|
+
: "Request cancellation in the owning Pi session.",
|
|
464
475
|
"Goals/next steps are owner recommendations, not execution authority.",
|
|
465
476
|
"Reviews apply only to their exact subject; completed is not accepted.",
|
|
466
477
|
"Evidence rows are references; content needs its authorized resolver.",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dashboardRequestTimeout, isDashboardChoiceRequest } from "../kernel/dashboard-request.ts";
|
|
2
|
+
import type { DispatchView, DispatchEdit } from "../governance/task-dispatch.ts";
|
|
1
3
|
import {
|
|
2
4
|
validChoiceDetail,
|
|
3
5
|
type DashboardChoiceAction,
|
|
@@ -15,8 +17,9 @@ export interface DashboardSessionSnapshot {
|
|
|
15
17
|
cost: number | null;
|
|
16
18
|
/** Delegation results in the owning Pi session that reported child usage, and those its host recorded. */
|
|
17
19
|
childUsage?: { results: number; recorded: number; cost: number };
|
|
18
|
-
choiceControls?: { sourceGeneration: string };
|
|
20
|
+
choiceControls?: { sourceGeneration: string; reclassify?: true };
|
|
19
21
|
observation?: DashboardOwnerObservation;
|
|
22
|
+
taskDispatch?: DispatchView;
|
|
20
23
|
activity?: { rootId: string; path: string; taskId: string };
|
|
21
24
|
versions?: EcosystemVersions;
|
|
22
25
|
settings?: DashboardSettingsSnapshot;
|
|
@@ -27,7 +30,9 @@ export interface DashboardSessionSnapshot {
|
|
|
27
30
|
interface DashboardSessionReply extends DashboardSessionSnapshot {
|
|
28
31
|
choiceDetail?: DashboardChoiceDetail;
|
|
29
32
|
choiceSaved?: true;
|
|
33
|
+
choiceReclassified?: true;
|
|
30
34
|
workModeApplied?: true;
|
|
35
|
+
taskDispatchApplied?: true;
|
|
31
36
|
choiceRefreshRequested?: true;
|
|
32
37
|
sourceRefreshRequested?: true;
|
|
33
38
|
}
|
|
@@ -37,13 +42,14 @@ class ChoiceDeclined extends Error {
|
|
|
37
42
|
super(
|
|
38
43
|
stale
|
|
39
44
|
? "Choice is no longer available. Refresh and reopen it."
|
|
40
|
-
: "Bookie declined the
|
|
45
|
+
: "Bookie declined the choice change. Refresh and reopen the item.",
|
|
41
46
|
);
|
|
42
47
|
this.stale = stale;
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
export type DashboardSessionAction = (
|
|
46
51
|
| DashboardChoiceAction
|
|
52
|
+
| { action: "task-dispatch"; edit: DispatchEdit }
|
|
47
53
|
| { action: "get"; refreshChoices?: true; refreshSources?: true }
|
|
48
54
|
| { action: "set"; edits: string }
|
|
49
55
|
| { action: "set-auto"; enabled: boolean }
|
|
@@ -63,8 +69,8 @@ export async function dashboardSessionRequest(
|
|
|
63
69
|
const socket = createConnection(socketPath);
|
|
64
70
|
let output = "";
|
|
65
71
|
socket.setEncoding("utf8");
|
|
66
|
-
const choiceAction = request.action
|
|
67
|
-
socket.setTimeout(
|
|
72
|
+
const choiceAction = isDashboardChoiceRequest(request.action);
|
|
73
|
+
socket.setTimeout(dashboardRequestTimeout(request.action), () =>
|
|
68
74
|
socket.destroy(new Error("dashboard session request timed out")),
|
|
69
75
|
);
|
|
70
76
|
socket.once("error", reject);
|
|
@@ -95,6 +101,10 @@ export async function dashboardSessionRequest(
|
|
|
95
101
|
throw Error("The owner returned an unavailable choice.");
|
|
96
102
|
if (request.action === "answer-choice" && parsed.choiceSaved !== true)
|
|
97
103
|
throw Error("Bookie did not confirm the answer.");
|
|
104
|
+
if (request.action === "reclassify-choice" && parsed.choiceReclassified !== true)
|
|
105
|
+
throw Error("Bookie did not confirm the correction.");
|
|
106
|
+
if (request.action === "task-dispatch" && parsed.taskDispatchApplied !== true)
|
|
107
|
+
throw Error("Task control was not confirmed.");
|
|
98
108
|
if (request.action === "set-work-mode" && parsed.workModeApplied !== true)
|
|
99
109
|
throw Error("The owner did not confirm the work mode.");
|
|
100
110
|
if (
|
|
@@ -140,12 +150,16 @@ export function createDashboardConnection(
|
|
|
140
150
|
const disconnect = () => {
|
|
141
151
|
state.snapshot = undefined;
|
|
142
152
|
const previous = state.lastObserved;
|
|
153
|
+
if (previous && !previous.observation) state.lastObserved = { ...previous, taskDispatch: undefined };
|
|
143
154
|
if (previous?.observation)
|
|
144
155
|
state.lastObserved = {
|
|
145
156
|
...previous,
|
|
157
|
+
taskDispatch: undefined,
|
|
146
158
|
observation: {
|
|
147
159
|
...previous.observation,
|
|
148
|
-
sources: previous.observation.sources.map(
|
|
160
|
+
sources: previous.observation.sources.map(
|
|
161
|
+
({ inventory: _inventory, taskHistory: _history, ...source }) => source,
|
|
162
|
+
),
|
|
149
163
|
},
|
|
150
164
|
};
|
|
151
165
|
};
|
|
@@ -171,7 +185,10 @@ export function createDashboardConnection(
|
|
|
171
185
|
state.acknowledgment.state = snapshot.settings.jev.enabled === requestedJev ? "applied" : "refused";
|
|
172
186
|
return true;
|
|
173
187
|
};
|
|
174
|
-
const matchesOwner = (
|
|
188
|
+
const matchesOwner = (
|
|
189
|
+
snapshot: DashboardSessionSnapshot | undefined,
|
|
190
|
+
target: Pick<DashboardChoiceTarget, "expectedOwner">,
|
|
191
|
+
) => {
|
|
175
192
|
const owner = snapshot?.observation,
|
|
176
193
|
expected = target.expectedOwner;
|
|
177
194
|
return (
|
|
@@ -239,7 +256,12 @@ export function createDashboardConnection(
|
|
|
239
256
|
},
|
|
240
257
|
async change(action: Exclude<DashboardSessionAction, { action: "get" | "inspect-choice" }>) {
|
|
241
258
|
if (!request || !state.snapshot || state.pending) return false;
|
|
242
|
-
|
|
259
|
+
const choiceMutation = action.action === "answer-choice" || action.action === "reclassify-choice";
|
|
260
|
+
if (
|
|
261
|
+
choiceMutation &&
|
|
262
|
+
(!matches(state.snapshot, action) ||
|
|
263
|
+
(action.action === "reclassify-choice" && state.snapshot.choiceControls?.reclassify !== true))
|
|
264
|
+
) {
|
|
243
265
|
state.acknowledgment = {
|
|
244
266
|
action: action.action,
|
|
245
267
|
state: "refused",
|
|
@@ -252,21 +274,25 @@ export function createDashboardConnection(
|
|
|
252
274
|
state.pending = true;
|
|
253
275
|
requestedJev = action.action === "set-jev" ? action.enabled : undefined;
|
|
254
276
|
const effect =
|
|
255
|
-
action.action === "
|
|
256
|
-
? "
|
|
257
|
-
: action.action === "
|
|
258
|
-
? "
|
|
259
|
-
: action.action === "
|
|
260
|
-
? "
|
|
261
|
-
: action.action === "set-
|
|
262
|
-
? "current
|
|
263
|
-
: action.action === "
|
|
264
|
-
?
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
277
|
+
action.action === "task-dispatch"
|
|
278
|
+
? "Dispatch policy for this task"
|
|
279
|
+
: action.action === "answer-choice"
|
|
280
|
+
? "Save this answer in project memory"
|
|
281
|
+
: action.action === "reclassify-choice"
|
|
282
|
+
? "Remove this separate decision; original note retained, no answer recorded"
|
|
283
|
+
: action.action === "set-auto"
|
|
284
|
+
? "current permission handling; admitted work unchanged"
|
|
285
|
+
: action.action === "edit-jev"
|
|
286
|
+
? "use the main Pi session; current values shown below"
|
|
287
|
+
: action.action === "set-jev"
|
|
288
|
+
? "current JEV session; separate paid-call and storage choices"
|
|
289
|
+
: action.action === "set-work-mode"
|
|
290
|
+
? action.scope === "next-request"
|
|
291
|
+
? "next request only, including its children"
|
|
292
|
+
: "future requests in this session; active work unchanged"
|
|
293
|
+
: action.action === "set-telemetry"
|
|
294
|
+
? "optional telemetry polling in this Pi session"
|
|
295
|
+
: "future children; running children unchanged";
|
|
270
296
|
state.acknowledgment = { action: action.action, state: "pending", effect };
|
|
271
297
|
try {
|
|
272
298
|
const snapshot = await request({
|
|
@@ -283,6 +309,25 @@ export function createDashboardConnection(
|
|
|
283
309
|
});
|
|
284
310
|
if (action.action === "answer-choice" && (snapshot.choiceSaved !== true || !matchesOwner(snapshot, action)))
|
|
285
311
|
throw Error("Bookie did not confirm the answer.");
|
|
312
|
+
if (
|
|
313
|
+
action.action === "reclassify-choice" &&
|
|
314
|
+
(snapshot.choiceReclassified !== true || !matchesOwner(snapshot, action))
|
|
315
|
+
)
|
|
316
|
+
throw Error("Bookie did not confirm the correction.");
|
|
317
|
+
if (action.action === "task-dispatch") {
|
|
318
|
+
const expected = action.expectedOwner ?? observedOwner,
|
|
319
|
+
task = snapshot.taskDispatch;
|
|
320
|
+
if (
|
|
321
|
+
!expected ||
|
|
322
|
+
!matchesOwner(snapshot, { expectedOwner: expected }) ||
|
|
323
|
+
!task ||
|
|
324
|
+
!snapshot.taskDispatchApplied ||
|
|
325
|
+
task.taskId !== action.edit.expected.taskId ||
|
|
326
|
+
task.projectId !== action.edit.expected.projectId ||
|
|
327
|
+
task.selectionRevision !== action.edit.expected.selectionRevision
|
|
328
|
+
)
|
|
329
|
+
throw Error("Task control was not confirmed for the selected task.");
|
|
330
|
+
}
|
|
286
331
|
if (action.action === "set-work-mode") {
|
|
287
332
|
const expected = action.expectedOwner ?? observedOwner;
|
|
288
333
|
const acknowledged = snapshot.observation;
|
|
@@ -296,7 +341,14 @@ export function createDashboardConnection(
|
|
|
296
341
|
)
|
|
297
342
|
throw Error("The owner did not confirm the work mode in this session.");
|
|
298
343
|
}
|
|
299
|
-
const {
|
|
344
|
+
const {
|
|
345
|
+
choiceDetail: _detail,
|
|
346
|
+
choiceSaved: _saved,
|
|
347
|
+
choiceReclassified: _corrected,
|
|
348
|
+
workModeApplied: _modeApplied,
|
|
349
|
+
taskDispatchApplied: _dispatchApplied,
|
|
350
|
+
...observed
|
|
351
|
+
} = snapshot;
|
|
300
352
|
if (!accept(observed)) throw Error("owner acknowledgment is stale; reconcile before another action");
|
|
301
353
|
state.acknowledgment.state =
|
|
302
354
|
action.action === "edit-jev"
|
|
@@ -310,7 +362,7 @@ export function createDashboardConnection(
|
|
|
310
362
|
: "applied";
|
|
311
363
|
return true;
|
|
312
364
|
} catch (error) {
|
|
313
|
-
if (
|
|
365
|
+
if (choiceMutation && error instanceof ChoiceDeclined) {
|
|
314
366
|
if (error.stale) disconnect();
|
|
315
367
|
state.acknowledgment.state = "refused";
|
|
316
368
|
state.error = error.message;
|
|
@@ -318,10 +370,9 @@ export function createDashboardConnection(
|
|
|
318
370
|
}
|
|
319
371
|
disconnect();
|
|
320
372
|
state.acknowledgment.state = "unconfirmed";
|
|
321
|
-
state.error =
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
: `Control change not confirmed; inspect owner before retrying: ${error instanceof Error ? error.message : String(error)}`;
|
|
373
|
+
state.error = choiceMutation
|
|
374
|
+
? "Save unconfirmed. Check project memory before retrying."
|
|
375
|
+
: `Control change not confirmed; inspect owner before retrying: ${error instanceof Error ? error.message : String(error)}`;
|
|
325
376
|
return false;
|
|
326
377
|
} finally {
|
|
327
378
|
state.pending = false;
|