pi-daddy 0.56.2 → 0.57.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 (77) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +16 -2
  3. package/dist/executors/owned-worker.d.ts.map +1 -1
  4. package/dist/executors/owned-worker.js +16 -14
  5. package/dist/executors/owned-worker.js.map +1 -1
  6. package/dist/executors/worker-artifact.d.ts +1 -1
  7. package/dist/executors/worker-artifact.js +1 -1
  8. package/dist/governance/approval-prompt.d.ts +3 -1
  9. package/dist/governance/approval-prompt.d.ts.map +1 -1
  10. package/dist/governance/approval-prompt.js +7 -3
  11. package/dist/governance/approval-prompt.js.map +1 -1
  12. package/dist/governance/permission-question.d.ts.map +1 -1
  13. package/dist/governance/permission-question.js +15 -5
  14. package/dist/governance/permission-question.js.map +1 -1
  15. package/dist/kernel/child-tools.d.ts +17 -0
  16. package/dist/kernel/child-tools.d.ts.map +1 -0
  17. package/dist/kernel/child-tools.js +46 -0
  18. package/dist/kernel/child-tools.js.map +1 -0
  19. package/dist/kernel/definitions.d.ts +2 -0
  20. package/dist/kernel/definitions.d.ts.map +1 -1
  21. package/dist/kernel/definitions.js.map +1 -1
  22. package/dist/kernel/delegate-types.d.ts +2 -0
  23. package/dist/kernel/delegate-types.d.ts.map +1 -1
  24. package/dist/kernel/delegate-types.js.map +1 -1
  25. package/dist/kernel/delegate.d.ts.map +1 -1
  26. package/dist/kernel/delegate.js +12 -1
  27. package/dist/kernel/delegate.js.map +1 -1
  28. package/dist/kernel/principal-binding.d.ts.map +1 -1
  29. package/dist/kernel/principal-binding.js +11 -0
  30. package/dist/kernel/principal-binding.js.map +1 -1
  31. package/dist/kernel/selected-definitions.d.ts.map +1 -1
  32. package/dist/kernel/selected-definitions.js +10 -1
  33. package/dist/kernel/selected-definitions.js.map +1 -1
  34. package/dist/kernel/selected-resources.d.ts +21 -0
  35. package/dist/kernel/selected-resources.d.ts.map +1 -0
  36. package/dist/kernel/selected-resources.js +10 -0
  37. package/dist/kernel/selected-resources.js.map +1 -0
  38. package/dist/kernel/spawn.d.ts +2 -0
  39. package/dist/kernel/spawn.d.ts.map +1 -1
  40. package/dist/kernel/spawn.js +3 -1
  41. package/dist/kernel/spawn.js.map +1 -1
  42. package/dist/products/dashboard-components.d.ts.map +1 -1
  43. package/dist/products/dashboard-components.js +17 -1
  44. package/dist/products/dashboard-components.js.map +1 -1
  45. package/dist/products/dashboard-screen.d.ts.map +1 -1
  46. package/dist/products/dashboard-screen.js +1 -1
  47. package/dist/products/dashboard-screen.js.map +1 -1
  48. package/dist/products/dashboard-settings.d.ts +2 -1
  49. package/dist/products/dashboard-settings.d.ts.map +1 -1
  50. package/dist/products/dashboard-settings.js +10 -1
  51. package/dist/products/dashboard-settings.js.map +1 -1
  52. package/extensions/approvals.ts +52 -38
  53. package/extensions/chain-approval-facts.ts +20 -0
  54. package/extensions/definition-describe.ts +1 -0
  55. package/extensions/delegate-chain.ts +35 -21
  56. package/extensions/grants.ts +2 -0
  57. package/extensions/session.ts +3 -0
  58. package/native/linux-x64/worker +0 -0
  59. package/native/linux-x64/worker.sha256 +1 -1
  60. package/native/provenance.json +3 -3
  61. package/native/worker.c +35 -4
  62. package/package.json +2 -2
  63. package/src/executors/owned-worker.ts +16 -14
  64. package/src/executors/worker-artifact.ts +1 -1
  65. package/src/governance/approval-prompt.ts +10 -4
  66. package/src/governance/permission-question.ts +16 -5
  67. package/src/kernel/child-tools.ts +62 -0
  68. package/src/kernel/definitions.ts +2 -0
  69. package/src/kernel/delegate-types.ts +2 -0
  70. package/src/kernel/delegate.ts +12 -1
  71. package/src/kernel/principal-binding.ts +11 -0
  72. package/src/kernel/selected-definitions.ts +11 -1
  73. package/src/kernel/selected-resources.ts +20 -0
  74. package/src/kernel/spawn.ts +4 -1
  75. package/src/products/dashboard-components.ts +21 -1
  76. package/src/products/dashboard-screen.ts +1 -0
  77. package/src/products/dashboard-settings.ts +11 -0
