@soleri/core 2.12.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/data/flows/build.flow.yaml +128 -0
  2. package/data/flows/deliver.flow.yaml +110 -0
  3. package/data/flows/design.flow.yaml +108 -0
  4. package/data/flows/enhance.flow.yaml +90 -0
  5. package/data/flows/explore.flow.yaml +84 -0
  6. package/data/flows/fix.flow.yaml +90 -0
  7. package/data/flows/plan.flow.yaml +87 -0
  8. package/data/flows/review.flow.yaml +90 -0
  9. package/dist/agency/agency-manager.d.ts +27 -1
  10. package/dist/agency/agency-manager.d.ts.map +1 -1
  11. package/dist/agency/agency-manager.js +180 -9
  12. package/dist/agency/agency-manager.js.map +1 -1
  13. package/dist/agency/default-rules.d.ts +7 -0
  14. package/dist/agency/default-rules.d.ts.map +1 -0
  15. package/dist/agency/default-rules.js +79 -0
  16. package/dist/agency/default-rules.js.map +1 -0
  17. package/dist/agency/types.d.ts +48 -0
  18. package/dist/agency/types.d.ts.map +1 -1
  19. package/dist/brain/brain.d.ts +17 -2
  20. package/dist/brain/brain.d.ts.map +1 -1
  21. package/dist/brain/brain.js +118 -8
  22. package/dist/brain/brain.js.map +1 -1
  23. package/dist/brain/intelligence.d.ts.map +1 -1
  24. package/dist/brain/intelligence.js +16 -2
  25. package/dist/brain/intelligence.js.map +1 -1
  26. package/dist/brain/knowledge-synthesizer.d.ts +37 -0
  27. package/dist/brain/knowledge-synthesizer.d.ts.map +1 -0
  28. package/dist/brain/knowledge-synthesizer.js +161 -0
  29. package/dist/brain/knowledge-synthesizer.js.map +1 -0
  30. package/dist/brain/learning-radar.d.ts +96 -0
  31. package/dist/brain/learning-radar.d.ts.map +1 -0
  32. package/dist/brain/learning-radar.js +202 -0
  33. package/dist/brain/learning-radar.js.map +1 -0
  34. package/dist/brain/types.d.ts +15 -0
  35. package/dist/brain/types.d.ts.map +1 -1
  36. package/dist/capabilities/chain-mapping.d.ts +21 -0
  37. package/dist/capabilities/chain-mapping.d.ts.map +1 -0
  38. package/dist/capabilities/chain-mapping.js +86 -0
  39. package/dist/capabilities/chain-mapping.js.map +1 -0
  40. package/dist/capabilities/index.d.ts +10 -0
  41. package/dist/capabilities/index.d.ts.map +1 -0
  42. package/dist/capabilities/index.js +8 -0
  43. package/dist/capabilities/index.js.map +1 -0
  44. package/dist/capabilities/registry.d.ts +95 -0
  45. package/dist/capabilities/registry.d.ts.map +1 -0
  46. package/dist/capabilities/registry.js +227 -0
  47. package/dist/capabilities/registry.js.map +1 -0
  48. package/dist/capabilities/types.d.ts +106 -0
  49. package/dist/capabilities/types.d.ts.map +1 -0
  50. package/dist/capabilities/types.js +12 -0
  51. package/dist/capabilities/types.js.map +1 -0
  52. package/dist/context/context-engine.d.ts.map +1 -1
  53. package/dist/context/context-engine.js +82 -17
  54. package/dist/context/context-engine.js.map +1 -1
  55. package/dist/context/types.d.ts +5 -0
  56. package/dist/context/types.d.ts.map +1 -1
  57. package/dist/control/intent-router.d.ts +12 -1
  58. package/dist/control/intent-router.d.ts.map +1 -1
  59. package/dist/control/intent-router.js +126 -2
  60. package/dist/control/intent-router.js.map +1 -1
  61. package/dist/control/types.d.ts +17 -0
  62. package/dist/control/types.d.ts.map +1 -1
  63. package/dist/curator/classifier.d.ts +18 -0
  64. package/dist/curator/classifier.d.ts.map +1 -0
  65. package/dist/curator/classifier.js +61 -0
  66. package/dist/curator/classifier.js.map +1 -0
  67. package/dist/curator/quality-gate.d.ts +29 -0
  68. package/dist/curator/quality-gate.d.ts.map +1 -0
  69. package/dist/curator/quality-gate.js +88 -0
  70. package/dist/curator/quality-gate.js.map +1 -0
  71. package/dist/domain-packs/index.d.ts +8 -0
  72. package/dist/domain-packs/index.d.ts.map +1 -0
  73. package/dist/domain-packs/index.js +8 -0
  74. package/dist/domain-packs/index.js.map +1 -0
  75. package/dist/domain-packs/inject-rules.d.ts +24 -0
  76. package/dist/domain-packs/inject-rules.d.ts.map +1 -0
  77. package/dist/domain-packs/inject-rules.js +65 -0
  78. package/dist/domain-packs/inject-rules.js.map +1 -0
  79. package/dist/domain-packs/knowledge-installer.d.ts +27 -0
  80. package/dist/domain-packs/knowledge-installer.d.ts.map +1 -0
  81. package/dist/domain-packs/knowledge-installer.js +89 -0
  82. package/dist/domain-packs/knowledge-installer.js.map +1 -0
  83. package/dist/domain-packs/loader.d.ts +28 -0
  84. package/dist/domain-packs/loader.d.ts.map +1 -0
  85. package/dist/domain-packs/loader.js +105 -0
  86. package/dist/domain-packs/loader.js.map +1 -0
  87. package/dist/domain-packs/pack-runtime.d.ts +80 -0
  88. package/dist/domain-packs/pack-runtime.d.ts.map +1 -0
  89. package/dist/domain-packs/pack-runtime.js +36 -0
  90. package/dist/domain-packs/pack-runtime.js.map +1 -0
  91. package/dist/domain-packs/skills-installer.d.ts +21 -0
  92. package/dist/domain-packs/skills-installer.d.ts.map +1 -0
  93. package/dist/domain-packs/skills-installer.js +38 -0
  94. package/dist/domain-packs/skills-installer.js.map +1 -0
  95. package/dist/domain-packs/token-resolver.d.ts +37 -0
  96. package/dist/domain-packs/token-resolver.d.ts.map +1 -0
  97. package/dist/domain-packs/token-resolver.js +109 -0
  98. package/dist/domain-packs/token-resolver.js.map +1 -0
  99. package/dist/domain-packs/types.d.ts +91 -0
  100. package/dist/domain-packs/types.d.ts.map +1 -0
  101. package/dist/domain-packs/types.js +122 -0
  102. package/dist/domain-packs/types.js.map +1 -0
  103. package/dist/engine/bin/soleri-engine.d.ts +12 -0
  104. package/dist/engine/bin/soleri-engine.d.ts.map +1 -0
  105. package/dist/engine/bin/soleri-engine.js +184 -0
  106. package/dist/engine/bin/soleri-engine.js.map +1 -0
  107. package/dist/engine/core-ops.d.ts +27 -0
  108. package/dist/engine/core-ops.d.ts.map +1 -0
  109. package/dist/engine/core-ops.js +159 -0
  110. package/dist/engine/core-ops.js.map +1 -0
  111. package/dist/engine/index.d.ts +19 -0
  112. package/dist/engine/index.d.ts.map +1 -0
  113. package/dist/engine/index.js +17 -0
  114. package/dist/engine/index.js.map +1 -0
  115. package/dist/engine/register-engine.d.ts +54 -0
  116. package/dist/engine/register-engine.d.ts.map +1 -0
  117. package/dist/engine/register-engine.js +270 -0
  118. package/dist/engine/register-engine.js.map +1 -0
  119. package/dist/engine/test-helpers.d.ts +30 -0
  120. package/dist/engine/test-helpers.d.ts.map +1 -0
  121. package/dist/engine/test-helpers.js +59 -0
  122. package/dist/engine/test-helpers.js.map +1 -0
  123. package/dist/events/event-bus.d.ts +30 -0
  124. package/dist/events/event-bus.d.ts.map +1 -0
  125. package/dist/events/event-bus.js +51 -0
  126. package/dist/events/event-bus.js.map +1 -0
  127. package/dist/flows/chain-runner.d.ts +46 -0
  128. package/dist/flows/chain-runner.d.ts.map +1 -0
  129. package/dist/flows/chain-runner.js +271 -0
  130. package/dist/flows/chain-runner.js.map +1 -0
  131. package/dist/flows/chain-types.d.ts +103 -0
  132. package/dist/flows/chain-types.d.ts.map +1 -0
  133. package/dist/flows/chain-types.js +23 -0
  134. package/dist/flows/chain-types.js.map +1 -0
  135. package/dist/flows/context-router.d.ts +39 -0
  136. package/dist/flows/context-router.d.ts.map +1 -0
  137. package/dist/flows/context-router.js +206 -0
  138. package/dist/flows/context-router.js.map +1 -0
  139. package/dist/flows/dispatch-registry.d.ts +24 -0
  140. package/dist/flows/dispatch-registry.d.ts.map +1 -0
  141. package/dist/flows/dispatch-registry.js +70 -0
  142. package/dist/flows/dispatch-registry.js.map +1 -0
  143. package/dist/flows/epilogue.d.ts +24 -0
  144. package/dist/flows/epilogue.d.ts.map +1 -0
  145. package/dist/flows/epilogue.js +52 -0
  146. package/dist/flows/epilogue.js.map +1 -0
  147. package/dist/flows/executor.d.ts +25 -0
  148. package/dist/flows/executor.d.ts.map +1 -0
  149. package/dist/flows/executor.js +153 -0
  150. package/dist/flows/executor.js.map +1 -0
  151. package/dist/flows/gate-evaluator.d.ts +26 -0
  152. package/dist/flows/gate-evaluator.d.ts.map +1 -0
  153. package/dist/flows/gate-evaluator.js +162 -0
  154. package/dist/flows/gate-evaluator.js.map +1 -0
  155. package/dist/flows/index.d.ts +14 -0
  156. package/dist/flows/index.d.ts.map +1 -0
  157. package/dist/flows/index.js +20 -0
  158. package/dist/flows/index.js.map +1 -0
  159. package/dist/flows/loader.d.ts +17 -0
  160. package/dist/flows/loader.d.ts.map +1 -0
  161. package/dist/flows/loader.js +61 -0
  162. package/dist/flows/loader.js.map +1 -0
  163. package/dist/flows/plan-builder.d.ts +40 -0
  164. package/dist/flows/plan-builder.d.ts.map +1 -0
  165. package/dist/flows/plan-builder.js +213 -0
  166. package/dist/flows/plan-builder.js.map +1 -0
  167. package/dist/flows/probes.d.ts +11 -0
  168. package/dist/flows/probes.d.ts.map +1 -0
  169. package/dist/flows/probes.js +62 -0
  170. package/dist/flows/probes.js.map +1 -0
  171. package/dist/flows/types.d.ts +950 -0
  172. package/dist/flows/types.d.ts.map +1 -0
  173. package/dist/flows/types.js +105 -0
  174. package/dist/flows/types.js.map +1 -0
  175. package/dist/health/doctor-checks.d.ts +15 -0
  176. package/dist/health/doctor-checks.d.ts.map +1 -0
  177. package/dist/health/doctor-checks.js +98 -0
  178. package/dist/health/doctor-checks.js.map +1 -0
  179. package/dist/index.d.ts +11 -1
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js +10 -1
  182. package/dist/index.js.map +1 -1
  183. package/dist/intake/text-ingester.d.ts +52 -0
  184. package/dist/intake/text-ingester.d.ts.map +1 -0
  185. package/dist/intake/text-ingester.js +181 -0
  186. package/dist/intake/text-ingester.js.map +1 -0
  187. package/dist/intelligence/loader.d.ts +19 -0
  188. package/dist/intelligence/loader.d.ts.map +1 -1
  189. package/dist/intelligence/loader.js +35 -0
  190. package/dist/intelligence/loader.js.map +1 -1
  191. package/dist/intelligence/types.d.ts +1 -0
  192. package/dist/intelligence/types.d.ts.map +1 -1
  193. package/dist/llm/llm-client.d.ts.map +1 -1
  194. package/dist/llm/llm-client.js +37 -1
  195. package/dist/llm/llm-client.js.map +1 -1
  196. package/dist/llm/oauth-discovery.d.ts +26 -0
  197. package/dist/llm/oauth-discovery.d.ts.map +1 -0
  198. package/dist/llm/oauth-discovery.js +149 -0
  199. package/dist/llm/oauth-discovery.js.map +1 -0
  200. package/dist/packs/types.d.ts +58 -19
  201. package/dist/packs/types.d.ts.map +1 -1
  202. package/dist/packs/types.js +14 -0
  203. package/dist/packs/types.js.map +1 -1
  204. package/dist/planning/evidence-collector.d.ts +41 -0
  205. package/dist/planning/evidence-collector.d.ts.map +1 -0
  206. package/dist/planning/evidence-collector.js +194 -0
  207. package/dist/planning/evidence-collector.js.map +1 -0
  208. package/dist/planning/planner.d.ts +4 -0
  209. package/dist/planning/planner.d.ts.map +1 -1
  210. package/dist/planning/planner.js +11 -0
  211. package/dist/planning/planner.js.map +1 -1
  212. package/dist/playbooks/generic/onboarding.d.ts +9 -0
  213. package/dist/playbooks/generic/onboarding.d.ts.map +1 -0
  214. package/dist/playbooks/generic/onboarding.js +74 -0
  215. package/dist/playbooks/generic/onboarding.js.map +1 -0
  216. package/dist/playbooks/playbook-registry.d.ts.map +1 -1
  217. package/dist/playbooks/playbook-registry.js +2 -0
  218. package/dist/playbooks/playbook-registry.js.map +1 -1
  219. package/dist/queue/job-queue.d.ts +92 -0
  220. package/dist/queue/job-queue.d.ts.map +1 -0
  221. package/dist/queue/job-queue.js +180 -0
  222. package/dist/queue/job-queue.js.map +1 -0
  223. package/dist/queue/pipeline-runner.d.ts +62 -0
  224. package/dist/queue/pipeline-runner.d.ts.map +1 -0
  225. package/dist/queue/pipeline-runner.js +126 -0
  226. package/dist/queue/pipeline-runner.js.map +1 -0
  227. package/dist/runtime/admin-extra-ops.d.ts.map +1 -1
  228. package/dist/runtime/admin-extra-ops.js +15 -9
  229. package/dist/runtime/admin-extra-ops.js.map +1 -1
  230. package/dist/runtime/admin-ops.js +4 -4
  231. package/dist/runtime/admin-ops.js.map +1 -1
  232. package/dist/runtime/admin-setup-ops.d.ts +20 -0
  233. package/dist/runtime/admin-setup-ops.d.ts.map +1 -0
  234. package/dist/runtime/admin-setup-ops.js +583 -0
  235. package/dist/runtime/admin-setup-ops.js.map +1 -0
  236. package/dist/runtime/capture-ops.d.ts.map +1 -1
  237. package/dist/runtime/capture-ops.js +33 -1
  238. package/dist/runtime/capture-ops.js.map +1 -1
  239. package/dist/runtime/chain-ops.d.ts +9 -0
  240. package/dist/runtime/chain-ops.d.ts.map +1 -0
  241. package/dist/runtime/chain-ops.js +107 -0
  242. package/dist/runtime/chain-ops.js.map +1 -0
  243. package/dist/runtime/claude-md-helpers.d.ts +65 -0
  244. package/dist/runtime/claude-md-helpers.d.ts.map +1 -0
  245. package/dist/runtime/claude-md-helpers.js +173 -0
  246. package/dist/runtime/claude-md-helpers.js.map +1 -0
  247. package/dist/runtime/curator-extra-ops.d.ts +3 -2
  248. package/dist/runtime/curator-extra-ops.d.ts.map +1 -1
  249. package/dist/runtime/curator-extra-ops.js +81 -3
  250. package/dist/runtime/curator-extra-ops.js.map +1 -1
  251. package/dist/runtime/domain-ops.d.ts +21 -5
  252. package/dist/runtime/domain-ops.d.ts.map +1 -1
  253. package/dist/runtime/domain-ops.js +64 -6
  254. package/dist/runtime/domain-ops.js.map +1 -1
  255. package/dist/runtime/facades/admin-facade.d.ts.map +1 -1
  256. package/dist/runtime/facades/admin-facade.js +4 -0
  257. package/dist/runtime/facades/admin-facade.js.map +1 -1
  258. package/dist/runtime/facades/agency-facade.d.ts.map +1 -1
  259. package/dist/runtime/facades/agency-facade.js +64 -0
  260. package/dist/runtime/facades/agency-facade.js.map +1 -1
  261. package/dist/runtime/facades/brain-facade.d.ts.map +1 -1
  262. package/dist/runtime/facades/brain-facade.js +122 -1
  263. package/dist/runtime/facades/brain-facade.js.map +1 -1
  264. package/dist/runtime/facades/cognee-facade.d.ts.map +1 -1
  265. package/dist/runtime/facades/cognee-facade.js +3 -1
  266. package/dist/runtime/facades/cognee-facade.js.map +1 -1
  267. package/dist/runtime/facades/control-facade.d.ts.map +1 -1
  268. package/dist/runtime/facades/control-facade.js +42 -0
  269. package/dist/runtime/facades/control-facade.js.map +1 -1
  270. package/dist/runtime/facades/index.d.ts.map +1 -1
  271. package/dist/runtime/facades/index.js +10 -6
  272. package/dist/runtime/facades/index.js.map +1 -1
  273. package/dist/runtime/facades/memory-facade.d.ts.map +1 -1
  274. package/dist/runtime/facades/memory-facade.js +20 -2
  275. package/dist/runtime/facades/memory-facade.js.map +1 -1
  276. package/dist/runtime/facades/plan-facade.d.ts.map +1 -1
  277. package/dist/runtime/facades/plan-facade.js +2 -0
  278. package/dist/runtime/facades/plan-facade.js.map +1 -1
  279. package/dist/runtime/facades/vault-facade.d.ts.map +1 -1
  280. package/dist/runtime/facades/vault-facade.js +27 -5
  281. package/dist/runtime/facades/vault-facade.js.map +1 -1
  282. package/dist/runtime/intake-ops.d.ts +7 -5
  283. package/dist/runtime/intake-ops.d.ts.map +1 -1
  284. package/dist/runtime/intake-ops.js +98 -5
  285. package/dist/runtime/intake-ops.js.map +1 -1
  286. package/dist/runtime/memory-extra-ops.d.ts +6 -3
  287. package/dist/runtime/memory-extra-ops.d.ts.map +1 -1
  288. package/dist/runtime/memory-extra-ops.js +292 -4
  289. package/dist/runtime/memory-extra-ops.js.map +1 -1
  290. package/dist/runtime/orchestrate-ops.d.ts +8 -7
  291. package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
  292. package/dist/runtime/orchestrate-ops.js +217 -61
  293. package/dist/runtime/orchestrate-ops.js.map +1 -1
  294. package/dist/runtime/planning-extra-ops.d.ts.map +1 -1
  295. package/dist/runtime/planning-extra-ops.js +85 -0
  296. package/dist/runtime/planning-extra-ops.js.map +1 -1
  297. package/dist/runtime/playbook-ops.js +1 -1
  298. package/dist/runtime/playbook-ops.js.map +1 -1
  299. package/dist/runtime/runtime.d.ts.map +1 -1
  300. package/dist/runtime/runtime.js +165 -18
  301. package/dist/runtime/runtime.js.map +1 -1
  302. package/dist/runtime/session-briefing.d.ts +23 -0
  303. package/dist/runtime/session-briefing.d.ts.map +1 -0
  304. package/dist/runtime/session-briefing.js +140 -0
  305. package/dist/runtime/session-briefing.js.map +1 -0
  306. package/dist/runtime/types.d.ts +29 -2
  307. package/dist/runtime/types.d.ts.map +1 -1
  308. package/dist/runtime/vault-linking-ops.d.ts +13 -0
  309. package/dist/runtime/vault-linking-ops.d.ts.map +1 -0
  310. package/dist/runtime/vault-linking-ops.js +365 -0
  311. package/dist/runtime/vault-linking-ops.js.map +1 -0
  312. package/dist/vault/linking.d.ts +46 -0
  313. package/dist/vault/linking.d.ts.map +1 -0
  314. package/dist/vault/linking.js +275 -0
  315. package/dist/vault/linking.js.map +1 -0
  316. package/dist/vault/vault-types.d.ts +37 -0
  317. package/dist/vault/vault-types.d.ts.map +1 -1
  318. package/dist/vault/vault.d.ts +37 -0
  319. package/dist/vault/vault.d.ts.map +1 -1
  320. package/dist/vault/vault.js +152 -9
  321. package/dist/vault/vault.js.map +1 -1
  322. package/package.json +4 -1
  323. package/src/__tests__/admin-extra-ops.test.ts +1 -1
  324. package/src/__tests__/admin-ops.test.ts +2 -1
  325. package/src/__tests__/admin-setup-ops.test.ts +355 -0
  326. package/src/__tests__/async-infrastructure.test.ts +307 -0
  327. package/src/__tests__/cognee-client-gaps.test.ts +474 -0
  328. package/src/__tests__/cognee-hybrid-search.test.ts +492 -0
  329. package/src/__tests__/cognee-sync-manager-deep.test.ts +654 -0
  330. package/src/__tests__/cognee-sync-manager.test.ts +1 -0
  331. package/src/__tests__/core-ops.test.ts +9 -61
  332. package/src/__tests__/curator-extra-ops.test.ts +6 -2
  333. package/src/__tests__/curator-pipeline-e2e.test.ts +358 -0
  334. package/src/__tests__/domain-packs.test.ts +421 -0
  335. package/src/__tests__/flows.test.ts +604 -0
  336. package/src/__tests__/memory-extra-ops.test.ts +2 -2
  337. package/src/__tests__/planning-extra-ops.test.ts +2 -2
  338. package/src/__tests__/playbook-registry.test.ts +2 -2
  339. package/src/__tests__/playbook-seeder.test.ts +8 -8
  340. package/src/__tests__/playbook.test.ts +5 -5
  341. package/src/__tests__/second-brain-features.test.ts +583 -0
  342. package/src/__tests__/token-resolver.test.ts +79 -0
  343. package/src/agency/agency-manager.ts +217 -9
  344. package/src/agency/default-rules.ts +83 -0
  345. package/src/agency/types.ts +61 -0
  346. package/src/brain/brain.ts +110 -8
  347. package/src/brain/intelligence.ts +21 -2
  348. package/src/brain/knowledge-synthesizer.ts +218 -0
  349. package/src/brain/learning-radar.ts +340 -0
  350. package/src/brain/types.ts +16 -0
  351. package/src/capabilities/chain-mapping.ts +93 -0
  352. package/src/capabilities/index.ts +21 -0
  353. package/src/capabilities/registry.ts +290 -0
  354. package/src/capabilities/types.ts +143 -0
  355. package/src/context/context-engine.ts +114 -15
  356. package/src/context/types.ts +5 -0
  357. package/src/control/intent-router.ts +153 -2
  358. package/src/control/types.ts +10 -0
  359. package/src/curator/classifier.ts +88 -0
  360. package/src/curator/quality-gate.ts +129 -0
  361. package/src/domain-packs/index.ts +27 -0
  362. package/src/domain-packs/inject-rules.ts +74 -0
  363. package/src/domain-packs/knowledge-installer.ts +116 -0
  364. package/src/domain-packs/loader.ts +124 -0
  365. package/src/domain-packs/pack-runtime.ts +99 -0
  366. package/src/domain-packs/skills-installer.ts +56 -0
  367. package/src/domain-packs/token-resolver.ts +126 -0
  368. package/src/domain-packs/types.ts +229 -0
  369. package/src/engine/__tests__/register-engine.test.ts +104 -0
  370. package/src/engine/bin/soleri-engine.ts +218 -0
  371. package/src/engine/core-ops.ts +178 -0
  372. package/src/engine/index.ts +19 -0
  373. package/src/engine/register-engine.ts +385 -0
  374. package/src/engine/test-helpers.ts +83 -0
  375. package/src/events/event-bus.ts +58 -0
  376. package/src/flows/chain-runner.ts +369 -0
  377. package/src/flows/chain-types.ts +57 -0
  378. package/src/flows/context-router.ts +257 -0
  379. package/src/flows/dispatch-registry.ts +80 -0
  380. package/src/flows/epilogue.ts +65 -0
  381. package/src/flows/executor.ts +182 -0
  382. package/src/flows/gate-evaluator.ts +171 -0
  383. package/src/flows/index.ts +52 -0
  384. package/src/flows/loader.ts +63 -0
  385. package/src/flows/plan-builder.ts +250 -0
  386. package/src/flows/probes.ts +70 -0
  387. package/src/flows/types.ts +217 -0
  388. package/src/health/doctor-checks.ts +115 -0
  389. package/src/index.ts +68 -1
  390. package/src/intake/text-ingester.ts +234 -0
  391. package/src/intelligence/loader.ts +38 -0
  392. package/src/intelligence/types.ts +1 -0
  393. package/src/llm/llm-client.ts +38 -1
  394. package/src/llm/oauth-discovery.ts +169 -0
  395. package/src/packs/types.ts +19 -0
  396. package/src/planning/evidence-collector.ts +247 -0
  397. package/src/planning/planner.ts +11 -0
  398. package/src/playbooks/generic/onboarding.ts +79 -0
  399. package/src/playbooks/playbook-registry.ts +2 -0
  400. package/src/queue/job-queue.ts +281 -0
  401. package/src/queue/pipeline-runner.ts +149 -0
  402. package/src/runtime/admin-extra-ops.ts +14 -8
  403. package/src/runtime/admin-ops.ts +4 -4
  404. package/src/runtime/admin-setup-ops.ts +664 -0
  405. package/src/runtime/capture-ops.ts +40 -1
  406. package/src/runtime/chain-ops.ts +121 -0
  407. package/src/runtime/claude-md-helpers.ts +236 -0
  408. package/src/runtime/curator-extra-ops.ts +86 -3
  409. package/src/runtime/domain-ops.ts +71 -5
  410. package/src/runtime/facades/admin-facade.ts +4 -0
  411. package/src/runtime/facades/agency-facade.ts +68 -0
  412. package/src/runtime/facades/brain-facade.ts +142 -1
  413. package/src/runtime/facades/cognee-facade.ts +3 -1
  414. package/src/runtime/facades/control-facade.ts +45 -0
  415. package/src/runtime/facades/index.ts +12 -6
  416. package/src/runtime/facades/memory-facade.ts +20 -2
  417. package/src/runtime/facades/plan-facade.ts +2 -0
  418. package/src/runtime/facades/vault-facade.ts +30 -5
  419. package/src/runtime/intake-ops.ts +107 -5
  420. package/src/runtime/memory-extra-ops.ts +312 -4
  421. package/src/runtime/orchestrate-ops.ts +261 -65
  422. package/src/runtime/planning-extra-ops.ts +94 -0
  423. package/src/runtime/playbook-ops.ts +1 -1
  424. package/src/runtime/runtime.ts +164 -19
  425. package/src/runtime/session-briefing.ts +161 -0
  426. package/src/runtime/types.ts +29 -2
  427. package/src/runtime/vault-linking-ops.ts +452 -0
  428. package/src/vault/linking.ts +333 -0
  429. package/src/vault/vault-types.ts +46 -0
  430. package/src/vault/vault.ts +173 -11
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // ─── Intelligence ────────────────────────────────────────────────────
2
2
  export type { IntelligenceEntry, IntelligenceBundle } from './intelligence/types.js';
