open-multi-agent-kit 0.80.5 → 0.80.7

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 (1025) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +22 -14
  3. package/dist/cli/config-selector.d.ts +1 -1
  4. package/dist/cli/config-selector.d.ts.map +1 -1
  5. package/dist/cli/config-selector.js +1 -1
  6. package/dist/cli/config-selector.js.map +1 -1
  7. package/dist/config.d.ts +5 -9
  8. package/dist/config.d.ts.map +1 -1
  9. package/dist/config.js +55 -23
  10. package/dist/config.js.map +1 -1
  11. package/dist/core/agent-session.d.ts +45 -6
  12. package/dist/core/agent-session.d.ts.map +1 -1
  13. package/dist/core/agent-session.js +197 -13
  14. package/dist/core/agent-session.js.map +1 -1
  15. package/dist/core/auth-storage.d.ts +4 -1
  16. package/dist/core/auth-storage.d.ts.map +1 -1
  17. package/dist/core/auth-storage.js +5 -5
  18. package/dist/core/auth-storage.js.map +1 -1
  19. package/dist/core/bash-executor.d.ts.map +1 -1
  20. package/dist/core/bash-executor.js +1 -1
  21. package/dist/core/bash-executor.js.map +1 -1
  22. package/dist/core/command-safety.d.ts +11 -0
  23. package/dist/core/command-safety.d.ts.map +1 -0
  24. package/dist/core/command-safety.js +528 -0
  25. package/dist/core/command-safety.js.map +1 -0
  26. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  27. package/dist/core/compaction/branch-summarization.js +20 -5
  28. package/dist/core/compaction/branch-summarization.js.map +1 -1
  29. package/dist/core/compaction/compaction.d.ts +99 -1
  30. package/dist/core/compaction/compaction.d.ts.map +1 -1
  31. package/dist/core/compaction/compaction.js +655 -21
  32. package/dist/core/compaction/compaction.js.map +1 -1
  33. package/dist/core/compaction/pruner-policy.d.ts +84 -0
  34. package/dist/core/compaction/pruner-policy.d.ts.map +1 -0
  35. package/dist/core/compaction/pruner-policy.js +273 -0
  36. package/dist/core/compaction/pruner-policy.js.map +1 -0
  37. package/dist/core/context-graph-identity-resolution.d.ts +114 -0
  38. package/dist/core/context-graph-identity-resolution.d.ts.map +1 -0
  39. package/dist/core/context-graph-identity-resolution.js +127 -0
  40. package/dist/core/context-graph-identity-resolution.js.map +1 -0
  41. package/dist/core/context-graph-memory-store.d.ts +153 -0
  42. package/dist/core/context-graph-memory-store.d.ts.map +1 -0
  43. package/dist/core/context-graph-memory-store.js +377 -0
  44. package/dist/core/context-graph-memory-store.js.map +1 -0
  45. package/dist/core/context-graph-ontology-generation.d.ts +104 -0
  46. package/dist/core/context-graph-ontology-generation.d.ts.map +1 -0
  47. package/dist/core/context-graph-ontology-generation.js +135 -0
  48. package/dist/core/context-graph-ontology-generation.js.map +1 -0
  49. package/dist/core/context-graph-ontology-registry.d.ts +766 -0
  50. package/dist/core/context-graph-ontology-registry.d.ts.map +1 -0
  51. package/dist/core/context-graph-ontology-registry.js +1133 -0
  52. package/dist/core/context-graph-ontology-registry.js.map +1 -0
  53. package/dist/core/context-graph-policy.d.ts +68 -0
  54. package/dist/core/context-graph-policy.d.ts.map +1 -0
  55. package/dist/core/context-graph-policy.js +221 -0
  56. package/dist/core/context-graph-policy.js.map +1 -0
  57. package/dist/core/context-graph-reasoning.d.ts +130 -0
  58. package/dist/core/context-graph-reasoning.d.ts.map +1 -0
  59. package/dist/core/context-graph-reasoning.js +442 -0
  60. package/dist/core/context-graph-reasoning.js.map +1 -0
  61. package/dist/core/context-graph-retrieval.d.ts +120 -0
  62. package/dist/core/context-graph-retrieval.d.ts.map +1 -0
  63. package/dist/core/context-graph-retrieval.js +288 -0
  64. package/dist/core/context-graph-retrieval.js.map +1 -0
  65. package/dist/core/contract-verification.d.ts +78 -0
  66. package/dist/core/contract-verification.d.ts.map +1 -0
  67. package/dist/core/contract-verification.js +110 -0
  68. package/dist/core/contract-verification.js.map +1 -0
  69. package/dist/core/exact-cache-policy.d.ts +100 -0
  70. package/dist/core/exact-cache-policy.d.ts.map +1 -0
  71. package/dist/core/exact-cache-policy.js +175 -0
  72. package/dist/core/exact-cache-policy.js.map +1 -0
  73. package/dist/core/exec.d.ts +2 -0
  74. package/dist/core/exec.d.ts.map +1 -1
  75. package/dist/core/exec.js +1 -0
  76. package/dist/core/exec.js.map +1 -1
  77. package/dist/core/export-html/template.js +2 -2
  78. package/dist/core/extensions/builtin/command-safety-gate.d.ts +77 -0
  79. package/dist/core/extensions/builtin/command-safety-gate.d.ts.map +1 -0
  80. package/dist/core/extensions/builtin/command-safety-gate.js +147 -0
  81. package/dist/core/extensions/builtin/command-safety-gate.js.map +1 -0
  82. package/dist/core/extensions/loader.d.ts +4 -4
  83. package/dist/core/extensions/loader.d.ts.map +1 -1
  84. package/dist/core/extensions/loader.js +94 -56
  85. package/dist/core/extensions/loader.js.map +1 -1
  86. package/dist/core/extensions/runner.d.ts.map +1 -1
  87. package/dist/core/extensions/runner.js +1 -1
  88. package/dist/core/extensions/runner.js.map +1 -1
  89. package/dist/core/extensions/types.d.ts +38 -10
  90. package/dist/core/extensions/types.d.ts.map +1 -1
  91. package/dist/core/extensions/types.js.map +1 -1
  92. package/dist/core/freedom/banner.d.ts +14 -0
  93. package/dist/core/freedom/banner.d.ts.map +1 -0
  94. package/dist/core/freedom/banner.js +22 -0
  95. package/dist/core/freedom/banner.js.map +1 -0
  96. package/dist/core/freedom/config.d.ts +27 -0
  97. package/dist/core/freedom/config.d.ts.map +1 -0
  98. package/dist/core/freedom/config.js +216 -0
  99. package/dist/core/freedom/config.js.map +1 -0
  100. package/dist/core/freedom/index.d.ts +23 -0
  101. package/dist/core/freedom/index.d.ts.map +1 -0
  102. package/dist/core/freedom/index.js +19 -0
  103. package/dist/core/freedom/index.js.map +1 -0
  104. package/dist/core/freedom/policy.d.ts +42 -0
  105. package/dist/core/freedom/policy.d.ts.map +1 -0
  106. package/dist/core/freedom/policy.js +47 -0
  107. package/dist/core/freedom/policy.js.map +1 -0
  108. package/dist/core/freedom/safety-floor.d.ts +73 -0
  109. package/dist/core/freedom/safety-floor.d.ts.map +1 -0
  110. package/dist/core/freedom/safety-floor.js +275 -0
  111. package/dist/core/freedom/safety-floor.js.map +1 -0
  112. package/dist/core/harness-control-events.d.ts +91 -0
  113. package/dist/core/harness-control-events.d.ts.map +1 -0
  114. package/dist/core/harness-control-events.js +514 -0
  115. package/dist/core/harness-control-events.js.map +1 -0
  116. package/dist/core/harness-control-replay.d.ts +31 -0
  117. package/dist/core/harness-control-replay.d.ts.map +1 -0
  118. package/dist/core/harness-control-replay.js +187 -0
  119. package/dist/core/harness-control-replay.js.map +1 -0
  120. package/dist/core/headroom-middleware.d.ts +35 -0
  121. package/dist/core/headroom-middleware.d.ts.map +1 -0
  122. package/dist/core/headroom-middleware.js +166 -0
  123. package/dist/core/headroom-middleware.js.map +1 -0
  124. package/dist/core/hook-inventory.d.ts +23 -0
  125. package/dist/core/hook-inventory.d.ts.map +1 -0
  126. package/dist/core/hook-inventory.js +50 -0
  127. package/dist/core/hook-inventory.js.map +1 -0
  128. package/dist/core/keybindings.d.ts +12 -0
  129. package/dist/core/keybindings.d.ts.map +1 -1
  130. package/dist/core/keybindings.js +31 -1
  131. package/dist/core/keybindings.js.map +1 -1
  132. package/dist/core/lean-context-middleware.d.ts +12 -0
  133. package/dist/core/lean-context-middleware.d.ts.map +1 -0
  134. package/dist/core/lean-context-middleware.js +87 -0
  135. package/dist/core/lean-context-middleware.js.map +1 -0
  136. package/dist/core/lean-context-policy.d.ts +45 -0
  137. package/dist/core/lean-context-policy.d.ts.map +1 -0
  138. package/dist/core/lean-context-policy.js +108 -0
  139. package/dist/core/lean-context-policy.js.map +1 -0
  140. package/dist/core/loadout-access-policy.d.ts +41 -0
  141. package/dist/core/loadout-access-policy.d.ts.map +1 -0
  142. package/dist/core/loadout-access-policy.js +182 -0
  143. package/dist/core/loadout-access-policy.js.map +1 -0
  144. package/dist/core/loadout-runtime.d.ts +84 -0
  145. package/dist/core/loadout-runtime.d.ts.map +1 -0
  146. package/dist/core/loadout-runtime.js +157 -0
  147. package/dist/core/loadout-runtime.js.map +1 -0
  148. package/dist/core/loadouts.d.ts +147 -0
  149. package/dist/core/loadouts.d.ts.map +1 -0
  150. package/dist/core/loadouts.js +442 -0
  151. package/dist/core/loadouts.js.map +1 -0
  152. package/dist/core/mcp-inventory.d.ts +74 -0
  153. package/dist/core/mcp-inventory.d.ts.map +1 -0
  154. package/dist/core/mcp-inventory.js +156 -0
  155. package/dist/core/mcp-inventory.js.map +1 -0
  156. package/dist/core/mcp-presets.d.ts +57 -0
  157. package/dist/core/mcp-presets.d.ts.map +1 -0
  158. package/dist/core/mcp-presets.js +81 -0
  159. package/dist/core/mcp-presets.js.map +1 -0
  160. package/dist/core/model-registry.d.ts +1 -0
  161. package/dist/core/model-registry.d.ts.map +1 -1
  162. package/dist/core/model-registry.js +40 -17
  163. package/dist/core/model-registry.js.map +1 -1
  164. package/dist/core/model-resolver.d.ts.map +1 -1
  165. package/dist/core/model-resolver.js +1 -0
  166. package/dist/core/model-resolver.js.map +1 -1
  167. package/dist/core/native-adoption-benchmark.d.ts +166 -0
  168. package/dist/core/native-adoption-benchmark.d.ts.map +1 -0
  169. package/dist/core/native-adoption-benchmark.js +624 -0
  170. package/dist/core/native-adoption-benchmark.js.map +1 -0
  171. package/dist/core/observability-trace.d.ts +80 -0
  172. package/dist/core/observability-trace.d.ts.map +1 -0
  173. package/dist/core/observability-trace.js +140 -0
  174. package/dist/core/observability-trace.js.map +1 -0
  175. package/dist/core/orchestration/checkpoint.d.ts +83 -0
  176. package/dist/core/orchestration/checkpoint.d.ts.map +1 -0
  177. package/dist/core/orchestration/checkpoint.js +152 -0
  178. package/dist/core/orchestration/checkpoint.js.map +1 -0
  179. package/dist/core/orchestration/errors.d.ts +74 -0
  180. package/dist/core/orchestration/errors.d.ts.map +1 -0
  181. package/dist/core/orchestration/errors.js +52 -0
  182. package/dist/core/orchestration/errors.js.map +1 -0
  183. package/dist/core/orchestration/merge-queue.d.ts +121 -0
  184. package/dist/core/orchestration/merge-queue.d.ts.map +1 -0
  185. package/dist/core/orchestration/merge-queue.js +149 -0
  186. package/dist/core/orchestration/merge-queue.js.map +1 -0
  187. package/dist/core/orchestration/recovery.d.ts +106 -0
  188. package/dist/core/orchestration/recovery.d.ts.map +1 -0
  189. package/dist/core/orchestration/recovery.js +110 -0
  190. package/dist/core/orchestration/recovery.js.map +1 -0
  191. package/dist/core/orchestration/replay-ledger.d.ts +76 -0
  192. package/dist/core/orchestration/replay-ledger.d.ts.map +1 -0
  193. package/dist/core/orchestration/replay-ledger.js +395 -0
  194. package/dist/core/orchestration/replay-ledger.js.map +1 -0
  195. package/dist/core/orchestration/scheduler-state.d.ts +78 -0
  196. package/dist/core/orchestration/scheduler-state.d.ts.map +1 -0
  197. package/dist/core/orchestration/scheduler-state.js +185 -0
  198. package/dist/core/orchestration/scheduler-state.js.map +1 -0
  199. package/dist/core/orchestration/scheduler-store.d.ts +309 -0
  200. package/dist/core/orchestration/scheduler-store.d.ts.map +1 -0
  201. package/dist/core/orchestration/scheduler-store.js +368 -0
  202. package/dist/core/orchestration/scheduler-store.js.map +1 -0
  203. package/dist/core/orchestration/sqlite-scheduler-store.d.ts +57 -0
  204. package/dist/core/orchestration/sqlite-scheduler-store.d.ts.map +1 -0
  205. package/dist/core/orchestration/sqlite-scheduler-store.js +528 -0
  206. package/dist/core/orchestration/sqlite-scheduler-store.js.map +1 -0
  207. package/dist/core/orchestration/transaction-coordinator.d.ts +217 -0
  208. package/dist/core/orchestration/transaction-coordinator.d.ts.map +1 -0
  209. package/dist/core/orchestration/transaction-coordinator.js +281 -0
  210. package/dist/core/orchestration/transaction-coordinator.js.map +1 -0
  211. package/dist/core/orchestration/verification-contract.d.ts +197 -0
  212. package/dist/core/orchestration/verification-contract.d.ts.map +1 -0
  213. package/dist/core/orchestration/verification-contract.js +145 -0
  214. package/dist/core/orchestration/verification-contract.js.map +1 -0
  215. package/dist/core/package-composition.d.ts +68 -0
  216. package/dist/core/package-composition.d.ts.map +1 -0
  217. package/dist/core/package-composition.js +304 -0
  218. package/dist/core/package-composition.js.map +1 -0
  219. package/dist/core/package-gallery.d.ts +124 -0
  220. package/dist/core/package-gallery.d.ts.map +1 -0
  221. package/dist/core/package-gallery.js +392 -0
  222. package/dist/core/package-gallery.js.map +1 -0
  223. package/dist/core/package-manager.d.ts +69 -0
  224. package/dist/core/package-manager.d.ts.map +1 -1
  225. package/dist/core/package-manager.js +367 -69
  226. package/dist/core/package-manager.js.map +1 -1
  227. package/dist/core/package-procurement.d.ts +268 -0
  228. package/dist/core/package-procurement.d.ts.map +1 -0
  229. package/dist/core/package-procurement.js +697 -0
  230. package/dist/core/package-procurement.js.map +1 -0
  231. package/dist/core/package-trial-runtime.d.ts +75 -0
  232. package/dist/core/package-trial-runtime.d.ts.map +1 -0
  233. package/dist/core/package-trial-runtime.js +73 -0
  234. package/dist/core/package-trial-runtime.js.map +1 -0
  235. package/dist/core/package-trial-sandbox.d.ts +27 -0
  236. package/dist/core/package-trial-sandbox.d.ts.map +1 -0
  237. package/dist/core/package-trial-sandbox.js +102 -0
  238. package/dist/core/package-trial-sandbox.js.map +1 -0
  239. package/dist/core/policy-overlays-runtime.d.ts +141 -0
  240. package/dist/core/policy-overlays-runtime.d.ts.map +1 -0
  241. package/dist/core/policy-overlays-runtime.js +720 -0
  242. package/dist/core/policy-overlays-runtime.js.map +1 -0
  243. package/dist/core/read-anchor-registry.d.ts +27 -0
  244. package/dist/core/read-anchor-registry.d.ts.map +1 -0
  245. package/dist/core/read-anchor-registry.js +103 -0
  246. package/dist/core/read-anchor-registry.js.map +1 -0
  247. package/dist/core/read-anchors.d.ts +110 -0
  248. package/dist/core/read-anchors.d.ts.map +1 -0
  249. package/dist/core/read-anchors.js +193 -0
  250. package/dist/core/read-anchors.js.map +1 -0
  251. package/dist/core/read-content-cache.d.ts +22 -0
  252. package/dist/core/read-content-cache.d.ts.map +1 -0
  253. package/dist/core/read-content-cache.js +79 -0
  254. package/dist/core/read-content-cache.js.map +1 -0
  255. package/dist/core/recovery-checkpoint.d.ts +196 -0
  256. package/dist/core/recovery-checkpoint.d.ts.map +1 -0
  257. package/dist/core/recovery-checkpoint.js +382 -0
  258. package/dist/core/recovery-checkpoint.js.map +1 -0
  259. package/dist/core/resolve-config-value.d.ts +1 -1
  260. package/dist/core/resolve-config-value.d.ts.map +1 -1
  261. package/dist/core/resolve-config-value.js +30 -2
  262. package/dist/core/resolve-config-value.js.map +1 -1
  263. package/dist/core/resource-loader.d.ts +23 -21
  264. package/dist/core/resource-loader.d.ts.map +1 -1
  265. package/dist/core/resource-loader.js +93 -15
  266. package/dist/core/resource-loader.js.map +1 -1
  267. package/dist/core/sandbox/backend.d.ts +25 -0
  268. package/dist/core/sandbox/backend.d.ts.map +1 -0
  269. package/dist/core/sandbox/backend.js +150 -0
  270. package/dist/core/sandbox/backend.js.map +1 -0
  271. package/dist/core/sandbox/env.d.ts +6 -0
  272. package/dist/core/sandbox/env.d.ts.map +1 -0
  273. package/dist/core/sandbox/env.js +46 -0
  274. package/dist/core/sandbox/env.js.map +1 -0
  275. package/dist/core/sandbox/path-resolver.d.ts +4 -0
  276. package/dist/core/sandbox/path-resolver.d.ts.map +1 -0
  277. package/dist/core/sandbox/path-resolver.js +44 -0
  278. package/dist/core/sandbox/path-resolver.js.map +1 -0
  279. package/dist/core/sandbox/policy.d.ts +87 -0
  280. package/dist/core/sandbox/policy.d.ts.map +1 -0
  281. package/dist/core/sandbox/policy.js +280 -0
  282. package/dist/core/sandbox/policy.js.map +1 -0
  283. package/dist/core/sandbox/spawn.d.ts +20 -0
  284. package/dist/core/sandbox/spawn.d.ts.map +1 -0
  285. package/dist/core/sandbox/spawn.js +80 -0
  286. package/dist/core/sandbox/spawn.js.map +1 -0
  287. package/dist/core/sdk.d.ts +83 -4
  288. package/dist/core/sdk.d.ts.map +1 -1
  289. package/dist/core/sdk.js +143 -55
  290. package/dist/core/sdk.js.map +1 -1
  291. package/dist/core/semantic-cache-policy.d.ts +45 -0
  292. package/dist/core/semantic-cache-policy.d.ts.map +1 -0
  293. package/dist/core/semantic-cache-policy.js +220 -0
  294. package/dist/core/semantic-cache-policy.js.map +1 -0
  295. package/dist/core/session-digest.d.ts +57 -0
  296. package/dist/core/session-digest.d.ts.map +1 -0
  297. package/dist/core/session-digest.js +193 -0
  298. package/dist/core/session-digest.js.map +1 -0
  299. package/dist/core/session-manager.d.ts +2 -2
  300. package/dist/core/session-manager.d.ts.map +1 -1
  301. package/dist/core/session-manager.js +5 -4
  302. package/dist/core/session-manager.js.map +1 -1
  303. package/dist/core/settings-manager.d.ts +17 -0
  304. package/dist/core/settings-manager.d.ts.map +1 -1
  305. package/dist/core/settings-manager.js +47 -2
  306. package/dist/core/settings-manager.js.map +1 -1
  307. package/dist/core/slash-commands.d.ts.map +1 -1
  308. package/dist/core/slash-commands.js +4 -1
  309. package/dist/core/slash-commands.js.map +1 -1
  310. package/dist/core/spec-kit/compiler.d.ts +67 -0
  311. package/dist/core/spec-kit/compiler.d.ts.map +1 -0
  312. package/dist/core/spec-kit/compiler.js +268 -0
  313. package/dist/core/spec-kit/compiler.js.map +1 -0
  314. package/dist/core/system-prompt.d.ts.map +1 -1
  315. package/dist/core/system-prompt.js +25 -7
  316. package/dist/core/system-prompt.js.map +1 -1
  317. package/dist/core/telemetry.d.ts.map +1 -1
  318. package/dist/core/telemetry.js +1 -1
  319. package/dist/core/telemetry.js.map +1 -1
  320. package/dist/core/timings.d.ts +1 -1
  321. package/dist/core/timings.d.ts.map +1 -1
  322. package/dist/core/timings.js +2 -2
  323. package/dist/core/timings.js.map +1 -1
  324. package/dist/core/tools/bash.d.ts +28 -3
  325. package/dist/core/tools/bash.d.ts.map +1 -1
  326. package/dist/core/tools/bash.js +53 -10
  327. package/dist/core/tools/bash.js.map +1 -1
  328. package/dist/core/tools/edit.d.ts +12 -0
  329. package/dist/core/tools/edit.d.ts.map +1 -1
  330. package/dist/core/tools/edit.js +24 -0
  331. package/dist/core/tools/edit.js.map +1 -1
  332. package/dist/core/tools/find.d.ts +3 -0
  333. package/dist/core/tools/find.d.ts.map +1 -1
  334. package/dist/core/tools/find.js +3 -0
  335. package/dist/core/tools/find.js.map +1 -1
  336. package/dist/core/tools/grep.d.ts +3 -0
  337. package/dist/core/tools/grep.d.ts.map +1 -1
  338. package/dist/core/tools/grep.js +4 -1
  339. package/dist/core/tools/grep.js.map +1 -1
  340. package/dist/core/tools/index.d.ts +1 -1
  341. package/dist/core/tools/index.d.ts.map +1 -1
  342. package/dist/core/tools/index.js.map +1 -1
  343. package/dist/core/tools/ls.d.ts +3 -0
  344. package/dist/core/tools/ls.d.ts.map +1 -1
  345. package/dist/core/tools/ls.js +3 -0
  346. package/dist/core/tools/ls.js.map +1 -1
  347. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  348. package/dist/core/tools/output-accumulator.js +1 -1
  349. package/dist/core/tools/output-accumulator.js.map +1 -1
  350. package/dist/core/tools/read.d.ts +13 -0
  351. package/dist/core/tools/read.d.ts.map +1 -1
  352. package/dist/core/tools/read.js +29 -2
  353. package/dist/core/tools/read.js.map +1 -1
  354. package/dist/core/tools/write.d.ts +3 -0
  355. package/dist/core/tools/write.d.ts.map +1 -1
  356. package/dist/core/tools/write.js +3 -0
  357. package/dist/core/tools/write.js.map +1 -1
  358. package/dist/core/transaction-coordinator.d.ts +30 -0
  359. package/dist/core/transaction-coordinator.d.ts.map +1 -0
  360. package/dist/core/transaction-coordinator.js +173 -0
  361. package/dist/core/transaction-coordinator.js.map +1 -0
  362. package/dist/index.d.ts +19 -4
  363. package/dist/index.d.ts.map +1 -1
  364. package/dist/index.js +17 -2
  365. package/dist/index.js.map +1 -1
  366. package/dist/main.d.ts.map +1 -1
  367. package/dist/main.js +4 -6
  368. package/dist/main.js.map +1 -1
  369. package/dist/migrations.d.ts +35 -0
  370. package/dist/migrations.d.ts.map +1 -1
  371. package/dist/migrations.js +410 -4
  372. package/dist/migrations.js.map +1 -1
  373. package/dist/modes/interactive/components/control-panel-gradient-motion.d.ts +28 -0
  374. package/dist/modes/interactive/components/control-panel-gradient-motion.d.ts.map +1 -0
  375. package/dist/modes/interactive/components/control-panel-gradient-motion.js +146 -0
  376. package/dist/modes/interactive/components/control-panel-gradient-motion.js.map +1 -0
  377. package/dist/modes/interactive/components/control-panel-gradient.d.ts +27 -0
  378. package/dist/modes/interactive/components/control-panel-gradient.d.ts.map +1 -0
  379. package/dist/modes/interactive/components/control-panel-gradient.js +127 -0
  380. package/dist/modes/interactive/components/control-panel-gradient.js.map +1 -0
  381. package/dist/modes/interactive/components/control-panel.d.ts +56 -0
  382. package/dist/modes/interactive/components/control-panel.d.ts.map +1 -0
  383. package/dist/modes/interactive/components/control-panel.js +240 -0
  384. package/dist/modes/interactive/components/control-panel.js.map +1 -0
  385. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  386. package/dist/modes/interactive/components/custom-editor.js +21 -13
  387. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  388. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  389. package/dist/modes/interactive/components/earendil-announcement.js +1 -1
  390. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  391. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  392. package/dist/modes/interactive/components/extension-editor.js +1 -1
  393. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  394. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  395. package/dist/modes/interactive/components/footer.js +8 -0
  396. package/dist/modes/interactive/components/footer.js.map +1 -1
  397. package/dist/modes/interactive/components/index.d.ts +3 -0
  398. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  399. package/dist/modes/interactive/components/index.js +3 -0
  400. package/dist/modes/interactive/components/index.js.map +1 -1
  401. package/dist/modes/interactive/components/mcp-selector.d.ts +30 -0
  402. package/dist/modes/interactive/components/mcp-selector.d.ts.map +1 -0
  403. package/dist/modes/interactive/components/mcp-selector.js +155 -0
  404. package/dist/modes/interactive/components/mcp-selector.js.map +1 -0
  405. package/dist/modes/interactive/components/model-selector-state.d.ts +101 -0
  406. package/dist/modes/interactive/components/model-selector-state.d.ts.map +1 -0
  407. package/dist/modes/interactive/components/model-selector-state.js +261 -0
  408. package/dist/modes/interactive/components/model-selector-state.js.map +1 -0
  409. package/dist/modes/interactive/components/model-selector.d.ts +52 -9
  410. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  411. package/dist/modes/interactive/components/model-selector.js +212 -66
  412. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  413. package/dist/modes/interactive/components/settings-selector.d.ts +19 -1
  414. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  415. package/dist/modes/interactive/components/settings-selector.js +21 -8
  416. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  417. package/dist/modes/interactive/components/skills-selector.d.ts +32 -0
  418. package/dist/modes/interactive/components/skills-selector.d.ts.map +1 -0
  419. package/dist/modes/interactive/components/skills-selector.js +130 -0
  420. package/dist/modes/interactive/components/skills-selector.js.map +1 -0
  421. package/dist/modes/interactive/components/theme-selector.d.ts +1 -0
  422. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  423. package/dist/modes/interactive/components/theme-selector.js +10 -1
  424. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  425. package/dist/modes/interactive/components/thinking-selector.d.ts +7 -8
  426. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  427. package/dist/modes/interactive/components/thinking-selector.js +7 -48
  428. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  429. package/dist/modes/interactive/interactive-mode.d.ts +13 -2
  430. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  431. package/dist/modes/interactive/interactive-mode.js +399 -108
  432. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  433. package/dist/modes/interactive/theme/catppuccin-mocha.json +86 -0
  434. package/dist/modes/interactive/theme/dracula.json +86 -0
  435. package/dist/modes/interactive/theme/gruvbox-dark.json +86 -0
  436. package/dist/modes/interactive/theme/kanagawa-dragon.json +86 -0
  437. package/dist/modes/interactive/theme/omk-blackboard.json +91 -0
  438. package/dist/modes/interactive/theme/omk-control-panel.json +91 -0
  439. package/dist/modes/interactive/theme/omk-freedom-grid.json +91 -0
  440. package/dist/modes/interactive/theme/omk-neon-ops.json +90 -0
  441. package/dist/modes/interactive/theme/omk-slate-light.json +91 -0
  442. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  443. package/dist/modes/interactive/theme/theme.js +55 -16
  444. package/dist/modes/interactive/theme/theme.js.map +1 -1
  445. package/dist/modes/interactive/theme/tokyo-night-storm.json +86 -0
  446. package/dist/modes/print-mode.d.ts +2 -2
  447. package/dist/modes/print-mode.d.ts.map +1 -1
  448. package/dist/modes/print-mode.js +2 -2
  449. package/dist/modes/print-mode.js.map +1 -1
  450. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  451. package/dist/modes/rpc/rpc-mode.js +4 -0
  452. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  453. package/dist/package-manager-cli.d.ts.map +1 -1
  454. package/dist/package-manager-cli.js +114 -49
  455. package/dist/package-manager-cli.js.map +1 -1
  456. package/dist/utils/clipboard-image.d.ts.map +1 -1
  457. package/dist/utils/clipboard-image.js +1 -1
  458. package/dist/utils/clipboard-image.js.map +1 -1
  459. package/dist/utils/omk-user-agent.d.ts +2 -0
  460. package/dist/utils/omk-user-agent.d.ts.map +1 -0
  461. package/dist/utils/{pi-user-agent.js → omk-user-agent.js} +2 -2
  462. package/dist/utils/omk-user-agent.js.map +1 -0
  463. package/dist/utils/tools-manager.d.ts.map +1 -1
  464. package/dist/utils/tools-manager.js +1 -1
  465. package/dist/utils/tools-manager.js.map +1 -1
  466. package/dist/utils/version-check.d.ts +5 -5
  467. package/dist/utils/version-check.d.ts.map +1 -1
  468. package/dist/utils/version-check.js +8 -11
  469. package/dist/utils/version-check.js.map +1 -1
  470. package/dist/utils/windows-self-update.d.ts.map +1 -1
  471. package/dist/utils/windows-self-update.js +1 -1
  472. package/dist/utils/windows-self-update.js.map +1 -1
  473. package/docs/compaction.md +21 -8
  474. package/docs/packages.md +47 -6
  475. package/docs/prompt-templates.md +2 -0
  476. package/docs/quickstart.md +1 -1
  477. package/docs/themes.md +10 -2
  478. package/docs/usage.md +18 -7
  479. package/examples/README.md +1 -1
  480. package/examples/extensions/README.md +11 -11
  481. package/examples/extensions/auto-commit-on-exit.ts +6 -6
  482. package/examples/extensions/bash-spawn-hook.ts +4 -4
  483. package/examples/extensions/bookmark.ts +5 -5
  484. package/examples/extensions/border-status-editor.ts +7 -7
  485. package/examples/extensions/built-in-tool-renderer.ts +6 -6
  486. package/examples/extensions/claude-rules.ts +4 -4
  487. package/examples/extensions/commands.ts +5 -5
  488. package/examples/extensions/confirm-destructive.ts +3 -3
  489. package/examples/extensions/custom-compaction.ts +3 -3
  490. package/examples/extensions/custom-footer.ts +2 -2
  491. package/examples/extensions/custom-header.ts +5 -5
  492. package/examples/extensions/custom-provider-anthropic/index.ts +4 -4
  493. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  494. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  495. package/examples/extensions/custom-provider-gitlab-duo/index.ts +3 -3
  496. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  497. package/examples/extensions/dirty-repo-guard.ts +7 -7
  498. package/examples/extensions/doom-overlay/README.md +3 -3
  499. package/examples/extensions/doom-overlay/doom/build.sh +2 -2
  500. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +1 -1
  501. package/examples/extensions/doom-overlay/index.ts +3 -3
  502. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  503. package/examples/extensions/dynamic-resources/index.ts +2 -2
  504. package/examples/extensions/dynamic-tools.ts +4 -4
  505. package/examples/extensions/event-bus.ts +8 -8
  506. package/examples/extensions/file-trigger.ts +3 -3
  507. package/examples/extensions/git-checkpoint.ts +7 -7
  508. package/examples/extensions/git-merge-and-resolve.ts +14 -14
  509. package/examples/extensions/github-issue-autocomplete.ts +6 -6
  510. package/examples/extensions/gondolin/index.ts +16 -16
  511. package/examples/extensions/gondolin/package-lock.json +2 -2
  512. package/examples/extensions/gondolin/package.json +1 -1
  513. package/examples/extensions/handoff.ts +2 -2
  514. package/examples/extensions/hello.ts +2 -2
  515. package/examples/extensions/hidden-thinking-label.ts +4 -4
  516. package/examples/extensions/inline-bash.ts +5 -5
  517. package/examples/extensions/input-transform-streaming.ts +5 -5
  518. package/examples/extensions/input-transform.ts +5 -5
  519. package/examples/extensions/interactive-shell.ts +3 -3
  520. package/examples/extensions/mac-system-theme.ts +5 -5
  521. package/examples/extensions/message-renderer.ts +4 -4
  522. package/examples/extensions/minimal-mode.ts +9 -9
  523. package/examples/extensions/modal-editor.ts +3 -3
  524. package/examples/extensions/model-status.ts +3 -3
  525. package/examples/extensions/notify.ts +5 -5
  526. package/examples/extensions/overlay-qa-tests.ts +20 -20
  527. package/examples/extensions/overlay-test.ts +3 -3
  528. package/examples/extensions/permission-gate.ts +2 -2
  529. package/examples/extensions/pirate.ts +4 -4
  530. package/examples/extensions/plan-mode/index.ts +22 -22
  531. package/examples/extensions/preset.ts +30 -30
  532. package/examples/extensions/prompt-customizer.ts +3 -3
  533. package/examples/extensions/protected-paths.ts +2 -2
  534. package/examples/extensions/provider-payload.ts +5 -5
  535. package/examples/extensions/qna.ts +2 -2
  536. package/examples/extensions/question.ts +2 -2
  537. package/examples/extensions/questionnaire.ts +2 -2
  538. package/examples/extensions/rainbow-editor.ts +3 -3
  539. package/examples/extensions/reload-runtime.ts +4 -4
  540. package/examples/extensions/rpc-demo.ts +10 -10
  541. package/examples/extensions/sandbox/index.ts +17 -17
  542. package/examples/extensions/sandbox/package-lock.json +2 -2
  543. package/examples/extensions/sandbox/package.json +1 -1
  544. package/examples/extensions/send-user-message.ts +13 -13
  545. package/examples/extensions/session-name.ts +4 -4
  546. package/examples/extensions/shutdown-command.ts +10 -10
  547. package/examples/extensions/snake.ts +3 -3
  548. package/examples/extensions/space-invaders.ts +3 -3
  549. package/examples/extensions/ssh.ts +12 -12
  550. package/examples/extensions/status-line.ts +4 -4
  551. package/examples/extensions/structured-output.ts +2 -2
  552. package/examples/extensions/subagent/README.md +13 -13
  553. package/examples/extensions/subagent/agents.ts +2 -2
  554. package/examples/extensions/subagent/index.ts +53 -21
  555. package/examples/extensions/summarize.ts +2 -2
  556. package/examples/extensions/system-prompt-header.ts +3 -3
  557. package/examples/extensions/tic-tac-toe.ts +15 -15
  558. package/examples/extensions/timed-confirm.ts +4 -4
  559. package/examples/extensions/titlebar-spinner.ts +9 -9
  560. package/examples/extensions/todo.ts +5 -5
  561. package/examples/extensions/tool-override.ts +5 -5
  562. package/examples/extensions/tools.ts +10 -10
  563. package/examples/extensions/trigger-compact.ts +3 -3
  564. package/examples/extensions/truncated-tool.ts +3 -3
  565. package/examples/extensions/widget-placement.ts +2 -2
  566. package/examples/extensions/with-deps/index.ts +2 -2
  567. package/examples/extensions/with-deps/package-lock.json +2 -2
  568. package/examples/extensions/with-deps/package.json +1 -1
  569. package/examples/extensions/working-indicator.ts +7 -7
  570. package/examples/extensions/working-message-test.ts +3 -3
  571. package/examples/sdk/01-minimal.ts +1 -1
  572. package/examples/sdk/03-custom-prompt.ts +1 -1
  573. package/examples/sdk/04-skills.ts +1 -1
  574. package/examples/sdk/05-tools.ts +1 -1
  575. package/examples/sdk/06-extensions.ts +11 -11
  576. package/examples/sdk/07-context-files.ts +2 -0
  577. package/examples/sdk/08-prompt-templates.ts +1 -1
  578. package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
  579. package/examples/sdk/README.md +2 -2
  580. package/node_modules/@earendil-works/omk-agent-core/README.md +488 -0
  581. package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.d.ts +24 -0
  582. package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.d.ts.map +1 -0
  583. package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.js +553 -0
  584. package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.js.map +1 -0
  585. package/node_modules/@earendil-works/omk-agent-core/dist/agent.d.ts +118 -0
  586. package/node_modules/@earendil-works/omk-agent-core/dist/agent.d.ts.map +1 -0
  587. package/node_modules/@earendil-works/omk-agent-core/dist/agent.js +402 -0
  588. package/node_modules/@earendil-works/omk-agent-core/dist/agent.js.map +1 -0
  589. package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.d.ts +95 -0
  590. package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.d.ts.map +1 -0
  591. package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.js +996 -0
  592. package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.js.map +1 -0
  593. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.d.ts +53 -0
  594. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
  595. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.js +175 -0
  596. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -0
  597. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.d.ts +117 -0
  598. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -0
  599. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.js +568 -0
  600. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.js.map +1 -0
  601. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.d.ts +25 -0
  602. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.d.ts.map +1 -0
  603. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.js +131 -0
  604. package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.js.map +1 -0
  605. package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.d.ts +51 -0
  606. package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.d.ts.map +1 -0
  607. package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.js +510 -0
  608. package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.js.map +1 -0
  609. package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.d.ts +51 -0
  610. package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.d.ts.map +1 -0
  611. package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.js +102 -0
  612. package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.js.map +1 -0
  613. package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.d.ts +48 -0
  614. package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.d.ts.map +1 -0
  615. package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.js +230 -0
  616. package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.js.map +1 -0
  617. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.d.ts +26 -0
  618. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.d.ts.map +1 -0
  619. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.js +101 -0
  620. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.js.map +1 -0
  621. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.d.ts +36 -0
  622. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -0
  623. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.js +273 -0
  624. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.js.map +1 -0
  625. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.d.ts +18 -0
  626. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.d.ts.map +1 -0
  627. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.js +42 -0
  628. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.js.map +1 -0
  629. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.d.ts +25 -0
  630. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -0
  631. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.js +114 -0
  632. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.js.map +1 -0
  633. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.d.ts +11 -0
  634. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -0
  635. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.js +39 -0
  636. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.js.map +1 -0
  637. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.d.ts +33 -0
  638. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.d.ts.map +1 -0
  639. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.js +210 -0
  640. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.js.map +1 -0
  641. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.d.ts +2 -0
  642. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.d.ts.map +1 -0
  643. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.js +50 -0
  644. package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.js.map +1 -0
  645. package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.d.ts +44 -0
  646. package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.d.ts.map +1 -0
  647. package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.js +311 -0
  648. package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.js.map +1 -0
  649. package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.d.ts +3 -0
  650. package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.d.ts.map +1 -0
  651. package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.js +30 -0
  652. package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.js.map +1 -0
  653. package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.d.ts +616 -0
  654. package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.d.ts.map +1 -0
  655. package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.js +94 -0
  656. package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.js.map +1 -0
  657. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.d.ts +14 -0
  658. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -0
  659. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.js +126 -0
  660. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.js.map +1 -0
  661. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.d.ts +70 -0
  662. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.d.ts.map +1 -0
  663. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.js +297 -0
  664. package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.js.map +1 -0
  665. package/node_modules/@earendil-works/omk-agent-core/dist/index.d.ts +20 -0
  666. package/node_modules/@earendil-works/omk-agent-core/dist/index.d.ts.map +1 -0
  667. package/node_modules/@earendil-works/omk-agent-core/dist/index.js +25 -0
  668. package/node_modules/@earendil-works/omk-agent-core/dist/index.js.map +1 -0
  669. package/node_modules/@earendil-works/omk-agent-core/dist/node.d.ts +3 -0
  670. package/node_modules/@earendil-works/omk-agent-core/dist/node.d.ts.map +1 -0
  671. package/node_modules/@earendil-works/omk-agent-core/dist/node.js +3 -0
  672. package/node_modules/@earendil-works/omk-agent-core/dist/node.js.map +1 -0
  673. package/node_modules/@earendil-works/omk-agent-core/dist/proxy.d.ts +69 -0
  674. package/node_modules/@earendil-works/omk-agent-core/dist/proxy.d.ts.map +1 -0
  675. package/node_modules/@earendil-works/omk-agent-core/dist/proxy.js +278 -0
  676. package/node_modules/@earendil-works/omk-agent-core/dist/proxy.js.map +1 -0
  677. package/node_modules/@earendil-works/omk-agent-core/dist/types.d.ts +393 -0
  678. package/node_modules/@earendil-works/omk-agent-core/dist/types.d.ts.map +1 -0
  679. package/node_modules/@earendil-works/omk-agent-core/dist/types.js +2 -0
  680. package/node_modules/@earendil-works/omk-agent-core/dist/types.js.map +1 -0
  681. package/node_modules/@earendil-works/omk-agent-core/package.json +60 -0
  682. package/node_modules/@earendil-works/omk-ai/README.md +1389 -0
  683. package/node_modules/@earendil-works/omk-ai/dist/api-registry.d.ts +20 -0
  684. package/node_modules/@earendil-works/omk-ai/dist/api-registry.d.ts.map +1 -0
  685. package/node_modules/@earendil-works/omk-ai/dist/api-registry.js +44 -0
  686. package/node_modules/@earendil-works/omk-ai/dist/api-registry.js.map +1 -0
  687. package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.d.ts +5 -0
  688. package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.d.ts.map +1 -0
  689. package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.js +6 -0
  690. package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.js.map +1 -0
  691. package/node_modules/@earendil-works/omk-ai/dist/cli.d.ts +3 -0
  692. package/node_modules/@earendil-works/omk-ai/dist/cli.d.ts.map +1 -0
  693. package/node_modules/@earendil-works/omk-ai/dist/cli.js +130 -0
  694. package/node_modules/@earendil-works/omk-ai/dist/cli.js.map +1 -0
  695. package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.d.ts +20 -0
  696. package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.d.ts.map +1 -0
  697. package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.js +199 -0
  698. package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.js.map +1 -0
  699. package/node_modules/@earendil-works/omk-ai/dist/image-models.d.ts +10 -0
  700. package/node_modules/@earendil-works/omk-ai/dist/image-models.d.ts.map +1 -0
  701. package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.d.ts +515 -0
  702. package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.d.ts.map +1 -0
  703. package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.js +517 -0
  704. package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.js.map +1 -0
  705. package/node_modules/@earendil-works/omk-ai/dist/image-models.js +23 -0
  706. package/node_modules/@earendil-works/omk-ai/dist/image-models.js.map +1 -0
  707. package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.d.ts +14 -0
  708. package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.d.ts.map +1 -0
  709. package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.js +22 -0
  710. package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.js.map +1 -0
  711. package/node_modules/@earendil-works/omk-ai/dist/images.d.ts +4 -0
  712. package/node_modules/@earendil-works/omk-ai/dist/images.d.ts.map +1 -0
  713. package/node_modules/@earendil-works/omk-ai/dist/images.js +16 -0
  714. package/node_modules/@earendil-works/omk-ai/dist/images.js.map +1 -0
  715. package/node_modules/@earendil-works/omk-ai/dist/index.d.ts +33 -0
  716. package/node_modules/@earendil-works/omk-ai/dist/index.d.ts.map +1 -0
  717. package/node_modules/@earendil-works/omk-ai/dist/index.js +21 -0
  718. package/node_modules/@earendil-works/omk-ai/dist/index.js.map +1 -0
  719. package/node_modules/@earendil-works/omk-ai/dist/models.d.ts +18 -0
  720. package/node_modules/@earendil-works/omk-ai/dist/models.d.ts.map +1 -0
  721. package/node_modules/@earendil-works/omk-ai/dist/models.generated.d.ts +18762 -0
  722. package/node_modules/@earendil-works/omk-ai/dist/models.generated.d.ts.map +1 -0
  723. package/node_modules/@earendil-works/omk-ai/dist/models.generated.js +17197 -0
  724. package/node_modules/@earendil-works/omk-ai/dist/models.generated.js.map +1 -0
  725. package/node_modules/@earendil-works/omk-ai/dist/models.js +78 -0
  726. package/node_modules/@earendil-works/omk-ai/dist/models.js.map +1 -0
  727. package/node_modules/@earendil-works/omk-ai/dist/oauth.d.ts +2 -0
  728. package/node_modules/@earendil-works/omk-ai/dist/oauth.d.ts.map +1 -0
  729. package/node_modules/@earendil-works/omk-ai/dist/oauth.js +2 -0
  730. package/node_modules/@earendil-works/omk-ai/dist/oauth.js.map +1 -0
  731. package/node_modules/@earendil-works/omk-ai/dist/provider-network.d.ts +39 -0
  732. package/node_modules/@earendil-works/omk-ai/dist/provider-network.d.ts.map +1 -0
  733. package/node_modules/@earendil-works/omk-ai/dist/provider-network.js +170 -0
  734. package/node_modules/@earendil-works/omk-ai/dist/provider-network.js.map +1 -0
  735. package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.d.ts +38 -0
  736. package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
  737. package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.js +826 -0
  738. package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.js.map +1 -0
  739. package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.d.ts +77 -0
  740. package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.d.ts.map +1 -0
  741. package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.js +1123 -0
  742. package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.js.map +1 -0
  743. package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.d.ts +15 -0
  744. package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
  745. package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.js +221 -0
  746. package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.js.map +1 -0
  747. package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.d.ts +13 -0
  748. package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.d.ts.map +1 -0
  749. package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.js +26 -0
  750. package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.js.map +1 -0
  751. package/node_modules/@earendil-works/omk-ai/dist/providers/faux.d.ts +56 -0
  752. package/node_modules/@earendil-works/omk-ai/dist/providers/faux.d.ts.map +1 -0
  753. package/node_modules/@earendil-works/omk-ai/dist/providers/faux.js +368 -0
  754. package/node_modules/@earendil-works/omk-ai/dist/providers/faux.js.map +1 -0
  755. package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.d.ts +8 -0
  756. package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
  757. package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.js +29 -0
  758. package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.js.map +1 -0
  759. package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.d.ts +70 -0
  760. package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.d.ts.map +1 -0
  761. package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.js +331 -0
  762. package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.js.map +1 -0
  763. package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.d.ts +15 -0
  764. package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.d.ts.map +1 -0
  765. package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.js +442 -0
  766. package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.js.map +1 -0
  767. package/node_modules/@earendil-works/omk-ai/dist/providers/google.d.ts +13 -0
  768. package/node_modules/@earendil-works/omk-ai/dist/providers/google.d.ts.map +1 -0
  769. package/node_modules/@earendil-works/omk-ai/dist/providers/google.js +402 -0
  770. package/node_modules/@earendil-works/omk-ai/dist/providers/google.js.map +1 -0
  771. package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.d.ts +3 -0
  772. package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.d.ts.map +1 -0
  773. package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.js +128 -0
  774. package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.js.map +1 -0
  775. package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.d.ts +4 -0
  776. package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.d.ts.map +1 -0
  777. package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.js +34 -0
  778. package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.js.map +1 -0
  779. package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.d.ts +25 -0
  780. package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.d.ts.map +1 -0
  781. package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.js +534 -0
  782. package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.js.map +1 -0
  783. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.d.ts +30 -0
  784. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
  785. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.js +1171 -0
  786. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.js.map +1 -0
  787. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.d.ts +19 -0
  788. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.d.ts.map +1 -0
  789. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.js +977 -0
  790. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.js.map +1 -0
  791. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.d.ts +11 -0
  792. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.d.ts.map +1 -0
  793. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.js +22 -0
  794. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.js.map +1 -0
  795. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.d.ts +18 -0
  796. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
  797. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.js +496 -0
  798. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.js.map +1 -0
  799. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.d.ts +13 -0
  800. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.d.ts.map +1 -0
  801. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.js +233 -0
  802. package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.js.map +1 -0
  803. package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.d.ts +35 -0
  804. package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.d.ts.map +1 -0
  805. package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.js +254 -0
  806. package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.js.map +1 -0
  807. package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.d.ts +8 -0
  808. package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.d.ts.map +1 -0
  809. package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.js +42 -0
  810. package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.js.map +1 -0
  811. package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.d.ts +13 -0
  812. package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.d.ts.map +1 -0
  813. package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.js +82 -0
  814. package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.js.map +1 -0
  815. package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.d.ts +8 -0
  816. package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.d.ts.map +1 -0
  817. package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.js +184 -0
  818. package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.js.map +1 -0
  819. package/node_modules/@earendil-works/omk-ai/dist/session-resources.d.ts +4 -0
  820. package/node_modules/@earendil-works/omk-ai/dist/session-resources.d.ts.map +1 -0
  821. package/node_modules/@earendil-works/omk-ai/dist/session-resources.js +22 -0
  822. package/node_modules/@earendil-works/omk-ai/dist/session-resources.js.map +1 -0
  823. package/node_modules/@earendil-works/omk-ai/dist/stream.d.ts +8 -0
  824. package/node_modules/@earendil-works/omk-ai/dist/stream.d.ts.map +1 -0
  825. package/node_modules/@earendil-works/omk-ai/dist/stream.js +77 -0
  826. package/node_modules/@earendil-works/omk-ai/dist/stream.js.map +1 -0
  827. package/node_modules/@earendil-works/omk-ai/dist/types.d.ts +570 -0
  828. package/node_modules/@earendil-works/omk-ai/dist/types.d.ts.map +1 -0
  829. package/node_modules/@earendil-works/omk-ai/dist/types.js +2 -0
  830. package/node_modules/@earendil-works/omk-ai/dist/types.js.map +1 -0
  831. package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.d.ts +6 -0
  832. package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.d.ts.map +1 -0
  833. package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.js +34 -0
  834. package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.js.map +1 -0
  835. package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.d.ts +19 -0
  836. package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.d.ts.map +1 -0
  837. package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.js +25 -0
  838. package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.js.map +1 -0
  839. package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.d.ts +21 -0
  840. package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.d.ts.map +1 -0
  841. package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.js +81 -0
  842. package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.js.map +1 -0
  843. package/node_modules/@earendil-works/omk-ai/dist/utils/hash.d.ts +3 -0
  844. package/node_modules/@earendil-works/omk-ai/dist/utils/hash.d.ts.map +1 -0
  845. package/node_modules/@earendil-works/omk-ai/dist/utils/hash.js +14 -0
  846. package/node_modules/@earendil-works/omk-ai/dist/utils/hash.js.map +1 -0
  847. package/node_modules/@earendil-works/omk-ai/dist/utils/headers.d.ts +2 -0
  848. package/node_modules/@earendil-works/omk-ai/dist/utils/headers.d.ts.map +1 -0
  849. package/node_modules/@earendil-works/omk-ai/dist/utils/headers.js +8 -0
  850. package/node_modules/@earendil-works/omk-ai/dist/utils/headers.js.map +1 -0
  851. package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.d.ts +16 -0
  852. package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.d.ts.map +1 -0
  853. package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.js +113 -0
  854. package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.js.map +1 -0
  855. package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.d.ts +10 -0
  856. package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.d.ts.map +1 -0
  857. package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.js +97 -0
  858. package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.js.map +1 -0
  859. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.d.ts +25 -0
  860. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
  861. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.js +335 -0
  862. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.js.map +1 -0
  863. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.d.ts +21 -0
  864. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.d.ts.map +1 -0
  865. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.js +56 -0
  866. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.js.map +1 -0
  867. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.d.ts +30 -0
  868. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
  869. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.js +280 -0
  870. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.js.map +1 -0
  871. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.d.ts +58 -0
  872. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.d.ts.map +1 -0
  873. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.js +122 -0
  874. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.js.map +1 -0
  875. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.d.ts +3 -0
  876. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.d.ts.map +1 -0
  877. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.js +105 -0
  878. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.js.map +1 -0
  879. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.d.ts +43 -0
  880. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
  881. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.js +487 -0
  882. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.js.map +1 -0
  883. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.d.ts +13 -0
  884. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.d.ts.map +1 -0
  885. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.js +31 -0
  886. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.js.map +1 -0
  887. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.d.ts +64 -0
  888. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.d.ts.map +1 -0
  889. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.js +2 -0
  890. package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.js.map +1 -0
  891. package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.d.ts +57 -0
  892. package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.d.ts.map +1 -0
  893. package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.js +154 -0
  894. package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.js.map +1 -0
  895. package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.d.ts +22 -0
  896. package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
  897. package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.js +26 -0
  898. package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.js.map +1 -0
  899. package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.d.ts +17 -0
  900. package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.d.ts.map +1 -0
  901. package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.js +21 -0
  902. package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.js.map +1 -0
  903. package/node_modules/@earendil-works/omk-ai/dist/utils/validation.d.ts +18 -0
  904. package/node_modules/@earendil-works/omk-ai/dist/utils/validation.d.ts.map +1 -0
  905. package/node_modules/@earendil-works/omk-ai/dist/utils/validation.js +281 -0
  906. package/node_modules/@earendil-works/omk-ai/dist/utils/validation.js.map +1 -0
  907. package/node_modules/@earendil-works/omk-ai/package.json +106 -0
  908. package/node_modules/@earendil-works/omk-tui/README.md +791 -0
  909. package/node_modules/@earendil-works/omk-tui/dist/autocomplete.d.ts +54 -0
  910. package/node_modules/@earendil-works/omk-tui/dist/autocomplete.d.ts.map +1 -0
  911. package/node_modules/@earendil-works/omk-tui/dist/autocomplete.js +632 -0
  912. package/node_modules/@earendil-works/omk-tui/dist/autocomplete.js.map +1 -0
  913. package/node_modules/@earendil-works/omk-tui/dist/components/box.d.ts +22 -0
  914. package/node_modules/@earendil-works/omk-tui/dist/components/box.d.ts.map +1 -0
  915. package/node_modules/@earendil-works/omk-tui/dist/components/box.js +104 -0
  916. package/node_modules/@earendil-works/omk-tui/dist/components/box.js.map +1 -0
  917. package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.d.ts +22 -0
  918. package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.d.ts.map +1 -0
  919. package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.js +35 -0
  920. package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.js.map +1 -0
  921. package/node_modules/@earendil-works/omk-tui/dist/components/editor.d.ts +249 -0
  922. package/node_modules/@earendil-works/omk-tui/dist/components/editor.d.ts.map +1 -0
  923. package/node_modules/@earendil-works/omk-tui/dist/components/editor.js +1857 -0
  924. package/node_modules/@earendil-works/omk-tui/dist/components/editor.js.map +1 -0
  925. package/node_modules/@earendil-works/omk-tui/dist/components/image.d.ts +28 -0
  926. package/node_modules/@earendil-works/omk-tui/dist/components/image.d.ts.map +1 -0
  927. package/node_modules/@earendil-works/omk-tui/dist/components/image.js +89 -0
  928. package/node_modules/@earendil-works/omk-tui/dist/components/image.js.map +1 -0
  929. package/node_modules/@earendil-works/omk-tui/dist/components/input.d.ts +37 -0
  930. package/node_modules/@earendil-works/omk-tui/dist/components/input.d.ts.map +1 -0
  931. package/node_modules/@earendil-works/omk-tui/dist/components/input.js +378 -0
  932. package/node_modules/@earendil-works/omk-tui/dist/components/input.js.map +1 -0
  933. package/node_modules/@earendil-works/omk-tui/dist/components/loader.d.ts +31 -0
  934. package/node_modules/@earendil-works/omk-tui/dist/components/loader.d.ts.map +1 -0
  935. package/node_modules/@earendil-works/omk-tui/dist/components/loader.js +69 -0
  936. package/node_modules/@earendil-works/omk-tui/dist/components/loader.js.map +1 -0
  937. package/node_modules/@earendil-works/omk-tui/dist/components/markdown.d.ts +96 -0
  938. package/node_modules/@earendil-works/omk-tui/dist/components/markdown.d.ts.map +1 -0
  939. package/node_modules/@earendil-works/omk-tui/dist/components/markdown.js +644 -0
  940. package/node_modules/@earendil-works/omk-tui/dist/components/markdown.js.map +1 -0
  941. package/node_modules/@earendil-works/omk-tui/dist/components/select-list.d.ts +50 -0
  942. package/node_modules/@earendil-works/omk-tui/dist/components/select-list.d.ts.map +1 -0
  943. package/node_modules/@earendil-works/omk-tui/dist/components/select-list.js +159 -0
  944. package/node_modules/@earendil-works/omk-tui/dist/components/select-list.js.map +1 -0
  945. package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.d.ts +50 -0
  946. package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.d.ts.map +1 -0
  947. package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.js +185 -0
  948. package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.js.map +1 -0
  949. package/node_modules/@earendil-works/omk-tui/dist/components/spacer.d.ts +12 -0
  950. package/node_modules/@earendil-works/omk-tui/dist/components/spacer.d.ts.map +1 -0
  951. package/node_modules/@earendil-works/omk-tui/dist/components/spacer.js +23 -0
  952. package/node_modules/@earendil-works/omk-tui/dist/components/spacer.js.map +1 -0
  953. package/node_modules/@earendil-works/omk-tui/dist/components/text.d.ts +19 -0
  954. package/node_modules/@earendil-works/omk-tui/dist/components/text.d.ts.map +1 -0
  955. package/node_modules/@earendil-works/omk-tui/dist/components/text.js +89 -0
  956. package/node_modules/@earendil-works/omk-tui/dist/components/text.js.map +1 -0
  957. package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.d.ts +13 -0
  958. package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.d.ts.map +1 -0
  959. package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.js +51 -0
  960. package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.js.map +1 -0
  961. package/node_modules/@earendil-works/omk-tui/dist/editor-component.d.ts +39 -0
  962. package/node_modules/@earendil-works/omk-tui/dist/editor-component.d.ts.map +1 -0
  963. package/node_modules/@earendil-works/omk-tui/dist/editor-component.js +2 -0
  964. package/node_modules/@earendil-works/omk-tui/dist/editor-component.js.map +1 -0
  965. package/node_modules/@earendil-works/omk-tui/dist/fuzzy.d.ts +16 -0
  966. package/node_modules/@earendil-works/omk-tui/dist/fuzzy.d.ts.map +1 -0
  967. package/node_modules/@earendil-works/omk-tui/dist/fuzzy.js +110 -0
  968. package/node_modules/@earendil-works/omk-tui/dist/fuzzy.js.map +1 -0
  969. package/node_modules/@earendil-works/omk-tui/dist/index.d.ts +23 -0
  970. package/node_modules/@earendil-works/omk-tui/dist/index.d.ts.map +1 -0
  971. package/node_modules/@earendil-works/omk-tui/dist/index.js +32 -0
  972. package/node_modules/@earendil-works/omk-tui/dist/index.js.map +1 -0
  973. package/node_modules/@earendil-works/omk-tui/dist/keybindings.d.ts +212 -0
  974. package/node_modules/@earendil-works/omk-tui/dist/keybindings.d.ts.map +1 -0
  975. package/node_modules/@earendil-works/omk-tui/dist/keybindings.js +252 -0
  976. package/node_modules/@earendil-works/omk-tui/dist/keybindings.js.map +1 -0
  977. package/node_modules/@earendil-works/omk-tui/dist/keys.d.ts +184 -0
  978. package/node_modules/@earendil-works/omk-tui/dist/keys.d.ts.map +1 -0
  979. package/node_modules/@earendil-works/omk-tui/dist/keys.js +1173 -0
  980. package/node_modules/@earendil-works/omk-tui/dist/keys.js.map +1 -0
  981. package/node_modules/@earendil-works/omk-tui/dist/kill-ring.d.ts +28 -0
  982. package/node_modules/@earendil-works/omk-tui/dist/kill-ring.d.ts.map +1 -0
  983. package/node_modules/@earendil-works/omk-tui/dist/kill-ring.js +44 -0
  984. package/node_modules/@earendil-works/omk-tui/dist/kill-ring.js.map +1 -0
  985. package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.d.ts +3 -0
  986. package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.d.ts.map +1 -0
  987. package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.js +53 -0
  988. package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.js.map +1 -0
  989. package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.d.ts +50 -0
  990. package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.d.ts.map +1 -0
  991. package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.js +361 -0
  992. package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.js.map +1 -0
  993. package/node_modules/@earendil-works/omk-tui/dist/terminal-image.d.ts +90 -0
  994. package/node_modules/@earendil-works/omk-tui/dist/terminal-image.d.ts.map +1 -0
  995. package/node_modules/@earendil-works/omk-tui/dist/terminal-image.js +366 -0
  996. package/node_modules/@earendil-works/omk-tui/dist/terminal-image.js.map +1 -0
  997. package/node_modules/@earendil-works/omk-tui/dist/terminal.d.ts +113 -0
  998. package/node_modules/@earendil-works/omk-tui/dist/terminal.d.ts.map +1 -0
  999. package/node_modules/@earendil-works/omk-tui/dist/terminal.js +472 -0
  1000. package/node_modules/@earendil-works/omk-tui/dist/terminal.js.map +1 -0
  1001. package/node_modules/@earendil-works/omk-tui/dist/tui.d.ts +242 -0
  1002. package/node_modules/@earendil-works/omk-tui/dist/tui.d.ts.map +1 -0
  1003. package/node_modules/@earendil-works/omk-tui/dist/tui.js +1221 -0
  1004. package/node_modules/@earendil-works/omk-tui/dist/tui.js.map +1 -0
  1005. package/node_modules/@earendil-works/omk-tui/dist/undo-stack.d.ts +17 -0
  1006. package/node_modules/@earendil-works/omk-tui/dist/undo-stack.d.ts.map +1 -0
  1007. package/node_modules/@earendil-works/omk-tui/dist/undo-stack.js +25 -0
  1008. package/node_modules/@earendil-works/omk-tui/dist/undo-stack.js.map +1 -0
  1009. package/node_modules/@earendil-works/omk-tui/dist/utils.d.ts +84 -0
  1010. package/node_modules/@earendil-works/omk-tui/dist/utils.d.ts.map +1 -0
  1011. package/node_modules/@earendil-works/omk-tui/dist/utils.js +1032 -0
  1012. package/node_modules/@earendil-works/omk-tui/dist/utils.js.map +1 -0
  1013. package/node_modules/@earendil-works/omk-tui/dist/word-navigation.d.ts +25 -0
  1014. package/node_modules/@earendil-works/omk-tui/dist/word-navigation.d.ts.map +1 -0
  1015. package/node_modules/@earendil-works/omk-tui/dist/word-navigation.js +96 -0
  1016. package/node_modules/@earendil-works/omk-tui/dist/word-navigation.js.map +1 -0
  1017. package/node_modules/@earendil-works/omk-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
  1018. package/node_modules/@earendil-works/omk-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  1019. package/node_modules/@earendil-works/omk-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  1020. package/node_modules/@earendil-works/omk-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  1021. package/node_modules/@earendil-works/omk-tui/package.json +47 -0
  1022. package/package.json +22 -6
  1023. package/dist/utils/pi-user-agent.d.ts +0 -2
  1024. package/dist/utils/pi-user-agent.d.ts.map +0 -1
  1025. package/dist/utils/pi-user-agent.js.map +0 -1