@@ -0,0 +1,62 @@
1
+ /** Child delivery is separate from a parent's catalog and from permission to grant a tool. */
2
+ import { toPiToolsAllowlist, type Capability } from "./resolve.ts";
3
+ import { refusal, type StructuredRefusal } from "./refusals.ts";
4
+
5
+ /** Native CLI tools shared by the qualified Pi 1.0.4 and 1.5.2 runtimes, not the display catalog. */
6
+ const nativeTools = new Set(["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"]);
7
+ const governedTools = new Set(["delegate", "delegate_all", "delegate_chain", "delegate_describe"]);
8
+ export interface ChildToolSource {
9
+ readonly name: string;
10
+ readonly sourceInfo?: Readonly<{ path?: string; source?: string }>;
11
+ }
12
+
13
+ /** Copy only public origin metadata. Provider schemas, credentials and runtime objects do not cross. */
14
+ export function snapshotChildTools(tools: readonly ChildToolSource[]): readonly ChildToolSource[] {
15
+ return Object.freeze(
16
+ tools.map((tool) =>
17
+ Object.freeze({
18
+ name: tool.name,
19
+ ...(tool.sourceInfo
20
+ ? {
21
+ sourceInfo: Object.freeze({
22
+ path: tool.sourceInfo.path,
23
+ source: tool.sourceInfo.source,
24
+ }),
25
+ }
26
+ : {}),
27
+ }),
28
+ ),
29
+ );
30
+ }
31
+
32
+ export function childToolDeliveryRefusal(
33
+ requested: Capability[],
34
+ context: { childToolSources?: readonly ChildToolSource[]; extensionPath?: string },
35
+ ): StructuredRefusal | undefined {
36
+ const unavailable: string[] = [];
37
+ for (const name of toPiToolsAllowlist(requested) ?? []) {
38
+ // The existing narrowing guard owns wildcard refusal, not delivery classification.
39
+ if (name === "*") continue;
40
+ const entries = context.childToolSources?.filter((tool) => tool.name === name);
41
+ const source = entries?.length === 1 ? entries[0].sourceInfo : undefined;
42
+ // Pure legacy callers may omit observations; real extension dispatch always supplies the live inventory.
43
+ const unobserved = context.childToolSources === undefined;
44
+ const builtin =
45
+ nativeTools.has(name) && (unobserved || (source?.source === "builtin" && source.path === `builtin:${name}`));
46
+ const governed =
47
+ governedTools.has(name) &&
48
+ requested.includes("tool:delegate") &&
49
+ !!context.extensionPath &&
50
+ (unobserved || source?.path === context.extensionPath);
51
+ if (!builtin && !governed) unavailable.push(name);
52
+ }
53
+ if (!unavailable.length) return undefined;
54
+ return refusal(
55
+ "UNKNOWN_TOOL",
56
+ `child tool unavailable: ${unavailable.join(", ")} — the parent catalog is not child delivery. ` +
57
+ "Governed children load native Pi tools and Daddy's explicit entrypoint only; external extensions, MCP and " +
58
+ "SDK-only tools have no qualified child provider here. Keep this work in the parent or choose a definition " +
59
+ "using supported child tools. Additional permission cannot install or qualify a provider.",
60
+ { kind: "child-tool-unavailable", tools: unavailable.join(",") },
61
+ );
62
+ }
@@ -59,6 +59,8 @@ export function digestDefinition(definition: SkillDefinition): DefinitionDigest
59
59
  }
60
60
 
