@inneranimalmedia/agentsam-sdk 2.6.1 → 2.6.3

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 (507) hide show
  1. package/AGENTSAM.md +45 -1
  2. package/README.md +80 -0
  3. package/apps/README.md +34 -0
  4. package/apps/cad-creator/README.md +728 -0
  5. package/apps/cad-creator/shared/cad/package.json +19 -0
  6. package/apps/cad-creator/shared/cad/src/domain/operations.ts +7 -0
  7. package/apps/cad-creator/shared/cad/src/domain/project-contract.d.ts +3 -0
  8. package/apps/cad-creator/shared/cad/src/domain/project-contract.js +75 -0
  9. package/apps/cad-creator/shared/cad/src/domain/project-tools.d.ts +1 -0
  10. package/apps/cad-creator/shared/cad/src/domain/project-tools.js +24 -0
  11. package/apps/cad-creator/shared/cad/src/domain/validation.ts +191 -0
  12. package/apps/cad-creator/shared/cad/src/index.ts +4 -0
  13. package/apps/cad-creator/shared/cad/src/robotics/types.ts +232 -0
  14. package/apps/cad-creator/shared/cad/src/types.ts +507 -0
  15. package/apps/cad-creator/shared/cad/tsconfig.json +14 -0
  16. package/docs/AUTH_IDENTITY_CONTRACT.md +25 -27
  17. package/docs/AUTORAG.md +58 -0
  18. package/docs/BRAND_INTELLIGENCE.md +30 -0
  19. package/docs/CLI_SHELL.md +4 -2
  20. package/docs/CMS_CONTEXTUAL_COMPOSER.md +38 -0
  21. package/docs/MERKLE.md +4 -0
  22. package/docs/PROJECT_CONFIG.md +3 -0
  23. package/docs/REPOSITORY_KNOWLEDGE.md +2 -0
  24. package/docs/SDK_WORKER.md +4 -3
  25. package/docs/THEME_REFINERY.md +120 -0
  26. package/docs/architecture/PROVIDER-TOOLS-AND-COMPACTION.md +60 -0
  27. package/docs/architecture/STORAGE.md +87 -0
  28. package/docs/cad-project-tools.md +69 -0
  29. package/docs/cms-scaffolding-pattern-reference.md +73 -0
  30. package/docs/plans/AGENTSAM-INTERACTIVE-UI-REQUIREMENTS-codex-tui-20260919.md +113 -0
  31. package/docs/plans/AGENTSAM-INTERACTIVE-UI-REQUIREMENTS.md +85 -0
  32. package/docs/plans/AGENTSAM-MCP-CLIENT-2026-09-19.md +181 -0
  33. package/docs/plans/ASBD-PORTABLE-WORKGRAPH-UI-DEFERRED.md +34 -0
  34. package/docs/plans/ASTRA-BRIEF-2026-09-18.md +258 -0
  35. package/docs/plans/MULTI-AGENT-SPRINTS-2026-09-19.md +373 -0
  36. package/docs/plans/NEXT-AGENT-HANDOFF.md +167 -0
  37. package/docs/plans/RECONCILIATION-2026-09-19.md +178 -0
  38. package/docs/plugins.md +43 -0
  39. package/docs/tools/README.md +57 -0
  40. package/docs/tools/agent-and-orchestration.md +49 -0
  41. package/docs/tools/browser-and-research.md +46 -0
  42. package/docs/tools/cloudflare-platform.md +32 -0
  43. package/docs/tools/cms.md +25 -0
  44. package/docs/tools/communications.md +41 -0
  45. package/docs/tools/database-and-storage.md +62 -0
  46. package/docs/tools/design-and-media.md +64 -0
  47. package/docs/tools/filesystem-and-code.md +55 -0
  48. package/docs/tools/github.md +56 -0
  49. package/docs/tools/integrations-and-misc.md +16 -0
  50. package/docs/tools/memory.md +21 -0
  51. package/docs/tools/terminal-and-execution.md +29 -0
  52. package/docs/tools/tickets-and-platform.md +30 -0
  53. package/migrations/d1/0001_agentsam_plugin_runtime.sql +177 -0
  54. package/migrations/d1/0002_agentsam_ticket_ownership.sql +8 -0
  55. package/migrations/d1/0002_dynamic_model_policies.sql +23 -0
  56. package/migrations/d1/0003_expand_tool_handler_families.sql +18 -0
  57. package/migrations/d1/0004_project_aware_retrieval_lanes.sql +24 -0
  58. package/migrations/d1/0005_portable_knowledge_identity.sql +104 -0
  59. package/migrations/d1/0006_repair_ops_trail_account_scope.sql +14 -0
  60. package/migrations/d1/0007_repair_ops_trail_agent_run_account.sql +13 -0
  61. package/migrations/d1/0008_backfill_knowledge_run_legacy_tenant.sql +14 -0
  62. package/migrations/d1/0009_normalize_cloudflare_plugin_installations.sql +137 -0
  63. package/migrations/runtime/0001_cli_runtime.sql +67 -0
  64. package/migrations/runtime/0002_project_sessions.sql +15 -0
  65. package/migrations/runtime/0003_provider_continuations.sql +8 -0
  66. package/package.json +92 -12
  67. package/packages/agentsam-brand/README.md +21 -0
  68. package/packages/agentsam-brand/package.json +22 -0
  69. package/packages/agentsam-brand/src/contract.js +59 -0
  70. package/packages/agentsam-brand/src/extract.js +126 -0
  71. package/packages/agentsam-brand/src/goap-actions.js +73 -0
  72. package/packages/agentsam-brand/src/index.js +48 -0
  73. package/packages/agentsam-brand/src/plan.js +115 -0
  74. package/packages/agentsam-brand/src/resolve.js +139 -0
  75. package/packages/agentsam-brand/src/scan.js +250 -0
  76. package/packages/agentsam-brand/test/brand-scan.test.mjs +106 -0
  77. package/packages/agentsam-contracts/README.md +23 -0
  78. package/packages/agentsam-contracts/package.json +32 -0
  79. package/packages/agentsam-contracts/src/adapter.ts +25 -0
  80. package/packages/agentsam-contracts/src/agent.ts +35 -0
  81. package/packages/agentsam-contracts/src/artifacts.ts +33 -0
  82. package/packages/agentsam-contracts/src/authority.ts +29 -0
  83. package/packages/agentsam-contracts/src/context.ts +16 -0
  84. package/packages/agentsam-contracts/src/errors.ts +46 -0
  85. package/packages/agentsam-contracts/src/events.ts +47 -0
  86. package/packages/agentsam-contracts/src/execution.ts +50 -0
  87. package/packages/agentsam-contracts/src/hooks.ts +40 -0
  88. package/packages/agentsam-contracts/src/identity.ts +16 -0
  89. package/packages/agentsam-contracts/src/index.ts +14 -0
  90. package/packages/agentsam-contracts/src/models.ts +9 -0
  91. package/packages/agentsam-contracts/src/providers.ts +33 -0
  92. package/packages/agentsam-contracts/src/repository.ts +64 -0
  93. package/packages/agentsam-contracts/src/tools.ts +98 -0
  94. package/packages/agentsam-contracts/test/contracts.test.mjs +16 -0
  95. package/packages/agentsam-contracts/test/errors-catalog.test.mjs +25 -0
  96. package/packages/agentsam-contracts/test/repository.test.mjs +18 -0
  97. package/packages/agentsam-contracts/tsconfig.json +12 -0
  98. package/packages/agentsam-errors/package.json +17 -0
  99. package/packages/agentsam-errors/src/adapters/anthropic.js +15 -0
  100. package/packages/agentsam-errors/src/adapters/cad.js +109 -0
  101. package/packages/agentsam-errors/src/adapters/cloudflare.js +21 -0
  102. package/packages/agentsam-errors/src/adapters/cursor.js +4 -0
  103. package/packages/agentsam-errors/src/adapters/device.js +38 -0
  104. package/packages/agentsam-errors/src/adapters/docker.js +28 -0
  105. package/packages/agentsam-errors/src/adapters/gcp.js +14 -0
  106. package/packages/agentsam-errors/src/adapters/github.js +22 -0
  107. package/packages/agentsam-errors/src/adapters/google.js +17 -0
  108. package/packages/agentsam-errors/src/adapters/index.js +55 -0
  109. package/packages/agentsam-errors/src/adapters/internal.js +40 -0
  110. package/packages/agentsam-errors/src/adapters/oauth.js +24 -0
  111. package/packages/agentsam-errors/src/adapters/openai.js +17 -0
  112. package/packages/agentsam-errors/src/adapters/process.js +35 -0
  113. package/packages/agentsam-errors/src/adapters/provider.js +114 -0
  114. package/packages/agentsam-errors/src/envelope.js +186 -0
  115. package/packages/agentsam-errors/src/error.js +24 -0
  116. package/packages/agentsam-errors/src/fingerprint.js +35 -0
  117. package/packages/agentsam-errors/src/index.js +10 -0
  118. package/packages/agentsam-errors/src/normalize.js +30 -0
  119. package/packages/agentsam-errors/src/redaction.js +52 -0
  120. package/packages/agentsam-errors/src/render.js +16 -0
  121. package/packages/agentsam-errors/src/retry.js +10 -0
  122. package/packages/agentsam-errors/src/transport.js +52 -0
  123. package/packages/agentsam-errors/src/vocabulary.js +320 -0
  124. package/packages/agentsam-errors/test/envelope.test.mjs +70 -0
  125. package/packages/agentsam-errors/test/providers.test.mjs +99 -0
  126. package/packages/agentsam-errors/test/redaction.test.mjs +21 -0
  127. package/packages/agentsam-errors/test/runtime-cad-device.test.mjs +76 -0
  128. package/packages/agentsam-errors/test/transport.test.mjs +46 -0
  129. package/packages/agentsam-knowledge/package.json +15 -0
  130. package/packages/agentsam-knowledge/src/autorag/index.js +64 -0
  131. package/packages/agentsam-knowledge/src/backends/index.js +26 -0
  132. package/packages/agentsam-knowledge/src/index.js +3 -0
  133. package/packages/agentsam-knowledge/src/providers/index.js +95 -0
  134. package/packages/agentsam-knowledge/test/autorag.test.mjs +42 -0
  135. package/packages/agentsam-nav/README.md +40 -0
  136. package/packages/agentsam-nav/dist/Nav.d.ts +43 -0
  137. package/packages/agentsam-nav/dist/NavCollapsible.d.ts +10 -0
  138. package/packages/agentsam-nav/dist/NavContent.d.ts +2 -0
  139. package/packages/agentsam-nav/dist/NavFooter.d.ts +2 -0
  140. package/packages/agentsam-nav/dist/NavGroup.d.ts +3 -0
  141. package/packages/agentsam-nav/dist/NavHeader.d.ts +2 -0
  142. package/packages/agentsam-nav/dist/NavMenu.d.ts +22 -0
  143. package/packages/agentsam-nav/dist/NavProvider.d.ts +35 -0
  144. package/packages/agentsam-nav/dist/NavTrigger.d.ts +2 -0
  145. package/packages/agentsam-nav/dist/Surfaces.d.ts +41 -0
  146. package/packages/agentsam-nav/dist/browser.d.ts +11 -0
  147. package/packages/agentsam-nav/dist/browser.global.js +132 -0
  148. package/packages/agentsam-nav/dist/browser.js +613 -0
  149. package/packages/agentsam-nav/dist/contracts.d.ts +76 -0
  150. package/packages/agentsam-nav/dist/index.d.ts +11 -0
  151. package/packages/agentsam-nav/dist/index.js +614 -0
  152. package/packages/agentsam-nav/dist/legacy.css +83 -0
  153. package/packages/agentsam-nav/dist/shell.css +113 -0
  154. package/packages/agentsam-nav/dist/theme.css +113 -0
  155. package/packages/agentsam-nav/dist/utils.d.ts +1 -0
  156. package/packages/agentsam-nav/package.json +43 -0
  157. package/packages/agentsam-queue-control/README.md +107 -0
  158. package/packages/agentsam-queue-control/package.json +31 -0
  159. package/packages/agentsam-queue-control/schemas/job-envelope.schema.json +56 -0
  160. package/packages/agentsam-queue-control/src/adapters/cloudflare.js +152 -0
  161. package/packages/agentsam-queue-control/src/adapters/memory.js +38 -0
  162. package/packages/agentsam-queue-control/src/contracts.js +130 -0
  163. package/packages/agentsam-queue-control/src/control-plane.js +141 -0
  164. package/packages/agentsam-queue-control/src/dispatch.js +43 -0
  165. package/packages/agentsam-queue-control/src/index.js +7 -0
  166. package/packages/agentsam-queue-control/src/policy.js +88 -0
  167. package/packages/agentsam-queue-control/src/topology.js +66 -0
  168. package/packages/agentsam-queue-control/test/queue-control.test.mjs +100 -0
  169. package/packages/agentsam-repository/src/goap.js +718 -0
  170. package/packages/agentsam-repository/src/goap.js.bak-20260922011251 +670 -0
  171. package/packages/agentsam-repository/src/index.js +5 -0
  172. package/packages/agentsam-repository/src/merkle/cloudflare-persistence.js +2 -2
  173. package/packages/agentsam-repository/src/tickets.js +184 -0
  174. package/packages/agentsam-repository/src/work-tracking.js +199 -0
  175. package/packages/agentsam-repository/src/workspace-state.js +176 -0
  176. package/packages/agentsam-repository/test/goap-tickets-workspace-state.test.mjs +152 -0
  177. package/packages/connectors/cloudflare/src/index.js +297 -15
  178. package/packages/connectors/cloudflare/src/owner.js +43 -40
  179. package/packages/connectors/cloudflare/src/routes.js +167 -26
  180. package/packages/connectors/cloudflare/tests/connector.test.mjs +112 -2
  181. package/packages/heuristic-theme/README.md +11 -0
  182. package/packages/heuristic-theme/package.json +25 -0
  183. package/packages/heuristic-theme/src/index.js +2 -0
  184. package/packages/heuristic-theme/src/registry.js +36 -0
  185. package/packages/heuristic-theme/src/theme.js +41 -0
  186. package/packages/heuristic-theme/test/theme.test.mjs +26 -0
  187. package/packages/identity/.agentsam/features/oauth-login-portal/agentsam.feature.json +64 -0
  188. package/packages/identity/.agentsam/features/oauth-login-portal/providers.json +96 -0
  189. package/packages/identity/.agentsam/features/oauth-login-portal/resources.json +47 -0
  190. package/packages/identity/.agentsam/features/oauth-login-portal/routes.json +74 -0
  191. package/packages/identity/.agentsam/features/oauth-login-portal/ui.json +35 -0
  192. package/packages/identity/package.json +4 -3
  193. package/packages/identity/src/adapters/cloudflare-d1/ids.js +4 -0
  194. package/packages/identity/src/adapters/cloudflare-d1/index.js +39 -1
  195. package/packages/identity/src/contracts/auth-config.js +23 -40
  196. package/packages/identity/src/contracts/provider.js +3 -2
  197. package/packages/identity/src/frontend/auth-portal/pages/login.html +7 -0
  198. package/packages/identity/src/index.js +2 -0
  199. package/packages/identity/src/oauth/credentials.js +13 -0
  200. package/packages/identity/src/oauth/iam-platform.js +5 -5
  201. package/packages/identity/src/providers/cloudflare/index.js +19 -0
  202. package/packages/identity/src/providers/cloudflare/mapper.js +21 -0
  203. package/packages/identity/src/providers/cloudflare/oauth.js +48 -0
  204. package/packages/identity/src/providers/cloudflare/profile.js +28 -0
  205. package/packages/identity/src/providers/index.js +18 -2
  206. package/packages/identity/src/server/identity-service.js +13 -3
  207. package/packages/identity/src/server/worker-router.js +63 -8
  208. package/packages/identity/tests/auth-config.test.mjs +14 -23
  209. package/packages/identity/tests/identity-service.test.mjs +15 -0
  210. package/packages/providers/completeful/README.md +38 -0
  211. package/packages/providers/completeful/package.json +29 -0
  212. package/packages/providers/completeful/src/client.js +162 -0
  213. package/packages/providers/completeful/src/events.js +49 -0
  214. package/packages/providers/completeful/src/index.js +22 -0
  215. package/packages/providers/completeful/src/tools.js +579 -0
  216. package/packages/providers/completeful/src/webhooks.js +55 -0
  217. package/packages/providers/completeful/test/provider.test.mjs +196 -0
  218. package/packages/theme-church-site/README.md +10 -0
  219. package/packages/theme-church-site/package.json +30 -0
  220. package/packages/theme-church-site/src/harvest.json +14 -0
  221. package/packages/theme-church-site/src/index.js +84 -0
  222. package/packages/theme-church-site/test/theme.test.mjs +19 -0
  223. package/packages/theme-companions-site/README.md +10 -0
  224. package/packages/theme-companions-site/package.json +30 -0
  225. package/packages/theme-companions-site/src/harvest.json +12 -0
  226. package/packages/theme-companions-site/src/index.js +82 -0
  227. package/packages/theme-companions-site/test/theme.test.mjs +19 -0
  228. package/packages/theme-floors-site/README.md +10 -0
  229. package/packages/theme-floors-site/package.json +30 -0
  230. package/packages/theme-floors-site/src/harvest.json +14 -0
  231. package/packages/theme-floors-site/src/index.js +82 -0
  232. package/packages/theme-floors-site/test/theme.test.mjs +19 -0
  233. package/packages/theme-fuelnfree-site/README.md +10 -0
  234. package/packages/theme-fuelnfree-site/package.json +30 -0
  235. package/packages/theme-fuelnfree-site/src/harvest.json +13 -0
  236. package/packages/theme-fuelnfree-site/src/index.js +81 -0
  237. package/packages/theme-fuelnfree-site/test/theme.test.mjs +19 -0
  238. package/packages/theme-handyman-site/README.md +10 -0
  239. package/packages/theme-handyman-site/package.json +30 -0
  240. package/packages/theme-handyman-site/src/harvest.json +10 -0
  241. package/packages/theme-handyman-site/src/index.js +83 -0
  242. package/packages/theme-handyman-site/test/theme.test.mjs +19 -0
  243. package/packages/theme-insurance-site/README.md +10 -0
  244. package/packages/theme-insurance-site/package.json +30 -0
  245. package/packages/theme-insurance-site/src/harvest.json +10 -0
  246. package/packages/theme-insurance-site/src/index.js +83 -0
  247. package/packages/theme-insurance-site/test/theme.test.mjs +19 -0
  248. package/packages/theme-shinshu-site/README.md +10 -0
  249. package/packages/theme-shinshu-site/package.json +30 -0
  250. package/packages/theme-shinshu-site/src/harvest.json +12 -0
  251. package/packages/theme-shinshu-site/src/index.js +83 -0
  252. package/packages/theme-shinshu-site/test/theme.test.mjs +19 -0
  253. package/packages/work-graph/README.md +49 -0
  254. package/packages/work-graph/package.json +19 -0
  255. package/packages/work-graph/prototype/README.md +32 -0
  256. package/packages/work-graph/prototype/data/demo-workgraph.js +47 -0
  257. package/packages/work-graph/prototype/renderers/timeline-model.js +21 -0
  258. package/packages/work-graph/prototype/renderers/workgraph-runtime.js +38 -0
  259. package/packages/work-graph/prototype-gnantt.html +655 -0
  260. package/packages/work-graph/src/adapters/business/projects.js +23 -0
  261. package/packages/work-graph/src/adapters/engineering/git.js +22 -0
  262. package/packages/work-graph/src/adapters/engineering/mcp.js +22 -0
  263. package/packages/work-graph/src/index.js +76 -0
  264. package/packages/work-graph/src/renderers/gantt-model.js +11 -0
  265. package/packages/work-graph/src/renderers/timeline.js +16 -0
  266. package/packages/work-graph/test/work-graph.test.mjs +37 -0
  267. package/protocol/README.md +12 -0
  268. package/protocol/capabilities/cloudflare-cpu-audit-input.schema.json +30 -6
  269. package/protocol/capabilities/cloudflare-cpu-profile-input.schema.json +18 -4
  270. package/protocol/capabilities/cloudflare-wrangler-native-input.schema.json +59 -10
  271. package/protocol/capabilities/knowledge-search-input.schema.json +35 -0
  272. package/protocol/capabilities/manifest.json +163 -1
  273. package/protocol/capabilities/repository-audit-input.schema.json +39 -6
  274. package/protocol/capabilities/repository-snapshot-input.schema.json +15 -3
  275. package/protocol/capabilities/terminal-exec-input.schema.json +55 -0
  276. package/protocol/commerce/catalog.v1.json +50 -0
  277. package/protocol/errors/error-catalog.json +164 -0
  278. package/protocol/errors/error-envelope.schema.json +544 -0
  279. package/protocol/features/README.md +57 -0
  280. package/protocol/features/agentsam.feature.v1.schema.json +290 -0
  281. package/protocol/features/catalog.json +65 -0
  282. package/protocol/features/examples/provider-resend.feature.json +17 -0
  283. package/protocol/go/agentsam-go-runtime.v1.json +17 -0
  284. package/protocol/knowledge/LIFECYCLE.md +140 -0
  285. package/protocol/knowledge/README.md +4 -0
  286. package/protocol/presets/catalog.json +128 -19
  287. package/protocol/rpc/v1/errors.proto +24 -0
  288. package/protocol/theme-refinery/d1-reconciliation.md +48 -0
  289. package/protocol/theme-refinery/product-metadata.schema.json +27 -0
  290. package/protocol/theme-refinery/receipts/products-registry-batch-20260924.json +318 -0
  291. package/protocol/theme-refinery/receipts/theme-harvest-20260924.json +472 -0
  292. package/protocol/theme-refinery/reconciliation-receipt.schema.json +83 -0
  293. package/services/cad/server.py +249 -2
  294. package/src/agent/capability-adapter.js +15 -5
  295. package/src/agent/index.js +2 -1
  296. package/src/agent/model-turn.js +51 -0
  297. package/src/agent/responses-runner.js +304 -38
  298. package/src/capabilities/index.js +1 -0
  299. package/src/capabilities/terminal-exec.js +78 -0
  300. package/src/cli.js +129 -31
  301. package/src/cloudflare/index.js +6 -0
  302. package/src/cloudflare/runtime-status.js +393 -0
  303. package/src/cloudflare/wrangler.js +17 -1
  304. package/src/commands/account-auth.js +1 -1
  305. package/src/commands/app.js +106 -0
  306. package/src/commands/autorag.js +77 -0
  307. package/src/commands/brand.js +293 -0
  308. package/src/commands/cad.js +1 -0
  309. package/src/commands/connections.js +126 -29
  310. package/src/commands/context-economics.js +8 -0
  311. package/src/commands/db.js +7 -0
  312. package/src/commands/deploy.js +2 -2
  313. package/src/commands/env.js +5 -4
  314. package/src/commands/eval.js +209 -14
  315. package/src/commands/go.js +365 -0
  316. package/src/commands/goap.js +176 -0
  317. package/src/commands/identity-init.js +27 -3
  318. package/src/commands/identity-protocol.js +195 -0
  319. package/src/commands/knowledge.js +64 -5
  320. package/src/commands/mcp.js +341 -0
  321. package/src/commands/merkle-persist.js +3 -1
  322. package/src/commands/merkle.js +18 -3
  323. package/src/commands/models.js +109 -23
  324. package/src/commands/plugins.js +175 -0
  325. package/src/commands/preferences.js +28 -8
  326. package/src/commands/product.js +53 -10
  327. package/src/commands/providers.js +389 -0
  328. package/src/commands/resume.js +9 -5
  329. package/src/commands/runtime-status.js +154 -0
  330. package/src/commands/shell.js +469 -54
  331. package/src/commands/status.js +82 -7
  332. package/src/commands/tunnel.js +228 -195
  333. package/src/commands/whoami.js +115 -22
  334. package/src/context/budget.js +6 -0
  335. package/src/context/index.js +2 -1
  336. package/src/context/project-card.js +75 -0
  337. package/src/errors/contract.js +34 -211
  338. package/src/errors/diagnostic.js +95 -50
  339. package/src/errors/index.js +6 -13
  340. package/src/eval/index.js +6 -0
  341. package/src/eval/live.js +439 -0
  342. package/src/features/resolve.js +242 -0
  343. package/src/go/build.js +108 -0
  344. package/src/go/cloudflare.js +207 -0
  345. package/src/go/contract.js +139 -0
  346. package/src/go/discover.js +96 -0
  347. package/src/go/index.js +13 -0
  348. package/src/go/receipts.js +77 -0
  349. package/src/go/registry.js +223 -0
  350. package/src/go/verify.js +31 -0
  351. package/src/index.js +100 -1
  352. package/src/knowledge/config.js +13 -5
  353. package/src/knowledge/engine.js +23 -8
  354. package/src/knowledge/index.js +1 -0
  355. package/src/knowledge/lane-registry.js +46 -0
  356. package/src/knowledge/providers/gemini.js +48 -8
  357. package/src/knowledge/service/client.js +13 -1
  358. package/src/knowledge/service/grpc-codec.js +156 -53
  359. package/src/knowledge/service/job-engine.js +133 -11
  360. package/src/knowledge/service/job-worker.js +34 -5
  361. package/src/knowledge/service/server.js +10 -1
  362. package/src/knowledge/store-discovery.js +77 -0
  363. package/src/lib/account-session.js +100 -25
  364. package/src/lib/agent-instructions.js +3 -0
  365. package/src/lib/auth.js +318 -51
  366. package/src/lib/cad/blender.js +42 -3
  367. package/src/lib/cad/d1-project-store.js +43 -0
  368. package/src/lib/cad/discovery.js +616 -0
  369. package/src/lib/cad/docker-executor.js +352 -0
  370. package/src/lib/cad/freecad.js +253 -0
  371. package/src/lib/cad/index.js +40 -0
  372. package/src/lib/cad/openscad.js +198 -0
  373. package/src/lib/cad/project-cli.d.ts +2 -0
  374. package/src/lib/cad/project-cli.js +21 -0
  375. package/src/lib/cad/project-contract.d.ts +3 -0
  376. package/src/lib/cad/project-contract.js +1 -0
  377. package/src/lib/cad/project-recipe.js +30 -0
  378. package/src/lib/cad/project-runtime.d.ts +2 -0
  379. package/src/lib/cad/project-runtime.js +53 -0
  380. package/src/lib/cad/project-store.js +25 -0
  381. package/src/lib/cad/project-workflows.js +31 -0
  382. package/src/lib/cad-docker.js +21 -2
  383. package/src/lib/cli-preferences.js +17 -2
  384. package/src/lib/core-client.js +97 -33
  385. package/src/lib/deploy/local-studio.js +6 -5
  386. package/src/lib/detect-context.js +14 -16
  387. package/src/lib/dockerize.js +3 -0
  388. package/src/lib/execution-approvals.js +1 -0
  389. package/src/lib/identity-scaffold.js +4 -1
  390. package/src/lib/knowledge-docker.js +9 -1
  391. package/src/lib/local-sessions.js +124 -34
  392. package/src/lib/local-status.js +35 -14
  393. package/src/lib/project-config.js +9 -0
  394. package/src/lib/provider-credentials.js +233 -55
  395. package/src/lib/scaffold/resolve-cloudflare-account.js +37 -0
  396. package/src/lib/scaffold/wizards/cms.js +2 -8
  397. package/src/lib/scaffold/wizards/worker-api.js +2 -8
  398. package/src/lib/slash-commands.js +10 -2
  399. package/src/local/migrations.js +109 -1
  400. package/src/local/runtime-store.js +31 -5
  401. package/src/local/sqlite.js +36 -1
  402. package/src/mcp/authority.js +348 -0
  403. package/src/mcp/client-adapters.js +431 -0
  404. package/src/mcp/client.js +172 -0
  405. package/src/mcp/index.js +47 -0
  406. package/src/mcp/telemetry.js +103 -0
  407. package/src/models/catalog.js +329 -51
  408. package/src/models/discovery.js +59 -4
  409. package/src/models/index.js +2 -0
  410. package/src/models/inventory-core.js +182 -0
  411. package/src/models/policy.js +20 -0
  412. package/src/plugins/cloudflare.js +103 -0
  413. package/src/plugins/completeful.js +69 -0
  414. package/src/plugins/contracts.js +86 -0
  415. package/src/plugins/index.js +11 -0
  416. package/src/plugins/registry.js +207 -0
  417. package/src/plugins/resource-scope.js +45 -0
  418. package/src/plugins/runtime.js +118 -0
  419. package/src/plugins/vectorize.js +31 -0
  420. package/src/progression/engine.js +171 -0
  421. package/src/progression/index.js +1 -0
  422. package/src/providers/cloudflare-chat.js +1 -1
  423. package/src/providers/gemini-generate-content.js +2 -1
  424. package/src/providers/openai-responses.js +45 -16
  425. package/src/providers/tool-schema.js +85 -0
  426. package/src/repository/index.js +29 -0
  427. package/src/rpc/generated/errors_pb.js +961 -1
  428. package/src/security/local-vault.js +415 -0
  429. package/src/security/process.js +20 -4
  430. package/src/status/actions.js +192 -0
  431. package/src/tools/hydrate.js +5 -1
  432. package/src/tools/index.js +7 -0
  433. package/src/tools/redact.js +64 -0
  434. package/src/tools/registry.js +83 -0
  435. package/src/tools/runtime.js +257 -0
  436. package/src/tools/search.js +21 -8
  437. package/src/ui/ansi.js +117 -3
  438. package/src/ui/cli/activity.js +76 -7
  439. package/src/ui/cli/footer.js +110 -9
  440. package/src/ui/cli/help.js +14 -5
  441. package/src/ui/wireframes.js +166 -0
  442. package/test/account-session.test.mjs +76 -11
  443. package/test/apps-scaffold-contract.test.mjs +58 -0
  444. package/test/capabilities.test.mjs +1 -1
  445. package/test/cli/eval-live.test.mjs +219 -0
  446. package/test/cli/go.test.mjs +71 -0
  447. package/test/cli/local-vault-and-provider-setup.test.mjs +268 -0
  448. package/test/cli/mcp-client.test.mjs +245 -0
  449. package/test/cli/runtime-ui.test.mjs +69 -2
  450. package/test/cli/status-actions.test.mjs +88 -0
  451. package/test/cli/wireframes-go-registry.test.mjs +54 -0
  452. package/test/cloudflare-connector.test.mjs +3 -6
  453. package/test/cloudflare-runtime.test.mjs +8 -1
  454. package/test/context.test.mjs +15 -0
  455. package/test/error-diagnostics.test.mjs +9 -0
  456. package/test/fixtures/cad/courtyard-house.json +208 -0
  457. package/test/go/cloudflare-probe.test.mjs +53 -0
  458. package/test/integration/app-command.test.mjs +55 -0
  459. package/test/integration/cad-discovery.test.mjs +158 -0
  460. package/test/integration/cad-docker-executor.test.mjs +249 -0
  461. package/test/integration/cad-execution.test.mjs +184 -0
  462. package/test/integration/cad-project-app.test.mjs +31 -0
  463. package/test/integration/cad-project-d1.test.mjs +25 -0
  464. package/test/integration/cad-project-native.test.mjs +24 -0
  465. package/test/integration/cad-project-workflow.test.mjs +9 -0
  466. package/test/integration/cad-project.test.mjs +82 -0
  467. package/test/integration/cli-help.test.mjs +4 -0
  468. package/test/integration/cms-site-tenancy-contract.test.mjs +256 -0
  469. package/test/integration/core-client.integration.test.mjs +55 -0
  470. package/test/integration/error-runtime-rpc.test.mjs +71 -0
  471. package/test/integration/features-resolve.test.mjs +128 -0
  472. package/test/integration/install-script.test.mjs +107 -0
  473. package/test/integration/inventory-core.test.mjs +53 -0
  474. package/test/integration/plugins-cloudflare.integration.test.mjs +28 -0
  475. package/test/integration/provider-env-cli.test.mjs +1 -1
  476. package/test/integration/runtime-migrations.test.mjs +6 -1
  477. package/test/integration/runtime-status.integration.test.mjs +211 -0
  478. package/test/integration/scaffold-cloudflare.test.mjs +46 -0
  479. package/test/integration/storage-architecture.test.mjs +154 -0
  480. package/test/integration/store-discovery.test.mjs +44 -0
  481. package/test/integration/terminal-exec.integration.test.mjs +86 -0
  482. package/test/integration/tool-runtime.test.mjs +124 -0
  483. package/test/integration/tool-schema.test.mjs +59 -0
  484. package/test/knowledge-service.test.mjs +4 -0
  485. package/test/local-sessions.test.mjs +11 -2
  486. package/test/local-studio-deploy.test.mjs +1 -1
  487. package/test/model-catalog.test.mjs +28 -1
  488. package/test/models.test.mjs +159 -5
  489. package/test/openai-responses.test.mjs +60 -0
  490. package/test/provider-credentials.test.mjs +15 -5
  491. package/test/responses-runner.test.mjs +321 -6
  492. package/test/sdk-worker-contract.test.mjs +5 -1
  493. package/test/shell.test.mjs +149 -4
  494. package/test/smoke.mjs +4 -3
  495. package/test/tools-search.test.mjs +33 -0
  496. package/test/unit/website-assets-bindings.test.mjs +60 -0
  497. package/test/whoami-resume.test.mjs +87 -7
  498. package/examples/gorilla-shell/README.md +0 -15
  499. package/src/lib/gorilla-template.js +0 -54
  500. package/src/lib/prompt-byok.js +0 -57
  501. package/src/lib/save-sdk-token.js +0 -19
  502. package/templates/gorilla-shell/App.tsx +0 -639
  503. package/templates/gorilla-shell/README.md +0 -34
  504. package/templates/gorilla-shell/index.html +0 -15
  505. package/templates/gorilla-shell/main.jsx +0 -9
  506. package/templates/gorilla-shell/package.json +0 -19
  507. package/templates/gorilla-shell/vite.config.js +0 -21