@@ -0,0 +1,78 @@
1
+ /**
2
+ * `cli.contract.verify` — durable, tamper-evident verification of a CLI contract.
3
+ *
4
+ * Builds on the harness-control hash-chained ledger to record a contract
5
+ * verification as two correlated events (started -> completed/blocked), each
6
+ * carrying the SHA-256 of the contract's manifest and test files. After
7
+ * recording, the whole ledger is re-verified; a contract is only `passed` when
8
+ * both the gate succeeds AND the hash-chain ledger verifies. This lets a release
9
+ * gate detect after-the-fact tampering of either the contract artifacts or the
10
+ * audit ledger itself.
11
+ *
12
+ * Dependency-free: uses node:crypto only (no fast-check/xterm/etc.).
13
+ */
14
+ export declare const CONTRACT_VERIFY_EVENT_KIND = "cli.contract.verify";
15
+ export declare const CONTRACT_RESULT_SCHEMA_VERSION = "omk.cli-contract.result.v1";
16
+ export interface ContractFileRef {
17
+ readonly id: string;
18
+ readonly path: string;
19
+ }
20
+ export interface ContractFileHash {
21
+ readonly id: string;
22
+ readonly path: string;
23
+ /** `sha256:<hex>` of the file contents. */
24
+ readonly sha256: string;
25
+ }
26
+ export type ContractVerificationStatus = "passed" | "blocked";
27
+ export interface ContractGateResult {
28
+ readonly ok: boolean;
29
+ readonly details?: string;
30
+ }
31
+ export interface ContractLedgerSummary {
32
+ readonly path: string;
33
+ readonly verified: boolean;
34
+ readonly errors: readonly string[];
35
+ }
36
+ export interface ContractResult {
37
+ readonly schemaVersion: typeof CONTRACT_RESULT_SCHEMA_VERSION;
38
+ readonly contractId: string;
39
+ readonly contractVersion: string;
40
+ readonly status: ContractVerificationStatus;
41
+ readonly manifestHash: string;
42
+ readonly testFileHash: string;
43
+ readonly files: readonly ContractFileHash[];
44
+ readonly gate: ContractGateResult;
45
+ readonly ledger: ContractLedgerSummary;
46
+ readonly startedAt: string;
47
+ readonly completedAt: string;
48
+ }
49
+ export interface VerifyCliContractOptions {
50
+ readonly contractId: string;
51
+ readonly contractVersion: string;
52
+ readonly manifestPath: string;
53
+ readonly testPath: string;
54
+ readonly extraFiles?: readonly ContractFileRef[];
55
+ /** Runs the actual contract gate (e.g. the vitest contract file). */
56
+ readonly runGate: () => ContractGateResult | Promise<ContractGateResult>;
57
+ readonly cwd?: string;
58
+ readonly logPath?: string;
59
+ readonly runId?: string;
60
+ /** When set, a JSON contract-result is written here (atomically). */
61
+ readonly resultPath?: string;
62
+ readonly now?: () => Date;
63
+ }
64
+ /**
65
+ * Verify a CLI contract and append a tamper-evident audit trail.
66
+ *
67
+ * Algorithm:
68
+ * 1. SHA-256 the manifest, test, and any extra contract files.
69
+ * 2. Record a `started` ledger event (manifest/test hashes + artifact manifest).
70
+ * 3. Run the contract gate.
71
+ * 4. Record a `completed` (gate ok) or `blocked` (gate failed) ledger event.
72
+ * 5. Re-verify the whole hash-chain ledger.
73
+ * 6. Status is `passed` only when the gate passed AND the ledger verifies;
74
+ * otherwise `blocked`.
75
+ * 7. Optionally write a canonical contract-result.json.
76
+ */
77
+ export declare function verifyCliContract(options: VerifyCliContractOptions): Promise<ContractResult>;
78
+ //# sourceMappingURL=contract-verification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-verification.d.ts","sourceRoot":"","sources":["../../src/core/contract-verification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,eAAO,MAAM,0BAA0B,wBAAwB,CAAC;AAChE,eAAO,MAAM,8BAA8B,+BAA+B,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,0BAA0B,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,aAAa,EAAE,OAAO,8BAA8B,CAAC;IAC9D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACjD,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACzE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,CAgFlG","sourcesContent":["/**\n * `cli.contract.verify` — durable, tamper-evident verification of a CLI contract.\n *\n * Builds on the harness-control hash-chained ledger to record a contract\n * verification as two correlated events (started -> completed/blocked), each\n * carrying the SHA-256 of the contract's manifest and test files. After\n * recording, the whole ledger is re-verified; a contract is only `passed` when\n * both the gate succeeds AND the hash-chain ledger verifies. This lets a release\n * gate detect after-the-fact tampering of either the contract artifacts or the\n * audit ledger itself.\n *\n * Dependency-free: uses node:crypto only (no fast-check/xterm/etc.).\n */\n\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport {\n\ttype HarnessControlEventOptions,\n\ttype HarnessControlEventWriteResult,\n\trecordHarnessControlEvent,\n\tresolveHarnessControlEventLogPath,\n\tverifyHarnessControlLedger,\n} from \"./harness-control-events.ts\";\n\nexport const CONTRACT_VERIFY_EVENT_KIND = \"cli.contract.verify\";\nexport const CONTRACT_RESULT_SCHEMA_VERSION = \"omk.cli-contract.result.v1\";\n\nexport interface ContractFileRef {\n\treadonly id: string;\n\treadonly path: string;\n}\n\nexport interface ContractFileHash {\n\treadonly id: string;\n\treadonly path: string;\n\t/** `sha256:<hex>` of the file contents. */\n\treadonly sha256: string;\n}\n\nexport type ContractVerificationStatus = \"passed\" | \"blocked\";\n\nexport interface ContractGateResult {\n\treadonly ok: boolean;\n\treadonly details?: string;\n}\n\nexport interface ContractLedgerSummary {\n\treadonly path: string;\n\treadonly verified: boolean;\n\treadonly errors: readonly string[];\n}\n\nexport interface ContractResult {\n\treadonly schemaVersion: typeof CONTRACT_RESULT_SCHEMA_VERSION;\n\treadonly contractId: string;\n\treadonly contractVersion: string;\n\treadonly status: ContractVerificationStatus;\n\treadonly manifestHash: string;\n\treadonly testFileHash: string;\n\treadonly files: readonly ContractFileHash[];\n\treadonly gate: ContractGateResult;\n\treadonly ledger: ContractLedgerSummary;\n\treadonly startedAt: string;\n\treadonly completedAt: string;\n}\n\nexport interface VerifyCliContractOptions {\n\treadonly contractId: string;\n\treadonly contractVersion: string;\n\treadonly manifestPath: string;\n\treadonly testPath: string;\n\treadonly extraFiles?: readonly ContractFileRef[];\n\t/** Runs the actual contract gate (e.g. the vitest contract file). */\n\treadonly runGate: () => ContractGateResult | Promise<ContractGateResult>;\n\treadonly cwd?: string;\n\treadonly logPath?: string;\n\treadonly runId?: string;\n\t/** When set, a JSON contract-result is written here (atomically). */\n\treadonly resultPath?: string;\n\treadonly now?: () => Date;\n}\n\nfunction hashFile(path: string): string {\n\treturn `sha256:${createHash(\"sha256\").update(readFileSync(path)).digest(\"hex\")}`;\n}\n\nfunction writeJsonAtomic(path: string, value: unknown): void {\n\tmkdirSync(dirname(path), { recursive: true });\n\tconst tmp = `${path}.tmp-${process.pid}-${randomUUID()}`;\n\twriteFileSync(tmp, `${JSON.stringify(value, null, 2)}\\n`, { encoding: \"utf-8\", mode: 0o600 });\n\trenameSync(tmp, path);\n}\n\nfunction ledgerErrorOf(record: HarnessControlEventWriteResult): string | undefined {\n\tif (record.ok) return undefined;\n\treturn record.error ? `event not recorded: ${record.error}` : \"event not recorded\";\n}\n\n/**\n * Verify a CLI contract and append a tamper-evident audit trail.\n *\n * Algorithm:\n * 1. SHA-256 the manifest, test, and any extra contract files.\n * 2. Record a `started` ledger event (manifest/test hashes + artifact manifest).\n * 3. Run the contract gate.\n * 4. Record a `completed` (gate ok) or `blocked` (gate failed) ledger event.\n * 5. Re-verify the whole hash-chain ledger.\n * 6. Status is `passed` only when the gate passed AND the ledger verifies;\n * otherwise `blocked`.\n * 7. Optionally write a canonical contract-result.json.\n */\nexport async function verifyCliContract(options: VerifyCliContractOptions): Promise<ContractResult> {\n\tconst clock = options.now ?? (() => new Date());\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst operationId = randomUUID();\n\tconst startedAt = clock().toISOString();\n\n\tconst files: ContractFileHash[] = [\n\t\t{ id: \"manifest\", path: options.manifestPath, sha256: hashFile(options.manifestPath) },\n\t\t{ id: \"test\", path: options.testPath, sha256: hashFile(options.testPath) },\n\t\t...(options.extraFiles ?? []).map((file) => ({ id: file.id, path: file.path, sha256: hashFile(file.path) })),\n\t];\n\tconst manifestHash = files[0]?.sha256 ?? \"\";\n\tconst testFileHash = files[1]?.sha256 ?? \"\";\n\tconst artifactRefs = files.map((file) => file.path);\n\n\tconst eventBase: HarnessControlEventOptions = {\n\t\tcwd,\n\t\tlogPath: options.logPath,\n\t\trunId: options.runId,\n\t\toperationId,\n\t\tcorrelationId: operationId,\n\t\tartifactRefs,\n\t};\n\n\tconst startedRecord = recordHarnessControlEvent(\n\t\tCONTRACT_VERIFY_EVENT_KIND,\n\t\t\"started\",\n\t\t{ contractId: options.contractId, contractVersion: options.contractVersion, manifestHash, testFileHash, files },\n\t\t{ ...eventBase, now: clock() },\n\t);\n\n\tconst gate = await options.runGate();\n\tconst completedAt = clock().toISOString();\n\n\tconst completedRecord = recordHarnessControlEvent(\n\t\tCONTRACT_VERIFY_EVENT_KIND,\n\t\tgate.ok ? \"completed\" : \"blocked\",\n\t\t{\n\t\t\tcontractId: options.contractId,\n\t\t\tcontractVersion: options.contractVersion,\n\t\t\tmanifestHash,\n\t\t\ttestFileHash,\n\t\t\tgate,\n\t\t},\n\t\t{ ...eventBase, causationId: startedRecord.event?.eventId ?? null, now: clock() },\n\t);\n\n\tconst ledgerPath = resolveHarnessControlEventLogPath({ cwd, logPath: options.logPath, runId: options.runId });\n\tconst ledgerErrors: string[] = [];\n\tlet ledgerChainOk = true;\n\tif (ledgerPath) {\n\t\tconst verification = verifyHarnessControlLedger(ledgerPath);\n\t\tledgerChainOk = verification.ok;\n\t\tledgerErrors.push(...verification.errors);\n\t}\n\tfor (const record of [startedRecord, completedRecord]) {\n\t\tconst error = ledgerErrorOf(record);\n\t\tif (error) ledgerErrors.push(error);\n\t}\n\tconst ledgerVerified = ledgerChainOk && ledgerErrors.length === 0;\n\n\tconst result: ContractResult = {\n\t\tschemaVersion: CONTRACT_RESULT_SCHEMA_VERSION,\n\t\tcontractId: options.contractId,\n\t\tcontractVersion: options.contractVersion,\n\t\tstatus: gate.ok && ledgerVerified ? \"passed\" : \"blocked\",\n\t\tmanifestHash,\n\t\ttestFileHash,\n\t\tfiles,\n\t\tgate,\n\t\tledger: { path: ledgerPath ?? \"\", verified: ledgerVerified, errors: ledgerErrors },\n\t\tstartedAt,\n\t\tcompletedAt,\n\t};\n\n\tif (options.resultPath) {\n\t\twriteJsonAtomic(resolve(cwd, options.resultPath), result);\n\t}\n\n\treturn result;\n}\n"]}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * `cli.contract.verify` — durable, tamper-evident verification of a CLI contract.
3
+ *
4
+ * Builds on the harness-control hash-chained ledger to record a contract
5
+ * verification as two correlated events (started -> completed/blocked), each
6
+ * carrying the SHA-256 of the contract's manifest and test files. After
7
+ * recording, the whole ledger is re-verified; a contract is only `passed` when
8
+ * both the gate succeeds AND the hash-chain ledger verifies. This lets a release
9
+ * gate detect after-the-fact tampering of either the contract artifacts or the
10
+ * audit ledger itself.
11
+ *
12
+ * Dependency-free: uses node:crypto only (no fast-check/xterm/etc.).
13
+ */
14
+ import { createHash, randomUUID } from "node:crypto";
15
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
16
+ import { dirname, resolve } from "node:path";
17
+ import { recordHarnessControlEvent, resolveHarnessControlEventLogPath, verifyHarnessControlLedger, } from "./harness-control-events.js";
18
+ export const CONTRACT_VERIFY_EVENT_KIND = "cli.contract.verify";
19
+ export const CONTRACT_RESULT_SCHEMA_VERSION = "omk.cli-contract.result.v1";
20
+ function hashFile(path) {
21
+ return `sha256:${createHash("sha256").update(readFileSync(path)).digest("hex")}`;
22
+ }
23
+ function writeJsonAtomic(path, value) {
24
+ mkdirSync(dirname(path), { recursive: true });
25
+ const tmp = `${path}.tmp-${process.pid}-${randomUUID()}`;
26
+ writeFileSync(tmp, `${JSON.stringify(value, null, 2)}\n`, { encoding: "utf-8", mode: 0o600 });
27
+ renameSync(tmp, path);
28
+ }
29
+ function ledgerErrorOf(record) {
30
+ if (record.ok)
31
+ return undefined;
32
+ return record.error ? `event not recorded: ${record.error}` : "event not recorded";
33
+ }
34
+ /**
35
+ * Verify a CLI contract and append a tamper-evident audit trail.
36
+ *
37
+ * Algorithm:
38
+ * 1. SHA-256 the manifest, test, and any extra contract files.
39
+ * 2. Record a `started` ledger event (manifest/test hashes + artifact manifest).
40
+ * 3. Run the contract gate.
41
+ * 4. Record a `completed` (gate ok) or `blocked` (gate failed) ledger event.
42
+ * 5. Re-verify the whole hash-chain ledger.
43
+ * 6. Status is `passed` only when the gate passed AND the ledger verifies;
44
+ * otherwise `blocked`.
45
+ * 7. Optionally write a canonical contract-result.json.
46
+ */
47
+ export async function verifyCliContract(options) {
48
+ const clock = options.now ?? (() => new Date());
49
+ const cwd = options.cwd ?? process.cwd();
50
+ const operationId = randomUUID();
51
+ const startedAt = clock().toISOString();
52
+ const files = [
53
+ { id: "manifest", path: options.manifestPath, sha256: hashFile(options.manifestPath) },
54
+ { id: "test", path: options.testPath, sha256: hashFile(options.testPath) },
55
+ ...(options.extraFiles ?? []).map((file) => ({ id: file.id, path: file.path, sha256: hashFile(file.path) })),
56
+ ];
57
+ const manifestHash = files[0]?.sha256 ?? "";
58
+ const testFileHash = files[1]?.sha256 ?? "";
59
+ const artifactRefs = files.map((file) => file.path);
60
+ const eventBase = {
61
+ cwd,
62
+ logPath: options.logPath,
63
+ runId: options.runId,
64
+ operationId,
65
+ correlationId: operationId,
66
+ artifactRefs,
67
+ };
68
+ const startedRecord = recordHarnessControlEvent(CONTRACT_VERIFY_EVENT_KIND, "started", { contractId: options.contractId, contractVersion: options.contractVersion, manifestHash, testFileHash, files }, { ...eventBase, now: clock() });
69
+ const gate = await options.runGate();
70
+ const completedAt = clock().toISOString();
71
+ const completedRecord = recordHarnessControlEvent(CONTRACT_VERIFY_EVENT_KIND, gate.ok ? "completed" : "blocked", {
72
+ contractId: options.contractId,
73
+ contractVersion: options.contractVersion,
74
+ manifestHash,
75
+ testFileHash,
76
+ gate,
77
+ }, { ...eventBase, causationId: startedRecord.event?.eventId ?? null, now: clock() });
78
+ const ledgerPath = resolveHarnessControlEventLogPath({ cwd, logPath: options.logPath, runId: options.runId });
79
+ const ledgerErrors = [];
80
+ let ledgerChainOk = true;
81
+ if (ledgerPath) {
82
+ const verification = verifyHarnessControlLedger(ledgerPath);
83
+ ledgerChainOk = verification.ok;
84
+ ledgerErrors.push(...verification.errors);
85
+ }
86
+ for (const record of [startedRecord, completedRecord]) {
87
+ const error = ledgerErrorOf(record);
88
+ if (error)
89
+ ledgerErrors.push(error);
90
+ }
91
+ const ledgerVerified = ledgerChainOk && ledgerErrors.length === 0;
92
+ const result = {
93
+ schemaVersion: CONTRACT_RESULT_SCHEMA_VERSION,
94
+ contractId: options.contractId,
95
+ contractVersion: options.contractVersion,
96
+ status: gate.ok && ledgerVerified ? "passed" : "blocked",
97
+ manifestHash,
98
+ testFileHash,
99
+ files,
100
+ gate,
101
+ ledger: { path: ledgerPath ?? "", verified: ledgerVerified, errors: ledgerErrors },
102
+ startedAt,
103
+ completedAt,
104
+ };
105
+ if (options.resultPath) {
106
+ writeJsonAtomic(resolve(cwd, options.resultPath), result);
107
+ }
108
+ return result;
109
+ }
110
+ //# sourceMappingURL=contract-verification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-verification.js","sourceRoot":"","sources":["../../src/core/contract-verification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAGN,yBAAyB,EACzB,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAAqB,CAAC;AAChE,MAAM,CAAC,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAyD3E,SAAS,QAAQ,CA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B;QAC7C,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QACxD,YAAY;QACZ,YAAY;QACZ,KAAK;QACL,IAAI;QACJ,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,IAAI,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE;QAClF,SAAS;QACT,WAAW;KACX,CAAC;IAEF,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * `cli.contract.verify` — durable, tamper-evident verification of a CLI contract.\n *\n * Builds on the harness-control hash-chained ledger to record a contract\n * verification as two correlated events (started -> completed/blocked), each\n * carrying the SHA-256 of the contract's manifest and test files. After\n * recording, the whole ledger is re-verified; a contract is only `passed` when\n * both the gate succeeds AND the hash-chain ledger verifies. This lets a release\n * gate detect after-the-fact tampering of either the contract artifacts or the\n * audit ledger itself.\n *\n * Dependency-free: uses node:crypto only (no fast-check/xterm/etc.).\n */\n\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport {\n\ttype HarnessControlEventOptions,\n\ttype HarnessControlEventWriteResult,\n\trecordHarnessControlEvent,\n\tresolveHarnessControlEventLogPath,\n\tverifyHarnessControlLedger,\n} from \"./harness-control-events.ts\";\n\nexport const CONTRACT_VERIFY_EVENT_KIND = \"cli.contract.verify\";\nexport const CONTRACT_RESULT_SCHEMA_VERSION = \"omk.cli-contract.result.v1\";\n\nexport interface ContractFileRef {\n\treadonly id: string;\n\treadonly path: string;\n}\n\nexport interface ContractFileHash {\n\treadonly id: string;\n\treadonly path: string;\n\t/** `sha256:<hex>` of the file contents. */\n\treadonly sha256: string;\n}\n\nexport type ContractVerificationStatus = \"passed\" | \"blocked\";\n\nexport interface ContractGateResult {\n\treadonly ok: boolean;\n\treadonly details?: string;\n}\n\nexport interface ContractLedgerSummary {\n\treadonly path: string;\n\treadonly verified: boolean;\n\treadonly errors: readonly string[];\n}\n\nexport interface ContractResult {\n\treadonly schemaVersion: typeof CONTRACT_RESULT_SCHEMA_VERSION;\n\treadonly contractId: string;\n\treadonly contractVersion: string;\n\treadonly status: ContractVerificationStatus;\n\treadonly manifestHash: string;\n\treadonly testFileHash: string;\n\treadonly files: readonly ContractFileHash[];\n\treadonly gate: ContractGateResult;\n\treadonly ledger: ContractLedgerSummary;\n\treadonly startedAt: string;\n\treadonly completedAt: string;\n}\n\nexport interface VerifyCliContractOptions {\n\treadonly contractId: string;\n\treadonly contractVersion: string;\n\treadonly manifestPath: string;\n\treadonly testPath: string;\n\treadonly extraFiles?: readonly ContractFileRef[];\n\t/** Runs the actual contract gate (e.g. the vitest contract file). */\n\treadonly runGate: () => ContractGateResult | Promise<ContractGateResult>;\n\treadonly cwd?: string;\n\treadonly logPath?: string;\n\treadonly runId?: string;\n\t/** When set, a JSON contract-result is written here (atomically). */\n\treadonly resultPath?: string;\n\treadonly now?: () => Date;\n}\n\nfunction hashFile(path: string): string {\n\treturn `sha256:${createHash(\"sha256\").update(readFileSync(path)).digest(\"hex\")}`;\n}\n\nfunction writeJsonAtomic(path: string, value: unknown): void {\n\tmkdirSync(dirname(path), { recursive: true });\n\tconst tmp = `${path}.tmp-${process.pid}-${randomUUID()}`;\n\twriteFileSync(tmp, `${JSON.stringify(value, null, 2)}\\n`, { encoding: \"utf-8\", mode: 0o600 });\n\trenameSync(tmp, path);\n}\n\nfunction ledgerErrorOf(record: HarnessControlEventWriteResult): string | undefined {\n\tif (record.ok) return undefined;\n\treturn record.error ? `event not recorded: ${record.error}` : \"event not recorded\";\n}\n\n/**\n * Verify a CLI contract and append a tamper-evident audit trail.\n *\n * Algorithm:\n * 1. SHA-256 the manifest, test, and any extra contract files.\n * 2. Record a `started` ledger event (manifest/test hashes + artifact manifest).\n * 3. Run the contract gate.\n * 4. Record a `completed` (gate ok) or `blocked` (gate failed) ledger event.\n * 5. Re-verify the whole hash-chain ledger.\n * 6. Status is `passed` only when the gate passed AND the ledger verifies;\n * otherwise `blocked`.\n * 7. Optionally write a canonical contract-result.json.\n */\nexport async function verifyCliContract(options: VerifyCliContractOptions): Promise<ContractResult> {\n\tconst clock = options.now ?? (() => new Date());\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst operationId = randomUUID();\n\tconst startedAt = clock().toISOString();\n\n\tconst files: ContractFileHash[] = [\n\t\t{ id: \"manifest\", path: options.manifestPath, sha256: hashFile(options.manifestPath) },\n\t\t{ id: \"test\", path: options.testPath, sha256: hashFile(options.testPath) },\n\t\t...(options.extraFiles ?? []).map((file) => ({ id: file.id, path: file.path, sha256: hashFile(file.path) })),\n\t];\n\tconst manifestHash = files[0]?.sha256 ?? \"\";\n\tconst testFileHash = files[1]?.sha256 ?? \"\";\n\tconst artifactRefs = files.map((file) => file.path);\n\n\tconst eventBase: HarnessControlEventOptions = {\n\t\tcwd,\n\t\tlogPath: options.logPath,\n\t\trunId: options.runId,\n\t\toperationId,\n\t\tcorrelationId: operationId,\n\t\tartifactRefs,\n\t};\n\n\tconst startedRecord = recordHarnessControlEvent(\n\t\tCONTRACT_VERIFY_EVENT_KIND,\n\t\t\"started\",\n\t\t{ contractId: options.contractId, contractVersion: options.contractVersion, manifestHash, testFileHash, files },\n\t\t{ ...eventBase, now: clock() },\n\t);\n\n\tconst gate = await options.runGate();\n\tconst completedAt = clock().toISOString();\n\n\tconst completedRecord = recordHarnessControlEvent(\n\t\tCONTRACT_VERIFY_EVENT_KIND,\n\t\tgate.ok ? \"completed\" : \"blocked\",\n\t\t{\n\t\t\tcontractId: options.contractId,\n\t\t\tcontractVersion: options.contractVersion,\n\t\t\tmanifestHash,\n\t\t\ttestFileHash,\n\t\t\tgate,\n\t\t},\n\t\t{ ...eventBase, causationId: startedRecord.event?.eventId ?? null, now: clock() },\n\t);\n\n\tconst ledgerPath = resolveHarnessControlEventLogPath({ cwd, logPath: options.logPath, runId: options.runId });\n\tconst ledgerErrors: string[] = [];\n\tlet ledgerChainOk = true;\n\tif (ledgerPath) {\n\t\tconst verification = verifyHarnessControlLedger(ledgerPath);\n\t\tledgerChainOk = verification.ok;\n\t\tledgerErrors.push(...verification.errors);\n\t}\n\tfor (const record of [startedRecord, completedRecord]) {\n\t\tconst error = ledgerErrorOf(record);\n\t\tif (error) ledgerErrors.push(error);\n\t}\n\tconst ledgerVerified = ledgerChainOk && ledgerErrors.length === 0;\n\n\tconst result: ContractResult = {\n\t\tschemaVersion: CONTRACT_RESULT_SCHEMA_VERSION,\n\t\tcontractId: options.contractId,\n\t\tcontractVersion: options.contractVersion,\n\t\tstatus: gate.ok && ledgerVerified ? \"passed\" : \"blocked\",\n\t\tmanifestHash,\n\t\ttestFileHash,\n\t\tfiles,\n\t\tgate,\n\t\tledger: { path: ledgerPath ?? \"\", verified: ledgerVerified, errors: ledgerErrors },\n\t\tstartedAt,\n\t\tcompletedAt,\n\t};\n\n\tif (options.resultPath) {\n\t\twriteJsonAtomic(resolve(cwd, options.resultPath), result);\n\t}\n\n\treturn result;\n}\n"]}
@@ -0,0 +1,100 @@
1
+ export declare const EXACT_CACHE_KEY_VERSION = "v1";
2
+ export type JsonPrimitive = string | number | boolean | null;
3
+ export type JsonValue = JsonPrimitive | readonly JsonValue[] | JsonObject;
4
+ export interface JsonObject {
5
+ readonly [key: string]: JsonValue;
6
+ }
7
+ export interface ExactResponseCacheKeyInput {
8
+ readonly provider: string;
9
+ readonly model: string;
10
+ readonly modelRevision: string;
11
+ readonly messages: JsonValue;
12
+ readonly toolSchema: JsonValue;
13
+ readonly temperature: number | null;
14
+ readonly seed: string | number | null;
15
+ readonly reasoningEffort: string | null;
16
+ readonly promptPolicyVersion: string;
17
+ readonly tenantId: string | null;
18
+ readonly userId: string | null;
19
+ readonly repoHead: string;
20
+ readonly worktreeHash: string;
21
+ readonly environmentHash: string;
22
+ }
23
+ export interface ExactResponseCacheKeyMaterial extends JsonObject {
24
+ readonly kind: "exact-response";
25
+ readonly version: typeof EXACT_CACHE_KEY_VERSION;
26
+ readonly provider: string;
27
+ readonly model: string;
28
+ readonly modelRevision: string;
29
+ readonly messagesHash: string;
30
+ readonly toolSchemaHash: string;
31
+ readonly temperature: number | null;
32
+ readonly seed: string | number | null;
33
+ readonly reasoningEffort: string | null;
34
+ readonly promptPolicyVersion: string;
35
+ readonly tenantId: string | null;
36
+ readonly userId: string | null;
37
+ readonly repoHead: string;
38
+ readonly worktreeHash: string;
39
+ readonly environmentHash: string;
40
+ }
41
+ export interface ExactResponseCacheKey {
42
+ readonly kind: "exact-response";
43
+ readonly version: typeof EXACT_CACHE_KEY_VERSION;
44
+ readonly key: string;
45
+ readonly hash: string;
46
+ readonly messagesHash: string;
47
+ readonly toolSchemaHash: string;
48
+ readonly material: ExactResponseCacheKeyMaterial;
49
+ }
50
+ export interface ToolResultCacheKeyInput {
51
+ readonly toolName: string;
52
+ readonly args: JsonValue;
53
+ readonly repoHead: string;
54
+ readonly worktreeHash: string;
55
+ readonly toolVersion: string;
56
+ readonly environmentHash: string;
57
+ }
58
+ export interface ToolResultCacheKeyMaterial extends JsonObject {
59
+ readonly kind: "tool-result";
60
+ readonly version: typeof EXACT_CACHE_KEY_VERSION;
61
+ readonly toolName: string;
62
+ readonly canonicalArgs: string;
63
+ readonly repoHead: string;
64
+ readonly worktreeHash: string;
65
+ readonly toolVersion: string;
66
+ readonly environmentHash: string;
67
+ }
68
+ export interface ToolResultCacheKey {
69
+ readonly kind: "tool-result";
70
+ readonly version: typeof EXACT_CACHE_KEY_VERSION;
71
+ readonly key: string;
72
+ readonly hash: string;
73
+ readonly canonicalArgs: string;
74
+ readonly argsHash: string;
75
+ readonly material: ToolResultCacheKeyMaterial;
76
+ }
77
+ export type ToolResultCacheStatus = "success" | "error";
78
+ export interface ToolResultCachePolicyCandidate {
79
+ readonly toolName: string;
80
+ readonly status: ToolResultCacheStatus;
81
+ readonly mutates?: boolean;
82
+ readonly secretMarked?: boolean;
83
+ readonly bashPure?: boolean;
84
+ }
85
+ export type ToolResultCachePolicyReason = "eligible" | "tool.mutating" | "result.error" | "result.secret" | "bash.impure";
86
+ export interface ToolResultCachePolicyDecision {
87
+ readonly eligible: boolean;
88
+ readonly reason: ToolResultCachePolicyReason;
89
+ readonly detail?: string;
90
+ }
91
+ export declare const MUTATING_TOOL_NAME_TERMS: readonly ["write", "edit", "patch", "delete", "remove", "move", "rename", "commit", "merge", "rebase", "checkout", "push", "deploy", "publish", "install", "execute", "exec", "run"];
92
+ export declare function canonicalizeJson(value: JsonValue): string;
93
+ export declare function hashCanonicalJson(value: JsonValue): string;
94
+ export declare function createExactResponseCacheKey(input: ExactResponseCacheKeyInput): ExactResponseCacheKey;
95
+ export declare function createToolResultCacheKey(input: ToolResultCacheKeyInput): ToolResultCacheKey;
96
+ export declare function classifyToolResultCacheEligibility(candidate: ToolResultCachePolicyCandidate): ToolResultCachePolicyDecision;
97
+ export declare function canCacheToolResult(candidate: ToolResultCachePolicyCandidate): boolean;
98
+ export declare function isKnownMutatingToolName(toolName: string): boolean;
99
+ export declare function isBashToolName(toolName: string): boolean;
100
+ //# sourceMappingURL=exact-cache-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact-cache-policy.d.ts","sourceRoot":"","sources":["../../src/core/exact-cache-policy.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,SAAS,EAAE,GAAG,UAAU,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CAAC;AAEX,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAuBzD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAE1D;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,0BAA0B,GAAG,qBAAqB,CA+BpG;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,uBAAuB,GAAG,kBAAkB,CAuB3F;AAED,wBAAgB,kCAAkC,CACjD,SAAS,EAAE,8BAA8B,GACvC,6BAA6B,CAmB/B;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,8BAA8B,GAAG,OAAO,CAErF;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGjE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD","sourcesContent":["import { createHash } from \"node:crypto\";\n\nexport const EXACT_CACHE_KEY_VERSION = \"v1\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | readonly JsonValue[] | JsonObject;\n\nexport interface JsonObject {\n\treadonly [key: string]: JsonValue;\n}\n\nexport interface ExactResponseCacheKeyInput {\n\treadonly provider: string;\n\treadonly model: string;\n\treadonly modelRevision: string;\n\treadonly messages: JsonValue;\n\treadonly toolSchema: JsonValue;\n\treadonly temperature: number | null;\n\treadonly seed: string | number | null;\n\treadonly reasoningEffort: string | null;\n\treadonly promptPolicyVersion: string;\n\treadonly tenantId: string | null;\n\treadonly userId: string | null;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ExactResponseCacheKeyMaterial extends JsonObject {\n\treadonly kind: \"exact-response\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly provider: string;\n\treadonly model: string;\n\treadonly modelRevision: string;\n\treadonly messagesHash: string;\n\treadonly toolSchemaHash: string;\n\treadonly temperature: number | null;\n\treadonly seed: string | number | null;\n\treadonly reasoningEffort: string | null;\n\treadonly promptPolicyVersion: string;\n\treadonly tenantId: string | null;\n\treadonly userId: string | null;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ExactResponseCacheKey {\n\treadonly kind: \"exact-response\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly key: string;\n\treadonly hash: string;\n\treadonly messagesHash: string;\n\treadonly toolSchemaHash: string;\n\treadonly material: ExactResponseCacheKeyMaterial;\n}\n\nexport interface ToolResultCacheKeyInput {\n\treadonly toolName: string;\n\treadonly args: JsonValue;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly toolVersion: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ToolResultCacheKeyMaterial extends JsonObject {\n\treadonly kind: \"tool-result\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly toolName: string;\n\treadonly canonicalArgs: string;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly toolVersion: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ToolResultCacheKey {\n\treadonly kind: \"tool-result\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly key: string;\n\treadonly hash: string;\n\treadonly canonicalArgs: string;\n\treadonly argsHash: string;\n\treadonly material: ToolResultCacheKeyMaterial;\n}\n\nexport type ToolResultCacheStatus = \"success\" | \"error\";\n\nexport interface ToolResultCachePolicyCandidate {\n\treadonly toolName: string;\n\treadonly status: ToolResultCacheStatus;\n\treadonly mutates?: boolean;\n\treadonly secretMarked?: boolean;\n\treadonly bashPure?: boolean;\n}\n\nexport type ToolResultCachePolicyReason =\n\t| \"eligible\"\n\t| \"tool.mutating\"\n\t| \"result.error\"\n\t| \"result.secret\"\n\t| \"bash.impure\";\n\nexport interface ToolResultCachePolicyDecision {\n\treadonly eligible: boolean;\n\treadonly reason: ToolResultCachePolicyReason;\n\treadonly detail?: string;\n}\n\nexport const MUTATING_TOOL_NAME_TERMS = [\n\t\"write\",\n\t\"edit\",\n\t\"patch\",\n\t\"delete\",\n\t\"remove\",\n\t\"move\",\n\t\"rename\",\n\t\"commit\",\n\t\"merge\",\n\t\"rebase\",\n\t\"checkout\",\n\t\"push\",\n\t\"deploy\",\n\t\"publish\",\n\t\"install\",\n\t\"execute\",\n\t\"exec\",\n\t\"run\",\n] as const;\n\nexport function canonicalizeJson(value: JsonValue): string {\n\tif (value === null) {\n\t\treturn \"null\";\n\t}\n\n\tswitch (typeof value) {\n\t\tcase \"string\":\n\t\tcase \"boolean\":\n\t\t\treturn stringifyCanonicalPrimitive(value);\n\t\tcase \"number\":\n\t\t\tif (!Number.isFinite(value)) {\n\t\t\t\tthrow new TypeError(\"Canonical JSON only supports finite numbers\");\n\t\t\t}\n\t\t\treturn stringifyCanonicalPrimitive(value);\n\t\tcase \"object\":\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\treturn `[${value.map((item) => canonicalizeJson(item)).join(\",\")}]`;\n\t\t\t}\n\t\t\tassertPlainJsonObject(value);\n\t\t\treturn canonicalizeObject(value);\n\t\tdefault:\n\t\t\tthrow new TypeError(`Unsupported JSON value type: ${typeof value}`);\n\t}\n}\n\nexport function hashCanonicalJson(value: JsonValue): string {\n\treturn sha256Hex(canonicalizeJson(value));\n}\n\nexport function createExactResponseCacheKey(input: ExactResponseCacheKeyInput): ExactResponseCacheKey {\n\tconst messagesHash = hashCanonicalJson(input.messages);\n\tconst toolSchemaHash = hashCanonicalJson(input.toolSchema);\n\tconst material: ExactResponseCacheKeyMaterial = {\n\t\tkind: \"exact-response\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\tprovider: requireNonEmptyString(\"provider\", input.provider),\n\t\tmodel: requireNonEmptyString(\"model\", input.model),\n\t\tmodelRevision: requireNonEmptyString(\"modelRevision\", input.modelRevision),\n\t\tmessagesHash,\n\t\ttoolSchemaHash,\n\t\ttemperature: input.temperature,\n\t\tseed: input.seed,\n\t\treasoningEffort: normalizeNullableString(\"reasoningEffort\", input.reasoningEffort),\n\t\tpromptPolicyVersion: requireNonEmptyString(\"promptPolicyVersion\", input.promptPolicyVersion),\n\t\ttenantId: normalizeNullableString(\"tenantId\", input.tenantId),\n\t\tuserId: normalizeNullableString(\"userId\", input.userId),\n\t\trepoHead: requireNonEmptyString(\"repoHead\", input.repoHead),\n\t\tworktreeHash: requireNonEmptyString(\"worktreeHash\", input.worktreeHash),\n\t\tenvironmentHash: requireNonEmptyString(\"environmentHash\", input.environmentHash),\n\t};\n\tconst hash = hashCanonicalJson(material);\n\treturn {\n\t\tkind: \"exact-response\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\tkey: `exact-response:${EXACT_CACHE_KEY_VERSION}:${hash}`,\n\t\thash,\n\t\tmessagesHash,\n\t\ttoolSchemaHash,\n\t\tmaterial,\n\t};\n}\n\nexport function createToolResultCacheKey(input: ToolResultCacheKeyInput): ToolResultCacheKey {\n\tconst canonicalArgs = canonicalizeJson(input.args);\n\tconst argsHash = sha256Hex(canonicalArgs);\n\tconst material: ToolResultCacheKeyMaterial = {\n\t\tkind: \"tool-result\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\ttoolName: requireNonEmptyString(\"toolName\", input.toolName),\n\t\tcanonicalArgs,\n\t\trepoHead: requireNonEmptyString(\"repoHead\", input.repoHead),\n\t\tworktreeHash: requireNonEmptyString(\"worktreeHash\", input.worktreeHash),\n\t\ttoolVersion: requireNonEmptyString(\"toolVersion\", input.toolVersion),\n\t\tenvironmentHash: requireNonEmptyString(\"environmentHash\", input.environmentHash),\n\t};\n\tconst hash = hashCanonicalJson(material);\n\treturn {\n\t\tkind: \"tool-result\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\tkey: `tool-result:${EXACT_CACHE_KEY_VERSION}:${hash}`,\n\t\thash,\n\t\tcanonicalArgs,\n\t\targsHash,\n\t\tmaterial,\n\t};\n}\n\nexport function classifyToolResultCacheEligibility(\n\tcandidate: ToolResultCachePolicyCandidate,\n): ToolResultCachePolicyDecision {\n\tconst toolName = requireNonEmptyString(\"toolName\", candidate.toolName);\n\tif (candidate.mutates === true || isKnownMutatingToolName(toolName)) {\n\t\treturn denyToolResultCache(\"tool.mutating\", toolName);\n\t}\n\n\tif (candidate.status !== \"success\") {\n\t\treturn denyToolResultCache(\"result.error\", candidate.status);\n\t}\n\n\tif (candidate.secretMarked === true) {\n\t\treturn denyToolResultCache(\"result.secret\", toolName);\n\t}\n\n\tif (isBashToolName(toolName) && candidate.bashPure !== true) {\n\t\treturn denyToolResultCache(\"bash.impure\", toolName);\n\t}\n\n\treturn { eligible: true, reason: \"eligible\" };\n}\n\nexport function canCacheToolResult(candidate: ToolResultCachePolicyCandidate): boolean {\n\treturn classifyToolResultCacheEligibility(candidate).eligible;\n}\n\nexport function isKnownMutatingToolName(toolName: string): boolean {\n\tconst terms = splitToolName(toolName);\n\treturn MUTATING_TOOL_NAME_TERMS.some((term) => terms.includes(term));\n}\n\nexport function isBashToolName(toolName: string): boolean {\n\treturn splitToolName(toolName).includes(\"bash\");\n}\n\nfunction canonicalizeObject(value: JsonObject): string {\n\treturn `{${Object.keys(value)\n\t\t.sort()\n\t\t.map((key) => `${stringifyCanonicalPrimitive(key)}:${canonicalizeJson(value[key])}`)\n\t\t.join(\",\")}}`;\n}\n\nfunction stringifyCanonicalPrimitive(value: JsonPrimitive): string {\n\tconst encoded = JSON.stringify(value);\n\tif (encoded === undefined) {\n\t\tthrow new TypeError(\"Unsupported JSON primitive\");\n\t}\n\treturn encoded;\n}\n\nfunction assertPlainJsonObject(value: object): asserts value is JsonObject {\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (prototype !== Object.prototype && prototype !== null) {\n\t\tthrow new TypeError(\"Canonical JSON only supports plain objects and arrays\");\n\t}\n}\n\nfunction sha256Hex(value: string): string {\n\treturn createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n}\n\nfunction requireNonEmptyString(name: string, value: string): string {\n\tif (value.trim().length === 0) {\n\t\tthrow new TypeError(`${name} must be a non-empty string`);\n\t}\n\treturn value;\n}\n\nfunction normalizeNullableString(name: string, value: string | null): string | null {\n\tif (value === null) {\n\t\treturn null;\n\t}\n\treturn requireNonEmptyString(name, value);\n}\n\nfunction splitToolName(toolName: string): readonly string[] {\n\treturn toolName\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.split(/[^a-z0-9]+/g)\n\t\t.filter((term) => term.length > 0);\n}\n\nfunction denyToolResultCache(\n\treason: Exclude<ToolResultCachePolicyReason, \"eligible\">,\n\tdetail: string,\n): ToolResultCachePolicyDecision {\n\treturn { eligible: false, reason, detail };\n}\n"]}
@@ -0,0 +1,175 @@
1
+ import { createHash } from "node:crypto";
2
+ export const EXACT_CACHE_KEY_VERSION = "v1";
3
+ export const MUTATING_TOOL_NAME_TERMS = [
4
+ "write",
5
+ "edit",
6
+ "patch",
7
+ "delete",
8
+ "remove",
9
+ "move",
10
+ "rename",
11
+ "commit",
12
+ "merge",
13
+ "rebase",
14
+ "checkout",
15
+ "push",
16
+ "deploy",
17
+ "publish",
18
+ "install",
19
+ "execute",
20
+ "exec",
21
+ "run",
22
+ ];
23
+ export function canonicalizeJson(value) {
24
+ if (value === null) {
25
+ return "null";
26
+ }
27
+ switch (typeof value) {
28
+ case "string":
29
+ case "boolean":
30
+ return stringifyCanonicalPrimitive(value);
31
+ case "number":
32
+ if (!Number.isFinite(value)) {
33
+ throw new TypeError("Canonical JSON only supports finite numbers");
34
+ }
35
+ return stringifyCanonicalPrimitive(value);
36
+ case "object":
37
+ if (Array.isArray(value)) {
38
+ return `[${value.map((item) => canonicalizeJson(item)).join(",")}]`;
39
+ }
40
+ assertPlainJsonObject(value);
41
+ return canonicalizeObject(value);
42
+ default:
43
+ throw new TypeError(`Unsupported JSON value type: ${typeof value}`);
44
+ }
45
+ }
46
+ export function hashCanonicalJson(value) {
47
+ return sha256Hex(canonicalizeJson(value));
48
+ }
49
+ export function createExactResponseCacheKey(input) {
50
+ const messagesHash = hashCanonicalJson(input.messages);
51
+ const toolSchemaHash = hashCanonicalJson(input.toolSchema);
52
+ const material = {
53
+ kind: "exact-response",
54
+ version: EXACT_CACHE_KEY_VERSION,
55
+ provider: requireNonEmptyString("provider", input.provider),
56
+ model: requireNonEmptyString("model", input.model),
57
+ modelRevision: requireNonEmptyString("modelRevision", input.modelRevision),
58
+ messagesHash,
59
+ toolSchemaHash,
60
+ temperature: input.temperature,
61
+ seed: input.seed,
62
+ reasoningEffort: normalizeNullableString("reasoningEffort", input.reasoningEffort),
63
+ promptPolicyVersion: requireNonEmptyString("promptPolicyVersion", input.promptPolicyVersion),
64
+ tenantId: normalizeNullableString("tenantId", input.tenantId),
65
+ userId: normalizeNullableString("userId", input.userId),
66
+ repoHead: requireNonEmptyString("repoHead", input.repoHead),
67
+ worktreeHash: requireNonEmptyString("worktreeHash", input.worktreeHash),
68
+ environmentHash: requireNonEmptyString("environmentHash", input.environmentHash),
69
+ };
70
+ const hash = hashCanonicalJson(material);
71
+ return {
72
+ kind: "exact-response",
73
+ version: EXACT_CACHE_KEY_VERSION,
74
+ key: `exact-response:${EXACT_CACHE_KEY_VERSION}:${hash}`,
75
+ hash,
76
+ messagesHash,
77
+ toolSchemaHash,
78
+ material,
79
+ };
80
+ }
81
+ export function createToolResultCacheKey(input) {
82
+ const canonicalArgs = canonicalizeJson(input.args);
83
+ const argsHash = sha256Hex(canonicalArgs);
84
+ const material = {
85
+ kind: "tool-result",
86
+ version: EXACT_CACHE_KEY_VERSION,
87
+ toolName: requireNonEmptyString("toolName", input.toolName),
88
+ canonicalArgs,
89
+ repoHead: requireNonEmptyString("repoHead", input.repoHead),
90
+ worktreeHash: requireNonEmptyString("worktreeHash", input.worktreeHash),
91
+ toolVersion: requireNonEmptyString("toolVersion", input.toolVersion),
92
+ environmentHash: requireNonEmptyString("environmentHash", input.environmentHash),
93
+ };
94
+ const hash = hashCanonicalJson(material);
95
+ return {
96
+ kind: "tool-result",
97
+ version: EXACT_CACHE_KEY_VERSION,
98
+ key: `tool-result:${EXACT_CACHE_KEY_VERSION}:${hash}`,
99
+ hash,
100
+ canonicalArgs,
101
+ argsHash,
102
+ material,
103
+ };
104
+ }
105
+ export function classifyToolResultCacheEligibility(candidate) {
106
+ const toolName = requireNonEmptyString("toolName", candidate.toolName);
107
+ if (candidate.mutates === true || isKnownMutatingToolName(toolName)) {
108
+ return denyToolResultCache("tool.mutating", toolName);
109
+ }
110
+ if (candidate.status !== "success") {
111
+ return denyToolResultCache("result.error", candidate.status);
112
+ }
113
+ if (candidate.secretMarked === true) {
114
+ return denyToolResultCache("result.secret", toolName);
115
+ }
116
+ if (isBashToolName(toolName) && candidate.bashPure !== true) {
117
+ return denyToolResultCache("bash.impure", toolName);
118
+ }
119
+ return { eligible: true, reason: "eligible" };
120
+ }
121
+ export function canCacheToolResult(candidate) {
122
+ return classifyToolResultCacheEligibility(candidate).eligible;
123
+ }
124
+ export function isKnownMutatingToolName(toolName) {
125
+ const terms = splitToolName(toolName);
126
+ return MUTATING_TOOL_NAME_TERMS.some((term) => terms.includes(term));
127
+ }
128
+ export function isBashToolName(toolName) {
129
+ return splitToolName(toolName).includes("bash");
130
+ }
131
+ function canonicalizeObject(value) {
132
+ return `{${Object.keys(value)
133
+ .sort()
134
+ .map((key) => `${stringifyCanonicalPrimitive(key)}:${canonicalizeJson(value[key])}`)
135
+ .join(",")}}`;
136
+ }
137
+ function stringifyCanonicalPrimitive(value) {
138
+ const encoded = JSON.stringify(value);
139
+ if (encoded === undefined) {
140
+ throw new TypeError("Unsupported JSON primitive");
141
+ }
142
+ return encoded;
143
+ }
144
+ function assertPlainJsonObject(value) {
145
+ const prototype = Object.getPrototypeOf(value);
146
+ if (prototype !== Object.prototype && prototype !== null) {
147
+ throw new TypeError("Canonical JSON only supports plain objects and arrays");
148
+ }
149
+ }
150
+ function sha256Hex(value) {
151
+ return createHash("sha256").update(value, "utf8").digest("hex");
152
+ }
153
+ function requireNonEmptyString(name, value) {
154
+ if (value.trim().length === 0) {
155
+ throw new TypeError(`${name} must be a non-empty string`);
156
+ }
157
+ return value;
158
+ }
159
+ function normalizeNullableString(name, value) {
160
+ if (value === null) {
161
+ return null;
162
+ }
163
+ return requireNonEmptyString(name, value);
164
+ }
165
+ function splitToolName(toolName) {
166
+ return toolName
167
+ .trim()
168
+ .toLowerCase()
169
+ .split(/[^a-z0-9]+/g)
170
+ .filter((term) => term.length > 0);
171
+ }
172
+ function denyToolResultCache(reason, detail) {
173
+ return { eligible: false, reason, detail };
174
+ }
175
+ //# sourceMappingURL=exact-cache-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact-cache-policy.js","sourceRoot":"","sources":["../../src/core/exact-cache-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AA4G5C,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,OAAO;IACP,MAAM;IACN,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,UAAU;IACV,MAAM;IACN,QAAQ;IACR,SAAS;IACT,SAAS;IACT,SAAS;IACT,MAAM;IACN,KAAK;CACI,CAAC;AAEX,MAAM,UAAU,gBAAgB,CAAC,KAAgB,EAAU;IAC1D,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC;IACf,CAAC;IAED,QAAQ,OAAO,KAAK,EAAE,CAAC;QACtB,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACb,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAC3C,KAAK,QAAQ;YACZ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;YACpE,CAAC;YACD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,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAAA,CAChE;AAED,SAAS,qBAAqB,CAAC,IAAY,EAAE,KAAa,EAAU;IACnE,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,6BAA6B,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC;AAAA,CACb;AAED,SAAS,uBAAuB,CAAC,IAAY,EAAE,KAAoB,EAAiB;IACnF,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAAA,CAC1C;AAED,SAAS,aAAa,CAAC,QAAgB,EAAqB;IAC3D,OAAO,QAAQ;SACb,IAAI,EAAE;SACN,WAAW,EAAE;SACb,KAAK,CAAC,aAAa,CAAC;SACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAAA,CACpC;AAED,SAAS,mBAAmB,CAC3B,MAAwD,EACxD,MAAc,EACkB;IAChC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAAA,CAC3C","sourcesContent":["import { createHash } from \"node:crypto\";\n\nexport const EXACT_CACHE_KEY_VERSION = \"v1\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | readonly JsonValue[] | JsonObject;\n\nexport interface JsonObject {\n\treadonly [key: string]: JsonValue;\n}\n\nexport interface ExactResponseCacheKeyInput {\n\treadonly provider: string;\n\treadonly model: string;\n\treadonly modelRevision: string;\n\treadonly messages: JsonValue;\n\treadonly toolSchema: JsonValue;\n\treadonly temperature: number | null;\n\treadonly seed: string | number | null;\n\treadonly reasoningEffort: string | null;\n\treadonly promptPolicyVersion: string;\n\treadonly tenantId: string | null;\n\treadonly userId: string | null;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ExactResponseCacheKeyMaterial extends JsonObject {\n\treadonly kind: \"exact-response\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly provider: string;\n\treadonly model: string;\n\treadonly modelRevision: string;\n\treadonly messagesHash: string;\n\treadonly toolSchemaHash: string;\n\treadonly temperature: number | null;\n\treadonly seed: string | number | null;\n\treadonly reasoningEffort: string | null;\n\treadonly promptPolicyVersion: string;\n\treadonly tenantId: string | null;\n\treadonly userId: string | null;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ExactResponseCacheKey {\n\treadonly kind: \"exact-response\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly key: string;\n\treadonly hash: string;\n\treadonly messagesHash: string;\n\treadonly toolSchemaHash: string;\n\treadonly material: ExactResponseCacheKeyMaterial;\n}\n\nexport interface ToolResultCacheKeyInput {\n\treadonly toolName: string;\n\treadonly args: JsonValue;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly toolVersion: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ToolResultCacheKeyMaterial extends JsonObject {\n\treadonly kind: \"tool-result\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly toolName: string;\n\treadonly canonicalArgs: string;\n\treadonly repoHead: string;\n\treadonly worktreeHash: string;\n\treadonly toolVersion: string;\n\treadonly environmentHash: string;\n}\n\nexport interface ToolResultCacheKey {\n\treadonly kind: \"tool-result\";\n\treadonly version: typeof EXACT_CACHE_KEY_VERSION;\n\treadonly key: string;\n\treadonly hash: string;\n\treadonly canonicalArgs: string;\n\treadonly argsHash: string;\n\treadonly material: ToolResultCacheKeyMaterial;\n}\n\nexport type ToolResultCacheStatus = \"success\" | \"error\";\n\nexport interface ToolResultCachePolicyCandidate {\n\treadonly toolName: string;\n\treadonly status: ToolResultCacheStatus;\n\treadonly mutates?: boolean;\n\treadonly secretMarked?: boolean;\n\treadonly bashPure?: boolean;\n}\n\nexport type ToolResultCachePolicyReason =\n\t| \"eligible\"\n\t| \"tool.mutating\"\n\t| \"result.error\"\n\t| \"result.secret\"\n\t| \"bash.impure\";\n\nexport interface ToolResultCachePolicyDecision {\n\treadonly eligible: boolean;\n\treadonly reason: ToolResultCachePolicyReason;\n\treadonly detail?: string;\n}\n\nexport const MUTATING_TOOL_NAME_TERMS = [\n\t\"write\",\n\t\"edit\",\n\t\"patch\",\n\t\"delete\",\n\t\"remove\",\n\t\"move\",\n\t\"rename\",\n\t\"commit\",\n\t\"merge\",\n\t\"rebase\",\n\t\"checkout\",\n\t\"push\",\n\t\"deploy\",\n\t\"publish\",\n\t\"install\",\n\t\"execute\",\n\t\"exec\",\n\t\"run\",\n] as const;\n\nexport function canonicalizeJson(value: JsonValue): string {\n\tif (value === null) {\n\t\treturn \"null\";\n\t}\n\n\tswitch (typeof value) {\n\t\tcase \"string\":\n\t\tcase \"boolean\":\n\t\t\treturn stringifyCanonicalPrimitive(value);\n\t\tcase \"number\":\n\t\t\tif (!Number.isFinite(value)) {\n\t\t\t\tthrow new TypeError(\"Canonical JSON only supports finite numbers\");\n\t\t\t}\n\t\t\treturn stringifyCanonicalPrimitive(value);\n\t\tcase \"object\":\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\treturn `[${value.map((item) => canonicalizeJson(item)).join(\",\")}]`;\n\t\t\t}\n\t\t\tassertPlainJsonObject(value);\n\t\t\treturn canonicalizeObject(value);\n\t\tdefault:\n\t\t\tthrow new TypeError(`Unsupported JSON value type: ${typeof value}`);\n\t}\n}\n\nexport function hashCanonicalJson(value: JsonValue): string {\n\treturn sha256Hex(canonicalizeJson(value));\n}\n\nexport function createExactResponseCacheKey(input: ExactResponseCacheKeyInput): ExactResponseCacheKey {\n\tconst messagesHash = hashCanonicalJson(input.messages);\n\tconst toolSchemaHash = hashCanonicalJson(input.toolSchema);\n\tconst material: ExactResponseCacheKeyMaterial = {\n\t\tkind: \"exact-response\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\tprovider: requireNonEmptyString(\"provider\", input.provider),\n\t\tmodel: requireNonEmptyString(\"model\", input.model),\n\t\tmodelRevision: requireNonEmptyString(\"modelRevision\", input.modelRevision),\n\t\tmessagesHash,\n\t\ttoolSchemaHash,\n\t\ttemperature: input.temperature,\n\t\tseed: input.seed,\n\t\treasoningEffort: normalizeNullableString(\"reasoningEffort\", input.reasoningEffort),\n\t\tpromptPolicyVersion: requireNonEmptyString(\"promptPolicyVersion\", input.promptPolicyVersion),\n\t\ttenantId: normalizeNullableString(\"tenantId\", input.tenantId),\n\t\tuserId: normalizeNullableString(\"userId\", input.userId),\n\t\trepoHead: requireNonEmptyString(\"repoHead\", input.repoHead),\n\t\tworktreeHash: requireNonEmptyString(\"worktreeHash\", input.worktreeHash),\n\t\tenvironmentHash: requireNonEmptyString(\"environmentHash\", input.environmentHash),\n\t};\n\tconst hash = hashCanonicalJson(material);\n\treturn {\n\t\tkind: \"exact-response\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\tkey: `exact-response:${EXACT_CACHE_KEY_VERSION}:${hash}`,\n\t\thash,\n\t\tmessagesHash,\n\t\ttoolSchemaHash,\n\t\tmaterial,\n\t};\n}\n\nexport function createToolResultCacheKey(input: ToolResultCacheKeyInput): ToolResultCacheKey {\n\tconst canonicalArgs = canonicalizeJson(input.args);\n\tconst argsHash = sha256Hex(canonicalArgs);\n\tconst material: ToolResultCacheKeyMaterial = {\n\t\tkind: \"tool-result\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\ttoolName: requireNonEmptyString(\"toolName\", input.toolName),\n\t\tcanonicalArgs,\n\t\trepoHead: requireNonEmptyString(\"repoHead\", input.repoHead),\n\t\tworktreeHash: requireNonEmptyString(\"worktreeHash\", input.worktreeHash),\n\t\ttoolVersion: requireNonEmptyString(\"toolVersion\", input.toolVersion),\n\t\tenvironmentHash: requireNonEmptyString(\"environmentHash\", input.environmentHash),\n\t};\n\tconst hash = hashCanonicalJson(material);\n\treturn {\n\t\tkind: \"tool-result\",\n\t\tversion: EXACT_CACHE_KEY_VERSION,\n\t\tkey: `tool-result:${EXACT_CACHE_KEY_VERSION}:${hash}`,\n\t\thash,\n\t\tcanonicalArgs,\n\t\targsHash,\n\t\tmaterial,\n\t};\n}\n\nexport function classifyToolResultCacheEligibility(\n\tcandidate: ToolResultCachePolicyCandidate,\n): ToolResultCachePolicyDecision {\n\tconst toolName = requireNonEmptyString(\"toolName\", candidate.toolName);\n\tif (candidate.mutates === true || isKnownMutatingToolName(toolName)) {\n\t\treturn denyToolResultCache(\"tool.mutating\", toolName);\n\t}\n\n\tif (candidate.status !== \"success\") {\n\t\treturn denyToolResultCache(\"result.error\", candidate.status);\n\t}\n\n\tif (candidate.secretMarked === true) {\n\t\treturn denyToolResultCache(\"result.secret\", toolName);\n\t}\n\n\tif (isBashToolName(toolName) && candidate.bashPure !== true) {\n\t\treturn denyToolResultCache(\"bash.impure\", toolName);\n\t}\n\n\treturn { eligible: true, reason: \"eligible\" };\n}\n\nexport function canCacheToolResult(candidate: ToolResultCachePolicyCandidate): boolean {\n\treturn classifyToolResultCacheEligibility(candidate).eligible;\n}\n\nexport function isKnownMutatingToolName(toolName: string): boolean {\n\tconst terms = splitToolName(toolName);\n\treturn MUTATING_TOOL_NAME_TERMS.some((term) => terms.includes(term));\n}\n\nexport function isBashToolName(toolName: string): boolean {\n\treturn splitToolName(toolName).includes(\"bash\");\n}\n\nfunction canonicalizeObject(value: JsonObject): string {\n\treturn `{${Object.keys(value)\n\t\t.sort()\n\t\t.map((key) => `${stringifyCanonicalPrimitive(key)}:${canonicalizeJson(value[key])}`)\n\t\t.join(\",\")}}`;\n}\n\nfunction stringifyCanonicalPrimitive(value: JsonPrimitive): string {\n\tconst encoded = JSON.stringify(value);\n\tif (encoded === undefined) {\n\t\tthrow new TypeError(\"Unsupported JSON primitive\");\n\t}\n\treturn encoded;\n}\n\nfunction assertPlainJsonObject(value: object): asserts value is JsonObject {\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (prototype !== Object.prototype && prototype !== null) {\n\t\tthrow new TypeError(\"Canonical JSON only supports plain objects and arrays\");\n\t}\n}\n\nfunction sha256Hex(value: string): string {\n\treturn createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n}\n\nfunction requireNonEmptyString(name: string, value: string): string {\n\tif (value.trim().length === 0) {\n\t\tthrow new TypeError(`${name} must be a non-empty string`);\n\t}\n\treturn value;\n}\n\nfunction normalizeNullableString(name: string, value: string | null): string | null {\n\tif (value === null) {\n\t\treturn null;\n\t}\n\treturn requireNonEmptyString(name, value);\n}\n\nfunction splitToolName(toolName: string): readonly string[] {\n\treturn toolName\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.split(/[^a-z0-9]+/g)\n\t\t.filter((term) => term.length > 0);\n}\n\nfunction denyToolResultCache(\n\treason: Exclude<ToolResultCachePolicyReason, \"eligible\">,\n\tdetail: string,\n): ToolResultCachePolicyDecision {\n\treturn { eligible: false, reason, detail };\n}\n"]}
@@ -11,6 +11,8 @@ export interface ExecOptions {
11
11
  timeout?: number;
12
12
  /** Working directory */
13
13
  cwd?: string;
14
+ /** Environment variables for the spawned process. Defaults to the parent environment. */
15
+ env?: NodeJS.ProcessEnv;
14
16
  }
