@caupulican/pi-adaptative 0.85.4 → 0.86.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (480) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/bun/cli.d.ts +1 -1
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js +1 -0
  5. package/dist/bun/cli.js.map +1 -1
  6. package/dist/core/agent-paths.d.ts +3 -3
  7. package/dist/core/agent-paths.d.ts.map +1 -1
  8. package/dist/core/agent-paths.js +3 -3
  9. package/dist/core/agent-paths.js.map +1 -1
  10. package/dist/core/agent-session-runtime.d.ts +1 -1
  11. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  12. package/dist/core/agent-session-runtime.js +1 -1
  13. package/dist/core/agent-session-runtime.js.map +1 -1
  14. package/dist/core/agent-session.d.ts +11 -5
  15. package/dist/core/agent-session.d.ts.map +1 -1
  16. package/dist/core/agent-session.js +14 -3
  17. package/dist/core/agent-session.js.map +1 -1
  18. package/dist/core/auth-storage.d.ts +2 -2
  19. package/dist/core/auth-storage.d.ts.map +1 -1
  20. package/dist/core/auth-storage.js +2 -2
  21. package/dist/core/auth-storage.js.map +1 -1
  22. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  23. package/dist/core/autonomy/bounded-completion.js +19 -8
  24. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  25. package/dist/core/autonomy/lane-tool-surface.d.ts +11 -5
  26. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  27. package/dist/core/autonomy/lane-tool-surface.js +34 -8
  28. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  29. package/dist/core/autonomy/subagent-prompt.d.ts +3 -3
  30. package/dist/core/autonomy/subagent-prompt.js +9 -9
  31. package/dist/core/autonomy/subagent-prompt.js.map +1 -1
  32. package/dist/core/background-lane-controller.d.ts +10 -8
  33. package/dist/core/background-lane-controller.d.ts.map +1 -1
  34. package/dist/core/background-lane-controller.js +23 -13
  35. package/dist/core/background-lane-controller.js.map +1 -1
  36. package/dist/core/bash-execution-controller.d.ts +4 -0
  37. package/dist/core/bash-execution-controller.d.ts.map +1 -1
  38. package/dist/core/bash-execution-controller.js +11 -4
  39. package/dist/core/bash-execution-controller.js.map +1 -1
  40. package/dist/core/bash-executor.d.ts +2 -0
  41. package/dist/core/bash-executor.d.ts.map +1 -1
  42. package/dist/core/bash-executor.js +4 -3
  43. package/dist/core/bash-executor.js.map +1 -1
  44. package/dist/core/billing-failover-controller.d.ts +2 -2
  45. package/dist/core/billing-failover-controller.d.ts.map +1 -1
  46. package/dist/core/billing-failover-controller.js +1 -1
  47. package/dist/core/billing-failover-controller.js.map +1 -1
  48. package/dist/core/capability-contract.d.ts +1 -1
  49. package/dist/core/capability-contract.d.ts.map +1 -1
  50. package/dist/core/capability-contract.js +0 -1
  51. package/dist/core/capability-contract.js.map +1 -1
  52. package/dist/core/compaction-controller.d.ts +8 -2
  53. package/dist/core/compaction-controller.d.ts.map +1 -1
  54. package/dist/core/compaction-controller.js +73 -3
  55. package/dist/core/compaction-controller.js.map +1 -1
  56. package/dist/core/compaction-support.d.ts +2 -2
  57. package/dist/core/compaction-support.d.ts.map +1 -1
  58. package/dist/core/compaction-support.js +9 -1
  59. package/dist/core/compaction-support.js.map +1 -1
  60. package/dist/core/context/artifact-retrieval.d.ts +1 -1
  61. package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
  62. package/dist/core/context/artifact-retrieval.js +1 -1
  63. package/dist/core/context/artifact-retrieval.js.map +1 -1
  64. package/dist/core/context/context-artifacts.d.ts +6 -6
  65. package/dist/core/context/context-artifacts.d.ts.map +1 -1
  66. package/dist/core/context/context-artifacts.js +151 -63
  67. package/dist/core/context/context-artifacts.js.map +1 -1
  68. package/dist/core/context/context-composition.js +1 -1
  69. package/dist/core/context/context-composition.js.map +1 -1
  70. package/dist/core/context/context-store-retention.d.ts.map +1 -1
  71. package/dist/core/context/context-store-retention.js +5 -2
  72. package/dist/core/context/context-store-retention.js.map +1 -1
  73. package/dist/core/context/file-store-memory-provider.js +1 -1
  74. package/dist/core/context/file-store-memory-provider.js.map +1 -1
  75. package/dist/core/context/tool-output-packer.d.ts +1 -1
  76. package/dist/core/context/tool-output-packer.d.ts.map +1 -1
  77. package/dist/core/context/tool-output-packer.js +1 -1
  78. package/dist/core/context/tool-output-packer.js.map +1 -1
  79. package/dist/core/context-gc.d.ts.map +1 -1
  80. package/dist/core/context-gc.js +7 -5
  81. package/dist/core/context-gc.js.map +1 -1
  82. package/dist/core/context-pipeline.d.ts +2 -2
  83. package/dist/core/context-pipeline.d.ts.map +1 -1
  84. package/dist/core/context-pipeline.js +8 -4
  85. package/dist/core/context-pipeline.js.map +1 -1
  86. package/dist/core/cost/cost-summary.d.ts +1 -1
  87. package/dist/core/cost/cost-summary.d.ts.map +1 -1
  88. package/dist/core/cost/cost-summary.js +1 -1
  89. package/dist/core/cost/cost-summary.js.map +1 -1
  90. package/dist/core/cost/daily-usage.d.ts +1 -1
  91. package/dist/core/cost/daily-usage.d.ts.map +1 -1
  92. package/dist/core/cost/daily-usage.js +2 -2
  93. package/dist/core/cost/daily-usage.js.map +1 -1
  94. package/dist/core/cost/session-usage.d.ts +1 -1
  95. package/dist/core/cost/session-usage.d.ts.map +1 -1
  96. package/dist/core/cost/session-usage.js +1 -1
  97. package/dist/core/cost/session-usage.js.map +1 -1
  98. package/dist/core/default-tool-surface.d.ts +1 -0
  99. package/dist/core/default-tool-surface.d.ts.map +1 -1
  100. package/dist/core/default-tool-surface.js +3 -2
  101. package/dist/core/default-tool-surface.js.map +1 -1
  102. package/dist/core/delegation/worker-actions.js +1 -1
  103. package/dist/core/delegation/worker-actions.js.map +1 -1
  104. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +27 -8
  105. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  106. package/dist/core/delegation/worker-agent-control-coordinator.js +191 -33
  107. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  108. package/dist/core/delegation/worker-agent-control.d.ts +45 -6
  109. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  110. package/dist/core/delegation/worker-agent-control.js +110 -13
  111. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  112. package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
  113. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  114. package/dist/core/delegation/worker-attempt-executor.js +180 -160
  115. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  116. package/dist/core/delegation/worker-authority-resolver.d.ts +23 -0
  117. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -0
  118. package/dist/core/delegation/worker-authority-resolver.js +128 -0
  119. package/dist/core/delegation/worker-authority-resolver.js.map +1 -0
  120. package/dist/core/delegation/worker-conversation-store.d.ts +2 -1
  121. package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
  122. package/dist/core/delegation/worker-conversation-store.js +4 -3
  123. package/dist/core/delegation/worker-conversation-store.js.map +1 -1
  124. package/dist/core/delegation/worker-delegation-controller.d.ts +7 -1
  125. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  126. package/dist/core/delegation/worker-delegation-controller.js +260 -87
  127. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  128. package/dist/core/delegation/worker-delegation-request.d.ts +25 -4
  129. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  130. package/dist/core/delegation/worker-delegation-request.js +90 -1
  131. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  132. package/dist/core/delegation/worker-execution-policy.d.ts +2 -0
  133. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  134. package/dist/core/delegation/worker-execution-policy.js +22 -12
  135. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  136. package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
  137. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  138. package/dist/core/delegation/worker-lifecycle.js +4 -2
  139. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  140. package/dist/core/delegation/worker-profile-resolver.d.ts +0 -2
  141. package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
  142. package/dist/core/delegation/worker-profile-resolver.js +8 -35
  143. package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
  144. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  145. package/dist/core/delegation/worker-recovery-coordinator.js +1 -0
  146. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  147. package/dist/core/delegation/worker-runner.d.ts +6 -1
  148. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  149. package/dist/core/delegation/worker-runner.js +20 -6
  150. package/dist/core/delegation/worker-runner.js.map +1 -1
  151. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +47 -0
  152. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -0
  153. package/dist/core/delegation/worker-tree-budget-coordinator.js +210 -0
  154. package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -0
  155. package/dist/core/extensions/builtin.d.ts +2 -2
  156. package/dist/core/extensions/builtin.d.ts.map +1 -1
  157. package/dist/core/extensions/builtin.js +2 -2
  158. package/dist/core/extensions/builtin.js.map +1 -1
  159. package/dist/core/extensions/bundled-virtual-modules.d.ts +2 -0
  160. package/dist/core/extensions/bundled-virtual-modules.d.ts.map +1 -0
  161. package/dist/core/extensions/bundled-virtual-modules.js +129 -0
  162. package/dist/core/extensions/bundled-virtual-modules.js.map +1 -0
  163. package/dist/core/extensions/factory-runtime.d.ts +22 -0
  164. package/dist/core/extensions/factory-runtime.d.ts.map +1 -0
  165. package/dist/core/extensions/factory-runtime.js +334 -0
  166. package/dist/core/extensions/factory-runtime.js.map +1 -0
  167. package/dist/core/extensions/index.d.ts +1 -1
  168. package/dist/core/extensions/index.d.ts.map +1 -1
  169. package/dist/core/extensions/index.js +1 -1
  170. package/dist/core/extensions/index.js.map +1 -1
  171. package/dist/core/extensions/lifecycle.d.ts +13 -0
  172. package/dist/core/extensions/lifecycle.d.ts.map +1 -0
  173. package/dist/core/extensions/lifecycle.js +52 -0
  174. package/dist/core/extensions/lifecycle.js.map +1 -0
  175. package/dist/core/extensions/loader.d.ts +3 -24
  176. package/dist/core/extensions/loader.d.ts.map +1 -1
  177. package/dist/core/extensions/loader.js +21 -531
  178. package/dist/core/extensions/loader.js.map +1 -1
  179. package/dist/core/extensions/virtual-modules.d.ts +51 -0
  180. package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
  181. package/dist/core/extensions/virtual-modules.js +59 -0
  182. package/dist/core/extensions/virtual-modules.js.map +1 -0
  183. package/dist/core/foreground-recovery-controller.d.ts +2 -1
  184. package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
  185. package/dist/core/foreground-recovery-controller.js +3 -3
  186. package/dist/core/foreground-recovery-controller.js.map +1 -1
  187. package/dist/core/goal-loop-controller.js +1 -1
  188. package/dist/core/goal-loop-controller.js.map +1 -1
  189. package/dist/core/goals/compact-goal-context.d.ts +1 -1
  190. package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
  191. package/dist/core/goals/compact-goal-context.js +1 -1
  192. package/dist/core/goals/compact-goal-context.js.map +1 -1
  193. package/dist/core/goals/goal-auto-continue-controller.js +1 -1
  194. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  195. package/dist/core/goals/goal-session-controller.d.ts +1 -1
  196. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  197. package/dist/core/goals/goal-session-controller.js +1 -1
  198. package/dist/core/goals/goal-session-controller.js.map +1 -1
  199. package/dist/core/http-dispatcher.d.ts +1 -1
  200. package/dist/core/http-dispatcher.d.ts.map +1 -1
  201. package/dist/core/http-dispatcher.js +1 -1
  202. package/dist/core/http-dispatcher.js.map +1 -1
  203. package/dist/core/index.d.ts +3 -2
  204. package/dist/core/index.d.ts.map +1 -1
  205. package/dist/core/index.js +2 -1
  206. package/dist/core/index.js.map +1 -1
  207. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  208. package/dist/core/memory/providers/file-store.js +1 -1
  209. package/dist/core/memory/providers/file-store.js.map +1 -1
  210. package/dist/core/memory/providers/user-memory-archive.js +1 -1
  211. package/dist/core/memory/providers/user-memory-archive.js.map +1 -1
  212. package/dist/core/model-registry.d.ts +2 -1
  213. package/dist/core/model-registry.d.ts.map +1 -1
  214. package/dist/core/model-registry.js +4 -1
  215. package/dist/core/model-registry.js.map +1 -1
  216. package/dist/core/model-resolver.d.ts +1 -1
  217. package/dist/core/model-resolver.d.ts.map +1 -1
  218. package/dist/core/model-resolver.js +1 -1
  219. package/dist/core/model-resolver.js.map +1 -1
  220. package/dist/core/model-router-controller.js +1 -1
  221. package/dist/core/model-router-controller.js.map +1 -1
  222. package/dist/core/model-selection-controller.js +1 -1
  223. package/dist/core/model-selection-controller.js.map +1 -1
  224. package/dist/core/model-tool-protocol.d.ts +1 -1
  225. package/dist/core/model-tool-protocol.d.ts.map +1 -1
  226. package/dist/core/model-tool-protocol.js +1 -1
  227. package/dist/core/model-tool-protocol.js.map +1 -1
  228. package/dist/core/models/llamacpp-runtime.d.ts +7 -0
  229. package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
  230. package/dist/core/models/llamacpp-runtime.js +8 -3
  231. package/dist/core/models/llamacpp-runtime.js.map +1 -1
  232. package/dist/core/models/local-runtime.js +1 -1
  233. package/dist/core/models/local-runtime.js.map +1 -1
  234. package/dist/core/models/runtime-process.d.ts.map +1 -1
  235. package/dist/core/models/runtime-process.js +5 -18
  236. package/dist/core/models/runtime-process.js.map +1 -1
  237. package/dist/core/orchestration/bounded-string-array.d.ts +11 -0
  238. package/dist/core/orchestration/bounded-string-array.d.ts.map +1 -0
  239. package/dist/core/orchestration/bounded-string-array.js +17 -0
  240. package/dist/core/orchestration/bounded-string-array.js.map +1 -0
  241. package/dist/core/orchestration/capability-gateway.d.ts +16 -0
  242. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  243. package/dist/core/orchestration/capability-gateway.js +38 -0
  244. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  245. package/dist/core/orchestration/contracts.d.ts +11 -3
  246. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  247. package/dist/core/orchestration/contracts.js +0 -1
  248. package/dist/core/orchestration/contracts.js.map +1 -1
  249. package/dist/core/orchestration/delegation-ledger.d.ts +1 -0
  250. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
  251. package/dist/core/orchestration/delegation-ledger.js +3 -0
  252. package/dist/core/orchestration/delegation-ledger.js.map +1 -1
  253. package/dist/core/orchestration/event-store.d.ts +12 -10
  254. package/dist/core/orchestration/event-store.d.ts.map +1 -1
  255. package/dist/core/orchestration/event-store.js +94 -104
  256. package/dist/core/orchestration/event-store.js.map +1 -1
  257. package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
  258. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  259. package/dist/core/orchestration/lane-tool-manifests.js +4 -1
  260. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  261. package/dist/core/orchestration/model-binding.d.ts +1 -1
  262. package/dist/core/orchestration/model-binding.d.ts.map +1 -1
  263. package/dist/core/orchestration/model-binding.js +1 -1
  264. package/dist/core/orchestration/model-binding.js.map +1 -1
  265. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
  266. package/dist/core/orchestration/policy-compiler.js +8 -9
  267. package/dist/core/orchestration/policy-compiler.js.map +1 -1
  268. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  269. package/dist/core/orchestration/profile-registry.js +4 -10
  270. package/dist/core/orchestration/profile-registry.js.map +1 -1
  271. package/dist/core/orchestration/task-profile-writer.js +1 -1
  272. package/dist/core/orchestration/task-profile-writer.js.map +1 -1
  273. package/dist/core/orchestration/task-runtime.d.ts +1 -0
  274. package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
  275. package/dist/core/orchestration/task-runtime.js +58 -3
  276. package/dist/core/orchestration/task-runtime.js.map +1 -1
  277. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  278. package/dist/core/orchestration/worker-execution-contract.js +10 -17
  279. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  280. package/dist/core/process-matrix/runtime.d.ts +15 -1
  281. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  282. package/dist/core/process-matrix/runtime.js +55 -34
  283. package/dist/core/process-matrix/runtime.js.map +1 -1
  284. package/dist/core/reflection-controller.d.ts +4 -3
  285. package/dist/core/reflection-controller.d.ts.map +1 -1
  286. package/dist/core/reflection-controller.js +2 -2
  287. package/dist/core/reflection-controller.js.map +1 -1
  288. package/dist/core/research/model-fitness-controller.js +1 -1
  289. package/dist/core/research/model-fitness-controller.js.map +1 -1
  290. package/dist/core/research/research-lane-controller.d.ts +2 -2
  291. package/dist/core/research/research-lane-controller.d.ts.map +1 -1
  292. package/dist/core/research/research-lane-controller.js +1 -1
  293. package/dist/core/research/research-lane-controller.js.map +1 -1
  294. package/dist/core/resource-loader.d.ts +10 -19
  295. package/dist/core/resource-loader.d.ts.map +1 -1
  296. package/dist/core/resource-loader.js +8 -70
  297. package/dist/core/resource-loader.js.map +1 -1
  298. package/dist/core/risk-classifier.js +3 -3
  299. package/dist/core/risk-classifier.js.map +1 -1
  300. package/dist/core/runtime-builder.d.ts +4 -1
  301. package/dist/core/runtime-builder.d.ts.map +1 -1
  302. package/dist/core/runtime-builder.js +47 -18
  303. package/dist/core/runtime-builder.js.map +1 -1
  304. package/dist/core/scout-controller.d.ts +1 -1
  305. package/dist/core/scout-controller.d.ts.map +1 -1
  306. package/dist/core/scout-controller.js +1 -1
  307. package/dist/core/scout-controller.js.map +1 -1
  308. package/dist/core/sdk.d.ts +2 -2
  309. package/dist/core/sdk.d.ts.map +1 -1
  310. package/dist/core/sdk.js +3 -3
  311. package/dist/core/sdk.js.map +1 -1
  312. package/dist/core/secrets/bitwarden-credential-storage.d.ts +51 -0
  313. package/dist/core/secrets/bitwarden-credential-storage.d.ts.map +1 -0
  314. package/dist/core/secrets/bitwarden-credential-storage.js +345 -0
  315. package/dist/core/secrets/bitwarden-credential-storage.js.map +1 -0
  316. package/dist/core/secrets/credential-exposure-guard.d.ts +8 -4
  317. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  318. package/dist/core/secrets/credential-exposure-guard.js +31 -29
  319. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  320. package/dist/core/secrets/credential-manager.d.ts +109 -0
  321. package/dist/core/secrets/credential-manager.d.ts.map +1 -0
  322. package/dist/core/secrets/credential-manager.js +384 -0
  323. package/dist/core/secrets/credential-manager.js.map +1 -0
  324. package/dist/core/secrets/credential-project.d.ts +4 -0
  325. package/dist/core/secrets/credential-project.d.ts.map +1 -0
  326. package/dist/core/secrets/credential-project.js +145 -0
  327. package/dist/core/secrets/credential-project.js.map +1 -0
  328. package/dist/core/secrets/secret-dotenv.d.ts +1 -1
  329. package/dist/core/secrets/secret-dotenv.js +1 -1
  330. package/dist/core/secrets/secret-dotenv.js.map +1 -1
  331. package/dist/core/security/context-threat-scanner.d.ts +14 -0
  332. package/dist/core/security/context-threat-scanner.d.ts.map +1 -0
  333. package/dist/core/security/context-threat-scanner.js +71 -0
  334. package/dist/core/security/context-threat-scanner.js.map +1 -0
  335. package/dist/core/session-supervision-runtime.d.ts +4 -1
  336. package/dist/core/session-supervision-runtime.d.ts.map +1 -1
  337. package/dist/core/session-supervision-runtime.js +49 -11
  338. package/dist/core/session-supervision-runtime.js.map +1 -1
  339. package/dist/core/settings-manager.d.ts +4 -2
  340. package/dist/core/settings-manager.d.ts.map +1 -1
  341. package/dist/core/settings-manager.js +10 -6
  342. package/dist/core/settings-manager.js.map +1 -1
  343. package/dist/core/slash-commands.d.ts.map +1 -1
  344. package/dist/core/slash-commands.js +1 -0
  345. package/dist/core/slash-commands.js.map +1 -1
  346. package/dist/core/system-prompt.js +1 -1
  347. package/dist/core/system-prompt.js.map +1 -1
  348. package/dist/core/tool-capability-policy.js +2 -2
  349. package/dist/core/tool-capability-policy.js.map +1 -1
  350. package/dist/core/tool-recovery-logger.js +1 -1
  351. package/dist/core/tool-recovery-logger.js.map +1 -1
  352. package/dist/core/tools/artifact-retrieve.js +1 -1
  353. package/dist/core/tools/artifact-retrieve.js.map +1 -1
  354. package/dist/core/tools/bash.d.ts +2 -2
  355. package/dist/core/tools/bash.d.ts.map +1 -1
  356. package/dist/core/tools/bash.js +16 -4
  357. package/dist/core/tools/bash.js.map +1 -1
  358. package/dist/core/tools/delegate.d.ts +29 -1
  359. package/dist/core/tools/delegate.d.ts.map +1 -1
  360. package/dist/core/tools/delegate.js +179 -28
  361. package/dist/core/tools/delegate.js.map +1 -1
  362. package/dist/core/tools/extensionify-runtime.d.ts +44 -0
  363. package/dist/core/tools/extensionify-runtime.d.ts.map +1 -0
  364. package/dist/core/tools/extensionify-runtime.js +115 -0
  365. package/dist/core/tools/extensionify-runtime.js.map +1 -0
  366. package/dist/core/tools/extensionify.d.ts +9 -30
  367. package/dist/core/tools/extensionify.d.ts.map +1 -1
  368. package/dist/core/tools/extensionify.js +10 -140
  369. package/dist/core/tools/extensionify.js.map +1 -1
  370. package/dist/core/tools/find.d.ts +1 -1
  371. package/dist/core/tools/find.d.ts.map +1 -1
  372. package/dist/core/tools/find.js +1 -1
  373. package/dist/core/tools/find.js.map +1 -1
  374. package/dist/core/tools/git-filter.d.ts +1 -0
  375. package/dist/core/tools/git-filter.d.ts.map +1 -1
  376. package/dist/core/tools/git-filter.js +1 -1
  377. package/dist/core/tools/git-filter.js.map +1 -1
  378. package/dist/core/tools/index.d.ts +2 -4
  379. package/dist/core/tools/index.d.ts.map +1 -1
  380. package/dist/core/tools/index.js +7 -43
  381. package/dist/core/tools/index.js.map +1 -1
  382. package/dist/core/tools/ls.d.ts +1 -1
  383. package/dist/core/tools/ls.d.ts.map +1 -1
  384. package/dist/core/tools/ls.js +1 -1
  385. package/dist/core/tools/ls.js.map +1 -1
  386. package/dist/core/tools/output-accumulator.d.ts +1 -1
  387. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  388. package/dist/core/tools/output-accumulator.js +1 -1
  389. package/dist/core/tools/output-accumulator.js.map +1 -1
  390. package/dist/core/tools/profile-writer.js +3 -3
  391. package/dist/core/tools/profile-writer.js.map +1 -1
  392. package/dist/core/tools/python.d.ts +2 -0
  393. package/dist/core/tools/python.d.ts.map +1 -1
  394. package/dist/core/tools/python.js +17 -12
  395. package/dist/core/tools/python.js.map +1 -1
  396. package/dist/core/tools/render-utils.js +1 -1
  397. package/dist/core/tools/render-utils.js.map +1 -1
  398. package/dist/core/tools/run-process.d.ts +2 -0
  399. package/dist/core/tools/run-process.d.ts.map +1 -1
  400. package/dist/core/tools/run-process.js +7 -3
  401. package/dist/core/tools/run-process.js.map +1 -1
  402. package/dist/core/tools/search-command-guard.d.ts +8 -0
  403. package/dist/core/tools/search-command-guard.d.ts.map +1 -1
  404. package/dist/core/tools/search-command-guard.js +54 -0
  405. package/dist/core/tools/search-command-guard.js.map +1 -1
  406. package/dist/core/tools/secret-store.d.ts +8 -18
  407. package/dist/core/tools/secret-store.d.ts.map +1 -1
  408. package/dist/core/tools/secret-store.js +83 -348
  409. package/dist/core/tools/secret-store.js.map +1 -1
  410. package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
  411. package/dist/core/tools/shell-contract-router.js +9 -4
  412. package/dist/core/tools/shell-contract-router.js.map +1 -1
  413. package/dist/core/tools/shell-session.d.ts.map +1 -1
  414. package/dist/core/tools/shell-session.js +6 -4
  415. package/dist/core/tools/shell-session.js.map +1 -1
  416. package/dist/core/tools/tool-definition-factory.d.ts +32 -0
  417. package/dist/core/tools/tool-definition-factory.d.ts.map +1 -0
  418. package/dist/core/tools/tool-definition-factory.js +55 -0
  419. package/dist/core/tools/tool-definition-factory.js.map +1 -0
  420. package/dist/core/util/atomic-file.d.ts.map +1 -1
  421. package/dist/core/util/atomic-file.js +79 -32
  422. package/dist/core/util/atomic-file.js.map +1 -1
  423. package/dist/index.d.ts +5 -2
  424. package/dist/index.d.ts.map +1 -1
  425. package/dist/index.js +5 -2
  426. package/dist/index.js.map +1 -1
  427. package/dist/main.d.ts +2 -0
  428. package/dist/main.d.ts.map +1 -1
  429. package/dist/main.js +24 -18
  430. package/dist/main.js.map +1 -1
  431. package/dist/modes/interactive/auto-learn-controller.js +1 -1
  432. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  433. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  434. package/dist/modes/interactive/components/settings-selector.js +35 -14
  435. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  436. package/dist/modes/interactive/components/tool-execution.js +1 -1
  437. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  438. package/dist/modes/interactive/interactive-event-controller.js +1 -1
  439. package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
  440. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  441. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  442. package/dist/modes/interactive/interactive-mode.js +27 -4
  443. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  444. package/dist/modes/interactive/secret-menu-controller.d.ts +21 -0
  445. package/dist/modes/interactive/secret-menu-controller.d.ts.map +1 -0
  446. package/dist/modes/interactive/secret-menu-controller.js +276 -0
  447. package/dist/modes/interactive/secret-menu-controller.js.map +1 -0
  448. package/dist/utils/child-process.js +1 -1
  449. package/dist/utils/child-process.js.map +1 -1
  450. package/dist/utils/tools-manager.d.ts +2 -1
  451. package/dist/utils/tools-manager.d.ts.map +1 -1
  452. package/dist/utils/tools-manager.js +43 -48
  453. package/dist/utils/tools-manager.js.map +1 -1
  454. package/dist/utils/zip-extractor.d.ts +8 -0
  455. package/dist/utils/zip-extractor.d.ts.map +1 -0
  456. package/dist/utils/zip-extractor.js +275 -0
  457. package/dist/utils/zip-extractor.js.map +1 -0
  458. package/docs/harness-architecture.md +34 -22
  459. package/docs/index.md +1 -1
  460. package/docs/resources.md +1 -1
  461. package/docs/settings.md +39 -103
  462. package/docs/usage.md +7 -5
  463. package/docs/worker-profiles.md +9 -7
  464. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  465. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  466. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  467. package/examples/extensions/sandbox/package-lock.json +2 -2
  468. package/examples/extensions/sandbox/package.json +1 -1
  469. package/examples/extensions/with-deps/package-lock.json +2 -2
  470. package/examples/extensions/with-deps/package.json +1 -1
  471. package/npm-shrinkwrap.json +12 -12
  472. package/package.json +7 -5
  473. package/dist/core/secrets/secret-vault-format.d.ts +0 -112
  474. package/dist/core/secrets/secret-vault-format.d.ts.map +0 -1
  475. package/dist/core/secrets/secret-vault-format.js +0 -396
  476. package/dist/core/secrets/secret-vault-format.js.map +0 -1
  477. package/dist/core/secrets/secret-vault.d.ts +0 -72
  478. package/dist/core/secrets/secret-vault.d.ts.map +0 -1
  479. package/dist/core/secrets/secret-vault.js +0 -663
  480. package/dist/core/secrets/secret-vault.js.map +0 -1