package/docs/CLI_SHELL.md CHANGED
@@ -55,6 +55,8 @@ Current controls include:
55
55
  /whoami authenticated IAM identity + safe credential status
56
56
  /session current cumulative token/cost/resume receipt
57
57
  /cf bounded Cloudflare/Workers operations
58
+ /connections live account / terminal / Worker / Cloudflare connection evidence
59
+ /tunnel real Cloudflare Tunnel picker backed by Wrangler
58
60
  /status local project / DB / Git / PTY health
59
61
  /settings project/runtime/terminal/model preferences
60
62
  /pwd working directory
@@ -86,7 +88,7 @@ Provider files are machine-local and must not be group/world-readable on POSIX s
86
88
 
87
89
  `agentsam models` uses the credential internally for safe provider discovery but never returns the secret. Its public status reports only safe facts such as provider, configured state, source class, and provider-verified model availability.
88
90
 
89
- IAM login is also machine-local rather than repository state. A successful browser authentication may persist the `sdk_` bearer under `~/.agentsam/auth/session.json` with restrictive permissions. `agentsam whoami`, deploy, tunnel, and context detection can reuse that validated session. Project `.agentsam/config.json` remains portable and must not become a second identity database.
91
+ IAM login is also machine-local rather than repository state. A successful browser authentication may persist the `sdk_` bearer under `~/.agentsam/auth/session.json` with restrictive permissions. `agentsam whoami`, deploy, and context detection can reuse that validated session. Cloudflare Tunnel management uses Wrangler's own authenticated Cloudflare identity rather than IAM bearer state. Project `.agentsam/config.json` remains portable and must not become a second identity database.
90
92
 