15
17
  /**
16
18
  * Result of executing a shell command.
@@ -1 +1 @@
1
- {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/core/exec.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,wCAAwC;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAyErB","sourcesContent":["/**\n * Shared command execution utilities for extensions and custom tools.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { waitForChildProcess } from \"../utils/child-process.ts\";\n\n/**\n * Options for executing shell commands.\n */\nexport interface ExecOptions {\n\t/** AbortSignal to cancel the command */\n\tsignal?: AbortSignal;\n\t/** Timeout in milliseconds */\n\ttimeout?: number;\n\t/** Working directory */\n\tcwd?: string;\n}\n\n/**\n * Result of executing a shell command.\n */\nexport interface ExecResult {\n\tstdout: string;\n\tstderr: string;\n\tcode: number;\n\tkilled: boolean;\n}\n\n/**\n * Execute a shell command and return stdout/stderr/code.\n * Supports timeout and abort signal.\n */\nexport async function execCommand(\n\tcommand: string,\n\targs: string[],\n\tcwd: string,\n\toptions?: ExecOptions,\n): Promise<ExecResult> {\n\treturn new Promise((resolve) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd,\n\t\t\tshell: false,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tlet killed = false;\n\t\tlet timeoutId: NodeJS.Timeout | undefined;\n\t\tlet forceKillTimeoutId: NodeJS.Timeout | undefined;\n\n\t\tconst killProcess = () => {\n\t\t\tif (!killed) {\n\t\t\t\tkilled = true;\n\t\t\t\tproc.kill(\"SIGTERM\");\n\t\t\t\t// Force kill after 5 seconds if SIGTERM doesn't work.\n\t\t\t\t// Note: proc.killed only means a signal was successfully SENT, so we\n\t\t\t\t// must check whether the process actually exited instead.\n\t\t\t\tforceKillTimeoutId = setTimeout(() => {\n\t\t\t\t\tif (proc.exitCode === null && proc.signalCode === null) {\n\t\t\t\t\t\tproc.kill(\"SIGKILL\");\n\t\t\t\t\t}\n\t\t\t\t}, 5000);\n\t\t\t\tforceKillTimeoutId.unref();\n\t\t\t}\n\t\t};\n\n\t\t// Handle abort signal\n\t\tif (options?.signal) {\n\t\t\tif (options.signal.aborted) {\n\t\t\t\tkillProcess();\n\t\t\t} else {\n\t\t\t\toptions.signal.addEventListener(\"abort\", killProcess, { once: true });\n\t\t\t}\n\t\t}\n\n\t\t// Handle timeout\n\t\tif (options?.timeout && options.timeout > 0) {\n\t\t\ttimeoutId = setTimeout(() => {\n\t\t\t\tkillProcess();\n\t\t\t}, options.timeout);\n\t\t}\n\n\t\tproc.stdout?.on(\"data\", (data) => {\n\t\t\tstdout += data.toString();\n\t\t});\n\n\t\tproc.stderr?.on(\"data\", (data) => {\n\t\t\tstderr += data.toString();\n\t\t});\n\n\t\tconst settle = (code: number) => {\n\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t\tif (forceKillTimeoutId) clearTimeout(forceKillTimeoutId);\n\t\t\tif (options?.signal) {\n\t\t\t\toptions.signal.removeEventListener(\"abort\", killProcess);\n\t\t\t}\n\t\t\tresolve({ stdout, stderr, code, killed });\n\t\t};\n\n\t\t// Wait for process termination without hanging on inherited stdio handles\n\t\t// held open by detached descendants.\n\t\twaitForChildProcess(proc)\n\t\t\t.then((code) => {\n\t\t\t\tsettle(code ?? 0);\n\t\t\t})\n\t\t\t.catch((_err) => {\n\t\t\t\tsettle(1);\n\t\t\t});\n\t});\n}\n"]}
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/core/exec.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,wCAAwC;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CA0ErB","sourcesContent":["/**\n * Shared command execution utilities for extensions and custom tools.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { waitForChildProcess } from \"../utils/child-process.ts\";\n\n/**\n * Options for executing shell commands.\n */\nexport interface ExecOptions {\n\t/** AbortSignal to cancel the command */\n\tsignal?: AbortSignal;\n\t/** Timeout in milliseconds */\n\ttimeout?: number;\n\t/** Working directory */\n\tcwd?: string;\n\t/** Environment variables for the spawned process. Defaults to the parent environment. */\n\tenv?: NodeJS.ProcessEnv;\n}\n\n/**\n * Result of executing a shell command.\n */\nexport interface ExecResult {\n\tstdout: string;\n\tstderr: string;\n\tcode: number;\n\tkilled: boolean;\n}\n\n/**\n * Execute a shell command and return stdout/stderr/code.\n * Supports timeout and abort signal.\n */\nexport async function execCommand(\n\tcommand: string,\n\targs: string[],\n\tcwd: string,\n\toptions?: ExecOptions,\n): Promise<ExecResult> {\n\treturn new Promise((resolve) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd,\n\t\t\tenv: options?.env ?? process.env,\n\t\t\tshell: false,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tlet killed = false;\n\t\tlet timeoutId: NodeJS.Timeout | undefined;\n\t\tlet forceKillTimeoutId: NodeJS.Timeout | undefined;\n\n\t\tconst killProcess = () => {\n\t\t\tif (!killed) {\n\t\t\t\tkilled = true;\n\t\t\t\tproc.kill(\"SIGTERM\");\n\t\t\t\t// Force kill after 5 seconds if SIGTERM doesn't work.\n\t\t\t\t// Note: proc.killed only means a signal was successfully SENT, so we\n\t\t\t\t// must check whether the process actually exited instead.\n\t\t\t\tforceKillTimeoutId = setTimeout(() => {\n\t\t\t\t\tif (proc.exitCode === null && proc.signalCode === null) {\n\t\t\t\t\t\tproc.kill(\"SIGKILL\");\n\t\t\t\t\t}\n\t\t\t\t}, 5000);\n\t\t\t\tforceKillTimeoutId.unref();\n\t\t\t}\n\t\t};\n\n\t\t// Handle abort signal\n\t\tif (options?.signal) {\n\t\t\tif (options.signal.aborted) {\n\t\t\t\tkillProcess();\n\t\t\t} else {\n\t\t\t\toptions.signal.addEventListener(\"abort\", killProcess, { once: true });\n\t\t\t}\n\t\t}\n\n\t\t// Handle timeout\n\t\tif (options?.timeout && options.timeout > 0) {\n\t\t\ttimeoutId = setTimeout(() => {\n\t\t\t\tkillProcess();\n\t\t\t}, options.timeout);\n\t\t}\n\n\t\tproc.stdout?.on(\"data\", (data) => {\n\t\t\tstdout += data.toString();\n\t\t});\n\n\t\tproc.stderr?.on(\"data\", (data) => {\n\t\t\tstderr += data.toString();\n\t\t});\n\n\t\tconst settle = (code: number) => {\n\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t\tif (forceKillTimeoutId) clearTimeout(forceKillTimeoutId);\n\t\t\tif (options?.signal) {\n\t\t\t\toptions.signal.removeEventListener(\"abort\", killProcess);\n\t\t\t}\n\t\t\tresolve({ stdout, stderr, code, killed });\n\t\t};\n\n\t\t// Wait for process termination without hanging on inherited stdio handles\n\t\t// held open by detached descendants.\n\t\twaitForChildProcess(proc)\n\t\t\t.then((code) => {\n\t\t\t\tsettle(code ?? 0);\n\t\t\t})\n\t\t\t.catch((_err) => {\n\t\t\t\tsettle(1);\n\t\t\t});\n\t});\n}\n"]}
package/dist/core/exec.js CHANGED
@@ -11,6 +11,7 @@ export async function execCommand(command, args, cwd, options) {
11
11
  return new Promise((resolve) => {
12
12
  const proc = spawn(command, args, {
13
13
  cwd,
14
+ env: options?.env ?? process.env,
14
15
  shell: false,
15
16
  stdio: ["ignore", "pipe", "pipe"],
16
17
  });