@caupulican/pi-adaptative 0.81.41 → 0.81.43

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 (1480) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/bun/cli.d.ts.map +1 -1
  3. package/dist/bun/cli.js.map +1 -1
  4. package/dist/bun/register-bedrock.d.ts.map +1 -1
  5. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  6. package/dist/bun/restore-sandbox-env.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +52 -49
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +62 -57
  13. package/dist/bundled-resources/prompts/skillify.md +1 -1
  14. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +16 -19
  15. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +12 -26
  16. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +15 -121
  17. package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +57 -80
  18. package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +3 -3
  19. package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +8 -0
  20. package/dist/bundled-resources/runtimes/pi-shell-engine/escapes.py +70 -0
  21. package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +135 -63
  22. package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +3 -0
  23. package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +108 -22
  24. package/dist/bundled-resources/runtimes/pi-shell-engine/paths.py +10 -0
  25. package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +12 -4
  26. package/dist/bundled-resources/runtimes/pi-shell-engine/shell_args.py +22 -0
  27. package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +10 -2
  28. package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +131 -259
  29. package/dist/bundled-resources/skills/authorized-web-security-audit/SKILL.md +187 -0
  30. package/dist/bundled-resources/skills/authorized-web-security-audit/references/assessment-contract.md +92 -0
  31. package/dist/bundled-resources/skills/deduplicate-by-evidence/SKILL.md +134 -0
  32. package/dist/bundled-resources/skills/evidence-gated-tdd/SKILL.md +93 -0
  33. package/dist/bundled-resources/skills/evidence-gated-tdd/references/evidence-model.md +27 -0
  34. package/dist/bundled-resources/skills/evidence-gated-tdd/references/security-scanners.md +24 -0
  35. package/dist/bundled-resources/skills/harness-self-adaptation/SKILL.md +4 -2
  36. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/SKILL.md +217 -0
  37. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/defensive-exploit-catalogue.md +175 -0
  38. package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/tool-boundary-checklist.md +87 -0
  39. package/dist/bundled-resources/skills/skill-architect/SKILL.md +2 -2
  40. package/dist/bundled-resources/skills/skill-creator/SKILL.md +188 -0
  41. package/dist/bundled-resources/skills/skill-creator/references/pi-skill-contract.md +73 -0
  42. package/dist/bundled-resources/skills/skill-creator/scripts/init-skill.mjs +142 -0
  43. package/dist/bundled-resources/skills/skill-creator/scripts/validate-skill.mjs +122 -0
  44. package/dist/cli/args.d.ts.map +1 -1
  45. package/dist/cli/args.js.map +1 -1
  46. package/dist/cli/config-selector.d.ts.map +1 -1
  47. package/dist/cli/config-selector.js.map +1 -1
  48. package/dist/cli/file-processor.d.ts.map +1 -1
  49. package/dist/cli/file-processor.js +8 -8
  50. package/dist/cli/file-processor.js.map +1 -1
  51. package/dist/cli/initial-message.d.ts +1 -1
  52. package/dist/cli/initial-message.d.ts.map +1 -1
  53. package/dist/cli/initial-message.js.map +1 -1
  54. package/dist/cli/list-models.d.ts.map +1 -1
  55. package/dist/cli/list-models.js.map +1 -1
  56. package/dist/cli/piped-stdin.d.ts +4 -0
  57. package/dist/cli/piped-stdin.d.ts.map +1 -0
  58. package/dist/cli/piped-stdin.js +13 -0
  59. package/dist/cli/piped-stdin.js.map +1 -0
  60. package/dist/cli/session-picker.d.ts.map +1 -1
  61. package/dist/cli/session-picker.js.map +1 -1
  62. package/dist/cli.d.ts.map +1 -1
  63. package/dist/cli.js.map +1 -1
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +9 -14
  66. package/dist/config.js.map +1 -1
  67. package/dist/core/agent-directory-layout.d.ts.map +1 -1
  68. package/dist/core/agent-directory-layout.js.map +1 -1
  69. package/dist/core/agent-paths.d.ts +32 -0
  70. package/dist/core/agent-paths.d.ts.map +1 -1
  71. package/dist/core/agent-paths.js +65 -0
  72. package/dist/core/agent-paths.js.map +1 -1
  73. package/dist/core/agent-session-contracts.d.ts +24 -10
  74. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  75. package/dist/core/agent-session-contracts.js +1 -12
  76. package/dist/core/agent-session-contracts.js.map +1 -1
  77. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  78. package/dist/core/agent-session-runtime.js +10 -25
  79. package/dist/core/agent-session-runtime.js.map +1 -1
  80. package/dist/core/agent-session-services.d.ts.map +1 -1
  81. package/dist/core/agent-session-services.js.map +1 -1
  82. package/dist/core/agent-session.d.ts +24 -1
  83. package/dist/core/agent-session.d.ts.map +1 -1
  84. package/dist/core/agent-session.js +214 -246
  85. package/dist/core/agent-session.js.map +1 -1
  86. package/dist/core/auth-guidance.d.ts.map +1 -1
  87. package/dist/core/auth-guidance.js.map +1 -1
  88. package/dist/core/auth-storage.d.ts +4 -1
  89. package/dist/core/auth-storage.d.ts.map +1 -1
  90. package/dist/core/auth-storage.js +13 -39
  91. package/dist/core/auth-storage.js.map +1 -1
  92. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  93. package/dist/core/autonomy/approval-gate.js.map +1 -1
  94. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  95. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  96. package/dist/core/autonomy/contracts.d.ts +2 -0
  97. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  98. package/dist/core/autonomy/contracts.js.map +1 -1
  99. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  100. package/dist/core/autonomy/envelope-enforcement.js +4 -9
  101. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  102. package/dist/core/autonomy/evidence-finding-projection.d.ts +11 -0
  103. package/dist/core/autonomy/evidence-finding-projection.d.ts.map +1 -0
  104. package/dist/core/autonomy/evidence-finding-projection.js +37 -0
  105. package/dist/core/autonomy/evidence-finding-projection.js.map +1 -0
  106. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
  107. package/dist/core/autonomy/foreground-envelope.js.map +1 -1
  108. package/dist/core/autonomy/gates.d.ts.map +1 -1
  109. package/dist/core/autonomy/gates.js.map +1 -1
  110. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  111. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  112. package/dist/core/autonomy/lane-tool-surface.d.ts +3 -1
  113. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  114. package/dist/core/autonomy/lane-tool-surface.js +17 -4
  115. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  116. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  117. package/dist/core/autonomy/lane-tracker.js +2 -3
  118. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  119. package/dist/core/autonomy/path-scope.d.ts +14 -0
  120. package/dist/core/autonomy/path-scope.d.ts.map +1 -1
  121. package/dist/core/autonomy/path-scope.js +37 -6
  122. package/dist/core/autonomy/path-scope.js.map +1 -1
  123. package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
  124. package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
  125. package/dist/core/autonomy/session-lane-record.js.map +1 -1
  126. package/dist/core/autonomy/status.d.ts.map +1 -1
  127. package/dist/core/autonomy/status.js.map +1 -1
  128. package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
  129. package/dist/core/autonomy/subagent-prompt.js.map +1 -1
  130. package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
  131. package/dist/core/autonomy/telemetry-events.js.map +1 -1
  132. package/dist/core/autonomy-telemetry.d.ts.map +1 -1
  133. package/dist/core/autonomy-telemetry.js +2 -4
  134. package/dist/core/autonomy-telemetry.js.map +1 -1
  135. package/dist/core/background-lane-controller.d.ts +27 -1
  136. package/dist/core/background-lane-controller.d.ts.map +1 -1
  137. package/dist/core/background-lane-controller.js +34 -16
  138. package/dist/core/background-lane-controller.js.map +1 -1
  139. package/dist/core/background-tool-task-controller.d.ts +88 -0
  140. package/dist/core/background-tool-task-controller.d.ts.map +1 -0
  141. package/dist/core/background-tool-task-controller.js +470 -0
  142. package/dist/core/background-tool-task-controller.js.map +1 -0
  143. package/dist/core/bash-execution-controller.d.ts +1 -0
  144. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  145. package/dist/core/bash-execution-controller.js +5 -4
  146. package/dist/core/bash-execution-controller.js.map +1 -1
  147. package/dist/core/bash-executor.d.ts.map +1 -1
  148. package/dist/core/bash-executor.js.map +1 -1
  149. package/dist/core/bedrock-sso-login.d.ts.map +1 -1
  150. package/dist/core/bedrock-sso-login.js.map +1 -1
  151. package/dist/core/billing-failover-controller.d.ts.map +1 -1
  152. package/dist/core/billing-failover-controller.js +3 -3
  153. package/dist/core/billing-failover-controller.js.map +1 -1
  154. package/dist/core/billing-failover.d.ts.map +1 -1
  155. package/dist/core/billing-failover.js.map +1 -1
  156. package/dist/core/capability-contract.d.ts.map +1 -1
  157. package/dist/core/catalog-manager.d.ts.map +1 -1
  158. package/dist/core/catalog-manager.js +0 -0
  159. package/dist/core/catalog-manager.js.map +1 -1
  160. package/dist/core/compaction-controller.d.ts +2 -0
  161. package/dist/core/compaction-controller.d.ts.map +1 -1
  162. package/dist/core/compaction-controller.js +21 -8
  163. package/dist/core/compaction-controller.js.map +1 -1
  164. package/dist/core/compaction-support.d.ts +8 -0
  165. package/dist/core/compaction-support.d.ts.map +1 -1
  166. package/dist/core/compaction-support.js +0 -2
  167. package/dist/core/compaction-support.js.map +1 -1
  168. package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
  169. package/dist/core/context/artifact-retrieval.js.map +1 -1
  170. package/dist/core/context/brain-curator.d.ts.map +1 -1
  171. package/dist/core/context/brain-curator.js +14 -33
  172. package/dist/core/context/brain-curator.js.map +1 -1
  173. package/dist/core/context/context-artifacts.d.ts.map +1 -1
  174. package/dist/core/context/context-artifacts.js +16 -24
  175. package/dist/core/context/context-artifacts.js.map +1 -1
  176. package/dist/core/context/context-audit.d.ts.map +1 -1
  177. package/dist/core/context/context-audit.js +3 -17
  178. package/dist/core/context/context-audit.js.map +1 -1
  179. package/dist/core/context/context-composition.d.ts.map +1 -1
  180. package/dist/core/context/context-composition.js.map +1 -1
  181. package/dist/core/context/context-item.d.ts.map +1 -1
  182. package/dist/core/context/context-item.js.map +1 -1
  183. package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -1
  184. package/dist/core/context/context-prompt-enforcement.js +3 -16
  185. package/dist/core/context/context-prompt-enforcement.js.map +1 -1
  186. package/dist/core/context/context-prompt-policy.d.ts.map +1 -1
  187. package/dist/core/context/context-prompt-policy.js.map +1 -1
  188. package/dist/core/context/context-retention.d.ts.map +1 -1
  189. package/dist/core/context/context-retention.js.map +1 -1
  190. package/dist/core/context/context-store-retention.d.ts.map +1 -1
  191. package/dist/core/context/context-store-retention.js.map +1 -1
  192. package/dist/core/context/context-store.d.ts.map +1 -1
  193. package/dist/core/context/context-store.js.map +1 -1
  194. package/dist/core/context/context-tool-result.d.ts +4 -0
  195. package/dist/core/context/context-tool-result.d.ts.map +1 -0
  196. package/dist/core/context/context-tool-result.js +15 -0
  197. package/dist/core/context/context-tool-result.js.map +1 -0
  198. package/dist/core/context/current-work-memory.d.ts.map +1 -1
  199. package/dist/core/context/current-work-memory.js.map +1 -1
  200. package/dist/core/context/file-store-memory-provider.d.ts.map +1 -1
  201. package/dist/core/context/file-store-memory-provider.js +7 -28
  202. package/dist/core/context/file-store-memory-provider.js.map +1 -1
  203. package/dist/core/context/local-memory-search.d.ts +11 -0
  204. package/dist/core/context/local-memory-search.d.ts.map +1 -0
  205. package/dist/core/context/local-memory-search.js +37 -0
  206. package/dist/core/context/local-memory-search.js.map +1 -0
  207. package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
  208. package/dist/core/context/long-term-memory-trigger.js.map +1 -1
  209. package/dist/core/context/memory-diagnostics.d.ts.map +1 -1
  210. package/dist/core/context/memory-diagnostics.js.map +1 -1
  211. package/dist/core/context/memory-index-store.d.ts.map +1 -1
  212. package/dist/core/context/memory-index-store.js.map +1 -1
  213. package/dist/core/context/memory-prompt-block.d.ts.map +1 -1
  214. package/dist/core/context/memory-prompt-block.js.map +1 -1
  215. package/dist/core/context/memory-prompt-budget.d.ts.map +1 -1
  216. package/dist/core/context/memory-prompt-budget.js.map +1 -1
  217. package/dist/core/context/memory-provider-contract.d.ts.map +1 -1
  218. package/dist/core/context/memory-provider-contract.js.map +1 -1
  219. package/dist/core/context/memory-retrieval.d.ts.map +1 -1
  220. package/dist/core/context/memory-retrieval.js.map +1 -1
  221. package/dist/core/context/memory-tier-composer.d.ts.map +1 -1
  222. package/dist/core/context/memory-tier-composer.js.map +1 -1
  223. package/dist/core/context/message-text.d.ts +7 -0
  224. package/dist/core/context/message-text.d.ts.map +1 -0
  225. package/dist/core/context/message-text.js +68 -0
  226. package/dist/core/context/message-text.js.map +1 -0
  227. package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
  228. package/dist/core/context/okf-memory-provider.js +4 -30
  229. package/dist/core/context/okf-memory-provider.js.map +1 -1
  230. package/dist/core/context/okf-memory.d.ts.map +1 -1
  231. package/dist/core/context/okf-memory.js.map +1 -1
  232. package/dist/core/context/policy-engine.d.ts.map +1 -1
  233. package/dist/core/context/policy-engine.js.map +1 -1
  234. package/dist/core/context/policy-types.d.ts.map +1 -1
  235. package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
  236. package/dist/core/context/sqlite-runtime-index.js.map +1 -1
  237. package/dist/core/context/storage-authority.d.ts.map +1 -1
  238. package/dist/core/context/tool-output-packer.d.ts.map +1 -1
  239. package/dist/core/context/tool-output-packer.js.map +1 -1
  240. package/dist/core/context-gc.d.ts.map +1 -1
  241. package/dist/core/context-gc.js +14 -21
  242. package/dist/core/context-gc.js.map +1 -1
  243. package/dist/core/context-pipeline.d.ts +1 -3
  244. package/dist/core/context-pipeline.d.ts.map +1 -1
  245. package/dist/core/context-pipeline.js +64 -145
  246. package/dist/core/context-pipeline.js.map +1 -1
  247. package/dist/core/cost/cost-summary.d.ts.map +1 -1
  248. package/dist/core/cost/cost-summary.js.map +1 -1
  249. package/dist/core/cost/daily-usage.d.ts.map +1 -1
  250. package/dist/core/cost/daily-usage.js.map +1 -1
  251. package/dist/core/cost/session-usage.d.ts.map +1 -1
  252. package/dist/core/cost/session-usage.js.map +1 -1
  253. package/dist/core/cost-guard.d.ts.map +1 -1
  254. package/dist/core/cost-guard.js.map +1 -1
  255. package/dist/core/default-tool-surface.d.ts.map +1 -1
  256. package/dist/core/default-tool-surface.js +1 -0
  257. package/dist/core/default-tool-surface.js.map +1 -1
  258. package/dist/core/defaults.d.ts.map +1 -1
  259. package/dist/core/delegation/managed-lane-controller.d.ts +11 -1
  260. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
  261. package/dist/core/delegation/managed-lane-controller.js +85 -46
  262. package/dist/core/delegation/managed-lane-controller.js.map +1 -1
  263. package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
  264. package/dist/core/delegation/session-worker-claim.js +4 -3
  265. package/dist/core/delegation/session-worker-claim.js.map +1 -1
  266. package/dist/core/delegation/worker-action-journal.d.ts +73 -0
  267. package/dist/core/delegation/worker-action-journal.d.ts.map +1 -0
  268. package/dist/core/delegation/worker-action-journal.js +293 -0
  269. package/dist/core/delegation/worker-action-journal.js.map +1 -0
  270. package/dist/core/delegation/worker-actions.d.ts +36 -1
  271. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  272. package/dist/core/delegation/worker-actions.js +171 -46
  273. package/dist/core/delegation/worker-actions.js.map +1 -1
  274. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +76 -0
  275. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -0
  276. package/dist/core/delegation/worker-agent-control-coordinator.js +216 -0
  277. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -0
  278. package/dist/core/delegation/worker-agent-control.d.ts +66 -0
  279. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -0
  280. package/dist/core/delegation/worker-agent-control.js +160 -0
  281. package/dist/core/delegation/worker-agent-control.js.map +1 -0
  282. package/dist/core/delegation/worker-attempt-executor.d.ts +80 -0
  283. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -0
  284. package/dist/core/delegation/worker-attempt-executor.js +343 -0
  285. package/dist/core/delegation/worker-attempt-executor.js.map +1 -0
  286. package/dist/core/delegation/worker-claim.d.ts +30 -0
  287. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  288. package/dist/core/delegation/worker-claim.js +205 -53
  289. package/dist/core/delegation/worker-claim.js.map +1 -1
  290. package/dist/core/delegation/worker-conversation-store.d.ts +116 -0
  291. package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -0
  292. package/dist/core/delegation/worker-conversation-store.js +440 -0
  293. package/dist/core/delegation/worker-conversation-store.js.map +1 -0
  294. package/dist/core/delegation/worker-delegation-controller.d.ts +21 -5
  295. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  296. package/dist/core/delegation/worker-delegation-controller.js +386 -260
  297. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  298. package/dist/core/delegation/worker-delegation-request.d.ts +14 -0
  299. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  300. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  301. package/dist/core/delegation/worker-dispatch-scheduler.d.ts +4 -2
  302. package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
  303. package/dist/core/delegation/worker-dispatch-scheduler.js +20 -11
  304. package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
  305. package/dist/core/delegation/worker-execution-policy.d.ts +2 -1
  306. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  307. package/dist/core/delegation/worker-execution-policy.js +5 -7
  308. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  309. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
  310. package/dist/core/delegation/worker-lane-projection.js.map +1 -1
  311. package/dist/core/delegation/worker-lifecycle.d.ts +44 -1
  312. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  313. package/dist/core/delegation/worker-lifecycle.js +119 -2
  314. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  315. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  316. package/dist/core/delegation/worker-notification-coordinator.js +4 -5
  317. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  318. package/dist/core/delegation/worker-process-owner.d.ts +18 -0
  319. package/dist/core/delegation/worker-process-owner.d.ts.map +1 -0
  320. package/dist/core/delegation/worker-process-owner.js +54 -0
  321. package/dist/core/delegation/worker-process-owner.js.map +1 -0
  322. package/dist/core/delegation/worker-profile-resolver.d.ts +5 -1
  323. package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
  324. package/dist/core/delegation/worker-profile-resolver.js +9 -2
  325. package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
  326. package/dist/core/delegation/worker-recovery-coordinator.d.ts +54 -0
  327. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -0
  328. package/dist/core/delegation/worker-recovery-coordinator.js +180 -0
  329. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -0
  330. package/dist/core/delegation/worker-resource-catalog.d.ts +32 -0
  331. package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -0
  332. package/dist/core/delegation/worker-resource-catalog.js +116 -0
  333. package/dist/core/delegation/worker-resource-catalog.js.map +1 -0
  334. package/dist/core/delegation/worker-resource-materializer.d.ts +47 -0
  335. package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -0
  336. package/dist/core/delegation/worker-resource-materializer.js +134 -0
  337. package/dist/core/delegation/worker-resource-materializer.js.map +1 -0
  338. package/dist/core/delegation/worker-runner.d.ts +5 -5
  339. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  340. package/dist/core/delegation/worker-runner.js +193 -70
  341. package/dist/core/delegation/worker-runner.js.map +1 -1
  342. package/dist/core/delegation/worker-task-label.d.ts.map +1 -1
  343. package/dist/core/delegation/worker-task-label.js.map +1 -1
  344. package/dist/core/delegation/worker-terminal-finalizer.d.ts +23 -0
  345. package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -0
  346. package/dist/core/delegation/worker-terminal-finalizer.js +12 -0
  347. package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -0
  348. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +38 -0
  349. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -0
  350. package/dist/core/delegation/worker-write-reservation-coordinator.js +104 -0
  351. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -0
  352. package/dist/core/delegation/worker-write-reservation.d.ts +90 -0
  353. package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -0
  354. package/dist/core/delegation/worker-write-reservation.js +346 -0
  355. package/dist/core/delegation/worker-write-reservation.js.map +1 -0
  356. package/dist/core/diagnostics.d.ts.map +1 -1
  357. package/dist/core/doctor.d.ts.map +1 -1
  358. package/dist/core/doctor.js.map +1 -1
  359. package/dist/core/event-bus.d.ts.map +1 -1
  360. package/dist/core/event-bus.js.map +1 -1
  361. package/dist/core/exec.d.ts.map +1 -1
  362. package/dist/core/exec.js +26 -7
  363. package/dist/core/exec.js.map +1 -1
  364. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  365. package/dist/core/export-html/ansi-to-html.js +21 -74
  366. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  367. package/dist/core/export-html/index.d.ts.map +1 -1
  368. package/dist/core/export-html/index.js +4 -0
  369. package/dist/core/export-html/index.js.map +1 -1
  370. package/dist/core/export-html/session-tree-foundations.d.mts +67 -0
  371. package/dist/core/export-html/session-tree-foundations.mjs +313 -0
  372. package/dist/core/export-html/template.css +14 -41
  373. package/dist/core/export-html/template.html +3 -1
  374. package/dist/core/export-html/template.js +26 -435
  375. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  376. package/dist/core/export-html/tool-renderer.js.map +1 -1
  377. package/dist/core/extension-import-authority.d.ts.map +1 -1
  378. package/dist/core/extension-import-authority.js.map +1 -1
  379. package/dist/core/extension-metadata.d.ts.map +1 -1
  380. package/dist/core/extension-metadata.js.map +1 -1
  381. package/dist/core/extensions/builtin.d.ts +17 -0
  382. package/dist/core/extensions/builtin.d.ts.map +1 -1
  383. package/dist/core/extensions/builtin.js +18 -54
  384. package/dist/core/extensions/builtin.js.map +1 -1
  385. package/dist/core/extensions/entry-resolution.d.ts +3 -0
  386. package/dist/core/extensions/entry-resolution.d.ts.map +1 -0
  387. package/dist/core/extensions/entry-resolution.js +17 -0
  388. package/dist/core/extensions/entry-resolution.js.map +1 -0
  389. package/dist/core/extensions/index.d.ts.map +1 -1
  390. package/dist/core/extensions/loader.d.ts.map +1 -1
  391. package/dist/core/extensions/loader.js +76 -21
  392. package/dist/core/extensions/loader.js.map +1 -1
  393. package/dist/core/extensions/runner.d.ts +2 -0
  394. package/dist/core/extensions/runner.d.ts.map +1 -1
  395. package/dist/core/extensions/runner.js +41 -112
  396. package/dist/core/extensions/runner.js.map +1 -1
  397. package/dist/core/extensions/stale-context.d.ts.map +1 -1
  398. package/dist/core/extensions/storage.d.ts.map +1 -1
  399. package/dist/core/extensions/storage.js.map +1 -1
  400. package/dist/core/extensions/types.d.ts.map +1 -1
  401. package/dist/core/extensions/types.js.map +1 -1
  402. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  403. package/dist/core/extensions/wrapper.js.map +1 -1
  404. package/dist/core/failure-corpus.d.ts.map +1 -1
  405. package/dist/core/failure-corpus.js +2 -5
  406. package/dist/core/failure-corpus.js.map +1 -1
  407. package/dist/core/footer-data-provider.d.ts.map +1 -1
  408. package/dist/core/footer-data-provider.js +27 -33
  409. package/dist/core/footer-data-provider.js.map +1 -1
  410. package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
  411. package/dist/core/foreground-recovery-controller.js +0 -4
  412. package/dist/core/foreground-recovery-controller.js.map +1 -1
  413. package/dist/core/gateways/channel-provider.d.ts.map +1 -1
  414. package/dist/core/gateways/channel-provider.js +7 -5
  415. package/dist/core/gateways/channel-provider.js.map +1 -1
  416. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  417. package/dist/core/goal-loop-controller.js +0 -1
  418. package/dist/core/goal-loop-controller.js.map +1 -1
  419. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  420. package/dist/core/goals/compact-goal-context.js +2 -4
  421. package/dist/core/goals/compact-goal-context.js.map +1 -1
  422. package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
  423. package/dist/core/goals/goal-acceptance.js.map +1 -1
  424. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
  425. package/dist/core/goals/goal-auto-continue-controller.js +1 -3
  426. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  427. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  428. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  429. package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
  430. package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
  431. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  432. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
  433. package/dist/core/goals/goal-lifecycle.js.map +1 -1
  434. package/dist/core/goals/goal-record.d.ts.map +1 -1
  435. package/dist/core/goals/goal-record.js.map +1 -1
  436. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  437. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  438. package/dist/core/goals/goal-session-controller.d.ts +15 -0
  439. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  440. package/dist/core/goals/goal-session-controller.js +27 -3
  441. package/dist/core/goals/goal-session-controller.js.map +1 -1
  442. package/dist/core/goals/goal-state.d.ts.map +1 -1
  443. package/dist/core/goals/goal-state.js +35 -51
  444. package/dist/core/goals/goal-state.js.map +1 -1
  445. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  446. package/dist/core/goals/goal-tool-core.js.map +1 -1
  447. package/dist/core/goals/natural-language-goal.d.ts +9 -0
  448. package/dist/core/goals/natural-language-goal.d.ts.map +1 -0
  449. package/dist/core/goals/natural-language-goal.js +23 -0
  450. package/dist/core/goals/natural-language-goal.js.map +1 -0
  451. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  452. package/dist/core/goals/session-goal-state.js.map +1 -1
  453. package/dist/core/http-dispatcher.d.ts.map +1 -1
  454. package/dist/core/http-dispatcher.js.map +1 -1
  455. package/dist/core/human-input-controller.d.ts.map +1 -1
  456. package/dist/core/human-input-controller.js +2 -3
  457. package/dist/core/human-input-controller.js.map +1 -1
  458. package/dist/core/human-input.d.ts.map +1 -1
  459. package/dist/core/human-input.js.map +1 -1
  460. package/dist/core/improvement-loop.d.ts.map +1 -1
  461. package/dist/core/improvement-loop.js +11 -11
  462. package/dist/core/improvement-loop.js.map +1 -1
  463. package/dist/core/index.d.ts.map +1 -1
  464. package/dist/core/install-telemetry.d.ts.map +1 -1
  465. package/dist/core/install-telemetry.js.map +1 -1
  466. package/dist/core/isolated-text-completion.d.ts +17 -0
  467. package/dist/core/isolated-text-completion.d.ts.map +1 -0
  468. package/dist/core/isolated-text-completion.js +15 -0
  469. package/dist/core/isolated-text-completion.js.map +1 -0
  470. package/dist/core/keybindings.d.ts +47 -2
  471. package/dist/core/keybindings.d.ts.map +1 -1
  472. package/dist/core/keybindings.js +12 -1
  473. package/dist/core/keybindings.js.map +1 -1
  474. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  475. package/dist/core/learning/learning-audit.js.map +1 -1
  476. package/dist/core/learning/learning-gate.d.ts.map +1 -1
  477. package/dist/core/learning/learning-gate.js.map +1 -1
  478. package/dist/core/learning/observation-store.d.ts.map +1 -1
  479. package/dist/core/learning/observation-store.js +0 -2
  480. package/dist/core/learning/observation-store.js.map +1 -1
  481. package/dist/core/learning/reflection-engine.d.ts +1 -1
  482. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  483. package/dist/core/learning/reflection-engine.js +3 -0
  484. package/dist/core/learning/reflection-engine.js.map +1 -1
  485. package/dist/core/learning/reflection-turn-analysis.d.ts +20 -0
  486. package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -0
  487. package/dist/core/learning/reflection-turn-analysis.js +136 -0
  488. package/dist/core/learning/reflection-turn-analysis.js.map +1 -0
  489. package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
  490. package/dist/core/learning/session-learning-decision.js.map +1 -1
  491. package/dist/core/learning/skill-curator.d.ts.map +1 -1
  492. package/dist/core/learning/skill-curator.js +0 -3
  493. package/dist/core/learning/skill-curator.js.map +1 -1
  494. package/dist/core/local-runtime-controller.d.ts +39 -0
  495. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  496. package/dist/core/local-runtime-controller.js +41 -62
  497. package/dist/core/local-runtime-controller.js.map +1 -1
  498. package/dist/core/memory/effectiveness-tracker.d.ts.map +1 -1
  499. package/dist/core/memory/effectiveness-tracker.js +4 -2
  500. package/dist/core/memory/effectiveness-tracker.js.map +1 -1
  501. package/dist/core/memory/memory-manager.d.ts.map +1 -1
  502. package/dist/core/memory/memory-manager.js +7 -7
  503. package/dist/core/memory/memory-manager.js.map +1 -1
  504. package/dist/core/memory/memory-provider.d.ts.map +1 -1
  505. package/dist/core/memory/providers/file-store.d.ts +7 -0
  506. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  507. package/dist/core/memory/providers/file-store.js +48 -13
  508. package/dist/core/memory/providers/file-store.js.map +1 -1
  509. package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts +47 -0
  510. package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts.map +1 -0
  511. package/dist/core/memory/providers/transcript-recall-worker-protocol.js +50 -0
  512. package/dist/core/memory/providers/transcript-recall-worker-protocol.js.map +1 -0
  513. package/dist/core/memory/providers/transcript-recall-worker.d.ts +2 -0
  514. package/dist/core/memory/providers/transcript-recall-worker.d.ts.map +1 -0
  515. package/dist/core/memory/providers/transcript-recall-worker.js +143 -0
  516. package/dist/core/memory/providers/transcript-recall-worker.js.map +1 -0
  517. package/dist/core/memory/providers/transcript-recall.d.ts +24 -13
  518. package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
  519. package/dist/core/memory/providers/transcript-recall.js +143 -141
  520. package/dist/core/memory/providers/transcript-recall.js.map +1 -1
  521. package/dist/core/memory/providers/user-memory-archive.d.ts +39 -0
  522. package/dist/core/memory/providers/user-memory-archive.d.ts.map +1 -0
  523. package/dist/core/memory/providers/user-memory-archive.js +258 -0
  524. package/dist/core/memory/providers/user-memory-archive.js.map +1 -0
  525. package/dist/core/memory/transcript-index.d.ts.map +1 -1
  526. package/dist/core/memory/transcript-index.js +1 -1
  527. package/dist/core/memory/transcript-index.js.map +1 -1
  528. package/dist/core/memory-controller.d.ts +9 -0
  529. package/dist/core/memory-controller.d.ts.map +1 -1
  530. package/dist/core/memory-controller.js +57 -16
  531. package/dist/core/memory-controller.js.map +1 -1
  532. package/dist/core/model-capability.d.ts.map +1 -1
  533. package/dist/core/model-capability.js.map +1 -1
  534. package/dist/core/model-output-json.d.ts +10 -0
  535. package/dist/core/model-output-json.d.ts.map +1 -0
  536. package/dist/core/model-output-json.js +43 -0
  537. package/dist/core/model-output-json.js.map +1 -0
  538. package/dist/core/model-registry.d.ts +8 -8
  539. package/dist/core/model-registry.d.ts.map +1 -1
  540. package/dist/core/model-registry.js +29 -52
  541. package/dist/core/model-registry.js.map +1 -1
  542. package/dist/core/model-resolver.d.ts.map +1 -1
  543. package/dist/core/model-resolver.js +1 -1
  544. package/dist/core/model-resolver.js.map +1 -1
  545. package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
  546. package/dist/core/model-router/config-diagnostics.js.map +1 -1
  547. package/dist/core/model-router/executor-route.d.ts.map +1 -1
  548. package/dist/core/model-router/executor-route.js.map +1 -1
  549. package/dist/core/model-router/fitness-gate.d.ts.map +1 -1
  550. package/dist/core/model-router/fitness-gate.js.map +1 -1
  551. package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
  552. package/dist/core/model-router/route-judge.d.ts.map +1 -1
  553. package/dist/core/model-router/route-judge.js +18 -36
  554. package/dist/core/model-router/route-judge.js.map +1 -1
  555. package/dist/core/model-router/session-buffer.d.ts.map +1 -1
  556. package/dist/core/model-router/session-buffer.js.map +1 -1
  557. package/dist/core/model-router/status.d.ts.map +1 -1
  558. package/dist/core/model-router/status.js.map +1 -1
  559. package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
  560. package/dist/core/model-router/tool-escalation.js.map +1 -1
  561. package/dist/core/model-router-controller.d.ts +1 -0
  562. package/dist/core/model-router-controller.d.ts.map +1 -1
  563. package/dist/core/model-router-controller.js +25 -56
  564. package/dist/core/model-router-controller.js.map +1 -1
  565. package/dist/core/model-selection-controller.d.ts +10 -0
  566. package/dist/core/model-selection-controller.d.ts.map +1 -1
  567. package/dist/core/model-selection-controller.js +0 -1
  568. package/dist/core/model-selection-controller.js.map +1 -1
  569. package/dist/core/model-tool-protocol.d.ts.map +1 -1
  570. package/dist/core/model-tool-protocol.js.map +1 -1
  571. package/dist/core/models/adaptation-store.d.ts.map +1 -1
  572. package/dist/core/models/adaptation-store.js +0 -1
  573. package/dist/core/models/adaptation-store.js.map +1 -1
  574. package/dist/core/models/context-sizing.d.ts.map +1 -1
  575. package/dist/core/models/context-sizing.js.map +1 -1
  576. package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
  577. package/dist/core/models/default-model-suggestions.js.map +1 -1
  578. package/dist/core/models/fitness-store.d.ts.map +1 -1
  579. package/dist/core/models/fitness-store.js +0 -1
  580. package/dist/core/models/fitness-store.js.map +1 -1
  581. package/dist/core/models/host-state-store.d.ts.map +1 -1
  582. package/dist/core/models/host-state-store.js +1 -6
  583. package/dist/core/models/host-state-store.js.map +1 -1
  584. package/dist/core/models/llamacpp-runtime.d.ts +4 -19
  585. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
  586. package/dist/core/models/llamacpp-runtime.js +32 -136
  587. package/dist/core/models/llamacpp-runtime.js.map +1 -1
  588. package/dist/core/models/local-registration.d.ts.map +1 -1
  589. package/dist/core/models/local-registration.js +82 -115
  590. package/dist/core/models/local-registration.js.map +1 -1
  591. package/dist/core/models/local-runtime.d.ts +12 -18
  592. package/dist/core/models/local-runtime.d.ts.map +1 -1
  593. package/dist/core/models/local-runtime.js +60 -204
  594. package/dist/core/models/local-runtime.js.map +1 -1
  595. package/dist/core/models/model-endpoint.d.ts +3 -0
  596. package/dist/core/models/model-endpoint.d.ts.map +1 -0
  597. package/dist/core/models/model-endpoint.js +11 -0
  598. package/dist/core/models/model-endpoint.js.map +1 -0
  599. package/dist/core/models/model-ref.d.ts.map +1 -1
  600. package/dist/core/models/model-ref.js.map +1 -1
  601. package/dist/core/models/needle-runtime.d.ts +7 -3
  602. package/dist/core/models/needle-runtime.d.ts.map +1 -1
  603. package/dist/core/models/needle-runtime.js +16 -92
  604. package/dist/core/models/needle-runtime.js.map +1 -1
  605. package/dist/core/models/perf-profile.d.ts +1 -1
  606. package/dist/core/models/perf-profile.d.ts.map +1 -1
  607. package/dist/core/models/perf-profile.js +6 -13
  608. package/dist/core/models/perf-profile.js.map +1 -1
  609. package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
  610. package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
  611. package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
  612. package/dist/core/models/runtime-arbiter.js +3 -15
  613. package/dist/core/models/runtime-arbiter.js.map +1 -1
  614. package/dist/core/models/runtime-process.d.ts +100 -0
  615. package/dist/core/models/runtime-process.d.ts.map +1 -0
  616. package/dist/core/models/runtime-process.js +183 -0
  617. package/dist/core/models/runtime-process.js.map +1 -0
  618. package/dist/core/orchestration/agent-resume.d.ts +2 -0
  619. package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
  620. package/dist/core/orchestration/agent-resume.js +7 -0
  621. package/dist/core/orchestration/agent-resume.js.map +1 -1
  622. package/dist/core/orchestration/attempt-usage.d.ts +28 -0
  623. package/dist/core/orchestration/attempt-usage.d.ts.map +1 -0
  624. package/dist/core/orchestration/attempt-usage.js +168 -0
  625. package/dist/core/orchestration/attempt-usage.js.map +1 -0
  626. package/dist/core/orchestration/capability-gateway.d.ts +19 -1
  627. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  628. package/dist/core/orchestration/capability-gateway.js +120 -34
  629. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  630. package/dist/core/orchestration/contracts.d.ts +35 -0
  631. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  632. package/dist/core/orchestration/contracts.js +17 -0
  633. package/dist/core/orchestration/contracts.js.map +1 -1
  634. package/dist/core/orchestration/delegation-ledger.d.ts +17 -2
  635. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
  636. package/dist/core/orchestration/delegation-ledger.js +78 -5
  637. package/dist/core/orchestration/delegation-ledger.js.map +1 -1
  638. package/dist/core/orchestration/event-store.d.ts +1 -0
  639. package/dist/core/orchestration/event-store.d.ts.map +1 -1
  640. package/dist/core/orchestration/event-store.js +79 -52
  641. package/dist/core/orchestration/event-store.js.map +1 -1
  642. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  643. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  644. package/dist/core/orchestration/model-binding.d.ts.map +1 -1
  645. package/dist/core/orchestration/model-binding.js.map +1 -1
  646. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
  647. package/dist/core/orchestration/policy-compiler.js +0 -3
  648. package/dist/core/orchestration/policy-compiler.js.map +1 -1
  649. package/dist/core/orchestration/policy-gate.d.ts.map +1 -1
  650. package/dist/core/orchestration/policy-gate.js +0 -2
  651. package/dist/core/orchestration/policy-gate.js.map +1 -1
  652. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  653. package/dist/core/orchestration/profile-registry.js +82 -42
  654. package/dist/core/orchestration/profile-registry.js.map +1 -1
  655. package/dist/core/orchestration/profile-store.d.ts.map +1 -1
  656. package/dist/core/orchestration/profile-store.js +18 -7
  657. package/dist/core/orchestration/profile-store.js.map +1 -1
  658. package/dist/core/orchestration/risk-budget.d.ts +2 -0
  659. package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
  660. package/dist/core/orchestration/risk-budget.js +26 -0
  661. package/dist/core/orchestration/risk-budget.js.map +1 -1
  662. package/dist/core/orchestration/task-runtime.d.ts +14 -1
  663. package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
  664. package/dist/core/orchestration/task-runtime.js +153 -57
  665. package/dist/core/orchestration/task-runtime.js.map +1 -1
  666. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
  667. package/dist/core/orchestration/work-state-projection.js.map +1 -1
  668. package/dist/core/orchestration/worker-execution-contract.d.ts +3 -1
  669. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  670. package/dist/core/orchestration/worker-execution-contract.js +75 -23
  671. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  672. package/dist/core/orchestration/worker-result-adapter.d.ts +9 -3
  673. package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
  674. package/dist/core/orchestration/worker-result-adapter.js +167 -14
  675. package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
  676. package/dist/core/output-guard.d.ts.map +1 -1
  677. package/dist/core/output-guard.js.map +1 -1
  678. package/dist/core/package-manager.d.ts +3 -0
  679. package/dist/core/package-manager.d.ts.map +1 -1
  680. package/dist/core/package-manager.js +88 -353
  681. package/dist/core/package-manager.js.map +1 -1
  682. package/dist/core/process-identity.d.ts.map +1 -1
  683. package/dist/core/process-identity.js.map +1 -1
  684. package/dist/core/process-liveness.d.ts +3 -0
  685. package/dist/core/process-liveness.d.ts.map +1 -0
  686. package/dist/core/process-liveness.js +17 -0
  687. package/dist/core/process-liveness.js.map +1 -0
  688. package/dist/core/process-matrix/codes.d.ts.map +1 -1
  689. package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -1
  690. package/dist/core/process-matrix/resume-launcher.js.map +1 -1
  691. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  692. package/dist/core/process-matrix/runtime.js.map +1 -1
  693. package/dist/core/process-matrix/store.d.ts.map +1 -1
  694. package/dist/core/process-matrix/store.js.map +1 -1
  695. package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
  696. package/dist/core/process-matrix/supervisor.js.map +1 -1
  697. package/dist/core/profile-filter-controller.d.ts.map +1 -1
  698. package/dist/core/profile-filter-controller.js +7 -8
  699. package/dist/core/profile-filter-controller.js.map +1 -1
  700. package/dist/core/profile-registry.d.ts.map +1 -1
  701. package/dist/core/profile-registry.js +1 -2
  702. package/dist/core/profile-registry.js.map +1 -1
  703. package/dist/core/profile-resource-selection.d.ts.map +1 -1
  704. package/dist/core/profile-resource-selection.js +18 -59
  705. package/dist/core/profile-resource-selection.js.map +1 -1
  706. package/dist/core/prompt-markup.d.ts +3 -0
  707. package/dist/core/prompt-markup.d.ts.map +1 -0
  708. package/dist/core/prompt-markup.js +7 -0
  709. package/dist/core/prompt-markup.js.map +1 -0
  710. package/dist/core/prompt-templates.d.ts.map +1 -1
  711. package/dist/core/prompt-templates.js +13 -39
  712. package/dist/core/prompt-templates.js.map +1 -1
  713. package/dist/core/provider-display-names.d.ts.map +1 -1
  714. package/dist/core/python-runtime.d.ts.map +1 -1
  715. package/dist/core/python-runtime.js.map +1 -1
  716. package/dist/core/reflection-controller.d.ts +23 -2
  717. package/dist/core/reflection-controller.d.ts.map +1 -1
  718. package/dist/core/reflection-controller.js +233 -79
  719. package/dist/core/reflection-controller.js.map +1 -1
  720. package/dist/core/reload-blockers.d.ts +2 -1
  721. package/dist/core/reload-blockers.d.ts.map +1 -1
  722. package/dist/core/reload-blockers.js +4 -14
  723. package/dist/core/reload-blockers.js.map +1 -1
  724. package/dist/core/request-auth.d.ts.map +1 -1
  725. package/dist/core/request-auth.js.map +1 -1
  726. package/dist/core/research/automata-provider.d.ts.map +1 -1
  727. package/dist/core/research/automata-provider.js.map +1 -1
  728. package/dist/core/research/evidence-bundle.d.ts +20 -0
  729. package/dist/core/research/evidence-bundle.d.ts.map +1 -1
  730. package/dist/core/research/evidence-bundle.js +173 -69
  731. package/dist/core/research/evidence-bundle.js.map +1 -1
  732. package/dist/core/research/lane-model-resolver.d.ts.map +1 -1
  733. package/dist/core/research/lane-model-resolver.js +0 -1
  734. package/dist/core/research/lane-model-resolver.js.map +1 -1
  735. package/dist/core/research/model-fitness-controller.d.ts.map +1 -1
  736. package/dist/core/research/model-fitness-controller.js +17 -33
  737. package/dist/core/research/model-fitness-controller.js.map +1 -1
  738. package/dist/core/research/model-fitness.d.ts.map +1 -1
  739. package/dist/core/research/model-fitness.js +4 -25
  740. package/dist/core/research/model-fitness.js.map +1 -1
  741. package/dist/core/research/research-gate.d.ts.map +1 -1
  742. package/dist/core/research/research-gate.js.map +1 -1
  743. package/dist/core/research/research-lane-controller.d.ts.map +1 -1
  744. package/dist/core/research/research-lane-controller.js +5 -10
  745. package/dist/core/research/research-lane-controller.js.map +1 -1
  746. package/dist/core/research/research-runner.d.ts +2 -4
  747. package/dist/core/research/research-runner.d.ts.map +1 -1
  748. package/dist/core/research/research-runner.js +17 -48
  749. package/dist/core/research/research-runner.js.map +1 -1
  750. package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
  751. package/dist/core/research/session-evidence-bundle.js.map +1 -1
  752. package/dist/core/research/workspace-collector.d.ts.map +1 -1
  753. package/dist/core/research/workspace-collector.js.map +1 -1
  754. package/dist/core/resolve-config-value.d.ts.map +1 -1
  755. package/dist/core/resolve-config-value.js.map +1 -1
  756. package/dist/core/resource-ignore.d.ts +6 -0
  757. package/dist/core/resource-ignore.d.ts.map +1 -0
  758. package/dist/core/resource-ignore.js +44 -0
  759. package/dist/core/resource-ignore.js.map +1 -0
  760. package/dist/core/resource-loader.d.ts +0 -1
  761. package/dist/core/resource-loader.d.ts.map +1 -1
  762. package/dist/core/resource-loader.js +52 -187
  763. package/dist/core/resource-loader.js.map +1 -1
  764. package/dist/core/resource-profile-blocks.d.ts +3 -1
  765. package/dist/core/resource-profile-blocks.d.ts.map +1 -1
  766. package/dist/core/resource-profile-blocks.js +8 -5
  767. package/dist/core/resource-profile-blocks.js.map +1 -1
  768. package/dist/core/resource-profile-equality.d.ts.map +1 -1
  769. package/dist/core/resource-profile-equality.js.map +1 -1
  770. package/dist/core/resource-traversal.d.ts +43 -0
  771. package/dist/core/resource-traversal.d.ts.map +1 -0
  772. package/dist/core/resource-traversal.js +84 -0
  773. package/dist/core/resource-traversal.js.map +1 -0
  774. package/dist/core/risk-classifier.d.ts.map +1 -1
  775. package/dist/core/risk-classifier.js.map +1 -1
  776. package/dist/core/runtime-builder.d.ts +11 -1
  777. package/dist/core/runtime-builder.d.ts.map +1 -1
  778. package/dist/core/runtime-builder.js +40 -51
  779. package/dist/core/runtime-builder.js.map +1 -1
  780. package/dist/core/scout-controller.d.ts.map +1 -1
  781. package/dist/core/scout-controller.js +0 -1
  782. package/dist/core/scout-controller.js.map +1 -1
  783. package/dist/core/sdk.d.ts.map +1 -1
  784. package/dist/core/sdk.js.map +1 -1
  785. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  786. package/dist/core/secrets/credential-exposure-guard.js +70 -44
  787. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  788. package/dist/core/secrets/secret-dotenv.d.ts.map +1 -1
  789. package/dist/core/secrets/secret-dotenv.js +0 -1
  790. package/dist/core/secrets/secret-dotenv.js.map +1 -1
  791. package/dist/core/secrets/secret-vault-format.d.ts.map +1 -1
  792. package/dist/core/secrets/secret-vault-format.js +0 -1
  793. package/dist/core/secrets/secret-vault-format.js.map +1 -1
  794. package/dist/core/secrets/secret-vault.d.ts.map +1 -1
  795. package/dist/core/secrets/secret-vault.js +2 -10
  796. package/dist/core/secrets/secret-vault.js.map +1 -1
  797. package/dist/core/security/secret-text.d.ts.map +1 -1
  798. package/dist/core/security/secret-text.js.map +1 -1
  799. package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
  800. package/dist/core/security/untrusted-boundary.js.map +1 -1
  801. package/dist/core/session-analytics.d.ts.map +1 -1
  802. package/dist/core/session-analytics.js +18 -50
  803. package/dist/core/session-analytics.js.map +1 -1
  804. package/dist/core/session-artifact-bundle.d.ts +35 -0
  805. package/dist/core/session-artifact-bundle.d.ts.map +1 -0
  806. package/dist/core/session-artifact-bundle.js +61 -0
  807. package/dist/core/session-artifact-bundle.js.map +1 -0
  808. package/dist/core/session-cwd.d.ts.map +1 -1
  809. package/dist/core/session-cwd.js +0 -1
  810. package/dist/core/session-cwd.js.map +1 -1
  811. package/dist/core/session-entry-index.d.ts +8 -0
  812. package/dist/core/session-entry-index.d.ts.map +1 -0
  813. package/dist/core/session-entry-index.js +16 -0
  814. package/dist/core/session-entry-index.js.map +1 -0
  815. package/dist/core/session-image-store.d.ts.map +1 -1
  816. package/dist/core/session-image-store.js +0 -3
  817. package/dist/core/session-image-store.js.map +1 -1
  818. package/dist/core/session-jsonl-writer.d.ts +3 -0
  819. package/dist/core/session-jsonl-writer.d.ts.map +1 -0
  820. package/dist/core/session-jsonl-writer.js +38 -0
  821. package/dist/core/session-jsonl-writer.js.map +1 -0
  822. package/dist/core/session-manager-factory.d.ts.map +1 -1
  823. package/dist/core/session-manager-factory.js.map +1 -1
  824. package/dist/core/session-role.d.ts.map +1 -1
  825. package/dist/core/session-role.js.map +1 -1
  826. package/dist/core/session-snapshot.d.ts.map +1 -1
  827. package/dist/core/session-snapshot.js.map +1 -1
  828. package/dist/core/session-supervision-runtime.d.ts.map +1 -1
  829. package/dist/core/session-supervision-runtime.js +1 -4
  830. package/dist/core/session-supervision-runtime.js.map +1 -1
  831. package/dist/core/session-tree-navigator.d.ts.map +1 -1
  832. package/dist/core/session-tree-navigator.js +0 -1
  833. package/dist/core/session-tree-navigator.js.map +1 -1
  834. package/dist/core/settings-manager.d.ts +2 -1
  835. package/dist/core/settings-manager.d.ts.map +1 -1
  836. package/dist/core/settings-manager.js +64 -162
  837. package/dist/core/settings-manager.js.map +1 -1
  838. package/dist/core/skill-block.d.mts +8 -0
  839. package/dist/core/skill-block.mjs +52 -0
  840. package/dist/core/skill-discovery.d.ts +5 -0
  841. package/dist/core/skill-discovery.d.ts.map +1 -0
  842. package/dist/core/skill-discovery.js +34 -0
  843. package/dist/core/skill-discovery.js.map +1 -0
  844. package/dist/core/skills.d.ts.map +1 -1
  845. package/dist/core/skills.js +23 -159
  846. package/dist/core/skills.js.map +1 -1
  847. package/dist/core/slash-commands.d.ts.map +1 -1
  848. package/dist/core/source-info.d.ts.map +1 -1
  849. package/dist/core/source-info.js.map +1 -1
  850. package/dist/core/spawned-usage.d.ts +21 -0
  851. package/dist/core/spawned-usage.d.ts.map +1 -0
  852. package/dist/core/spawned-usage.js +29 -0
  853. package/dist/core/spawned-usage.js.map +1 -0
  854. package/dist/core/system-prompt-builder.d.ts +4 -0
  855. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  856. package/dist/core/system-prompt-builder.js +15 -8
  857. package/dist/core/system-prompt-builder.js.map +1 -1
  858. package/dist/core/system-prompt.d.ts.map +1 -1
  859. package/dist/core/system-prompt.js +52 -35
  860. package/dist/core/system-prompt.js.map +1 -1
  861. package/dist/core/tasks/session-task-state.d.ts.map +1 -1
  862. package/dist/core/tasks/session-task-state.js.map +1 -1
  863. package/dist/core/tasks/task-command.d.ts.map +1 -1
  864. package/dist/core/tasks/task-command.js.map +1 -1
  865. package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -1
  866. package/dist/core/tasks/task-contract-monitor.js.map +1 -1
  867. package/dist/core/tasks/task-projection.d.ts.map +1 -1
  868. package/dist/core/tasks/task-projection.js.map +1 -1
  869. package/dist/core/tasks/task-state.d.ts.map +1 -1
  870. package/dist/core/tasks/task-state.js.map +1 -1
  871. package/dist/core/text-preview.d.ts +4 -0
  872. package/dist/core/text-preview.d.ts.map +1 -0
  873. package/dist/core/text-preview.js +33 -0
  874. package/dist/core/text-preview.js.map +1 -0
  875. package/dist/core/timings.d.ts.map +1 -1
  876. package/dist/core/timings.js.map +1 -1
  877. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  878. package/dist/core/tool-capability-policy.js.map +1 -1
  879. package/dist/core/tool-gate-controller.d.ts.map +1 -1
  880. package/dist/core/tool-gate-controller.js +86 -87
  881. package/dist/core/tool-gate-controller.js.map +1 -1
  882. package/dist/core/tool-protocol-controller.d.ts +4 -1
  883. package/dist/core/tool-protocol-controller.d.ts.map +1 -1
  884. package/dist/core/tool-protocol-controller.js +19 -23
  885. package/dist/core/tool-protocol-controller.js.map +1 -1
  886. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  887. package/dist/core/tool-recovery-log-records.js.map +1 -1
  888. package/dist/core/tool-recovery-log-worker.d.ts.map +1 -1
  889. package/dist/core/tool-recovery-log-worker.js.map +1 -1
  890. package/dist/core/tool-recovery-logger.d.ts.map +1 -1
  891. package/dist/core/tool-recovery-logger.js +12 -24
  892. package/dist/core/tool-recovery-logger.js.map +1 -1
  893. package/dist/core/tool-recovery-stats.d.ts.map +1 -1
  894. package/dist/core/tool-recovery-stats.js +16 -22
  895. package/dist/core/tool-recovery-stats.js.map +1 -1
  896. package/dist/core/tool-repair-health.d.ts.map +1 -1
  897. package/dist/core/tool-repair-health.js.map +1 -1
  898. package/dist/core/tool-repair-settings.d.ts.map +1 -1
  899. package/dist/core/tool-repair-settings.js.map +1 -1
  900. package/dist/core/tool-selection/expected-utility.d.ts.map +1 -1
  901. package/dist/core/tool-selection/expected-utility.js.map +1 -1
  902. package/dist/core/tool-selection/promotion.d.ts.map +1 -1
  903. package/dist/core/tool-selection/promotion.js.map +1 -1
  904. package/dist/core/tool-selection/tool-performance-store.d.ts +2 -0
  905. package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
  906. package/dist/core/tool-selection/tool-performance-store.js +49 -7
  907. package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
  908. package/dist/core/tool-selection/tool-phase-timing.d.ts +19 -0
  909. package/dist/core/tool-selection/tool-phase-timing.d.ts.map +1 -0
  910. package/dist/core/tool-selection/tool-phase-timing.js +63 -0
  911. package/dist/core/tool-selection/tool-phase-timing.js.map +1 -0
  912. package/dist/core/tool-selection/tool-selection-controller.d.ts +2 -5
  913. package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
  914. package/dist/core/tool-selection/tool-selection-controller.js +50 -30
  915. package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
  916. package/dist/core/toolkit/reflex-interpreter.d.ts +16 -0
  917. package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
  918. package/dist/core/toolkit/reflex-interpreter.js +21 -0
  919. package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
  920. package/dist/core/toolkit/script-registry.d.ts.map +1 -1
  921. package/dist/core/toolkit/script-registry.js.map +1 -1
  922. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  923. package/dist/core/toolkit/script-runner.js.map +1 -1
  924. package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
  925. package/dist/core/tools/artifact-retrieve.js.map +1 -1
  926. package/dist/core/tools/ask-question.d.ts +2 -3
  927. package/dist/core/tools/ask-question.d.ts.map +1 -1
  928. package/dist/core/tools/ask-question.js +14 -40
  929. package/dist/core/tools/ask-question.js.map +1 -1
  930. package/dist/core/tools/bash.d.ts +2 -0
  931. package/dist/core/tools/bash.d.ts.map +1 -1
  932. package/dist/core/tools/bash.js +83 -30
  933. package/dist/core/tools/bash.js.map +1 -1
  934. package/dist/core/tools/context-scout.d.ts.map +1 -1
  935. package/dist/core/tools/context-scout.js.map +1 -1
  936. package/dist/core/tools/delegate-status.d.ts +6 -1
  937. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  938. package/dist/core/tools/delegate-status.js +109 -25
  939. package/dist/core/tools/delegate-status.js.map +1 -1
  940. package/dist/core/tools/delegate.d.ts +9 -1
  941. package/dist/core/tools/delegate.d.ts.map +1 -1
  942. package/dist/core/tools/delegate.js +329 -67
  943. package/dist/core/tools/delegate.js.map +1 -1
  944. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  945. package/dist/core/tools/edit-diff.js.map +1 -1
  946. package/dist/core/tools/edit.d.ts.map +1 -1
  947. package/dist/core/tools/edit.js.map +1 -1
  948. package/dist/core/tools/extensionify.d.ts.map +1 -1
  949. package/dist/core/tools/extensionify.js.map +1 -1
  950. package/dist/core/tools/fff-search-backend.d.ts +19 -0
  951. package/dist/core/tools/fff-search-backend.d.ts.map +1 -1
  952. package/dist/core/tools/fff-search-backend.js +28 -2
  953. package/dist/core/tools/fff-search-backend.js.map +1 -1
  954. package/dist/core/tools/file-encoding-policy.d.ts.map +1 -1
  955. package/dist/core/tools/file-encoding-policy.js.map +1 -1
  956. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  957. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  958. package/dist/core/tools/find.d.ts +1 -1
  959. package/dist/core/tools/find.d.ts.map +1 -1
  960. package/dist/core/tools/find.js +44 -108
  961. package/dist/core/tools/find.js.map +1 -1
  962. package/dist/core/tools/git-filter.d.ts.map +1 -1
  963. package/dist/core/tools/git-filter.js.map +1 -1
  964. package/dist/core/tools/goal.d.ts.map +1 -1
  965. package/dist/core/tools/goal.js +7 -7
  966. package/dist/core/tools/goal.js.map +1 -1
  967. package/dist/core/tools/grep.d.ts +1 -1
  968. package/dist/core/tools/grep.d.ts.map +1 -1
  969. package/dist/core/tools/grep.js +42 -102
  970. package/dist/core/tools/grep.js.map +1 -1
  971. package/dist/core/tools/index.d.ts.map +1 -1
  972. package/dist/core/tools/index.js.map +1 -1
  973. package/dist/core/tools/ls.d.ts.map +1 -1
  974. package/dist/core/tools/ls.js +20 -36
  975. package/dist/core/tools/ls.js.map +1 -1
  976. package/dist/core/tools/model-fitness.d.ts.map +1 -1
  977. package/dist/core/tools/model-fitness.js.map +1 -1
  978. package/dist/core/tools/orchestration-panel.d.ts +5 -0
  979. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  980. package/dist/core/tools/orchestration-panel.js +5 -5
  981. package/dist/core/tools/orchestration-panel.js.map +1 -1
  982. package/dist/core/tools/output-accumulator.d.ts +2 -0
  983. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  984. package/dist/core/tools/output-accumulator.js +24 -36
  985. package/dist/core/tools/output-accumulator.js.map +1 -1
  986. package/dist/core/tools/path-utils.d.ts.map +1 -1
  987. package/dist/core/tools/path-utils.js.map +1 -1
  988. package/dist/core/tools/persistent-process-coordinator.d.ts +31 -0
  989. package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -0
  990. package/dist/core/tools/persistent-process-coordinator.js +123 -0
  991. package/dist/core/tools/persistent-process-coordinator.js.map +1 -0
  992. package/dist/core/tools/python.d.ts.map +1 -1
  993. package/dist/core/tools/python.js.map +1 -1
  994. package/dist/core/tools/read.d.ts.map +1 -1
  995. package/dist/core/tools/read.js +14 -13
  996. package/dist/core/tools/read.js.map +1 -1
  997. package/dist/core/tools/render-utils.d.ts +29 -0
  998. package/dist/core/tools/render-utils.d.ts.map +1 -1
  999. package/dist/core/tools/render-utils.js +31 -1
  1000. package/dist/core/tools/render-utils.js.map +1 -1
  1001. package/dist/core/tools/run-process.d.ts +1 -1
  1002. package/dist/core/tools/run-process.d.ts.map +1 -1
  1003. package/dist/core/tools/run-process.js +69 -9
  1004. package/dist/core/tools/run-process.js.map +1 -1
  1005. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  1006. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  1007. package/dist/core/tools/search-command-guard.d.ts +10 -0
  1008. package/dist/core/tools/search-command-guard.d.ts.map +1 -1
  1009. package/dist/core/tools/search-command-guard.js +118 -31
  1010. package/dist/core/tools/search-command-guard.js.map +1 -1
  1011. package/dist/core/tools/search-router.d.ts.map +1 -1
  1012. package/dist/core/tools/search-router.js.map +1 -1
  1013. package/dist/core/tools/search-tool-runtime.d.ts +19 -0
  1014. package/dist/core/tools/search-tool-runtime.d.ts.map +1 -0
  1015. package/dist/core/tools/search-tool-runtime.js +12 -0
  1016. package/dist/core/tools/search-tool-runtime.js.map +1 -0
  1017. package/dist/core/tools/secret-store.d.ts.map +1 -1
  1018. package/dist/core/tools/secret-store.js.map +1 -1
  1019. package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
  1020. package/dist/core/tools/shell-command-parser.js.map +1 -1
  1021. package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
  1022. package/dist/core/tools/shell-contract-router.js +16 -6
  1023. package/dist/core/tools/shell-contract-router.js.map +1 -1
  1024. package/dist/core/tools/shell-execution-session.d.ts +4 -0
  1025. package/dist/core/tools/shell-execution-session.d.ts.map +1 -0
  1026. package/dist/core/tools/shell-execution-session.js +11 -0
  1027. package/dist/core/tools/shell-execution-session.js.map +1 -0
  1028. package/dist/core/tools/shell-output-projection.d.ts +49 -0
  1029. package/dist/core/tools/shell-output-projection.d.ts.map +1 -0
  1030. package/dist/core/tools/shell-output-projection.js +381 -0
  1031. package/dist/core/tools/shell-output-projection.js.map +1 -0
  1032. package/dist/core/tools/shell-session.d.ts +2 -13
  1033. package/dist/core/tools/shell-session.d.ts.map +1 -1
  1034. package/dist/core/tools/shell-session.js +36 -136
  1035. package/dist/core/tools/shell-session.js.map +1 -1
  1036. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  1037. package/dist/core/tools/skill-audit.js.map +1 -1
  1038. package/dist/core/tools/skillify.d.ts.map +1 -1
  1039. package/dist/core/tools/skillify.js.map +1 -1
  1040. package/dist/core/tools/task-steps.d.ts +8 -8
  1041. package/dist/core/tools/task-steps.d.ts.map +1 -1
  1042. package/dist/core/tools/task-steps.js +17 -18
  1043. package/dist/core/tools/task-steps.js.map +1 -1
  1044. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  1045. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  1046. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  1047. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  1048. package/dist/core/tools/tool-task.d.ts +23 -0
  1049. package/dist/core/tools/tool-task.d.ts.map +1 -0
  1050. package/dist/core/tools/tool-task.js +93 -0
  1051. package/dist/core/tools/tool-task.js.map +1 -0
  1052. package/dist/core/tools/windows-shell-engine.d.ts +17 -11
  1053. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
  1054. package/dist/core/tools/windows-shell-engine.js +339 -117
  1055. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  1056. package/dist/core/tools/windows-shell-state.d.ts.map +1 -1
  1057. package/dist/core/tools/windows-shell-state.js.map +1 -1
  1058. package/dist/core/tools/worktree-sync.d.ts.map +1 -1
  1059. package/dist/core/tools/worktree-sync.js +8 -12
  1060. package/dist/core/tools/worktree-sync.js.map +1 -1
  1061. package/dist/core/tools/write.d.ts.map +1 -1
  1062. package/dist/core/tools/write.js +0 -1
  1063. package/dist/core/tools/write.js.map +1 -1
  1064. package/dist/core/trust-manager.d.ts.map +1 -1
  1065. package/dist/core/trust-manager.js +7 -40
  1066. package/dist/core/trust-manager.js.map +1 -1
  1067. package/dist/core/util/atomic-file.d.ts +19 -0
  1068. package/dist/core/util/atomic-file.d.ts.map +1 -1
  1069. package/dist/core/util/atomic-file.js +50 -15
  1070. package/dist/core/util/atomic-file.js.map +1 -1
  1071. package/dist/core/util/bounded-file.d.ts +15 -0
  1072. package/dist/core/util/bounded-file.d.ts.map +1 -0
  1073. package/dist/core/util/bounded-file.js +120 -0
  1074. package/dist/core/util/bounded-file.js.map +1 -0
  1075. package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
  1076. package/dist/core/util/bounded-jsonl.js +112 -9
  1077. package/dist/core/util/bounded-jsonl.js.map +1 -1
  1078. package/dist/core/util/bounded-value.d.ts +3 -0
  1079. package/dist/core/util/bounded-value.d.ts.map +1 -0
  1080. package/dist/core/util/bounded-value.js +12 -0
  1081. package/dist/core/util/bounded-value.js.map +1 -0
  1082. package/dist/core/util/json-size.d.ts +3 -0
  1083. package/dist/core/util/json-size.d.ts.map +1 -0
  1084. package/dist/core/util/json-size.js +95 -0
  1085. package/dist/core/util/json-size.js.map +1 -0
  1086. package/dist/core/util/minimatch-cache.d.ts.map +1 -1
  1087. package/dist/core/util/minimatch-cache.js.map +1 -1
  1088. package/dist/core/util/value-guards.d.ts +2 -0
  1089. package/dist/core/util/value-guards.d.ts.map +1 -1
  1090. package/dist/core/util/value-guards.js +5 -0
  1091. package/dist/core/util/value-guards.js.map +1 -1
  1092. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  1093. package/dist/core/worktree-sync/git-engine.d.ts.map +1 -1
  1094. package/dist/core/worktree-sync/git-engine.js +20 -36
  1095. package/dist/core/worktree-sync/git-engine.js.map +1 -1
  1096. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  1097. package/dist/core/worktree-sync/lane-gate.js +1 -4
  1098. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  1099. package/dist/core/worktree-sync/runtime.d.ts.map +1 -1
  1100. package/dist/core/worktree-sync/runtime.js.map +1 -1
  1101. package/dist/core/worktree-sync/store.d.ts.map +1 -1
  1102. package/dist/core/worktree-sync/store.js.map +1 -1
  1103. package/dist/core/worktree-sync/watcher.d.ts.map +1 -1
  1104. package/dist/core/worktree-sync/watcher.js.map +1 -1
  1105. package/dist/index.d.ts.map +1 -1
  1106. package/dist/index.js.map +1 -1
  1107. package/dist/main.d.ts.map +1 -1
  1108. package/dist/main.js +10 -32
  1109. package/dist/main.js.map +1 -1
  1110. package/dist/migrations.d.ts.map +1 -1
  1111. package/dist/migrations.js +6 -19
  1112. package/dist/migrations.js.map +1 -1
  1113. package/dist/modes/index.d.ts.map +1 -1
  1114. package/dist/modes/interactive/auth-dialogs-controller.d.ts +3 -0
  1115. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
  1116. package/dist/modes/interactive/auth-dialogs-controller.js +96 -132
  1117. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
  1118. package/dist/modes/interactive/auto-learn-controller.d.ts +1 -31
  1119. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  1120. package/dist/modes/interactive/auto-learn-controller.js +86 -307
  1121. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  1122. package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -1
  1123. package/dist/modes/interactive/autocomplete-provider.js.map +1 -1
  1124. package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -1
  1125. package/dist/modes/interactive/autonomy-commands.js +2 -8
  1126. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  1127. package/dist/modes/interactive/clipboard-input.d.ts +5 -1
  1128. package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
  1129. package/dist/modes/interactive/clipboard-input.js +17 -0
  1130. package/dist/modes/interactive/clipboard-input.js.map +1 -1
  1131. package/dist/modes/interactive/compaction-queue.d.ts.map +1 -1
  1132. package/dist/modes/interactive/compaction-queue.js +13 -18
  1133. package/dist/modes/interactive/compaction-queue.js.map +1 -1
  1134. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  1135. package/dist/modes/interactive/components/activity-lane.js +6 -10
  1136. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  1137. package/dist/modes/interactive/components/armin.d.ts +1 -0
  1138. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  1139. package/dist/modes/interactive/components/armin.js +10 -21
  1140. package/dist/modes/interactive/components/armin.js.map +1 -1
  1141. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  1142. package/dist/modes/interactive/components/assistant-message.js +1 -6
  1143. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  1144. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  1145. package/dist/modes/interactive/components/bash-execution.js +4 -9
  1146. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  1147. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  1148. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  1149. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  1150. package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -8
  1151. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  1152. package/dist/modes/interactive/components/branch-summary-message.js +13 -35
  1153. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  1154. package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -8
  1155. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  1156. package/dist/modes/interactive/components/compaction-summary-message.js +14 -36
  1157. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  1158. package/dist/modes/interactive/components/config-selector.d.ts +1 -0
  1159. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  1160. package/dist/modes/interactive/components/config-selector.js +20 -43
  1161. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  1162. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  1163. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  1164. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  1165. package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
  1166. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  1167. package/dist/modes/interactive/components/custom-editor.js +4 -8
  1168. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  1169. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  1170. package/dist/modes/interactive/components/custom-message.js +1 -6
  1171. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  1172. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  1173. package/dist/modes/interactive/components/daxnuts.js +6 -8
  1174. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  1175. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  1176. package/dist/modes/interactive/components/diff.js.map +1 -1
  1177. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  1178. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  1179. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  1180. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  1181. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  1182. package/dist/modes/interactive/components/expandable-markdown-message.d.ts +21 -0
  1183. package/dist/modes/interactive/components/expandable-markdown-message.d.ts.map +1 -0
  1184. package/dist/modes/interactive/components/expandable-markdown-message.js +48 -0
  1185. package/dist/modes/interactive/components/expandable-markdown-message.js.map +1 -0
  1186. package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -1
  1187. package/dist/modes/interactive/components/expandable-text.js +0 -2
  1188. package/dist/modes/interactive/components/expandable-text.js.map +1 -1
  1189. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  1190. package/dist/modes/interactive/components/extension-editor.js +1 -9
  1191. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  1192. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  1193. package/dist/modes/interactive/components/extension-input.js +2 -8
  1194. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  1195. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  1196. package/dist/modes/interactive/components/extension-selector.js +5 -20
  1197. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  1198. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  1199. package/dist/modes/interactive/components/fitness-role-selector.js +0 -1
  1200. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  1201. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  1202. package/dist/modes/interactive/components/footer.js +1 -5
  1203. package/dist/modes/interactive/components/footer.js.map +1 -1
  1204. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  1205. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  1206. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  1207. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  1208. package/dist/modes/interactive/components/login-dialog.js +4 -10
  1209. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  1210. package/dist/modes/interactive/components/model-selector.d.ts +2 -2
  1211. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  1212. package/dist/modes/interactive/components/model-selector.js +21 -44
  1213. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  1214. package/dist/modes/interactive/components/model-suggestion-selector.d.ts.map +1 -1
  1215. package/dist/modes/interactive/components/model-suggestion-selector.js +0 -1
  1216. package/dist/modes/interactive/components/model-suggestion-selector.js.map +1 -1
  1217. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
  1218. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  1219. package/dist/modes/interactive/components/oauth-selector.js +16 -32
  1220. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  1221. package/dist/modes/interactive/components/profile-resource-editor.d.ts +3 -4
  1222. package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
  1223. package/dist/modes/interactive/components/profile-resource-editor.js +34 -93
  1224. package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
  1225. package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -1
  1226. package/dist/modes/interactive/components/profile-selector.js +0 -1
  1227. package/dist/modes/interactive/components/profile-selector.js.map +1 -1
  1228. package/dist/modes/interactive/components/scoped-models-selector.d.ts +3 -4
  1229. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  1230. package/dist/modes/interactive/components/scoped-models-selector.js +34 -79
  1231. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  1232. package/dist/modes/interactive/components/selector-list.d.ts +63 -0
  1233. package/dist/modes/interactive/components/selector-list.d.ts.map +1 -0
  1234. package/dist/modes/interactive/components/selector-list.js +186 -0
  1235. package/dist/modes/interactive/components/selector-list.js.map +1 -0
  1236. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  1237. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  1238. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  1239. package/dist/modes/interactive/components/session-selector.js +61 -103
  1240. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  1241. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  1242. package/dist/modes/interactive/components/settings-selector.js +40 -138
  1243. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  1244. package/dist/modes/interactive/components/show-images-selector.d.ts +2 -4
  1245. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  1246. package/dist/modes/interactive/components/show-images-selector.js +9 -28
  1247. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  1248. package/dist/modes/interactive/components/skill-invocation-message.d.ts +3 -8
  1249. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  1250. package/dist/modes/interactive/components/skill-invocation-message.js +12 -40
  1251. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  1252. package/dist/modes/interactive/components/theme-selector.d.ts +2 -5
  1253. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  1254. package/dist/modes/interactive/components/theme-selector.js +11 -37
  1255. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  1256. package/dist/modes/interactive/components/thinking-selector.d.ts +2 -4
  1257. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  1258. package/dist/modes/interactive/components/thinking-selector.js +9 -31
  1259. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  1260. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  1261. package/dist/modes/interactive/components/tool-execution.js +9 -28
  1262. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  1263. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
  1264. package/dist/modes/interactive/components/tool-group.js +2 -3
  1265. package/dist/modes/interactive/components/tool-group.js.map +1 -1
  1266. package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -1
  1267. package/dist/modes/interactive/components/tool-panel-registry.js +5 -3
  1268. package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -1
  1269. package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
  1270. package/dist/modes/interactive/components/tool-title.js +0 -4
  1271. package/dist/modes/interactive/components/tool-title.js.map +1 -1
  1272. package/dist/modes/interactive/components/transcript-pager.d.ts +26 -0
  1273. package/dist/modes/interactive/components/transcript-pager.d.ts.map +1 -0
  1274. package/dist/modes/interactive/components/transcript-pager.js +81 -0
  1275. package/dist/modes/interactive/components/transcript-pager.js.map +1 -0
  1276. package/dist/modes/interactive/components/tree-selector.d.ts +1 -12
  1277. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  1278. package/dist/modes/interactive/components/tree-selector.js +42 -402
  1279. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  1280. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  1281. package/dist/modes/interactive/components/trust-selector.js +4 -16
  1282. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  1283. package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -1
  1284. package/dist/modes/interactive/components/usage-action-selector.js +2 -10
  1285. package/dist/modes/interactive/components/usage-action-selector.js.map +1 -1
  1286. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  1287. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  1288. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  1289. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  1290. package/dist/modes/interactive/components/user-message.js +0 -1
  1291. package/dist/modes/interactive/components/user-message.js.map +1 -1
  1292. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  1293. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  1294. package/dist/modes/interactive/config-backup.d.ts.map +1 -1
  1295. package/dist/modes/interactive/config-backup.js.map +1 -1
  1296. package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -1
  1297. package/dist/modes/interactive/editor-overlay-host.js +0 -3
  1298. package/dist/modes/interactive/editor-overlay-host.js.map +1 -1
  1299. package/dist/modes/interactive/extension-ui-host.d.ts +2 -0
  1300. package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
  1301. package/dist/modes/interactive/extension-ui-host.js +51 -72
  1302. package/dist/modes/interactive/extension-ui-host.js.map +1 -1
  1303. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  1304. package/dist/modes/interactive/external-editor.js +2 -15
  1305. package/dist/modes/interactive/external-editor.js.map +1 -1
  1306. package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
  1307. package/dist/modes/interactive/history-reload-math.js.map +1 -1
  1308. package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
  1309. package/dist/modes/interactive/interactive-event-controller.js +23 -16
  1310. package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
  1311. package/dist/modes/interactive/interactive-mode.d.ts +13 -4
  1312. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  1313. package/dist/modes/interactive/interactive-mode.js +123 -204
  1314. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  1315. package/dist/modes/interactive/interactive-selection-prompts.d.ts +20 -0
  1316. package/dist/modes/interactive/interactive-selection-prompts.d.ts.map +1 -0
  1317. package/dist/modes/interactive/interactive-selection-prompts.js +43 -0
  1318. package/dist/modes/interactive/interactive-selection-prompts.js.map +1 -0
  1319. package/dist/modes/interactive/key-handlers.d.ts +2 -1
  1320. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  1321. package/dist/modes/interactive/key-handlers.js +4 -2
  1322. package/dist/modes/interactive/key-handlers.js.map +1 -1
  1323. package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -1
  1324. package/dist/modes/interactive/loaded-resources-view.js.map +1 -1
  1325. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
  1326. package/dist/modes/interactive/local-model-commands.js +4 -9
  1327. package/dist/modes/interactive/local-model-commands.js.map +1 -1
  1328. package/dist/modes/interactive/model-fitness-presentation.d.ts +21 -0
  1329. package/dist/modes/interactive/model-fitness-presentation.d.ts.map +1 -0
  1330. package/dist/modes/interactive/model-fitness-presentation.js +13 -0
  1331. package/dist/modes/interactive/model-fitness-presentation.js.map +1 -0
  1332. package/dist/modes/interactive/profile-menu-controller.d.ts +2 -0
  1333. package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
  1334. package/dist/modes/interactive/profile-menu-controller.js +79 -171
  1335. package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
  1336. package/dist/modes/interactive/report-commands.d.ts +2 -0
  1337. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  1338. package/dist/modes/interactive/report-commands.js +12 -6
  1339. package/dist/modes/interactive/report-commands.js.map +1 -1
  1340. package/dist/modes/interactive/resource-display.d.ts.map +1 -1
  1341. package/dist/modes/interactive/resource-display.js.map +1 -1
  1342. package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
  1343. package/dist/modes/interactive/resource-shell-commands.js +6 -23
  1344. package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
  1345. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  1346. package/dist/modes/interactive/session-flow-commands.js +21 -25
  1347. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  1348. package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
  1349. package/dist/modes/interactive/session-io-commands.js.map +1 -1
  1350. package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -1
  1351. package/dist/modes/interactive/session-replacement-errors.js.map +1 -1
  1352. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  1353. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  1354. package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -1
  1355. package/dist/modes/interactive/signal-lifecycle.js.map +1 -1
  1356. package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
  1357. package/dist/modes/interactive/startup-checks.js +12 -8
  1358. package/dist/modes/interactive/startup-checks.js.map +1 -1
  1359. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  1360. package/dist/modes/interactive/theme/theme.js +10 -76
  1361. package/dist/modes/interactive/theme/theme.js.map +1 -1
  1362. package/dist/modes/interactive/usage-commands.d.ts.map +1 -1
  1363. package/dist/modes/interactive/usage-commands.js.map +1 -1
  1364. package/dist/modes/print-mode.d.ts.map +1 -1
  1365. package/dist/modes/print-mode.js +5 -22
  1366. package/dist/modes/print-mode.js.map +1 -1
  1367. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  1368. package/dist/modes/rpc/jsonl.js +1 -1
  1369. package/dist/modes/rpc/jsonl.js.map +1 -1
  1370. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  1371. package/dist/modes/rpc/rpc-client.js +7 -8
  1372. package/dist/modes/rpc/rpc-client.js.map +1 -1
  1373. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  1374. package/dist/modes/rpc/rpc-mode.js +5 -20
  1375. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  1376. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  1377. package/dist/modes/rpc/rpc-types.js.map +1 -1
  1378. package/dist/modes/termination-signals.d.ts +4 -0
  1379. package/dist/modes/termination-signals.d.ts.map +1 -0
  1380. package/dist/modes/termination-signals.js +21 -0
  1381. package/dist/modes/termination-signals.js.map +1 -0
  1382. package/dist/package-manager-cli.d.ts.map +1 -1
  1383. package/dist/package-manager-cli.js.map +1 -1
  1384. package/dist/utils/ansi-colors.d.ts +5 -0
  1385. package/dist/utils/ansi-colors.d.ts.map +1 -0
  1386. package/dist/utils/ansi-colors.js +38 -0
  1387. package/dist/utils/ansi-colors.js.map +1 -0
  1388. package/dist/utils/ansi.d.ts.map +1 -1
  1389. package/dist/utils/ansi.js.map +1 -1
  1390. package/dist/utils/changelog.d.ts.map +1 -1
  1391. package/dist/utils/changelog.js.map +1 -1
  1392. package/dist/utils/child-process.d.ts.map +1 -1
  1393. package/dist/utils/child-process.js.map +1 -1
  1394. package/dist/utils/clipboard-image.d.ts.map +1 -1
  1395. package/dist/utils/clipboard-image.js.map +1 -1
  1396. package/dist/utils/clipboard-native.d.ts.map +1 -1
  1397. package/dist/utils/clipboard-native.js.map +1 -1
  1398. package/dist/utils/clipboard.d.ts.map +1 -1
  1399. package/dist/utils/clipboard.js.map +1 -1
  1400. package/dist/utils/deprecation.d.ts.map +1 -1
  1401. package/dist/utils/deprecation.js.map +1 -1
  1402. package/dist/utils/exif-orientation.d.ts.map +1 -1
  1403. package/dist/utils/exif-orientation.js.map +1 -1
  1404. package/dist/utils/external-editor-command.d.ts.map +1 -1
  1405. package/dist/utils/external-editor-command.js.map +1 -1
  1406. package/dist/utils/frontmatter.d.ts.map +1 -1
  1407. package/dist/utils/frontmatter.js.map +1 -1
  1408. package/dist/utils/fs-watch.d.ts.map +1 -1
  1409. package/dist/utils/fs-watch.js.map +1 -1
  1410. package/dist/utils/git.d.ts.map +1 -1
  1411. package/dist/utils/git.js +20 -28
  1412. package/dist/utils/git.js.map +1 -1
  1413. package/dist/utils/highlight-js-languages.d.ts.map +1 -1
  1414. package/dist/utils/html.d.ts.map +1 -1
  1415. package/dist/utils/html.js.map +1 -1
  1416. package/dist/utils/image-convert.d.ts.map +1 -1
  1417. package/dist/utils/image-convert.js.map +1 -1
  1418. package/dist/utils/image-resize-core.d.ts.map +1 -1
  1419. package/dist/utils/image-resize-core.js.map +1 -1
  1420. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  1421. package/dist/utils/image-resize-worker.js.map +1 -1
  1422. package/dist/utils/image-resize.d.ts.map +1 -1
  1423. package/dist/utils/image-resize.js.map +1 -1
  1424. package/dist/utils/json.d.ts.map +1 -1
  1425. package/dist/utils/json.js.map +1 -1
  1426. package/dist/utils/mime.d.ts.map +1 -1
  1427. package/dist/utils/mime.js.map +1 -1
  1428. package/dist/utils/open-browser.d.ts.map +1 -1
  1429. package/dist/utils/open-browser.js.map +1 -1
  1430. package/dist/utils/paths.d.ts.map +1 -1
  1431. package/dist/utils/paths.js.map +1 -1
  1432. package/dist/utils/photon.d.ts.map +1 -1
  1433. package/dist/utils/photon.js.map +1 -1
  1434. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  1435. package/dist/utils/pi-user-agent.js.map +1 -1
  1436. package/dist/utils/platform.d.ts.map +1 -1
  1437. package/dist/utils/platform.js.map +1 -1
  1438. package/dist/utils/process-memory.d.ts.map +1 -1
  1439. package/dist/utils/process-memory.js.map +1 -1
  1440. package/dist/utils/safe-write-stream.d.ts.map +1 -1
  1441. package/dist/utils/safe-write-stream.js.map +1 -1
  1442. package/dist/utils/shell.d.ts.map +1 -1
  1443. package/dist/utils/shell.js.map +1 -1
  1444. package/dist/utils/sleep.d.ts.map +1 -1
  1445. package/dist/utils/sleep.js +2 -15
  1446. package/dist/utils/sleep.js.map +1 -1
  1447. package/dist/utils/stdin-events.d.ts +8 -0
  1448. package/dist/utils/stdin-events.d.ts.map +1 -0
  1449. package/dist/utils/stdin-events.js +19 -0
  1450. package/dist/utils/stdin-events.js.map +1 -0
  1451. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  1452. package/dist/utils/syntax-highlight.js +20 -13
  1453. package/dist/utils/syntax-highlight.js.map +1 -1
  1454. package/dist/utils/tools-manager.d.ts.map +1 -1
  1455. package/dist/utils/tools-manager.js.map +1 -1
  1456. package/dist/utils/version-check.d.ts.map +1 -1
  1457. package/dist/utils/version-check.js.map +1 -1
  1458. package/dist/utils/windows-self-update.d.ts.map +1 -1
  1459. package/dist/utils/windows-self-update.js.map +1 -1
  1460. package/dist/utils/work-directory.d.ts.map +1 -1
  1461. package/dist/utils/work-directory.js.map +1 -1
  1462. package/docs/compaction.md +11 -3
  1463. package/docs/sessions.md +6 -0
  1464. package/docs/settings.md +1 -1
  1465. package/docs/tool-repair.md +3 -0
  1466. package/docs/windows.md +29 -2
  1467. package/docs/work-directory.md +9 -1
  1468. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  1469. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  1470. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  1471. package/examples/extensions/sandbox/package-lock.json +2 -2
  1472. package/examples/extensions/sandbox/package.json +1 -1
  1473. package/examples/extensions/with-deps/package-lock.json +2 -2
  1474. package/examples/extensions/with-deps/package.json +1 -1
  1475. package/npm-shrinkwrap.json +16 -16
  1476. package/package.json +10 -10
  1477. package/dist/utils/streaming-lines.d.ts +0 -20
  1478. package/dist/utils/streaming-lines.d.ts.map +0 -1
  1479. package/dist/utils/streaming-lines.js +0 -79
  1480. package/dist/utils/streaming-lines.js.map +0 -1