@@ -1,38 +1,28 @@
1
1
  import { type Static, Type } from "typebox";
2
- import { type SecretProfileSummary, SecretVault } from "../secrets/secret-vault.ts";
2
+ import { type CredentialManager, type CredentialProfileSummary } from "../secrets/credential-manager.ts";
3
3
  declare const secretStoreSchema: Type.TObject<{
4
- action: Type.TUnion<[Type.TLiteral<"set">, Type.TLiteral<"list">, Type.TLiteral<"materialize">, Type.TLiteral<"remove">, Type.TLiteral<"lock">]>;
4
+ action: Type.TUnion<[Type.TLiteral<"status">, Type.TLiteral<"list">, Type.TLiteral<"activate">]>;
5
5
  profile: Type.TOptional<Type.TString>;
6
- description: Type.TOptional<Type.TString>;
7
- envFile: Type.TOptional<Type.TString>;
8
- variableNames: Type.TOptional<Type.TArray<Type.TString>>;
9
- scope: Type.TOptional<Type.TUnion<[Type.TLiteral<"managed">, Type.TLiteral<"workspace">]>>;
10
6
  }>;
11
7
  export type SecretStoreToolInput = Static<typeof secretStoreSchema>;
12
- export type SecretStoreStatus = "cancelled" | "error" | "listed" | "locked" | "materialized" | "removed" | "stored" | "unavailable";
8
+ export type SecretStoreStatus = "activated" | "available" | "cancelled" | "error" | "listed" | "unavailable";
13
9
  export interface SecretStoreToolDetails {
14
10
  action: SecretStoreToolInput["action"];
15
11
  status: SecretStoreStatus;
16
12
  profile?: string;
17
13
  variableNames?: string[];
18
- profiles?: SecretProfileSummary[];
19
- scope?: "managed" | "workspace";
20
- envFile?: string;
21
- materialized?: boolean;
14
+ profiles?: CredentialProfileSummary[];
15
+ project?: string;
16
+ connected?: boolean;
22
17
  code?: string;
23
18
  message?: string;
24
19
  }
