pi-daddy 0.61.0 → 0.62.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.
- package/CHANGELOG.md +9 -0
- package/README.md +62 -3
- 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/delegate-types.d.ts +3 -0
- package/dist/kernel/delegate-types.d.ts.map +1 -1
- package/dist/kernel/delegate-types.js.map +1 -1
- package/dist/kernel/delegate.d.ts.map +1 -1
- package/dist/kernel/delegate.js +30 -8
- package/dist/kernel/delegate.js.map +1 -1
- package/dist/kernel/env-names.d.ts +2 -0
- package/dist/kernel/env-names.d.ts.map +1 -1
- package/dist/kernel/env-names.js +3 -0
- package/dist/kernel/env-names.js.map +1 -1
- package/dist/kernel/propagation.d.ts +1 -1
- package/dist/kernel/propagation.d.ts.map +1 -1
- package/dist/kernel/propagation.js +2 -0
- package/dist/kernel/propagation.js.map +1 -1
- package/dist/kernel/spawn.d.ts +3 -0
- package/dist/kernel/spawn.d.ts.map +1 -1
- package/dist/kernel/spawn.js +4 -0
- package/dist/kernel/spawn.js.map +1 -1
- package/dist/kernel/work-mode.d.ts +24 -0
- package/dist/kernel/work-mode.d.ts.map +1 -0
- package/dist/kernel/work-mode.js +73 -0
- package/dist/kernel/work-mode.js.map +1 -0
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +36 -0
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-display-controls.d.ts +1 -1
- package/dist/products/dashboard-display-controls.d.ts.map +1 -1
- package/dist/products/dashboard-display-controls.js +25 -0
- package/dist/products/dashboard-display-controls.js.map +1 -1
- package/dist/products/dashboard-screen.d.ts +3 -1
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +23 -13
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +6 -0
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +21 -4
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/dashboard-settings.d.ts +4 -2
- package/dist/products/dashboard-settings.d.ts.map +1 -1
- package/dist/products/dashboard-settings.js +27 -2
- package/dist/products/dashboard-settings.js.map +1 -1
- package/dist/products/dashboard-work-mode.d.ts +27 -0
- package/dist/products/dashboard-work-mode.d.ts.map +1 -0
- package/dist/products/dashboard-work-mode.js +117 -0
- package/dist/products/dashboard-work-mode.js.map +1 -0
- package/extensions/dashboard-session-server.ts +13 -0
- package/extensions/dashboard-settings.ts +2 -0
- package/extensions/definition-describe.ts +3 -1
- package/extensions/delegation-operations.ts +25 -1
- package/extensions/grants.ts +3 -0
- package/extensions/reload-environment.ts +2 -0
- package/extensions/run-delegation.ts +11 -2
- package/extensions/work-mode-command.ts +82 -0
- package/extensions/work-mode.ts +226 -0
- package/package.json +2 -2
- package/src/kernel/context-handoff.ts +19 -0
- package/src/kernel/delegate-types.ts +3 -0
- package/src/kernel/delegate.ts +38 -14
- package/src/kernel/env-names.ts +3 -0
- package/src/kernel/propagation.ts +2 -0
- package/src/kernel/spawn.ts +5 -0
- package/src/kernel/work-mode.ts +85 -0
- package/src/products/dashboard-cli.ts +33 -1
- package/src/products/dashboard-display-controls.ts +22 -1
- package/src/products/dashboard-screen.ts +45 -14
- package/src/products/dashboard-session-client.ts +26 -4
- package/src/products/dashboard-settings.ts +33 -3
- package/src/products/dashboard-work-mode.ts +151 -0
package/src/kernel/delegate.ts
CHANGED
|
@@ -34,7 +34,13 @@ import {
|
|
|
34
34
|
import { DELEGATE_SUBJECT, inheritApprovals, type InheritableApproval } from "./approval.ts";
|
|
35
35
|
import { explainDoubledNamespace, suggestForUnknown, unknownCapabilities, type Catalog } from "./catalog.ts";
|
|
36
36
|
import { GovernanceRefusal, refusal, type RefusalCode, type StructuredRefusal } from "./refusals.ts";
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
contextCapability,
|
|
39
|
+
definitionContextContract,
|
|
40
|
+
isContextCapability,
|
|
41
|
+
parseContextRequest,
|
|
42
|
+
type ContextRequest,
|
|
43
|
+
} from "./context-handoff.ts";
|
|
38
44
|
import { digestTask, normaliseCorrelation, type ApprovalBinding, type CorrelationMetadata } from "./correlation.ts";
|
|
39
45
|
import { resolveDelegationApproval } from "./delegation-approval.ts";
|
|
40
46
|
import type { Delegation, DelegationContext, DelegationRequest } from "./delegate-types.ts";
|
|
@@ -42,6 +48,7 @@ import { assertCapabilitiesArePropagatable } from "./capabilities.ts";
|
|
|
42
48
|
export type { Delegation, DelegationContext, DelegationRequest } from "./delegate-types.ts";
|
|
43
49
|
import { ENV_CHILD_DEFINITION, ENV_CHILD_EPISODE, ENV_CHILD_EXECUTION, GOVERNANCE_ENV_KEYS } from "./env-names.ts";
|
|
44
50
|
import { ENV_PROXIED_TOOLS } from "./env-names.ts";
|
|
51
|
+
import { ENV_WORK_MODE, parseWorkMode } from "./work-mode.ts";
|
|
45
52
|
|
|
46
53
|
export function planDelegation(request: DelegationRequest, ctx: DelegationContext): Delegation {
|
|
47
54
|
const childDepth = ctx.depth + 1;
|
|
@@ -242,19 +249,32 @@ export function planDelegation(request: DelegationRequest, ctx: DelegationContex
|
|
|
242
249
|
const wanted = contextCapability(handoff.mode);
|
|
243
250
|
// Subsumed, so declaring the strongest mode permits asking for a weaker one — the same relation the grant has.
|
|
244
251
|
const permitted = new Set(expandSubsumed([...declaredContext]));
|
|
245
|
-
if (request.agent !== undefined && !permitted.has(wanted))
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
"
|
|
257
|
-
|
|
252
|
+
if (request.agent !== undefined && !permitted.has(wanted)) {
|
|
253
|
+
const contract = definitionContextContract(declaredContext);
|
|
254
|
+
const reason =
|
|
255
|
+
`context: ${request.agent} may not receive ${wanted} — its allowed-tools ` +
|
|
256
|
+
(declaredContext.length === 0
|
|
257
|
+
? "declares no context: capability, so it receives none"
|
|
258
|
+
: `permits ${declaredContext.join(", ")}`) +
|
|
259
|
+
'. Correct the context argument: omit it or use {"mode":"none"} when the child can inspect the workspace. ' +
|
|
260
|
+
(contract.definitionModes.includes("files")
|
|
261
|
+
? 'If file contents are needed, use {"mode":"files","files":[...]} with actual repository-relative paths. '
|
|
262
|
+
: "") +
|
|
263
|
+
"Keep the task scope, acceptance criteria and exact evidence references; do not omit required evidence. " +
|
|
264
|
+
"Do not relabel the rejected summary as task or file content, or widen the definition. " +
|
|
265
|
+
"This request stopped before child launch; it does not establish the outcome of earlier calls with the same operation_id.";
|
|
266
|
+
return {
|
|
267
|
+
...empty,
|
|
268
|
+
requested,
|
|
269
|
+
reason,
|
|
270
|
+
refusal: refusal("CONTEXT_REQUEST_INVALID", reason, {
|
|
271
|
+
requestedContextMode: handoff.mode,
|
|
272
|
+
definitionContextModes: contract.definitionModes.join(","),
|
|
273
|
+
suggestedContextMode: "none",
|
|
274
|
+
correction: "correct-context-argument",
|
|
275
|
+
}),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
258
278
|
requested = [...requested, wanted];
|
|
259
279
|
}
|
|
260
280
|
|
|
@@ -371,6 +391,8 @@ export function planDelegation(request: DelegationRequest, ctx: DelegationContex
|
|
|
371
391
|
: undefined;
|
|
372
392
|
if (staged?.refusal)
|
|
373
393
|
return denied({ ...empty, requested, result, reason: staged.refusal }, "CONTEXT_REQUEST_INVALID");
|
|
394
|
+
const selectedMode = parseWorkMode(ctx.workMode);
|
|
395
|
+
const workMode = selectedMode?.mode === "ambitious" ? selectedMode : undefined;
|
|
374
396
|
const plan = planSpawn({
|
|
375
397
|
effective: result.effective,
|
|
376
398
|
prompt: request.task,
|
|
@@ -380,6 +402,7 @@ export function planDelegation(request: DelegationRequest, ctx: DelegationContex
|
|
|
380
402
|
skillPaths: ctx.skillPaths,
|
|
381
403
|
contextFiles: ctx.contextFiles,
|
|
382
404
|
systemPrompt,
|
|
405
|
+
...(workMode ? { workMode } : {}),
|
|
383
406
|
selectedResourcePrompt: selectedResourcePrompt(spawned?.selectedResources),
|
|
384
407
|
// A fork replaces the session file rather than joining it: pi refuses `--fork` beside `--session`.
|
|
385
408
|
...(staged?.forkFrom ? { forkFrom: staged.forkFrom } : { sessionFile: ctx.sessionFile }),
|
|
@@ -429,6 +452,7 @@ export function planDelegation(request: DelegationRequest, ctx: DelegationContex
|
|
|
429
452
|
[ENV_DEPTH]: String(childDepth),
|
|
430
453
|
[ENV_MAX_DEPTH]: String(ctx.maxDepth),
|
|
431
454
|
};
|
|
455
|
+
if (workMode) env[ENV_WORK_MODE] = JSON.stringify(workMode);
|
|
432
456
|
// The child's own share of the subtree budget, and its identity. Both attenuate downward like depth: a
|
|
433
457
|
// child can never be handed more budget than its parent had left, so the total bound holds across
|
|
434
458
|
// process boundaries with no shared state.
|
package/src/kernel/env-names.ts
CHANGED
|
@@ -22,6 +22,8 @@ export const ENV_LEDGER = "PI_DADDY_LEDGER";
|
|
|
22
22
|
export const ENV_APPROVED = "PI_DADDY_APPROVED";
|
|
23
23
|
export const ENV_AUTO_MODE = "PI_DADDY_AUTO_MODE";
|
|
24
24
|
export const ENV_AUTO_MODE_REF = "PI_DADDY_AUTO_MODE_REF";
|
|
25
|
+
/** Bounded working-style metadata, supplied explicitly for each governed child. */
|
|
26
|
+
export const ENV_WORK_MODE = "PI_DADDY_WORK_MODE_V1";
|
|
25
27
|
export const ENV_FANOUT = "PI_DADDY_FANOUT";
|
|
26
28
|
export const ENV_PARENT_ID = "PI_DADDY_PARENT_ID";
|
|
27
29
|
export const ENV_EXECUTION_ID = "PI_DADDY_EXECUTION_ID";
|
|
@@ -110,6 +112,7 @@ export const GOVERNANCE_ENV_KEYS: readonly string[] = Object.freeze([
|
|
|
110
112
|
ENV_APPROVED,
|
|
111
113
|
ENV_AUTO_MODE,
|
|
112
114
|
ENV_AUTO_MODE_REF,
|
|
115
|
+
ENV_WORK_MODE,
|
|
113
116
|
ENV_FANOUT,
|
|
114
117
|
ENV_PARENT_ID,
|
|
115
118
|
ENV_EXECUTION_ID,
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
import { ENV_AUTO_MODE, ENV_AUTO_MODE_REF, ENV_PUBLIC_EVIDENCE_DIR } from "./env-names.ts";
|
|
29
29
|
import { ENV_PROXIED_TOOLS, ENV_PROXIED_TOOLS_KEY } from "./env-names.ts";
|
|
30
|
+
import { ENV_WORK_MODE } from "./env-names.ts";
|
|
30
31
|
import type { AutoModeRef } from "./auto-mode.ts";
|
|
31
32
|
import type { Capability } from "./resolve.ts";
|
|
32
33
|
import { attenuateWorkspacePin, formatWorkspacePin, type WorkspacePins } from "./workspace-pin.ts";
|
|
@@ -92,6 +93,7 @@ export {
|
|
|
92
93
|
* to give it.
|
|
93
94
|
*/
|
|
94
95
|
export const GRANT_ENV_KEYS = [
|
|
96
|
+
ENV_WORK_MODE,
|
|
95
97
|
ENV_AUTO_MODE,
|
|
96
98
|
ENV_AUTO_MODE_REF,
|
|
97
99
|
ENV_PUBLIC_EVIDENCE_DIR,
|
package/src/kernel/spawn.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { toPiToolsAllowlist, type Capability } from "./resolve.ts";
|
|
11
|
+
import { parseWorkMode, workModeGuidance, type WorkModeSelection } from "./work-mode.ts";
|
|
11
12
|
|
|
12
13
|
export interface SpawnPlanInput {
|
|
13
14
|
effective: Capability[];
|
|
@@ -34,6 +35,8 @@ export interface SpawnPlanInput {
|
|
|
34
35
|
* `--append-system-prompt`, which pi accepts more than once.
|
|
35
36
|
*/
|
|
36
37
|
contextPrompt?: string;
|
|
38
|
+
/** Trusted request snapshot; separate from the task and the immutable skill definition. */
|
|
39
|
+
workMode?: WorkModeSelection;
|
|
37
40
|
/** Non-interactive by default: a governed child should not prompt a human. */
|
|
38
41
|
print?: boolean;
|
|
39
42
|
/**
|
|
@@ -146,6 +149,8 @@ export function planSpawn(input: SpawnPlanInput): SpawnPlan {
|
|
|
146
149
|
// remit: the G1 hazard is a model-controlled string reaching a parser, and this is not one.
|
|
147
150
|
if (input.systemPrompt) args.push("--append-system-prompt", input.systemPrompt);
|
|
148
151
|
if (input.selectedResourcePrompt) args.push("--append-system-prompt", input.selectedResourcePrompt);
|
|
152
|
+
const workModePrompt = workModeGuidance(parseWorkMode(input.workMode), "child");
|
|
153
|
+
if (workModePrompt) args.push("--append-system-prompt", workModePrompt);
|
|
149
154
|
// After the definition body, so a child reads what it IS before what it was told (ADR-0078). Operator- and
|
|
150
155
|
// parent-authored text, never a model-chosen argv position, so `neutralisePrompt` has no remit here either.
|
|
151
156
|
if (input.contextPrompt) args.push("--append-system-prompt", input.contextPrompt);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** Optional working-style guidance. This data never participates in execution authority or task identity. */
|
|
2
|
+
export { ENV_WORK_MODE } from "./env-names.ts";
|
|
3
|
+
export const WORK_MODE_EMPHASES = ["speed", "altitude", "depth", "range"] as const;
|
|
4
|
+
export type WorkModeEmphasis = (typeof WORK_MODE_EMPHASES)[number];
|
|
5
|
+
export interface WorkModeSelection {
|
|
6
|
+
mode: "standard" | "ambitious";
|
|
7
|
+
emphases: WorkModeEmphasis[];
|
|
8
|
+
}
|
|
9
|
+
export interface WorkModeSnapshot {
|
|
10
|
+
available: boolean;
|
|
11
|
+
selection: WorkModeSelection;
|
|
12
|
+
nextRequest?: WorkModeSelection;
|
|
13
|
+
active?: WorkModeSelection;
|
|
14
|
+
inherited: boolean;
|
|
15
|
+
note?: string;
|
|
16
|
+
}
|
|
17
|
+
export const WORK_MODE_LABELS: Record<WorkModeEmphasis, string> = {
|
|
18
|
+
speed: "Faster delivery",
|
|
19
|
+
altitude: "Better outcome",
|
|
20
|
+
depth: "Deeper proof",
|
|
21
|
+
range: "Broader approaches",
|
|
22
|
+
};
|
|
23
|
+
export const standardWorkMode = (): WorkModeSelection => ({ mode: "standard", emphases: [] });
|
|
24
|
+
|
|
25
|
+
/** Accept only bounded enumerated data. No arbitrary prompt can enter through stored state or transport. */
|
|
26
|
+
export function parseWorkMode(value: unknown): WorkModeSelection | undefined {
|
|
27
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
28
|
+
const input = value as Record<string, unknown>;
|
|
29
|
+
if (Object.keys(input).some((key) => key !== "mode" && key !== "emphases")) return;
|
|
30
|
+
if (input.mode !== "standard" && input.mode !== "ambitious") return;
|
|
31
|
+
const choices = input.emphases;
|
|
32
|
+
if (!Array.isArray(choices) || choices.length > WORK_MODE_EMPHASES.length) return;
|
|
33
|
+
if (choices.some((item) => !WORK_MODE_EMPHASES.includes(item as WorkModeEmphasis))) return;
|
|
34
|
+
if (new Set(choices).size !== choices.length) return;
|
|
35
|
+
if (input.mode === "standard" && choices.length > 0) return;
|
|
36
|
+
return {
|
|
37
|
+
mode: input.mode,
|
|
38
|
+
emphases: WORK_MODE_EMPHASES.filter((item) => choices.includes(item)),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function workModeLabel(value: WorkModeSelection): string {
|
|
43
|
+
return value.mode === "standard"
|
|
44
|
+
? "Standard (current behavior)"
|
|
45
|
+
: `Ambitious · ${value.emphases.length ? value.emphases.map((key) => WORK_MODE_LABELS[key]).join(" + ") : "balanced"}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const emphases: Record<WorkModeEmphasis, string> = {
|
|
49
|
+
speed:
|
|
50
|
+
"Faster delivery: simplify the approach, reuse valid evidence and completed work, and parallelize useful independent work when worthwhile.",
|
|
51
|
+
altitude:
|
|
52
|
+
"Better outcome: examine the purpose behind the requested artifact and consider a better route to the agreed outcome.",
|
|
53
|
+
depth:
|
|
54
|
+
"Deeper proof: challenge important assumptions using raw evidence, suitable professional instruments and a small decisive experiment.",
|
|
55
|
+
range:
|
|
56
|
+
"Broader approaches: borrow a useful technique from another discipline when it changes the method or result; choose concrete methods, not expert personas.",
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Standard is a strict prompt no-op. Child guidance supplements, and never replaces, its assigned role. */
|
|
60
|
+
export function workModeGuidance(value: WorkModeSelection | undefined, role: "parent" | "child"): string | undefined {
|
|
61
|
+
if (!value || value.mode === "standard") return;
|
|
62
|
+
const selected = value.emphases.length ? value.emphases : WORK_MODE_EMPHASES;
|
|
63
|
+
return [
|
|
64
|
+
"<pi-daddy-work-mode>",
|
|
65
|
+
`Working style: ${workModeLabel(value)}. This is optional approach guidance for this request.`,
|
|
66
|
+
role === "child"
|
|
67
|
+
? "Stay within the assigned task and role: review remains review and read-only investigation remains read-only. Return evidence and useful findings to the parent."
|
|
68
|
+
: "Own the agreed outcome and choose a proportionate approach using relevant installed skills and available tools.",
|
|
69
|
+
...selected.map((key) => emphases[key]),
|
|
70
|
+
"Select the useful directions; they are not required stages. Before expensive work, identify the important assumption, " +
|
|
71
|
+
"available raw evidence and a check that could disprove it.",
|
|
72
|
+
"Use observed results to revise the method. Seek independent checks such as tests, measurements, source data or actual user-path observations. " +
|
|
73
|
+
"Another model's opinion alone is not proof.",
|
|
74
|
+
"Treat stretch targets as bounded experiments with a baseline and honest results. Ask about material changes to the agreed goal, scope or cost; " +
|
|
75
|
+
"continue routine authorized work without extra ceremony.",
|
|
76
|
+
"Missing optional evidence narrows claims, not independent work. Keep genuine permission and execution constraints. " +
|
|
77
|
+
"Mode selection changes no permissions, tools, models, limits or JEV settings.",
|
|
78
|
+
"Reuse completed work and current evidence. No mandatory delegation, research, evaluation or memory calls: " +
|
|
79
|
+
"use them only when useful and available under their existing rules.",
|
|
80
|
+
"For useful progress checkpoints, preserve the chosen approach, observed findings, limitations and next unfinished step through available memory, " +
|
|
81
|
+
"so resuming need not repeat work.",
|
|
82
|
+
"Keep planning and reporting concise; spend effort on delivery and verification.",
|
|
83
|
+
"</pi-daddy-work-mode>",
|
|
84
|
+
].join("\n");
|
|
85
|
+
}
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
} from "./activity-timeline.ts";
|
|
29
29
|
import { createDashboardDisplayControls } from "./dashboard-display-controls.ts";
|
|
30
30
|
import { dashboardJevNotice, JEV_CONSENT_NOTICE, JEV_EDITOR_NOTICE } from "./dashboard-settings.ts";
|
|
31
|
+
import { openWorkModeEditor, workModeEditAction } from "./dashboard-work-mode.ts";
|
|
31
32
|
import {
|
|
32
33
|
createDashboardConnection,
|
|
33
34
|
dashboardSessionRequest,
|
|
@@ -494,6 +495,27 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
494
495
|
);
|
|
495
496
|
if (action === "inspect-choice") void inspectChoice(display.screen, connection).then(redraw);
|
|
496
497
|
if (action === "answer-choice") void saveChoice(display.screen, connection).then(redraw);
|
|
498
|
+
if (action === "apply-work-mode" && display.screen.workModeEditor) {
|
|
499
|
+
const editor = display.screen.workModeEditor;
|
|
500
|
+
const snapshot = connection.state.snapshot;
|
|
501
|
+
const edit = workModeEditAction(editor, snapshot?.settings?.workMode, snapshot?.observation);
|
|
502
|
+
if (edit && !connection.state.pending) {
|
|
503
|
+
editor.busy = true;
|
|
504
|
+
void connection.change(edit).then((changed) => {
|
|
505
|
+
editor.busy = false;
|
|
506
|
+
if (changed) {
|
|
507
|
+
display.screen.view = "settings";
|
|
508
|
+
delete display.screen.workModeEditor;
|
|
509
|
+
display.screen.offset = 0;
|
|
510
|
+
notice =
|
|
511
|
+
edit.scope === "next-request"
|
|
512
|
+
? "Work mode saved for the next request only."
|
|
513
|
+
: "Work mode saved for this session; active work unchanged.";
|
|
514
|
+
} else editor.error = connection.state.error || "Work mode change was not confirmed. Cancel and refresh.";
|
|
515
|
+
redraw();
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
497
519
|
if (action === "quit") {
|
|
498
520
|
stop();
|
|
499
521
|
return;
|
|
@@ -504,7 +526,17 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
504
526
|
const settings = connection.state.snapshot?.settings;
|
|
505
527
|
if (!settings?.editable) notice = "Settings can only be changed in the connected owning parent";
|
|
506
528
|
else if (selected === "auto") action = "auto";
|
|
507
|
-
else if (selected === "
|
|
529
|
+
else if (selected === "work-mode") {
|
|
530
|
+
const editor = openWorkModeEditor(settings.workMode, connection.state.snapshot?.observation);
|
|
531
|
+
if (!editor) notice = "Work mode is unavailable or inherited from the parent.";
|
|
532
|
+
else {
|
|
533
|
+
display.screen.workModeEditor = editor;
|
|
534
|
+
display.screen.view = "work-mode";
|
|
535
|
+
display.screen.offset = 0;
|
|
536
|
+
display.screen.manualScroll = false;
|
|
537
|
+
notice = "";
|
|
538
|
+
}
|
|
539
|
+
} else if (selected === "wall" || selected === "idle") command = `limit ${selected} `;
|
|
508
540
|
else if (selected === "descendants") notice = "Startup only: set PI_DADDY_FANOUT before restarting Pi";
|
|
509
541
|
else if (selected === "depth") notice = "Startup only: set PI_DADDY_MAX_DEPTH before restarting Pi";
|
|
510
542
|
else if (selected === "perCall") notice = "Children per call is a fixed safety bound";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { openChoice, choiceKey } from "./dashboard-choice-picker.ts";
|
|
2
2
|
import { DASHBOARD_DESTINATIONS } from "./dashboard-panels.ts";
|
|
3
3
|
import { DASHBOARD_SETTING_KEYS } from "./dashboard-settings.ts";
|
|
4
|
+
import { workModeEditorKey } from "./dashboard-work-mode.ts";
|
|
4
5
|
/** Local display controls; these never dispatch actions to an owner or change ledger state. */
|
|
5
6
|
import { dashboardScreenState } from "./dashboard-screen.ts";
|
|
6
7
|
import { ActivityTimelineAliases } from "./activity-timeline.ts";
|
|
@@ -23,7 +24,27 @@ export function createDashboardDisplayControls(details: boolean, ledger: boolean
|
|
|
23
24
|
key(
|
|
24
25
|
key: string,
|
|
25
26
|
text?: string,
|
|
26
|
-
): "auto" | "quit" | "command" | "setting" | "inspect-choice" | "answer-choice" | undefined {
|
|
27
|
+
): "auto" | "quit" | "command" | "setting" | "inspect-choice" | "answer-choice" | "apply-work-mode" | undefined {
|
|
28
|
+
if (screen.view === "work-mode") {
|
|
29
|
+
if (key === "q" || key === "ctrl-c") return "quit";
|
|
30
|
+
if (key === "pageup" || key === "pagedown") {
|
|
31
|
+
screen.manualScroll = true;
|
|
32
|
+
screen.offset = Math.max(0, screen.offset + (key === "pageup" ? -8 : 8));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (["up", "down", "j", "k"].includes(key)) screen.manualScroll = false;
|
|
36
|
+
if (!screen.workModeEditor) {
|
|
37
|
+
screen.view = "settings";
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const action = workModeEditorKey(screen.workModeEditor, key);
|
|
41
|
+
if (action === "cancel-work-mode") {
|
|
42
|
+
delete screen.workModeEditor;
|
|
43
|
+
screen.view = "settings";
|
|
44
|
+
screen.offset = 0;
|
|
45
|
+
} else return action;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
27
48
|
if (screen.view === "choice") return choiceKey(screen, key, text);
|
|
28
49
|
if (key === "?" || key === "r") {
|
|
29
50
|
const reading = key === "?" ? "help" : "recap";
|
|
@@ -14,6 +14,12 @@ import { versionLines } from "./dashboard-components.ts";
|
|
|
14
14
|
import { sessionRecapLines } from "./dashboard-recap.ts";
|
|
15
15
|
import { colorSessionLine, previewWidth, sectionHeading } from "./dashboard-layout.ts";
|
|
16
16
|
import { visibleSettingKeys, dashboardSettingsLines, type DashboardSettingKey } from "./dashboard-settings.ts";
|
|
17
|
+
import {
|
|
18
|
+
availableWorkMode,
|
|
19
|
+
workModeOverview,
|
|
20
|
+
workModeEditorLines,
|
|
21
|
+
type DashboardWorkModeEditor,
|
|
22
|
+
} from "./dashboard-work-mode.ts";
|
|
17
23
|
/** Height-bounded, task-first view. Permission state is always supplied by the owner. */
|
|
18
24
|
import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
|
|
19
25
|
import type { DashboardProjection } from "./dashboard-projection.ts";
|
|
@@ -42,8 +48,19 @@ export interface DashboardItem {
|
|
|
42
48
|
agent?: boolean;
|
|
43
49
|
}
|
|
44
50
|
export interface DashboardScreenState {
|
|
45
|
-
view:
|
|
51
|
+
view:
|
|
52
|
+
| "main"
|
|
53
|
+
| "details"
|
|
54
|
+
| "models"
|
|
55
|
+
| "help"
|
|
56
|
+
| "versions"
|
|
57
|
+
| "version-details"
|
|
58
|
+
| "settings"
|
|
59
|
+
| "recap"
|
|
60
|
+
| "choice"
|
|
61
|
+
| "work-mode";
|
|
46
62
|
picker?: ChoicePicker;
|
|
63
|
+
workModeEditor?: DashboardWorkModeEditor;
|
|
47
64
|
destination?: DashboardDestination;
|
|
48
65
|
expanded?: boolean;
|
|
49
66
|
sourceDetails?: boolean;
|
|
@@ -236,6 +253,7 @@ function sessionLocation(screen: DashboardScreenState, width: number): string {
|
|
|
236
253
|
"version-details": "Version details",
|
|
237
254
|
recap: "Session recap",
|
|
238
255
|
choice: "Answer choice",
|
|
256
|
+
"work-mode": "Work mode",
|
|
239
257
|
};
|
|
240
258
|
const name = destinationNames[destination];
|
|
241
259
|
if (screen.view in overlays) return `${name} / ${overlays[screen.view as keyof typeof overlays]}`;
|
|
@@ -251,6 +269,7 @@ function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | und
|
|
|
251
269
|
const view = screen.view;
|
|
252
270
|
const brief = width < 34;
|
|
253
271
|
if (view === "choice") return choiceKeys(screen);
|
|
272
|
+
if (view === "work-mode") return ["↑↓ select · Enter/Space change", "Apply saves · Esc cancels"];
|
|
254
273
|
if (view === "main") {
|
|
255
274
|
if (selected?.choice) return ["↑↓ select · Enter answer", "d details · q close"];
|
|
256
275
|
const action = selected?.browse ? "browse" : "details";
|
|
@@ -342,16 +361,18 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
342
361
|
const footer =
|
|
343
362
|
options.command !== undefined
|
|
344
363
|
? [`: ${clean(options.command)}`]
|
|
345
|
-
:
|
|
346
|
-
?
|
|
347
|
-
:
|
|
348
|
-
?
|
|
349
|
-
: screen.view === "
|
|
350
|
-
? ["↑↓ select · Enter
|
|
351
|
-
:
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
364
|
+
: screen.view === "work-mode"
|
|
365
|
+
? ["↑↓ select · Enter/Space change", "Apply saves · Esc cancels"]
|
|
366
|
+
: modern
|
|
367
|
+
? sessionKeys(screen, selected, width)
|
|
368
|
+
: screen.view === "settings"
|
|
369
|
+
? ["↑↓ select · Enter toggle/edit · Esc back", "0 default limit · PgUp/PgDn scroll · s settings"]
|
|
370
|
+
: screen.view === "main" || screen.view === "versions"
|
|
371
|
+
? ["↑↓ select · Enter details · a Auto", "m models · v versions · s settings · ?"]
|
|
372
|
+
: [
|
|
373
|
+
"↑↓ scroll · Esc back · a Auto",
|
|
374
|
+
screen.view === "details" ? "p prompt · f final · : command · ? help" : ": command · ? help",
|
|
375
|
+
];
|
|
355
376
|
const fixed = [
|
|
356
377
|
modern && options.connected !== false ? `${header} · Connected` : header,
|
|
357
378
|
...(!modern
|
|
@@ -380,6 +401,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
380
401
|
"edit-jev": "JEV settings",
|
|
381
402
|
set: "model",
|
|
382
403
|
"set-limit": "limit",
|
|
404
|
+
"set-work-mode": "work mode",
|
|
383
405
|
} as Record<string, string>
|
|
384
406
|
)[ack.action] ?? "setting";
|
|
385
407
|
fixed.push(
|
|
@@ -396,6 +418,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
396
418
|
fixed.push(`Filter: ${options.filter} · Tab to change`);
|
|
397
419
|
if (modern && options.height >= 22) fixed.push("");
|
|
398
420
|
if (modern && screen.view === "main" && (screen.destination ?? "now") === "now" && !disconnected) {
|
|
421
|
+
fixed.push(...wrapDashboardLines(workModeOverview(session?.settings?.workMode), width));
|
|
399
422
|
const [heading, action] = sessionNextLines(options);
|
|
400
423
|
const recommendation = action !== "No current next step reported.";
|
|
401
424
|
if (recommendation) {
|
|
@@ -407,7 +430,11 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
407
430
|
if (options.height >= 22) fixed.push("");
|
|
408
431
|
}
|
|
409
432
|
const body: string[] = [];
|
|
410
|
-
if (screen.view === "
|
|
433
|
+
if (screen.view === "work-mode")
|
|
434
|
+
body.push(
|
|
435
|
+
...(screen.workModeEditor ? workModeEditorLines(screen.workModeEditor) : ["Reopen Work mode from Settings."]),
|
|
436
|
+
);
|
|
437
|
+
else if (screen.view === "choice") body.push(...choiceLines);
|
|
411
438
|
else if (screen.view === "recap") {
|
|
412
439
|
const recap = sessionRecapLines(options);
|
|
413
440
|
const activity = recap.findIndex(
|
|
@@ -449,7 +476,11 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
449
476
|
"Finished means observed completion, not acceptance.",
|
|
450
477
|
);
|
|
451
478
|
else if (screen.view === "settings") {
|
|
452
|
-
screen.settingKeys = visibleSettingKeys(
|
|
479
|
+
screen.settingKeys = visibleSettingKeys(
|
|
480
|
+
session?.settings?.jev,
|
|
481
|
+
Boolean(session?.settings?.telemetry),
|
|
482
|
+
Boolean(availableWorkMode(session?.settings?.workMode)),
|
|
483
|
+
);
|
|
453
484
|
if (screen.settingKey && !screen.settingKeys.includes(screen.settingKey)) screen.settingKey = "jev";
|
|
454
485
|
body.push(
|
|
455
486
|
...(disconnected
|
|
@@ -608,7 +639,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
|
|
|
608
639
|
if (row < screen.offset) screen.offset = row;
|
|
609
640
|
else if (row + 1 >= screen.offset + room) screen.offset = Math.max(0, row + 2 - room);
|
|
610
641
|
}
|
|
611
|
-
if (screen.view === "settings" && room > 0 && !screen.manualScroll) {
|
|
642
|
+
if ((screen.view === "settings" || screen.view === "work-mode") && room > 0 && !screen.manualScroll) {
|
|
612
643
|
const row = detailBody.findIndex((line) => line.startsWith(">"));
|
|
613
644
|
if (row >= 0) {
|
|
614
645
|
// Keep the first supporting detail with its control, even when the detail wraps.
|
|
@@ -8,6 +8,7 @@ import { DASHBOARD_RESPONSE_BYTES, type DashboardOwnerObservation } from "../ker
|
|
|
8
8
|
import type { DashboardSettingsSnapshot, JevEditAction } from "./dashboard-settings.ts";
|
|
9
9
|
import type { EcosystemVersions } from "./ecosystem-versions.ts";
|
|
10
10
|
import { createConnection } from "node:net";
|
|
11
|
+
import type { WorkModeSelection } from "../kernel/work-mode.ts";
|
|
11
12
|
|
|
12
13
|
export interface DashboardSessionSnapshot {
|
|
13
14
|
rows: Array<{ definition: string; model: string; thinking: string; source: string }>;
|
|
@@ -26,6 +27,7 @@ export interface DashboardSessionSnapshot {
|
|
|
26
27
|
interface DashboardSessionReply extends DashboardSessionSnapshot {
|
|
27
28
|
choiceDetail?: DashboardChoiceDetail;
|
|
28
29
|
choiceSaved?: true;
|
|
30
|
+
workModeApplied?: true;
|
|
29
31
|
choiceRefreshRequested?: true;
|
|
30
32
|
sourceRefreshRequested?: true;
|
|
31
33
|
}
|
|
@@ -49,6 +51,7 @@ export type DashboardSessionAction = (
|
|
|
49
51
|
| { action: "set-telemetry"; enabled: boolean }
|
|
50
52
|
| { action: "edit-jev"; option: JevEditAction }
|
|
51
53
|
| { action: "set-limit"; key: "wall" | "idle"; seconds: number }
|
|
54
|
+
| { action: "set-work-mode"; selection: WorkModeSelection; scope: "session" | "next-request" }
|
|
52
55
|
) & { expectedOwner?: { sessionId: string; cwd: string; generation: string } };
|
|
53
56
|
|
|
54
57
|
export async function dashboardSessionRequest(
|
|
@@ -92,6 +95,8 @@ export async function dashboardSessionRequest(
|
|
|
92
95
|
throw Error("The owner returned an unavailable choice.");
|
|
93
96
|
if (request.action === "answer-choice" && parsed.choiceSaved !== true)
|
|
94
97
|
throw Error("Bookie did not confirm the answer.");
|
|
98
|
+
if (request.action === "set-work-mode" && parsed.workModeApplied !== true)
|
|
99
|
+
throw Error("The owner did not confirm the work mode.");
|
|
95
100
|
if (
|
|
96
101
|
!parsed.auto ||
|
|
97
102
|
typeof parsed.auto.enabled !== "boolean" ||
|
|
@@ -255,9 +260,13 @@ export function createDashboardConnection(
|
|
|
255
260
|
? "use the main Pi session; current values shown below"
|
|
256
261
|
: action.action === "set-jev"
|
|
257
262
|
? "current JEV session; separate paid-call and storage choices"
|
|
258
|
-
: action.action === "set-
|
|
259
|
-
?
|
|
260
|
-
|
|
263
|
+
: action.action === "set-work-mode"
|
|
264
|
+
? action.scope === "next-request"
|
|
265
|
+
? "next request only, including its children"
|
|
266
|
+
: "future requests in this session; active work unchanged"
|
|
267
|
+
: action.action === "set-telemetry"
|
|
268
|
+
? "optional telemetry polling in this Pi session"
|
|
269
|
+
: "future children; running children unchanged";
|
|
261
270
|
state.acknowledgment = { action: action.action, state: "pending", effect };
|
|
262
271
|
try {
|
|
263
272
|
const snapshot = await request({
|
|
@@ -274,7 +283,20 @@ export function createDashboardConnection(
|
|
|
274
283
|
});
|
|
275
284
|
if (action.action === "answer-choice" && (snapshot.choiceSaved !== true || !matchesOwner(snapshot, action)))
|
|
276
285
|
throw Error("Bookie did not confirm the answer.");
|
|
277
|
-
|
|
286
|
+
if (action.action === "set-work-mode") {
|
|
287
|
+
const expected = action.expectedOwner ?? observedOwner;
|
|
288
|
+
const acknowledged = snapshot.observation;
|
|
289
|
+
if (
|
|
290
|
+
snapshot.workModeApplied !== true ||
|
|
291
|
+
!expected ||
|
|
292
|
+
!acknowledged ||
|
|
293
|
+
expected.sessionId !== acknowledged.sessionId ||
|
|
294
|
+
expected.cwd !== acknowledged.cwd ||
|
|
295
|
+
expected.generation !== acknowledged.generation
|
|
296
|
+
)
|
|
297
|
+
throw Error("The owner did not confirm the work mode in this session.");
|
|
298
|
+
}
|
|
299
|
+
const { choiceDetail: _detail, choiceSaved: _saved, workModeApplied: _modeApplied, ...observed } = snapshot;
|
|
278
300
|
if (!accept(observed)) throw Error("owner acknowledgment is stale; reconcile before another action");
|
|
279
301
|
state.acknowledgment.state =
|
|
280
302
|
action.action === "edit-jev"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AutoModeSource } from "../kernel/auto-mode.ts";
|
|
2
2
|
import { sectionHeading } from "./dashboard-layout.ts";
|
|
3
|
+
import { workModeLabel, type WorkModeSnapshot } from "../kernel/work-mode.ts";
|
|
4
|
+
import { availableWorkMode } from "./dashboard-work-mode.ts";
|
|
3
5
|
|
|
4
6
|
/** Settings are owner observations; rendering never grants consent or changes execution. */
|
|
5
7
|
export const JEV_EDIT_ACTIONS = ["limit", "configure", "hints"] as const;
|
|
@@ -7,7 +9,7 @@ export type JevEditAction = (typeof JEV_EDIT_ACTIONS)[number];
|
|
|
7
9
|
export const isJevEditAction = (value: unknown): value is JevEditAction =>
|
|
8
10
|
JEV_EDIT_ACTIONS.some((key) => value === key);
|
|
9
11
|
export type DashboardSettingKey =
|
|
10
|
-
JevEditAction | "auto" | "jev" | "wall" | "idle" | "descendants" | "depth" | "perCall" | "telemetry";
|
|
12
|
+
JevEditAction | "auto" | "jev" | "wall" | "idle" | "descendants" | "depth" | "perCall" | "telemetry" | "work-mode";
|
|
11
13
|
export const DASHBOARD_SETTING_KEYS: DashboardSettingKey[] = [
|
|
12
14
|
"auto",
|
|
13
15
|
"jev",
|
|
@@ -36,9 +38,20 @@ export interface DashboardJevState {
|
|
|
36
38
|
storageRoot?: string;
|
|
37
39
|
error?: string;
|
|
38
40
|
}
|
|
39
|
-
export function visibleSettingKeys(
|
|
41
|
+
export function visibleSettingKeys(
|
|
42
|
+
jev?: DashboardJevState,
|
|
43
|
+
telemetry = false,
|
|
44
|
+
workMode = false,
|
|
45
|
+
): DashboardSettingKey[] {
|
|
40
46
|
const extra = JEV_EDIT_ACTIONS.filter((key) => jev?.available && jev.controls?.includes(key));
|
|
41
|
-
return [
|
|
47
|
+
return [
|
|
48
|
+
"auto",
|
|
49
|
+
...(workMode ? ["work-mode" as const] : []),
|
|
50
|
+
"jev",
|
|
51
|
+
...extra,
|
|
52
|
+
...(telemetry ? ["telemetry" as const] : []),
|
|
53
|
+
...DASHBOARD_SETTING_KEYS.slice(2),
|
|
54
|
+
];
|
|
42
55
|
}
|
|
43
56
|
export interface DashboardSettingsSnapshot {
|
|
44
57
|
editable: boolean;
|
|
@@ -51,6 +64,7 @@ export interface DashboardSettingsSnapshot {
|
|
|
51
64
|
maxDepth: number;
|
|
52
65
|
perCall: number;
|
|
53
66
|
jev: DashboardJevState;
|
|
67
|
+
workMode?: WorkModeSnapshot;
|
|
54
68
|
telemetry?: {
|
|
55
69
|
enabled: boolean;
|
|
56
70
|
status: "disabled" | "missing-dependency" | "stopped" | "disconnected" | "stale" | "connected";
|
|
@@ -83,6 +97,7 @@ export function dashboardSettingsLines(
|
|
|
83
97
|
const canConfigure = jev.controls?.includes("configure");
|
|
84
98
|
const providerIndent = canConfigure ? " " : " ";
|
|
85
99
|
const telemetry = settings.telemetry;
|
|
100
|
+
const workMode = availableWorkMode(settings.workMode);
|
|
86
101
|
const gpu = telemetry?.gpuPercent === undefined ? "unavailable" : `${telemetry.gpuPercent}%`;
|
|
87
102
|
const temperature = telemetry?.temperatureC === undefined ? "unavailable" : `${telemetry.temperatureC}°C`;
|
|
88
103
|
const ram =
|
|
@@ -113,6 +128,21 @@ export function dashboardSettingsLines(
|
|
|
113
128
|
]
|
|
114
129
|
: []),
|
|
115
130
|
"",
|
|
131
|
+
...(workMode
|
|
132
|
+
? [
|
|
133
|
+
sectionHeading("WORK MODE", width),
|
|
134
|
+
row("work-mode", `Session: ${workModeLabel(workMode.selection)}`),
|
|
135
|
+
...(workMode.selection.mode === "standard" ? [" Standard: Current behavior."] : []),
|
|
136
|
+
` Active now: ${workMode.active ? workModeLabel(workMode.active) : "Idle"}`,
|
|
137
|
+
` Next request: ${workMode.nextRequest ? `${workModeLabel(workMode.nextRequest)} · once` : "session setting"}`,
|
|
138
|
+
workMode.inherited
|
|
139
|
+
? " Inherited from the parent; read-only."
|
|
140
|
+
: " Enter to choose mode, scope and emphases.",
|
|
141
|
+
" Session setting resets to Standard after /new.",
|
|
142
|
+
...(workMode.note ? [` ${workMode.note}`] : []),
|
|
143
|
+
"",
|
|
144
|
+
]
|
|
145
|
+
: []),
|
|
116
146
|
sectionHeading("JEV · optional advice", width),
|
|
117
147
|
row(
|
|
118
148
|
"jev",
|