@amodalai/core 0.1.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 (463) hide show
  1. package/LICENSE +21 -0
  2. package/dist/.last_build +0 -0
  3. package/dist/src/amodal-config.d.ts +194 -0
  4. package/dist/src/amodal-config.js +326 -0
  5. package/dist/src/amodal-config.js.map +1 -0
  6. package/dist/src/audit/audit-logger.d.ts +52 -0
  7. package/dist/src/audit/audit-logger.js +137 -0
  8. package/dist/src/audit/audit-logger.js.map +1 -0
  9. package/dist/src/audit/audit-outputs.d.ts +34 -0
  10. package/dist/src/audit/audit-outputs.js +73 -0
  11. package/dist/src/audit/audit-outputs.js.map +1 -0
  12. package/dist/src/audit/audit-redact.d.ts +14 -0
  13. package/dist/src/audit/audit-redact.js +55 -0
  14. package/dist/src/audit/audit-redact.js.map +1 -0
  15. package/dist/src/audit/audit-types.d.ts +122 -0
  16. package/dist/src/audit/audit-types.js +64 -0
  17. package/dist/src/audit/audit-types.js.map +1 -0
  18. package/dist/src/audit/index.d.ts +10 -0
  19. package/dist/src/audit/index.js +10 -0
  20. package/dist/src/audit/index.js.map +1 -0
  21. package/dist/src/eval/eval-cost.d.ts +33 -0
  22. package/dist/src/eval/eval-cost.js +73 -0
  23. package/dist/src/eval/eval-cost.js.map +1 -0
  24. package/dist/src/eval/eval-diff.d.ts +11 -0
  25. package/dist/src/eval/eval-diff.js +97 -0
  26. package/dist/src/eval/eval-diff.js.map +1 -0
  27. package/dist/src/eval/eval-formatter.d.ts +23 -0
  28. package/dist/src/eval/eval-formatter.js +221 -0
  29. package/dist/src/eval/eval-formatter.js.map +1 -0
  30. package/dist/src/eval/eval-judge.d.ts +26 -0
  31. package/dist/src/eval/eval-judge.js +76 -0
  32. package/dist/src/eval/eval-judge.js.map +1 -0
  33. package/dist/src/eval/eval-run-builder.d.ts +25 -0
  34. package/dist/src/eval/eval-run-builder.js +78 -0
  35. package/dist/src/eval/eval-run-builder.js.map +1 -0
  36. package/dist/src/eval/eval-runner.d.ts +36 -0
  37. package/dist/src/eval/eval-runner.js +92 -0
  38. package/dist/src/eval/eval-runner.js.map +1 -0
  39. package/dist/src/eval/eval-session-provider.d.ts +40 -0
  40. package/dist/src/eval/eval-session-provider.js +46 -0
  41. package/dist/src/eval/eval-session-provider.js.map +1 -0
  42. package/dist/src/eval/eval-types.d.ts +146 -0
  43. package/dist/src/eval/eval-types.js +7 -0
  44. package/dist/src/eval/eval-types.js.map +1 -0
  45. package/dist/src/eval/experiment-runner.d.ts +16 -0
  46. package/dist/src/eval/experiment-runner.js +73 -0
  47. package/dist/src/eval/experiment-runner.js.map +1 -0
  48. package/dist/src/eval/experiment-types.d.ts +56 -0
  49. package/dist/src/eval/experiment-types.js +7 -0
  50. package/dist/src/eval/experiment-types.js.map +1 -0
  51. package/dist/src/eval/index.d.ts +22 -0
  52. package/dist/src/eval/index.js +18 -0
  53. package/dist/src/eval/index.js.map +1 -0
  54. package/dist/src/eval/multi-model-runner.d.ts +42 -0
  55. package/dist/src/eval/multi-model-runner.js +70 -0
  56. package/dist/src/eval/multi-model-runner.js.map +1 -0
  57. package/dist/src/eval/platform-eval-client.d.ts +105 -0
  58. package/dist/src/eval/platform-eval-client.js +155 -0
  59. package/dist/src/eval/platform-eval-client.js.map +1 -0
  60. package/dist/src/index.d.ts +41 -0
  61. package/dist/src/index.js +68 -0
  62. package/dist/src/index.js.map +1 -0
  63. package/dist/src/knowledge/index.d.ts +11 -0
  64. package/dist/src/knowledge/index.js +12 -0
  65. package/dist/src/knowledge/index.js.map +1 -0
  66. package/dist/src/knowledge/kb-formatter.d.ts +15 -0
  67. package/dist/src/knowledge/kb-formatter.js +78 -0
  68. package/dist/src/knowledge/kb-formatter.js.map +1 -0
  69. package/dist/src/knowledge/kb-index.d.ts +27 -0
  70. package/dist/src/knowledge/kb-index.js +66 -0
  71. package/dist/src/knowledge/kb-index.js.map +1 -0
  72. package/dist/src/knowledge/kb-types.d.ts +54 -0
  73. package/dist/src/knowledge/kb-types.js +7 -0
  74. package/dist/src/knowledge/kb-types.js.map +1 -0
  75. package/dist/src/knowledge/knowledge-store.d.ts +56 -0
  76. package/dist/src/knowledge/knowledge-store.js +141 -0
  77. package/dist/src/knowledge/knowledge-store.js.map +1 -0
  78. package/dist/src/knowledge/load-knowledge.d.ts +30 -0
  79. package/dist/src/knowledge/load-knowledge.js +161 -0
  80. package/dist/src/knowledge/load-knowledge.js.map +1 -0
  81. package/dist/src/knowledge/propose-kb-update.d.ts +32 -0
  82. package/dist/src/knowledge/propose-kb-update.js +148 -0
  83. package/dist/src/knowledge/propose-kb-update.js.map +1 -0
  84. package/dist/src/knowledge/propose-knowledge.d.ts +34 -0
  85. package/dist/src/knowledge/propose-knowledge.js +163 -0
  86. package/dist/src/knowledge/propose-knowledge.js.map +1 -0
  87. package/dist/src/mcp/index.d.ts +7 -0
  88. package/dist/src/mcp/index.js +7 -0
  89. package/dist/src/mcp/index.js.map +1 -0
  90. package/dist/src/mcp/mcp-manager.d.ts +96 -0
  91. package/dist/src/mcp/mcp-manager.js +192 -0
  92. package/dist/src/mcp/mcp-manager.js.map +1 -0
  93. package/dist/src/packages/config-deps.d.ts +20 -0
  94. package/dist/src/packages/config-deps.js +77 -0
  95. package/dist/src/packages/config-deps.js.map +1 -0
  96. package/dist/src/packages/env-file.d.ts +28 -0
  97. package/dist/src/packages/env-file.js +143 -0
  98. package/dist/src/packages/env-file.js.map +1 -0
  99. package/dist/src/packages/frontmatter.d.ts +28 -0
  100. package/dist/src/packages/frontmatter.js +77 -0
  101. package/dist/src/packages/frontmatter.js.map +1 -0
  102. package/dist/src/packages/index.d.ts +16 -0
  103. package/dist/src/packages/index.js +17 -0
  104. package/dist/src/packages/index.js.map +1 -0
  105. package/dist/src/packages/lock-file.d.ts +35 -0
  106. package/dist/src/packages/lock-file.js +117 -0
  107. package/dist/src/packages/lock-file.js.map +1 -0
  108. package/dist/src/packages/manifest-reader.d.ts +19 -0
  109. package/dist/src/packages/manifest-reader.js +91 -0
  110. package/dist/src/packages/manifest-reader.js.map +1 -0
  111. package/dist/src/packages/merge-engine.d.ts +63 -0
  112. package/dist/src/packages/merge-engine.js +357 -0
  113. package/dist/src/packages/merge-engine.js.map +1 -0
  114. package/dist/src/packages/npm-context.d.ts +56 -0
  115. package/dist/src/packages/npm-context.js +235 -0
  116. package/dist/src/packages/npm-context.js.map +1 -0
  117. package/dist/src/packages/npm-registry.d.ts +35 -0
  118. package/dist/src/packages/npm-registry.js +107 -0
  119. package/dist/src/packages/npm-registry.js.map +1 -0
  120. package/dist/src/packages/package-error.d.ts +16 -0
  121. package/dist/src/packages/package-error.js +17 -0
  122. package/dist/src/packages/package-error.js.map +1 -0
  123. package/dist/src/packages/package-types.d.ts +477 -0
  124. package/dist/src/packages/package-types.js +156 -0
  125. package/dist/src/packages/package-types.js.map +1 -0
  126. package/dist/src/packages/resolver.d.ts +41 -0
  127. package/dist/src/packages/resolver.js +353 -0
  128. package/dist/src/packages/resolver.js.map +1 -0
  129. package/dist/src/platform/config-builder.d.ts +24 -0
  130. package/dist/src/platform/config-builder.js +70 -0
  131. package/dist/src/platform/config-builder.js.map +1 -0
  132. package/dist/src/platform/index.d.ts +8 -0
  133. package/dist/src/platform/index.js +9 -0
  134. package/dist/src/platform/index.js.map +1 -0
  135. package/dist/src/platform/platform-client.d.ts +160 -0
  136. package/dist/src/platform/platform-client.js +486 -0
  137. package/dist/src/platform/platform-client.js.map +1 -0
  138. package/dist/src/platform/platform-types.d.ts +81 -0
  139. package/dist/src/platform/platform-types.js +18 -0
  140. package/dist/src/platform/platform-types.js.map +1 -0
  141. package/dist/src/providers/content-generator/google-to-llm.d.ts +87 -0
  142. package/dist/src/providers/content-generator/google-to-llm.js +226 -0
  143. package/dist/src/providers/content-generator/google-to-llm.js.map +1 -0
  144. package/dist/src/providers/content-generator/index.d.ts +10 -0
  145. package/dist/src/providers/content-generator/index.js +9 -0
  146. package/dist/src/providers/content-generator/index.js.map +1 -0
  147. package/dist/src/providers/content-generator/llm-to-google.d.ts +59 -0
  148. package/dist/src/providers/content-generator/llm-to-google.js +178 -0
  149. package/dist/src/providers/content-generator/llm-to-google.js.map +1 -0
  150. package/dist/src/providers/content-generator/multi-provider-content-generator.d.ts +61 -0
  151. package/dist/src/providers/content-generator/multi-provider-content-generator.js +144 -0
  152. package/dist/src/providers/content-generator/multi-provider-content-generator.js.map +1 -0
  153. package/dist/src/providers/runtime/anthropic-provider.d.ts +18 -0
  154. package/dist/src/providers/runtime/anthropic-provider.js +253 -0
  155. package/dist/src/providers/runtime/anthropic-provider.js.map +1 -0
  156. package/dist/src/providers/runtime/azure-provider.d.ts +25 -0
  157. package/dist/src/providers/runtime/azure-provider.js +206 -0
  158. package/dist/src/providers/runtime/azure-provider.js.map +1 -0
  159. package/dist/src/providers/runtime/bedrock-provider.d.ts +22 -0
  160. package/dist/src/providers/runtime/bedrock-provider.js +276 -0
  161. package/dist/src/providers/runtime/bedrock-provider.js.map +1 -0
  162. package/dist/src/providers/runtime/failover-provider.d.ts +30 -0
  163. package/dist/src/providers/runtime/failover-provider.js +124 -0
  164. package/dist/src/providers/runtime/failover-provider.js.map +1 -0
  165. package/dist/src/providers/runtime/google-provider.d.ts +17 -0
  166. package/dist/src/providers/runtime/google-provider.js +239 -0
  167. package/dist/src/providers/runtime/google-provider.js.map +1 -0
  168. package/dist/src/providers/runtime/index.d.ts +16 -0
  169. package/dist/src/providers/runtime/index.js +16 -0
  170. package/dist/src/providers/runtime/index.js.map +1 -0
  171. package/dist/src/providers/runtime/openai-provider.d.ts +21 -0
  172. package/dist/src/providers/runtime/openai-provider.js +266 -0
  173. package/dist/src/providers/runtime/openai-provider.js.map +1 -0
  174. package/dist/src/providers/runtime/provider-errors.d.ts +39 -0
  175. package/dist/src/providers/runtime/provider-errors.js +50 -0
  176. package/dist/src/providers/runtime/provider-errors.js.map +1 -0
  177. package/dist/src/providers/runtime/provider-factory.d.ts +19 -0
  178. package/dist/src/providers/runtime/provider-factory.js +45 -0
  179. package/dist/src/providers/runtime/provider-factory.js.map +1 -0
  180. package/dist/src/providers/runtime/runtime-provider-types.d.ts +63 -0
  181. package/dist/src/providers/runtime/runtime-provider-types.js +7 -0
  182. package/dist/src/providers/runtime/runtime-provider-types.js.map +1 -0
  183. package/dist/src/providers/runtime/streaming-types.d.ts +40 -0
  184. package/dist/src/providers/runtime/streaming-types.js +7 -0
  185. package/dist/src/providers/runtime/streaming-types.js.map +1 -0
  186. package/dist/src/repo/config-schema.d.ts +238 -0
  187. package/dist/src/repo/config-schema.js +155 -0
  188. package/dist/src/repo/config-schema.js.map +1 -0
  189. package/dist/src/repo/connection-schemas.d.ts +449 -0
  190. package/dist/src/repo/connection-schemas.js +109 -0
  191. package/dist/src/repo/connection-schemas.js.map +1 -0
  192. package/dist/src/repo/connection-types.d.ts +29 -0
  193. package/dist/src/repo/connection-types.js +7 -0
  194. package/dist/src/repo/connection-types.js.map +1 -0
  195. package/dist/src/repo/drift-detector.d.ts +26 -0
  196. package/dist/src/repo/drift-detector.js +66 -0
  197. package/dist/src/repo/drift-detector.js.map +1 -0
  198. package/dist/src/repo/graphql-drift-detector.d.ts +27 -0
  199. package/dist/src/repo/graphql-drift-detector.js +66 -0
  200. package/dist/src/repo/graphql-drift-detector.js.map +1 -0
  201. package/dist/src/repo/graphql-parser.d.ts +30 -0
  202. package/dist/src/repo/graphql-parser.js +125 -0
  203. package/dist/src/repo/graphql-parser.js.map +1 -0
  204. package/dist/src/repo/graphql-surface-parser.d.ts +20 -0
  205. package/dist/src/repo/graphql-surface-parser.js +74 -0
  206. package/dist/src/repo/graphql-surface-parser.js.map +1 -0
  207. package/dist/src/repo/index.d.ts +30 -0
  208. package/dist/src/repo/index.js +29 -0
  209. package/dist/src/repo/index.js.map +1 -0
  210. package/dist/src/repo/local-reader.d.ts +10 -0
  211. package/dist/src/repo/local-reader.js +299 -0
  212. package/dist/src/repo/local-reader.js.map +1 -0
  213. package/dist/src/repo/openapi-parser.d.ts +35 -0
  214. package/dist/src/repo/openapi-parser.js +93 -0
  215. package/dist/src/repo/openapi-parser.js.map +1 -0
  216. package/dist/src/repo/parsers.d.ts +91 -0
  217. package/dist/src/repo/parsers.js +454 -0
  218. package/dist/src/repo/parsers.js.map +1 -0
  219. package/dist/src/repo/platform-reader.d.ts +10 -0
  220. package/dist/src/repo/platform-reader.js +206 -0
  221. package/dist/src/repo/platform-reader.js.map +1 -0
  222. package/dist/src/repo/repo-loader.d.ts +14 -0
  223. package/dist/src/repo/repo-loader.js +25 -0
  224. package/dist/src/repo/repo-loader.js.map +1 -0
  225. package/dist/src/repo/repo-types.d.ts +159 -0
  226. package/dist/src/repo/repo-types.js +17 -0
  227. package/dist/src/repo/repo-types.js.map +1 -0
  228. package/dist/src/repo/spec-syncer.d.ts +30 -0
  229. package/dist/src/repo/spec-syncer.js +85 -0
  230. package/dist/src/repo/spec-syncer.js.map +1 -0
  231. package/dist/src/repo/store-loader.d.ts +19 -0
  232. package/dist/src/repo/store-loader.js +94 -0
  233. package/dist/src/repo/store-loader.js.map +1 -0
  234. package/dist/src/repo/store-schemas.d.ts +313 -0
  235. package/dist/src/repo/store-schemas.js +103 -0
  236. package/dist/src/repo/store-schemas.js.map +1 -0
  237. package/dist/src/repo/store-tool-schema.d.ts +29 -0
  238. package/dist/src/repo/store-tool-schema.js +103 -0
  239. package/dist/src/repo/store-tool-schema.js.map +1 -0
  240. package/dist/src/repo/store-types.d.ts +91 -0
  241. package/dist/src/repo/store-types.js +7 -0
  242. package/dist/src/repo/store-types.js.map +1 -0
  243. package/dist/src/repo/surface-parser.d.ts +17 -0
  244. package/dist/src/repo/surface-parser.js +75 -0
  245. package/dist/src/repo/surface-parser.js.map +1 -0
  246. package/dist/src/repo/tool-loader.d.ts +33 -0
  247. package/dist/src/repo/tool-loader.js +240 -0
  248. package/dist/src/repo/tool-loader.js.map +1 -0
  249. package/dist/src/repo/tool-types.d.ts +205 -0
  250. package/dist/src/repo/tool-types.js +61 -0
  251. package/dist/src/repo/tool-types.js.map +1 -0
  252. package/dist/src/roles/index.d.ts +7 -0
  253. package/dist/src/roles/index.js +8 -0
  254. package/dist/src/roles/index.js.map +1 -0
  255. package/dist/src/roles/role-filter.d.ts +33 -0
  256. package/dist/src/roles/role-filter.js +55 -0
  257. package/dist/src/roles/role-filter.js.map +1 -0
  258. package/dist/src/roles/role-types.d.ts +76 -0
  259. package/dist/src/roles/role-types.js +38 -0
  260. package/dist/src/roles/role-types.js.map +1 -0
  261. package/dist/src/runtime/connection-bridge.d.ts +19 -0
  262. package/dist/src/runtime/connection-bridge.js +103 -0
  263. package/dist/src/runtime/connection-bridge.js.map +1 -0
  264. package/dist/src/runtime/context-compiler.d.ts +35 -0
  265. package/dist/src/runtime/context-compiler.js +183 -0
  266. package/dist/src/runtime/context-compiler.js.map +1 -0
  267. package/dist/src/runtime/default-prompt.d.ts +28 -0
  268. package/dist/src/runtime/default-prompt.js +71 -0
  269. package/dist/src/runtime/default-prompt.js.map +1 -0
  270. package/dist/src/runtime/explore-tool.d.ts +96 -0
  271. package/dist/src/runtime/explore-tool.js +111 -0
  272. package/dist/src/runtime/explore-tool.js.map +1 -0
  273. package/dist/src/runtime/index.d.ts +26 -0
  274. package/dist/src/runtime/index.js +19 -0
  275. package/dist/src/runtime/index.js.map +1 -0
  276. package/dist/src/runtime/output-pipeline.d.ts +62 -0
  277. package/dist/src/runtime/output-pipeline.js +69 -0
  278. package/dist/src/runtime/output-pipeline.js.map +1 -0
  279. package/dist/src/runtime/plan-mode.d.ts +39 -0
  280. package/dist/src/runtime/plan-mode.js +81 -0
  281. package/dist/src/runtime/plan-mode.js.map +1 -0
  282. package/dist/src/runtime/preference-client.d.ts +39 -0
  283. package/dist/src/runtime/preference-client.js +70 -0
  284. package/dist/src/runtime/preference-client.js.map +1 -0
  285. package/dist/src/runtime/preference-detector.d.ts +22 -0
  286. package/dist/src/runtime/preference-detector.js +95 -0
  287. package/dist/src/runtime/preference-detector.js.map +1 -0
  288. package/dist/src/runtime/request-integration.d.ts +18 -0
  289. package/dist/src/runtime/request-integration.js +36 -0
  290. package/dist/src/runtime/request-integration.js.map +1 -0
  291. package/dist/src/runtime/runtime-types.d.ts +48 -0
  292. package/dist/src/runtime/runtime-types.js +7 -0
  293. package/dist/src/runtime/runtime-types.js.map +1 -0
  294. package/dist/src/runtime/session-setup.d.ts +53 -0
  295. package/dist/src/runtime/session-setup.js +90 -0
  296. package/dist/src/runtime/session-setup.js.map +1 -0
  297. package/dist/src/runtime/telemetry-client.d.ts +39 -0
  298. package/dist/src/runtime/telemetry-client.js +87 -0
  299. package/dist/src/runtime/telemetry-client.js.map +1 -0
  300. package/dist/src/runtime/telemetry-hooks.d.ts +47 -0
  301. package/dist/src/runtime/telemetry-hooks.js +115 -0
  302. package/dist/src/runtime/telemetry-hooks.js.map +1 -0
  303. package/dist/src/runtime/token-allocator.d.ts +34 -0
  304. package/dist/src/runtime/token-allocator.js +86 -0
  305. package/dist/src/runtime/token-allocator.js.map +1 -0
  306. package/dist/src/runtime/user-context.d.ts +49 -0
  307. package/dist/src/runtime/user-context.js +135 -0
  308. package/dist/src/runtime/user-context.js.map +1 -0
  309. package/dist/src/sdk.d.ts +57 -0
  310. package/dist/src/sdk.js +377 -0
  311. package/dist/src/sdk.js.map +1 -0
  312. package/dist/src/security/action-gate.d.ts +23 -0
  313. package/dist/src/security/action-gate.js +78 -0
  314. package/dist/src/security/action-gate.js.map +1 -0
  315. package/dist/src/security/field-scrubber.d.ts +27 -0
  316. package/dist/src/security/field-scrubber.js +152 -0
  317. package/dist/src/security/field-scrubber.js.map +1 -0
  318. package/dist/src/security/index.d.ts +14 -0
  319. package/dist/src/security/index.js +15 -0
  320. package/dist/src/security/index.js.map +1 -0
  321. package/dist/src/security/leak-detector.d.ts +23 -0
  322. package/dist/src/security/leak-detector.js +51 -0
  323. package/dist/src/security/leak-detector.js.map +1 -0
  324. package/dist/src/security/output-guard.d.ts +33 -0
  325. package/dist/src/security/output-guard.js +118 -0
  326. package/dist/src/security/output-guard.js.map +1 -0
  327. package/dist/src/security/pattern-scanner.d.ts +19 -0
  328. package/dist/src/security/pattern-scanner.js +66 -0
  329. package/dist/src/security/pattern-scanner.js.map +1 -0
  330. package/dist/src/security/scope-checker.d.ts +27 -0
  331. package/dist/src/security/scope-checker.js +52 -0
  332. package/dist/src/security/scope-checker.js.map +1 -0
  333. package/dist/src/security/scrub-tracker.d.ts +21 -0
  334. package/dist/src/security/scrub-tracker.js +39 -0
  335. package/dist/src/security/scrub-tracker.js.map +1 -0
  336. package/dist/src/security/security-types.d.ts +69 -0
  337. package/dist/src/security/security-types.js +17 -0
  338. package/dist/src/security/security-types.js.map +1 -0
  339. package/dist/src/security/threshold-evaluator.d.ts +13 -0
  340. package/dist/src/security/threshold-evaluator.js +44 -0
  341. package/dist/src/security/threshold-evaluator.js.map +1 -0
  342. package/dist/src/snapshot/index.d.ts +8 -0
  343. package/dist/src/snapshot/index.js +9 -0
  344. package/dist/src/snapshot/index.js.map +1 -0
  345. package/dist/src/snapshot/snapshot-builder.d.ts +37 -0
  346. package/dist/src/snapshot/snapshot-builder.js +152 -0
  347. package/dist/src/snapshot/snapshot-builder.js.map +1 -0
  348. package/dist/src/snapshot/snapshot-loader.d.ts +29 -0
  349. package/dist/src/snapshot/snapshot-loader.js +188 -0
  350. package/dist/src/snapshot/snapshot-loader.js.map +1 -0
  351. package/dist/src/snapshot/snapshot-types.d.ts +1940 -0
  352. package/dist/src/snapshot/snapshot-types.js +145 -0
  353. package/dist/src/snapshot/snapshot-types.js.map +1 -0
  354. package/dist/src/stores/index.d.ts +6 -0
  355. package/dist/src/stores/index.js +7 -0
  356. package/dist/src/stores/index.js.map +1 -0
  357. package/dist/src/stores/store-backend.d.ts +135 -0
  358. package/dist/src/stores/store-backend.js +7 -0
  359. package/dist/src/stores/store-backend.js.map +1 -0
  360. package/dist/src/templates/connections.d.ts +14 -0
  361. package/dist/src/templates/connections.js +7 -0
  362. package/dist/src/templates/connections.js.map +1 -0
  363. package/dist/src/templates/index.d.ts +7 -0
  364. package/dist/src/templates/index.js +8 -0
  365. package/dist/src/templates/index.js.map +1 -0
  366. package/dist/src/templates/template-resolver.d.ts +45 -0
  367. package/dist/src/templates/template-resolver.js +121 -0
  368. package/dist/src/templates/template-resolver.js.map +1 -0
  369. package/dist/src/tool-context.d.ts +33 -0
  370. package/dist/src/tool-context.js +7 -0
  371. package/dist/src/tool-context.js.map +1 -0
  372. package/dist/src/tool-registration.d.ts +14 -0
  373. package/dist/src/tool-registration.js +51 -0
  374. package/dist/src/tool-registration.js.map +1 -0
  375. package/dist/src/tools/amodal-tool-errors.d.ts +24 -0
  376. package/dist/src/tools/amodal-tool-errors.js +28 -0
  377. package/dist/src/tools/amodal-tool-errors.js.map +1 -0
  378. package/dist/src/tools/amodal-tool-names.d.ts +14 -0
  379. package/dist/src/tools/amodal-tool-names.js +15 -0
  380. package/dist/src/tools/amodal-tool-names.js.map +1 -0
  381. package/dist/src/tools/chain-tool-registry.d.ts +20 -0
  382. package/dist/src/tools/chain-tool-registry.js +49 -0
  383. package/dist/src/tools/chain-tool-registry.js.map +1 -0
  384. package/dist/src/tools/chain-tool-types.d.ts +190 -0
  385. package/dist/src/tools/chain-tool-types.js +50 -0
  386. package/dist/src/tools/chain-tool-types.js.map +1 -0
  387. package/dist/src/tools/chain-tool.d.ts +34 -0
  388. package/dist/src/tools/chain-tool.js +294 -0
  389. package/dist/src/tools/chain-tool.js.map +1 -0
  390. package/dist/src/tools/custom-tool-registrar.d.ts +8 -0
  391. package/dist/src/tools/custom-tool-registrar.js +10 -0
  392. package/dist/src/tools/custom-tool-registrar.js.map +1 -0
  393. package/dist/src/tools/definitions/amodal-tools.d.ts +9 -0
  394. package/dist/src/tools/definitions/amodal-tools.js +192 -0
  395. package/dist/src/tools/definitions/amodal-tools.js.map +1 -0
  396. package/dist/src/tools/function-tool-registry.d.ts +22 -0
  397. package/dist/src/tools/function-tool-registry.js +45 -0
  398. package/dist/src/tools/function-tool-registry.js.map +1 -0
  399. package/dist/src/tools/function-tool-types.d.ts +76 -0
  400. package/dist/src/tools/function-tool-types.js +27 -0
  401. package/dist/src/tools/function-tool-types.js.map +1 -0
  402. package/dist/src/tools/function-tool.d.ts +34 -0
  403. package/dist/src/tools/function-tool.js +97 -0
  404. package/dist/src/tools/function-tool.js.map +1 -0
  405. package/dist/src/tools/http-tool-registry.d.ts +20 -0
  406. package/dist/src/tools/http-tool-registry.js +34 -0
  407. package/dist/src/tools/http-tool-registry.js.map +1 -0
  408. package/dist/src/tools/http-tool-types.d.ts +92 -0
  409. package/dist/src/tools/http-tool-types.js +44 -0
  410. package/dist/src/tools/http-tool-types.js.map +1 -0
  411. package/dist/src/tools/http-tool.d.ts +32 -0
  412. package/dist/src/tools/http-tool.js +176 -0
  413. package/dist/src/tools/http-tool.js.map +1 -0
  414. package/dist/src/tools/merge-template.d.ts +33 -0
  415. package/dist/src/tools/merge-template.js +65 -0
  416. package/dist/src/tools/merge-template.js.map +1 -0
  417. package/dist/src/tools/request-tool-types.d.ts +46 -0
  418. package/dist/src/tools/request-tool-types.js +20 -0
  419. package/dist/src/tools/request-tool-types.js.map +1 -0
  420. package/dist/src/tools/request-tool.d.ts +29 -0
  421. package/dist/src/tools/request-tool.js +268 -0
  422. package/dist/src/tools/request-tool.js.map +1 -0
  423. package/dist/src/tools/store-query-tool.d.ts +29 -0
  424. package/dist/src/tools/store-query-tool.js +82 -0
  425. package/dist/src/tools/store-query-tool.js.map +1 -0
  426. package/dist/src/tools/store-write-tool.d.ts +26 -0
  427. package/dist/src/tools/store-write-tool.js +84 -0
  428. package/dist/src/tools/store-write-tool.js.map +1 -0
  429. package/dist/src/tools/tool-definition-types.d.ts +21 -0
  430. package/dist/src/tools/tool-definition-types.js +7 -0
  431. package/dist/src/tools/tool-definition-types.js.map +1 -0
  432. package/dist/src/tools/tool-utils.d.ts +29 -0
  433. package/dist/src/tools/tool-utils.js +66 -0
  434. package/dist/src/tools/tool-utils.js.map +1 -0
  435. package/dist/src/versions/bundle-loader.d.ts +37 -0
  436. package/dist/src/versions/bundle-loader.js +99 -0
  437. package/dist/src/versions/bundle-loader.js.map +1 -0
  438. package/dist/src/versions/dependency-manager.d.ts +54 -0
  439. package/dist/src/versions/dependency-manager.js +132 -0
  440. package/dist/src/versions/dependency-manager.js.map +1 -0
  441. package/dist/src/versions/handler-loader.d.ts +27 -0
  442. package/dist/src/versions/handler-loader.js +62 -0
  443. package/dist/src/versions/handler-loader.js.map +1 -0
  444. package/dist/src/versions/index.d.ts +10 -0
  445. package/dist/src/versions/index.js +11 -0
  446. package/dist/src/versions/index.js.map +1 -0
  447. package/dist/src/versions/version-bundle-types.d.ts +1278 -0
  448. package/dist/src/versions/version-bundle-types.js +207 -0
  449. package/dist/src/versions/version-bundle-types.js.map +1 -0
  450. package/dist/src/versions/version-manager.d.ts +89 -0
  451. package/dist/src/versions/version-manager.js +124 -0
  452. package/dist/src/versions/version-manager.js.map +1 -0
  453. package/dist/src/widgets/index.d.ts +8 -0
  454. package/dist/src/widgets/index.js +8 -0
  455. package/dist/src/widgets/index.js.map +1 -0
  456. package/dist/src/widgets/present-tool.d.ts +21 -0
  457. package/dist/src/widgets/present-tool.js +107 -0
  458. package/dist/src/widgets/present-tool.js.map +1 -0
  459. package/dist/src/widgets/widget-types.d.ts +78 -0
  460. package/dist/src/widgets/widget-types.js +28 -0
  461. package/dist/src/widgets/widget-types.js.map +1 -0
  462. package/dist/tsconfig.tsbuildinfo +1 -0
  463. package/package.json +50 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Amodal Labs, Inc.
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { readFile, readdir } from 'node:fs/promises';
7
+ import * as path from 'node:path';
8
+ import { ZodError } from 'zod';
9
+ import { PackageError } from './package-error.js';
10
+ import { PackageManifestSchema } from './package-types.js';
11
+ /**
12
+ * Read and validate the amodal manifest from an installed package directory.
13
+ */
14
+ export async function readPackageManifest(packageDir) {
15
+ const pkgJsonPath = path.join(packageDir, 'package.json');
16
+ let content;
17
+ try {
18
+ content = await readFile(pkgJsonPath, 'utf-8');
19
+ }
20
+ catch (err) {
21
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
22
+ if (err.code === 'ENOENT') {
23
+ throw new PackageError('NOT_FOUND', `Missing package.json in ${packageDir}`);
24
+ }
25
+ throw new PackageError('PARSE_FAILED', `Failed to read ${pkgJsonPath}`, err);
26
+ }
27
+ let raw;
28
+ try {
29
+ raw = JSON.parse(content);
30
+ }
31
+ catch (err) {
32
+ throw new PackageError('PARSE_FAILED', `Invalid JSON in ${pkgJsonPath}`, err);
33
+ }
34
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
35
+ throw new PackageError('PARSE_FAILED', `package.json is not an object in ${packageDir}`);
36
+ }
37
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
38
+ const pkg = raw;
39
+ const amodal = pkg['amodal'];
40
+ if (!amodal || typeof amodal !== 'object') {
41
+ throw new PackageError('VALIDATION_FAILED', `Missing or invalid "amodal" block in ${pkgJsonPath}`);
42
+ }
43
+ try {
44
+ return PackageManifestSchema.parse(amodal);
45
+ }
46
+ catch (err) {
47
+ if (err instanceof ZodError) {
48
+ const issues = err.issues
49
+ .map((i) => `${i.path.join('.')}: ${i.message}`)
50
+ .join('; ');
51
+ throw new PackageError('VALIDATION_FAILED', `Invalid amodal manifest in ${pkgJsonPath}: ${issues}`, err);
52
+ }
53
+ throw new PackageError('VALIDATION_FAILED', `Manifest validation failed in ${packageDir}`, err);
54
+ }
55
+ }
56
+ /**
57
+ * Read a specific file from a package directory.
58
+ * Returns null if the file doesn't exist.
59
+ */
60
+ export async function readPackageFile(packageDir, filename) {
61
+ const filePath = path.join(packageDir, filename);
62
+ try {
63
+ return await readFile(filePath, 'utf-8');
64
+ }
65
+ catch (err) {
66
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
67
+ if (err.code === 'ENOENT') {
68
+ return null;
69
+ }
70
+ throw new PackageError('NOT_FOUND', `Failed to read ${filePath}`, err);
71
+ }
72
+ }
73
+ /**
74
+ * List all files in a package directory.
75
+ */
76
+ export async function listPackageFiles(packageDir) {
77
+ try {
78
+ const entries = await readdir(packageDir, { withFileTypes: true });
79
+ return entries
80
+ .filter((e) => e.isFile())
81
+ .map((e) => e.name);
82
+ }
83
+ catch (err) {
84
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
85
+ if (err.code === 'ENOENT') {
86
+ return [];
87
+ }
88
+ throw new PackageError('NOT_FOUND', `Failed to list files in ${packageDir}`, err);
89
+ }
90
+ }
91
+ //# sourceMappingURL=manifest-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-reader.js","sourceRoot":"","sources":["../../../src/packages/manifest-reader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,KAAK,CAAC;AAE7B,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAGzD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,UAAkB;IAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC1D,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,uEAAuE;QACvE,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,2BAA2B,UAAU,EAAE,CAAC,CAAC;QAC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EAAE,EAAE,GAAG,CAAC,CAAC;IACpF,CAAC;AACH,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Amodal Labs, Inc.
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import type { AccessConfig } from '../repo/connection-schemas.js';
7
+ import type { ConnectionSpec } from '../repo/connection-schemas.js';
8
+ import type { SurfaceEndpoint } from '../repo/connection-types.js';
9
+ /**
10
+ * Deep merge two objects. Local values win. Arrays are replaced entirely.
11
+ */
12
+ export declare function deepMergeLocalWins(base: Record<string, unknown>, local: Record<string, unknown>): Record<string, unknown>;
13
+ /**
14
+ * Merge a local spec.json override on top of a package base.
15
+ */
16
+ export declare function mergeSpecJson(baseJson: string, localJson: string): ConnectionSpec;
17
+ type ConfirmTier = undefined | true | 'review' | 'never';
18
+ /**
19
+ * Filter endpoints by only/exclude lists from frontmatter.
20
+ */
21
+ export declare function filterEndpoints(endpoints: SurfaceEndpoint[], frontmatter: Record<string, unknown>): SurfaceEndpoint[];
22
+ /**
23
+ * Merge a local surface.md override on top of a package base.
24
+ */
25
+ export declare function mergeSurface(baseMd: string, localMd: string): string;
26
+ /**
27
+ * Return the tighter of two confirmation tiers.
28
+ */
29
+ export declare function tighterConfirm(base: ConfirmTier, local: ConfirmTier): ConfirmTier;
30
+ type FieldPolicy = 'role_gated' | 'retrieve_but_redact' | 'never_retrieve';
31
+ /**
32
+ * Return the tighter of two field restriction policies.
33
+ */
34
+ export declare function tighterPolicy(base: FieldPolicy, local: FieldPolicy): FieldPolicy;
35
+ /**
36
+ * Narrow roles by intersection. undefined means "no restriction" (all roles).
37
+ */
38
+ export declare function narrowRoles(base?: string[], local?: string[]): string[] | undefined;
39
+ /**
40
+ * Merge a local access.json override on top of a package base.
41
+ * Local overrides take precedence — the user's repo is the final word.
42
+ */
43
+ export declare function mergeAccessJson(baseJson: string, localJson: string): AccessConfig;
44
+ /**
45
+ * Extract ### heading sections from markdown content.
46
+ * Returns a Map of heading text → section content (without the heading line).
47
+ * Also returns the preamble (content before the first ### heading).
48
+ */
49
+ export declare function extractHeadingSections(content: string): {
50
+ preamble: string;
51
+ sections: Map<string, string>;
52
+ };
53
+ /**
54
+ * Merge entities.md: local ### sections replace matching base sections.
55
+ * Unmatched base sections pass through.
56
+ */
57
+ export declare function mergeEntities(baseMd: string, localMd: string): string;
58
+ /**
59
+ * Concatenate package base with local additions.
60
+ * Package content first, blank line separator, local body (frontmatter stripped).
61
+ */
62
+ export declare function mergeConcatenation(baseMd: string, localMd: string): string;
63
+ export {};
@@ -0,0 +1,357 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Amodal Labs, Inc.
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { AccessConfigSchema, ConnectionSpecSchema } from '../repo/connection-schemas.js';
7
+ import { parseSurface } from '../repo/surface-parser.js';
8
+ import { parseJsonImport, parseMarkdownFrontmatter, validateSurfaceFrontmatter } from './frontmatter.js';
9
+ import { PackageError } from './package-error.js';
10
+ // --- spec.json merge: deep merge, local wins, arrays replaced ---
11
+ /**
12
+ * Deep merge two objects. Local values win. Arrays are replaced entirely.
13
+ */
14
+ export function deepMergeLocalWins(base, local) {
15
+ const result = { ...base };
16
+ for (const key of Object.keys(local)) {
17
+ const baseVal = base[key];
18
+ const localVal = local[key];
19
+ if (localVal !== null &&
20
+ typeof localVal === 'object' &&
21
+ !Array.isArray(localVal) &&
22
+ baseVal !== null &&
23
+ typeof baseVal === 'object' &&
24
+ !Array.isArray(baseVal)) {
25
+ // Recurse for nested objects
26
+ result[key] = deepMergeLocalWins(
27
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
28
+ baseVal,
29
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
30
+ localVal);
31
+ }
32
+ else {
33
+ // Local wins (arrays replaced entirely)
34
+ result[key] = localVal;
35
+ }
36
+ }
37
+ return result;
38
+ }
39
+ /**
40
+ * Merge a local spec.json override on top of a package base.
41
+ */
42
+ export function mergeSpecJson(baseJson, localJson) {
43
+ const { data: localData } = parseJsonImport(localJson);
44
+ let baseRaw;
45
+ try {
46
+ baseRaw = JSON.parse(baseJson);
47
+ }
48
+ catch (err) {
49
+ throw new PackageError('PARSE_FAILED', 'Invalid JSON in base spec.json', err);
50
+ }
51
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
52
+ const merged = deepMergeLocalWins(baseRaw, localData);
53
+ return ConnectionSpecSchema.parse(merged);
54
+ }
55
+ const CONFIRM_RANK = {
56
+ undefined: 0,
57
+ true: 1,
58
+ review: 2,
59
+ never: 3,
60
+ };
61
+ /**
62
+ * Filter endpoints by only/exclude lists from frontmatter.
63
+ */
64
+ export function filterEndpoints(endpoints, frontmatter) {
65
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
66
+ const only = frontmatter['only'];
67
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
68
+ const exclude = frontmatter['exclude'];
69
+ if (Array.isArray(only) && only.length > 0) {
70
+ const set = new Set(only);
71
+ return endpoints.filter((ep) => set.has(`${ep.method} ${ep.path}`));
72
+ }
73
+ if (Array.isArray(exclude) && exclude.length > 0) {
74
+ const set = new Set(exclude);
75
+ return endpoints.filter((ep) => !set.has(`${ep.method} ${ep.path}`));
76
+ }
77
+ return endpoints;
78
+ }
79
+ const ENDPOINT_HEADING_RE = /^###\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+(\S+)/;
80
+ /**
81
+ * Merge a local surface.md override on top of a package base.
82
+ */
83
+ export function mergeSurface(baseMd, localMd) {
84
+ const { frontmatter, body } = parseMarkdownFrontmatter(localMd);
85
+ if (frontmatter) {
86
+ validateSurfaceFrontmatter(frontmatter);
87
+ }
88
+ // Parse and filter base endpoints
89
+ let baseEndpoints = parseSurface(baseMd);
90
+ if (frontmatter) {
91
+ baseEndpoints = filterEndpoints(baseEndpoints, frontmatter);
92
+ }
93
+ // Build local endpoint sections
94
+ const localSections = new Map();
95
+ let currentKey = null;
96
+ const currentLines = [];
97
+ const nonEndpointLines = [];
98
+ let foundEndpoint = false;
99
+ for (const line of body.split('\n')) {
100
+ const match = ENDPOINT_HEADING_RE.exec(line);
101
+ if (match) {
102
+ if (currentKey) {
103
+ localSections.set(currentKey, currentLines.join('\n').trim());
104
+ currentLines.length = 0;
105
+ }
106
+ currentKey = `${match[1]} ${match[2]}`;
107
+ foundEndpoint = true;
108
+ }
109
+ else if (currentKey) {
110
+ currentLines.push(line);
111
+ }
112
+ else if (!foundEndpoint) {
113
+ // Lines before any ### endpoint heading
114
+ nonEndpointLines.push(line);
115
+ }
116
+ }
117
+ if (currentKey) {
118
+ localSections.set(currentKey, currentLines.join('\n').trim());
119
+ }
120
+ // Build output
121
+ const outputParts = [];
122
+ // Render base endpoints, appending local additions if they match
123
+ for (const ep of baseEndpoints) {
124
+ const key = `${ep.method} ${ep.path}`;
125
+ let section = `### ${ep.method} ${ep.path}`;
126
+ if (ep.description) {
127
+ section += `\n${ep.description}`;
128
+ }
129
+ const localAddition = localSections.get(key);
130
+ if (localAddition) {
131
+ section += `\n${localAddition}`;
132
+ localSections.delete(key);
133
+ }
134
+ outputParts.push(section);
135
+ }
136
+ // Append remaining local sections that didn't match base endpoints
137
+ for (const [key, content] of localSections) {
138
+ let section = `### ${key}`;
139
+ if (content) {
140
+ section += `\n${content}`;
141
+ }
142
+ outputParts.push(section);
143
+ }
144
+ let result = outputParts.join('\n\n');
145
+ // Prepend non-endpoint content from local body
146
+ const preamble = nonEndpointLines.join('\n').trim();
147
+ if (preamble) {
148
+ result = preamble + '\n\n' + result;
149
+ }
150
+ return result.trim();
151
+ }
152
+ // --- access.json merge: additive, restrictions only tighten ---
153
+ function confirmRank(tier) {
154
+ return CONFIRM_RANK[String(tier)] ?? 0;
155
+ }
156
+ /**
157
+ * Return the tighter of two confirmation tiers.
158
+ */
159
+ export function tighterConfirm(base, local) {
160
+ if (confirmRank(local) > confirmRank(base))
161
+ return local;
162
+ return base;
163
+ }
164
+ const POLICY_RANK = {
165
+ role_gated: 0,
166
+ retrieve_but_redact: 1,
167
+ never_retrieve: 2,
168
+ };
169
+ /**
170
+ * Return the tighter of two field restriction policies.
171
+ */
172
+ export function tighterPolicy(base, local) {
173
+ const baseRank = POLICY_RANK[base] ?? 0;
174
+ const localRank = POLICY_RANK[local] ?? 0;
175
+ return localRank > baseRank ? local : base;
176
+ }
177
+ /**
178
+ * Narrow roles by intersection. undefined means "no restriction" (all roles).
179
+ */
180
+ export function narrowRoles(base, local) {
181
+ if (!base)
182
+ return local;
183
+ if (!local)
184
+ return base;
185
+ // Intersection
186
+ const baseSet = new Set(base);
187
+ return local.filter((r) => baseSet.has(r));
188
+ }
189
+ /**
190
+ * Merge a local access.json override on top of a package base.
191
+ * Local overrides take precedence — the user's repo is the final word.
192
+ */
193
+ export function mergeAccessJson(baseJson, localJson) {
194
+ const { data: localData } = parseJsonImport(localJson);
195
+ let baseRaw;
196
+ try {
197
+ baseRaw = JSON.parse(baseJson);
198
+ }
199
+ catch (err) {
200
+ throw new PackageError('PARSE_FAILED', 'Invalid JSON in base access.json', err);
201
+ }
202
+ const base = AccessConfigSchema.parse(baseRaw);
203
+ // Merge endpoints
204
+ const mergedEndpoints = { ...base.endpoints };
205
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
206
+ const localEndpoints = localData['endpoints'];
207
+ if (localEndpoints) {
208
+ for (const [ep, localAccess] of Object.entries(localEndpoints)) {
209
+ const baseAccess = mergedEndpoints[ep];
210
+ if (!baseAccess) {
211
+ // New endpoint — add it directly (local defines new restrictions)
212
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
213
+ mergedEndpoints[ep] = localAccess;
214
+ }
215
+ else {
216
+ // Local override wins — merge base fields, then apply local on top
217
+ mergedEndpoints[ep] = {
218
+ ...baseAccess,
219
+ ...localAccess,
220
+ };
221
+ // If local explicitly omits confirm (undefined), remove it from merged
222
+ if (localAccess.confirm === undefined && 'confirm' in localAccess) {
223
+ delete mergedEndpoints[ep].confirm;
224
+ }
225
+ else if (localAccess.confirm !== undefined) {
226
+ mergedEndpoints[ep].confirm = localAccess.confirm;
227
+ }
228
+ if (localAccess.thresholds) {
229
+ mergedEndpoints[ep].thresholds = [
230
+ ...(baseAccess.thresholds ?? []),
231
+ ...localAccess.thresholds,
232
+ ];
233
+ }
234
+ }
235
+ }
236
+ }
237
+ // Merge field restrictions
238
+ const baseRestrictions = base.fieldRestrictions ?? [];
239
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
240
+ const localRestrictions = (localData['fieldRestrictions'] ?? []);
241
+ const mergedRestrictions = [...baseRestrictions];
242
+ for (const localRestr of localRestrictions) {
243
+ const entity = String(localRestr['entity'] ?? '');
244
+ const field = String(localRestr['field'] ?? '');
245
+ // Find matching base restriction
246
+ const existingIdx = mergedRestrictions.findIndex((r) => r.entity === entity && r.field === field);
247
+ if (existingIdx >= 0) {
248
+ const existing = mergedRestrictions[existingIdx];
249
+ // Local override wins for policy and roles
250
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
251
+ const newPolicy = localRestr['policy'] ?? existing.policy;
252
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
253
+ const newRoles = localRestr['allowedRoles'] ?? existing.allowedRoles;
254
+ mergedRestrictions[existingIdx] = {
255
+ ...existing,
256
+ policy: newPolicy,
257
+ allowedRoles: newRoles,
258
+ };
259
+ }
260
+ else {
261
+ // New restriction — add it
262
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
263
+ mergedRestrictions.push(localRestr);
264
+ }
265
+ }
266
+ const result = {
267
+ ...base,
268
+ endpoints: mergedEndpoints,
269
+ fieldRestrictions: mergedRestrictions.length > 0 ? mergedRestrictions : undefined,
270
+ };
271
+ // Merge delegations if local provides them
272
+ if (localData['delegations']) {
273
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
274
+ result.delegations = localData['delegations'];
275
+ }
276
+ // Merge alternativeLookups additively
277
+ if (localData['alternativeLookups']) {
278
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
279
+ const localLookups = localData['alternativeLookups'];
280
+ result.alternativeLookups = [
281
+ ...(base.alternativeLookups ?? []),
282
+ ...(localLookups ?? []),
283
+ ];
284
+ }
285
+ return result;
286
+ }
287
+ // --- entities.md merge: section-level by ### heading ---
288
+ /**
289
+ * Extract ### heading sections from markdown content.
290
+ * Returns a Map of heading text → section content (without the heading line).
291
+ * Also returns the preamble (content before the first ### heading).
292
+ */
293
+ export function extractHeadingSections(content) {
294
+ const lines = content.split('\n');
295
+ const sections = new Map();
296
+ const preambleLines = [];
297
+ let currentHeading = null;
298
+ const currentLines = [];
299
+ for (const line of lines) {
300
+ const headingMatch = /^###\s+(.+)/.exec(line);
301
+ if (headingMatch) {
302
+ if (currentHeading) {
303
+ sections.set(currentHeading, currentLines.join('\n').trim());
304
+ currentLines.length = 0;
305
+ }
306
+ currentHeading = headingMatch[1].trim();
307
+ }
308
+ else if (currentHeading) {
309
+ currentLines.push(line);
310
+ }
311
+ else {
312
+ preambleLines.push(line);
313
+ }
314
+ }
315
+ if (currentHeading) {
316
+ sections.set(currentHeading, currentLines.join('\n').trim());
317
+ }
318
+ return { preamble: preambleLines.join('\n').trim(), sections };
319
+ }
320
+ /**
321
+ * Merge entities.md: local ### sections replace matching base sections.
322
+ * Unmatched base sections pass through.
323
+ */
324
+ export function mergeEntities(baseMd, localMd) {
325
+ const { body } = parseMarkdownFrontmatter(localMd);
326
+ const baseParsed = extractHeadingSections(baseMd);
327
+ const localParsed = extractHeadingSections(body);
328
+ // Start with base sections, replace with local where present
329
+ const mergedSections = new Map(baseParsed.sections);
330
+ for (const [heading, content] of localParsed.sections) {
331
+ mergedSections.set(heading, content);
332
+ }
333
+ const parts = [];
334
+ if (baseParsed.preamble) {
335
+ parts.push(baseParsed.preamble);
336
+ }
337
+ for (const [heading, content] of mergedSections) {
338
+ parts.push(`### ${heading}\n${content}`);
339
+ }
340
+ return parts.join('\n\n').trim();
341
+ }
342
+ // --- Concatenation merge (rules, skills, automations, knowledge) ---
343
+ /**
344
+ * Concatenate package base with local additions.
345
+ * Package content first, blank line separator, local body (frontmatter stripped).
346
+ */
347
+ export function mergeConcatenation(baseMd, localMd) {
348
+ const { body } = parseMarkdownFrontmatter(localMd);
349
+ const baseContent = baseMd.trim();
350
+ const localContent = body.trim();
351
+ if (!localContent)
352
+ return baseContent;
353
+ if (!baseContent)
354
+ return localContent;
355
+ return `${baseContent}\n\n${localContent}`;
356
+ }
357
+ //# sourceMappingURL=merge-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-engine.js","sourceRoot":"","sources":["../../../src/packages/merge-engine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,kBAAkB,EAAE,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AAGvF,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAC,eAAe,EAAE,wBAAwB,EAAE,0BAA0B,EAAC,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,mEAAmE;AAEnE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAA6B,EAC7B,KAA8B;IAE9B,MAAM,MAAM,GAA4B,EAAC,GAAG,IAAI,EAAC,CAAC;IAElD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAE5B,IACE,QAAQ,KAAK,IAAI;YACjB,OAAO,QAAQ,KAAK,QAAQ;YAC5B,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACxB,OAAO,KAAK,IAAI;YAChB,OAAO,OAAO,KAAK,QAAQ;YAC3B,C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AO,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC;AAED,sEAAsE;AAEtE;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAAe;IAChE,MAAM,EAAC,IAAI,EAAC,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAClC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAEjC,IAAI,CAAC,YAAY;QAAE,OAAO,WAAW,CAAC;IACtC,IAAI,CAAC,WAAW;QAAE,OAAO,YAAY,CAAC;IAEtC,OAAO,GAAG,WAAW,OAAO,YAAY,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Amodal Labs, Inc.
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import type { LockFile, PackageRef } from './package-types.js';
7
+ /**
8
+ * Paths for the hidden npm context.
9
+ */
10
+ export interface NpmContextPaths {
11
+ root: string;
12
+ npmDir: string;
13
+ npmrc: string;
14
+ packageJson: string;
15
+ nodeModules: string;
16
+ }
17
+ /**
18
+ * Get the standard paths for the hidden npm context.
19
+ */
20
+ export declare function getNpmContextPaths(repoPath: string): NpmContextPaths;
21
+ /**
22
+ * Ensure the hidden npm context exists. Idempotent.
23
+ */
24
+ export declare function ensureNpmContext(repoPath: string, registryUrl?: string): Promise<NpmContextPaths>;
25
+ /**
26
+ * Run `npm install` for a specific package.
27
+ */
28
+ export declare function npmInstall(paths: NpmContextPaths, npmName: string, version?: string, timeout?: number): Promise<{
29
+ version: string;
30
+ integrity: string;
31
+ }>;
32
+ /**
33
+ * Run `npm install` to restore all packages from package.json.
34
+ */
35
+ export declare function npmInstallAll(paths: NpmContextPaths, timeout?: number): Promise<void>;
36
+ /**
37
+ * Run `npm uninstall` for a specific package.
38
+ */
39
+ export declare function npmUninstall(paths: NpmContextPaths, npmName: string, timeout?: number): Promise<void>;
40
+ /**
41
+ * Generate package.json dependencies from a lock file.
42
+ */
43
+ export declare function generatePackageJson(lockFile: LockFile): Record<string, unknown>;
44
+ /**
45
+ * Create or repair a symlink from the clean path to the npm node_modules path.
46
+ */
47
+ export declare function ensureSymlink(paths: NpmContextPaths, ref: PackageRef): Promise<string>;
48
+ /**
49
+ * Create symlinks for all packages in a lock file.
50
+ */
51
+ export declare function ensureAllSymlinks(paths: NpmContextPaths, lockFile: LockFile): Promise<void>;
52
+ /**
53
+ * Get the resolved package directory for an installed package.
54
+ * Returns null if the package is not installed or the symlink is broken.
55
+ */
56
+ export declare function getPackageDir(repoPath: string, ref: PackageRef): Promise<string | null>;