91
93
  ```bash
92
94
  agentsam whoami
@@ -209,7 +211,7 @@ SDK developers can preview rendering experiments from this repository, but those
209
211
 
210
212
  `agentsam init` owns portable repository/project setup. User identity, provider secrets, session history, execution approvals, and provider continuation state are machine/account runtime state and must not be written into portable project configuration.
211
213
 
212
- Local development does not require a cloud account. Cloud infrastructure is added intentionally.
214
+ Local development does not require a cloud account. Cloud infrastructure is added intentionally. When Cloudflare Tunnel is selected, Agent Sam delegates discovery and lifecycle to Wrangler (`tunnel list`, `info`, `run`, `create`, and `quick-start`) instead of maintaining a parallel named-tunnel implementation.
213
215
 
214
216
  ## Design rule
215
217
 
@@ -0,0 +1,38 @@
1
+ # CMS Editor — Agent Sam Contextual Composer
2
+
3
+ 24 Sept 2026 · build target for `apps/client-cms-editor` (agentsam-sdk), proven on Fuel & Free Time, then brought into Inner Animal Media.
4
+
5
+ ## Ideal-state packages (FNF = proving ground)
6
+
7
+ These FNF packages are **examples of the ideal state**, not permanent homes. Each becomes an SDK-packaged prebuild:
8
+
9
+ | Proving ground (FNF) | SDK target | Role |
10
+ |---|---|---|
11
+ | `packages/agentsam-workbench` | `@inneranimalmedia/agentsam-workbench` | miniAgentSam + contextual composer |
12
+ | `packages/heuristic-theme` | `@inneranimalmedia/heuristic-theme` | **Stock CMS theme preset** |
13
+ | `packages/commerce-analytics` | `@inneranimalmedia/commerce-analytics` | Commerce analytics surfaces |
14
+
15
+ `agentsam create … --preset cms` should land on **heuristic-theme** as the basic stock theme.
16
+
17
+ ## Interaction loop (required)
18
+
19
+ 1. **Select** an object on the live canvas.
20
+ 2. **Ask** (or agent proactively offers) — right panel scopes to selection.
21
+ 3. **Suggest** — one primary suggestion card (action title + rationale + chevron), not a chat wall.
22
+ 4. **Accept** (card click) → generation starts (no extra confirm).
23
+ 5. **Generate** — polished gradient overlay on canvas + contained monospace code stream with soft gradient veil (trust/transparency, not approval UI). Phases: Reading selection → Drafting markup → Writing styles → Wiring settings.
24
+ 6. **Land** — gradient cross-fades to real block; left inspector flashes updated fields; composer posts confirmation.
25
+
26
+ Left panel is always a real layers tree + property inspector (text, layout, typography preset, appearance, padding, remove) bound to the **same** block model the agent edits.
27
+
28
+ ## Implementation
29
+
30
+ - Primitives: `packages/agentsam-workbench/src/agent/ContextualComposer.tsx` (+ CSS)
31
+ - Host wiring: `apps/client-cms-editor/frontend/src/CmsAgentSurface.tsx` with `contextual`
32
+ - Threads persist per page/site via `localStorage` (survive redock/resize — portable agent)
33
+
34
+ ## Open decisions (from spec)
35
+
36
+ - Generation preview dock: default **inside right composer**; canvas keeps the gradient overlay.
37
+ - Threads: persisted per project key; scoped optionally to selection without discarding other threads.
38
+ - Pipeline: host-owned `planSuggestion` / `runGeneration` (AgentSam runtime / MCP) — demos ship with local stubs.
package/docs/MERKLE.md CHANGED
@@ -68,3 +68,7 @@ const comparison = diffTrees(baseline, current);
68
68
  ```