@@ -5,5 +5,19 @@ import type { PathScope, PathScopeDecision } from "./contracts.ts";
5
5
  * remainder, ensuring that any symlinks in the existing path prefix are expanded.
6
6
  */
7
7
  export declare function safeRealpathSync(targetPath: string): string;
8
+ /**
9
+ * Stable lexical scope identity for durable planners. Windows drive and UNC paths are normalized
10
+ * case-insensitively even when a WSL process is only comparing them and cannot realpath them.
11
+ */
12
+ export declare function canonicalPathScopeIdentity(value: string): string;
13
+ /**
14
+ * Boundary-safe lexical containment for already-resolved paths and portable scope planning.
15
+ * Windows drive and UNC paths compare case-insensitively; native POSIX paths remain case-sensitive.
16
+ * This deliberately does not resolve symlinks — callers that authorize filesystem access must first
17
+ * use {@link safeRealpathSync}.
18
+ */
19
+ export declare function isPathWithinScope(targetPath: string, scopeRoot: string): boolean;
20
+ /** True when either scope contains the other, including an exact match. */
21
+ export declare function pathScopesOverlap(firstScope: string, secondScope: string): boolean;
8
22
  export declare function checkPathScope(scope: PathScope, targetPath: string): PathScopeDecision;
9
23
  //# sourceMappingURL=path-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-scope.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/path-scope.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOnE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3D;AAiDD,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAqGtF","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { PathScope, PathScopeDecision } from \"./contracts.ts\";\n\n// Bounds the symlink-following recursion in resolveSafely: a chain of dangling links is finite\n// in practice, and a genuine symlink cycle (a -> b -> a) must fail closed with a throw rather\n// than recurse forever.\nconst MAX_SYMLINK_HOPS = 32;\n\n/**\n * Resolves the real path of a target. If the target does not exist, it recursively\n * resolves the deepest existing parent directory and then appends the non-existent\n * remainder, ensuring that any symlinks in the existing path prefix are expanded.\n */\nexport function safeRealpathSync(targetPath: string): string {\n\treturn resolveSafely(path.resolve(targetPath), 0);\n}\n\nfunction resolveSafely(absolutePath: string, hops: number): string {\n\tif (hops > MAX_SYMLINK_HOPS) {\n\t\tthrow new Error(`safeRealpathSync: exceeded ${MAX_SYMLINK_HOPS} symlink hops resolving \"${absolutePath}\"`);\n\t}\n\n\tif (fs.existsSync(absolutePath)) {\n\t\treturn fs.realpathSync(absolutePath);\n\t}\n\n\t// existsSync FOLLOWS symlinks, so it reports false for a DANGLING link (the link exists but\n\t// its target does not) — the same as a path that plain doesn't exist at all. Without this\n\t// lstat check, a dangling leaf would fall straight into the lexical parent-join below, never\n\t// dereferencing the link itself. That would let a dangling symlink placed inside an allowed\n\t// root smuggle writes to wherever it points, since the write itself (e.g. writeFileSync) DOES\n\t// follow the link. lstatSync throws ENOENT for a path that truly doesn't exist anywhere in\n\t// the chain — that case falls through to the parent-recursion branch below, unchanged.\n\tlet lstat: ReturnType<typeof fs.lstatSync> | undefined;\n\ttry {\n\t\tlstat = fs.lstatSync(absolutePath);\n\t} catch {\n\t\tlstat = undefined;\n\t}\n\n\tif (lstat?.isSymbolicLink()) {\n\t\tconst linkTarget = fs.readlinkSync(absolutePath);\n\t\tconst resolvedParent = resolveSafely(path.dirname(absolutePath), hops + 1);\n\t\tconst resolvedTarget = path.isAbsolute(linkTarget)\n\t\t\t? path.resolve(linkTarget)\n\t\t\t: path.resolve(resolvedParent, linkTarget);\n\t\treturn resolveSafely(resolvedTarget, hops + 1);\n\t}\n\n\tconst parent = path.dirname(absolutePath);\n\t// Base case: if parent is the same as absolutePath, we've hit the root\n\tif (parent === absolutePath) {\n\t\treturn absolutePath;\n\t}\n\n\tconst resolvedParent = resolveSafely(parent, hops + 1);\n\treturn path.join(resolvedParent, path.basename(absolutePath));\n}\n\nfunction isPathInside(target: string, root: string): boolean {\n\tconst rootWithSep = root.endsWith(path.sep) ? root : `${root}${path.sep}`;\n\treturn target === root || target.startsWith(rootWithSep);\n}\n\nexport function checkPathScope(scope: PathScope, targetPath: string): PathScopeDecision {\n\tif (!targetPath) {\n\t\treturn {\n\t\t\tkind: \"missing\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"empty_path\",\n\t\t};\n\t}\n\n\tlet resolvedTarget: string;\n\ttry {\n\t\tresolvedTarget = safeRealpathSync(targetPath);\n\t} catch {\n\t\t// If we can't resolve the path at all (e.g. permission error), fail safely\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"unresolvable_target\",\n\t\t};\n\t}\n\n\tlet resolvedRoot: string;\n\ttry {\n\t\tresolvedRoot = safeRealpathSync(scope.root);\n\t} catch {\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"unresolvable_root\",\n\t\t};\n\t}\n\n\t// First, it must be inside the main root\n\tif (!isPathInside(resolvedTarget, resolvedRoot)) {\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\tresolvedPath: resolvedTarget,\n\t\t\treasonCode: \"outside_root\",\n\t\t};\n\t}\n\n\t// Check deniedPaths (overrides allowedPaths)\n\tif (scope.deniedPaths && scope.deniedPaths.length > 0) {\n\t\tfor (const denied of scope.deniedPaths) {\n\t\t\ttry {\n\t\t\t\tconst resolvedDenied = safeRealpathSync(denied);\n\t\t\t\tif (isPathInside(resolvedTarget, resolvedDenied)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: \"denied\",\n\t\t\t\t\t\tpath: targetPath,\n\t\t\t\t\t\tresolvedPath: resolvedTarget,\n\t\t\t\t\t\tmatchedRule: denied,\n\t\t\t\t\t\treasonCode: \"matches_denied_path\",\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t// Check allowedPaths\n\tif (scope.allowedPaths && scope.allowedPaths.length > 0) {\n\t\tlet isAllowed = false;\n\t\tlet matchedAllowed: string | undefined;\n\n\t\tfor (const allowed of scope.allowedPaths) {\n\t\t\ttry {\n\t\t\t\tconst resolvedAllowed = safeRealpathSync(allowed);\n\t\t\t\tif (isPathInside(resolvedTarget, resolvedAllowed)) {\n\t\t\t\t\tisAllowed = true;\n\t\t\t\t\tmatchedAllowed = allowed;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tif (!isAllowed) {\n\t\t\treturn {\n\t\t\t\tkind: \"outside\",\n\t\t\t\tpath: targetPath,\n\t\t\t\tresolvedPath: resolvedTarget,\n\t\t\t\treasonCode: \"outside_allowed_paths\",\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tkind: \"inside\",\n\t\t\tpath: targetPath,\n\t\t\tresolvedPath: resolvedTarget,\n\t\t\tmatchedRule: matchedAllowed,\n\t\t\treasonCode: \"inside_allowed_paths\",\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: \"inside\",\n\t\tpath: targetPath,\n\t\tresolvedPath: resolvedTarget,\n\t\tmatchedRule: scope.root,\n\t\treasonCode: \"inside_root\",\n\t};\n}\n"]}