3
- export { loadIntelligenceData } from './intelligence/loader.js';
3
+ export { loadIntelligenceData, loadPacks } from './intelligence/loader.js';
4
4
 
5
5
  // ─── Vault ───────────────────────────────────────────────────────────
6
6
  export { Vault } from './vault/vault.js';
@@ -503,6 +503,15 @@ export {
503
503
  } from './runtime/deprecation.js';
504
504
  export type { DeprecationInfo } from './runtime/deprecation.js';
505
505
 
506
+ // ─── Engine (v7 — direct registration, replaces facade factory) ───────
507
+ export { registerEngine } from './engine/register-engine.js';
508
+ export type {
509
+ EngineRegistrationOptions,
510
+ EngineRegistrationResult,
511
+ } from './engine/register-engine.js';
512
+ export { captureOps, executeOp } from './engine/test-helpers.js';
513
+ export type { CapturedOp } from './engine/test-helpers.js';
514
+
506
515
  // ─── Migrations ────────────────────────────────────────────────────────
507
516
  export { MigrationRunner } from './migrations/index.js';
508
517
  export type { Migration, MigrationResult, MigrationState } from './migrations/index.js';
@@ -629,3 +638,61 @@ export type {
629
638
  // ─── Prompts ───────────────────────────────────────────────────────────
630
639
  export { TemplateManager, parseVariables, resolveIncludes } from './prompts/index.js';
631
640
  export type { PromptTemplate, TemplateVariable, RenderOptions } from './prompts/index.js';
641
+
642
+ // ─── Domain Packs ──────────────────────────────────────────────────────
643
+ export {
644
+ validateDomainPack,
645
+ SEMANTIC_FACADE_NAMES,
646
+ loadDomainPack,
647
+ loadDomainPacksFromConfig,
648
+ resolveDependencies,
649
+ } from './domain-packs/index.js';
650
+ export type {
651
+ DomainPack,
652
+ DomainPackManifest,
653
+ DomainPackRef,
654
+ KnowledgeManifest,
655
+ PackSkillDefinition,
656
+ ValidateResult as DomainPackValidateResult,
657
+ PackRuntime,
658
+ PackProjectContext,
659
+ PackCheckContext,
660
+ } from './domain-packs/index.js';
661
+ export {
662
+ createPackRuntime,
663
+ resolveToken,
664
+ listProjectTokens,
665
+ buildReverseIndex,
666
+ } from './domain-packs/index.js';
667
+
668
+ // ─── Capabilities ───────────────────────────────────────────────────────
669
+ export * from './capabilities/index.js';
670
+
671
+ // ─── Flow Engine ───────────────────────────────────────────────────────
672
+ export type {
673
+ Flow,
674
+ FlowStep,
675
+ ProbeName,
676
+ ProbeResults,
677
+ PlanStep,
678
+ SkippedStep,
679
+ OrchestrationPlan,
680
+ OrchestrationContext,
681
+ StepResult as FlowStepResult,
682
+ ExecutionResult,
683
+ GateVerdict,
684
+ } from './flows/index.js';
685
+ export {
686
+ loadFlowById,
687
+ loadAllFlows,
688
+ runProbes,
689
+ INTENT_TO_FLOW,
690
+ chainToToolName,
691
+ buildPlan,
692
+ pruneSteps,
693
+ evaluateGate,
694
+ evaluateCondition,
695
+ FlowExecutor,
696
+ createDispatcher,
697
+ runEpilogue,
698
+ } from './flows/index.js';
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Text Ingester — ingest articles, transcripts, and plain text into the vault.
3
+ *
4
+ * Reuses existing content-classifier (LLM extraction) and dedup-gate (TF-IDF).
5
+ * No new dependencies — fetch() is built-in, HTML stripping is regex-based.
6
+ */
7
+
8
+ import type { Vault } from '../vault/vault.js';
9
+ import type { LLMClient } from '../llm/llm-client.js';
10
+ import type { IntelligenceEntry } from '../intelligence/types.js';
11
+ import type { ClassifiedItem } from './types.js';
12
+ import { classifyChunk } from './content-classifier.js';
13
+ import { dedupItems } from './dedup-gate.js';
14
+
15
+ // ─── Types ───────────────────────────────────────────────────────────
16
+
17
+ export interface IngestSource {
18
+ type: 'article' | 'transcript' | 'notes' | 'documentation';
19
+ title: string;
20
+ url?: string;
21
+ author?: string;
22
+ }
23
+
24
+ export interface IngestOptions {
25
+ domain?: string;
26
+ tags?: string[];
27
+ /** Max chars per chunk for LLM classification. Default 4000. */
28
+ chunkSize?: number;
29
+ }
30
+
31
+ export interface IngestResult {
32
+ source: IngestSource;
33
+ ingested: number;
34
+ duplicates: number;
35
+ entries: Array<{ id: string; title: string; type: string }>;
36
+ }
37
+
38
+ // ─── Constants ───────────────────────────────────────────────────────
39
+
40
+ const DEFAULT_CHUNK_SIZE = 4000;
41
+ const FETCH_TIMEOUT_MS = 15000;
42
+
43
+ // ─── Class ───────────────────────────────────────────────────────────
44
+
45
+ export class TextIngester {
46
+ private vault: Vault;
47
+ private llm: LLMClient | null;
48
+
49
+ constructor(vault: Vault, llm: LLMClient | null) {
50
+ this.vault = vault;
51
+ this.llm = llm;
52
+ }
53
+
54
+ /**
55
+ * Ingest a URL — fetch, strip HTML, classify, dedup, store.
56
+ */
57
+ async ingestUrl(url: string, opts?: IngestOptions): Promise<IngestResult> {
58
+ if (!this.llm) {
59
+ return { source: { type: 'article', title: url }, ingested: 0, duplicates: 0, entries: [] };
60
+ }
61
+
62
+ let text: string;
63
+ let title = url;
64
+ try {
65
+ const response = await fetch(url, {
66
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
67
+ headers: { 'User-Agent': 'Soleri/1.0 (knowledge ingestion)' },
68
+ });
69
+ if (!response.ok) {
70
+ return { source: { type: 'article', title }, ingested: 0, duplicates: 0, entries: [] };
71
+ }
72
+ const html = await response.text();
73
+ title = extractTitle(html) ?? url;
74
+ text = stripHtml(html);
75
+ } catch {
76
+ return { source: { type: 'article', title }, ingested: 0, duplicates: 0, entries: [] };
77
+ }
78
+
79
+ if (text.length < 50) {
80
+ return { source: { type: 'article', title }, ingested: 0, duplicates: 0, entries: [] };
81
+ }
82
+
83
+ const source: IngestSource = { type: 'article', title, url };
84
+ return this.ingestText(text, source, opts);
85
+ }
86
+
87
+ /**
88
+ * Ingest raw text — classify, dedup, store.
89
+ */
90
+ async ingestText(
91
+ text: string,
92
+ source: IngestSource,
93
+ opts?: IngestOptions,
94
+ ): Promise<IngestResult> {
95
+ if (!this.llm) {
96
+ return { source, ingested: 0, duplicates: 0, entries: [] };
97
+ }
98
+
99
+ const chunkSize = opts?.chunkSize ?? DEFAULT_CHUNK_SIZE;
100
+ const chunks = splitIntoChunks(text, chunkSize);
101
+ const domain = opts?.domain ?? 'general';
102
+ const extraTags = opts?.tags ?? [];
103
+
104
+ // Classify all chunks
105
+ const allItems: ClassifiedItem[] = [];
106
+ for (const chunk of chunks) {
107
+ const items = await classifyChunk(this.llm, chunk, `${source.type}: ${source.title}`);
108
+ allItems.push(...items);
109
+ }
110
+
111
+ if (allItems.length === 0) {
112
+ return { source, ingested: 0, duplicates: 0, entries: [] };
113
+ }
114
+
115
+ // Dedup against vault
116
+ const dedupResults = dedupItems(allItems, this.vault);
117
+ const unique = dedupResults.filter((r) => !r.isDuplicate).map((r) => r.item);
118
+ const duplicateCount = dedupResults.filter((r) => r.isDuplicate).length;
119
+
120
+ // Build source attribution for context field
121
+ const attribution = buildAttribution(source);
122
+
123
+ // Store in vault
124
+ const entries: IntelligenceEntry[] = unique.map((item, i) => ({
125
+ id: `ingest-${source.type}-${Date.now()}-${i}-${Math.random().toString(36).slice(2, 6)}`,
126
+ type: mapType(item.type),
127
+ domain,
128
+ title: item.title,
129
+ description: item.description,
130
+ severity: mapSeverity(item.severity),
131
+ tags: [...(item.tags ?? []), ...extraTags, 'ingested', source.type],
132
+ context: attribution,
133
+ origin: 'user' as const,
134
+ }));
135
+
136
+ if (entries.length > 0) {
137
+ this.vault.seed(entries);
138
+ }
139
+
140
+ return {
141
+ source,
142
+ ingested: entries.length,
143
+ duplicates: duplicateCount,
144
+ entries: entries.map((e) => ({ id: e.id, title: e.title, type: e.type })),
145
+ };
146
+ }
147
+
148
+ /**
149
+ * Ingest multiple items in sequence.
150
+ */
151
+ async ingestBatch(
152
+ items: Array<{ text: string; source: IngestSource; opts?: IngestOptions }>,
153
+ ): Promise<IngestResult[]> {
154
+ const results: IngestResult[] = [];
155
+ for (const item of items) {
156
+ const result = await this.ingestText(item.text, item.source, item.opts);
157
+ results.push(result);
158
+ }
159
+ return results;
160
+ }
161
+ }
162
+
163
+ // ─── Helpers ─────────────────────────────────────────────────────────
164
+
165
+ function stripHtml(html: string): string {
166
+ return (
167
+ html
168
+ // Remove script and style blocks
169
+ .replace(/<script[\s\S]*?<\/script>/gi, '')
170
+ .replace(/<style[\s\S]*?<\/style>/gi, '')
171
+ // Remove nav, header, footer, aside
172
+ .replace(/<(nav|header|footer|aside)[\s\S]*?<\/\1>/gi, '')
173
+ // Remove all HTML tags
174
+ .replace(/<[^>]+>/g, ' ')
175
+ // Decode common entities
176
+ .replace(/&amp;/g, '&')
177
+ .replace(/&lt;/g, '<')
178
+ .replace(/&gt;/g, '>')
179
+ .replace(/&quot;/g, '"')
180
+ .replace(/&#39;/g, "'")
181
+ .replace(/&nbsp;/g, ' ')
182
+ // Collapse whitespace
183
+ .replace(/\s+/g, ' ')
184
+ .trim()
185
+ );
186
+ }
187
+
188
+ function extractTitle(html: string): string | null {
189
+ const match = html.match(/<title[^>]*>(.*?)<\/title>/i);
190
+ if (match) {
191
+ return match[1].replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').trim();
192
+ }
193
+ return null;
194
+ }
195
+
196
+ function splitIntoChunks(text: string, chunkSize: number): string[] {
197
+ if (text.length <= chunkSize) return [text];
198
+
199
+ const chunks: string[] = [];
200
+ let start = 0;
201
+ while (start < text.length) {
202
+ let end = start + chunkSize;
203
+ // Try to break at a sentence boundary
204
+ if (end < text.length) {
205
+ const lastPeriod = text.lastIndexOf('. ', end);
206
+ if (lastPeriod > start + chunkSize * 0.5) {
207
+ end = lastPeriod + 2;
208
+ }
209
+ }
210
+ chunks.push(text.slice(start, end).trim());
211
+ start = end;
212
+ }
213
+ return chunks.filter((c) => c.length > 0);
214
+ }
215
+
216
+ function buildAttribution(source: IngestSource): string {
217
+ const parts = [`Source: ${source.type}`];
218
+ if (source.title) parts.push(`Title: ${source.title}`);
219
+ if (source.url) parts.push(`URL: ${source.url}`);
220
+ if (source.author) parts.push(`Author: ${source.author}`);
221
+ return parts.join(' | ');
222
+ }
223
+
224
+ function mapType(type: string): IntelligenceEntry['type'] {
225
+ if (type === 'pattern') return 'pattern';
226
+ if (type === 'anti-pattern') return 'anti-pattern';
227
+ return 'rule';
228
+ }
229
+
230
+ function mapSeverity(severity: string | undefined): IntelligenceEntry['severity'] {
231
+ if (severity === 'critical') return 'critical';
232
+ if (severity === 'warning') return 'warning';
233
+ return 'suggestion';
234
+ }
@@ -93,3 +93,41 @@ function validateEntry(entry: IntelligenceEntry): boolean {
93
93
  Array.isArray(entry.tags)
94
94
  );
95
95
  }
96
+
97
+ /**
98
+ * Load all knowledge packs from a packs directory.
99
+ * Each subdirectory is a pack with JSON bundle files and an optional soleri-pack.json manifest.
100
+ *
101
+ * Structure:
102
+ * packsDir/
103
+ * design-system/
104
+ * soleri-pack.json ← optional manifest
105
+ * design-tokens.json ← IntelligenceBundle
106
+ * components.json ← IntelligenceBundle
107
+ * clean-code/
108
+ * refactoring.json ← IntelligenceBundle
109
+ *
110
+ * Returns entries grouped by pack name for installPack() calls.
111
+ */
112
+ export function loadPacks(
113
+ packsDir: string,
114
+ ): Array<{ packName: string; entries: IntelligenceEntry[] }> {
115
+ const result: Array<{ packName: string; entries: IntelligenceEntry[] }> = [];
116
+ let dirs: string[];
117
+ try {
118
+ dirs = readdirSync(packsDir, { withFileTypes: true })
119
+ .filter((d) => d.isDirectory() && !d.name.startsWith('.'))
120
+ .map((d) => d.name);
121
+ } catch {
122
+ return result;
123
+ }
124
+
125
+ for (const dir of dirs) {
126
+ const packPath = join(packsDir, dir);
127
+ const entries = loadIntelligenceData(packPath);
128
+ if (entries.length > 0) {
129
+ result.push({ packName: dir, entries });
130
+ }
131
+ }
132
+ return result;
133
+ }
@@ -12,6 +12,7 @@ export interface IntelligenceEntry {
12
12
  tags: string[];
13
13
  appliesTo?: string[];
14
14
  tier?: 'agent' | 'project' | 'team'; // scope tier — auto-detected or manually set
15
+ origin?: 'agent' | 'pack' | 'user'; // knowledge origin — 'agent' = engine, 'pack' = installable knowledge pack, 'user' = personal capture
15
16
  validFrom?: number; // unix epoch — when entry becomes active
16
17
  validUntil?: number; // unix epoch — when entry expires (null = never)
17
18
  }
@@ -25,8 +25,45 @@ const OPENAI_API_URL = 'https://api.openai.com/v1/chat/completions';
25
25
  // =============================================================================
26
26
 
27
27
  function loadRoutingConfig(agentId: string): RoutingConfig {
28
+ // Default task→model routing: cheap models for routine, powerful for reasoning.
29
+ // Anthropic routes use extended thinking for quality decisions when available.
30
+ // Agents can override via ~/.{agentId}/model-routing.json.
31
+ const defaultRoutes: RouteEntry[] = [
32
+ // OpenAI routes (default — works without Anthropic key)
33
+ { caller: 'quality-gate', task: 'evaluate', model: 'gpt-4o', provider: 'openai' },
34
+ { caller: 'classifier', task: 'classify', model: 'gpt-4o-mini', provider: 'openai' },
35
+ { caller: 'knowledge-synthesizer', task: 'synthesize', model: 'gpt-4o', provider: 'openai' },
36
+ { caller: 'content-classifier', model: 'gpt-4o-mini', provider: 'openai' },
37
+ { caller: 'vault-linking', task: 'evaluate-links', model: 'gpt-4o-mini', provider: 'openai' },
38
+ // Anthropic routes (higher quality when key available — extended thinking capable)
39
+ {
40
+ caller: 'quality-gate-anthropic',
41
+ task: 'evaluate',
42
+ model: 'claude-sonnet-4-20250514',
43
+ provider: 'anthropic',
44
+ },
45
+ {
46
+ caller: 'contradiction-evaluator',
47
+ task: 'evaluate',
48
+ model: 'claude-sonnet-4-20250514',
49
+ provider: 'anthropic',
50
+ },
51
+ {
52
+ caller: 'knowledge-synthesizer-anthropic',
53
+ task: 'synthesize',
54
+ model: 'claude-sonnet-4-20250514',
55
+ provider: 'anthropic',
56
+ },
57
+ {
58
+ caller: 'classifier-anthropic',
59
+ task: 'classify',
60
+ model: 'claude-haiku-4-5-20251001',
61
+ provider: 'anthropic',
62
+ },
63
+ ];
64
+
28
65
  const defaultConfig: RoutingConfig = {
29
- routes: [],
66
+ routes: defaultRoutes,
30
67
  defaultOpenAIModel: 'gpt-4o-mini',
31
68
  defaultAnthropicModel: 'claude-sonnet-4-20250514',
32
69
  };
@@ -0,0 +1,169 @@
1
+ /**
2
+ * OAuth Token Discovery — find Claude Code OAuth tokens on macOS and Linux.
3
+ *
4
+ * Priority:
5
+ * 1. ANTHROPIC_API_KEY env var (explicit, highest priority)
6
+ * 2. Claude Code credentials file (~/.claude/.credentials.json or similar)
7
+ * 3. macOS Keychain (security find-generic-password)
8
+ * 4. Linux GNOME Keyring (secret-tool lookup)
9
+ * 5. null (graceful fallback → use OpenAI or no LLM)
10
+ *
11
+ * Cached for 5 minutes to avoid repeated I/O.
12
+ */
13
+
14
+ import { execFileSync } from 'node:child_process';
15
+ import { readFileSync, existsSync } from 'node:fs';
16
+ import { join } from 'node:path';
17
+ import { homedir, platform } from 'node:os';
18
+
19
+ // ─── Cache ───────────────────────────────────────────────────────────
20
+
21
+ let cachedToken: string | null = null;
22
+ let cacheTimestamp = 0;
23
+ const CACHE_TTL_MS = 5 * 60 * 1000;
24
+
25
+ // ─── Public API ──────────────────────────────────────────────────────
26
+
27
+ /**
28
+ * Discover an Anthropic API token. Returns null if none found.
29
+ * Results cached for 5 minutes.
30
+ */
31
+ export function discoverAnthropicToken(): string | null {
32
+ if (cachedToken && Date.now() - cacheTimestamp < CACHE_TTL_MS) {
33
+ return cachedToken;
34
+ }
35
+
36
+ const token = tryEnvVar() ?? tryCredentialsFile() ?? tryPlatformKeychain();
37
+
38
+ if (token) {
39
+ cachedToken = token;
40
+ cacheTimestamp = Date.now();
41
+ }
42
+
43
+ return token;
44
+ }
45
+
46
+ /**
47
+ * Clear the cached token (for testing or rotation).
48
+ */
49
+ export function resetTokenCache(): void {
50
+ cachedToken = null;
51
+ cacheTimestamp = 0;
52
+ }
53
+
54
+ /**
55
+ * Get discovery source info (for diagnostics).
56
+ */
57
+ export function getTokenSource(): string {
58
+ if (process.env.ANTHROPIC_API_KEY) return 'env:ANTHROPIC_API_KEY';
59
+ if (tryCredentialsFile()) return 'file:credentials';
60
+ if (tryPlatformKeychain()) return `keychain:${platform()}`;
61
+ return 'none';
62
+ }
63
+
64
+ // ─── Discovery Methods ───────────────────────────────────────────────
65
+
66
+ function tryEnvVar(): string | null {
67
+ return process.env.ANTHROPIC_API_KEY ?? null;
68
+ }
69
+
70
+ function tryCredentialsFile(): string | null {
71
+ const candidates = [
72
+ join(homedir(), '.claude', '.credentials.json'),
73
+ join(homedir(), '.claude', 'credentials.json'),
74
+ join(homedir(), '.config', 'claude', 'credentials.json'),
75
+ ];
76
+
77
+ for (const path of candidates) {
78
+ try {
79
+ if (!existsSync(path)) continue;
80
+ const raw = readFileSync(path, 'utf-8');
81
+ const parsed = JSON.parse(raw) as Record<string, unknown>;
82
+
83
+ // Claude Code OAuth format: { claudeAiOauth: { accessToken: "..." } }
84
+ const oauth = parsed.claudeAiOauth as Record<string, unknown> | undefined;
85
+ if (oauth?.accessToken && typeof oauth.accessToken === 'string') {
86
+ return oauth.accessToken;
87
+ }
88
+
89
+ // Alternative: direct token field
90
+ if (parsed.accessToken && typeof parsed.accessToken === 'string') {
91
+ return parsed.accessToken as string;
92
+ }
93
+
94
+ // Alternative: API key field
95
+ if (parsed.apiKey && typeof parsed.apiKey === 'string') {
96
+ return parsed.apiKey as string;
97
+ }
98
+ } catch {
99
+ continue;
100
+ }
101
+ }
102
+
103
+ return null;
104
+ }
105
+
106
+ function tryPlatformKeychain(): string | null {
107
+ const os = platform();
108
+
109
+ if (os === 'darwin') return tryMacKeychain();
110
+ if (os === 'linux') return tryLinuxKeyring();
111
+
112
+ return null;
113
+ }
114
+
115
+ function tryMacKeychain(): string | null {
116
+ try {
117
+ const raw = execFileSync(
118
+ 'security',
119
+ ['find-generic-password', '-s', 'Claude Code-credentials', '-w'],
120
+ { encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'] },
121
+ ).trim();
122
+
123
+ if (!raw) return null;
124
+
125
+ // Try JSON parse
126
+ try {
127
+ const parsed = JSON.parse(raw) as Record<string, unknown>;
128
+ const oauth = parsed.claudeAiOauth as Record<string, unknown> | undefined;
129
+ if (oauth?.accessToken && typeof oauth.accessToken === 'string') {
130
+ return oauth.accessToken;
131
+ }
132
+ } catch {
133
+ // JSON might be truncated — try regex fallback
134
+ const match = raw.match(/"accessToken"\s*:\s*"([^"]+)"/);
135
+ if (match) return match[1];
136
+ }
137
+ } catch {
138
+ // Keychain not available or no entry
139
+ }
140
+
141
+ return null;
142
+ }
143
+
144
+ function tryLinuxKeyring(): string | null {
145
+ try {
146
+ // GNOME Keyring via secret-tool
147
+ const token = execFileSync(
148
+ 'secret-tool',
149
+ ['lookup', 'service', 'Claude Code', 'type', 'credentials'],
150
+ { encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'] },
151
+ ).trim();
152
+
153
+ if (token) {
154
+ // May be JSON or raw token
155
+ try {
156
+ const parsed = JSON.parse(token) as Record<string, unknown>;
157
+ const oauth = parsed.claudeAiOauth as Record<string, unknown> | undefined;
158
+ if (oauth?.accessToken) return oauth.accessToken as string;
159
+ } catch {
160
+ // Treat as raw token
161
+ if (token.length > 20) return token;
162
+ }
163
+ }
164
+ } catch {
165
+ // secret-tool not available or no entry
166
+ }
167
+
168
+ return null;
169
+ }
@@ -34,6 +34,25 @@ export const packManifestSchema = z.object({
34
34
  engine: z.string().optional(),
35
35
  /** Pack dependencies (other pack IDs) */
36
36
  dependencies: z.array(z.string()).optional().default([]),
37
+ /** Capability declarations — what this pack can do and what it needs */
38
+ capabilities: z
39
+ .array(
40
+ z.object({
41
+ id: z
42
+ .string()
43
+ .regex(
44
+ /^[a-z][a-z0-9]*\.[a-z][a-z0-9]*$/,
45
+ 'Capability ID must be domain.action format (e.g., color.validate)',
46
+ ),
47
+ description: z.string().min(1),
48
+ provides: z.array(z.string()),
49
+ requires: z.array(z.string()),
50
+ depends: z.array(z.string()).optional().default([]),
51
+ knowledge: z.array(z.string()).optional().default([]),
52
+ }),
53
+ )
54
+ .optional()
55
+ .default([]),
37
56
  /** Facade definitions (same as plugin manifest) */
38
57
  facades: z
39
58
  .array(