pi-daddy 0.43.1 → 0.44.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 (221) hide show
  1. package/CHANGELOG.md +93 -31
  2. package/README.md +15 -0
  3. package/THIRD_PARTY_LICENSES/musl-COPYRIGHT.txt +193 -0
  4. package/THIRD_PARTY_LICENSES/zig-MIT.txt +21 -0
  5. package/THIRD_PARTY_NOTICES.md +9 -0
  6. package/dist/cli.d.ts +2 -1
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +10 -5
  9. package/dist/cli.js.map +1 -1
  10. package/dist/executors/activity-session.js +116 -65
  11. package/dist/executors/activity-session.js.map +1 -1
  12. package/dist/executors/captured-execution.d.ts +13 -0
  13. package/dist/executors/captured-execution.d.ts.map +1 -0
  14. package/dist/executors/captured-execution.js +53 -0
  15. package/dist/executors/captured-execution.js.map +1 -0
  16. package/dist/executors/child-final.d.ts +31 -0
  17. package/dist/executors/child-final.d.ts.map +1 -0
  18. package/dist/executors/child-final.js +197 -0
  19. package/dist/executors/child-final.js.map +1 -0
  20. package/dist/executors/executor.d.ts +2 -1
  21. package/dist/executors/executor.d.ts.map +1 -1
  22. package/dist/executors/executor.js +12 -0
  23. package/dist/executors/executor.js.map +1 -1
  24. package/dist/executors/owned-worker.d.ts +18 -0
  25. package/dist/executors/owned-worker.d.ts.map +1 -0
  26. package/dist/executors/owned-worker.js +295 -0
  27. package/dist/executors/owned-worker.js.map +1 -0
  28. package/dist/executors/worker-artifact.d.ts +3 -0
  29. package/dist/executors/worker-artifact.d.ts.map +1 -0
  30. package/dist/executors/worker-artifact.js +3 -0
  31. package/dist/executors/worker-artifact.js.map +1 -0
  32. package/dist/governance/approval-prompt.d.ts +4 -3
  33. package/dist/governance/approval-prompt.d.ts.map +1 -1
  34. package/dist/governance/approval-prompt.js +13 -6
  35. package/dist/governance/approval-prompt.js.map +1 -1
  36. package/dist/governance/captured-worker-record.d.ts +9 -0
  37. package/dist/governance/captured-worker-record.d.ts.map +1 -0
  38. package/dist/governance/captured-worker-record.js +123 -0
  39. package/dist/governance/captured-worker-record.js.map +1 -0
  40. package/dist/governance/lease-record.d.ts +4 -0
  41. package/dist/governance/lease-record.d.ts.map +1 -1
  42. package/dist/governance/lease-record.js +19 -2
  43. package/dist/governance/lease-record.js.map +1 -1
  44. package/dist/governance/ledger-events.d.ts +5 -5
  45. package/dist/governance/ledger-events.d.ts.map +1 -1
  46. package/dist/governance/ledger-v3-validation.js +1 -1
  47. package/dist/governance/ledger-v3-validation.js.map +1 -1
  48. package/dist/governance/workspace-acceptance.d.ts +3 -1
  49. package/dist/governance/workspace-acceptance.d.ts.map +1 -1
  50. package/dist/governance/workspace-acceptance.js +21 -5
  51. package/dist/governance/workspace-acceptance.js.map +1 -1
  52. package/dist/governance/workspace-lease.d.ts.map +1 -1
  53. package/dist/governance/workspace-lease.js +44 -1
  54. package/dist/governance/workspace-lease.js.map +1 -1
  55. package/dist/kernel/authority-text.d.ts +3 -0
  56. package/dist/kernel/authority-text.d.ts.map +1 -0
  57. package/dist/kernel/authority-text.js +22 -0
  58. package/dist/kernel/authority-text.js.map +1 -0
  59. package/dist/kernel/bounded-read-failures.d.ts +9 -0
  60. package/dist/kernel/bounded-read-failures.d.ts.map +1 -0
  61. package/dist/kernel/bounded-read-failures.js +33 -0
  62. package/dist/kernel/bounded-read-failures.js.map +1 -0
  63. package/dist/kernel/bounded-read-sync.d.ts +24 -0
  64. package/dist/kernel/bounded-read-sync.d.ts.map +1 -0
  65. package/dist/kernel/bounded-read-sync.js +75 -0
  66. package/dist/kernel/bounded-read-sync.js.map +1 -0
  67. package/dist/kernel/bounded-read.d.ts +29 -2
  68. package/dist/kernel/bounded-read.d.ts.map +1 -1
  69. package/dist/kernel/bounded-read.js +98 -9
  70. package/dist/kernel/bounded-read.js.map +1 -1
  71. package/dist/kernel/capacity.d.ts +36 -0
  72. package/dist/kernel/capacity.d.ts.map +1 -0
  73. package/dist/kernel/capacity.js +94 -0
  74. package/dist/kernel/capacity.js.map +1 -0
  75. package/dist/kernel/captured-worker-contract.d.ts +38 -0
  76. package/dist/kernel/captured-worker-contract.d.ts.map +1 -0
  77. package/dist/kernel/captured-worker-contract.js +2 -0
  78. package/dist/kernel/captured-worker-contract.js.map +1 -0
  79. package/dist/kernel/catalog.d.ts +12 -3
  80. package/dist/kernel/catalog.d.ts.map +1 -1
  81. package/dist/kernel/catalog.js +28 -8
  82. package/dist/kernel/catalog.js.map +1 -1
  83. package/dist/kernel/chain.d.ts +1 -0
  84. package/dist/kernel/chain.d.ts.map +1 -1
  85. package/dist/kernel/chain.js.map +1 -1
  86. package/dist/kernel/definitions.d.ts +11 -1
  87. package/dist/kernel/definitions.d.ts.map +1 -1
  88. package/dist/kernel/definitions.js +6 -3
  89. package/dist/kernel/definitions.js.map +1 -1
  90. package/dist/kernel/fanout.d.ts +5 -25
  91. package/dist/kernel/fanout.d.ts.map +1 -1
  92. package/dist/kernel/fanout.js +15 -30
  93. package/dist/kernel/fanout.js.map +1 -1
  94. package/dist/kernel/grant-env.d.ts +0 -2
  95. package/dist/kernel/grant-env.d.ts.map +1 -1
  96. package/dist/kernel/grant-env.js +0 -1
  97. package/dist/kernel/grant-env.js.map +1 -1
  98. package/dist/kernel/model-preflight.d.ts +8 -0
  99. package/dist/kernel/model-preflight.d.ts.map +1 -1
  100. package/dist/kernel/model-preflight.js +23 -0
  101. package/dist/kernel/model-preflight.js.map +1 -1
  102. package/dist/kernel/selected-definitions.d.ts +15 -0
  103. package/dist/kernel/selected-definitions.d.ts.map +1 -0
  104. package/dist/kernel/selected-definitions.js +146 -0
  105. package/dist/kernel/selected-definitions.js.map +1 -0
  106. package/dist/kernel/skill-packages.d.ts +4 -2
  107. package/dist/kernel/skill-packages.d.ts.map +1 -1
  108. package/dist/kernel/skill-packages.js +34 -41
  109. package/dist/kernel/skill-packages.js.map +1 -1
  110. package/dist/kernel/skill-resources.d.ts.map +1 -1
  111. package/dist/kernel/skill-resources.js +8 -11
  112. package/dist/kernel/skill-resources.js.map +1 -1
  113. package/dist/kernel/workspace.d.ts +6 -3
  114. package/dist/kernel/workspace.d.ts.map +1 -1
  115. package/dist/kernel/workspace.js +10 -6
  116. package/dist/kernel/workspace.js.map +1 -1
  117. package/dist/products/dashboard-cli.js +1 -1
  118. package/dist/products/dashboard-cli.js.map +1 -1
  119. package/dist/products/dashboard-render.d.ts +1 -2
  120. package/dist/products/dashboard-render.d.ts.map +1 -1
  121. package/dist/products/dashboard-render.js +3 -1
  122. package/dist/products/dashboard-render.js.map +1 -1
  123. package/dist/products/dashboard-session-client.d.ts +1 -2
  124. package/dist/products/dashboard-session-client.d.ts.map +1 -1
  125. package/dist/products/dashboard-session-client.js.map +1 -1
  126. package/dist/products/episode-report.d.ts +12 -8
  127. package/dist/products/episode-report.d.ts.map +1 -1
  128. package/dist/products/episode-report.js +61 -12
  129. package/dist/products/episode-report.js.map +1 -1
  130. package/extensions/approvals.ts +1 -1
  131. package/extensions/chain-plan.ts +9 -3
  132. package/extensions/context-staging.ts +30 -35
  133. package/extensions/dashboard-session-server.ts +1 -2
  134. package/extensions/definition-describe.ts +44 -0
  135. package/extensions/definition-runtime.ts +89 -26
  136. package/extensions/delegate-chain.ts +273 -256
  137. package/extensions/delegation-activation.ts +1 -1
  138. package/extensions/delegation.ts +41 -53
  139. package/extensions/execute-child.ts +167 -134
  140. package/extensions/fanout-outcome.ts +1 -9
  141. package/extensions/grants-command.ts +2 -9
  142. package/extensions/grants.ts +106 -38
  143. package/extensions/init-command.ts +52 -12
  144. package/extensions/reload-environment.ts +21 -2
  145. package/extensions/retired-inputs.ts +7 -0
  146. package/extensions/run-delegation.ts +212 -265
  147. package/extensions/session-capacity.ts +53 -0
  148. package/extensions/session-environment.ts +5 -2
  149. package/extensions/session-model-prompt.ts +33 -32
  150. package/extensions/session-report.ts +28 -11
  151. package/extensions/session.ts +200 -157
  152. package/extensions/workspace-runtime.ts +2 -1
  153. package/native/README.md +25 -0
  154. package/native/linux-x64/worker +0 -0
  155. package/native/linux-x64/worker.sha256 +1 -0
  156. package/native/provenance.json +42 -0
  157. package/native/toolchain.json +18 -0
  158. package/native/worker.c +209 -0
  159. package/package.json +15 -7
  160. package/src/cli.ts +16 -6
  161. package/src/executors/activity-session.ts +120 -66
  162. package/src/executors/captured-execution.ts +61 -0
  163. package/src/executors/child-final.ts +190 -0
  164. package/src/executors/executor.ts +14 -1
  165. package/src/executors/owned-worker.ts +322 -0
  166. package/src/executors/worker-artifact.ts +2 -0
  167. package/src/governance/approval-prompt.ts +18 -8
  168. package/src/governance/captured-worker-record.ts +138 -0
  169. package/src/governance/lease-record.ts +21 -2
  170. package/src/governance/ledger-events.ts +5 -5
  171. package/src/governance/ledger-v3-validation.ts +1 -1
  172. package/src/governance/workspace-acceptance.ts +20 -4
  173. package/src/governance/workspace-lease.ts +59 -1
  174. package/src/kernel/authority-text.ts +17 -0
  175. package/src/kernel/bounded-read-failures.ts +42 -0
  176. package/src/kernel/bounded-read-sync.ts +87 -0
  177. package/src/kernel/bounded-read.ts +128 -11
  178. package/src/kernel/capacity.ts +123 -0
  179. package/src/kernel/captured-worker-contract.ts +29 -0
  180. package/src/kernel/catalog.ts +45 -16
  181. package/src/kernel/chain.ts +1 -0
  182. package/src/kernel/definitions.ts +11 -2
  183. package/src/kernel/fanout.ts +17 -32
  184. package/src/kernel/grant-env.ts +0 -3
  185. package/src/kernel/model-preflight.ts +29 -0
  186. package/src/kernel/selected-definitions.ts +156 -0
  187. package/src/kernel/skill-packages.ts +40 -38
  188. package/src/kernel/skill-resources.ts +8 -9
  189. package/src/kernel/workspace.ts +12 -5
  190. package/src/products/dashboard-cli.ts +1 -1
  191. package/src/products/dashboard-render.ts +6 -2
  192. package/src/products/dashboard-session-client.ts +1 -2
  193. package/src/products/episode-report.ts +80 -17
  194. package/dist/advisors/advisor.d.ts +0 -90
  195. package/dist/advisors/advisor.d.ts.map +0 -1
  196. package/dist/advisors/advisor.js +0 -154
  197. package/dist/advisors/advisor.js.map +0 -1
  198. package/dist/advisors/decider.d.ts +0 -88
  199. package/dist/advisors/decider.d.ts.map +0 -1
  200. package/dist/advisors/decider.js +0 -29
  201. package/dist/advisors/decider.js.map +0 -1
  202. package/dist/advisors/jev.d.ts +0 -41
  203. package/dist/advisors/jev.d.ts.map +0 -1
  204. package/dist/advisors/jev.js +0 -139
  205. package/dist/advisors/jev.js.map +0 -1
  206. package/dist/advisors/settings.d.ts +0 -49
  207. package/dist/advisors/settings.d.ts.map +0 -1
  208. package/dist/advisors/settings.js +0 -99
  209. package/dist/advisors/settings.js.map +0 -1
  210. package/dist/governance/episode-cost-gate.d.ts +0 -31
  211. package/dist/governance/episode-cost-gate.d.ts.map +0 -1
  212. package/dist/governance/episode-cost-gate.js +0 -112
  213. package/dist/governance/episode-cost-gate.js.map +0 -1
  214. package/extensions/advisor-session.ts +0 -67
  215. package/extensions/effort-advice.ts +0 -112
  216. package/extensions/pruning-advice.ts +0 -133
  217. package/src/advisors/advisor.ts +0 -246
  218. package/src/advisors/decider.ts +0 -74
  219. package/src/advisors/jev.ts +0 -163
  220. package/src/advisors/settings.ts +0 -115
  221. package/src/governance/episode-cost-gate.ts +0 -128
