pi-daddy 0.52.0 → 0.53.1

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 (43) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +22 -10
  3. package/dist/products/dashboard-cli.d.ts.map +1 -1
  4. package/dist/products/dashboard-cli.js +27 -5
  5. package/dist/products/dashboard-cli.js.map +1 -1
  6. package/dist/products/dashboard-display-controls.js +3 -3
  7. package/dist/products/dashboard-display-controls.js.map +1 -1
  8. package/dist/products/dashboard-handshake.d.ts +2 -0
  9. package/dist/products/dashboard-handshake.d.ts.map +1 -1
  10. package/dist/products/dashboard-handshake.js +39 -43
  11. package/dist/products/dashboard-handshake.js.map +1 -1
  12. package/dist/products/dashboard-herdr.d.ts.map +1 -1
  13. package/dist/products/dashboard-herdr.js +7 -1
  14. package/dist/products/dashboard-herdr.js.map +1 -1
  15. package/dist/products/dashboard-panels.d.ts.map +1 -1
  16. package/dist/products/dashboard-panels.js +3 -1
  17. package/dist/products/dashboard-panels.js.map +1 -1
  18. package/dist/products/dashboard-screen.d.ts +1 -0
  19. package/dist/products/dashboard-screen.d.ts.map +1 -1
  20. package/dist/products/dashboard-screen.js +14 -3
  21. package/dist/products/dashboard-screen.js.map +1 -1
  22. package/dist/products/dashboard-session-client.d.ts +5 -2
  23. package/dist/products/dashboard-session-client.d.ts.map +1 -1
  24. package/dist/products/dashboard-session-client.js +14 -10
  25. package/dist/products/dashboard-session-client.js.map +1 -1
  26. package/dist/products/dashboard-settings.d.ts +10 -1
  27. package/dist/products/dashboard-settings.d.ts.map +1 -1
  28. package/dist/products/dashboard-settings.js +26 -1
  29. package/dist/products/dashboard-settings.js.map +1 -1
  30. package/extensions/dashboard-session-server.ts +6 -1
  31. package/extensions/dashboard-settings.ts +15 -1
  32. package/extensions/grants.ts +10 -4
  33. package/extensions/session-report.ts +4 -0
  34. package/extensions/session.ts +2 -1
  35. package/package.json +2 -2
  36. package/src/products/dashboard-cli.ts +21 -6
  37. package/src/products/dashboard-display-controls.ts +3 -3
  38. package/src/products/dashboard-handshake.ts +45 -49
  39. package/src/products/dashboard-herdr.ts +9 -1
  40. package/src/products/dashboard-panels.ts +3 -1
  41. package/src/products/dashboard-screen.ts +18 -5
  42. package/src/products/dashboard-session-client.ts +17 -12
  43. package/src/products/dashboard-settings.ts +36 -2
@@ -3,6 +3,7 @@ import { randomUUID } from "node:crypto";
3
3
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
4
  import type { GrantsSession } from "./session.ts";
5
5
  import type { DashboardJevState, DashboardSettingsSnapshot } from "../src/products/dashboard-settings.ts";
6
+ import { isJevEditAction, type JevEditAction } from "../src/products/dashboard-settings.ts";
6
7
  import { MAX_CHILDREN_PER_CALL } from "../src/kernel/fanout.ts";