69
69
 
70
70
  The library is local filesystem tooling. It adds no Worker bindings, user/workspace identity, or network calls. The interoperable content hash format is specified in [MERKLE_V1](../protocol/MERKLE_V1.md), and semantic identity in [FILEMETA_V1](../protocol/FILEMETA_V1.md).
71
+
72
+ ## AutoRAG use
73
+
74
+ AutoRAG consumes this package's content root and optional semantic metadata root as source evidence. During a code plan it compares those roots with the previous generation, reports changed paths, and reuses unchanged parsed chunks/vectors where their content identity still matches. Merkle is deterministic filesystem evidence; it is not a dependency graph, an AST graph, a vector index, or a replacement for Git history.
@@ -57,10 +57,13 @@ Current schema:
57
57
  D1 / runtime stores runs, plans, tasks, executions, model history, subagents
58
58
  Merkle snapshot store filesystem evidence and snapshot lineage
59
59
  Git source-control authority
60
+ knowledge generations indexed evidence history; never mutable project config
60
61
  ```
61
62
 
62
63
  Do **not** add account/user/tenant/workspace identity, current run IDs, active task state, PTY/session/connection IDs, current Merkle roots, provider credentials, deployment receipts, model history, or subagent execution records to the project manifest.
63
64
 
65
+ AutoRAG manages the existing `.agentsam/knowledge.json` authority. It may add a portable repository/project key and explicit lane/profile settings there; it does not create per-lane, retrieval, backend, or credential config files. `workspace_id` is legacy read compatibility only, not universal knowledge authority.
66
+
64
67
  `repository.id` is the portable repository authority for Agent Sam surfaces. Existing `knowledge.json.repository_id` remains readable during migration, but when both files exist the IDs must agree. Git remote discovery is fallback/adoption evidence rather than a second persistent identity.
65
68
 
66
69
  For a repository already hosted on a known Git provider, IDs use the portable form such as `github:owner/repo`. Repositories without a provider identity receive a durable `local:<uuid>` ID.
@@ -72,6 +72,8 @@ The current SDK contains a portable/local knowledge slice with deterministic rep
72
72
 
73
73
  That is useful as a standalone implementation. It is not presented as the architecture of every Agent Sam host.
74
74
 
75
+ `@inneranimalmedia/agentsam-sdk/autorag` is the higher-level façade over that same engine. It performs discovery, recommends bounded source scopes, manages the existing knowledge config, selects explicit provider/backend lanes, and runs probes. It never becomes a second indexing runtime. The lower-level engine remains available through `@inneranimalmedia/agentsam-sdk/knowledge`.
76
+
75
77
  ## InnerAnimal production implementation
76
78
 
77
79
  The InnerAnimal platform is a separate host implementation with a broader code-intelligence pipeline: repository/index generations, a dedicated Tree-sitter parsing service, D1 structural nodes/edges, structural-first graph retrieval, semantic projections, and bounded hydration.
@@ -47,16 +47,17 @@ agentsam-sdk
47
47
  ├─ AGENTSAM_WAI -> Workers AI provider
48
48
  ├─ EXECOS -> execos service binding
49
49
  ├─ PTY_SERVICE -> iam-vpc VPC service
50
- ├─ IAM_ORIGIN -> https://inneranimalmedia.com
50
+ ├─ IAM_OAUTH_ISSUER -> https://inneranimalmedia.com
51
+ ├─ IAM_ORIGIN -> migration fallback
51
52
  ├─ IAM_CLIENT_ID -> public OAuth client id
52
53
  ├─ IAM_CLIENT_SECRET -> secret
53
- ├─ AGENTSAM_SDK_KEY -> secret
54
+ ├─ AGENTSAM_API_KEY -> aak_ account credential (only when a reusable account credential is needed)
54
55
  └─ AGENTSAM_BRIDGE_KEY -> secret
55
56
  ```