@@ -1,90 +0,0 @@
1
- /**
2
- * The wrapper that makes "every use is recorded" structural rather than a rule (ADR-0077).
3
- *
4
- * A caller cannot reach a `Decider` directly through this layer's public surface: it asks an `Advisor`, and asking
5
- * always produces an `advice` record — including when the answer was "no advice", which is the case a reviewer most
6
- * needs to see, because an advisor that silently stops answering would otherwise look exactly like one nobody used.
7
- *
8
- * **What is recorded, and what is not.** The record names the purpose, the decider, the question keys, the answers
9
- * and how long it took. It does NOT contain the state. A caller composes that state from its own context, which can
10
- * include task text, file contents and a repository's private material; the ledger has never stored a task
11
- * (ADR-0021) and an advisor must not become the way it starts. The question keys are the caller's own constants,
12
- * so they name the decision without describing the situation.
13
- */
14
- import type { Advice, AdviceRequest, Decider } from "./decider.ts";
15
- /** Two seconds. An advisor is on the path of a decision a human is waiting for; it is not worth more than that. */
16
- export declare const DEFAULT_ADVICE_TIMEOUT_MS = 2000;
17
- export type TaskEgressMode = "digest" | "raw";
18
- export interface TaskDigest {
19
- length: number;
20
- language: string;
21
- referencedFiles: {
22
- count: number;
23
- extensions: string[];
24
- };
25
- }
26
- export interface AdviceRecord {
27
- /** Stable root episode; absent on records written before episode identity shipped. */
28
- episodeId?: string;
29
- /** The governed child this advice applied to; absent on records written before attribution shipped. */
30
- executionId?: string;
31
- /** Which task representation was sent; absent on records written before the egress split shipped. */
32
- taskEgress?: TaskEgressMode;
33
- /** Which decision this advice was for, from the caller's own closed list. */
34
- purpose: string;
35
- decider: string;
36
- /** Question keys only — never the state, and never a question's free text. */
37
- questions: string[];
38
- answered: boolean;
39
- durationMs: number;
40
- /** Present only when advice came back. */
41
- answers?: Readonly<Record<string, {
42
- value: string | number | boolean;
43
- confidence?: number;
44
- }>>;
45
- model?: string;
46
- resolvedModel: {
47
- provider: string;
48
- modelId: string;
49
- } | null;
50
- modelSource: "explicit" | "session" | "definition" | "global" | "pi";
51
- thinkingLevel: string | null;
52
- thinkingSource: "explicit" | "session" | "advisor" | "definition" | "global" | "pi";
53
- tokenDetail: {
54
- inputTokens: number | null;
55
- outputTokens: number | null;
56
- cacheReadTokens: number | null;
57
- cacheWriteTokens: number | null;
58
- reasoningTokens: number | null;
59
- };
60
- /**
61
- * Why there is no advice. `declined` means the advisor answered with nothing; `error` means it could not be
62
- * reached or its response was unrecognised; `cancelled` means the CALLER went away, which is not the advisor's
63
- * failure and must not read as one.
64
- */
65
- outcome: "answered" | "disabled" | "timeout" | "error" | "declined" | "cancelled";
66
- }
67
- export interface AdviceAttribution {
68
- resolvedModel: {
69
- provider: string;
70
- modelId: string;
71
- } | null;
72
- modelSource: AdviceRecord["modelSource"];
73
- thinkingLevel: string | null;
74
- thinkingSource: AdviceRecord["thinkingSource"];
75
- }
76
- export interface Advisor {
77
- task(task: string): string | TaskDigest;
78
- ask(purpose: string, request: AdviceRequest, signal?: AbortSignal, executionId?: string, attribution?: AdviceAttribution | ((advice: Advice | null) => AdviceAttribution)): Promise<Advice | null>;
79
- }
80
- export declare function createAdvisor(input: {
81
- decider: Decider;
82
- /** Where the record goes. Injected so this layer does no I/O and governance does not import it. */
83
- record: (entry: AdviceRecord) => void | Promise<void>;
84
- timeoutMs?: number;
85
- /** Absent or false means the null decider is used whatever `decider` says. */
86
- enabled?: boolean;
87
- episodeId?: string;
88
- taskEgress?: TaskEgressMode;
89
- }): Advisor;
90
- //# sourceMappingURL=advisor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"advisor.d.ts","sourceRoot":"","sources":["../../src/advisors/advisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEnE,mHAAmH;AACnH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC1D;AAED,MAAM,WAAW,YAAY;IAC3B,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uGAAuG;IACvG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qGAAqG;IACrG,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,OA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UAAU,CAAC;IACxC,GAAG,CACD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,iBAAiB,CAAC,GAC/E,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,mGAAmG;IACnG,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,GAAG,OAAO,CAiGV"}
@@ -1,154 +0,0 @@
1
- /** Two seconds. An advisor is on the path of a decision a human is waiting for; it is not worth more than that. */
2
- export const DEFAULT_ADVICE_TIMEOUT_MS = 2000;
3
- export function createAdvisor(input) {
4
- const timeoutMs = input.timeoutMs ?? DEFAULT_ADVICE_TIMEOUT_MS;
5
- const taskEgress = input.taskEgress ?? "digest";
6
- return {
7
- task(task) {
8
- if (taskEgress === "raw") {
9
- warnRawTaskEgress();
10
- return task;
11
- }
12
- return digestTask(task);
13
- },
14
- async ask(purpose, request, signal, executionId, attribution) {
15
- const started = Date.now();
16
- const attributionFor = (advice) => typeof attribution === "function"
17
- ? attribution(advice)
18
- : (attribution ?? {
19
- resolvedModel: advice?.resolvedModel ?? null,
20
- modelSource: "pi",
21
- thinkingLevel: null,
22
- thinkingSource: "pi",
23
- });
24
- const base = {
25
- ...(input.episodeId ? { episodeId: input.episodeId } : {}),
26
- ...(executionId ? { executionId } : {}),
27
- taskEgress,
28
- purpose,
29
- decider: input.decider.name,
30
- questions: Object.keys(request.questions),
31
- ...attributionFor(null),
32
- tokenDetail: {
33
- inputTokens: null,
34
- outputTokens: null,
35
- cacheReadTokens: null,
36
- cacheWriteTokens: null,
37
- reasoningTokens: null,
38
- },
39
- };
40
- const write = async (entry) => {
41
- try {
42
- await input.record(entry);
43
- }
44
- catch {
45
- // Recording is an observation of a decision that has already been taken. Failing to write it must not
46
- // change what the caller does, for `execute-child`'s reason: an audit failure that discards the work is
47
- // worse than one that is merely missing.
48
- }
49
- };
50
- if (input.enabled !== true) {
51
- await write({ ...base, decider: "none", answered: false, durationMs: 0, outcome: "disabled" });
52
- return null;
53
- }
54
- const timer = new AbortController();
55
- const cancel = setTimeout(() => timer.abort(), timeoutMs);
56
- const linked = signal ? AbortSignal.any([signal, timer.signal]) : timer.signal;
57
- try {
58
- // RACED, not merely signalled. A decider that ignores its signal would otherwise run as long as it liked
59
- // and then be recorded as a timeout — measured at fifty times the configured bound. The `Decider` contract
60
- // cannot make an implementation honour an abort, so the bound is enforced on this side of it.
61
- const advice = await Promise.race([
62
- input.decider.decide(request, linked),
63
- new Promise((settle) => linked.addEventListener("abort", () => settle(null), { once: true })),
64
- ]);
65
- const durationMs = Date.now() - started;
66
- if (!advice) {
67
- await write({ ...base, answered: false, durationMs, outcome: outcomeFor(timer.signal, signal, "declined") });
68
- return null;
69
- }
70
- await write({
71
- ...base,
72
- answered: true,
73
- durationMs,
74
- outcome: "answered",
75
- answers: Object.fromEntries(Object.entries(advice.answers).map(([key, answer]) => [
76
- key,
77
- { value: answer.value, ...(answer.confidence === undefined ? {} : { confidence: answer.confidence }) },
78
- ])),
79
- ...(advice.model ? { model: advice.model } : {}),
80
- ...attributionFor(advice),
81
- ...(advice.tokenDetail ? { tokenDetail: advice.tokenDetail } : {}),
82
- });
83
- return advice;
84
- }
85
- catch {
86
- // Including an abort. A caller asked for advice and is getting none; it proceeds exactly as it would have.
87
- await write({
88
- ...base,
89
- answered: false,
90
- durationMs: Date.now() - started,
91
- outcome: outcomeFor(timer.signal, signal, "error"),
92
- });
93
- return null;
94
- }
95
- finally {
96
- clearTimeout(cancel);
97
- }
98
- },
99
- };
100
- }
101
- let rawTaskEgressWarned = false;
102
- function warnRawTaskEgress() {
103
- if (rawTaskEgressWarned)
104
- return;
105
- rawTaskEgressWarned = true;
106
- console.warn("pi-daddy: raw advisor task egress is enabled");
107
- }
108
- function digestTask(task) {
109
- const files = [...task.matchAll(/\b(?:[\w.-]+\/)*[\w-]+\.[A-Za-z0-9]{1,10}\b/g)].map((match) => match[0]);
110
- const extensions = [
111
- ...new Set(files.map((file) => `.${file.slice(file.lastIndexOf(".") + 1).toLowerCase()}`)),
112
- ].sort();
113
- const languages = new Set(extensions.map(languageForExtension).filter((language) => language !== "unknown"));
114
- return {
115
- length: task.length,
116
- language: languages.size === 0 ? "unknown" : languages.size === 1 ? [...languages][0] : "mixed",
117
- referencedFiles: { count: files.length, extensions },
118
- };
119
- }
120
- function languageForExtension(extension) {
121
- const languages = {
122
- ".c": "c",
123
- ".cpp": "cpp",
124
- ".css": "css",
125
- ".go": "go",
126
- ".html": "html",
127
- ".java": "java",
128
- ".js": "javascript",
129
- ".jsx": "javascript",
130
- ".json": "json",
131
- ".md": "markdown",
132
- ".php": "php",
133
- ".py": "python",
134
- ".rb": "ruby",
135
- ".rs": "rust",
136
- ".sh": "shell",
137
- ".sql": "sql",
138
- ".swift": "swift",
139
- ".ts": "typescript",
140
- ".tsx": "typescript",
141
- ".yaml": "yaml",
142
- ".yml": "yaml",
143
- };
144
- return languages[extension] ?? "unknown";
145
- }
146
- /** The bound fired, the caller went away, or neither — three different facts a reviewer needs to tell apart. */
147
- function outcomeFor(timer, caller, otherwise) {
148
- if (timer.aborted && !caller?.aborted)
149
- return "timeout";
150
- if (caller?.aborted)
151
- return "cancelled";
152
- return otherwise;
153
- }
154
- //# sourceMappingURL=advisor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"advisor.js","source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OAAO,SAAS,CAAC;IACxD,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO,WAAW,CAAC;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,88 +0,0 @@
1
- /**
2
- * An advisor is a thing that answers a typed question. It is never a thing that decides (ADR-0077).
3
- *
4
- * The boundary is the whole design, and it is structural rather than remembered: **no type in this layer names a
5
- * `Capability` or a refusal code**, and no function in `kernel/` or `governance/` accepts an advisor's result. An
6
- * advisor may select among options the caller already had, rank them, annotate them, or propose one. It can never
7
- * widen an `effective` set, satisfy a gate, or stand in for a human's answer — not because it is asked not to, but
8
- * because nothing on those paths can receive what it returns. `test/advisors.test.ts` forces that.
9
- *
10
- * Non-generative on purpose. The first advisor is a classifier that returns a typed answer with a probability, not
11
- * prose, which is what makes an advisor auditable: "it chose `b` at 0.91" is a fact a reviewer can disagree with,
12
- * where a paragraph of reasoning is not.
13
- *
14
- * Degradation is "no advice", never a guess. Every path that cannot produce an answer — disabled, missing key,
15
- * timeout, transport error, a response shape we do not recognise — returns `null`, and the caller does what it
16
- * would have done without an advisor at all. That is why a caller must be written to work with `nullDecider`
17
- * first, and why `nullDecider` is the default.
18
- */
19
- /** A question, in the three shapes the first advisor understands. */
20
- export type Question = {
21
- kind: "noul";
22
- instructions: string;
23
- whenTrue: string;
24
- whenFalse: string;
25
- } | {
26
- kind: "choice";
27
- instructions: string;
28
- options: Readonly<Record<string, string>>;
29
- } | {
30
- kind: "score";
31
- instructions: string;
32
- levels: readonly string[];
33
- };
34
- /** One typed answer. `confidence` is absent when the transport did not report one; it is never invented. */
35
- export type Answer = {
36
- kind: "noul";
37
- value: boolean;
38
- confidence?: number;
39
- } | {
40
- kind: "choice";
41
- value: string;
42
- confidence?: number;
43
- } | {
44
- kind: "score";
45
- value: number;
46
- level: string;
47
- confidence?: number;
48
- };
49
- export interface AdviceRequest {
50
- /**
51
- * What the advisor is told about the situation, composed by the caller.
52
- *
53
- * **Sent, never recorded.** The task is never STORED (ADR-0021) and that still holds — `createAdvisor` writes the
54
- * question keys and the answers and never this object. Raw task text crosses only when the independent egress
55
- * switch permits it; otherwise callers send a structural digest. Neither representation is copied into the record.
56
- */
57
- state: Readonly<Record<string, unknown>>;
58
- questions: Readonly<Record<string, Question>>;
59
- }
60
- export interface Advice {
61
- answers: Readonly<Record<string, Answer>>;
62
- /** What actually answered, as the transport reported it — a dated model id, not the one we asked for. */
63
- model?: string;
64
- resolvedModel?: {
65
- provider: string;
66
- modelId: string;
67
- };
68
- tokenDetail?: {
69
- inputTokens: number | null;
70
- outputTokens: number | null;
71
- cacheReadTokens: number | null;
72
- cacheWriteTokens: number | null;
73
- reasoningTokens: number | null;
74
- };
75
- }
76
- export interface Decider {
77
- /** Recorded in the ledger so a reviewer can tell which advisor a decision was taken beside. */
78
- readonly name: string;
79
- decide(request: AdviceRequest, signal?: AbortSignal): Promise<Advice | null>;
80
- }
81
- /**
82
- * The default, and the one every caller must work correctly with.
83
- *
84
- * Not a placeholder: it is how advisors stay optional. A caller that behaves differently under `nullDecider` than
85
- * under no advisor at all has made advice load-bearing, which is the one thing ADR-0077 forbids.
86
- */
87
- export declare const nullDecider: Decider;
88
- //# sourceMappingURL=decider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decider.d.ts","sourceRoot":"","sources":["../../src/advisors/decider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,qEAAqE;AACrE,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,GACnF;IAAE,IAAI,EAAE,OAAO,CAAC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tB,+FAA+F;IAC/F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9E;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,OAGzB,CAAC"}
@@ -1,29 +0,0 @@
1
- /**
2
- * An advisor is a thing that answers a typed question. It is never a thing that decides (ADR-0077).
3
- *
4
- * The boundary is the whole design, and it is structural rather than remembered: **no type in this layer names a
5
- * `Capability` or a refusal code**, and no function in `kernel/` or `governance/` accepts an advisor's result. An
6
- * advisor may select among options the caller already had, rank them, annotate them, or propose one. It can never
7
- * widen an `effective` set, satisfy a gate, or stand in for a human's answer — not because it is asked not to, but
8
- * because nothing on those paths can receive what it returns. `test/advisors.test.ts` forces that.
9
- *
10
- * Non-generative on purpose. The first advisor is a classifier that returns a typed answer with a probability, not
11
- * prose, which is what makes an advisor auditable: "it chose `b` at 0.91" is a fact a reviewer can disagree with,
12
- * where a paragraph of reasoning is not.
13
- *
14
- * Degradation is "no advice", never a guess. Every path that cannot produce an answer — disabled, missing key,
15
- * timeout, transport error, a response shape we do not recognise — returns `null`, and the caller does what it
16
- * would have done without an advisor at all. That is why a caller must be written to work with `nullDecider`
17
- * first, and why `nullDecider` is the default.
18
- */
19
- /**
20
- * The default, and the one every caller must work correctly with.
21
- *
22
- * Not a placeholder: it is how advisors stay optional. A caller that behaves differently under `nullDecider` than
23
- * under no advisor at all has made advice load-bearing, which is the one thing ADR-0077 forbids.
24
- */
25
- export const nullDecider = {
26
- name: "none",
27
- decide: async () => null,
28
- };
29
- //# sourceMappingURL=decider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decider.js","sourceRoot":"","sources":["../../src/advisors/decider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA+CH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAY;IAClC,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;CACzB,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * Jev, through OpenRouter's Decisions endpoint — the first advisor adapter (ADR-0077).
3
- *
4
- * **What is verified and what is not.** The REQUEST shape below is taken from OpenRouter's own SDK reference for
5
- * `POST /api/alpha/decisions`: `{model, state, questions}`, where each question is `noul` with `criteria.true` and
6
- * `criteria.false`, `choice` with a `criteria` map of option to description, or `score` with a `criteria` array of
7
- * level descriptions. That much is documented. The RESPONSE is described there only as an `answers` object beside
8
- * `id`, `model`, `provider` and `usage`, with probabilities and confidence mentioned but never shown, and the one
9
- * public guide to this endpoint says plainly that it has not run paid calls either. **So no shape below has been
10
- * confirmed against a live response.** The parser therefore accepts what the documentation describes, tolerates the
11
- * obvious variants, and returns `null` for anything else rather than guessing — which is the same thing it does when
12
- * the endpoint is down. A live check is the `PI_DADDY_IT_JEV=1` tier, and until somebody runs it this adapter's
13
- * response handling is a reading of documentation, not a measurement.
14
- *
15
- * Nothing here can widen anything: it returns `Advice`, and no kernel or governance function accepts one.
16
- */
17
- import type { Advice, AdviceRequest, Answer, Decider, Question } from "./decider.ts";
18
- export declare const JEV_ENDPOINT = "https://openrouter.ai/api/alpha/decisions";
19
- export declare const JEV_MODEL = "typesafe/jev-1.13";
20
- /** The wire form of one question, exactly as OpenRouter's reference documents it. */
21
- export declare function wireQuestion(question: Question): Record<string, unknown>;
22
- export declare function wireRequest(request: AdviceRequest, model: string): Record<string, unknown>;
23
- /**
24
- * Read one answer out of a response, or nothing.
25
- *
26
- * Deliberately generous about WHERE the value and the probability sit, because the documentation names the fields
27
- * without showing them, and strict about WHAT they are: a `choice` answer must be one of the options that were
28
- * asked about, and a `score` must be an index into the levels. An answer outside the question's own vocabulary is
29
- * not a low-confidence answer, it is a response we did not understand, and the honest reading of that is no advice.
30
- */
31
- export declare function parseAnswer(question: Question, raw: unknown): Answer | undefined;
32
- export declare function parseAdvice(request: AdviceRequest, body: unknown): Advice | null;
33
- export interface JevConfig {
34
- apiKey: string;
35
- model?: string;
36
- endpoint?: string;
37
- /** Injected so the adapter is testable without a network, and so nothing here reaches for a global. */
38
- fetch?: typeof globalThis.fetch;
39
- }
40
- export declare function jevDecider(config: JevConfig): Decider;
41
- //# sourceMappingURL=jev.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jev.d.ts","sourceRoot":"","sources":["../../src/advisors/jev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAErF,eAAO,MAAM,YAAY,8CAA8C,CAAC;AACxE,eAAO,MAAM,SAAS,sBAAsB,CAAC;AAE7C,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUxE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1F;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CA8BhF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAsBhF;AA2BD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uGAAuG;IACvG,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAuBrD"}
@@ -1,139 +0,0 @@
1
- export const JEV_ENDPOINT = "https://openrouter.ai/api/alpha/decisions";
2
- export const JEV_MODEL = "typesafe/jev-1.13";
3
- /** The wire form of one question, exactly as OpenRouter's reference documents it. */
4
- export function wireQuestion(question) {
5
- if (question.kind === "noul")
6
- return {
7
- type: "noul",
8
- instructions: question.instructions,
9
- criteria: { true: question.whenTrue, false: question.whenFalse },
10
- };
11
- if (question.kind === "choice")
12
- return { type: "choice", instructions: question.instructions, criteria: { ...question.options } };
13
- return { type: "score", instructions: question.instructions, criteria: [...question.levels] };
14
- }
15
- export function wireRequest(request, model) {
16
- return {
17
- model,
18
- state: request.state,
19
- questions: Object.fromEntries(Object.entries(request.questions).map(([key, q]) => [key, wireQuestion(q)])),
20
- };
21
- }
22
- /**
23
- * Read one answer out of a response, or nothing.
24
- *
25
- * Deliberately generous about WHERE the value and the probability sit, because the documentation names the fields
26
- * without showing them, and strict about WHAT they are: a `choice` answer must be one of the options that were
27
- * asked about, and a `score` must be an index into the levels. An answer outside the question's own vocabulary is
28
- * not a low-confidence answer, it is a response we did not understand, and the honest reading of that is no advice.
29
- */
30
- export function parseAnswer(question, raw) {
31
- if (raw === null || raw === undefined)
32
- return undefined;
33
- const object = typeof raw === "object" && !Array.isArray(raw) ? raw : undefined;
34
- const value = object ? (object.value ?? object.answer ?? object.choice ?? object.result) : raw;
35
- const confidenceRaw = object ? (object.confidence ?? object.probability ?? object.p) : undefined;
36
- const confidence = typeof confidenceRaw === "number" && Number.isFinite(confidenceRaw) ? confidenceRaw : undefined;
37
- const withConfidence = (answer) => (confidence === undefined ? answer : { ...answer, confidence });
38
- if (question.kind === "noul") {
39
- if (typeof value !== "boolean")
40
- return undefined;
41
- return withConfidence({ kind: "noul", value });
42
- }
43
- if (question.kind === "choice") {
44
- if (typeof value !== "string" || !Object.hasOwn(question.options, value))
45
- return undefined;
46
- return withConfidence({ kind: "choice", value });
47
- }
48
- // ONE reading: a score is a 0-based index into the `criteria` array that was asked about, and `level` carries the
49
- // string so a caller never indexes the number itself.
50
- //
51
- // The first draft accepted both a 0-based and a 1-based reading "because the documentation shows neither", which
52
- // pushed the ambiguity onto the caller and into the ledger: with three levels, 1 and 2 were valid under both, so
53
- // `levels[value]` could read "high" where the model meant "mid". An advisor exists to remove that guess, not to
54
- // relocate it. **The 0-based reading is an assumption** — it indexes the documented array form — and it is
55
- // unverified for the same reason everything else about the response is: no live call has been made. If Jev is
56
- // 1-based, its top level falls outside the array and the whole answer is refused as unrecognised, which is the
57
- // loud failure rather than a silently shifted one, and the `PI_DADDY_IT_JEV=1` tier is what would show it.
58
- if (typeof value !== "number" || !Number.isInteger(value))
59
- return undefined;
60
- if (value < 0 || value >= question.levels.length)
61
- return undefined;
62
- return withConfidence({ kind: "score", value, level: question.levels[value] });
63
- }
64
- export function parseAdvice(request, body) {
65
- if (typeof body !== "object" || body === null)
66
- return null;
67
- const envelope = body;
68
- const raw = envelope.answers;
69
- if (typeof raw !== "object" || raw === null)
70
- return null;
71
- const answers = {};
72
- for (const [key, question] of Object.entries(request.questions)) {
73
- const parsed = parseAnswer(question, raw[key]);
74
- // Every question or none: a caller that asked two questions and silently received one would have to guess which
75
- // of its branches the missing answer belonged to, and guessing is what an advisor exists to remove.
76
- if (!parsed)
77
- return null;
78
- answers[key] = parsed;
79
- }
80
- const model = typeof envelope.model === "string" ? envelope.model : undefined;
81
- const provider = typeof envelope.provider === "string" ? envelope.provider : undefined;
82
- const tokenDetail = parseTokenDetail(envelope.usage);
83
- return {
84
- answers,
85
- ...(model ? { model } : {}),
86
- ...(model && provider ? { resolvedModel: { provider, modelId: model } } : {}),
87
- ...(tokenDetail ? { tokenDetail } : {}),
88
- };
89
- }
90
- function parseTokenDetail(value) {
91
- if (typeof value !== "object" || value === null || Array.isArray(value))
92
- return undefined;
93
- const usage = value;
94
- const details = object(usage.input_tokens_details ?? usage.prompt_tokens_details);
95
- const outputDetails = object(usage.output_tokens_details ?? usage.completion_tokens_details);
96
- const read = (...keys) => {
97
- const reported = keys.map((key) => usage[key]).find((entry) => typeof entry === "number" && Number.isFinite(entry));
98
- return typeof reported === "number" && reported > 0 ? reported : null;
99
- };
100
- const nested = (source, key) => {
101
- const reported = source?.[key];
102
- return typeof reported === "number" && Number.isFinite(reported) && reported > 0 ? reported : null;
103
- };
104
- return {
105
- inputTokens: read("input_tokens", "prompt_tokens"),
106
- outputTokens: read("output_tokens", "completion_tokens"),
107
- cacheReadTokens: read("cache_read_tokens") ?? nested(details, "cached_tokens"),
108
- cacheWriteTokens: read("cache_write_tokens"),
109
- reasoningTokens: read("reasoning_tokens") ?? nested(outputDetails, "reasoning_tokens"),
110
- };
111
- }
112
- const object = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
113
- export function jevDecider(config) {
114
- return {
115
- name: "jev",
116
- async decide(request, signal) {
117
- const send = config.fetch ?? globalThis.fetch;
118
- const response = await send(config.endpoint ?? JEV_ENDPOINT, {
119
- method: "POST",
120
- headers: { "content-type": "application/json", authorization: `Bearer ${config.apiKey}` },
121
- body: JSON.stringify(wireRequest(request, config.model ?? JEV_MODEL)),
122
- ...(signal ? { signal } : {}),
123
- });
124
- // A dead endpoint and an advisor with nothing to say must not read alike in the ledger: the whole reason for
125
- // recording the nothing-cases is that an advisor which quietly stopped answering should not look like one
126
- // nobody called. Thrown, so `createAdvisor` records `error` rather than `declined`; it catches, so nothing
127
- // reaches the caller but `null` either way.
128
- if (!response.ok)
129
- throw new Error(`advisor endpoint returned ${response.status}`);
130
- try {
131
- return parseAdvice(request, await response.json());
132
- }
133
- catch {
134
- return null;
135
- }
136
- },
137
- };
138
- }
139
- //# sourceMappingURL=jev.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jev.js","sourceRoot":"","sources":["../../src/advisors/jev.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,YAAY,GAAG,2CAA2C,CAAC;AACxE,MAAM,CAAC,MAAM,SAAS,GAAG,mBAAmB,CAAC;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YAC1B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;YAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,YAAY,EAAE;gBAC3D,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,UAAU,MAAM,CAAC,MAAM,EAAE,EAAE;gBACzF,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC;gBACrE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9B,CAAC,CAAC;YACH,6GAA6G;YAC7G,0GAA0G;YAC1G,2GAA2G;YAC3G,4CAA4C;YAC5C,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAClF,IAAI,CAAC;gBACH,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,49 +0,0 @@
1
- /**
2
- * Whether an advisor is on, and which one (ADR-0077).
3
- *
4
- * **Default off, and only the environment can turn it on.** An advisor sends a description of the caller's
5
- * situation to a third party, so enabling one is `PI_DADDY_ADVISOR=jev` plus a key — both outside the workspace,
6
- * both stripped from every child.
7
- *
8
- * 0.34.0 read the enable from `.pi/pi-daddy/settings.json` and that was wrong for the reason `grant-store.ts`
9
- * states about the same file: it is writable by any child holding `tool:write`, so it is "the reviewable record of
10
- * the decision, not the thing the enforcer reads". A grant lives outside the workspace precisely so a child cannot
11
- * widen the next session's ceiling; an advisor switch a child could flip would make the operator's next session
12
- * ship its own description to a third party, which is the same self-defeating shape. The settings block may still
13
- * NARROW — a shorter timeout, or `enabled: false` to turn an advisor off for one project — and can never turn one
14
- * on, choose its model, or lengthen its bound. A model is a destination rather than a narrowing, so `model` in the
15
- * block is refused with a message naming `PI_DADDY_ADVISOR_MODEL`, and a timeout is clamped to the default rather
16
- * than trusted. Malformed configuration disables the advisor and says so: a typo must not be a way to enable anything.
17
- *
18
- * **Not a dashboard toggle**, which is what the programme originally sketched. The dashboard is a read-only
19
- * renderer in a separate process that "never affects enforcement" (ADR-0036), and a control there that wrote to
20
- * settings would be the first thing it ever wrote. Turning an advisor on is an operator decision that belongs in
21
- * the reviewable file; `/grants` reports what is in force. That is a deliberate departure from the roadmap line.
22
- *
23
- * The key is never in the settings file either, because that file is committed and an API key must not be.
24
- */
25
- export { ENV_ADVISOR_KEY as ADVISOR_KEY_ENV } from "../kernel/env-names.ts";
26
- import { type TaskEgressMode } from "./advisor.ts";
27
- export { ENV_ADVISOR_MODEL, ENV_ADVISOR_TASK_EGRESS } from "../kernel/env-names.ts";
28
- export { ENV_ADVISOR } from "../kernel/env-names.ts";
29
- export interface AdvisorSettings {
30
- enabled: boolean;
31
- /** The only decider this release knows besides the null one. */
32
- decider: "none" | "jev";
33
- /** Overrides the adapter's pinned model id; absent means the adapter's own default. */
34
- model?: string;
35
- timeoutMs?: number;
36
- taskEgress: TaskEgressMode;
37
- /** Why an advisor is off when the settings asked for one on — reported, never silently applied. */
38
- refusal?: string;
39
- }
40
- export declare const ADVISOR_OFF: AdvisorSettings;
41
- /**
42
- * Read the `advisor` block of a project settings file. Absent is off; malformed is off WITH a reason.
43
- *
44
- * The reason matters more than it looks: an operator who wrote `"enabeld": true` and got silence would conclude the
45
- * feature does not work, and an operator who wrote it and got an advisor anyway would have a third party reading
46
- * their session without having successfully asked for it. Both are worse than a sentence naming the field.
47
- */
48
- export declare function advisorSettingsFrom(raw: unknown, env?: NodeJS.ProcessEnv): AdvisorSettings;
49
- //# sourceMappingURL=settings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/advisors/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,eAAe,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,cAAc,CAAC;IAC3B,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,WAAW,EAAE,eAA0F,CAAC;AAErH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,eAAe,CA6DvG"}