61
61
  export interface SkillDefinition {
62
+ /** Trusted selected-source locations, frozen with the definition identity; never additional authority. */
63
+ selectedResources?: import("./selected-resources.ts").SelectedResources;
62
64
  /** Present only for explicit local public-evidence capture; excluded from authority and identity. */
63
65
  sourceSnapshot?: import("./definition-sources.ts").DefinitionSourceSnapshot;
64
66
  /** Immutable selected-resource identity, independent of the model-authored name. */
@@ -80,6 +80,8 @@ export interface DelegationContext {
80
80
  extensionPath?: string;
81
81
  /** No-tool activity observer injected only for governed leaf children. */
82
82
  observerExtensionPath?: string;
83
+ /** Public tool origins observed in the current host; names alone do not establish child delivery. */
84
+ childToolSources?: readonly import("./child-tools.ts").ChildToolSource[];
83
85
  /**
84
86
  * Extra per-child environment supplied by the composition layer (today: the activity timeline's local
85
87
  * observation identity). Evaluated once the child's execution id is known. The kernel refuses any key in
@@ -5,7 +5,9 @@
5
5
 
6
6
  import { planSpawn } from "./spawn.ts";
7
7
  import { ceilingForDefinition, digestDefinition, type DefinitionDigest, type SkillDefinition } from "./definitions.ts";
8
- import { assertNarrowing, type Capability, type ResolveResult, expandSubsumed } from "./resolve.ts";
8
+ import { assertNarrowing, type Capability, type ResolveResult, expandSubsumed, resolve } from "./resolve.ts";
9
+ import { childToolDeliveryRefusal } from "./child-tools.ts";
10
+ import { selectedResourcePrompt } from "./selected-resources.ts";
9
11
  import { checkRoutingAuthority, checkWorkspaceWildcardRequest } from "./routing-authority.ts";
10
12
  import { DELEGATE_CAPABILITY, agentCapability, maySpawnDefinition, normaliseCapability } from "./capabilities.ts";
11
13
 
@@ -296,6 +298,14 @@ export function planDelegation(request: DelegationRequest, ctx: DelegationContex
296
298
  return denied({ ...empty, requested, reason: wildcardRequest.reason }, wildcardRequest.code);
297
299
  }
298
300
 
301
+ // Refuse undeliverable tools before calculating a permission request. Preserve escalation precedence:
302
+ // a caller without authority still receives the ordinary denial and its exact denied capability set.
303
+ const authority = resolve({ requested, parentGrant: ctx.ownGrant });
304
+ if (authority.denied.length === 0 && authority.universal.length === 0) {
305
+ const unavailable = childToolDeliveryRefusal(requested, ctx);
306
+ if (unavailable) return { ...empty, requested, reason: unavailable.message, refusal: unavailable };
307
+ }
308
+
299
309
  const { result, approvalBinding, bindingMismatch } = resolveDelegationApproval({
300
310
  task: request.task,
301
311
  agent: request.agent,
@@ -365,6 +375,7 @@ export function planDelegation(request: DelegationRequest, ctx: DelegationContex
365
375
  skillPaths: ctx.skillPaths,
366
376
  contextFiles: ctx.contextFiles,
367
377
  systemPrompt,
378
+ selectedResourcePrompt: selectedResourcePrompt(spawned?.selectedResources),
368
379
  // A fork replaces the session file rather than joining it: pi refuses `--fork` beside `--session`.
369
380
  ...(staged?.forkFrom ? { forkFrom: staged.forkFrom } : { sessionFile: ctx.sessionFile }),
370
381
  ...(staged?.contextPrompt ? { contextPrompt: staged.contextPrompt } : {}),
@@ -100,5 +100,16 @@ export async function principalBinding(
100
100
  runtimePreferences: agent.runtimePreferences ?? inline.runtimePreferences,
101
101
  ...(typeof pkg.version === "string" ? { packageVersion: pkg.version } : {}),
102
102
  binding: Object.freeze({ package: "principal-pi-skills", phase }),
103
+ selectedResources: Object.freeze({
104
+ version: 1 as const,
105
+ selectedSkill: Object.freeze({ path, sha256: hash(skillText) }),
106
+ definition: Object.freeze({ path: agentPath, sha256: hash(agentText) }),
107
+ resourceDirectory: dirname(path),
108
+ package: Object.freeze({
109
+ name: "principal-pi-skills" as const,
110
+ root,
111
+ ...(typeof pkg.version === "string" ? { version: pkg.version } : {}),
112
+ }),
113
+ }),
103
114
  };
104
115
  }
@@ -1,6 +1,6 @@
1
1
  /** Selected Pi 1.0.4 resources, frozen once per extension instance. No independent resource scan. */
2
2
  import { createHash } from "node:crypto";
3
- import { resolve as resolvePath } from "node:path";
3
+ import { dirname, resolve as resolvePath } from "node:path";
4
4
  import { lstat } from "node:fs/promises";
5
5
  import { BoundedReadCleanupError, readBoundedBytes } from "./bounded-read.ts";
6
6
  import { parseSkillDefinition, type SkillDefinition } from "./definitions.ts";
@@ -50,6 +50,14 @@ export async function selectedDefinitions(
50
50
  const parsed = parseSkillDefinition(path, text);
51
51
  if (!parsed || parsed.name !== name) throw Error("selected name/path does not match definition");
52
52
  const bound = await principalBinding(path, parsed, text, sources, read);
53
+ const selectedResources =
54
+ bound.selectedResources ??
55
+ Object.freeze({
56
+ version: 1 as const,
57
+ selectedSkill: Object.freeze({ path, sha256: hash(text) }),
58
+ definition: Object.freeze({ path: bound.source, sha256: bound.sourceHash! }),
59
+ resourceDirectory: dirname(path),
60
+ });
53
61
  const definitionId = hash(
54
62
  JSON.stringify({
55
63
  name,
@@ -61,6 +69,7 @@ export async function selectedDefinitions(
61
69
  runtimePreferences: bound.runtimePreferences,
62
70
  binding: bound.binding,
63
71
  packageVersion: bound.packageVersion,
72
+ selectedResources,
64
73
  }),
65
74
  );
66
75
  if (bound.metadata) Object.freeze(bound.metadata);
@@ -68,6 +77,7 @@ export async function selectedDefinitions(
68
77
  name,
69
78
  Object.freeze({
70
79
  ...bound,
80
+ selectedResources,
71
81
  definitionId,
72
82
  ...(sources
73
83
  ? { sourceSnapshot: Object.freeze({ resources: Object.freeze(sources), body: bound.body }) }
@@ -0,0 +1,20 @@
1
+ /** Locations of the selected definition, not permission to load additional resources. */
2
+ export interface SelectedResources {
3
+ readonly version: 1;
4
+ readonly selectedSkill: Readonly<{ path: string; sha256: string }>;
5
+ readonly definition: Readonly<{ path: string; sha256: string }>;
6
+ readonly resourceDirectory: string;
7
+ /** Present only after the selected Principal package's existing binding checks succeeded. */
8
+ readonly package?: Readonly<{ name: "principal-pi-skills"; root: string; version?: string }>;
9
+ }
10
+
11
+ export function selectedResourcePrompt(resources: SelectedResources | undefined): string | undefined {
12
+ if (!resources) return undefined;
13
+ return (
14
+ "Selected definition resource locations (pi-daddy, version 1):\n" +
15
+ JSON.stringify(resources) +
16
+ "\nThese locations identify the selected instruction source. Resolve its relative resource references here, " +
17
+ "using only tools already granted. Other resource contents and availability have not been verified or loaded. " +
18
+ "These locations grant no additional tools, runtime skills, permission, or task approval."
19
+ );
20
+ }
@@ -55,6 +55,8 @@ export interface SpawnPlanInput {
55
55
  * definition only has to describe its own job.
56
56
  */
57
57
  systemPrompt?: string;
58
+ /** Trusted selected-definition locations, separate from the unchanged authored body. */
59
+ selectedResourcePrompt?: string;
58
60
  }
59
61
 
60
62
  export interface SpawnPlan {
@@ -99,7 +101,7 @@ export function planSpawn(input: SpawnPlanInput): SpawnPlan {
99
101
  else args.push("--no-session");
100
102
 
101
103
  // Disable discovery so ambient user extensions cannot widen a governed child's surface. Explicit
102
- // `-e` paths would still load, so this package never passes one.
104
+ // `-e` paths still load; the delegation planner adds only its qualified governance/observer entrypoint.
103
105
  args.push("--no-extensions");
104
106
 
105
107
  // R-32. `--no-extensions` governs EXTENSIONS ONLY — measured, not assumed: a child spawned with
@@ -143,6 +145,7 @@ export function planSpawn(input: SpawnPlanInput): SpawnPlan {
143
145
  // picks WHICH definition, never its contents. That is what keeps it out of `neutralisePrompt`'s
144
146
  // remit: the G1 hazard is a model-controlled string reaching a parser, and this is not one.
145
147
  if (input.systemPrompt) args.push("--append-system-prompt", input.systemPrompt);
148
+ if (input.selectedResourcePrompt) args.push("--append-system-prompt", input.selectedResourcePrompt);
146
149
  // After the definition body, so a child reads what it IS before what it was told (ADR-0078). Operator- and
147
150
  // parent-authored text, never a model-chosen argv position, so `neutralisePrompt` has no remit here either.
148
151
  if (input.contextPrompt) args.push("--append-system-prompt", input.contextPrompt);
@@ -138,7 +138,12 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
138
138
  let state = "observed",
139
139
  status: string,
140
140
  explanation: string;
141
- if (options.connected === false || (source && !current(source, options))) {
141
+ if (
142
+ options.connected === false ||
143
+ (source &&
144
+ !current(source, options) &&
145
+ !(source.producer === "bookie-memory" && options.session?.auto.enabled === false))
146
+ ) {
142
147
  state = "last-observed";
143
148
  status = "Live status unknown";
144
149
  const lastReport =
@@ -150,6 +155,21 @@ function componentItem(producer: KnownSource, options: DashboardScreenOptions):
150
155
  ? "Project connected"
151
156
  : undefined;
152
157
  explanation = (lastReport ? `Last report: ${lastReport}. ` : "") + "Check the main Pi chat for current status.";
158
+ } else if (
159
+ bookie &&
160
+ options.session &&
161
+ !options.session.auto.enabled &&
162
+ (source?.producer === "bookie-memory" || pkg?.commandAvailable || pkg?.loadedVersion) &&
163
+ !(source?.producer === "bookie" && current(source, options) && source.items.length)
164
+ ) {
165
+ status = "Automatic memory paused · Auto OFF";
166
+ const origin =
167
+ options.session.auto.source === "session"
168
+ ? "Auto was turned off for this session."
169
+ : options.session.auto.source === "environment"
170
+ ? "Pi started with Auto off."
171
+ : "Auto starts off by default.";
172
+ explanation = `${origin} Turn Auto on in Settings for automatic notes in this folder, or use /bookie-context to select memory manually. A session toggle does not change the startup setting.`;
153
173
  } else if (source?.producer === "bookie-memory") {
154
174
  status = "Ready in this folder";
155
175
  explanation = "Bookie can save and recall routine notes for this workspace.";
@@ -461,6 +461,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
461
461
  session?.auto.enabled,
462
462
  screen.settingKey ?? "auto",
463
463
  width,
464
+ session?.auto.source,
464
465
  ),
465
466
  );
466
467
  if (session?.observation)
@@ -1,3 +1,4 @@
1
+ import type { AutoModeSource } from "../kernel/auto-mode.ts";
1
2
  import { sectionHeading } from "./dashboard-layout.ts";
2
3
 
3
4
  /** Settings are owner observations; rendering never grants consent or changes execution. */
@@ -63,6 +64,7 @@ export function dashboardSettingsLines(
63
64
  auto: boolean | undefined,
64
65
  selected: DashboardSettingKey,
65
66
  width: number,
67
+ autoSource?: AutoModeSource,
66
68
  ): string[] {
67
69
  if (!settings) return ["Owner settings unavailable. Reconnect from /grants dashboard."];
68
70
  const row = (key: DashboardSettingKey, label: string, nested = false) =>
@@ -84,6 +86,15 @@ export function dashboardSettingsLines(
84
86
  return [
85
87
  sectionHeading("PERMISSIONS", width),
86
88
  row("auto", `Permission Auto: ${auto ? "ON" : "OFF"}`),
89
+ ...(autoSource
90
+ ? [
91
+ autoSource === "session"
92
+ ? " Session choice; /new uses the startup setting."
93
+ : autoSource === "environment"
94
+ ? " From the startup environment."
95
+ : " Startup default: OFF.",
96
+ ]
97
+ : []),
87
98
  "",
88
99
  sectionHeading("JEV · optional advice", width),
89
100
  row(