56
57
 
57
58
  Hosted model credentials are secrets: `XAI_API_KEY`, `OPENAI_API_KEY`, and `GEMINI_API_KEY`. Grok model inference is the `XAI_API_KEY` provider lane and is independent from the pre-wired Grok gate viewer identity/session system.
58
59
 
59
- `AGENTSAM_WORKER_ROLE` is not part of the SDK contract. `IAM_OAUTH_ISSUER` and `AGENTSAM_SDK_TOKEN` are SDK 2.5 migration-read aliases only; new configuration uses `IAM_ORIGIN` and `AGENTSAM_SDK_KEY`.
60
+ `AGENTSAM_WORKER_ROLE` is not part of the SDK contract. `IAM_OAUTH_ISSUER` is the canonical IAM authority; `IAM_ORIGIN` is a migration fallback. Reusable account API credentials use `AGENTSAM_API_KEY` with an `aak_` prefix. Browser login sessions and machine/infrastructure credentials remain separate and must not be promoted into account API keys.
60
61
 
61
62
  ## Ollama
62
63
 
@@ -0,0 +1,120 @@
1
+ # Theme Refinery — Archaeology → Product Graph
2
+
3
+ **Law:** discover ≠ promote · install ≠ activate · automation ≠ authority
4
+ **SSOT for registry:** live `inneranimalmedia-business` D1 (`agentsam_products` + `asset_relationships` + evidence/artifacts)
5
+ **SSOT for packages:** `agentsam-sdk` workspaces (`@inneranimalmedia/heuristic-theme`, `@inneranimalmedia/theme-*`)
6
+
7
+ Python owns deterministic harvest/normalize/preview/QA. AgentSam owns interpretation. **Every meaningful product unit must reconcile into D1** — filesystem-only runs are incomplete.
8
+
9
+ ## Pipeline states
10
+
11
+ ```
12
+ old scattered website
13
+ ↓ discover + fingerprint → evidence snapshot (website/repository)
14
+ ↓ make portable → work/theme-harvest/<slug>/
15
+ ↓ make previewable → preview/ + agentsam_artifacts
16
+ ↓ classify + document → agentsam_products UPSERT (prototype)
17
+ ↓ normalize structure → apps/<slug> (scaffolded)
18
+ ↓ map reusable features → feature.v1 + asset_relationships
19
+ ↓ visual/product refinement → AgentSam (preserve design, replace plumbing)
20
+ ↓ QA + screenshots + receipts → quality_reports + evidence
21
+ ↓ promote → production (human authority)
22
+ apps/<sellable-theme> + @inneranimalmedia/theme-<slug>
23
+ ```
24
+
25
+ ## Product unit kinds (`agentsam_products.kind`)
26
+
27
+ | Kind | Use when |
28
+ |------|----------|
29
+ | `app` | Sellable site/APP (`insurance-site`) |
30
+ | `theme` | Visual/design product or stock shell (`heuristic-theme`) |
31
+ | `sdk-package` | npm boundary (`@inneranimalmedia/theme-insurance-site`) |
32
+ | `section` / `block` | Reusable CMS pieces (also may write `cms_component_templates`) |
33
+ | `ui-component` | Header/nav shells extracted for reuse |
34
+ | `integration` | Provider adapters (Resend, Square, …) |
35
+ | `service` | Worker/backend service |
36
+ | `script` / `solution` / `collection` / `product` / `product-line` | As classified |
37
+
38
+ **Status ladder:** `prototype` → `scaffolded` → `wired` → `production` (→ `deprecated`)
39
+
40
+ UPSERT by stable `slug`. Never delete/recreate to refresh metadata.
41
+
42
+ ## D1 reconciliation (required)
43
+
44
+ ### 1. `agentsam_products` — canonical identity
45
+
46
+ - Resolve `repository_id` from live `code_repositories` (never invent IDs).
47
+ - Set `canonical_path` (e.g. `apps/insurance-site`, `packages/theme-insurance-site`).
48
+ - Rely on existing triggers for `defined_in` → `code_repository`.
49
+ - Provenance in `metadata` only (no secrets). See `protocol/theme-refinery/product-metadata.schema.json`.
50
+
51
+ ### 2. `asset_relationships` — topology
52
+
53
+ Idempotent UPSERT on `(source_type, source_id, target_type, target_id, relationship_type)`.
54
+
55
+ Preferred verbs already in use: `defined_in`, `depends_on`, `consumed_by`, `builds_shell_for`, `integrates_with`, `packaged_as`, `runtime_for`, `exposes_tool`, `provides_workflow`, `sourced_from`, …
56
+
57
+ Example:
58
+
59
+ ```
60
+ insurance-site --sourced_from--> (evidence / donor path hash)
61
+ insurance-site --packaged_as--> @inneranimalmedia/theme-insurance-site
62
+ insurance-site --depends_on--> theme.storefront.shell / cms contracts
63
+ ```
64
+
65
+ ### 3. `agentsam_evidence_snapshots` — point-in-time proof
66
+
67
+ Fingerprint, intake, pre/post visual, link scans.
68
+ Product row = durable summary; snapshot = detailed evidence.
69
+
70
+ ### 4. `agentsam_artifacts` — durable previews/docs
71
+
72
+ Screenshots, preview bundles, help exports. Link via relationships (`has_preview`, `documented_by` — extend vocabulary intentionally).
73
+
74
+ ### 5. `agentsam_quality_reports` — only when a real report artifact exists
75
+
76
+ ### 6. `cms_themes` vs product identity
77
+
78
+ Style tokens → `cms_themes`. Sellable APP → `agentsam_products`. Link; do not substitute.
79
+
80
+ ### 7. `cms_component_templates`
81
+
82
+ Only for extracted reusable sections/blocks — not whole sites.
83
+
84
+ ### 8. Discovery inputs (merge automatically)
85
+
86
+ - `~/company-map/machine/projects.json` + `git-roots.json`
87
+ - `~/IAM-Library/01_Template_Candidates`
88
+ - live D1 `apps` (historical inventory — discovery/backfill only)
89
+ - existing `agentsam_products` + `code_repositories`
90
+ - explicit donor roots
91
+
92
+ `apps` / `client_apps` are **not** the new SSOT. Backfill into `agentsam_products`.
93
+
94
+ ## CLI surface (target)
95
+
96
+ ```
97
+ agentsam theme harvest <path> # archaeology packet + evidence + product UPSERT (prototype)
98
+ agentsam theme preview <slug> # gallery-ready artifacts
99
+ agentsam theme normalize <slug> # proposed plan (scaffolded/wired)
100
+ agentsam theme promote <slug> # human-gated → production
101
+ agentsam themes # status table from D1 + filesystem
102
+ ```
103
+
104
+ ## Reconciliation receipt
105
+
106
+ Every run emits `ThemeRefineryReconciliationReceipt` (`protocol/theme-refinery/reconciliation-receipt.schema.json`):
107
+
108
+ discovered / matched / registered / updated / unchanged products · repositories resolved · relationships · evidence · artifacts · quality reports · CMS themes/templates · tools/workflows linked · duplicates · promotions · failures.
109
+
110
+ **Run incomplete if only files were written.**
111
+
112
+ ## Packages (current)
113
+
114
+ | Package | Role |
115
+ |---------|------|
116
+ | `@inneranimalmedia/heuristic-theme` | Stock CMS `theme.storefront.shell` |
117
+ | `@inneranimalmedia/theme-<slug>` | Installable gallery theme contracts |
118
+ | `apps/theme-gallery-preview` | Proving surface / historical mounts — not the package SSOT |
119
+
120
+ Preserve design, replace plumbing: old auth/email/uploads/CMS → current feature vocabulary.
@@ -0,0 +1,60 @@
1
+ # Provider tools and conversation compaction
2
+
3
+ Canonical capability schemas stay in `protocol/`. The Responses runner validates
4
+ selected schemas before any paid pre-turn compaction or inference. Provider
5
+ adapters also compile at their HTTP boundary for direct SDK callers.
6
+
7
+ `src/providers/tool-schema.js` owns a bounded supported JSON Schema dialect:
8
+ objects, scalar types/enums, arrays and nested anyOf, with supported scalar bounds.
9
+ It strips annotation metadata without confusing schema keywords with property
10
+ names. OpenAI/Grok strict projections close every object and make optional
11
+ properties required-and-nullable. The runtime restores those optional nulls to
12
+ omission before invoking canonical handlers. Gemini uses its JSON Schema field,
13
+ `parametersJsonSchema`, not the incompatible OpenAPI `parameters` field.
14
+
15
+ Unknown/unsupported validation keywords, refs, dynamic dictionaries, malformed
16
+ required arrays, missing array items and invalid types fail locally with the
17
+ provider, tool and schema path. This is deliberately not a general JSON Schema
18
+ compiler: adding refs/compositions requires a tested projection, not dropping
19
+ validation keywords or changing strict mode. Provider/API acceptance still needs
20
+ live integration evidence; local validation cannot prove model availability or
21
+ all future provider restrictions.
22
+
23
+ `knowledge.search` has a real schema for text, bounded search limits, semantic
24
+ selection and generation. Runtime-owned cwd is injected by the runner.
25
+
26
+ ## Interactive compaction
27
+
28
+ - `/compact` uses the selected active session/model's existing native `compact()`.
29
+ - `/compact status` reports support, active context, canonical threshold,
30
+ automatic state and the latest receipt.
31
+ - `/context` includes the same model-policy threshold and compaction support.
32
+ - `/session` and `/usage` include provider compaction usage/cost in cumulative totals.
33
+
34
+ The exact returned output is canonical continuation input. It may contain both
35
+ ordinary provider-returned items and encrypted items; it must not be filtered to
36
+ only encrypted items, decoded, or turned into a homemade summary. A dedicated
37
+ session record in the same project SQLite stores only the latest pending returned
38
+ window (maximum 10 MiB), separately from generic session JSON. It is atomically
39
+ saved with its usage/cost receipt, survives resume, and is deleted when a new
40
+ provider response ID successfully replaces it. This storage is local access-
41
+ restricted SQLite, not an application-level encrypted store; it must never be
42
+ exported as knowledge, telemetry, or model reasoning logs.
43
+
44
+ Automatic pre-turn compaction includes usage/cost in totals and can checkpoint
45
+ its output before the subsequent model call. A failed continuation leaves the
46
+ saved compacted window available for retry. Providers lacking declared native
47
+ compaction fail closed for the manual command. The local context-item truncation
48
+ module is unchanged.
49
+
50
+ OpenAI normal requests use server-side `context_management` when the model
51
+ explicitly declares compaction and a canonical policy threshold. The same
52
+ `autoCompact: false` option disables both automatic paths. Response-ID chaining
53
+ sends only new input; standalone compaction clears the old ID and uses the exact
54
+ returned window. Server-side usage is accounted from the normal response.
55
+
56
+ Sources checked during implementation:
57
+ - https://developers.openai.com/api/docs/guides/function-calling
58
+ - https://ai.google.dev/api/generate-content#FunctionDeclaration
59
+ - https://developers.openai.com/api/docs/guides/compaction
60
+ - https://developers.openai.com/api/reference/python/resources/beta/subresources/responses/methods/compact
@@ -0,0 +1,87 @@
1
+ # AgentSam storage architecture
2
+
3
+ ## Authorities
4
+
5
+ AgentSam's own local execution state defaults to one database per project:
6
+ `<projectRoot>/.agentsam/data/agentsam.sqlite`. A model or provider switch
7
+ keeps the same ProjectSession and storage authority. A `cwd` change inside the
8
+ project also keeps it. Switching repositories selects a new project authority.
9
+
10
+ The user's application keeps its actual storage. In this repository,
11
+ `apps/local-studio/backend/wrangler.jsonc` declares a deployed Worker with D1,
12
+ Hyperdrive, R2, Workers AI, and service bindings. AgentSam must honor those
13
+ bindings for Worker features. Its local SQLite session state does not replace
14
+ the Worker's data, provision new cloud state, or start an implicit sync. Inspect
15
+ the project's real deployment and data bindings before choosing storage for
16
+ application features. Use local SQLite for application data only when the user
17
+ selects it or the task benefits from a clearly scoped local cache or scratch
18
+ store.
19
+
20
+ Cloudflare, Postgres/Supabase, object stores, and vector systems are connected
21
+ infrastructure. Their use is explicit and governed by the user's project and
22
+ credentials. Ordinary `agentsam` boot requires none of them. Durable Objects
23
+ are reserved for a future optional actor adapter with a demonstrated need for
24
+ globally addressed, serialized distributed actors. No default runtime path may
25
+ require one.
26
+
27
+ ## Runtime state and lifecycle
28
+
29
+ `src/local/runtime-store.js`, `src/local/sqlite.js`, and
30
+ `src/local/migrations.js` own the local relational runtime and its versioned
31
+ SQL. `src/lib/local-sessions.js` writes resumable session records to the same
32
+ database. The older `~/.agentsam/sessions/*.json` files are a read-only
33
+ compatibility source: a session is imported only when its saved project root
34
+ matches the selected project. New sessions do not write there.
35
+ `agentsam resume` lists sessions for the current project; use
36
+ `agentsam resume --cwd <project-path>` when invoking it elsewhere. Opaque
37
+ provider response IDs can continue across process restarts. Provider message
38
+ arrays remain in memory for the active shell and are not stored in generic
39
+ session state. An explicit native compaction saves only its latest returned
40
+ window in the separate `agentsam_provider_continuations` session record, bounded
41
+ to 10 MiB. It is replaced on compaction and deleted after successful continuation.
42
+ Generic session JSON retains only a presence marker and a usage/cost receipt.
43
+ The returned window may contain plaintext provider items as well as encrypted
44
+ items; local SQLite file permissions protect access, not application-level
45
+ encryption. It is never a knowledge source. Outside that explicit checkpoint,
46
+ providers without an opaque continuation ID start a fresh model conversation
47
+ after process restart.
48
+
49
+ | Lifecycle | Keep | Expire or discard |
50
+ | --- | --- | --- |
51
+ | persistent | project configuration, selected model metadata, valuable cache | stale derived copies |
52
+ | session | safe continuation IDs, status, usage, bounded receipts | raw prompts and provider message arrays |
53
+ | work_cycle | accepted objective/plan, final checkpoint and evidence | search frontier and rejected candidates |
54
+ | ttl | useful temporary context digest until expiry | expired digest/scratch |
55
+ | scratch | recoverable intermediate state only while needed | all obsolete scratch |
56
+
57
+ Existing runtime tables carry their own status and expiry fields where
58
+ applicable. New persisted concepts require a migration, an owner, and a
59
+ cleanup rule. Credentials stay in the existing credential-specific machine
60
+ stores. Session state retains no access/refresh tokens, provider keys, cookies,
61
+ or raw prompts. Blob and vector data do not belong behind a pretend universal
62
+ relational interface. `SQLITE_RUNTIME_CAPABILITIES` reports transactions,
63
+ relational queries, application-managed expiry, and local-only storage; it
64
+ does not claim shared remote state, blob/vector storage, or actor semantics.
65
+
66
+ ## Connected infrastructure and sync
67
+
68
+ Use the cheapest appropriate authority already available. Local session and
69
+ run state belongs in SQLite. Remote relational application data may belong in
70
+ the user's D1 or Postgres. Blobs may belong in the user's object store; vectors
71
+ in the selected vector system. An explicit remote integration must state its
72
+ source authority, owner, direction, retry, conflict, freshness, and deletion
73
+ policy before copying state between stores. Connected D1 does not move a local
74
+ ProjectSession into D1.
75
+
76
+ ## Enforcement
77
+
78
+ The existing source boundary verifier rejects a new Durable Object dependency
79
+ in the default shell, runtime store, agent, and provider paths. It also checks
80
+ that resumable sessions use the canonical project SQLite database and that
81
+ runtime schema definitions stay in versioned migrations. Focused storage tests
82
+ cover project-root selection, project isolation, model-independent session
83
+ storage, migration behavior, and secret-free session rows.
84
+
85
+ See [Provider tools and compaction](PROVIDER-TOOLS-AND-COMPACTION.md) for the
86
+ continuation contract and [knowledge lifecycle proposal](../../protocol/knowledge/LIFECYCLE.md)
87
+ for blackboard, knowledge, evidence, and store-selection boundaries.
@@ -0,0 +1,69 @@
1
+ # CAD project tools — implementation contract
2
+
3
+ Ticket: tkt_ae8044139c294a6a. Work branch: feat/cad-project-tools-20260922.
4
+
5
+ ## Geometry and surfaces
6
+ CAD Creator's editable DesignProject is canonical: coordinates, wall thickness/heights, furniture and room polygons are inches; scale must equal 1. Door/window locations are ratios along their host wall. IDs survive edits and native generation. Display units do not rescale the document.
7
+
8
+ The existing IAM Design Studio BIM viewport consumes GLB with placement metadata. It does not edit a FreeCAD/BIM object tree. Blender receives metres; exported GLB is the preview interchange, while project JSON remains editable. There is no IFC semantic roundtrip in this implementation.
9
+
10
+ The courtyard fixture is a reference-derived massing baseline with a 72 by 60 foot bounding envelope, two 22 foot wings and 28 foot centre span. The envelope is not enclosed floor area. Height is an explicit assumption. Roof generation, nonrectangular floor triangulation and parametric-object evaluation are not yet supported by this native adapter and fail explicitly.
11
+
12
+ ## Shared handlers
13
+ Nine tools: project get, validate, atomic apply, save, restore; native build, inspect, render, export. Schemas live in shared/cad/src/domain/project-tools.js, geometry validation/edits in project-contract.js, and execution in src/lib/cad/project-runtime.js.
14
+
15
+ CLI, SDK agent capability adapter, CAD Creator HTTP API and frontend tool dispatcher invoke these same handlers. App builds package the runtime and Blender adapter, including standalone scaffolds.
16
+
17
+ Save requires expected_revision (0 for new). Restore creates another immutable revision. CLI edits emit filesystem-backed SSE updates to the app; unsaved browser edits are retained on conflict. Native receipts bind content hashes and model digests to exact revisions.
18
+
19
+ ## Running
20
+ From the SDK checkout:
21
+ ```sh
22
+ node bin/agentsam cad project tools
23
+ node bin/agentsam cad project save request.json --root /absolute/project-root
24
+ node bin/agentsam cad project workflows
25
+ node bin/agentsam cad project workflow cad.house_baseline baseline-request.json --root /absolute/project-root
26
+ node bin/agentsam cad project workflow cad.edit_preview edit-request.json --root /absolute/project-root
27
+ npm run dev --prefix apps/cad-creator
28
+ ```
29
+ Baseline request is {project: DesignProject}; edit request is {project_id, expected_revision, operation}. Set AGENTSAM_CAD_PROJECT_ROOT on the app to the same --root used by the CLI. Open the saved project ID using the revision panel.
30
+
31
+ Local state is .agentsam/cad/projects, native artifacts .agentsam/cad/artifacts, and workflow evidence .agentsam/cad/workflow-runs under the selected root. A native engine is required; there is no simulated success.
32
+
33
+ ## Existing D1 structures
34
+ No tables are added.
35
+
36
+ | Existing structure | Role |
37
+ |---|---|
38
+ | agentsam_tools | Schema, handler_key cad_project, capability, lifecycle/visibility |
39
+ | agentsam_capabilities + agentsam_tool_capabilities | Existing design.read/write/export with exact operations |
40
+ | designstudio_design_blueprints | Editable project in sketch_json; revision/hash in generation_config_json |
41
+ | scene_snapshots + R2 | Immutable project snapshots; CAD_PROJECT type; owner-scoped access |
42
+ | agentsam_workflows / nodes / edges | Baseline and edit-preview graphs, pinned tools, prerequisites |
43
+ | agentsam_workflow_runs | Account-owned workflow execution |
44
+ | agentsam_executions / execution_steps | Per-tool attempt and verification output |
45
+ | agentsam_artifacts / execution_artifacts | Private durable output and per-execution evidence; only populate for actual uploaded objects |
46
+ | agentsam_workspace_state / plans / plan tasks / work tracking checkpoint | Existing GOAP work tracking, separate from geometry and execution evidence |
47
+
48
+ D1ProjectStore implements the existing blueprint/snapshot mapping with injected D1 and R2 bindings, authenticated host scope and transactional optimistic concurrency. It has been tested against the existing schemas. The local app currently uses FileProjectStore; it does not claim automatic cloud synchronisation.
49
+
50
+ GOAP metadata exposes prerequisites and effects. Effects are returned only after completed verified execution. The existing /goap work tracker has not been replaced by a new planner; consuming these action definitions through its planner remains an integration task.
51
+
52
+ ## Registry and hosted boundary
53
+ Generate: node scripts/cad-registry.mjs
54
+ Check committed/source parity: node scripts/cad-registry.mjs --check
55
+ Check a live D1 export: node scripts/cad-registry-verify.mjs live-rows.json
56
+
57
+ registry/cad-project includes generated tools, schemas, bindings, capability associations, workflow graphs and SQL. The IAM repo carries the identical manifest and migration plus its backend cad_project bridge. Transport adds sdk_root/project_root and nests the common schema in input. It resolves account identity from authenticated run context and executes through the owned local terminal lane.
58
+
59
+ The seed deliberately registers tools inactive and workflows draft. Local native proof is not hosted deployment proof. Do not activate until the IAM binding is deployed and the catalog path completes the same roundtrip. Do not widen OAuth/client grants as part of seeding.
60
+
61
+ ## Verification
62
+ ```sh
63
+ node --test test/cad-project.test.mjs test/cad-project-d1.test.mjs test/cad-project-workflow.test.mjs
64
+ AGENTSAM_TEST_NATIVE_CAD=1 node --test test/cad-project-native.test.mjs
65
+ npm run package:verify --prefix apps/cad-creator
66
+ AGENTSAM_TEST_CAD_APP=1 node --test test/cad-project-app.test.mjs
67
+ node scripts/cad-registry.mjs --check
68
+ ```
69
+ Verified on the local Mac: real .blend, GLB and PNG; edit/restore rebuild; both workflows; production app API + SSE + stale-write rejection; package build/typecheck/tests. Hosted deployment, browser visual review, D1 host wiring and IFC roundtrip are not claimed by these checks.
@@ -0,0 +1,73 @@
1
+ # CMS scaffolding pattern reference — sections/blocks/schema
2
+
3
+ _Reference captured 2026-09-18; reconciled against current SDK tree 2026-09-19._
4
+
5
+ The pattern worth copying isn't a framework, it's a separation: reusable sections and blocks with a typed schema, page composition as pure data (templates), and an editor UI generated automatically from each section or block's schema — never hand-built per section or block. Every tool below implements this same separation differently; this doc tracks how, so agentsam-sdk's version can be compared against them as it's built.
6
+
7
+ ## The core pattern
8
+
9
+ Shopify's [theme architecture](https://shopify.dev/docs/storefronts/themes/architecture) is the cleanest real-world example of the separation worth copying. Six primitives, each with one job:
10
+
11
+ | Primitive | Job | Who edits it |
12
+ | --- | --- | --- |
13
+ | Layout file | Repeated shell (header/footer) every page renders inside | Developer |
14
+ | Template (JSON) | Which sections appear on a page, in what order — pure data, no markup | Merchant, via editor |
15
+ | Section group | Container letting merchants add/remove/reorder sections in fixed zones (header, footer) | Merchant |
16
+ | Section | A reusable, self-contained module with its own `{% schema %}` block defining its editable fields | Developer writes it, merchant configures it |
17
+ | Block | A repeatable sub-item inside a section (one testimonial card inside a testimonials section) | Merchant |
18
+ | Snippet | Small reusable code partial, invisible to merchants, no schema | Developer only |
19
+
20
+ The part that matters most: **a section's schema is what generates its settings panel in the editor.** Nobody hand-builds a settings UI per section — the editor reads the schema and renders the right inputs (text field, image picker, color swatch, range slider) automatically. Add a new section with a new schema and the editor already knows how to edit it.
21
+
22
+ ## How the leading tools implement the same pattern
23
+
24
+ Every modern visual builder is solving the same problem Shopify solved — register a section or block once, get its editor UI for free — with a different registration API and a different ownership model.
25
+
26
+ | Tool | Registration call | Schema lives | Editor UI | Code ownership |
27
+ | --- | --- | --- | --- | --- |
28
+ | [Shopify (Dawn)](https://shopify.dev/docs/storefronts/themes/architecture) | `{% schema %}` tag at the bottom of a `.liquid` section file | Inside the section file itself | Auto-generated from schema, zero custom UI code | Hosted — themes only run on Shopify |
29
+ | [Plasmic](https://docs.plasmic.app/learn/registering-code-components) | `PLASMIC.registerComponent(Component, meta)` | JS object passed at registration (`props` field) | Auto-generated panel in Plasmic Studio from `meta.props` | Can generate/export React code into your own repo |
30
+ | [Makeswift](https://docs.makeswift.com/developer/docs/reference/makeswiftruntime/reactruntime/register-component) | `runtime.registerComponent(Component, { type, label, props })` | `props` object, values are "Controls" (`Style`, `TextInput`, etc.) | Panel built from the Controls you pass per prop | Runs inside your own Next.js codebase |
31
+ | [Builder.io](https://www.builder.io/c/docs/input-types) | `Builder.registerComponent(Component, { name, inputs })` | `inputs` array, each with a `name` + `type` (string, color, richText, object, list…) | Auto-generated from `inputs`, same input-type system also drives their headless CMS data models | Hosted headless CMS; components live in your repo |
32
+ | [Webstudio](https://github.com/webstudio-is/webstudio) | Not confirmed against a cited source — don't take this as a specific API to copy | Not confirmed against a cited source | Visual canvas editor | Verified: fully open source, self-hostable — you own data, components, and infrastructure |
33
+
34
+ The pattern is identical across the sourced rows: **schema → editor UI writes itself.** The only real axis of difference is who owns the runtime — Shopify and Builder.io are hosted platforms you build on top of; Plasmic and Makeswift let the component code live in your own repo, which is closer to what agentsam-sdk needs, though the portable core still can't be React-specific (see below).
35
+
36
+ ## Gap check: where our current setup stands
37
+
38
+ The real gap isn't "we don't have this pattern" — IAM already has most of it. The real gap is that it's owned by IAM, not portable, and not consistently used. That authority split is the actual problem to solve.
39
+
40
+ | Pattern element | In IAM | In SDK | Notes |
41
+ | --- | --- | --- | --- |
42
+ | Section/block registry + schema | Yes | Partial | `apps/client-cms-editor` now consumes section/block schema catalogs and exposes registry-backed section/block/template UX, but canonical schema authority is still supplied by the host/backend rather than owned as a portable SDK registry |
43
+ | Data-only page composition | Partial | Partial | `apps/client-cms-editor` models and consumes structured Page → Section → Block data; what's still missing is portable authoritative storage, a versioned template/publication manifest, and renderer convergence between editor preview and publish |
44
+ | Auto-generated editor UI | Partial | Partial | `apps/client-cms-editor/frontend/src/CmsEditor.tsx` has a schema-driven `ContentInspector` that reads registry field definitions and renders controls from them, but it still depends on host/backend-supplied schemas rather than an SDK-owned portable registry |
45
+ | Debug/schema metadata isolated from public render | Historical gap | Re-verify | The 2026-09-18 `/work` audit found `route:` / `section:` / `cms:` strings rendering visibly. Treat that as historical evidence to regression-test, not as a claim about the current deployed renderer without a fresh probe. |
46
+
47
+ **Storage law**, once extracted: D1 holds identity, relationships, ordering, lifecycle, structured state, and artifact pointers. R2 holds media, imported source, generated HTML, and heavy/versioned artifacts. KV holds only current-publication/cache pointers and invalidation — never identity or source of truth.
48
+
49
+ The honest read: the Dawn zips are raw material (real, tested HTML patterns worth mining for section ideas), not architecture to extend as-is — they predate the schema concept entirely. IAM's CMS core is a different case: the registry/schema authority exists, and the SDK now contains `apps/client-cms-editor` with Page → Section → Block modeling plus schema-driven inspector controls. What's still missing is portable ownership of that authority and renderer convergence. That's the extraction problem, not an invention problem.
50
+
51
+ ## Target blended pattern for agentsam-sdk
52
+
53
+ What to take from each:
54
+
55
+ - **From Shopify** — the schema-in-the-definition convention (a section or block ships its own field definitions) and the strict split between layout / template-as-data / section / block. This is the skeleton, and it already exists in IAM's registry — it needs extracting, not inventing.
56
+ - **From Plasmic** — the registration call shape, as a reference for ergonomics only. The portable core can't be React-specific, since the Worker and public runtime must not be forced to ship React just to render a page.
57
+ - **From Makeswift** — the idea of typed "Controls" per field carrying their own validation, options, custom widgets, and conditional behavior — not just a type string. The current `apps/client-cms-editor` inspector already selects controls from schema field definitions; richer validation, options, conditional behavior, and portable control metadata remain the gap.
58
+ - **From Builder.io** — the unified input-type system spanning both components and data models, so the same schema vocabulary describes a section/block's fields and a content model's fields — one type system, not two.
59
+ - **From Webstudio** — the ownership stance: open-source, self-hostable, infrastructure-ownable — the business owns data/components/infrastructure outright. Non-negotiable given the resale plan.
60
+
61
+ The portable contract is **schema + renderer key/adapters + optional editor-control overrides** — not "React component + schema." A section or block definition is: a versioned schema (fields, types, defaults, motion settings), a renderer key the Worker and public runtime resolve to a deterministic renderer, and optional editor-control overrides for the React-based editor specifically. That's what lets React power the editor without forcing the Worker or public runtime to ship React at all.
62
+
63
+ AgentSam doesn't need to invent this pattern. The current SDK already has the client CMS editor surface and schema-driven inspection; IAM still owns more of the canonical registry/schema authority. The remaining work is extraction and convergence: move portable authority into shared SDK contracts, bind schemas to deterministic renderer keys/adapters, keep every editor panel schema-driven, and package the result with local and Cloudflare host adapters.
64
+
65
+ ## Sources
66
+
67
+ - [Shopify theme architecture](https://shopify.dev/docs/storefronts/themes/architecture)
68
+ - [Shopify Dawn reference theme](https://github.com/Shopify/dawn)
69
+ - [Plasmic — registering code components](https://docs.plasmic.app/learn/registering-code-components)
70
+ - [Plasmic — code components API reference](https://docs.plasmic.app/learn/code-components-ref)
71
+ - [Makeswift — registerComponent reference](https://docs.makeswift.com/developer/docs/reference/makeswiftruntime/reactruntime/register-component)
72
+ - [Builder.io — custom component input types](https://www.builder.io/c/docs/input-types)
73
+ - [Webstudio](https://github.com/webstudio-is/webstudio)