7
8
  import {
8
9
  ENV_CHILD_TIMEOUT,
@@ -69,7 +70,7 @@ const safeStorageRoot = (value: unknown) =>
69
70
  : undefined;
70
71
  export async function dashboardJev(
71
72
  session: GrantsSession,
72
- action: "status" | "enable" | "disable",
73
+ action: "status" | "enable" | "disable" | JevEditAction,
73
74
  ): Promise<DashboardJevState> {
74
75
  const current = owner(session, action !== "status");
75
76
  const pi = bridges.get(session);
@@ -95,6 +96,10 @@ export async function dashboardJev(
95
96
  mode?: string;
96
97
  storage?: string | null;
97
98
  remaining?: number;
99
+ used?: number;
100
+ limit?: number;
101
+ hintsEnabled?: boolean;
102
+ controls?: unknown;
98
103
  availability?: string;
99
104
  providerReadiness?: string;
100
105
  selectedProvider?: string | null;
@@ -115,8 +120,17 @@ export async function dashboardJev(
115
120
  else resolve(unavailable("JEV owner is not bound to this session"));
116
121
  return;
117
122
  }
123
+ if (value.error && isJevEditAction(action)) {
124
+ reject(new Error("JEV settings request declined. Check the main Pi session."));
125
+ return;
126
+ }
127
+ const count = (n: unknown) => (typeof n === "number" && Number.isSafeInteger(n) && n >= 0 ? n : undefined);
118
128
  resolve({
119
129
  available: true,
130
+ controls: Array.isArray(value.status.controls) ? value.status.controls.filter(isJevEditAction) : undefined,
131
+ used: count(value.status.used),
132
+ limit: count(value.status.limit),
133
+ hintsEnabled: typeof value.status.hintsEnabled === "boolean" ? value.status.hintsEnabled : undefined,
120
134
  enabled: value.status.enabled,
121
135
  pending: value.pending === true,
122
136
  mode: safeText(value.status.mode),
@@ -105,7 +105,9 @@ export default function (pi: ExtensionAPI, trustedSession?: GrantsSession) {
105
105
  session.ensureDefinitions = () =>
106
106
  (selectedReady ??= (async () => {
107
107
  const lifecycle = session.reloadLifecycle;
108
- await loadProjectDefinitions(session, session.cwd, lifecycle, pi.getCommands());
108
+ const selected = pi.getCommands();
109
+ // The resource paths can stay unchanged while their bytes or companion bindings change.
110
+ await loadProjectDefinitions(session, session.cwd, lifecycle, selected);
109
111
  assertDiscoveryHealthy(session, lifecycle);
110
112
  delegation.refreshSpawnable();
111
113
  if (selectedReportContext)
@@ -191,7 +193,11 @@ export default function (pi: ExtensionAPI, trustedSession?: GrantsSession) {
191
193
  // delegate by `tools:`, and an operator whose `agent:` spawns have all started failing deserves to
192
194
  // know it was the *scan* that broke rather than the grant.
193
195
  try {
194
- await loadProjectDefinitions(session, ctx.cwd, reload.lifecycle, session.ensureDefinitions ? [] : undefined);
196
+ // Pi exposes installed selections at open. Later contributors arrive by the first
197
+ // request, when ensureDefinitions binds the complete snapshot before any dispatch.
198
+ const preview = ctx.mode === "tui" && session.depth === 0 && !session.ownExecutionId && session.governed;
199
+ const initialCommands = session.ensureDefinitions ? (preview ? pi.getCommands() : []) : undefined;
200
+ await loadProjectDefinitions(session, ctx.cwd, reload.lifecycle, initialCommands);
195
201
  } catch (error) {
196
202
  if (session.reloadLifecycle !== reload.lifecycle) return undefined;
197
203
  if (error instanceof BoundedReadCleanupError) {
@@ -275,8 +281,8 @@ export default function (pi: ExtensionAPI, trustedSession?: GrantsSession) {
275
281
  );
276
282
  }
277
283
  if (session.reloadLifecycle !== reload.lifecycle) return undefined;
278
- // Explicit installation handshake. It only runs in a Herdr-hosted TUI, asks once, and the only branch
279
- // that links software is the literal human choice "Install and open".
284
+ // Only a parent opens the dashboard. View-only children inherit the parent's controls.
285
+ if (session.depth !== 0 || session.ownExecutionId || session.malformedBounds.length) return undefined;
280
286
  try {
281
287
  const sessionEndpoint = await ensureDashboardSessionServer(session);
282
288
  if (session.reloadLifecycle !== reload.lifecycle) return undefined;
@@ -253,6 +253,10 @@ export async function reportSessionStart(session: GrantsSession, ctx: SessionRep
253
253
  // Warnings and errors are NOT folded in — they go to different components (`showError`), survive on their
254
254
  // own, and each says something an operator may need to act on separately.
255
255
  const info: string[] = [];
256
+ if (session.depth === 0 && session.governed && session.grantSource === "default" && !session.malformedBounds.length)
257
+ info.push("Pi Daddy started with session permissions. Use /grants to inspect access.");
258
+ if (session.depth === 0 && session.governed && session.grantSource === "stored")
259
+ info.push("Pi Daddy restored this project's saved permissions.");
256
260
 
257
261
  if (session.mayDelegate && !session.executor.refusal) {
258
262
  info.push(`grants: executor — ${session.executor.disclosure}`);
@@ -717,7 +717,8 @@ export function createGrantsSession(
717
717
  // `/grants` print "inactive" while holding thirteen capabilities — a status line contradicting the
718
718
  // enforcer, which is the defect R-28 is named for.
719
719
  session.governed = true;
720
- session.ownGrant = grant;
720
+ session.inherited = [...grant];
721
+ session.ownGrant = deriveOwnGrant(session.inherited, session.observedTools);
721
722
  session.grantSource = "operator-init";
722
723
  session.storeCwd = session.cwd;
723
724
  // An environment ledger remains the explicit answer. Otherwise init's v2 choice becomes live now,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-daddy",
3
- "version": "0.52.0",
3
+ "version": "0.53.1",
4
4
  "description": "Capability governance for pi sub-agents: spawn Agent Skills (SKILL.md) definitions whose allowed-tools becomes a grant that can only narrow going down a delegation tree, enforced by pi's own --tools allowlist, with an append-only ledger.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -53,7 +53,7 @@
53
53
  "typecheck": "tsc -p tsconfig.check.json",
54
54
  "test": "node scripts/unit-tests.ts",
55
55
  "test:integration": "node --test test-integration/*.it.ts",
56
- "test:integration:ci": "node --test test-integration/approval.it.ts test-integration/governance.it.ts test-integration/activity.it.ts test-integration/auto-chain.it.ts",
56
+ "test:integration:ci": "node --test test-integration/approval.it.ts test-integration/governance.it.ts test-integration/activity.it.ts test-integration/auto-chain.it.ts test-integration/pi-sdk/automatic-start.it.ts",
57
57
  "contracts:generate": "node scripts/generate-ledger-record-contract.ts",
58
58
  "prepack": "npm run build",
59
59
  "test:smoke": "node scripts/smoke-installed.mjs",
@@ -26,7 +26,7 @@ import {
26
26
  type TimelineFilter,
27
27
  } from "./activity-timeline.ts";
28
28
  import { createDashboardDisplayControls } from "./dashboard-display-controls.ts";
29
- import { dashboardJevNotice, JEV_CONSENT_NOTICE } from "./dashboard-settings.ts";
29
+ import { dashboardJevNotice, JEV_CONSENT_NOTICE, JEV_EDITOR_NOTICE } from "./dashboard-settings.ts";
30
30
  import {
31
31
  createDashboardConnection,
32
32
  dashboardSessionRequest,
@@ -200,10 +200,10 @@ async function compactFrame(options: DashboardFrameOptions): Promise<string> {
200
200
  if (projection.corrupt.length) problem = `Ledger unavailable: ${projection.corrupt.length} corrupt line(s)`;
201
201
  }
202
202
  } catch (error) {
203
- problem =
204
- (error as { code?: string }).code === "ENOENT"
205
- ? "Waiting for local work; open from /grants dashboard."
206
- : `Evidence unavailable: ${error instanceof Error ? error.message : String(error)}`;
203
+ if ((error as { code?: string }).code === "ENOENT") {
204
+ // A new owner session can have no local task records yet.
205
+ if (!options.session && !options.connected) problem = "Waiting for local work; open from /grants dashboard.";
206
+ } else problem = `Evidence unavailable: ${error instanceof Error ? error.message : String(error)}`;
207
207
  }
208
208
  // The owner supplies this exact current turn. No sibling timeline or unrelated history is merged.
209
209
  const activity = options.session?.activity;
@@ -374,6 +374,7 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
374
374
  await connection.refresh();
375
375
  const jev = connection.state.snapshot?.settings?.jev;
376
376
  if (notice === JEV_CONSENT_NOTICE && jev && !jev.pending) notice = dashboardJevNotice(jev);
377
+ if (notice === JEV_EDITOR_NOTICE && jev && !jev.pending) notice = "";
377
378
  if (stopped) return;
378
379
  const view = await dashboardFrame({
379
380
  cwd,
@@ -491,7 +492,21 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
491
492
  else if (selected === "perCall") notice = "Children per call is a fixed safety bound";
492
493
  else if (!settings.jev.available)
493
494
  notice = "JEV controls unavailable; load skill-harness in the parent Pi session";
494
- else {
495
+ else if (selected === "limit" || selected === "configure" || selected === "hints") {
496
+ if (!settings.jev.controls?.includes(selected)) notice = "Update skill-harness to edit this setting";
497
+ else if (settings.jev.pending) notice = "Finish the open settings dialog in the main Pi session";
498
+ else if (selected === "hints" && (!settings.jev.enabled || settings.jev.mode !== "workflow"))
499
+ notice = "Turn on JEV workflow calls first, then choose Tool hints";
500
+ else
501
+ void connection.change({ action: "edit-jev", option: selected }).then((changed) => {
502
+ notice = changed
503
+ ? connection.state.snapshot?.settings?.jev.pending
504
+ ? JEV_EDITOR_NOTICE
505
+ : "JEV settings refreshed."
506
+ : connection.state.error || "Settings unavailable";
507
+ redraw();
508
+ });
509
+ } else {
495
510
  void connection
496
511
  .change({ action: "set-jev", enabled: !(settings.jev.enabled || settings.jev.pending) })
497
512
  .then((changed) => {
@@ -93,9 +93,9 @@ export function createDashboardDisplayControls(details: boolean, ledger: boolean
93
93
  screen.manualScroll = false;
94
94
  const delta = key === "up" || key === "k" ? -1 : 1;
95
95
  if (screen.view === "settings") {
96
- const index = DASHBOARD_SETTING_KEYS.indexOf(screen.settingKey ?? "auto");
97
- screen.settingKey =
98
- DASHBOARD_SETTING_KEYS[Math.max(0, Math.min(DASHBOARD_SETTING_KEYS.length - 1, index + delta))];
96
+ const keys = screen.settingKeys ?? DASHBOARD_SETTING_KEYS;
97
+ const index = keys.indexOf(screen.settingKey ?? "auto");
98
+ screen.settingKey = keys[Math.max(0, Math.min(keys.length - 1, index + delta))];
99
99
  } else if (screen.view === "versions") {
100
100
  const rows = screen.versionRows ?? [],
101
101
  index = rows.findIndex((row) => row.id === screen.versionId);
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
3
3
  import { dirname, resolve } from "node:path";
4
+ import { userInfo } from "node:os";
4
5
  import {
5
6
  DASHBOARD_PLUGIN_ID,
6
7
  dashboardHerdrExec,
@@ -13,6 +14,7 @@ import {
13
14
  } from "./dashboard-herdr.ts";
14
15
  import { DASHBOARD_PROTOCOL_VERSION } from "./dashboard-cli.ts";
15
16
  import type { HerdrExec } from "../executors/herdr-cli.ts";
17
+ import { withFileLock } from "../governance/file-lock.ts";
16
18
  import { defaultActivityTimelinePath, parseActivityTimeline, renderActivityTimeline } from "./activity-timeline.ts";
17
19
 
18
20
  export type DashboardPromptChoice = "not-now" | "never";
@@ -73,6 +75,8 @@ export interface DashboardHandshakeInput {
73
75
  ledgerPath?: string;
74
76
  pluginRoot: string;
75
77
  preferencePath: string;
78
+ /** Supply an isolated OS account home when testing a shared Herdr registry. */
79
+ registryOwnerHome?: string;
76
80
  paneStatePath: string;
77
81
  sessionEndpoint?: { socketPath: string; token: string };
78
82
  ui: DashboardHandshakeUI;
@@ -91,61 +95,53 @@ export async function offerDashboardHandshake(input: DashboardHandshakeInput): P
91
95
  const preference = await loadPreference(input.preferencePath);
92
96
  if (preference) return "suppressed";
93
97
  const plugin = await inspectDashboardPlugin(exec, input.pluginRoot);
94
- // A compatible bundled panel is local software already chosen by the operator. Present it by default;
95
- // pane identity makes this one panel per caller tab/session and --no-focus avoids focus theft.
96
- if (plugin.state === "compatible") {
97
- const opened = await openOrReuseDashboard({
98
- exec,
99
- host: host.host,
100
- ledgerPath: input.ledgerPath ?? "",
101
- cwd: input.cwd,
102
- statePath: input.paneStatePath,
103
- pluginRoot: input.pluginRoot,
104
- allowInactive: true,
105
- sessionEndpoint: input.sessionEndpoint,
106
- });
107
- input.ui.notify(`pi-daddy dashboard ${opened.kind} in pane ${opened.paneId} without changing focus.`, "info");
108
- return "already-installed";
109
- }
110
- const replacingDifferentPackage = plugin.state === "incompatible" && plugin.incompatibility === "package-root";
111
- if (plugin.state !== "absent" && !replacingDifferentPackage) {
98
+ if (plugin.plugin?.enabled === false) return "suppressed";
99
+ const replacing =
100
+ plugin.state === "incompatible" && plugin.incompatibility === "package-root" && plugin.plugin?.enabled === true;
101
+ if (plugin.state !== "compatible" && plugin.state !== "absent" && !replacing) {
112
102
  input.ui.notify(`pi-daddy dashboard: ${plugin.diagnostic}`, "error");
113
103
  return "failed";
114
104
  }
115
-
116
- const affirmative = replacingDifferentPackage ? "Relink and open" : "Install and open";
117
- const choices = replacingDifferentPackage ? [affirmative, "Not now"] : [affirmative, "Not now", "Never ask"];
118
- const choice = await input.ui.select(
119
- replacingDifferentPackage
120
- ? "The pi-daddy dashboard is linked from a different package. Relink this bundled copy and open it?"
121
- : "Herdr detected. Install and open the pi-daddy dashboard?",
122
- choices,
123
- );
124
- if (!choices.includes(choice ?? "")) {
125
- // Escape, timeout and UI teardown return undefined. None is an operator choice, so none may become a
126
- // durable preference merely because the dialog disappeared.
127
- input.ui.notify("pi-daddy dashboard: installation prompt dismissed; no preference was stored.", "info");
128
- return "deferred";
129
- }
130
- if (choice !== affirmative) {
131
- if (replacingDifferentPackage) {
132
- input.ui.notify("pi-daddy dashboard: existing link unchanged; no preference was stored.", "info");
105
+ if (replacing) {
106
+ const choice = await input.ui.select(
107
+ "The dashboard is linked to another Pi Daddy installation. Use this installation's dashboard instead?",
108
+ ["Relink and open", "Not now", "Keep existing link"],
109
+ );
110
+ if (choice !== "Relink and open") {
111
+ if (choice === "Keep existing link") await savePreference(input.preferencePath, "never");
112
+ input.ui.notify("pi-daddy dashboard: kept the existing dashboard link.", "info");
133
113
  return "deferred";
134
114
  }
135
- const recorded = choice === "Never ask" ? "never" : "not-now";
136
- await savePreference(input.preferencePath, recorded);
137
- input.ui.notify(
138
- recorded === "never"
139
- ? "pi-daddy dashboard: startup installation prompt disabled. /grants dashboard remains available."
140
- : "pi-daddy dashboard: not installed. /grants dashboard will report the manual setup when requested.",
141
- "info",
115
+ }
116
+ let outcome: DashboardHandshakeOutcome = "already-installed";
117
+ if (plugin.state !== "compatible") {
118
+ // Herdr plugin links are shared across Pi profiles. Lock once per OS account,
119
+ // independently of Pi settings, environment HOME, and the bundled plugin path.
120
+ const registryLock = resolve(
121
+ input.registryOwnerHome ?? userInfo().homedir,
122
+ ".cache",
123
+ "pi-daddy",
124
+ "herdr-plugin-registry",
142
125
  );
143
- return "deferred";
126
+ await mkdir(dirname(registryLock), { recursive: true, mode: 0o700 });
127
+ outcome = await withFileLock(registryLock, "dashboard setup", async () => {
128
+ if (await loadPreference(input.preferencePath)) return "suppressed" as const;
129
+ const current = await inspectDashboardPlugin(exec, input.pluginRoot);
130
+ if (current.state === "compatible") return "already-installed" as const;
131
+ if (
132
+ current.state !== plugin.state ||
133
+ current.incompatibility !== plugin.incompatibility ||
134
+ current.plugin?.plugin_root !== plugin.plugin?.plugin_root ||
135
+ current.plugin?.enabled !== plugin.plugin?.enabled
136
+ )
137
+ throw Error("The dashboard installation changed during startup. Reopen the dashboard to inspect it.");
138
+ await linkDashboardPlugin(input.pluginRoot, exec);
139
+ const linked = await inspectDashboardPlugin(exec, input.pluginRoot);
140
+ if (linked.state !== "compatible") throw new Error(linked.diagnostic);
141
+ return "installed" as const;
142
+ });
143
+ if (outcome === "suppressed") return outcome;
144
144
  }
145
-
146
- await linkDashboardPlugin(input.pluginRoot, exec);
147
- const linked = await inspectDashboardPlugin(exec, input.pluginRoot);
148
- if (linked.state !== "compatible") throw new Error(linked.diagnostic);
149
145
  const opened = await openOrReuseDashboard({
150
146
  exec,
151
147
  host: host.host,
@@ -157,7 +153,7 @@ export async function offerDashboardHandshake(input: DashboardHandshakeInput): P
157
153
  sessionEndpoint: input.sessionEndpoint,
158
154
  });
159
155
  input.ui.notify(`pi-daddy dashboard ${opened.kind} in pane ${opened.paneId} without changing focus.`, "info");
160
- return "installed";
156
+ return outcome;
161
157
  } catch (error) {
162
158
  input.ui.notify(
163
159
  `pi-daddy dashboard setup failed: ${error instanceof Error ? error.message : String(error)}`,
@@ -127,7 +127,15 @@ export async function inspectDashboardPlugin(
127
127
  try {
128
128
  const parsed = parseReply(await exec(["plugin", "list", "--json"]));
129
129
  if (parsed.error) return { state: "unavailable", diagnostic: `Herdr plugin registry unavailable: ${parsed.error}` };
130
- const plugins = Array.isArray(parsed.result?.plugins) ? (parsed.result.plugins as Record<string, unknown>[]) : [];
130
+ if (
131
+ !Array.isArray(parsed.result?.plugins) ||
132
+ !parsed.result.plugins.every((row) => typeof row?.plugin_id === "string")
133
+ )
134
+ return {
135
+ state: "unavailable",
136
+ diagnostic: "Herdr returned an unreadable plugin list. Check the Herdr connection.",
137
+ };
138
+ const plugins = parsed.result.plugins as Record<string, unknown>[];
131
139
  const plugin = plugins.find((candidate) => candidate.plugin_id === DASHBOARD_PLUGIN_ID);
132
140
  if (!plugin) return { state: "absent", diagnostic: `Herdr plugin ${DASHBOARD_PLUGIN_ID} is not installed.` };
133
141
  // Protocol and provenance both precede enabled state. A root-only repair is offered only when the
@@ -400,7 +400,9 @@ export function sessionPanelLines(options: DashboardScreenOptions, items: Dashbo
400
400
  ? "No saved results reported to this dashboard."
401
401
  : destination === "activity"
402
402
  ? "No activity has been recorded in this session yet."
403
- : "No tasks reported for this session yet.";
403
+ : destination === "now" && options.connected && !observation.turn
404
+ ? "Give Pi a task in the main chat. Its progress will appear here."
405
+ : "No tasks reported for this session yet.";
404
406
  lines.push(fallback);
405
407
  }
406
408
  const left = previewWidth(destination, Boolean(screen.expanded), width);
@@ -10,7 +10,7 @@ import { activityTaskTitle } from "./dashboard-activity.ts";
10
10
  import { versionLines } from "./dashboard-components.ts";
11
11
  import { sessionRecapLines } from "./dashboard-recap.ts";
12
12
  import { colorSessionLine, previewWidth, sectionHeading } from "./dashboard-layout.ts";
13
- import { dashboardSettingsLines, type DashboardSettingKey } from "./dashboard-settings.ts";
13
+ import { visibleSettingKeys, dashboardSettingsLines, type DashboardSettingKey } from "./dashboard-settings.ts";
14
14
  /** Height-bounded, task-first view. Permission state is always supplied by the owner. */
15
15
  import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
16
16
  import type { DashboardProjection } from "./dashboard-projection.ts";
@@ -43,6 +43,7 @@ export interface DashboardScreenState {
43
43
  manualScroll?: boolean;
44
44
  selections?: Record<string, string>;
45
45
  settingKey?: DashboardSettingKey;
46
+ settingKeys?: DashboardSettingKey[];
46
47
  versionId?: EcosystemVersionRow["id"];
47
48
  versionRows?: EcosystemVersionRow[];
48
49
  selectedKey?: string;
@@ -351,14 +352,24 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
351
352
  const ack = options.acknowledgment;
352
353
  if (ack?.state === "unconfirmed") {
353
354
  const setting =
354
- ({ "set-auto": "Auto", "set-jev": "JEV", set: "model", "set-limit": "limit" } as Record<string, string>)[
355
- ack.action
356
- ] ?? "setting";
355
+ (
356
+ {
357
+ "set-auto": "Auto",
358
+ "set-jev": "JEV",
359
+ "edit-jev": "JEV settings",
360
+ set: "model",
361
+ "set-limit": "limit",
362
+ } as Record<string, string>
363
+ )[ack.action] ?? "setting";
357
364
  fixed.push(
358
365
  ...wrapDashboardLines([`Unconfirmed ${setting} change. Check the main Pi chat before trying again.`], width),
359
366
  );
360
367
  } else if (ack && (!disconnected || !modern) && (!modern || screen.view === "settings" || ack.state === "refused")) {
361
- fixed.push(clean(`${ack.action}: ${ack.state} · ${ack.effect}`));
368
+ fixed.push(
369
+ ack.action === "edit-jev" && ack.state === "opened"
370
+ ? "JEV settings · current values below"
371
+ : clean(`${ack.action}: ${ack.state} · ${ack.effect}`),
372
+ );
362
373
  }
363
374
  if (modern && options.filter && options.filter !== "everything" && screen.view === "main")
364
375
  fixed.push(`Filter: ${options.filter} · Tab to change`);
@@ -415,6 +426,8 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
415
426
  "Finished means observed completion, not acceptance.",
416
427
  );
417
428
  else if (screen.view === "settings") {
429
+ screen.settingKeys = visibleSettingKeys(session?.settings?.jev);
430
+ if (screen.settingKey && !screen.settingKeys.includes(screen.settingKey)) screen.settingKey = "jev";
418
431
  body.push(
419
432
  ...(disconnected
420
433
  ? [
@@ -1,5 +1,5 @@
1
1
  import type { DashboardOwnerObservation } from "../kernel/dashboard-observation.ts";
2
- import type { DashboardSettingsSnapshot } from "./dashboard-settings.ts";
2
+ import type { DashboardSettingsSnapshot, JevEditAction } from "./dashboard-settings.ts";
3
3
  import type { EcosystemVersions } from "./ecosystem-versions.ts";
4
4
  import { createConnection } from "node:net";
5
5
 
@@ -19,6 +19,7 @@ export type DashboardSessionAction = (
19
19
  | { action: "set"; edits: string }
20
20
  | { action: "set-auto"; enabled: boolean }
21
21
  | { action: "set-jev"; enabled: boolean }
22
+ | { action: "edit-jev"; option: JevEditAction }
22
23
  | { action: "set-limit"; key: "wall" | "idle"; seconds: number }
23
24
  ) & { expectedOwner?: { sessionId: string; cwd: string; generation: string } };
24
25
 
@@ -60,7 +61,7 @@ export async function dashboardSessionRequest(
60
61
 
61
62
  export type DashboardAcknowledgment = {
62
63
  action: string;
63
- state: "pending" | "applied" | "refused" | "unconfirmed";
64
+ state: "opened" | "pending" | "applied" | "refused" | "unconfirmed";
64
65
  effect: string;
65
66
  };
66
67
 
@@ -129,9 +130,11 @@ export function createDashboardConnection(
129
130
  const effect =
130
131
  action.action === "set-auto"
131
132
  ? "current permission handling; admitted work unchanged"
132
- : action.action === "set-jev"
133
- ? "current JEV session; separate paid-call and storage choices"
134
- : "future children; running children unchanged";
133
+ : action.action === "edit-jev"
134
+ ? "use the main Pi session; current values shown below"
135
+ : action.action === "set-jev"
136
+ ? "current JEV session; separate paid-call and storage choices"
137
+ : "future children; running children unchanged";
135
138
  state.acknowledgment = { action: action.action, state: "pending", effect };
136
139
  try {
137
140
  const snapshot = await request({
@@ -148,13 +151,15 @@ export function createDashboardConnection(
148
151
  });
149
152
  if (!accept(snapshot)) throw Error("owner acknowledgment is stale; reconcile before another action");
150
153
  state.acknowledgment.state =
151
- action.action === "set-jev"
152
- ? snapshot.settings?.jev.pending
153
- ? "pending"
154
- : snapshot.settings?.jev.enabled === action.enabled
155
- ? "applied"
156
- : "refused"
157
- : "applied";
154
+ action.action === "edit-jev"
155
+ ? "opened"
156
+ : action.action === "set-jev"
157
+ ? snapshot.settings?.jev.pending
158
+ ? "pending"
159
+ : snapshot.settings?.jev.enabled === action.enabled
160
+ ? "applied"
161
+ : "refused"
162
+ : "applied";
158
163
  return true;
159
164
  } catch (error) {
160
165
  state.snapshot = undefined;
@@ -1,5 +1,10 @@
1
1
  /** Settings are owner observations; rendering never grants consent or changes execution. */
2
- export type DashboardSettingKey = "auto" | "jev" | "wall" | "idle" | "descendants" | "depth" | "perCall";
2
+ export const JEV_EDIT_ACTIONS = ["limit", "configure", "hints"] as const;
3
+ export type JevEditAction = (typeof JEV_EDIT_ACTIONS)[number];
4
+ export const isJevEditAction = (value: unknown): value is JevEditAction =>
5
+ JEV_EDIT_ACTIONS.some((key) => value === key);
6
+ export type DashboardSettingKey =
7
+ JevEditAction | "auto" | "jev" | "wall" | "idle" | "descendants" | "depth" | "perCall";
3
8
  export const DASHBOARD_SETTING_KEYS: DashboardSettingKey[] = [
4
9
  "auto",
5
10
  "jev",
@@ -16,6 +21,10 @@ export interface DashboardJevState {
16
21
  mode?: string;
17
22
  storage?: string | null;
18
23
  remaining?: number;
24
+ limit?: number;
25
+ used?: number;
26
+ hintsEnabled?: boolean;
27
+ controls?: JevEditAction[];
19
28
  availability?: string;
20
29
  providerReadiness?: string;
21
30
  selectedProvider?: string;
@@ -24,6 +33,10 @@ export interface DashboardJevState {
24
33
  storageRoot?: string;
25
34
  error?: string;
26
35
  }
36
+ export function visibleSettingKeys(jev?: DashboardJevState): DashboardSettingKey[] {
37
+ const extra = JEV_EDIT_ACTIONS.filter((key) => jev?.available && jev.controls?.includes(key));
38
+ return ["auto", "jev", ...extra, ...DASHBOARD_SETTING_KEYS.slice(2)];
39
+ }
27
40
  export interface DashboardSettingsSnapshot {
28
41
  editable: boolean;
29
42
  wallSeconds: number;
@@ -36,6 +49,7 @@ export interface DashboardSettingsSnapshot {
36
49
  perCall: number;
37
50
  jev: DashboardJevState;
38
51
  }
52
+ export const JEV_EDITOR_NOTICE = "Finish editing in the main Pi session.";
39
53
  export const JEV_CONSENT_NOTICE = "Complete JEV paid-call and LoRA-storage choices in the parent Pi session";
40
54
  export function dashboardJevNotice(jev: DashboardJevState): string {
41
55
  if (jev.pending) return JEV_CONSENT_NOTICE;
@@ -57,9 +71,29 @@ export function dashboardSettingsLines(
57
71
  "jev",
58
72
  `JEV: ${jev.pending ? "waiting for consent" : !jev.available ? "unavailable" : jev.enabled ? "ON" : "OFF"}`,
59
73
  ),
74
+ ...(jev.available && jev.controls?.includes("limit")
75
+ ? [
76
+ row("limit", `Call limit: ${jev.limit ?? "unknown"} per session`),
77
+ ` ${jev.used ?? "?"} used · ${jev.remaining ?? "?"} available now`,
78
+ ]
79
+ : []),
80
+ ...(jev.available && jev.controls?.includes("configure")
81
+ ? [row("configure", "Choose JEV model and storage…")]
82
+ : []),
83
+ ...(jev.available && jev.controls?.includes("hints")
84
+ ? [
85
+ row(
86
+ "hints",
87
+ `Tool hints: ${jev.hintsEnabled === true ? "ON" : jev.hintsEnabled === false ? "OFF" : "unknown"}`,
88
+ ),
89
+ " Suggestions only · above 90% confidence",
90
+ ]
91
+ : []),
60
92
  ...(jev.available
61
93
  ? [
62
- ` ${jev.availability ?? "unknown"} · ${jev.remaining ?? 0} paid calls left`,
94
+ ...(jev.controls?.includes("limit")
95
+ ? [` Provider status: ${jev.availability ?? "unknown"}`]
96
+ : [` ${jev.availability ?? "unknown"} · ${jev.remaining ?? 0} paid calls left`]),
63
97
  ` Key: ${jev.providerReadiness ?? "unknown"}; storage: ${jev.storage ?? "not granted"}`,
64
98
  ...(jev.selectedProvider || jev.selectedModel
65
99
  ? [` Model: ${jev.selectedProvider ?? "unknown"}/${jev.selectedModel ?? "not reported"}`]