pi-daddy 0.49.4 → 0.50.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.
Files changed (149) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/README.md +218 -28
  3. package/dist/governance/initiative-coordinator.d.ts +58 -0
  4. package/dist/governance/initiative-coordinator.d.ts.map +1 -0
  5. package/dist/governance/initiative-coordinator.js +348 -0
  6. package/dist/governance/initiative-coordinator.js.map +1 -0
  7. package/dist/governance/initiative-effects.d.ts +20 -0
  8. package/dist/governance/initiative-effects.d.ts.map +1 -0
  9. package/dist/governance/initiative-effects.js +108 -0
  10. package/dist/governance/initiative-effects.js.map +1 -0
  11. package/dist/governance/initiative-state.d.ts +13 -0
  12. package/dist/governance/initiative-state.d.ts.map +1 -0
  13. package/dist/governance/initiative-state.js +122 -0
  14. package/dist/governance/initiative-state.js.map +1 -0
  15. package/dist/governance/operation-artifact-io.d.ts +8 -0
  16. package/dist/governance/operation-artifact-io.d.ts.map +1 -0
  17. package/dist/governance/operation-artifact-io.js +95 -0
  18. package/dist/governance/operation-artifact-io.js.map +1 -0
  19. package/dist/governance/operation-artifact-scan.d.ts +13 -0
  20. package/dist/governance/operation-artifact-scan.d.ts.map +1 -0
  21. package/dist/governance/operation-artifact-scan.js +71 -0
  22. package/dist/governance/operation-artifact-scan.js.map +1 -0
  23. package/dist/governance/operation-artifacts.d.ts +53 -0
  24. package/dist/governance/operation-artifacts.d.ts.map +1 -0
  25. package/dist/governance/operation-artifacts.js +309 -0
  26. package/dist/governance/operation-artifacts.js.map +1 -0
  27. package/dist/governance/runtime-settlement.d.ts +2 -0
  28. package/dist/governance/runtime-settlement.d.ts.map +1 -1
  29. package/dist/governance/runtime-settlement.js +26 -0
  30. package/dist/governance/runtime-settlement.js.map +1 -1
  31. package/dist/governance/workspace-acceptance.d.ts +5 -0
  32. package/dist/governance/workspace-acceptance.d.ts.map +1 -1
  33. package/dist/governance/workspace-acceptance.js +16 -0
  34. package/dist/governance/workspace-acceptance.js.map +1 -1
  35. package/dist/index.d.ts +8 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +8 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/kernel/dashboard-observation.d.ts +76 -0
  40. package/dist/kernel/dashboard-observation.d.ts.map +1 -0
  41. package/dist/kernel/dashboard-observation.js +49 -0
  42. package/dist/kernel/dashboard-observation.js.map +1 -0
  43. package/dist/kernel/dispatch-operation.d.ts +2 -0
  44. package/dist/kernel/dispatch-operation.d.ts.map +1 -1
  45. package/dist/kernel/dispatch-operation.js.map +1 -1
  46. package/dist/kernel/initiative.d.ts +94 -0
  47. package/dist/kernel/initiative.d.ts.map +1 -0
  48. package/dist/kernel/initiative.js +38 -0
  49. package/dist/kernel/initiative.js.map +1 -0
  50. package/dist/kernel/operation-artifact.d.ts +49 -0
  51. package/dist/kernel/operation-artifact.d.ts.map +1 -0
  52. package/dist/kernel/operation-artifact.js +4 -0
  53. package/dist/kernel/operation-artifact.js.map +1 -0
  54. package/dist/kernel/principal-binding.d.ts +4 -0
  55. package/dist/kernel/principal-binding.d.ts.map +1 -0
  56. package/dist/kernel/principal-binding.js +94 -0
  57. package/dist/kernel/principal-binding.js.map +1 -0
  58. package/dist/kernel/project-paths.d.ts +6 -0
  59. package/dist/kernel/project-paths.d.ts.map +1 -1
  60. package/dist/kernel/project-paths.js +12 -0
  61. package/dist/kernel/project-paths.js.map +1 -1
  62. package/dist/kernel/selected-definitions.d.ts.map +1 -1
  63. package/dist/kernel/selected-definitions.js +5 -91
  64. package/dist/kernel/selected-definitions.js.map +1 -1
  65. package/dist/kernel/workspace-diagnostics.d.ts +24 -0
  66. package/dist/kernel/workspace-diagnostics.d.ts.map +1 -0
  67. package/dist/kernel/workspace-diagnostics.js +81 -0
  68. package/dist/kernel/workspace-diagnostics.js.map +1 -0
  69. package/dist/products/activity-storage.d.ts +2 -0
  70. package/dist/products/activity-storage.d.ts.map +1 -0
  71. package/dist/products/activity-storage.js +119 -0
  72. package/dist/products/activity-storage.js.map +1 -0
  73. package/dist/products/activity-timeline.d.ts +4 -0
  74. package/dist/products/activity-timeline.d.ts.map +1 -1
  75. package/dist/products/activity-timeline.js +12 -0
  76. package/dist/products/activity-timeline.js.map +1 -1
  77. package/dist/products/dashboard-cli.d.ts +2 -0
  78. package/dist/products/dashboard-cli.d.ts.map +1 -1
  79. package/dist/products/dashboard-cli.js +41 -9
  80. package/dist/products/dashboard-cli.js.map +1 -1
  81. package/dist/products/dashboard-display-controls.d.ts.map +1 -1
  82. package/dist/products/dashboard-display-controls.js +30 -0
  83. package/dist/products/dashboard-display-controls.js.map +1 -1
  84. package/dist/products/dashboard-file-cache.d.ts +10 -0
  85. package/dist/products/dashboard-file-cache.d.ts.map +1 -0
  86. package/dist/products/dashboard-file-cache.js +38 -0
  87. package/dist/products/dashboard-file-cache.js.map +1 -0
  88. package/dist/products/dashboard-panels.d.ts +6 -0
  89. package/dist/products/dashboard-panels.d.ts.map +1 -0
  90. package/dist/products/dashboard-panels.js +179 -0
  91. package/dist/products/dashboard-panels.js.map +1 -0
  92. package/dist/products/dashboard-screen.d.ts +8 -0
  93. package/dist/products/dashboard-screen.d.ts.map +1 -1
  94. package/dist/products/dashboard-screen.js +86 -15
  95. package/dist/products/dashboard-screen.js.map +1 -1
  96. package/dist/products/dashboard-session-client.d.ts +16 -2
  97. package/dist/products/dashboard-session-client.d.ts.map +1 -1
  98. package/dist/products/dashboard-session-client.js +64 -11
  99. package/dist/products/dashboard-session-client.js.map +1 -1
  100. package/dist/products/dashboard-settings.d.ts.map +1 -1
  101. package/dist/products/dashboard-settings.js +4 -6
  102. package/dist/products/dashboard-settings.js.map +1 -1
  103. package/dist/products/ecosystem-versions.d.ts +1 -1
  104. package/dist/products/ecosystem-versions.d.ts.map +1 -1
  105. package/extensions/activity-timeline.ts +3 -1
  106. package/extensions/artifact-bridge.ts +130 -0
  107. package/extensions/dashboard-live.ts +63 -0
  108. package/extensions/dashboard-observation.ts +39 -0
  109. package/extensions/dashboard-session-server.ts +45 -3
  110. package/extensions/dashboard-sources.ts +124 -0
  111. package/extensions/delegation-artifacts.ts +125 -0
  112. package/extensions/delegation-operations.ts +100 -42
  113. package/extensions/ecosystem-versions.ts +12 -5
  114. package/extensions/grants-command.ts +34 -6
  115. package/extensions/grants.ts +9 -20
  116. package/extensions/initiative-dashboard.ts +143 -0
  117. package/extensions/initiative-runtime.ts +406 -0
  118. package/extensions/runtime-snapshot.ts +121 -2
  119. package/extensions/session-environment.ts +13 -1
  120. package/extensions/session.ts +28 -10
  121. package/extensions/workspace-diagnostics.ts +90 -0
  122. package/package.json +1 -1
  123. package/src/governance/initiative-coordinator.ts +400 -0
  124. package/src/governance/initiative-effects.ts +146 -0
  125. package/src/governance/initiative-state.ts +144 -0
  126. package/src/governance/operation-artifact-io.ts +103 -0
  127. package/src/governance/operation-artifact-scan.ts +77 -0
  128. package/src/governance/operation-artifacts.ts +363 -0
  129. package/src/governance/runtime-settlement.ts +28 -0
  130. package/src/governance/workspace-acceptance.ts +18 -0
  131. package/src/index.ts +13 -0
  132. package/src/kernel/dashboard-observation.ts +109 -0
  133. package/src/kernel/dispatch-operation.ts +2 -0
  134. package/src/kernel/initiative.ts +126 -0
  135. package/src/kernel/operation-artifact.ts +46 -0
  136. package/src/kernel/principal-binding.ts +104 -0
  137. package/src/kernel/project-paths.ts +16 -0
  138. package/src/kernel/selected-definitions.ts +5 -100
  139. package/src/kernel/workspace-diagnostics.ts +110 -0
  140. package/src/products/activity-storage.ts +128 -0
  141. package/src/products/activity-timeline.ts +11 -0
  142. package/src/products/dashboard-cli.ts +44 -9
  143. package/src/products/dashboard-display-controls.ts +27 -0
  144. package/src/products/dashboard-file-cache.ts +38 -0
  145. package/src/products/dashboard-panels.ts +217 -0
  146. package/src/products/dashboard-screen.ts +107 -17
  147. package/src/products/dashboard-session-client.ts +78 -14
  148. package/src/products/dashboard-settings.ts +4 -6
  149. package/src/products/ecosystem-versions.ts +2 -1