1
+ {"version":3,"file":"path-scope.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/path-scope.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOnE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3D;AAyDD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAShF;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAElF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAqGtF"}
@@ -49,9 +49,40 @@ function resolveSafely(absolutePath, hops) {
49
49
  const resolvedParent = resolveSafely(parent, hops + 1);
50
50
  return path.join(resolvedParent, path.basename(absolutePath));
51
51
  }
52
- function isPathInside(target, root) {
53
- const rootWithSep = root.endsWith(path.sep) ? root : `${root}${path.sep}`;
54
- return target === root || target.startsWith(rootWithSep);
52
+ function usesWindowsPath(value) {
53
+ return /^[a-zA-Z]:([\\/]|$)/.test(value) || value.startsWith("\\\\") || value.startsWith("//");
54
+ }
55
+ function lexicalPathApi(...paths) {
56
+ return paths.some(usesWindowsPath) ? path.win32 : path.posix;
57
+ }
58
+ function canonicalPathScopeIdentityWithApi(value, pathApi) {
59
+ const resolved = pathApi.resolve(value);
60
+ return pathApi === path.win32 ? resolved.toLowerCase() : resolved;
61
+ }
62
+ /**
63
+ * Stable lexical scope identity for durable planners. Windows drive and UNC paths are normalized
64
+ * case-insensitively even when a WSL process is only comparing them and cannot realpath them.
65
+ */
66
+ export function canonicalPathScopeIdentity(value) {
67
+ return canonicalPathScopeIdentityWithApi(value, lexicalPathApi(value));
68
+ }
69
+ /**
70
+ * Boundary-safe lexical containment for already-resolved paths and portable scope planning.
71
+ * Windows drive and UNC paths compare case-insensitively; native POSIX paths remain case-sensitive.
72
+ * This deliberately does not resolve symlinks — callers that authorize filesystem access must first
73
+ * use {@link safeRealpathSync}.
74
+ */
75
+ export function isPathWithinScope(targetPath, scopeRoot) {
76
+ const pathApi = lexicalPathApi(targetPath, scopeRoot);
77
+ const target = canonicalPathScopeIdentityWithApi(targetPath, pathApi);
78
+ const root = canonicalPathScopeIdentityWithApi(scopeRoot, pathApi);
79
+ const relativePath = pathApi.relative(root, target);
80
+ return (relativePath === "" ||
81
+ (!relativePath.startsWith(`..${pathApi.sep}`) && relativePath !== ".." && !pathApi.isAbsolute(relativePath)));
82
+ }
83
+ /** True when either scope contains the other, including an exact match. */
84
+ export function pathScopesOverlap(firstScope, secondScope) {
85
+ return isPathWithinScope(firstScope, secondScope) || isPathWithinScope(secondScope, firstScope);
55
86
  }
56
87
  export function checkPathScope(scope, targetPath) {
57
88
  if (!targetPath) {
@@ -85,7 +116,7 @@ export function checkPathScope(scope, targetPath) {
85
116
  };
86
117
  }
87
118
  // First, it must be inside the main root
88
- if (!isPathInside(resolvedTarget, resolvedRoot)) {
119
+ if (!isPathWithinScope(resolvedTarget, resolvedRoot)) {
89
120
  return {
90
121
  kind: "outside",
91
122
  path: targetPath,
@@ -98,7 +129,7 @@ export function checkPathScope(scope, targetPath) {
98
129
  for (const denied of scope.deniedPaths) {
99
130
  try {
100
131
  const resolvedDenied = safeRealpathSync(denied);
101
- if (isPathInside(resolvedTarget, resolvedDenied)) {
132
+ if (isPathWithinScope(resolvedTarget, resolvedDenied)) {
102
133
  return {
103
134
  kind: "denied",
104
135
  path: targetPath,
@@ -118,7 +149,7 @@ export function checkPathScope(scope, targetPath) {
118
149
  for (const allowed of scope.allowedPaths) {
119
150
  try {
120
151
  const resolvedAllowed = safeRealpathSync(allowed);
121
- if (isPathInside(resolvedTarget, resolvedAllowed)) {
152
+ if (isPathWithinScope(resolvedTarget, resolvedAllowed)) {
122
153
  isAllowed = true;
123
154
  matchedAllowed = allowed;
124
155
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"path-scope.js","sourceRoot":"","sources":["../../../src/core/autonomy/path-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,+FAA+F;AAC/F,8FAA8F;AAC9F,wBAAwB;AACxB,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB,EAAU;IAC5D,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;AAAA,CAClD;AAED,SAAS,aAAa,CAAC,YAAoB,EAAE,IAAY,EAAU;IAClE,IAAI,IAAI,GAAG,gBAAgB,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,8BAA8B,gBAAgB,4BAA4B,YAAY,GAAG,CAAC,CAAC;IAC5G,CAAC;IAED,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,C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,CAAC;IAED,OAAO;QACN,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE,cAAc;QAC5B,WAAW,EAAE,KAAK,CAAC,IAAI;QACvB,UAAU,EAAE,aAAa;KACzB,CAAC;AAAA,CACF","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { PathScope, PathScopeDecision } from \"./contracts.ts\";\n\n// Bounds the symlink-following recursion in resolveSafely: a chain of dangling links is finite\n// in practice, and a genuine symlink cycle (a -> b -> a) must fail closed with a throw rather\n// than recurse forever.\nconst MAX_SYMLINK_HOPS = 32;\n\n/**\n * Resolves the real path of a target. If the target does not exist, it recursively\n * resolves the deepest existing parent directory and then appends the non-existent\n * remainder, ensuring that any symlinks in the existing path prefix are expanded.\n */\nexport function safeRealpathSync(targetPath: string): string {\n\treturn resolveSafely(path.resolve(targetPath), 0);\n}\n\nfunction resolveSafely(absolutePath: string, hops: number): string {\n\tif (hops > MAX_SYMLINK_HOPS) {\n\t\tthrow new Error(`safeRealpathSync: exceeded ${MAX_SYMLINK_HOPS} symlink hops resolving \"${absolutePath}\"`);\n\t}\n\n\tif (fs.existsSync(absolutePath)) {\n\t\treturn fs.realpathSync(absolutePath);\n\t}\n\n\t// existsSync FOLLOWS symlinks, so it reports false for a DANGLING link (the link exists but\n\t// its target does not) — the same as a path that plain doesn't exist at all. Without this\n\t// lstat check, a dangling leaf would fall straight into the lexical parent-join below, never\n\t// dereferencing the link itself. That would let a dangling symlink placed inside an allowed\n\t// root smuggle writes to wherever it points, since the write itself (e.g. writeFileSync) DOES\n\t// follow the link. lstatSync throws ENOENT for a path that truly doesn't exist anywhere in\n\t// the chain — that case falls through to the parent-recursion branch below, unchanged.\n\tlet lstat: ReturnType<typeof fs.lstatSync> | undefined;\n\ttry {\n\t\tlstat = fs.lstatSync(absolutePath);\n\t} catch {\n\t\tlstat = undefined;\n\t}\n\n\tif (lstat?.isSymbolicLink()) {\n\t\tconst linkTarget = fs.readlinkSync(absolutePath);\n\t\tconst resolvedParent = resolveSafely(path.dirname(absolutePath), hops + 1);\n\t\tconst resolvedTarget = path.isAbsolute(linkTarget)\n\t\t\t? path.resolve(linkTarget)\n\t\t\t: path.resolve(resolvedParent, linkTarget);\n\t\treturn resolveSafely(resolvedTarget, hops + 1);\n\t}\n\n\tconst parent = path.dirname(absolutePath);\n\t// Base case: if parent is the same as absolutePath, we've hit the root\n\tif (parent === absolutePath) {\n\t\treturn absolutePath;\n\t}\n\n\tconst resolvedParent = resolveSafely(parent, hops + 1);\n\treturn path.join(resolvedParent, path.basename(absolutePath));\n}\n\nfunction isPathInside(target: string, root: string): boolean {\n\tconst rootWithSep = root.endsWith(path.sep) ? root : `${root}${path.sep}`;\n\treturn target === root || target.startsWith(rootWithSep);\n}\n\nexport function checkPathScope(scope: PathScope, targetPath: string): PathScopeDecision {\n\tif (!targetPath) {\n\t\treturn {\n\t\t\tkind: \"missing\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"empty_path\",\n\t\t};\n\t}\n\n\tlet resolvedTarget: string;\n\ttry {\n\t\tresolvedTarget = safeRealpathSync(targetPath);\n\t} catch {\n\t\t// If we can't resolve the path at all (e.g. permission error), fail safely\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"unresolvable_target\",\n\t\t};\n\t}\n\n\tlet resolvedRoot: string;\n\ttry {\n\t\tresolvedRoot = safeRealpathSync(scope.root);\n\t} catch {\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"unresolvable_root\",\n\t\t};\n\t}\n\n\t// First, it must be inside the main root\n\tif (!isPathInside(resolvedTarget, resolvedRoot)) {\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\tresolvedPath: resolvedTarget,\n\t\t\treasonCode: \"outside_root\",\n\t\t};\n\t}\n\n\t// Check deniedPaths (overrides allowedPaths)\n\tif (scope.deniedPaths && scope.deniedPaths.length > 0) {\n\t\tfor (const denied of scope.deniedPaths) {\n\t\t\ttry {\n\t\t\t\tconst resolvedDenied = safeRealpathSync(denied);\n\t\t\t\tif (isPathInside(resolvedTarget, resolvedDenied)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: \"denied\",\n\t\t\t\t\t\tpath: targetPath,\n\t\t\t\t\t\tresolvedPath: resolvedTarget,\n\t\t\t\t\t\tmatchedRule: denied,\n\t\t\t\t\t\treasonCode: \"matches_denied_path\",\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t// Check allowedPaths\n\tif (scope.allowedPaths && scope.allowedPaths.length > 0) {\n\t\tlet isAllowed = false;\n\t\tlet matchedAllowed: string | undefined;\n\n\t\tfor (const allowed of scope.allowedPaths) {\n\t\t\ttry {\n\t\t\t\tconst resolvedAllowed = safeRealpathSync(allowed);\n\t\t\t\tif (isPathInside(resolvedTarget, resolvedAllowed)) {\n\t\t\t\t\tisAllowed = true;\n\t\t\t\t\tmatchedAllowed = allowed;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tif (!isAllowed) {\n\t\t\treturn {\n\t\t\t\tkind: \"outside\",\n\t\t\t\tpath: targetPath,\n\t\t\t\tresolvedPath: resolvedTarget,\n\t\t\t\treasonCode: \"outside_allowed_paths\",\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tkind: \"inside\",\n\t\t\tpath: targetPath,\n\t\t\tresolvedPath: resolvedTarget,\n\t\t\tmatchedRule: matchedAllowed,\n\t\t\treasonCode: \"inside_allowed_paths\",\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: \"inside\",\n\t\tpath: targetPath,\n\t\tresolvedPath: resolvedTarget,\n\t\tmatchedRule: scope.root,\n\t\treasonCode: \"inside_root\",\n\t};\n}\n"]}
1
+ {"version":3,"file":"path-scope.js","sourceRoot":"","sources":["../../../src/core/autonomy/path-scope.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AG,gBAAgB,CAAC,OAAO,CAAC,CAAC;gBAClD,IAAI,iBAAiB,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,CAAC;oBACxD,SAAS,GAAG,IAAI,CAAC;oBACjB,cAAc,GAAG,OAAO,CAAC;oBACzB,MAAM;gBACP,CAAC;YACF,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACX,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,OAAO;gBACN,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,UAAU;gBAChB,YAAY,EAAE,cAAc;gBAC5B,UAAU,EAAE,uBAAuB;aACnC,CAAC;QACH,CAAC;QAED,OAAO;YACN,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,UAAU;YAChB,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,cAAc;YAC3B,UAAU,EAAE,sBAAsB;SAClC,CAAC;IACH,CAAC;IAED,OAAO;QACN,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE,cAAc;QAC5B,WAAW,EAAE,KAAK,CAAC,IAAI;QACvB,UAAU,EAAE,aAAa;KACzB,CAAC;AACH,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { PathScope, PathScopeDecision } from \"./contracts.ts\";\n\n// Bounds the symlink-following recursion in resolveSafely: a chain of dangling links is finite\n// in practice, and a genuine symlink cycle (a -> b -> a) must fail closed with a throw rather\n// than recurse forever.\nconst MAX_SYMLINK_HOPS = 32;\n\n/**\n * Resolves the real path of a target. If the target does not exist, it recursively\n * resolves the deepest existing parent directory and then appends the non-existent\n * remainder, ensuring that any symlinks in the existing path prefix are expanded.\n */\nexport function safeRealpathSync(targetPath: string): string {\n\treturn resolveSafely(path.resolve(targetPath), 0);\n}\n\nfunction resolveSafely(absolutePath: string, hops: number): string {\n\tif (hops > MAX_SYMLINK_HOPS) {\n\t\tthrow new Error(`safeRealpathSync: exceeded ${MAX_SYMLINK_HOPS} symlink hops resolving \"${absolutePath}\"`);\n\t}\n\n\tif (fs.existsSync(absolutePath)) {\n\t\treturn fs.realpathSync(absolutePath);\n\t}\n\n\t// existsSync FOLLOWS symlinks, so it reports false for a DANGLING link (the link exists but\n\t// its target does not) — the same as a path that plain doesn't exist at all. Without this\n\t// lstat check, a dangling leaf would fall straight into the lexical parent-join below, never\n\t// dereferencing the link itself. That would let a dangling symlink placed inside an allowed\n\t// root smuggle writes to wherever it points, since the write itself (e.g. writeFileSync) DOES\n\t// follow the link. lstatSync throws ENOENT for a path that truly doesn't exist anywhere in\n\t// the chain — that case falls through to the parent-recursion branch below, unchanged.\n\tlet lstat: ReturnType<typeof fs.lstatSync> | undefined;\n\ttry {\n\t\tlstat = fs.lstatSync(absolutePath);\n\t} catch {\n\t\tlstat = undefined;\n\t}\n\n\tif (lstat?.isSymbolicLink()) {\n\t\tconst linkTarget = fs.readlinkSync(absolutePath);\n\t\tconst resolvedParent = resolveSafely(path.dirname(absolutePath), hops + 1);\n\t\tconst resolvedTarget = path.isAbsolute(linkTarget)\n\t\t\t? path.resolve(linkTarget)\n\t\t\t: path.resolve(resolvedParent, linkTarget);\n\t\treturn resolveSafely(resolvedTarget, hops + 1);\n\t}\n\n\tconst parent = path.dirname(absolutePath);\n\t// Base case: if parent is the same as absolutePath, we've hit the root\n\tif (parent === absolutePath) {\n\t\treturn absolutePath;\n\t}\n\n\tconst resolvedParent = resolveSafely(parent, hops + 1);\n\treturn path.join(resolvedParent, path.basename(absolutePath));\n}\n\nfunction usesWindowsPath(value: string): boolean {\n\treturn /^[a-zA-Z]:([\\\\/]|$)/.test(value) || value.startsWith(\"\\\\\\\\\") || value.startsWith(\"//\");\n}\n\nfunction lexicalPathApi(...paths: readonly string[]): typeof path.posix | typeof path.win32 {\n\treturn paths.some(usesWindowsPath) ? path.win32 : path.posix;\n}\n\nfunction canonicalPathScopeIdentityWithApi(value: string, pathApi: typeof path.posix | typeof path.win32): string {\n\tconst resolved = pathApi.resolve(value);\n\treturn pathApi === path.win32 ? resolved.toLowerCase() : resolved;\n}\n\n/**\n * Stable lexical scope identity for durable planners. Windows drive and UNC paths are normalized\n * case-insensitively even when a WSL process is only comparing them and cannot realpath them.\n */\nexport function canonicalPathScopeIdentity(value: string): string {\n\treturn canonicalPathScopeIdentityWithApi(value, lexicalPathApi(value));\n}\n\n/**\n * Boundary-safe lexical containment for already-resolved paths and portable scope planning.\n * Windows drive and UNC paths compare case-insensitively; native POSIX paths remain case-sensitive.\n * This deliberately does not resolve symlinks — callers that authorize filesystem access must first\n * use {@link safeRealpathSync}.\n */\nexport function isPathWithinScope(targetPath: string, scopeRoot: string): boolean {\n\tconst pathApi = lexicalPathApi(targetPath, scopeRoot);\n\tconst target = canonicalPathScopeIdentityWithApi(targetPath, pathApi);\n\tconst root = canonicalPathScopeIdentityWithApi(scopeRoot, pathApi);\n\tconst relativePath = pathApi.relative(root, target);\n\treturn (\n\t\trelativePath === \"\" ||\n\t\t(!relativePath.startsWith(`..${pathApi.sep}`) && relativePath !== \"..\" && !pathApi.isAbsolute(relativePath))\n\t);\n}\n\n/** True when either scope contains the other, including an exact match. */\nexport function pathScopesOverlap(firstScope: string, secondScope: string): boolean {\n\treturn isPathWithinScope(firstScope, secondScope) || isPathWithinScope(secondScope, firstScope);\n}\n\nexport function checkPathScope(scope: PathScope, targetPath: string): PathScopeDecision {\n\tif (!targetPath) {\n\t\treturn {\n\t\t\tkind: \"missing\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"empty_path\",\n\t\t};\n\t}\n\n\tlet resolvedTarget: string;\n\ttry {\n\t\tresolvedTarget = safeRealpathSync(targetPath);\n\t} catch {\n\t\t// If we can't resolve the path at all (e.g. permission error), fail safely\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"unresolvable_target\",\n\t\t};\n\t}\n\n\tlet resolvedRoot: string;\n\ttry {\n\t\tresolvedRoot = safeRealpathSync(scope.root);\n\t} catch {\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\treasonCode: \"unresolvable_root\",\n\t\t};\n\t}\n\n\t// First, it must be inside the main root\n\tif (!isPathWithinScope(resolvedTarget, resolvedRoot)) {\n\t\treturn {\n\t\t\tkind: \"outside\",\n\t\t\tpath: targetPath,\n\t\t\tresolvedPath: resolvedTarget,\n\t\t\treasonCode: \"outside_root\",\n\t\t};\n\t}\n\n\t// Check deniedPaths (overrides allowedPaths)\n\tif (scope.deniedPaths && scope.deniedPaths.length > 0) {\n\t\tfor (const denied of scope.deniedPaths) {\n\t\t\ttry {\n\t\t\t\tconst resolvedDenied = safeRealpathSync(denied);\n\t\t\t\tif (isPathWithinScope(resolvedTarget, resolvedDenied)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: \"denied\",\n\t\t\t\t\t\tpath: targetPath,\n\t\t\t\t\t\tresolvedPath: resolvedTarget,\n\t\t\t\t\t\tmatchedRule: denied,\n\t\t\t\t\t\treasonCode: \"matches_denied_path\",\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t// Check allowedPaths\n\tif (scope.allowedPaths && scope.allowedPaths.length > 0) {\n\t\tlet isAllowed = false;\n\t\tlet matchedAllowed: string | undefined;\n\n\t\tfor (const allowed of scope.allowedPaths) {\n\t\t\ttry {\n\t\t\t\tconst resolvedAllowed = safeRealpathSync(allowed);\n\t\t\t\tif (isPathWithinScope(resolvedTarget, resolvedAllowed)) {\n\t\t\t\t\tisAllowed = true;\n\t\t\t\t\tmatchedAllowed = allowed;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tif (!isAllowed) {\n\t\t\treturn {\n\t\t\t\tkind: \"outside\",\n\t\t\t\tpath: targetPath,\n\t\t\t\tresolvedPath: resolvedTarget,\n\t\t\t\treasonCode: \"outside_allowed_paths\",\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tkind: \"inside\",\n\t\t\tpath: targetPath,\n\t\t\tresolvedPath: resolvedTarget,\n\t\t\tmatchedRule: matchedAllowed,\n\t\t\treasonCode: \"inside_allowed_paths\",\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: \"inside\",\n\t\tpath: targetPath,\n\t\tresolvedPath: resolvedTarget,\n\t\tmatchedRule: scope.root,\n\t\treasonCode: \"inside_root\",\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"risk-assessment.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/risk-assessment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export { assessOperationRisk } from \"../risk-classifier.ts\";\n"]}
1
+ {"version":3,"file":"risk-assessment.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/risk-assessment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"session-lane-record.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/session-lane-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAIN,KAAK,sBAAsB,EAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7F,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AASrF,wBAAgB,wBAAwB,CACvC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,mBAAmB,CAAC,EACzD,MAAM,EAAE,UAAU,GAChB,MAAM,CAER;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,UAAU,EAAE,CAErF;AAED,uFAAuF;AACvF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,UAAU,EAAE,CAI3F","sourcesContent":["import type { SessionEntry, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport {\n\tappendSessionSnapshot,\n\tgetSessionSnapshots,\n\ttype SessionSnapshotCodec,\n\ttype SessionSnapshotPayload,\n} from \"../session-snapshot.ts\";\nimport { cloneLaneRecordForStorage, isLaneRecord, type LaneRecord } from \"./lane-tracker.ts\";\n\nexport const LANE_RECORD_CUSTOM_TYPE = \"lane_record\";\n\nexport type LaneRecordSnapshotPayload = SessionSnapshotPayload<\"record\", LaneRecord>;\n\nconst LANE_RECORD_SNAPSHOT_CODEC: SessionSnapshotCodec<LaneRecord, \"record\"> = {\n\tcustomType: LANE_RECORD_CUSTOM_TYPE,\n\tvalueKey: \"record\",\n\tisValue: isLaneRecord,\n\tclone: cloneLaneRecordForStorage,\n};\n\nexport function appendLaneRecordSnapshot(\n\tsessionManager: Pick<SessionManager, \"appendCustomEntry\">,\n\trecord: LaneRecord,\n): string {\n\treturn appendSessionSnapshot(sessionManager, LANE_RECORD_SNAPSHOT_CODEC, record);\n}\n\nexport function getLaneRecordSnapshots(entries: readonly SessionEntry[]): LaneRecord[] {\n\treturn getSessionSnapshots(entries, LANE_RECORD_SNAPSHOT_CODEC);\n}\n\n/** Latest durable projection per logical lane id, preserving first-seen lane order. */\nexport function getLatestLaneRecordSnapshots(entries: readonly SessionEntry[]): LaneRecord[] {\n\tconst latest = new Map<string, LaneRecord>();\n\tfor (const record of getLaneRecordSnapshots(entries)) latest.set(record.laneId, record);\n\treturn [...latest.values()].map(cloneLaneRecordForStorage);\n}\n"]}
1
+ {"version":3,"file":"session-lane-record.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/session-lane-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAIN,KAAK,sBAAsB,EAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7F,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AASrF,wBAAgB,wBAAwB,CACvC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,mBAAmB,CAAC,EACzD,MAAM,EAAE,UAAU,GAChB,MAAM,CAER;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,UAAU,EAAE,CAErF;AAED,uFAAuF;AACvF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,UAAU,EAAE,CAI3F"}
@@ -1 +1 @@
1
- {"version":3,"file":"session-lane-record.js","sourceRoot":"","sources":["../../../src/core/autonomy/session-lane-record.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,mBAAmB,GAGnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAE7F,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAIrD,MAAM,0BAA0B,GAA+C;IAC9E,UAAU,EAAE,uBAAuB;IACnC,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,yBAAyB;CAChC,CAAC;AAEF,MAAM,UAAU,wBAAwB,CACvC,cAAyD,EACzD,MAAkB,EACT;IACT,OAAO,qBAAqB,CAAC,cAAc,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC;AAAA,CACjF;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAgC,EAAgB;IACtF,OAAO,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;AAAA,CAChE;AAED,uFAAuF;AACvF,MAAM,UAAU,4BAA4B,CAAC,OAAgC,EAAgB;IAC5F,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC7C,KAAK,MAAM,MAAM,IAAI,sBAAsB,CAAC,OAAO,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAAA,CAC3D","sourcesContent":["import type { SessionEntry, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport {\n\tappendSessionSnapshot,\n\tgetSessionSnapshots,\n\ttype SessionSnapshotCodec,\n\ttype SessionSnapshotPayload,\n} from \"../session-snapshot.ts\";\nimport { cloneLaneRecordForStorage, isLaneRecord, type LaneRecord } from \"./lane-tracker.ts\";\n\nexport const LANE_RECORD_CUSTOM_TYPE = \"lane_record\";\n\nexport type LaneRecordSnapshotPayload = SessionSnapshotPayload<\"record\", LaneRecord>;\n\nconst LANE_RECORD_SNAPSHOT_CODEC: SessionSnapshotCodec<LaneRecord, \"record\"> = {\n\tcustomType: LANE_RECORD_CUSTOM_TYPE,\n\tvalueKey: \"record\",\n\tisValue: isLaneRecord,\n\tclone: cloneLaneRecordForStorage,\n};\n\nexport function appendLaneRecordSnapshot(\n\tsessionManager: Pick<SessionManager, \"appendCustomEntry\">,\n\trecord: LaneRecord,\n): string {\n\treturn appendSessionSnapshot(sessionManager, LANE_RECORD_SNAPSHOT_CODEC, record);\n}\n\nexport function getLaneRecordSnapshots(entries: readonly SessionEntry[]): LaneRecord[] {\n\treturn getSessionSnapshots(entries, LANE_RECORD_SNAPSHOT_CODEC);\n}\n\n/** Latest durable projection per logical lane id, preserving first-seen lane order. */\nexport function getLatestLaneRecordSnapshots(entries: readonly SessionEntry[]): LaneRecord[] {\n\tconst latest = new Map<string, LaneRecord>();\n\tfor (const record of getLaneRecordSnapshots(entries)) latest.set(record.laneId, record);\n\treturn [...latest.values()].map(cloneLaneRecordForStorage);\n}\n"]}
1
+ {"version":3,"file":"session-lane-record.js","sourceRoot":"","sources":["../../../src/core/autonomy/session-lane-record.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,mBAAmB,GAGnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAE7F,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAIrD,MAAM,0BAA0B,GAA+C;IAC9E,UAAU,EAAE,uBAAuB;IACnC,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,yBAAyB;CAChC,CAAC;AAEF,MAAM,UAAU,wBAAwB,CACvC,cAAyD,EACzD,MAAkB;IAElB,OAAO,qBAAqB,CAAC,cAAc,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAgC;IACtE,OAAO,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;AACjE,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,4BAA4B,CAAC,OAAgC;IAC5E,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC7C,KAAK,MAAM,MAAM,IAAI,sBAAsB,CAAC,OAAO,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import type { SessionEntry, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport {\n\tappendSessionSnapshot,\n\tgetSessionSnapshots,\n\ttype SessionSnapshotCodec,\n\ttype SessionSnapshotPayload,\n} from \"../session-snapshot.ts\";\nimport { cloneLaneRecordForStorage, isLaneRecord, type LaneRecord } from \"./lane-tracker.ts\";\n\nexport const LANE_RECORD_CUSTOM_TYPE = \"lane_record\";\n\nexport type LaneRecordSnapshotPayload = SessionSnapshotPayload<\"record\", LaneRecord>;\n\nconst LANE_RECORD_SNAPSHOT_CODEC: SessionSnapshotCodec<LaneRecord, \"record\"> = {\n\tcustomType: LANE_RECORD_CUSTOM_TYPE,\n\tvalueKey: \"record\",\n\tisValue: isLaneRecord,\n\tclone: cloneLaneRecordForStorage,\n};\n\nexport function appendLaneRecordSnapshot(\n\tsessionManager: Pick<SessionManager, \"appendCustomEntry\">,\n\trecord: LaneRecord,\n): string {\n\treturn appendSessionSnapshot(sessionManager, LANE_RECORD_SNAPSHOT_CODEC, record);\n}\n\nexport function getLaneRecordSnapshots(entries: readonly SessionEntry[]): LaneRecord[] {\n\treturn getSessionSnapshots(entries, LANE_RECORD_SNAPSHOT_CODEC);\n}\n\n/** Latest durable projection per logical lane id, preserving first-seen lane order. */\nexport function getLatestLaneRecordSnapshots(entries: readonly SessionEntry[]): LaneRecord[] {\n\tconst latest = new Map<string, LaneRecord>();\n\tfor (const record of getLaneRecordSnapshots(entries)) latest.set(record.laneId, record);\n\treturn [...latest.values()].map(cloneLaneRecordForStorage);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACtC,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,UAAU,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAA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Summary } from \"../cost/cost-summary.ts\";\nimport type { GateOutcomeKind } from \"./contracts.ts\";\n\nexport interface AutonomyStatusSnapshot {\n\tlatestRoute?: { tier: string; reasonCode: string; risk?: string };\n\tlatestGate?: { outcome: string; gate: string; reasonCode: string };\n\tcostSummary?: SessionCostSummary;\n\tactiveGoal?: { goalId: string; status: string; openRequirements?: number; stallTurns?: number };\n\tactiveLaneCount?: number;\n}\n\n/**\n * One bounded entry in AgentSession's gate-outcome history (G8). Codes/ids only — never the gate's\n * human-facing `message`. The most recent entry is the tail; `at` is an ISO timestamp.\n */\nexport interface GateOutcomeHistoryEntry {\n\toutcome: GateOutcomeKind;\n\tgate: string;\n\treasonCode: string;\n\tat: string;\n}\n\nexport interface DiagnosticEntry {\n\ttitle: string;\n\tsummary?: string;\n\treasonCode?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface AutonomyDiagnosticSnapshot {\n\troutes?: readonly DiagnosticEntry[];\n\tgates?: readonly DiagnosticEntry[];\n\tcosts?: readonly DiagnosticEntry[];\n\tresearch?: readonly DiagnosticEntry[];\n\tdelegation?: readonly DiagnosticEntry[];\n\tlearning?: readonly DiagnosticEntry[];\n\tgoals?: readonly DiagnosticEntry[];\n\tprocessMemory?: readonly DiagnosticEntry[];\n}\n\nconst REDACTED = \"[REDACTED]\";\nconst CIRCULAR = \"[Circular]\";\nconst MAX_STRING_LENGTH = 200;\nconst SENSITIVE_KEYS = [\"token\", \"secret\", \"key\", \"credential\", \"password\", \"authorization\"];\nconst SENSITIVE_VALUE_REGEX = /bearer\\s+[\\w\\-._]+|api[-_]?key[-_]?[\\w\\-._]+|sk-[\\w\\-._]+/i;\n\nfunction redactAndTruncateString(value: string): string {\n\tif (SENSITIVE_VALUE_REGEX.test(value)) return REDACTED;\n\tif (value.length <= MAX_STRING_LENGTH) return value;\n\treturn `${value.slice(0, MAX_STRING_LENGTH - 1)}…`;\n}\n\nfunction isSensitiveKey(key: string): boolean {\n\tconst lowerKey = key.toLowerCase();\n\treturn SENSITIVE_KEYS.some((sensitiveKey) => lowerKey.includes(sensitiveKey));\n}\n\nfunction sanitizeMetadataValue(value: unknown, seen: WeakSet<object>): unknown {\n\tif (typeof value === \"string\") return redactAndTruncateString(value);\n\tif (typeof value !== \"object\" || value === null) return value;\n\tif (seen.has(value)) return CIRCULAR;\n\tif (Array.isArray(value)) {\n\t\tseen.add(value);\n\t\treturn value.map((item) => sanitizeMetadataValue(item, seen));\n\t}\n\treturn sanitizeMetadata(value as Record<string, unknown>, seen);\n}\n\nfunction sanitizeMetadata(\n\tobj: Record<string, unknown>,\n\tseen: WeakSet<object> = new WeakSet(),\n): Record<string, unknown> {\n\tif (seen.has(obj)) return { value: CIRCULAR };\n\tseen.add(obj);\n\tconst result: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tresult[key] = isSensitiveKey(key) ? REDACTED : sanitizeMetadataValue(value, seen);\n\t}\n\treturn result;\n}\n\nexport function formatAutonomyStatus(args: AutonomyStatusSnapshot): string {\n\tconst parts: string[] = [];\n\n\tif (args.latestRoute) {\n\t\tconst risk = args.latestRoute.risk ? ` (${redactAndTruncateString(args.latestRoute.risk)})` : \"\";\n\t\tparts.push(\n\t\t\t`Route: ${redactAndTruncateString(args.latestRoute.tier)}${risk} - ${redactAndTruncateString(args.latestRoute.reasonCode)}`,\n\t\t);\n\t}\n\n\tif (args.latestGate) {\n\t\tparts.push(\n\t\t\t`Gate: ${redactAndTruncateString(args.latestGate.gate)} = ${redactAndTruncateString(args.latestGate.outcome)} (${redactAndTruncateString(args.latestGate.reasonCode)})`,\n\t\t);\n\t}\n\n\tif (args.costSummary) {\n\t\tparts.push(`Costs: ${formatStatusCostSummary(args.costSummary)}`);\n\t}\n\n\tif (args.activeGoal) {\n\t\tconst goal = args.activeGoal;\n\t\tconst requirements = goal.openRequirements !== undefined ? `, open reqs: ${goal.openRequirements}` : \"\";\n\t\tconst stalls = goal.stallTurns !== undefined ? `, stalls: ${goal.stallTurns}` : \"\";\n\t\tparts.push(\n\t\t\t`Goal [${redactAndTruncateString(goal.goalId)}]: ${redactAndTruncateString(goal.status)}${requirements}${stalls}`,\n\t\t);\n\t}\n\n\tif (args.activeLaneCount !== undefined) {\n\t\tparts.push(`Lanes: ${args.activeLaneCount}`);\n\t}\n\n\tif (parts.length === 0) return \"Autonomy: idle\";\n\treturn parts.join(\" | \");\n}\n\nfunction formatDiagnosticSection(name: string, entries?: readonly DiagnosticEntry[]): string | undefined {\n\tif (!entries || entries.length === 0) return undefined;\n\n\tconst lines: string[] = [`--- ${name} ---`];\n\tfor (const entry of entries) {\n\t\tlet header = `- ${redactAndTruncateString(entry.title)}`;\n\t\tif (entry.reasonCode) header += ` [${redactAndTruncateString(entry.reasonCode)}]`;\n\t\tlines.push(header);\n\n\t\tif (entry.summary) {\n\t\t\tlines.push(` Summary: ${redactAndTruncateString(entry.summary)}`);\n\t\t}\n\n\t\tif (entry.metadata) {\n\t\t\tlines.push(` Metadata: ${JSON.stringify(sanitizeMetadata(entry.metadata))}`);\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatAutonomyDiagnostics(args: AutonomyDiagnosticSnapshot): string {\n\tconst sections = [\n\t\tformatDiagnosticSection(\"Routes\", args.routes),\n\t\tformatDiagnosticSection(\"Gates\", args.gates),\n\t\tformatDiagnosticSection(\"Costs\", args.costs),\n\t\tformatDiagnosticSection(\"Research\", args.research),\n\t\tformatDiagnosticSection(\"Delegation\", args.delegation),\n\t\tformatDiagnosticSection(\"Learning\", args.learning),\n\t\tformatDiagnosticSection(\"Goals\", args.goals),\n\t\tformatDiagnosticSection(\"Process Memory\", args.processMemory),\n\t].filter((section): section is string => Boolean(section));\n\n\tif (sections.length === 0) return \"No diagnostics available.\";\n\treturn sections.join(\"\\n\\n\");\n}\n"]}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,kBAAk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C,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAgC,EAAU;IACnF,MAAM,QAAQ,GAAG;QAChB,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC;QAC9C,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;QAC5C,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;QAC5C,uBAAuB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC;QAClD,uBAAuB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;QACtD,uBAAuB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC;QAClD,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;QAC5C,uBAAuB,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,CAAC;KAC7D,CAAC,MAAM,CAAC,CAAC,OAAO,EAAqB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,2BAA2B,CAAC;IAC9D,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAAA,CAC7B","sourcesContent":["import { formatStatusCostSummary, type SessionCostSummary } from \"../cost/cost-summary.ts\";\nimport type { GateOutcomeKind } from \"./contracts.ts\";\n\nexport interface AutonomyStatusSnapshot {\n\tlatestRoute?: { tier: string; reasonCode: string; risk?: string };\n\tlatestGate?: { outcome: string; gate: string; reasonCode: string };\n\tcostSummary?: SessionCostSummary;\n\tactiveGoal?: { goalId: string; status: string; openRequirements?: number; stallTurns?: number };\n\tactiveLaneCount?: number;\n}\n\n/**\n * One bounded entry in AgentSession's gate-outcome history (G8). Codes/ids only — never the gate's\n * human-facing `message`. The most recent entry is the tail; `at` is an ISO timestamp.\n */\nexport interface GateOutcomeHistoryEntry {\n\toutcome: GateOutcomeKind;\n\tgate: string;\n\treasonCode: string;\n\tat: string;\n}\n\nexport interface DiagnosticEntry {\n\ttitle: string;\n\tsummary?: string;\n\treasonCode?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface AutonomyDiagnosticSnapshot {\n\troutes?: readonly DiagnosticEntry[];\n\tgates?: readonly DiagnosticEntry[];\n\tcosts?: readonly DiagnosticEntry[];\n\tresearch?: readonly DiagnosticEntry[];\n\tdelegation?: readonly DiagnosticEntry[];\n\tlearning?: readonly DiagnosticEntry[];\n\tgoals?: readonly DiagnosticEntry[];\n\tprocessMemory?: readonly DiagnosticEntry[];\n}\n\nconst REDACTED = \"[REDACTED]\";\nconst CIRCULAR = \"[Circular]\";\nconst MAX_STRING_LENGTH = 200;\nconst SENSITIVE_KEYS = [\"token\", \"secret\", \"key\", \"credential\", \"password\", \"authorization\"];\nconst SENSITIVE_VALUE_REGEX = /bearer\\s+[\\w\\-._]+|api[-_]?key[-_]?[\\w\\-._]+|sk-[\\w\\-._]+/i;\n\nfunction redactAndTruncateString(value: string): string {\n\tif (SENSITIVE_VALUE_REGEX.test(value)) return REDACTED;\n\tif (value.length <= MAX_STRING_LENGTH) return value;\n\treturn `${value.slice(0, MAX_STRING_LENGTH - 1)}…`;\n}\n\nfunction isSensitiveKey(key: string): boolean {\n\tconst lowerKey = key.toLowerCase();\n\treturn SENSITIVE_KEYS.some((sensitiveKey) => lowerKey.includes(sensitiveKey));\n}\n\nfunction sanitizeMetadataValue(value: unknown, seen: WeakSet<object>): unknown {\n\tif (typeof value === \"string\") return redactAndTruncateString(value);\n\tif (typeof value !== \"object\" || value === null) return value;\n\tif (seen.has(value)) return CIRCULAR;\n\tif (Array.isArray(value)) {\n\t\tseen.add(value);\n\t\treturn value.map((item) => sanitizeMetadataValue(item, seen));\n\t}\n\treturn sanitizeMetadata(value as Record<string, unknown>, seen);\n}\n\nfunction sanitizeMetadata(\n\tobj: Record<string, unknown>,\n\tseen: WeakSet<object> = new WeakSet(),\n): Record<string, unknown> {\n\tif (seen.has(obj)) return { value: CIRCULAR };\n\tseen.add(obj);\n\tconst result: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tresult[key] = isSensitiveKey(key) ? REDACTED : sanitizeMetadataValue(value, seen);\n\t}\n\treturn result;\n}\n\nexport function formatAutonomyStatus(args: AutonomyStatusSnapshot): string {\n\tconst parts: string[] = [];\n\n\tif (args.latestRoute) {\n\t\tconst risk = args.latestRoute.risk ? ` (${redactAndTruncateString(args.latestRoute.risk)})` : \"\";\n\t\tparts.push(\n\t\t\t`Route: ${redactAndTruncateString(args.latestRoute.tier)}${risk} - ${redactAndTruncateString(args.latestRoute.reasonCode)}`,\n\t\t);\n\t}\n\n\tif (args.latestGate) {\n\t\tparts.push(\n\t\t\t`Gate: ${redactAndTruncateString(args.latestGate.gate)} = ${redactAndTruncateString(args.latestGate.outcome)} (${redactAndTruncateString(args.latestGate.reasonCode)})`,\n\t\t);\n\t}\n\n\tif (args.costSummary) {\n\t\tparts.push(`Costs: ${formatStatusCostSummary(args.costSummary)}`);\n\t}\n\n\tif (args.activeGoal) {\n\t\tconst goal = args.activeGoal;\n\t\tconst requirements = goal.openRequirements !== undefined ? `, open reqs: ${goal.openRequirements}` : \"\";\n\t\tconst stalls = goal.stallTurns !== undefined ? `, stalls: ${goal.stallTurns}` : \"\";\n\t\tparts.push(\n\t\t\t`Goal [${redactAndTruncateString(goal.goalId)}]: ${redactAndTruncateString(goal.status)}${requirements}${stalls}`,\n\t\t);\n\t}\n\n\tif (args.activeLaneCount !== undefined) {\n\t\tparts.push(`Lanes: ${args.activeLaneCount}`);\n\t}\n\n\tif (parts.length === 0) return \"Autonomy: idle\";\n\treturn parts.join(\" | \");\n}\n\nfunction formatDiagnosticSection(name: string, entries?: readonly DiagnosticEntry[]): string | undefined {\n\tif (!entries || entries.length === 0) return undefined;\n\n\tconst lines: string[] = [`--- ${name} ---`];\n\tfor (const entry of entries) {\n\t\tlet header = `- ${redactAndTruncateString(entry.title)}`;\n\t\tif (entry.reasonCode) header += ` [${redactAndTruncateString(entry.reasonCode)}]`;\n\t\tlines.push(header);\n\n\t\tif (entry.summary) {\n\t\t\tlines.push(` Summary: ${redactAndTruncateString(entry.summary)}`);\n\t\t}\n\n\t\tif (entry.metadata) {\n\t\t\tlines.push(` Metadata: ${JSON.stringify(sanitizeMetadata(entry.metadata))}`);\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatAutonomyDiagnostics(args: AutonomyDiagnosticSnapshot): string {\n\tconst sections = [\n\t\tformatDiagnosticSection(\"Routes\", args.routes),\n\t\tformatDiagnosticSection(\"Gates\", args.gates),\n\t\tformatDiagnosticSection(\"Costs\", args.costs),\n\t\tformatDiagnosticSection(\"Research\", args.research),\n\t\tformatDiagnosticSection(\"Delegation\", args.delegation),\n\t\tformatDiagnosticSection(\"Learning\", args.learning),\n\t\tformatDiagnosticSection(\"Goals\", args.goals),\n\t\tformatDiagnosticSection(\"Process Memory\", args.processMemory),\n\t].filter((section): section is string => Boolean(section));\n\n\tif (sections.length === 0) return \"No diagnostics available.\";\n\treturn sections.join(\"\\n\\n\");\n}\n"]}
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/core/autonomy/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAA2B,MAAM,yBAAyB,CAAC;AAwC3F,MAAM,QAAQ,GAAG,YAAY,CAAC;AAC9B,MAAM,QAAQ,GAAG,YAAY,CAAC;AAC9B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AAC7F,MAAM,qBAAqB,GAAG,4DAA4D,CAAC;AAE3F,SAAS,uBAAuB,CAAC,KAAa;IAC7C,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,Q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nimport type { GateOutcomeKind } from \"./contracts.ts\";\n\nexport interface AutonomyStatusSnapshot {\n\tlatestRoute?: { tier: string; reasonCode: string; risk?: string };\n\tlatestGate?: { outcome: string; gate: string; reasonCode: string };\n\tcostSummary?: SessionCostSummary;\n\tactiveGoal?: { goalId: string; status: string; openRequirements?: number; stallTurns?: number };\n\tactiveLaneCount?: number;\n}\n\n/**\n * One bounded entry in AgentSession's gate-outcome history (G8). Codes/ids only — never the gate's\n * human-facing `message`. The most recent entry is the tail; `at` is an ISO timestamp.\n */\nexport interface GateOutcomeHistoryEntry {\n\toutcome: GateOutcomeKind;\n\tgate: string;\n\treasonCode: string;\n\tat: string;\n}\n\nexport interface DiagnosticEntry {\n\ttitle: string;\n\tsummary?: string;\n\treasonCode?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface AutonomyDiagnosticSnapshot {\n\troutes?: readonly DiagnosticEntry[];\n\tgates?: readonly DiagnosticEntry[];\n\tcosts?: readonly DiagnosticEntry[];\n\tresearch?: readonly DiagnosticEntry[];\n\tdelegation?: readonly DiagnosticEntry[];\n\tlearning?: readonly DiagnosticEntry[];\n\tgoals?: readonly DiagnosticEntry[];\n\tprocessMemory?: readonly DiagnosticEntry[];\n}\n\nconst REDACTED = \"[REDACTED]\";\nconst CIRCULAR = \"[Circular]\";\nconst MAX_STRING_LENGTH = 200;\nconst SENSITIVE_KEYS = [\"token\", \"secret\", \"key\", \"credential\", \"password\", \"authorization\"];\nconst SENSITIVE_VALUE_REGEX = /bearer\\s+[\\w\\-._]+|api[-_]?key[-_]?[\\w\\-._]+|sk-[\\w\\-._]+/i;\n\nfunction redactAndTruncateString(value: string): string {\n\tif (SENSITIVE_VALUE_REGEX.test(value)) return REDACTED;\n\tif (value.length <= MAX_STRING_LENGTH) return value;\n\treturn `${value.slice(0, MAX_STRING_LENGTH - 1)}…`;\n}\n\nfunction isSensitiveKey(key: string): boolean {\n\tconst lowerKey = key.toLowerCase();\n\treturn SENSITIVE_KEYS.some((sensitiveKey) => lowerKey.includes(sensitiveKey));\n}\n\nfunction sanitizeMetadataValue(value: unknown, seen: WeakSet<object>): unknown {\n\tif (typeof value === \"string\") return redactAndTruncateString(value);\n\tif (typeof value !== \"object\" || value === null) return value;\n\tif (seen.has(value)) return CIRCULAR;\n\tif (Array.isArray(value)) {\n\t\tseen.add(value);\n\t\treturn value.map((item) => sanitizeMetadataValue(item, seen));\n\t}\n\treturn sanitizeMetadata(value as Record<string, unknown>, seen);\n}\n\nfunction sanitizeMetadata(\n\tobj: Record<string, unknown>,\n\tseen: WeakSet<object> = new WeakSet(),\n): Record<string, unknown> {\n\tif (seen.has(obj)) return { value: CIRCULAR };\n\tseen.add(obj);\n\tconst result: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tresult[key] = isSensitiveKey(key) ? REDACTED : sanitizeMetadataValue(value, seen);\n\t}\n\treturn result;\n}\n\nexport function formatAutonomyStatus(args: AutonomyStatusSnapshot): string {\n\tconst parts: string[] = [];\n\n\tif (args.latestRoute) {\n\t\tconst risk = args.latestRoute.risk ? ` (${redactAndTruncateString(args.latestRoute.risk)})` : \"\";\n\t\tparts.push(\n\t\t\t`Route: ${redactAndTruncateString(args.latestRoute.tier)}${risk} - ${redactAndTruncateString(args.latestRoute.reasonCode)}`,\n\t\t);\n\t}\n\n\tif (args.latestGate) {\n\t\tparts.push(\n\t\t\t`Gate: ${redactAndTruncateString(args.latestGate.gate)} = ${redactAndTruncateString(args.latestGate.outcome)} (${redactAndTruncateString(args.latestGate.reasonCode)})`,\n\t\t);\n\t}\n\n\tif (args.costSummary) {\n\t\tparts.push(`Costs: ${formatStatusCostSummary(args.costSummary)}`);\n\t}\n\n\tif (args.activeGoal) {\n\t\tconst goal = args.activeGoal;\n\t\tconst requirements = goal.openRequirements !== undefined ? `, open reqs: ${goal.openRequirements}` : \"\";\n\t\tconst stalls = goal.stallTurns !== undefined ? `, stalls: ${goal.stallTurns}` : \"\";\n\t\tparts.push(\n\t\t\t`Goal [${redactAndTruncateString(goal.goalId)}]: ${redactAndTruncateString(goal.status)}${requirements}${stalls}`,\n\t\t);\n\t}\n\n\tif (args.activeLaneCount !== undefined) {\n\t\tparts.push(`Lanes: ${args.activeLaneCount}`);\n\t}\n\n\tif (parts.length === 0) return \"Autonomy: idle\";\n\treturn parts.join(\" | \");\n}\n\nfunction formatDiagnosticSection(name: string, entries?: readonly DiagnosticEntry[]): string | undefined {\n\tif (!entries || entries.length === 0) return undefined;\n\n\tconst lines: string[] = [`--- ${name} ---`];\n\tfor (const entry of entries) {\n\t\tlet header = `- ${redactAndTruncateString(entry.title)}`;\n\t\tif (entry.reasonCode) header += ` [${redactAndTruncateString(entry.reasonCode)}]`;\n\t\tlines.push(header);\n\n\t\tif (entry.summary) {\n\t\t\tlines.push(` Summary: ${redactAndTruncateString(entry.summary)}`);\n\t\t}\n\n\t\tif (entry.metadata) {\n\t\t\tlines.push(` Metadata: ${JSON.stringify(sanitizeMetadata(entry.metadata))}`);\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatAutonomyDiagnostics(args: AutonomyDiagnosticSnapshot): string {\n\tconst sections = [\n\t\tformatDiagnosticSection(\"Routes\", args.routes),\n\t\tformatDiagnosticSection(\"Gates\", args.gates),\n\t\tformatDiagnosticSection(\"Costs\", args.costs),\n\t\tformatDiagnosticSection(\"Research\", args.research),\n\t\tformatDiagnosticSection(\"Delegation\", args.delegation),\n\t\tformatDiagnosticSection(\"Learning\", args.learning),\n\t\tformatDiagnosticSection(\"Goals\", args.goals),\n\t\tformatDiagnosticSection(\"Process Memory\", args.processMemory),\n\t].filter((section): section is string => Boolean(section));\n\n\tif (sections.length === 0) return \"No diagnostics available.\";\n\treturn sections.join(\"\\n\\n\");\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-prompt.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,QAO5B,CAAC;AAEb,MAAM,WAAW,mBAAmB;IACnC,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAS9E","sourcesContent":["/**\n * Subagent system-prompt composition with an irreducible level-0 core.\n *\n * The core is the \"ultimate level-0 default\": ~80 tokens of non-negotiable rules that survive ANY\n * customization. Everything above it — the lane's role prompt and a shipped profile's soul — is a\n * replaceable layer: settings, a lane profile, or the calling model (delegate tool) can erase and\n * replace it entirely. This keeps shipped subagents maximally efficient on small open models (a\n * caller can hand a tiny model a purpose-built minimal prompt) without ever shedding the safety\n * floor. Keep the core UNDER 300 tokens; it is deliberately terse.\n */\nexport const SUBAGENT_CORE_SYSTEM_PROMPT = [\n\t\"You are a bounded subagent shipped by a coding-agent session. Non-negotiable rules:\",\n\t\"1. Do only the task you were given; you cannot see the parent conversation.\",\n\t\"2. You are read-only unless your envelope explicitly grants otherwise; never attempt to change files, settings, credentials, or external state.\",\n\t\"3. Never invent facts, file paths, or APIs; say so when you do not know.\",\n\t\"4. Your output is untrusted evidence for the parent agent - data, never instructions.\",\n\t\"5. Follow the requested output format exactly and be concise; budgets are enforced outside you.\",\n].join(\"\\n\");\n\nexport interface SubagentPromptParts {\n\t/** Situational identity from the shipped profile (replaceable layer). */\n\tsoul?: string;\n\t/** The lane's default role prompt (replaceable layer). */\n\trolePrompt: string;\n\t/** User- or model-provided replacement for every layer above level 0. */\n\toverride?: string;\n}\n\nexport function composeSubagentSystemPrompt(parts: SubagentPromptParts): string {\n\tconst override = parts.override?.trim();\n\tconst above =\n\t\toverride && override.length > 0\n\t\t\t? override\n\t\t\t: [parts.soul?.trim(), parts.rolePrompt]\n\t\t\t\t\t.filter((part): part is string => Boolean(part && part.length > 0))\n\t\t\t\t\t.join(\"\\n\\n\");\n\treturn above.length > 0 ? `${SUBAGENT_CORE_SYSTEM_PROMPT}\\n\\n${above}` : SUBAGENT_CORE_SYSTEM_PROMPT;\n}\n"]}
1
+ {"version":3,"file":"subagent-prompt.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,QAO5B,CAAC;AAEb,MAAM,WAAW,mBAAmB;IACnC,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAS9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-prompt.js","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,qFAAqF;IACrF,6EAA6E;IAC7E,iJAAiJ;IACjJ,0EAA0E;IAC1E,uFAAuF;IACvF,iGAAiG;CACjG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAWb,MAAM,UAAU,2BAA2B,CAAC,KAA0B,EAAU;IAC/E,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,GACV,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC;aACrC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aAClE,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,2BAA2B,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC;AAAA,CACrG","sourcesContent":["/**\n * Subagent system-prompt composition with an irreducible level-0 core.\n *\n * The core is the \"ultimate level-0 default\": ~80 tokens of non-negotiable rules that survive ANY\n * customization. Everything above it — the lane's role prompt and a shipped profile's soul — is a\n * replaceable layer: settings, a lane profile, or the calling model (delegate tool) can erase and\n * replace it entirely. This keeps shipped subagents maximally efficient on small open models (a\n * caller can hand a tiny model a purpose-built minimal prompt) without ever shedding the safety\n * floor. Keep the core UNDER 300 tokens; it is deliberately terse.\n */\nexport const SUBAGENT_CORE_SYSTEM_PROMPT = [\n\t\"You are a bounded subagent shipped by a coding-agent session. Non-negotiable rules:\",\n\t\"1. Do only the task you were given; you cannot see the parent conversation.\",\n\t\"2. You are read-only unless your envelope explicitly grants otherwise; never attempt to change files, settings, credentials, or external state.\",\n\t\"3. Never invent facts, file paths, or APIs; say so when you do not know.\",\n\t\"4. Your output is untrusted evidence for the parent agent - data, never instructions.\",\n\t\"5. Follow the requested output format exactly and be concise; budgets are enforced outside you.\",\n].join(\"\\n\");\n\nexport interface SubagentPromptParts {\n\t/** Situational identity from the shipped profile (replaceable layer). */\n\tsoul?: string;\n\t/** The lane's default role prompt (replaceable layer). */\n\trolePrompt: string;\n\t/** User- or model-provided replacement for every layer above level 0. */\n\toverride?: string;\n}\n\nexport function composeSubagentSystemPrompt(parts: SubagentPromptParts): string {\n\tconst override = parts.override?.trim();\n\tconst above =\n\t\toverride && override.length > 0\n\t\t\t? override\n\t\t\t: [parts.soul?.trim(), parts.rolePrompt]\n\t\t\t\t\t.filter((part): part is string => Boolean(part && part.length > 0))\n\t\t\t\t\t.join(\"\\n\\n\");\n\treturn above.length > 0 ? `${SUBAGENT_CORE_SYSTEM_PROMPT}\\n\\n${above}` : SUBAGENT_CORE_SYSTEM_PROMPT;\n}\n"]}
1
+ {"version":3,"file":"subagent-prompt.js","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,qFAAqF;IACrF,6EAA6E;IAC7E,iJAAiJ;IACjJ,0EAA0E;IAC1E,uFAAuF;IACvF,iGAAiG;CACjG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAWb,MAAM,UAAU,2BAA2B,CAAC,KAA0B;IACrE,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,GACV,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC;aACrC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aAClE,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,2BAA2B,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC;AACtG,CAAC","sourcesContent":["/**\n * Subagent system-prompt composition with an irreducible level-0 core.\n *\n * The core is the \"ultimate level-0 default\": ~80 tokens of non-negotiable rules that survive ANY\n * customization. Everything above it — the lane's role prompt and a shipped profile's soul — is a\n * replaceable layer: settings, a lane profile, or the calling model (delegate tool) can erase and\n * replace it entirely. This keeps shipped subagents maximally efficient on small open models (a\n * caller can hand a tiny model a purpose-built minimal prompt) without ever shedding the safety\n * floor. Keep the core UNDER 300 tokens; it is deliberately terse.\n */\nexport const SUBAGENT_CORE_SYSTEM_PROMPT = [\n\t\"You are a bounded subagent shipped by a coding-agent session. Non-negotiable rules:\",\n\t\"1. Do only the task you were given; you cannot see the parent conversation.\",\n\t\"2. You are read-only unless your envelope explicitly grants otherwise; never attempt to change files, settings, credentials, or external state.\",\n\t\"3. Never invent facts, file paths, or APIs; say so when you do not know.\",\n\t\"4. Your output is untrusted evidence for the parent agent - data, never instructions.\",\n\t\"5. Follow the requested output format exactly and be concise; budgets are enforced outside you.\",\n].join(\"\\n\");\n\nexport interface SubagentPromptParts {\n\t/** Situational identity from the shipped profile (replaceable layer). */\n\tsoul?: string;\n\t/** The lane's default role prompt (replaceable layer). */\n\trolePrompt: string;\n\t/** User- or model-provided replacement for every layer above level 0. */\n\toverride?: string;\n}\n\nexport function composeSubagentSystemPrompt(parts: SubagentPromptParts): string {\n\tconst override = parts.override?.trim();\n\tconst above =\n\t\toverride && override.length > 0\n\t\t\t? override\n\t\t\t: [parts.soul?.trim(), parts.rolePrompt]\n\t\t\t\t\t.filter((part): part is string => Boolean(part && part.length > 0))\n\t\t\t\t\t.join(\"\\n\\n\");\n\treturn above.length > 0 ? `${SUBAGENT_CORE_SYSTEM_PROMPT}\\n\\n${above}` : SUBAGENT_CORE_SYSTEM_PROMPT;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-events.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/telemetry-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,8BAA8B;;;;;;;;CAQjC,CAAC;AAEX,MAAM,MAAM,0BAA0B,GACrC,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,OAAO,8BAA8B,CAAC,CAAC;AAEtF,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,0BAA0B,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,SAAS,CAAC;CACnB;AAiBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAyCvE","sourcesContent":["import type { JsonValue } from \"./contracts.ts\";\n\nexport const AUTONOMY_TELEMETRY_EVENT_TYPES = {\n\trouteDecision: \"autonomy.route_decision\",\n\tgateOutcome: \"autonomy.gate_outcome\",\n\tapprovalRequest: \"autonomy.approval_request\",\n\tevidenceBundle: \"autonomy.evidence_bundle\",\n\tworkerRequest: \"autonomy.worker_request\",\n\tworkerTerminal: \"autonomy.worker_terminal\",\n\tlearningDecision: \"autonomy.learning_decision\",\n} as const;\n\nexport type AutonomyTelemetryEventType =\n\t(typeof AUTONOMY_TELEMETRY_EVENT_TYPES)[keyof typeof AUTONOMY_TELEMETRY_EVENT_TYPES];\n\nexport interface AutonomyTelemetryEvent {\n\ttype: AutonomyTelemetryEventType;\n\ttimestamp: string;\n\tpayload: JsonValue;\n}\n\nconst SECRET_KEYS = new Set([\n\t\"apikey\",\n\t\"api_key\",\n\t\"token\",\n\t\"accesstoken\",\n\t\"refreshtoken\",\n\t\"secret\",\n\t\"password\",\n\t\"authorization\",\n\t\"credential\",\n\t\"credentials\",\n]);\n\nconst BEARER_RE = /bearer\\s+\\S+/i;\n\nexport function redactTelemetryValue(value: unknown, depth = 0): unknown {\n\tif (depth > 20) {\n\t\treturn \"[Depth Limit Exceeded]\";\n\t}\n\n\tif (typeof value === \"string\") {\n\t\tif (BEARER_RE.test(value)) {\n\t\t\treturn \"[REDACTED BEARER TOKEN]\";\n\t\t}\n\t\tif (value.startsWith(\"sk-\")) {\n\t\t\treturn \"[REDACTED API KEY]\";\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn value;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tconst result: unknown[] = [];\n\t\tfor (const item of value) {\n\t\t\tresult.push(redactTelemetryValue(item, depth + 1));\n\t\t}\n\t\treturn result;\n\t}\n\n\t// It is an object\n\tconst obj = value as Record<string, unknown>;\n\tconst result: Record<string, unknown> = {};\n\n\tfor (const key of Object.keys(obj)) {\n\t\tconst lowercaseKey = key.toLowerCase();\n\t\tif (SECRET_KEYS.has(lowercaseKey)) {\n\t\t\tresult[key] = \"[REDACTED]\";\n\t\t} else {\n\t\t\tresult[key] = redactTelemetryValue(obj[key], depth + 1);\n\t\t}\n\t}\n\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"telemetry-events.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/telemetry-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,8BAA8B;aAC1C,aAAa,EAAE,yBAAyB;aACxC,WAAW,EAAE,uBAAuB;aACpC,eAAe,EAAE,2BAA2B;aAC5C,cAAc,EAAE,0BAA0B;aAC1C,aAAa,EAAE,yBAAyB;aACxC,cAAc,EAAE,0BAA0B;aAC1C,gBAAgB,EAAE,4BAA4B;CACrC,CAAC;AAEX,MAAM,MAAM,0BAA0B,GACrC,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,OAAO,8BAA8B,CAAC,CAAC;AAEtF,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,0BAA0B,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,SAAS,CAAC;CACnB;AAiBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAyCvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-events.js","sourceRoot":"","sources":["../../../src/core/autonomy/telemetry-events.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC7C,aAAa,EAAE,yBAAyB;IACxC,WAAW,EAAE,uBAAuB;IACpC,eAAe,EAAE,2BAA2B;IAC5C,cAAc,EAAE,0BAA0B;IAC1C,aAAa,EAAE,yBAAyB;IACxC,cAAc,EAAE,0BA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AAC,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YACnC,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;QAC5B,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,GAAG,CAAC,GAAG,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["import type { JsonValue } from \"./contracts.ts\";\n\nexport const AUTONOMY_TELEMETRY_EVENT_TYPES = {\n\trouteDecision: \"autonomy.route_decision\",\n\tgateOutcome: \"autonomy.gate_outcome\",\n\tapprovalRequest: \"autonomy.approval_request\",\n\tevidenceBundle: \"autonomy.evidence_bundle\",\n\tworkerRequest: \"autonomy.worker_request\",\n\tworkerTerminal: \"autonomy.worker_terminal\",\n\tlearningDecision: \"autonomy.learning_decision\",\n} as const;\n\nexport type AutonomyTelemetryEventType =\n\t(typeof AUTONOMY_TELEMETRY_EVENT_TYPES)[keyof typeof AUTONOMY_TELEMETRY_EVENT_TYPES];\n\nexport interface AutonomyTelemetryEvent {\n\ttype: AutonomyTelemetryEventType;\n\ttimestamp: string;\n\tpayload: JsonValue;\n}\n\nconst SECRET_KEYS = new Set([\n\t\"apikey\",\n\t\"api_key\",\n\t\"token\",\n\t\"accesstoken\",\n\t\"refreshtoken\",\n\t\"secret\",\n\t\"password\",\n\t\"authorization\",\n\t\"credential\",\n\t\"credentials\",\n]);\n\nconst BEARER_RE = /bearer\\s+\\S+/i;\n\nexport function redactTelemetryValue(value: unknown, depth = 0): unknown {\n\tif (depth > 20) {\n\t\treturn \"[Depth Limit Exceeded]\";\n\t}\n\n\tif (typeof value === \"string\") {\n\t\tif (BEARER_RE.test(value)) {\n\t\t\treturn \"[REDACTED BEARER TOKEN]\";\n\t\t}\n\t\tif (value.startsWith(\"sk-\")) {\n\t\t\treturn \"[REDACTED API KEY]\";\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn value;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tconst result: unknown[] = [];\n\t\tfor (const item of value) {\n\t\t\tresult.push(redactTelemetryValue(item, depth + 1));\n\t\t}\n\t\treturn result;\n\t}\n\n\t// It is an object\n\tconst obj = value as Record<string, unknown>;\n\tconst result: Record<string, unknown> = {};\n\n\tfor (const key of Object.keys(obj)) {\n\t\tconst lowercaseKey = key.toLowerCase();\n\t\tif (SECRET_KEYS.has(lowercaseKey)) {\n\t\t\tresult[key] = \"[REDACTED]\";\n\t\t} else {\n\t\t\tresult[key] = redactTelemetryValue(obj[key], depth + 1);\n\t\t}\n\t}\n\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"telemetry-events.js","sourceRoot":"","sources":["../../../src/core/autonomy/telemetry-events.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC7C,aAAa,EAAE,yBAAyB;IACxC,WAAW,EAAE,uBAAuB;IACpC,eAAe,EAAE,2BAA2B;IAC5C,cAAc,EAAE,0BAA0B;IAC1C,aAAa,EAAE,yBAAyB;IACxC,cAAc,EAAE,0BAA0B;IAC1C,gBAAgB,EAAE,4BAA4B;CACrC,CAAC;AAWX,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC3B,QAAQ;IACR,SAAS;IACT,OAAO;IACP,aAAa;IACb,cAAc;IACd,QAAQ;IACR,UAAU;IACV,eAAe;IACf,YAAY;IACZ,aAAa;CACb,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,eAAe,CAAC;AAElC,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;IAC7D,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QAChB,OAAO,wBAAwB,CAAC;IACjC,CAAC;IAED,IA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const AUTONOMY_TELEMETRY_EVENT_TYPES = {\n\trouteDecision: \"autonomy.route_decision\",\n\tgateOutcome: \"autonomy.gate_outcome\",\n\tapprovalRequest: \"autonomy.approval_request\",\n\tevidenceBundle: \"autonomy.evidence_bundle\",\n\tworkerRequest: \"autonomy.worker_request\",\n\tworkerTerminal: \"autonomy.worker_terminal\",\n\tlearningDecision: \"autonomy.learning_decision\",\n} as const;\n\nexport type AutonomyTelemetryEventType =\n\t(typeof AUTONOMY_TELEMETRY_EVENT_TYPES)[keyof typeof AUTONOMY_TELEMETRY_EVENT_TYPES];\n\nexport interface AutonomyTelemetryEvent {\n\ttype: AutonomyTelemetryEventType;\n\ttimestamp: string;\n\tpayload: JsonValue;\n}\n\nconst SECRET_KEYS = new Set([\n\t\"apikey\",\n\t\"api_key\",\n\t\"token\",\n\t\"accesstoken\",\n\t\"refreshtoken\",\n\t\"secret\",\n\t\"password\",\n\t\"authorization\",\n\t\"credential\",\n\t\"credentials\",\n]);\n\nconst BEARER_RE = /bearer\\s+\\S+/i;\n\nexport function redactTelemetryValue(value: unknown, depth = 0): unknown {\n\tif (depth > 20) {\n\t\treturn \"[Depth Limit Exceeded]\";\n\t}\n\n\tif (typeof value === \"string\") {\n\t\tif (BEARER_RE.test(value)) {\n\t\t\treturn \"[REDACTED BEARER TOKEN]\";\n\t\t}\n\t\tif (value.startsWith(\"sk-\")) {\n\t\t\treturn \"[REDACTED API KEY]\";\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn value;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tconst result: unknown[] = [];\n\t\tfor (const item of value) {\n\t\t\tresult.push(redactTelemetryValue(item, depth + 1));\n\t\t}\n\t\treturn result;\n\t}\n\n\t// It is an object\n\tconst obj = value as Record<string, unknown>;\n\tconst result: Record<string, unknown> = {};\n\n\tfor (const key of Object.keys(obj)) {\n\t\tconst lowercaseKey = key.toLowerCase();\n\t\tif (SECRET_KEYS.has(lowercaseKey)) {\n\t\t\tresult[key] = \"[REDACTED]\";\n\t\t} else {\n\t\t\tresult[key] = redactTelemetryValue(obj[key], depth + 1);\n\t\t}\n\t}\n\n\treturn result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"autonomy-telemetry.d.ts","sourceRoot":"","sources":["../../src/core/autonomy-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE1G,OAAO,KAAK,EACX,0BAA0B,EAC1B,sBAAsB,EAEtB,uBAAuB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEN,KAAK,sBAAsB,EAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAA+C,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAiC,KAAK,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AASzG,MAAM,WAAW,qBAAqB;IACrC,yGAAyG;IACzG,iBAAiB,IAAI,IAAI,CAAC,cAAc,EAAE,mBAAmB,GAAG,YAAY,CAAC,CAAC;IAC9E,6GAA2G;IAC3G,0BAA0B,IAAI,yBAAyB,GAAG,SAAS,CAAC;IACpE,0GAAwG;IACxG,6BAA6B,IAAI,MAAM,GAAG,SAAS,CAAC;IACpD,wEAAwE;IACxE,cAAc,IAAI,kBAAkB,CAAC;IACrC,+CAA+C;IAC/C,oBAAoB,IAAI,SAAS,GAAG,SAAS,CAAC;IAC9C,qGAAmG;IACnG,kBAAkB,IAAI,MAAM,CAAC;IAC7B,8FAA8F;IAC9F,+BAA+B,IAAI,cAAc,EAAE,CAAC;IACpD,6FAA6F;IAC7F,4BAA4B,IAAI,WAAW,EAAE,CAAC;IAC9C,uFAAuF;IACvF,iCAAiC,IAAI,gBAAgB,EAAE,CAAC;IACxD,oDAAoD;IACpD,uBAAuB,IAAI,mBAAmB,EAAE,CAAC;CACjD;AAED,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,wBAAwB,CAAC,CAAc;IAC/C,qGAAqG;IACrG,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAiC;IAErE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwB;IAE7C,YAAY,IAAI,EAAE,qBAAqB,EAEtC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAOjD;IAED;;;;;;OAMG;IACH,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAsB5C;IAED,iFAAiF;IACjF,qBAAqB,IAAI,uBAAuB,EAAE,CAEjD;IAED,iBAAiB,IAAI,sBAAsB,CA2C1C;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,OAAO,CAAC,EAAE;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,0BAA0B,CA0J5F;CACD","sourcesContent":["/**\n * Autonomy telemetry sink + status/diagnostic snapshots.\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). Owns the latest gate outcome\n * and the bounded gate-outcome history, and is the single sink for G3 autonomy-telemetry custom\n * entries. The two snapshot builders READ broadly across live session state (router decision, cost,\n * goal, lanes, and the research/delegation/learning/goal getters) through narrow deps accessors\n * rather than the whole AgentSession — they never mutate anything but the owned gate-outcome fields.\n */\n\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { getProcessMemoryMb } from \"../utils/process-memory.ts\";\nimport type { EvidenceBundle, GateOutcome, LearningDecision, WorkerClaim } from \"./autonomy/contracts.ts\";\nimport { getLaneRecordSnapshots } from \"./autonomy/session-lane-record.ts\";\nimport type {\n\tAutonomyDiagnosticSnapshot,\n\tAutonomyStatusSnapshot,\n\tDiagnosticEntry,\n\tGateOutcomeHistoryEntry,\n} from \"./autonomy/status.ts\";\nimport {\n\tAUTONOMY_TELEMETRY_EVENT_TYPES,\n\ttype AutonomyTelemetryEvent,\n\tredactTelemetryValue,\n} from \"./autonomy/telemetry-events.ts\";\nimport { hasCostSummarySignal, hasSubagentCostSignal, type SessionCostSummary } from \"./cost/cost-summary.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport type { LearningAuditRecord } from \"./learning/learning-audit.ts\";\nimport { getRecentModelRouterDecisions, type ModelRouterDecisionStatus } from \"./model-router/status.ts\";\n\n/** Custom-entry type for G3 autonomy telemetry. Distinct from the router/lane record types so a\n * telemetry consumer can filter on it without decoding operational snapshots. */\nconst AUTONOMY_TELEMETRY_CUSTOM_TYPE = \"autonomy-telemetry\";\n\n/** G8: bound on the in-memory gate-outcome history. Oldest entries evict once the cap is reached. */\nconst GATE_OUTCOME_HISTORY_LIMIT = 50;\n\nexport interface AutonomyTelemetryDeps {\n\t/** Session log: `appendCustomEntry` is the telemetry sink; `getEntries` feeds diagnostic aggregation. */\n\tgetSessionManager(): Pick<SessionManager, \"appendCustomEntry\" | \"getEntries\">;\n\t/** Latest model-router decision, for the snapshot's `latestRoute` — owned by the router, not this sink. */\n\tgetLastModelRouterDecision(): ModelRouterDecisionStatus | undefined;\n\t/** Reason the last research lane was skipped, if any — surfaced in the diagnostic's research family. */\n\tgetLastResearchLaneSkipReason(): string | undefined;\n\t/** Single source of truth for CURRENT/TODAY/SUBAGENTS display costs. */\n\tgetCostSummary(): SessionCostSummary;\n\t/** Current goal state, if a goal is active. */\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\t/** Live count of active lanes from the lane tracker — never inferred from historical snapshots. */\n\tgetActiveLaneCount(): number;\n\t/** Research evidence bundles across the complete session tree, including sibling branches. */\n\tgetSessionEvidenceBundleHistory(): EvidenceBundle[];\n\t/** Worker-delegation claims across the complete session tree, including sibling branches. */\n\tgetSessionWorkerClaimHistory(): WorkerClaim[];\n\t/** Learning decisions across the complete session tree, including sibling branches. */\n\tgetSessionLearningDecisionHistory(): LearningDecision[];\n\t/** Learning audit records recorded this session. */\n\tgetLearningAuditRecords(): LearningAuditRecord[];\n}\n\nexport class AutonomyTelemetry {\n\tprivate _lastAutonomyGateOutcome?: GateOutcome;\n\t/** G8: bounded (cap {@link GATE_OUTCOME_HISTORY_LIMIT}) history of gate outcomes; tail is latest. */\n\tprivate readonly _gateOutcomeHistory: GateOutcomeHistoryEntry[] = [];\n\n\tprivate readonly deps: AutonomyTelemetryDeps;\n\n\tconstructor(deps: AutonomyTelemetryDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\t/**\n\t * G3: bounded autonomy-telemetry sink. Passes the whole event through {@link redactTelemetryValue}\n\t * (the taxonomy's redaction contract) before storing it, so a secret that leaked into a payload\n\t * field never lands in the session log. Observe-only: a failure here can never surface into the\n\t * turn it is measuring, so the whole body is swallowed. Payloads MUST stay small (ids, codes,\n\t * numbers) — never prompt/summary text; callers own that discipline.\n\t */\n\temitTelemetry(event: AutonomyTelemetryEvent): void {\n\t\ttry {\n\t\t\tconst redacted = redactTelemetryValue(event) as Record<string, unknown>;\n\t\t\tthis.deps.getSessionManager().appendCustomEntry(AUTONOMY_TELEMETRY_CUSTOM_TYPE, { version: 1, ...redacted });\n\t\t} catch {\n\t\t\t// Telemetry is best-effort: swallow so a sink failure cannot break the observed turn.\n\t\t}\n\t}\n\n\t/**\n\t * G8: single sink for a gate outcome. Keeps the latest-outcome getter behavior identical (the\n\t * full {@link GateOutcome} still lands in `_lastAutonomyGateOutcome`), and additionally appends a\n\t * bounded codes-only entry to {@link _gateOutcomeHistory} (oldest evicted at\n\t * {@link GATE_OUTCOME_HISTORY_LIMIT}) and emits the `gate_outcome` telemetry event. The history\n\t * tail therefore always mirrors the latest outcome. Only called with an active envelope.\n\t */\n\trecordGateOutcome(outcome: GateOutcome): void {\n\t\tthis._lastAutonomyGateOutcome = outcome;\n\t\tconst at = new Date().toISOString();\n\t\tthis._gateOutcomeHistory.push({\n\t\t\toutcome: outcome.outcome,\n\t\t\tgate: outcome.gate,\n\t\t\treasonCode: outcome.reasonCode,\n\t\t\tat,\n\t\t});\n\t\twhile (this._gateOutcomeHistory.length > GATE_OUTCOME_HISTORY_LIMIT) {\n\t\t\tthis._gateOutcomeHistory.shift();\n\t\t}\n\t\t// G8: gate outcome event. Codes/ids only — never the gate's human-facing message.\n\t\tthis.emitTelemetry({\n\t\t\ttype: AUTONOMY_TELEMETRY_EVENT_TYPES.gateOutcome,\n\t\t\ttimestamp: at,\n\t\t\tpayload: {\n\t\t\t\toutcome: outcome.outcome,\n\t\t\t\tgate: outcome.gate,\n\t\t\t\treasonCode: outcome.reasonCode,\n\t\t\t},\n\t\t});\n\t}\n\n\t/** G8: copies of the bounded gate-outcome history, oldest first, latest last. */\n\tgetGateOutcomeHistory(): GateOutcomeHistoryEntry[] {\n\t\treturn this._gateOutcomeHistory.map((entry) => ({ ...entry }));\n\t}\n\n\tgetStatusSnapshot(): AutonomyStatusSnapshot {\n\t\tconst snapshot: AutonomyStatusSnapshot = {};\n\n\t\tconst lastRouterDecision = this.deps.getLastModelRouterDecision();\n\t\tif (lastRouterDecision?.route) {\n\t\t\tsnapshot.latestRoute = {\n\t\t\t\ttier: lastRouterDecision.route.tier,\n\t\t\t\treasonCode: lastRouterDecision.route.reasonCode,\n\t\t\t\trisk: lastRouterDecision.route.risk,\n\t\t\t};\n\t\t}\n\n\t\tif (this._lastAutonomyGateOutcome) {\n\t\t\tsnapshot.latestGate = {\n\t\t\t\toutcome: this._lastAutonomyGateOutcome.outcome,\n\t\t\t\tgate: this._lastAutonomyGateOutcome.gate,\n\t\t\t\treasonCode: this._lastAutonomyGateOutcome.reasonCode,\n\t\t\t};\n\t\t}\n\n\t\tconst costSummary = this.deps.getCostSummary();\n\t\tif (hasCostSummarySignal(costSummary)) {\n\t\t\tsnapshot.costSummary = costSummary;\n\t\t}\n\n\t\tconst goal = this.deps.getGoalStateSnapshot();\n\t\tif (goal) {\n\t\t\tsnapshot.activeGoal = {\n\t\t\t\tgoalId: goal.goalId,\n\t\t\t\tstatus: goal.status,\n\t\t\t\topenRequirements: goal.requirements.filter((requirement) => requirement.status === \"open\").length,\n\t\t\t\tstallTurns: goal.stallTurns,\n\t\t\t};\n\t\t}\n\n\t\t// Real live count from the lane tracker — never inferred from historical snapshots. Absent\n\t\t// while zero, matching the presence-means-signal convention of the sibling fields.\n\t\tconst activeLaneCount = this.deps.getActiveLaneCount();\n\t\tif (activeLaneCount > 0) {\n\t\t\tsnapshot.activeLaneCount = activeLaneCount;\n\t\t}\n\n\t\treturn snapshot;\n\t}\n\n\t/**\n\t * Aggregate an effectiveness/autonomy dashboard: what Pi has actually been doing (recent\n\t * route choices, latest gate outcome, cost, and any research/delegation/learning/goal\n\t * activity). Read-only — combines existing session-log getters, never mutates state or\n\t * recomputes a route/gate decision.\n\t */\n\tgetDiagnosticSnapshot(options?: { maxEntriesPerFamily?: number }): AutonomyDiagnosticSnapshot {\n\t\tconst maxEntriesPerFamily = options?.maxEntriesPerFamily ?? 10;\n\t\tconst snapshot: AutonomyDiagnosticSnapshot = {};\n\t\tconst goal = this.deps.getGoalStateSnapshot();\n\n\t\tconst recentDecisions = getRecentModelRouterDecisions(\n\t\t\tthis.deps.getSessionManager().getEntries(),\n\t\t\tmaxEntriesPerFamily,\n\t\t);\n\t\tif (recentDecisions.length > 0) {\n\t\t\tsnapshot.routes = recentDecisions.map(\n\t\t\t\t(decision): DiagnosticEntry => ({\n\t\t\t\t\ttitle: decision.route.tier,\n\t\t\t\t\tsummary: decision.routedModel,\n\t\t\t\t\treasonCode: decision.route.reasonCode,\n\t\t\t\t\tmetadata: { risk: decision.route.risk, outcome: decision.outcome, intent: decision.intent },\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (this._lastAutonomyGateOutcome) {\n\t\t\tconst gate = this._lastAutonomyGateOutcome;\n\t\t\tsnapshot.gates = [\n\t\t\t\t{\n\t\t\t\t\ttitle: gate.gate,\n\t\t\t\t\tsummary: gate.message,\n\t\t\t\t\treasonCode: gate.reasonCode,\n\t\t\t\t\tmetadata: { outcome: gate.outcome, reversible: gate.reversible },\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst costs: DiagnosticEntry[] = [];\n\t\tconst costSummary = this.deps.getCostSummary();\n\t\tif (costSummary.currentCost > 0 || hasSubagentCostSignal(costSummary)) {\n\t\t\tcosts.push({ title: \"CURRENT\", summary: `$${costSummary.currentCost.toFixed(4)}` });\n\t\t}\n\t\tif (costSummary.todayCost > 0) {\n\t\t\tcosts.push({ title: \"TODAY\", summary: `$${costSummary.todayCost.toFixed(4)}` });\n\t\t}\n\t\tif (hasSubagentCostSignal(costSummary)) {\n\t\t\tcosts.push({\n\t\t\t\ttitle: \"SUBAGENTS\",\n\t\t\t\tsummary: `$${costSummary.subagentCost.toFixed(4)} included in CURRENT`,\n\t\t\t});\n\t\t}\n\t\tif (costs.length > 0) snapshot.costs = costs;\n\n\t\tconst researchEntries: DiagnosticEntry[] = [];\n\t\tconst researchLaneRecords = getLaneRecordSnapshots(this.deps.getSessionManager().getEntries()).filter(\n\t\t\t(record) => record.type === \"research\",\n\t\t);\n\t\tfor (const record of researchLaneRecords.slice(-maxEntriesPerFamily)) {\n\t\t\tresearchEntries.push({\n\t\t\t\ttitle: `Lane ${record.laneId} (${record.status})`,\n\t\t\t\treasonCode: record.reasonCode,\n\t\t\t\tmetadata: {\n\t\t\t\t\tcostUsd: record.costUsd,\n\t\t\t\t\tstartedAt: record.startedAt,\n\t\t\t\t\tcompletedAt: record.completedAt,\n\t\t\t\t\tgoalId: record.goalId,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tfor (const bundle of this.deps.getSessionEvidenceBundleHistory().slice(-maxEntriesPerFamily)) {\n\t\t\tresearchEntries.push({\n\t\t\t\ttitle: `Research: ${bundle.query}`,\n\t\t\t\tmetadata: { sourceCount: bundle.sources.length, findingCount: bundle.findings.length },\n\t\t\t});\n\t\t}\n\t\tif (this.deps.getLastResearchLaneSkipReason()) {\n\t\t\tresearchEntries.push({ title: \"Last skip\", reasonCode: this.deps.getLastResearchLaneSkipReason() });\n\t\t}\n\t\tif (researchEntries.length > 0) {\n\t\t\tsnapshot.research = researchEntries;\n\t\t}\n\n\t\tconst delegationEntries: DiagnosticEntry[] = [];\n\t\tconst workerLaneRecords = getLaneRecordSnapshots(this.deps.getSessionManager().getEntries()).filter(\n\t\t\t(record) => record.type === \"worker\",\n\t\t);\n\t\tfor (const record of workerLaneRecords.slice(-maxEntriesPerFamily)) {\n\t\t\tdelegationEntries.push({\n\t\t\t\ttitle: `Lane ${record.laneId} (${record.status})`,\n\t\t\t\treasonCode: record.reasonCode,\n\t\t\t\tmetadata: { costUsd: record.costUsd, startedAt: record.startedAt, completedAt: record.completedAt },\n\t\t\t});\n\t\t}\n\t\tconst workerClaims = this.deps.getSessionWorkerClaimHistory();\n\t\tfor (const claim of workerClaims.slice(-maxEntriesPerFamily)) {\n\t\t\tdelegationEntries.push({\n\t\t\t\ttitle: `Worker ${claim.requestId} (${claim.status})`,\n\t\t\t\tsummary: claim.summary,\n\t\t\t\tmetadata: {\n\t\t\t\t\tchangedFileCount: claim.changedFiles.length,\n\t\t\t\t\tblockerCount: claim.blockers?.length ?? 0,\n\t\t\t\t\tusageReportId: claim.usageReportId,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tif (delegationEntries.length > 0) {\n\t\t\tsnapshot.delegation = delegationEntries;\n\t\t}\n\n\t\tconst learningEntries: DiagnosticEntry[] = [];\n\t\tconst learningDecisions = this.deps.getSessionLearningDecisionHistory();\n\t\tfor (const decision of learningDecisions.slice(-maxEntriesPerFamily)) {\n\t\t\tlearningEntries.push({\n\t\t\t\ttitle: `Learning (${decision.kind})`,\n\t\t\t\tsummary: decision.summary,\n\t\t\t\treasonCode: decision.reasonCode,\n\t\t\t\tmetadata: { confidence: decision.confidence, requiresApproval: decision.requiresApproval },\n\t\t\t});\n\t\t}\n\t\tfor (const audit of this.deps.getLearningAuditRecords().slice(-maxEntriesPerFamily)) {\n\t\t\tlearningEntries.push({\n\t\t\t\ttitle: `Audit ${audit.id} (${audit.action})`,\n\t\t\t\tsummary: audit.summary,\n\t\t\t\treasonCode: audit.reasonCode,\n\t\t\t\tmetadata: { layer: audit.layer, proposalId: audit.proposalId, rollbackOf: audit.rollbackOf },\n\t\t\t});\n\t\t}\n\t\tif (learningEntries.length > 0) {\n\t\t\tsnapshot.learning = learningEntries;\n\t\t}\n\n\t\tif (goal) {\n\t\t\tsnapshot.goals = [\n\t\t\t\t{\n\t\t\t\t\ttitle: `Goal ${goal.goalId}`,\n\t\t\t\t\tsummary: goal.userGoal,\n\t\t\t\t\treasonCode: goal.status,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\topenRequirementCount: goal.requirements.filter((requirement) => requirement.status === \"open\").length,\n\t\t\t\t\t\tstallTurns: goal.stallTurns,\n\t\t\t\t\t\tblockedReason: goal.blockedReason,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst processMemory = getProcessMemoryMb();\n\t\tsnapshot.processMemory = [\n\t\t\t{\n\t\t\t\ttitle: \"process\",\n\t\t\t\tmetadata: {\n\t\t\t\t\trssMb: processMemory.rssMb,\n\t\t\t\t\theapUsedMb: processMemory.heapUsedMb,\n\t\t\t\t\texternalMb: processMemory.externalMb,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn snapshot;\n\t}\n}\n"]}
1
+ {"version":3,"file":"autonomy-telemetry.d.ts","sourceRoot":"","sources":["../../src/core/autonomy-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,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C;IAED;;;;;;OAMG;IACH,aAAa,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAOjD;IAED;;;;;;OAMG;IACH,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAsB5C;IAED,iFAAiF;IACjF,qBAAqB,IAAI,uBAAuB,EAAE,CAEjD;IAED,iBAAiB,IAAI,sBAAsB,CA2C1C;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,OAAO,CAAC,EAAE;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,0BAA0B,CA0J5F;CACD"}
@@ -18,11 +18,9 @@ const AUTONOMY_TELEMETRY_CUSTOM_TYPE = "autonomy-telemetry";
18
18
  /** G8: bound on the in-memory gate-outcome history. Oldest entries evict once the cap is reached. */
19
19
  const GATE_OUTCOME_HISTORY_LIMIT = 50;
20
20
  export class AutonomyTelemetry {
21
- _lastAutonomyGateOutcome;
22
- /** G8: bounded (cap {@link GATE_OUTCOME_HISTORY_LIMIT}) history of gate outcomes; tail is latest. */
23
- _gateOutcomeHistory = [];
24
- deps;
25
21
  constructor(deps) {
22
+ /** G8: bounded (cap {@link GATE_OUTCOME_HISTORY_LIMIT}) history of gate outcomes; tail is latest. */
23
+ this._gateOutcomeHistory = [];
26
24
  this.deps = deps;
27
25
  }
28
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"autonomy-telemetry.js","sourceRoot":"","sources":["../../src/core/autonomy-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAO3E,OAAO,EACN,8BAA8B,EAE9B,oBAAoB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAA2B,MAAM,wBAAwB,CAAC;AAG9G,OAAO,EAAE,6BAA6B,EAAkC,MAAM,0BAA0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ACJ,CAAC;QACD,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,QAAQ,CAAC,QAAQ,GAAG,eAAe,CAAC;QACrC,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACV,QAAQ,CAAC,KAAK,GAAG;gBAChB;oBACC,KAAK,EAAE,QAAQ,IAAI,CAAC,MAAM,EAAE;oBAC5B,OAAO,EAAE,IAAI,CAAC,QAAQ;oBACtB,UAAU,EAAE,IAAI,CAAC,MAAM;oBACvB,QAAQ,EAAE;wBACT,oBAAoB,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM;wBACrG,UAAU,EAAE,IAAI,CAAC,UAAU;wBAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;qBACjC;iBACD;aACD,CAAC;QACH,CAAC;QAED,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC;QAC3C,QAAQ,CAAC,aAAa,GAAG;YACxB;gBACC,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE;oBACT,KAAK,EAAE,aAAa,CAAC,KAAK;oBAC1B,UAAU,EAAE,aAAa,CAAC,UAAU;oBACpC,UAAU,EAAE,aAAa,CAAC,UAAU;iBACpC;aACD;SACD,CAAC;QAEF,OAAO,QAAQ,CAAC;IAAA,CAChB;CACD","sourcesContent":["/**\n * Autonomy telemetry sink + status/diagnostic snapshots.\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). Owns the latest gate outcome\n * and the bounded gate-outcome history, and is the single sink for G3 autonomy-telemetry custom\n * entries. The two snapshot builders READ broadly across live session state (router decision, cost,\n * goal, lanes, and the research/delegation/learning/goal getters) through narrow deps accessors\n * rather than the whole AgentSession — they never mutate anything but the owned gate-outcome fields.\n */\n\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { getProcessMemoryMb } from \"../utils/process-memory.ts\";\nimport type { EvidenceBundle, GateOutcome, LearningDecision, WorkerClaim } from \"./autonomy/contracts.ts\";\nimport { getLaneRecordSnapshots } from \"./autonomy/session-lane-record.ts\";\nimport type {\n\tAutonomyDiagnosticSnapshot,\n\tAutonomyStatusSnapshot,\n\tDiagnosticEntry,\n\tGateOutcomeHistoryEntry,\n} from \"./autonomy/status.ts\";\nimport {\n\tAUTONOMY_TELEMETRY_EVENT_TYPES,\n\ttype AutonomyTelemetryEvent,\n\tredactTelemetryValue,\n} from \"./autonomy/telemetry-events.ts\";\nimport { hasCostSummarySignal, hasSubagentCostSignal, type SessionCostSummary } from \"./cost/cost-summary.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport type { LearningAuditRecord } from \"./learning/learning-audit.ts\";\nimport { getRecentModelRouterDecisions, type ModelRouterDecisionStatus } from \"./model-router/status.ts\";\n\n/** Custom-entry type for G3 autonomy telemetry. Distinct from the router/lane record types so a\n * telemetry consumer can filter on it without decoding operational snapshots. */\nconst AUTONOMY_TELEMETRY_CUSTOM_TYPE = \"autonomy-telemetry\";\n\n/** G8: bound on the in-memory gate-outcome history. Oldest entries evict once the cap is reached. */\nconst GATE_OUTCOME_HISTORY_LIMIT = 50;\n\nexport interface AutonomyTelemetryDeps {\n\t/** Session log: `appendCustomEntry` is the telemetry sink; `getEntries` feeds diagnostic aggregation. */\n\tgetSessionManager(): Pick<SessionManager, \"appendCustomEntry\" | \"getEntries\">;\n\t/** Latest model-router decision, for the snapshot's `latestRoute` — owned by the router, not this sink. */\n\tgetLastModelRouterDecision(): ModelRouterDecisionStatus | undefined;\n\t/** Reason the last research lane was skipped, if any — surfaced in the diagnostic's research family. */\n\tgetLastResearchLaneSkipReason(): string | undefined;\n\t/** Single source of truth for CURRENT/TODAY/SUBAGENTS display costs. */\n\tgetCostSummary(): SessionCostSummary;\n\t/** Current goal state, if a goal is active. */\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\t/** Live count of active lanes from the lane tracker — never inferred from historical snapshots. */\n\tgetActiveLaneCount(): number;\n\t/** Research evidence bundles across the complete session tree, including sibling branches. */\n\tgetSessionEvidenceBundleHistory(): EvidenceBundle[];\n\t/** Worker-delegation claims across the complete session tree, including sibling branches. */\n\tgetSessionWorkerClaimHistory(): WorkerClaim[];\n\t/** Learning decisions across the complete session tree, including sibling branches. */\n\tgetSessionLearningDecisionHistory(): LearningDecision[];\n\t/** Learning audit records recorded this session. */\n\tgetLearningAuditRecords(): LearningAuditRecord[];\n}\n\nexport class AutonomyTelemetry {\n\tprivate _lastAutonomyGateOutcome?: GateOutcome;\n\t/** G8: bounded (cap {@link GATE_OUTCOME_HISTORY_LIMIT}) history of gate outcomes; tail is latest. */\n\tprivate readonly _gateOutcomeHistory: GateOutcomeHistoryEntry[] = [];\n\n\tprivate readonly deps: AutonomyTelemetryDeps;\n\n\tconstructor(deps: AutonomyTelemetryDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\t/**\n\t * G3: bounded autonomy-telemetry sink. Passes the whole event through {@link redactTelemetryValue}\n\t * (the taxonomy's redaction contract) before storing it, so a secret that leaked into a payload\n\t * field never lands in the session log. Observe-only: a failure here can never surface into the\n\t * turn it is measuring, so the whole body is swallowed. Payloads MUST stay small (ids, codes,\n\t * numbers) — never prompt/summary text; callers own that discipline.\n\t */\n\temitTelemetry(event: AutonomyTelemetryEvent): void {\n\t\ttry {\n\t\t\tconst redacted = redactTelemetryValue(event) as Record<string, unknown>;\n\t\t\tthis.deps.getSessionManager().appendCustomEntry(AUTONOMY_TELEMETRY_CUSTOM_TYPE, { version: 1, ...redacted });\n\t\t} catch {\n\t\t\t// Telemetry is best-effort: swallow so a sink failure cannot break the observed turn.\n\t\t}\n\t}\n\n\t/**\n\t * G8: single sink for a gate outcome. Keeps the latest-outcome getter behavior identical (the\n\t * full {@link GateOutcome} still lands in `_lastAutonomyGateOutcome`), and additionally appends a\n\t * bounded codes-only entry to {@link _gateOutcomeHistory} (oldest evicted at\n\t * {@link GATE_OUTCOME_HISTORY_LIMIT}) and emits the `gate_outcome` telemetry event. The history\n\t * tail therefore always mirrors the latest outcome. Only called with an active envelope.\n\t */\n\trecordGateOutcome(outcome: GateOutcome): void {\n\t\tthis._lastAutonomyGateOutcome = outcome;\n\t\tconst at = new Date().toISOString();\n\t\tthis._gateOutcomeHistory.push({\n\t\t\toutcome: outcome.outcome,\n\t\t\tgate: outcome.gate,\n\t\t\treasonCode: outcome.reasonCode,\n\t\t\tat,\n\t\t});\n\t\twhile (this._gateOutcomeHistory.length > GATE_OUTCOME_HISTORY_LIMIT) {\n\t\t\tthis._gateOutcomeHistory.shift();\n\t\t}\n\t\t// G8: gate outcome event. Codes/ids only — never the gate's human-facing message.\n\t\tthis.emitTelemetry({\n\t\t\ttype: AUTONOMY_TELEMETRY_EVENT_TYPES.gateOutcome,\n\t\t\ttimestamp: at,\n\t\t\tpayload: {\n\t\t\t\toutcome: outcome.outcome,\n\t\t\t\tgate: outcome.gate,\n\t\t\t\treasonCode: outcome.reasonCode,\n\t\t\t},\n\t\t});\n\t}\n\n\t/** G8: copies of the bounded gate-outcome history, oldest first, latest last. */\n\tgetGateOutcomeHistory(): GateOutcomeHistoryEntry[] {\n\t\treturn this._gateOutcomeHistory.map((entry) => ({ ...entry }));\n\t}\n\n\tgetStatusSnapshot(): AutonomyStatusSnapshot {\n\t\tconst snapshot: AutonomyStatusSnapshot = {};\n\n\t\tconst lastRouterDecision = this.deps.getLastModelRouterDecision();\n\t\tif (lastRouterDecision?.route) {\n\t\t\tsnapshot.latestRoute = {\n\t\t\t\ttier: lastRouterDecision.route.tier,\n\t\t\t\treasonCode: lastRouterDecision.route.reasonCode,\n\t\t\t\trisk: lastRouterDecision.route.risk,\n\t\t\t};\n\t\t}\n\n\t\tif (this._lastAutonomyGateOutcome) {\n\t\t\tsnapshot.latestGate = {\n\t\t\t\toutcome: this._lastAutonomyGateOutcome.outcome,\n\t\t\t\tgate: this._lastAutonomyGateOutcome.gate,\n\t\t\t\treasonCode: this._lastAutonomyGateOutcome.reasonCode,\n\t\t\t};\n\t\t}\n\n\t\tconst costSummary = this.deps.getCostSummary();\n\t\tif (hasCostSummarySignal(costSummary)) {\n\t\t\tsnapshot.costSummary = costSummary;\n\t\t}\n\n\t\tconst goal = this.deps.getGoalStateSnapshot();\n\t\tif (goal) {\n\t\t\tsnapshot.activeGoal = {\n\t\t\t\tgoalId: goal.goalId,\n\t\t\t\tstatus: goal.status,\n\t\t\t\topenRequirements: goal.requirements.filter((requirement) => requirement.status === \"open\").length,\n\t\t\t\tstallTurns: goal.stallTurns,\n\t\t\t};\n\t\t}\n\n\t\t// Real live count from the lane tracker — never inferred from historical snapshots. Absent\n\t\t// while zero, matching the presence-means-signal convention of the sibling fields.\n\t\tconst activeLaneCount = this.deps.getActiveLaneCount();\n\t\tif (activeLaneCount > 0) {\n\t\t\tsnapshot.activeLaneCount = activeLaneCount;\n\t\t}\n\n\t\treturn snapshot;\n\t}\n\n\t/**\n\t * Aggregate an effectiveness/autonomy dashboard: what Pi has actually been doing (recent\n\t * route choices, latest gate outcome, cost, and any research/delegation/learning/goal\n\t * activity). Read-only — combines existing session-log getters, never mutates state or\n\t * recomputes a route/gate decision.\n\t */\n\tgetDiagnosticSnapshot(options?: { maxEntriesPerFamily?: number }): AutonomyDiagnosticSnapshot {\n\t\tconst maxEntriesPerFamily = options?.maxEntriesPerFamily ?? 10;\n\t\tconst snapshot: AutonomyDiagnosticSnapshot = {};\n\t\tconst goal = this.deps.getGoalStateSnapshot();\n\n\t\tconst recentDecisions = getRecentModelRouterDecisions(\n\t\t\tthis.deps.getSessionManager().getEntries(),\n\t\t\tmaxEntriesPerFamily,\n\t\t);\n\t\tif (recentDecisions.length > 0) {\n\t\t\tsnapshot.routes = recentDecisions.map(\n\t\t\t\t(decision): DiagnosticEntry => ({\n\t\t\t\t\ttitle: decision.route.tier,\n\t\t\t\t\tsummary: decision.routedModel,\n\t\t\t\t\treasonCode: decision.route.reasonCode,\n\t\t\t\t\tmetadata: { risk: decision.route.risk, outcome: decision.outcome, intent: decision.intent },\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (this._lastAutonomyGateOutcome) {\n\t\t\tconst gate = this._lastAutonomyGateOutcome;\n\t\t\tsnapshot.gates = [\n\t\t\t\t{\n\t\t\t\t\ttitle: gate.gate,\n\t\t\t\t\tsummary: gate.message,\n\t\t\t\t\treasonCode: gate.reasonCode,\n\t\t\t\t\tmetadata: { outcome: gate.outcome, reversible: gate.reversible },\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst costs: DiagnosticEntry[] = [];\n\t\tconst costSummary = this.deps.getCostSummary();\n\t\tif (costSummary.currentCost > 0 || hasSubagentCostSignal(costSummary)) {\n\t\t\tcosts.push({ title: \"CURRENT\", summary: `$${costSummary.currentCost.toFixed(4)}` });\n\t\t}\n\t\tif (costSummary.todayCost > 0) {\n\t\t\tcosts.push({ title: \"TODAY\", summary: `$${costSummary.todayCost.toFixed(4)}` });\n\t\t}\n\t\tif (hasSubagentCostSignal(costSummary)) {\n\t\t\tcosts.push({\n\t\t\t\ttitle: \"SUBAGENTS\",\n\t\t\t\tsummary: `$${costSummary.subagentCost.toFixed(4)} included in CURRENT`,\n\t\t\t});\n\t\t}\n\t\tif (costs.length > 0) snapshot.costs = costs;\n\n\t\tconst researchEntries: DiagnosticEntry[] = [];\n\t\tconst researchLaneRecords = getLaneRecordSnapshots(this.deps.getSessionManager().getEntries()).filter(\n\t\t\t(record) => record.type === \"research\",\n\t\t);\n\t\tfor (const record of researchLaneRecords.slice(-maxEntriesPerFamily)) {\n\t\t\tresearchEntries.push({\n\t\t\t\ttitle: `Lane ${record.laneId} (${record.status})`,\n\t\t\t\treasonCode: record.reasonCode,\n\t\t\t\tmetadata: {\n\t\t\t\t\tcostUsd: record.costUsd,\n\t\t\t\t\tstartedAt: record.startedAt,\n\t\t\t\t\tcompletedAt: record.completedAt,\n\t\t\t\t\tgoalId: record.goalId,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tfor (const bundle of this.deps.getSessionEvidenceBundleHistory().slice(-maxEntriesPerFamily)) {\n\t\t\tresearchEntries.push({\n\t\t\t\ttitle: `Research: ${bundle.query}`,\n\t\t\t\tmetadata: { sourceCount: bundle.sources.length, findingCount: bundle.findings.length },\n\t\t\t});\n\t\t}\n\t\tif (this.deps.getLastResearchLaneSkipReason()) {\n\t\t\tresearchEntries.push({ title: \"Last skip\", reasonCode: this.deps.getLastResearchLaneSkipReason() });\n\t\t}\n\t\tif (researchEntries.length > 0) {\n\t\t\tsnapshot.research = researchEntries;\n\t\t}\n\n\t\tconst delegationEntries: DiagnosticEntry[] = [];\n\t\tconst workerLaneRecords = getLaneRecordSnapshots(this.deps.getSessionManager().getEntries()).filter(\n\t\t\t(record) => record.type === \"worker\",\n\t\t);\n\t\tfor (const record of workerLaneRecords.slice(-maxEntriesPerFamily)) {\n\t\t\tdelegationEntries.push({\n\t\t\t\ttitle: `Lane ${record.laneId} (${record.status})`,\n\t\t\t\treasonCode: record.reasonCode,\n\t\t\t\tmetadata: { costUsd: record.costUsd, startedAt: record.startedAt, completedAt: record.completedAt },\n\t\t\t});\n\t\t}\n\t\tconst workerClaims = this.deps.getSessionWorkerClaimHistory();\n\t\tfor (const claim of workerClaims.slice(-maxEntriesPerFamily)) {\n\t\t\tdelegationEntries.push({\n\t\t\t\ttitle: `Worker ${claim.requestId} (${claim.status})`,\n\t\t\t\tsummary: claim.summary,\n\t\t\t\tmetadata: {\n\t\t\t\t\tchangedFileCount: claim.changedFiles.length,\n\t\t\t\t\tblockerCount: claim.blockers?.length ?? 0,\n\t\t\t\t\tusageReportId: claim.usageReportId,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tif (delegationEntries.length > 0) {\n\t\t\tsnapshot.delegation = delegationEntries;\n\t\t}\n\n\t\tconst learningEntries: DiagnosticEntry[] = [];\n\t\tconst learningDecisions = this.deps.getSessionLearningDecisionHistory();\n\t\tfor (const decision of learningDecisions.slice(-maxEntriesPerFamily)) {\n\t\t\tlearningEntries.push({\n\t\t\t\ttitle: `Learning (${decision.kind})`,\n\t\t\t\tsummary: decision.summary,\n\t\t\t\treasonCode: decision.reasonCode,\n\t\t\t\tmetadata: { confidence: decision.confidence, requiresApproval: decision.requiresApproval },\n\t\t\t});\n\t\t}\n\t\tfor (const audit of this.deps.getLearningAuditRecords().slice(-maxEntriesPerFamily)) {\n\t\t\tlearningEntries.push({\n\t\t\t\ttitle: `Audit ${audit.id} (${audit.action})`,\n\t\t\t\tsummary: audit.summary,\n\t\t\t\treasonCode: audit.reasonCode,\n\t\t\t\tmetadata: { layer: audit.layer, proposalId: audit.proposalId, rollbackOf: audit.rollbackOf },\n\t\t\t});\n\t\t}\n\t\tif (learningEntries.length > 0) {\n\t\t\tsnapshot.learning = learningEntries;\n\t\t}\n\n\t\tif (goal) {\n\t\t\tsnapshot.goals = [\n\t\t\t\t{\n\t\t\t\t\ttitle: `Goal ${goal.goalId}`,\n\t\t\t\t\tsummary: goal.userGoal,\n\t\t\t\t\treasonCode: goal.status,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\topenRequirementCount: goal.requirements.filter((requirement) => requirement.status === \"open\").length,\n\t\t\t\t\t\tstallTurns: goal.stallTurns,\n\t\t\t\t\t\tblockedReason: goal.blockedReason,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst processMemory = getProcessMemoryMb();\n\t\tsnapshot.processMemory = [\n\t\t\t{\n\t\t\t\ttitle: \"process\",\n\t\t\t\tmetadata: {\n\t\t\t\t\trssMb: processMemory.rssMb,\n\t\t\t\t\theapUsedMb: processMemory.heapUsedMb,\n\t\t\t\t\texternalMb: processMemory.externalMb,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn snapshot;\n\t}\n}\n"]}
1
+ {"version":3,"file":"autonomy-telemetry.js","sourceRoot":"","sources":["../../src/core/autonomy-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAA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ACtB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE;aAC5F,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,QAAQ,CAAC,QAAQ,GAAG,eAAe,CAAC;QACrC,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACV,QAAQ,CAAC,KAAK,GAAG;gBAChB;oBACC,KAAK,EAAE,QAAQ,IAAI,CAAC,MAAM,EAAE;oBAC5B,OAAO,EAAE,IAAI,CAAC,QAAQ;oBACtB,UAAU,EAAE,IAAI,CAAC,MAAM;oBACvB,QAAQ,EAAE;wBACT,oBAAoB,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM;wBACrG,UAAU,EAAE,IAAI,CAAC,UAAU;wBAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;qBACjC;iBACD;aACD,CAAC;QACH,CAAC;QAED,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC;QAC3C,QAAQ,CAAC,aAAa,GAAG;YACxB;gBACC,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE;oBACT,KAAK,EAAE,aAAa,CAAC,KAAK;oBAC1B,UAAU,EAAE,aAAa,CAAC,UAAU;oBACpC,UAAU,EAAE,aAAa,CAAC,UAAU;iBACpC;aACD;SACD,CAAC;QAEF,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["/**\n * Autonomy telemetry sink + status/diagnostic snapshots.\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). Owns the latest gate outcome\n * and the bounded gate-outcome history, and is the single sink for G3 autonomy-telemetry custom\n * entries. The two snapshot builders READ broadly across live session state (router decision, cost,\n * goal, lanes, and the research/delegation/learning/goal getters) through narrow deps accessors\n * rather than the whole AgentSession — they never mutate anything but the owned gate-outcome fields.\n */\n\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { getProcessMemoryMb } from \"../utils/process-memory.ts\";\nimport type { EvidenceBundle, GateOutcome, LearningDecision, WorkerClaim } from \"./autonomy/contracts.ts\";\nimport { getLaneRecordSnapshots } from \"./autonomy/session-lane-record.ts\";\nimport type {\n\tAutonomyDiagnosticSnapshot,\n\tAutonomyStatusSnapshot,\n\tDiagnosticEntry,\n\tGateOutcomeHistoryEntry,\n} from \"./autonomy/status.ts\";\nimport {\n\tAUTONOMY_TELEMETRY_EVENT_TYPES,\n\ttype AutonomyTelemetryEvent,\n\tredactTelemetryValue,\n} from \"./autonomy/telemetry-events.ts\";\nimport { hasCostSummarySignal, hasSubagentCostSignal, type SessionCostSummary } from \"./cost/cost-summary.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport type { LearningAuditRecord } from \"./learning/learning-audit.ts\";\nimport { getRecentModelRouterDecisions, type ModelRouterDecisionStatus } from \"./model-router/status.ts\";\n\n/** Custom-entry type for G3 autonomy telemetry. Distinct from the router/lane record types so a\n * telemetry consumer can filter on it without decoding operational snapshots. */\nconst AUTONOMY_TELEMETRY_CUSTOM_TYPE = \"autonomy-telemetry\";\n\n/** G8: bound on the in-memory gate-outcome history. Oldest entries evict once the cap is reached. */\nconst GATE_OUTCOME_HISTORY_LIMIT = 50;\n\nexport interface AutonomyTelemetryDeps {\n\t/** Session log: `appendCustomEntry` is the telemetry sink; `getEntries` feeds diagnostic aggregation. */\n\tgetSessionManager(): Pick<SessionManager, \"appendCustomEntry\" | \"getEntries\">;\n\t/** Latest model-router decision, for the snapshot's `latestRoute` — owned by the router, not this sink. */\n\tgetLastModelRouterDecision(): ModelRouterDecisionStatus | undefined;\n\t/** Reason the last research lane was skipped, if any — surfaced in the diagnostic's research family. */\n\tgetLastResearchLaneSkipReason(): string | undefined;\n\t/** Single source of truth for CURRENT/TODAY/SUBAGENTS display costs. */\n\tgetCostSummary(): SessionCostSummary;\n\t/** Current goal state, if a goal is active. */\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\t/** Live count of active lanes from the lane tracker — never inferred from historical snapshots. */\n\tgetActiveLaneCount(): number;\n\t/** Research evidence bundles across the complete session tree, including sibling branches. */\n\tgetSessionEvidenceBundleHistory(): EvidenceBundle[];\n\t/** Worker-delegation claims across the complete session tree, including sibling branches. */\n\tgetSessionWorkerClaimHistory(): WorkerClaim[];\n\t/** Learning decisions across the complete session tree, including sibling branches. */\n\tgetSessionLearningDecisionHistory(): LearningDecision[];\n\t/** Learning audit records recorded this session. */\n\tgetLearningAuditRecords(): LearningAuditRecord[];\n}\n\nexport class AutonomyTelemetry {\n\tprivate _lastAutonomyGateOutcome?: GateOutcome;\n\t/** G8: bounded (cap {@link GATE_OUTCOME_HISTORY_LIMIT}) history of gate outcomes; tail is latest. */\n\tprivate readonly _gateOutcomeHistory: GateOutcomeHistoryEntry[] = [];\n\n\tprivate readonly deps: AutonomyTelemetryDeps;\n\n\tconstructor(deps: AutonomyTelemetryDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\t/**\n\t * G3: bounded autonomy-telemetry sink. Passes the whole event through {@link redactTelemetryValue}\n\t * (the taxonomy's redaction contract) before storing it, so a secret that leaked into a payload\n\t * field never lands in the session log. Observe-only: a failure here can never surface into the\n\t * turn it is measuring, so the whole body is swallowed. Payloads MUST stay small (ids, codes,\n\t * numbers) — never prompt/summary text; callers own that discipline.\n\t */\n\temitTelemetry(event: AutonomyTelemetryEvent): void {\n\t\ttry {\n\t\t\tconst redacted = redactTelemetryValue(event) as Record<string, unknown>;\n\t\t\tthis.deps.getSessionManager().appendCustomEntry(AUTONOMY_TELEMETRY_CUSTOM_TYPE, { version: 1, ...redacted });\n\t\t} catch {\n\t\t\t// Telemetry is best-effort: swallow so a sink failure cannot break the observed turn.\n\t\t}\n\t}\n\n\t/**\n\t * G8: single sink for a gate outcome. Keeps the latest-outcome getter behavior identical (the\n\t * full {@link GateOutcome} still lands in `_lastAutonomyGateOutcome`), and additionally appends a\n\t * bounded codes-only entry to {@link _gateOutcomeHistory} (oldest evicted at\n\t * {@link GATE_OUTCOME_HISTORY_LIMIT}) and emits the `gate_outcome` telemetry event. The history\n\t * tail therefore always mirrors the latest outcome. Only called with an active envelope.\n\t */\n\trecordGateOutcome(outcome: GateOutcome): void {\n\t\tthis._lastAutonomyGateOutcome = outcome;\n\t\tconst at = new Date().toISOString();\n\t\tthis._gateOutcomeHistory.push({\n\t\t\toutcome: outcome.outcome,\n\t\t\tgate: outcome.gate,\n\t\t\treasonCode: outcome.reasonCode,\n\t\t\tat,\n\t\t});\n\t\twhile (this._gateOutcomeHistory.length > GATE_OUTCOME_HISTORY_LIMIT) {\n\t\t\tthis._gateOutcomeHistory.shift();\n\t\t}\n\t\t// G8: gate outcome event. Codes/ids only — never the gate's human-facing message.\n\t\tthis.emitTelemetry({\n\t\t\ttype: AUTONOMY_TELEMETRY_EVENT_TYPES.gateOutcome,\n\t\t\ttimestamp: at,\n\t\t\tpayload: {\n\t\t\t\toutcome: outcome.outcome,\n\t\t\t\tgate: outcome.gate,\n\t\t\t\treasonCode: outcome.reasonCode,\n\t\t\t},\n\t\t});\n\t}\n\n\t/** G8: copies of the bounded gate-outcome history, oldest first, latest last. */\n\tgetGateOutcomeHistory(): GateOutcomeHistoryEntry[] {\n\t\treturn this._gateOutcomeHistory.map((entry) => ({ ...entry }));\n\t}\n\n\tgetStatusSnapshot(): AutonomyStatusSnapshot {\n\t\tconst snapshot: AutonomyStatusSnapshot = {};\n\n\t\tconst lastRouterDecision = this.deps.getLastModelRouterDecision();\n\t\tif (lastRouterDecision?.route) {\n\t\t\tsnapshot.latestRoute = {\n\t\t\t\ttier: lastRouterDecision.route.tier,\n\t\t\t\treasonCode: lastRouterDecision.route.reasonCode,\n\t\t\t\trisk: lastRouterDecision.route.risk,\n\t\t\t};\n\t\t}\n\n\t\tif (this._lastAutonomyGateOutcome) {\n\t\t\tsnapshot.latestGate = {\n\t\t\t\toutcome: this._lastAutonomyGateOutcome.outcome,\n\t\t\t\tgate: this._lastAutonomyGateOutcome.gate,\n\t\t\t\treasonCode: this._lastAutonomyGateOutcome.reasonCode,\n\t\t\t};\n\t\t}\n\n\t\tconst costSummary = this.deps.getCostSummary();\n\t\tif (hasCostSummarySignal(costSummary)) {\n\t\t\tsnapshot.costSummary = costSummary;\n\t\t}\n\n\t\tconst goal = this.deps.getGoalStateSnapshot();\n\t\tif (goal) {\n\t\t\tsnapshot.activeGoal = {\n\t\t\t\tgoalId: goal.goalId,\n\t\t\t\tstatus: goal.status,\n\t\t\t\topenRequirements: goal.requirements.filter((requirement) => requirement.status === \"open\").length,\n\t\t\t\tstallTurns: goal.stallTurns,\n\t\t\t};\n\t\t}\n\n\t\t// Real live count from the lane tracker — never inferred from historical snapshots. Absent\n\t\t// while zero, matching the presence-means-signal convention of the sibling fields.\n\t\tconst activeLaneCount = this.deps.getActiveLaneCount();\n\t\tif (activeLaneCount > 0) {\n\t\t\tsnapshot.activeLaneCount = activeLaneCount;\n\t\t}\n\n\t\treturn snapshot;\n\t}\n\n\t/**\n\t * Aggregate an effectiveness/autonomy dashboard: what Pi has actually been doing (recent\n\t * route choices, latest gate outcome, cost, and any research/delegation/learning/goal\n\t * activity). Read-only — combines existing session-log getters, never mutates state or\n\t * recomputes a route/gate decision.\n\t */\n\tgetDiagnosticSnapshot(options?: { maxEntriesPerFamily?: number }): AutonomyDiagnosticSnapshot {\n\t\tconst maxEntriesPerFamily = options?.maxEntriesPerFamily ?? 10;\n\t\tconst snapshot: AutonomyDiagnosticSnapshot = {};\n\t\tconst goal = this.deps.getGoalStateSnapshot();\n\n\t\tconst recentDecisions = getRecentModelRouterDecisions(\n\t\t\tthis.deps.getSessionManager().getEntries(),\n\t\t\tmaxEntriesPerFamily,\n\t\t);\n\t\tif (recentDecisions.length > 0) {\n\t\t\tsnapshot.routes = recentDecisions.map(\n\t\t\t\t(decision): DiagnosticEntry => ({\n\t\t\t\t\ttitle: decision.route.tier,\n\t\t\t\t\tsummary: decision.routedModel,\n\t\t\t\t\treasonCode: decision.route.reasonCode,\n\t\t\t\t\tmetadata: { risk: decision.route.risk, outcome: decision.outcome, intent: decision.intent },\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (this._lastAutonomyGateOutcome) {\n\t\t\tconst gate = this._lastAutonomyGateOutcome;\n\t\t\tsnapshot.gates = [\n\t\t\t\t{\n\t\t\t\t\ttitle: gate.gate,\n\t\t\t\t\tsummary: gate.message,\n\t\t\t\t\treasonCode: gate.reasonCode,\n\t\t\t\t\tmetadata: { outcome: gate.outcome, reversible: gate.reversible },\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst costs: DiagnosticEntry[] = [];\n\t\tconst costSummary = this.deps.getCostSummary();\n\t\tif (costSummary.currentCost > 0 || hasSubagentCostSignal(costSummary)) {\n\t\t\tcosts.push({ title: \"CURRENT\", summary: `$${costSummary.currentCost.toFixed(4)}` });\n\t\t}\n\t\tif (costSummary.todayCost > 0) {\n\t\t\tcosts.push({ title: \"TODAY\", summary: `$${costSummary.todayCost.toFixed(4)}` });\n\t\t}\n\t\tif (hasSubagentCostSignal(costSummary)) {\n\t\t\tcosts.push({\n\t\t\t\ttitle: \"SUBAGENTS\",\n\t\t\t\tsummary: `$${costSummary.subagentCost.toFixed(4)} included in CURRENT`,\n\t\t\t});\n\t\t}\n\t\tif (costs.length > 0) snapshot.costs = costs;\n\n\t\tconst researchEntries: DiagnosticEntry[] = [];\n\t\tconst researchLaneRecords = getLaneRecordSnapshots(this.deps.getSessionManager().getEntries()).filter(\n\t\t\t(record) => record.type === \"research\",\n\t\t);\n\t\tfor (const record of researchLaneRecords.slice(-maxEntriesPerFamily)) {\n\t\t\tresearchEntries.push({\n\t\t\t\ttitle: `Lane ${record.laneId} (${record.status})`,\n\t\t\t\treasonCode: record.reasonCode,\n\t\t\t\tmetadata: {\n\t\t\t\t\tcostUsd: record.costUsd,\n\t\t\t\t\tstartedAt: record.startedAt,\n\t\t\t\t\tcompletedAt: record.completedAt,\n\t\t\t\t\tgoalId: record.goalId,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tfor (const bundle of this.deps.getSessionEvidenceBundleHistory().slice(-maxEntriesPerFamily)) {\n\t\t\tresearchEntries.push({\n\t\t\t\ttitle: `Research: ${bundle.query}`,\n\t\t\t\tmetadata: { sourceCount: bundle.sources.length, findingCount: bundle.findings.length },\n\t\t\t});\n\t\t}\n\t\tif (this.deps.getLastResearchLaneSkipReason()) {\n\t\t\tresearchEntries.push({ title: \"Last skip\", reasonCode: this.deps.getLastResearchLaneSkipReason() });\n\t\t}\n\t\tif (researchEntries.length > 0) {\n\t\t\tsnapshot.research = researchEntries;\n\t\t}\n\n\t\tconst delegationEntries: DiagnosticEntry[] = [];\n\t\tconst workerLaneRecords = getLaneRecordSnapshots(this.deps.getSessionManager().getEntries()).filter(\n\t\t\t(record) => record.type === \"worker\",\n\t\t);\n\t\tfor (const record of workerLaneRecords.slice(-maxEntriesPerFamily)) {\n\t\t\tdelegationEntries.push({\n\t\t\t\ttitle: `Lane ${record.laneId} (${record.status})`,\n\t\t\t\treasonCode: record.reasonCode,\n\t\t\t\tmetadata: { costUsd: record.costUsd, startedAt: record.startedAt, completedAt: record.completedAt },\n\t\t\t});\n\t\t}\n\t\tconst workerClaims = this.deps.getSessionWorkerClaimHistory();\n\t\tfor (const claim of workerClaims.slice(-maxEntriesPerFamily)) {\n\t\t\tdelegationEntries.push({\n\t\t\t\ttitle: `Worker ${claim.requestId} (${claim.status})`,\n\t\t\t\tsummary: claim.summary,\n\t\t\t\tmetadata: {\n\t\t\t\t\tchangedFileCount: claim.changedFiles.length,\n\t\t\t\t\tblockerCount: claim.blockers?.length ?? 0,\n\t\t\t\t\tusageReportId: claim.usageReportId,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tif (delegationEntries.length > 0) {\n\t\t\tsnapshot.delegation = delegationEntries;\n\t\t}\n\n\t\tconst learningEntries: DiagnosticEntry[] = [];\n\t\tconst learningDecisions = this.deps.getSessionLearningDecisionHistory();\n\t\tfor (const decision of learningDecisions.slice(-maxEntriesPerFamily)) {\n\t\t\tlearningEntries.push({\n\t\t\t\ttitle: `Learning (${decision.kind})`,\n\t\t\t\tsummary: decision.summary,\n\t\t\t\treasonCode: decision.reasonCode,\n\t\t\t\tmetadata: { confidence: decision.confidence, requiresApproval: decision.requiresApproval },\n\t\t\t});\n\t\t}\n\t\tfor (const audit of this.deps.getLearningAuditRecords().slice(-maxEntriesPerFamily)) {\n\t\t\tlearningEntries.push({\n\t\t\t\ttitle: `Audit ${audit.id} (${audit.action})`,\n\t\t\t\tsummary: audit.summary,\n\t\t\t\treasonCode: audit.reasonCode,\n\t\t\t\tmetadata: { layer: audit.layer, proposalId: audit.proposalId, rollbackOf: audit.rollbackOf },\n\t\t\t});\n\t\t}\n\t\tif (learningEntries.length > 0) {\n\t\t\tsnapshot.learning = learningEntries;\n\t\t}\n\n\t\tif (goal) {\n\t\t\tsnapshot.goals = [\n\t\t\t\t{\n\t\t\t\t\ttitle: `Goal ${goal.goalId}`,\n\t\t\t\t\tsummary: goal.userGoal,\n\t\t\t\t\treasonCode: goal.status,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\topenRequirementCount: goal.requirements.filter((requirement) => requirement.status === \"open\").length,\n\t\t\t\t\t\tstallTurns: goal.stallTurns,\n\t\t\t\t\t\tblockedReason: goal.blockedReason,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst processMemory = getProcessMemoryMb();\n\t\tsnapshot.processMemory = [\n\t\t\t{\n\t\t\t\ttitle: \"process\",\n\t\t\t\tmetadata: {\n\t\t\t\t\trssMb: processMemory.rssMb,\n\t\t\t\t\theapUsedMb: processMemory.heapUsedMb,\n\t\t\t\t\texternalMb: processMemory.externalMb,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn snapshot;\n\t}\n}\n"]}
@@ -16,6 +16,7 @@
16
16
  import type { Api, Model } from "@caupulican/pi-ai";
17
17
  import type { GoalContinuationLoopOptions, GoalContinuationLoopResult, PromptOptions, ResearchLaneRunOutcome, WorkerDelegationRunOutcome } from "./agent-session-contracts.ts";
18
18
  import { type LaneRecord } from "./autonomy/lane-tracker.ts";
19
+ import type { WorkerAgentControlPort } from "./delegation/worker-agent-control.ts";
19
20
  import { type WorkerDelegationControllerDeps } from "./delegation/worker-delegation-controller.ts";
20
21
  import type { WorkerDelegationRequest } from "./delegation/worker-delegation-request.ts";
21
22
  import type { ManagedLaneEvent } from "./extensions/types.ts";
@@ -45,7 +46,7 @@ export interface BackgroundLaneControllerDeps extends WorkerDelegationController
45
46
  /** Persist an explicit stopped state when the selected surface cannot drive the active goal. */
46
47
  markGoalToolUnavailable(): void;
47
48
  }
48
- export declare class BackgroundLaneController {
49
+ export declare class BackgroundLaneController implements WorkerAgentControlPort {
49
50
  /** Live lane registry — the real source for AutonomyStatusSnapshot.activeLaneCount. */
50
51
  private readonly _laneTracker;
51
52
  private readonly _laneModels;
@@ -141,6 +142,31 @@ export declare class BackgroundLaneController {
141
142
  started: true;
142
143
  record: LaneRecord;
143
144
  };
145
+ /** Durable logical-worker controls. Each checks UAC before materializing worker state. */
146
+ sendWorkerAgentMessage(agentId: string, message: string): {
147
+ messageId: string;
148
+ queued: true;
149
+ };
150
+ followUpWorkerAgent(agentId: string, message: string): {
151
+ started: boolean;
152
+ steering: boolean;
153
+ messageId: string;
154
+ record?: LaneRecord;
155
+ skipReason?: string;
156
+ };
157
+ interruptWorkerAgent(agentId: string): {
158
+ interrupted: boolean;
159
+ reason?: string;
160
+ };
161
+ resumeWorkerAgent(agentId: string): {
162
+ started: boolean;
163
+ record?: LaneRecord;
164
+ skipReason?: string;
165
+ };
166
+ cancelWorkerAgent(agentId: string, reasonCode?: string): LaneRecord | undefined;
167
+ waitForWorkerAgent(agentId: string, timeoutMs?: number): Promise<{
168
+ status: "active" | "suspended" | "idle" | "unknown";
169
+ }>;
144
170
  /** Run one worker immediately; used by focused integrations and tests. */
145
171
  runWorkerDelegationOnce(request: WorkerDelegationRequest, onStarted?: (record: LaneRecord) => void, existingRecord?: LaneRecord): Promise<WorkerDelegationRunOutcome>;
146
172
  /**