25
20
  export interface SecretStoreToolOptions {
26
- agentDir?: string;
27
- vault?: SecretVault;
21
+ manager: CredentialManager;
28
22
  }
29
23
  export declare function createSecretStoreToolDefinition(options: SecretStoreToolOptions): import("../extensions/types.ts").ToolDefinition<Type.TObject<{
30
- action: Type.TUnion<[Type.TLiteral<"set">, Type.TLiteral<"list">, Type.TLiteral<"materialize">, Type.TLiteral<"remove">, Type.TLiteral<"lock">]>;
24
+ action: Type.TUnion<[Type.TLiteral<"status">, Type.TLiteral<"list">, Type.TLiteral<"activate">]>;
31
25
  profile: Type.TOptional<Type.TString>;
32
- description: Type.TOptional<Type.TString>;
33
- envFile: Type.TOptional<Type.TString>;
34
- variableNames: Type.TOptional<Type.TArray<Type.TString>>;
35
- scope: Type.TOptional<Type.TUnion<[Type.TLiteral<"managed">, Type.TLiteral<"workspace">]>>;
36
26
  }>, SecretStoreToolDetails, any> & import("../extensions/types.ts").ToolDefinition<any, any, any>;
37
27
  export {};
38
28
  //# sourceMappingURL=secret-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secret-store.d.ts","sourceRoot":"","sources":["../../../src/core/tools/secret-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EAQN,KAAK,oBAAoB,EACzB,WAAW,EAEX,MAAM,4BAA4B,CAAC;AAOpC,QAAA,MAAM,iBAAiB;;;;;;;EA0DtB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAC1B,WAAW,GACX,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,cAAc,GACd,SAAS,GACT,QAAQ,GACR,aAAa,CAAC;AAEjB,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB;AA8YD,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,sBAAsB;;;;;;;kGA6E9E"}