@@ -1,3 +1,4 @@
1
+ import { sessionDashboardItems, sessionPanelLines, type DashboardDestination } from "./dashboard-panels.ts";
1
2
  import { dashboardSettingsLines, type DashboardSettingKey } from "./dashboard-settings.ts";
2
3
  /** Height-bounded, task-first view. Permission state is always supplied by the owner. */
3
4
  import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
@@ -21,6 +22,10 @@ export interface DashboardItem {
21
22
  }
22
23
  export interface DashboardScreenState {
23
24
  view: "main" | "details" | "models" | "help" | "versions" | "version-details" | "settings";
25
+ destination?: DashboardDestination;
26
+ expanded?: boolean;
27
+ manualScroll?: boolean;
28
+ selections?: Record<string, string>;
24
29
  settingKey?: DashboardSettingKey;
25
30
  versionId?: EcosystemVersionRow["id"];
26
31
  versionRows?: EcosystemVersionRow[];
@@ -39,17 +44,26 @@ function wrapped(lines: string[], width: number): string[] {
39
44
  return lines.flatMap((line) => {
40
45
  const result: string[] = [];
41
46
  let row = "";
42
- for (const character of dashboardText(line)) {
43
- if (row && cellWidth(row + character) > width) {
47
+ for (const word of dashboardText(line).split(/\s+/)) {
48
+ if (row && cellWidth(row + " " + word) > width) {
44
49
  result.push(row);
45
50
  row = "";
46
51
  }
47
- row += character;
52
+ if (cellWidth(word) > width) {
53
+ for (const character of word) {
54
+ if (row && cellWidth(row + character) > width) {
55
+ result.push(row);
56
+ row = "";
57
+ }
58
+ row += character;
59
+ }
60
+ } else row += (row ? " " : "") + word;
48
61
  }
49
62
  result.push(row);
50
63
  return result;
51
64
  });
52
65
  }
66
+
53
67
  function elapsed(ms: number): string {
54
68
  const seconds = Math.max(0, Math.floor(ms / 1000));
55
69
  const minutes = Math.floor(seconds / 60);
@@ -157,6 +171,9 @@ export interface DashboardScreenOptions {
157
171
  color?: boolean;
158
172
  content?: { title: string; text: string };
159
173
  command?: string;
174
+ connected?: boolean;
175
+ acknowledgment?: string;
176
+ now?: Date;
160
177
  }
161
178
  /** Selection follows stable identity through refresh, never an unrelated task at the old row index. */
162
179
  export function renderDashboardScreen(options: DashboardScreenOptions): string {
@@ -178,7 +195,11 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
178
195
  "Use the owner's prompt, or a to enable Auto.",
179
196
  ],
180
197
  }));
181
- const allItems = [...approvals, ...options.items];
198
+ const modern = Boolean(session?.observation);
199
+ const allItems = [
200
+ ...(!modern || ["now", "work"].includes(screen.destination ?? "now") ? approvals : []),
201
+ ...(modern ? sessionDashboardItems(options) : options.items),
202
+ ];
182
203
  const items = allItems.filter((item) =>
183
204
  options.filter === "agents"
184
205
  ? item.agent
@@ -191,7 +212,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
191
212
  const live = items.filter((item) => active(item.status)),
192
213
  needsAttention = items.filter((item) => attention(item.status)),
193
214
  past = items.filter((item) => !active(item.status) && !attention(item.status)).reverse();
194
- screen.items = [...live, ...needsAttention, ...(options.history ? past : [])];
215
+ screen.items = modern ? items : [...live, ...needsAttention, ...(options.history ? past : [])];
195
216
  if (screen.view === "details" && !screen.items.some((item) => item.key === screen.selectedKey)) {
196
217
  const detail = items.find((item) => item.key === screen.selectedKey);
197
218
  if (detail) screen.items.push(detail);
@@ -202,26 +223,40 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
202
223
  screen.versionRows = session?.versions?.rows ?? [];
203
224
  if (!screen.versionRows.some((row) => row.id === screen.versionId)) screen.versionId = screen.versionRows[0]?.id;
204
225
  const selectedVersion = screen.versionRows.find((row) => row.id === screen.versionId);
205
- const mode = session ? `Auto ${session.auto.enabled ? "ON" : "OFF"}` : "Auto unavailable";
226
+ const mode =
227
+ session && options.connected !== false ? `Auto ${session.auto.enabled ? "ON" : "OFF"}` : "Auto unavailable";
206
228
  const header = `PI DADDY | ${mode}${options.pending ? " …" : session ? " [a]" : ""}`;
207
229
  const footer =
208
230
  options.command !== undefined
209
231
  ? [`: ${clean(options.command)}`]
210
232
  : screen.view === "settings"
211
- ? ["↑↓ select · Enter toggle/edit · Esc back", "0 restores a default limit · s settings"]
233
+ ? ["↑↓ select · Enter toggle/edit · Esc back", "0 default limit · PgUp/PgDn scroll · s settings"]
212
234
  : screen.view === "main" || screen.view === "versions"
213
- ? ["↑↓ select · Enter details · a Auto", "m models · v versions · s settings · ?"]
235
+ ? [
236
+ modern ? "↑↓ select · PgUp/PgDn scroll · Enter details" : "↑↓ select · Enter details · a Auto",
237
+ "m models · v versions · s settings · ?",
238
+ ]
214
239
  : [
215
240
  "↑↓ scroll · Esc back · a Auto",
216
241
  screen.view === "details" ? "p prompt · f final · : command · ? help" : ": command · ? help",
217
242
  ];
218
243
  const fixed = [
219
244
  header,
220
- session
245
+ session && options.connected !== false
221
246
  ? `Permissions connected${pending.length ? ` · ${pending.length} needs you` : ""}`
222
247
  : "Permission controls disconnected",
248
+ ...(modern
249
+ ? [
250
+ width >= 74
251
+ ? "1 Now · 2 Work · 3 Reviews · 4 Activity · 5 Evidence · 6 Settings"
252
+ : `${(screen.destination ?? "now").toUpperCase()} · 1–6 views · x expand`,
253
+ ]
254
+ : []),
223
255
  ];
224
256
  if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
257
+ if (options.acknowledgment) fixed.push(clean(options.acknowledgment));
258
+ if (modern && options.connected === false)
259
+ fixed.push(`LAST OBSERVED: ${session!.observation!.observedAt}; live state unknown`);
225
260
  const body: string[] = [];
226
261
  if (screen.view === "help")
227
262
  body.push(
@@ -229,6 +264,13 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
229
264
  "↑/↓ or j/k: select; Enter/d: details",
230
265
  "a: toggle Daddy permission Auto",
231
266
  "m: session models; v: ecosystem versions; s: settings",
267
+ "1–6: Now / Work / Reviews / Activity / Evidence / Settings",
268
+ "x: compact/expanded (96 columns); selection is preserved",
269
+ "No cancellation shortcut: request it in the owning Pi session.",
270
+ "Goals/next steps are owner recommendations, not execution authority.",
271
+ "Reviews apply only to their exact subject; completed is not accepted.",
272
+ "Evidence rows are references; content needs its authorized resolver.",
273
+ "Memory sample covers the parent only; host/child memory is unknown.",
232
274
  "h: show/hide finished history",
233
275
  "Tab: Everything / Agents / Skills / Needs-you",
234
276
  "p/f: selected retained prompt/final",
@@ -240,7 +282,21 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
240
282
  "Finished means observed completion, not acceptance.",
241
283
  );
242
284
  else if (screen.view === "settings") {
243
- body.push(...dashboardSettingsLines(session?.settings, session?.auto.enabled, screen.settingKey ?? "auto"));
285
+ body.push(
286
+ ...dashboardSettingsLines(
287
+ options.connected === false && session?.settings ? { ...session.settings, editable: false } : session?.settings,
288
+ session?.auto.enabled,
289
+ screen.settingKey ?? "auto",
290
+ ),
291
+ );
292
+ if (session?.observation)
293
+ body.push(
294
+ "CAPTURE · startup configuration (not a retention receipt)",
295
+ `Transcripts: ${session.observation.capture.transcripts ? "configured" : "off"}`,
296
+ `Diagnostics: ${session.observation.capture.diagnostics ? "configured" : "off"}`,
297
+ "Capture changes require a new parent launch.",
298
+ "m models · v versions",
299
+ );
244
300
  } else if (screen.view === "versions" || screen.view === "version-details") {
245
301
  body.push("VERSIONS");
246
302
  if (!session?.versions) body.push("Owner has not reported versions.");
@@ -278,6 +334,8 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
278
334
  ...(selected?.details ?? []),
279
335
  );
280
336
  if (options.content) body.push("", options.content.title, ...options.content.text.split(/\r?\n/));
337
+ } else if (modern) {
338
+ body.push(...sessionPanelLines(options, screen.items, width));
281
339
  } else {
282
340
  const requestFinished = options.currentStatus && !active(options.currentStatus);
283
341
  body.push(
@@ -323,21 +381,34 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
323
381
  if (history) body.push(history);
324
382
  }
325
383
 
326
- const detailBody = screen.view === "main" || screen.view === "versions" ? body : wrapped(body, width);
384
+ const detailBody =
385
+ (screen.view === "main" && (!modern || (screen.expanded && width >= 96))) || screen.view === "versions"
386
+ ? body
387
+ : wrapped(body, width);
388
+ const clipped = modern && detailBody.length > Math.max(0, height - fixed.length - footer.length);
389
+ if (clipped) footer.push("");
327
390
  const room = Math.max(0, height - fixed.length - footer.length);
328
391
  if (screen.view === "versions" && selectedVersion && room > 0) {
329
392
  const row = 2 + screen.versionRows.findIndex((value) => value.id === screen.versionId) * 2;
330
393
  if (row < screen.offset) screen.offset = row;
331
394
  else if (row + 1 >= screen.offset + room) screen.offset = Math.max(0, row + 2 - room);
332
395
  }
333
- if (screen.view === "settings" && room > 0) {
396
+ if (screen.view === "settings" && room > 0 && !screen.manualScroll) {
334
397
  const row = detailBody.findIndex((line) => line.startsWith(">"));
335
398
  if (row < screen.offset) screen.offset = Math.max(0, row);
336
399
  else if (row >= screen.offset + room) screen.offset = Math.max(0, row - room + 1);
337
400
  }
401
+ if (modern && screen.view === "main" && room > 0 && !screen.manualScroll) {
402
+ const selectedRow = detailBody.findIndex((line) => line.startsWith(">"));
403
+ if (selectedRow >= screen.offset + room) screen.offset = selectedRow - room + 1;
404
+ else if (selectedRow >= 0 && selectedRow < screen.offset) screen.offset = selectedRow;
405
+ }
338
406
  const offset =
339
- screen.view === "main" ? 0 : Math.max(0, Math.min(screen.offset, Math.max(0, detailBody.length - room)));
407
+ screen.view === "main" && !modern ? 0 : Math.max(0, Math.min(screen.offset, Math.max(0, detailBody.length - room)));
340
408
  screen.offset = offset;
409
+ if (clipped)
410
+ footer[footer.length - 1] =
411
+ `Rows ${offset + 1}–${Math.min(offset + room, detailBody.length)}/${detailBody.length} · PgUp/PgDn`;
341
412
  const lines = [...fixed, ...detailBody.slice(offset, offset + room)];
342
413
  while (lines.length < height - footer.length) lines.push("");
343
414
  const output =
@@ -348,10 +419,29 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
348
419
  .map((line, index) => {
349
420
  const safe = truncate(dashboardText(line), width);
350
421
  if (!options.color) return safe;
351
- const section =
352
- /^(CURRENT REQUEST|LATEST REQUEST|CURRENT WORK|NEEDS YOU|NEEDS ATTENTION|WORK IN PROGRESS|HISTORY|VERSIONS|SETTINGS|STARTUP LIMITS|SESSION MODELS|DASHBOARD KEYS|MANAGE)/.test(
353
- safe,
354
- );
422
+ const section = [
423
+ "NOW",
424
+ "WORK",
425
+ "REVIEWS",
426
+ "ACTIVITY",
427
+ "EVIDENCE",
428
+ "GOAL",
429
+ "NEXT",
430
+ "COMPONENTS",
431
+ "CURRENT REQUEST",
432
+ "LATEST REQUEST",
433
+ "CURRENT WORK",
434
+ "NEEDS YOU",
435
+ "NEEDS ATTENTION",
436
+ "WORK IN PROGRESS",
437
+ "HISTORY",
438
+ "VERSIONS",
439
+ "SETTINGS",
440
+ "STARTUP LIMITS",
441
+ "SESSION MODELS",
442
+ "DASHBOARD KEYS",
443
+ "MANAGE",
444
+ ].some((label) => safe.startsWith(label));
355
445
  const code =
356
446
  index === 0
357
447
  ? "1;36"
@@ -1,3 +1,4 @@
1
+ import type { DashboardOwnerObservation } from "../kernel/dashboard-observation.ts";
1
2
  import type { DashboardSettingsSnapshot } from "./dashboard-settings.ts";
2
3
  import type { EcosystemVersions } from "./ecosystem-versions.ts";
3
4
  import { createConnection } from "node:net";
@@ -5,6 +6,7 @@ import { createConnection } from "node:net";
5
6
  export interface DashboardSessionSnapshot {
6
7
  rows: Array<{ definition: string; model: string; thinking: string; source: string }>;
7
8
  cost: number | null;
9
+ observation?: DashboardOwnerObservation;
8
10
  activity?: { rootId: string; path: string; taskId: string };
9
11
  versions?: EcosystemVersions;
10
12
  settings?: DashboardSettingsSnapshot;
@@ -12,12 +14,13 @@ export interface DashboardSessionSnapshot {
12
14
  pendingApprovals: Array<{ id: string; subject: string; capability: string }>;
13
15
  }
14
16
 
15
- export type DashboardSessionAction =
17
+ export type DashboardSessionAction = (
16
18
  | { action: "get" }
17
19
  | { action: "set"; edits: string }
18
20
  | { action: "set-auto"; enabled: boolean }
19
21
  | { action: "set-jev"; enabled: boolean }
20
- | { action: "set-limit"; key: "wall" | "idle"; seconds: number };
22
+ | { action: "set-limit"; key: "wall" | "idle"; seconds: number }
23
+ ) & { expectedOwner?: { sessionId: string; cwd: string; generation: string } };
21
24
 
22
25
  export async function dashboardSessionRequest(
23
26
  socketPath: string,
@@ -55,41 +58,102 @@ export async function dashboardSessionRequest(
55
58
  });
56
59
  }
57
60
 
58
- /** A slow status poll cannot overwrite a newer acknowledged mutation. Failed requests expose no guessed mode. */
61
+ /** Controls use only a connected owner; last observations remain explicitly disconnected evidence. */
59
62
  export function createDashboardConnection(
60
63
  request?: (action: DashboardSessionAction) => Promise<DashboardSessionSnapshot>,
61
64
  ) {
62
- const state: { snapshot?: DashboardSessionSnapshot; pending: boolean; error?: string } = { pending: false };
63
- let generation = 0;
65
+ const state: {
66
+ snapshot?: DashboardSessionSnapshot;
67
+ lastObserved?: DashboardSessionSnapshot;
68
+ pending: boolean;
69
+ error?: string;
70
+ acknowledgment?: { action: string; state: "pending" | "applied" | "refused" | "unconfirmed"; effect: string };
71
+ } = { pending: false };
72
+ let generation = 0,
73
+ poll = 0,
74
+ requestedJev: boolean | undefined;
75
+ const retired = new Set<string>();
76
+ const accept = (snapshot: DashboardSessionSnapshot) => {
77
+ const previous = state.lastObserved?.observation,
78
+ next = snapshot.observation;
79
+ if (previous && !next) return false;
80
+ if (next && retired.has(next.generation)) return false;
81
+ if (previous && next && previous.generation === next.generation && next.sequence <= previous.sequence) return false;
82
+ if (previous && next && previous.generation !== next.generation) {
83
+ if (retired.size >= 16) throw Error("Dashboard owner changed repeatedly; reopen the panel");
84
+ retired.add(previous.generation);
85
+ }
86
+ state.snapshot = snapshot;
87
+ state.lastObserved = snapshot;
88
+ state.error = undefined;
89
+ if (
90
+ state.acknowledgment?.state === "pending" &&
91
+ requestedJev !== undefined &&
92
+ snapshot.settings?.jev &&
93
+ !snapshot.settings.jev.pending
94
+ )
95
+ state.acknowledgment.state = snapshot.settings.jev.enabled === requestedJev ? "applied" : "refused";
96
+ return true;
97
+ };
64
98
  return {
65
99
  state,
66
100
  async refresh() {
67
101
  if (!request || state.pending) return;
68
- const observed = generation;
102
+ const observed = generation,
103
+ order = ++poll;
69
104
  try {
70
105
  const snapshot = await request({ action: "get" });
71
- if (generation === observed) {
72
- state.snapshot = snapshot;
73
- state.error = undefined;
106
+ if (generation === observed && order === poll && !accept(snapshot)) {
107
+ state.snapshot = undefined;
108
+ state.error = "Owner observation is stale or unavailable; controls disabled until a fresh reply.";
74
109
  }
75
110
  } catch (error) {
76
- if (generation === observed) {
111
+ if (generation === observed && order === poll) {
77
112
  state.snapshot = undefined;
78
- state.error = `Controls unavailable: ${error instanceof Error ? error.message : String(error)}`;
113
+ state.error = `Controls unavailable; showing last observation: ${error instanceof Error ? error.message : String(error)}`;
79
114
  }
80
115
  }
81
116
  },
82
117
  async change(action: Exclude<DashboardSessionAction, { action: "get" }>) {
83
118
  if (!request || !state.snapshot || state.pending) return false;
119
+ const observedOwner = state.snapshot.observation;
84
120
  generation++;
85
121
  state.pending = true;
122
+ requestedJev = action.action === "set-jev" ? action.enabled : undefined;
123
+ const effect =
124
+ action.action === "set-auto"
125
+ ? "current permission handling; admitted work unchanged"
126
+ : action.action === "set-jev"
127
+ ? "current JEV session; separate paid-call and storage choices"
128
+ : "future children; running children unchanged";
129
+ state.acknowledgment = { action: action.action, state: "pending", effect };
86
130
  try {
87
- state.snapshot = await request(action);
88
- state.error = undefined;
131
+ const snapshot = await request({
132
+ ...action,
133
+ ...(observedOwner
134
+ ? {
135
+ expectedOwner: {
136
+ sessionId: observedOwner.sessionId,
137
+ cwd: observedOwner.cwd,
138
+ generation: observedOwner.generation,
139
+ },
140
+ }
141
+ : {}),
142
+ });
143
+ if (!accept(snapshot)) throw Error("owner acknowledgment is stale; reconcile before another action");
144
+ state.acknowledgment.state =
145
+ action.action === "set-jev"
146
+ ? snapshot.settings?.jev.pending
147
+ ? "pending"
148
+ : snapshot.settings?.jev.enabled === action.enabled
149
+ ? "applied"
150
+ : "refused"
151
+ : "applied";
89
152
  return true;
90
153
  } catch (error) {
91
154
  state.snapshot = undefined;
92
- state.error = `Control change not confirmed: ${error instanceof Error ? error.message : String(error)}`;
155
+ state.acknowledgment.state = "unconfirmed";
156
+ state.error = `Control change not confirmed; inspect owner before retrying: ${error instanceof Error ? error.message : String(error)}`;
93
157
  return false;
94
158
  } finally {
95
159
  state.pending = false;
@@ -71,12 +71,10 @@ export function dashboardSettingsLines(
71
71
  ...(jev.error ? [` ${jev.error}`] : []),
72
72
  row("wall", `Child wall: ${settings.wallSeconds}s (${settings.wallSource})`),
73
73
  row("idle", `Child idle: ${settings.idleSeconds}s (${settings.idleSource})`),
74
- settings.editable
75
- ? "Edits apply to future children from this parent."
76
- : "Read-only: change settings in the owning parent.",
77
- "Running children keep their captured limits.",
78
- "JEV ON asks paid-call and LoRA-storage consent in Pi.",
79
- "Auto never supplies that consent. No model token budget.",
74
+ settings.editable ? "Limits affect future children only." : "Read-only: change settings in the owning parent.",
75
+ "Running children keep their limits.",
76
+ "JEV needs separate call/storage consent in Pi.",
77
+ "Auto does not grant JEV consent. No token budget.",
80
78
  "",
81
79
  "STARTUP LIMITS · restart to change",
82
80
  row("descendants", `Active descendants: ${settings.descendants} (${settings.reserved} reserved) · PI_DADDY_FANOUT`),
@@ -1,5 +1,6 @@
1
1
  /** Operator version inventory. These observations do not qualify runtime compatibility. */
2
- export type EcosystemPackageId = "pi" | "pi-daddy" | "principal-pi-skills" | "skill-harness";
2
+ export type EcosystemPackageId =
3
+ "pi" | "pi-daddy" | "principal-pi-skills" | "skill-harness" | "pi-scout-research" | "bookie-pi-skills";
3
4
  export interface EcosystemVersionRow {
4
5
  id: EcosystemPackageId;
5
6
  label: string;