1
+ {"version":3,"file":"secret-store.d.ts","sourceRoot":"","sources":["../../../src/core/tools/secret-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAE7B,MAAM,kCAAkC,CAAC;AAO1C,QAAA,MAAM,iBAAiB;;;EAetB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE7G,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,iBAAiB,CAAC;CAC3B;AA4ED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,sBAAsB;;;kGAsF9E"}
@@ -1,355 +1,90 @@
1
1
  import { Type } from "typebox";
2
- import { ExtensionEditorComponent } from "../../modes/interactive/components/extension-editor.js";
3
2
  import { defineTool } from "../extensions/types.js";
4
- import { parseDotenvDocument, SecretDotenvError } from "../secrets/secret-dotenv.js";
5
- import { MAX_VARIABLES_PER_PROFILE, SECRET_DESCRIPTION_MAX_CHARS, SECRET_PRINTABLE_METADATA_PATTERN, SECRET_PROFILE_ID_MAX_CHARS, SECRET_PROFILE_ID_PATTERN, SECRET_VARIABLE_NAME_MAX_CHARS, SECRET_VARIABLE_NAME_PATTERN, SecretVault, SecretVaultError, } from "../secrets/secret-vault.js";
3
+ import { CredentialManagerError, CredentialStorageError, } from "../secrets/credential-manager.js";
6
4
  import { emptyOrchestrationCall, OrchestrationPanelComponent, } from "./orchestration-panel.js";
7
5
  const secretStoreSchema = Type.Object({
8
- action: Type.Union([
9
- Type.Literal("set"),
10
- Type.Literal("list"),
11
- Type.Literal("materialize"),
12
- Type.Literal("remove"),
13
- Type.Literal("lock"),
14
- ], { description: "Credential-management action." }),
6
+ action: Type.Union([Type.Literal("status"), Type.Literal("list"), Type.Literal("activate")], {
7
+ description: "Credential-use action. Credential mutation is owner-only through /secrets.",
8
+ }),
15
9
  profile: Type.Optional(Type.String({
16
10
  minLength: 1,
17
- maxLength: SECRET_PROFILE_ID_MAX_CHARS,
18
- pattern: SECRET_PROFILE_ID_PATTERN,
19
- description: "Portable profile identifier, such as project-dev or aws-work.",
20
- })),
21
- description: Type.Optional(Type.String({
22
- minLength: 1,
23
- maxLength: SECRET_DESCRIPTION_MAX_CHARS,
24
- pattern: SECRET_PRINTABLE_METADATA_PATTERN,
25
- description: "Non-secret profile description.",
26
- })),
27
- envFile: Type.Optional(Type.String({
28
- minLength: 1,
29
- maxLength: 512,
30
- description: "Relative dotenv location inside the current workspace, such as .env, .env.local, or config/dev.env. Valid only for set.",
31
- })),
32
- variableNames: Type.Optional(Type.Array(Type.String({
33
- minLength: 1,
34
- maxLength: SECRET_VARIABLE_NAME_MAX_CHARS,
35
- pattern: SECRET_VARIABLE_NAME_PATTERN,
36
- }), {
37
- minItems: 1,
38
- maxItems: MAX_VARIABLES_PER_PROFILE,
39
- description: "Specific variable names to remove. Omit to remove the whole profile.",
40
- })),
41
- scope: Type.Optional(Type.Union([Type.Literal("managed"), Type.Literal("workspace")], {
42
- description: "Materialization target. workspace resolves the durable current-project binding; managed writes private Pi state.",
11
+ maxLength: 96,
12
+ pattern: "^[A-Za-z0-9][A-Za-z0-9._-]*$",
13
+ description: "Bound profile to activate. Omit when the project has exactly one bound profile.",
43
14
  })),
44
15
  }, { additionalProperties: false });
45
16
  function result(details, text) {
46
17
  return { content: [{ type: "text", text }], details };
47
18
  }
48
- function cancelled(action, profile) {
49
- return result({ action, status: "cancelled", ...(profile ? { profile } : {}), code: "owner_cancelled" }, "Secret store action was cancelled by the owner.");
50
- }
51
- function failed(action, error, profile) {
52
- const code = error instanceof SecretVaultError ? error.code : "safe_failure";
53
- const message = error instanceof SecretVaultError ? error.message : "Secret store failed safely without exposing values.";
54
- return result({ action, status: "error", ...(profile ? { profile } : {}), code, message }, `Secret store failed: ${message}`);
19
+ function invalid(input) {
20
+ if (input.action !== "activate" && input.profile !== undefined) {
21
+ return result({
22
+ action: input.action,
23
+ status: "error",
24
+ code: "unexpected_profile",
25
+ message: `Action ${input.action} does not accept a profile.`,
26
+ }, `Secret store request is invalid: action ${input.action} does not accept a profile.`);
27
+ }
28
+ return undefined;
55
29
  }
56
- function invalid(action, code, message, profile) {
57
- return result({ action, status: "error", ...(profile ? { profile } : {}), code, message }, `Secret store request is invalid: ${message}`);
30
+ function failed(input, error) {
31
+ const known = error instanceof CredentialManagerError || error instanceof CredentialStorageError;
32
+ const code = known ? error.code : "safe_failure";
33
+ const message = known ? error.message : "Credential activation failed safely without exposing values.";
34
+ const status = ["owner_setup_required", "not_connected", "provider_unavailable"].includes(code)
35
+ ? "unavailable"
36
+ : "error";
37
+ return result({
38
+ action: input.action,
39
+ status,
40
+ ...(input.profile ? { profile: input.profile } : {}),
41
+ code,
42
+ message,
43
+ }, `Credential action failed: ${message}`);
58
44
  }
59
45
  function panelModel(details, expanded) {
60
46
  if (!details)
61
- return { label: "secrets", status: "error", emptyText: "No secret-store result was retained." };
62
- const success = ["listed", "locked", "materialized", "removed", "stored"].includes(details.status);
63
- const rows = expanded
64
- ? (details.profiles ?? []).map((profile) => ({
65
- status: "info",
66
- label: profile.profile,
67
- meta: [
68
- `${profile.variableNames.length} variable${profile.variableNames.length === 1 ? "" : "s"}`,
69
- `${profile.bindings.length} binding${profile.bindings.length === 1 ? "" : "s"}`,
70
- ],
71
- details: [
72
- ...(profile.description ? [profile.description] : []),
73
- ...profile.bindings.map((binding) => `${binding.envFile} · ${binding.workspace}`),
74
- ],
75
- }))
76
- : undefined;
47
+ return { label: "secrets", status: "error", emptyText: "No credential result was retained." };
48
+ const success = ["activated", "available", "listed"].includes(details.status);
77
49
  return {
78
50
  label: "secrets",
79
51
  action: details.status,
80
52
  status: success ? "success" : details.status === "cancelled" ? "warning" : "error",
81
53
  summary: [
82
54
  details.profile,
83
- details.envFile,
84
- details.scope,
55
+ details.project,
85
56
  details.variableNames
86
57
  ? `${details.variableNames.length} variable${details.variableNames.length === 1 ? "" : "s"}`
87
58
  : undefined,
88
59
  details.profiles ? `${details.profiles.length} profile${details.profiles.length === 1 ? "" : "s"}` : undefined,
89
60
  ].filter((value) => value !== undefined),
90
- rows,
61
+ rows: expanded
62
+ ? details.profiles?.map((profile) => ({
63
+ status: profile.boundToCurrentProject ? "succeeded" : "info",
64
+ label: profile.profile,
65
+ meta: [
66
+ `${profile.variableNames.length} variable${profile.variableNames.length === 1 ? "" : "s"}`,
67
+ profile.boundToCurrentProject ? "bound here" : "not bound here",
68
+ ],
69
+ details: profile.description ? [profile.description] : undefined,
70
+ }))
71
+ : undefined,
91
72
  notices: expanded && details.message ? [{ status: success ? "info" : "error", text: details.message }] : undefined,
92
73
  };
93
74
  }
94
- async function ensureUnlocked(vault, action, ctx, signal, profile) {
95
- if (vault.isUnlocked)
96
- return undefined;
97
- if (await vault.exists()) {
98
- while (!signal?.aborted) {
99
- let passphrase = await ctx.ui.input("Unlock secret vault", "Master passphrase", {
100
- signal,
101
- sensitive: true,
102
- });
103
- if (passphrase === undefined || signal?.aborted)
104
- return cancelled(action, profile);
105
- try {
106
- await vault.unlock(passphrase);
107
- return undefined;
108
- }
109
- catch (error) {
110
- if (error instanceof SecretVaultError && ["invalid_passphrase", "unlock_failed"].includes(error.code)) {
111
- ctx.ui.notify(error.message, "error");
112
- continue;
113
- }
114
- return failed(action, error, profile);
115
- }
116
- finally {
117
- passphrase = "";
118
- }
119
- }
120
- return cancelled(action, profile);
121
- }
122
- while (!signal?.aborted) {
123
- let passphrase = await ctx.ui.input("Create secret vault", "New master passphrase", { signal, sensitive: true });
124
- if (passphrase === undefined || signal?.aborted)
125
- return cancelled(action, profile);
126
- let confirmation = await ctx.ui.input("Confirm secret vault", "Repeat master passphrase", {
127
- signal,
128
- sensitive: true,
129
- });
130
- if (confirmation === undefined || signal?.aborted) {
131
- passphrase = "";
132
- return cancelled(action, profile);
133
- }
134
- try {
135
- if (passphrase !== confirmation) {
136
- ctx.ui.notify("The two master passphrases do not match.", "error");
137
- continue;
138
- }
139
- await vault.initialize(passphrase);
140
- return undefined;
141
- }
142
- catch (error) {
143
- if (error instanceof SecretVaultError && error.code === "invalid_passphrase") {
144
- ctx.ui.notify(error.message, "error");
145
- continue;
146
- }
147
- return failed(action, error, profile);
148
- }
149
- finally {
150
- passphrase = "";
151
- confirmation = "";
152
- }
153
- }
154
- return cancelled(action, profile);
155
- }
156
- function validateInput(input) {
157
- if (input.action === "lock" || input.action === "list") {
158
- if (input.profile !== undefined ||
159
- input.description !== undefined ||
160
- input.envFile !== undefined ||
161
- input.variableNames !== undefined ||
162
- input.scope !== undefined) {
163
- return invalid(input.action, "unexpected_fields", `Action ${input.action} does not accept profile fields.`);
164
- }
165
- return undefined;
166
- }
167
- if (input.action === "set" && !input.profile) {
168
- return invalid(input.action, "profile_required", "Action set requires a profile.");
169
- }
170
- if (input.action === "remove" && !input.profile) {
171
- return invalid(input.action, "profile_required", "Action remove requires a profile.");
172
- }
173
- if (input.action !== "set" && (input.description !== undefined || input.envFile !== undefined)) {
174
- return invalid(input.action, "unexpected_profile_fields", "description and envFile are valid only for set.", input.profile);
175
- }
176
- if (input.action !== "remove" && input.variableNames !== undefined) {
177
- return invalid(input.action, "unexpected_variable_names", "variableNames is valid only for remove.", input.profile);
178
- }
179
- if (input.action !== "materialize" && input.scope !== undefined) {
180
- return invalid(input.action, "unexpected_scope", "scope is valid only for materialize.", input.profile);
181
- }
182
- if (input.variableNames && new Set(input.variableNames).size !== input.variableNames.length) {
183
- return invalid(input.action, "duplicate_variables", "Variable names must be unique.", input.profile);
184
- }
185
- return undefined;
186
- }
187
- async function openPrivateDotenvEditor(ctx, title, prefill, signal) {
188
- if (signal?.aborted)
189
- return undefined;
190
- try {
191
- return await ctx.ui.custom((tui, _theme, keybindings, done) => new ExtensionEditorComponent(tui, keybindings, title, prefill, (value) => done(value), () => done(undefined), {
192
- privateContent: true,
193
- allowExternalEditor: false,
194
- signal,
195
- notice: "Private plaintext editor · content stays local and never enters model context",
196
- }));
197
- }
198
- catch (error) {
199
- if (signal?.aborted)
200
- return undefined;
201
- throw error;
202
- }
203
- }
204
- async function captureValidDotenv(ctx, title, prefill, signal) {
205
- let draft = prefill;
206
- while (!signal?.aborted) {
207
- const edited = await openPrivateDotenvEditor(ctx, title, draft, signal);
208
- if (edited === undefined || signal?.aborted)
209
- return undefined;
210
- try {
211
- const parsed = parseDotenvDocument(edited);
212
- const variableNames = parsed.variables.map((variable) => variable.name);
213
- for (const variable of parsed.variables)
214
- variable.value = "";
215
- draft = "";
216
- return { document: parsed.document, variableNames };
217
- }
218
- catch (error) {
219
- ctx.ui.notify(error instanceof SecretDotenvError ? error.message : "The dotenv document is invalid.", "error");
220
- draft = edited;
221
- }
222
- }
223
- return undefined;
224
- }
225
- async function executeSet(vault, input, ctx, signal) {
226
- let document = "";
227
- let originalUnmanagedContent;
228
- try {
229
- const target = vault.resolveBindingTarget(ctx.cwd, input.envFile ?? ".env");
230
- const destinationState = await vault.inspectEnvDestination(target.destination, input.profile);
231
- if (destinationState === "managed-other") {
232
- return invalid(input.action, "destination_conflict", "The selected dotenv location is already managed by another profile.", input.profile);
233
- }
234
- const storedDocument = await vault.getProfileDocument(input.profile);
235
- let prefill = storedDocument ?? "";
236
- if (destinationState === "unmanaged") {
237
- originalUnmanagedContent = await vault.readOwnerDotenv(target.destination);
238
- prefill = originalUnmanagedContent;
239
- }
240
- if (destinationState === "managed-profile" && storedDocument === undefined) {
241
- return invalid(input.action, "profile_missing", "The dotenv target claims this profile, but the encrypted profile is missing.", input.profile);
242
- }
243
- const captured = await captureValidDotenv(ctx, `Secrets · ${input.profile} → ${target.destination}`, prefill, signal);
244
- prefill = "";
245
- if (!captured)
246
- return cancelled(input.action, input.profile);
247
- document = captured.document;
248
- await vault.replaceProfileDocument(input.profile, input.description, document, {
249
- workspace: target.workspace,
250
- envFile: target.envFile,
251
- });
252
- try {
253
- await vault.materializeEnv(input.profile, target.destination, {
254
- allowReplaceUnmanaged: destinationState === "unmanaged",
255
- expectedUnmanagedContent: originalUnmanagedContent,
256
- });
257
- }
258
- catch (error) {
259
- const message = error instanceof SecretVaultError ? error.message : "Dotenv materialization failed safely.";
260
- ctx.ui.notify(`Profile stored, but ${target.destination} was not refreshed: ${message}`, "warning");
261
- return result({
262
- action: input.action,
263
- status: "stored",
264
- profile: input.profile,
265
- envFile: target.envFile,
266
- variableNames: captured.variableNames,
267
- materialized: false,
268
- code: "materialization_failed",
269
- message,
270
- }, `Stored profile ${input.profile}, but its bound dotenv could not be refreshed. Retry secret_store materialize; no values were exposed.`);
271
- }
272
- ctx.ui.notify(`Credential profile ${input.profile} stored and activated at ${target.destination}`, "info");
273
- return result({
274
- action: input.action,
275
- status: "stored",
276
- profile: input.profile,
277
- envFile: target.envFile,
278
- variableNames: captured.variableNames,
279
- materialized: true,
280
- }, `Stored and activated ${captured.variableNames.length} variables for profile ${input.profile} at its bound workspace dotenv location. Values never entered model context.`);
281
- }
282
- catch (error) {
283
- return failed(input.action, error, input.profile);
284
- }
285
- finally {
286
- document = "";
287
- originalUnmanagedContent = undefined;
288
- }
289
- }
290
- async function executeMaterialize(vault, input, ctx) {
291
- try {
292
- const scope = input.scope ?? "workspace";
293
- const binding = await vault.resolveBindingForWorkspace(ctx.cwd, input.profile);
294
- const destination = scope === "managed" ? vault.getManagedEnvPath(binding.profile) : binding.destination;
295
- const destinationState = await vault.inspectEnvDestination(destination, binding.profile);
296
- if (destinationState === "unmanaged" || destinationState === "managed-other") {
297
- return invalid(input.action, "destination_conflict", "The bound dotenv location is no longer safely managed. Use set to review it in the private editor.", binding.profile);
298
- }
299
- const materialized = await vault.materializeEnv(binding.profile, destination, {
300
- activationWorkspace: ctx.cwd,
301
- managed: scope === "managed",
302
- });
303
- ctx.ui.notify(`Credential profile ${binding.profile} activated at ${destination}`, "info");
304
- return result({
305
- action: input.action,
306
- status: "materialized",
307
- profile: binding.profile,
308
- variableNames: materialized.variableNames,
309
- scope,
310
- envFile: scope === "workspace" ? binding.envFile : undefined,
311
- materialized: true,
312
- }, `Activated profile ${binding.profile} for the current workspace. Its dotenv and process environment are available without exposing values to the model.`);
313
- }
314
- catch (error) {
315
- return failed(input.action, error, input.profile);
316
- }
317
- }
318
- async function executeRemove(vault, input, ctx, signal) {
319
- const target = input.variableNames?.length
320
- ? `${input.variableNames.join(", ")} from profile ${input.profile}`
321
- : `the entire profile ${input.profile}`;
322
- const approved = await ctx.ui.confirm("Remove stored secrets", `Remove ${target}? Pi-managed workspace and private dotenv copies are invalidated.`, { signal });
323
- if (!approved || signal?.aborted)
324
- return cancelled(input.action, input.profile);
325
- try {
326
- const removal = await vault.removeProfile(input.profile, input.variableNames);
327
- return result({
328
- action: input.action,
329
- status: "removed",
330
- profile: input.profile,
331
- variableNames: removal.removedVariableNames,
332
- }, `Removed ${removal.removedVariableNames.length} secret variable${removal.removedVariableNames.length === 1 ? "" : "s"} from profile ${input.profile}.`);
333
- }
334
- catch (error) {
335
- return failed(input.action, error, input.profile);
336
- }
337
- }
338
75
  export function createSecretStoreToolDefinition(options) {
339
- const vault = options.vault ?? (options.agentDir ? SecretVault.forAgentDir(options.agentDir) : undefined);
340
- if (!vault)
341
- throw new Error("secret_store requires an agentDir or SecretVault");
76
+ const { manager } = options;
342
77
  return defineTool({
343
78
  name: "secret_store",
344
79
  label: "Secret Store",
345
- description: "Open a model-blind native dotenv editor, encrypt owner credentials, bind profiles to workspace dotenv locations, and activate them for normal process use without returning values to the model.",
346
- promptSnippet: "Manage credentials through the model-blind secret vault. Before credential-dependent work, materialize the current workspace binding; use set to open the owner's private dotenv editor.",
80
+ description: "Discover and activate owner-authorized Bitwarden credential profiles for the current project without exposing values.",
81
+ promptSnippet: "Activate project credentials with secret_store before credential-dependent commands. Credential setup and mutation are owner-only through /secrets.",
347
82
  promptGuidelines: [
348
- "Use secret_store whenever credentials are needed. Never ask the owner to paste a secret into chat or place a value in tool arguments.",
349
- "Use set with a profile and relative envFile. The harness opens a private plaintext editor, persists the workspace binding, writes the dotenv, and activates the environment.",
350
- "Before credential-dependent commands in a later session, call materialize without a profile to resolve the current workspace binding. Use list only when selection or discovery is needed.",
351
- "After activation, run the consuming application normally. Never read, grep, print, echo, source, or otherwise inspect credential files or environment values.",
352
- "Treat cancellation as owner intent. Do not immediately repeat the same credential request.",
83
+ "Use secret_store activate before credential-dependent work. It works in TUI, print, and RPC modes and returns metadata only.",
84
+ "Omit profile when the project has one binding. Use list to select among multiple authorized profiles.",
85
+ "Never ask the owner to paste a credential into chat or pass a value through tool arguments.",
86
+ "After activation, run the consuming command normally. Never print, inspect, grep, or echo credential environment values.",
87
+ "If owner_setup_required is returned, tell the owner to run /secrets in a TUI session. Do not repeatedly retry.",
353
88
  ],
354
89
  parameters: secretStoreSchema,
355
90
  executionMode: "sequential",
@@ -361,50 +96,50 @@ export function createSecretStoreToolDefinition(options) {
361
96
  if (isPartial) {
362
97
  return new OrchestrationPanelComponent(theme, {
363
98
  label: "secrets",
364
- action: "waiting for you",
99
+ action: "activating",
365
100
  status: "running",
366
101
  });
367
102
  }
368
103
  return new OrchestrationPanelComponent(theme, panelModel(toolResult.details, expanded), expanded);
369
104
  },
370
105
  async execute(_toolCallId, input, signal, _onUpdate, ctx) {
371
- if (!ctx.hasUI || ctx.mode !== "tui") {
372
- return result({
373
- action: input.action,
374
- status: "unavailable",
375
- ...(input.profile ? { profile: input.profile } : {}),
376
- code: "user_tui_required",
377
- message: "Secret values can be captured only in a user-visible TUI session.",
378
- }, "secret_store requires a user-visible TUI session.");
106
+ if (signal?.aborted) {
107
+ return result({ action: input.action, status: "cancelled", code: "cancelled" }, "Credential action cancelled.");
379
108
  }
380
- if (signal?.aborted)
381
- return cancelled(input.action, input.profile);
382
- const validation = validateInput(input);
109
+ const validation = invalid(input);
383
110
  if (validation)
384
111
  return validation;
385
- if (input.action === "lock") {
386
- vault.lock();
387
- return result({ action: input.action, status: "locked" }, "Secret vault locked; cached key, credential environment, and exact-value redaction cache were cleared.");
388
- }
389
112
  try {
390
- const unlockResult = await ensureUnlocked(vault, input.action, ctx, signal, input.profile);
391
- if (unlockResult)
392
- return unlockResult;
393
- if (input.action === "list") {
394
- const profiles = await vault.listProfiles();
395
- return result({ action: input.action, status: "listed", profiles }, `Secret vault contains ${profiles.length} profile${profiles.length === 1 ? "" : "s"}. Only names, variable names, and workspace bindings were returned.`);
113
+ if (input.action === "status") {
114
+ const status = manager.status;
115
+ if (!status.sessionAvailable) {
116
+ return result({
117
+ action: input.action,
118
+ status: "unavailable",
119
+ connected: false,
120
+ code: "owner_setup_required",
121
+ message: "The owner must connect Bitwarden with /secrets.",
122
+ }, "Bitwarden owner setup is required. Run /secrets in a TUI session.");
123
+ }
124
+ return result({ action: input.action, status: "available", connected: status.connected }, status.connected
125
+ ? "Bitwarden is connected for this Pi session."
126
+ : "A Bitwarden session key is available and will be validated on activation.");
396
127
  }
397
- if (input.action === "set" && input.profile) {
398
- return executeSet(vault, { ...input, profile: input.profile }, ctx, signal);
128
+ if (input.action === "list") {
129
+ const profiles = await manager.listForProject(ctx.cwd, signal);
130
+ return result({ action: input.action, status: "listed", profiles }, `Found ${profiles.length} credential profile${profiles.length === 1 ? "" : "s"}; only metadata was returned.`);
399
131
  }
400
- if (input.action === "materialize")
401
- return executeMaterialize(vault, input, ctx);
402
- if (!input.profile)
403
- return invalid(input.action, "profile_required", "A profile is required.");
404
- return executeRemove(vault, { ...input, profile: input.profile }, ctx, signal);
132
+ const activated = await manager.activateForProject(ctx.cwd, input.profile, signal);
133
+ return result({
134
+ action: input.action,
135
+ status: "activated",
136
+ profile: activated.profile,
137
+ variableNames: activated.variableNames,
138
+ project: activated.project,
139
+ }, `Activated ${activated.profile} for ${activated.project}. Credential values remain hidden.`);
405
140
  }
406
141
  catch (error) {
407
- return failed(input.action, error, input.profile);
142
+ return failed(input, error);
408
143
  }
409
144
  },
410
145
  });