@inneranimalmedia/agentsam-sdk 2.6.2 → 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 (497) 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/AUTORAG.md +58 -0
  17. package/docs/BRAND_INTELLIGENCE.md +30 -0
  18. package/docs/CLI_SHELL.md +4 -2
  19. package/docs/CMS_CONTEXTUAL_COMPOSER.md +38 -0
  20. package/docs/MERKLE.md +4 -0
  21. package/docs/PROJECT_CONFIG.md +3 -0
  22. package/docs/REPOSITORY_KNOWLEDGE.md +2 -0
  23. package/docs/THEME_REFINERY.md +120 -0
  24. package/docs/architecture/PROVIDER-TOOLS-AND-COMPACTION.md +60 -0
  25. package/docs/architecture/STORAGE.md +87 -0
  26. package/docs/cad-project-tools.md +69 -0
  27. package/docs/cms-scaffolding-pattern-reference.md +73 -0
  28. package/docs/plans/AGENTSAM-INTERACTIVE-UI-REQUIREMENTS-codex-tui-20260919.md +113 -0
  29. package/docs/plans/AGENTSAM-INTERACTIVE-UI-REQUIREMENTS.md +85 -0
  30. package/docs/plans/AGENTSAM-MCP-CLIENT-2026-09-19.md +181 -0
  31. package/docs/plans/ASBD-PORTABLE-WORKGRAPH-UI-DEFERRED.md +34 -0
  32. package/docs/plans/ASTRA-BRIEF-2026-09-18.md +258 -0
  33. package/docs/plans/MULTI-AGENT-SPRINTS-2026-09-19.md +373 -0
  34. package/docs/plans/NEXT-AGENT-HANDOFF.md +167 -0
  35. package/docs/plans/RECONCILIATION-2026-09-19.md +178 -0
  36. package/docs/plugins.md +43 -0
  37. package/docs/tools/README.md +57 -0
  38. package/docs/tools/agent-and-orchestration.md +49 -0
  39. package/docs/tools/browser-and-research.md +46 -0
  40. package/docs/tools/cloudflare-platform.md +32 -0
  41. package/docs/tools/cms.md +25 -0
  42. package/docs/tools/communications.md +41 -0
  43. package/docs/tools/database-and-storage.md +62 -0
  44. package/docs/tools/design-and-media.md +64 -0
  45. package/docs/tools/filesystem-and-code.md +55 -0
  46. package/docs/tools/github.md +56 -0
  47. package/docs/tools/integrations-and-misc.md +16 -0
  48. package/docs/tools/memory.md +21 -0
  49. package/docs/tools/terminal-and-execution.md +29 -0
  50. package/docs/tools/tickets-and-platform.md +30 -0
  51. package/migrations/d1/0001_agentsam_plugin_runtime.sql +177 -0
  52. package/migrations/d1/0002_agentsam_ticket_ownership.sql +8 -0
  53. package/migrations/d1/0002_dynamic_model_policies.sql +23 -0
  54. package/migrations/d1/0003_expand_tool_handler_families.sql +18 -0
  55. package/migrations/d1/0004_project_aware_retrieval_lanes.sql +24 -0
  56. package/migrations/d1/0005_portable_knowledge_identity.sql +104 -0
  57. package/migrations/d1/0006_repair_ops_trail_account_scope.sql +14 -0
  58. package/migrations/d1/0007_repair_ops_trail_agent_run_account.sql +13 -0
  59. package/migrations/d1/0008_backfill_knowledge_run_legacy_tenant.sql +14 -0
  60. package/migrations/d1/0009_normalize_cloudflare_plugin_installations.sql +137 -0
  61. package/migrations/runtime/0001_cli_runtime.sql +67 -0
  62. package/migrations/runtime/0002_project_sessions.sql +15 -0
  63. package/migrations/runtime/0003_provider_continuations.sql +8 -0
  64. package/package.json +92 -12
  65. package/packages/agentsam-brand/README.md +21 -0
  66. package/packages/agentsam-brand/package.json +22 -0
  67. package/packages/agentsam-brand/src/contract.js +59 -0
  68. package/packages/agentsam-brand/src/extract.js +126 -0
  69. package/packages/agentsam-brand/src/goap-actions.js +73 -0
  70. package/packages/agentsam-brand/src/index.js +48 -0
  71. package/packages/agentsam-brand/src/plan.js +115 -0
  72. package/packages/agentsam-brand/src/resolve.js +139 -0
  73. package/packages/agentsam-brand/src/scan.js +250 -0
  74. package/packages/agentsam-brand/test/brand-scan.test.mjs +106 -0
  75. package/packages/agentsam-contracts/README.md +23 -0
  76. package/packages/agentsam-contracts/package.json +32 -0
  77. package/packages/agentsam-contracts/src/adapter.ts +25 -0
  78. package/packages/agentsam-contracts/src/agent.ts +35 -0
  79. package/packages/agentsam-contracts/src/artifacts.ts +33 -0
  80. package/packages/agentsam-contracts/src/authority.ts +29 -0
  81. package/packages/agentsam-contracts/src/context.ts +16 -0
  82. package/packages/agentsam-contracts/src/errors.ts +46 -0
  83. package/packages/agentsam-contracts/src/events.ts +47 -0
  84. package/packages/agentsam-contracts/src/execution.ts +50 -0
  85. package/packages/agentsam-contracts/src/hooks.ts +40 -0
  86. package/packages/agentsam-contracts/src/identity.ts +16 -0
  87. package/packages/agentsam-contracts/src/index.ts +14 -0
  88. package/packages/agentsam-contracts/src/models.ts +9 -0
  89. package/packages/agentsam-contracts/src/providers.ts +33 -0
  90. package/packages/agentsam-contracts/src/repository.ts +64 -0
  91. package/packages/agentsam-contracts/src/tools.ts +98 -0
  92. package/packages/agentsam-contracts/test/contracts.test.mjs +16 -0
  93. package/packages/agentsam-contracts/test/errors-catalog.test.mjs +25 -0
  94. package/packages/agentsam-contracts/test/repository.test.mjs +18 -0
  95. package/packages/agentsam-contracts/tsconfig.json +12 -0
  96. package/packages/agentsam-errors/package.json +17 -0
  97. package/packages/agentsam-errors/src/adapters/anthropic.js +15 -0
  98. package/packages/agentsam-errors/src/adapters/cad.js +109 -0
  99. package/packages/agentsam-errors/src/adapters/cloudflare.js +21 -0
  100. package/packages/agentsam-errors/src/adapters/cursor.js +4 -0
  101. package/packages/agentsam-errors/src/adapters/device.js +38 -0
  102. package/packages/agentsam-errors/src/adapters/docker.js +28 -0
  103. package/packages/agentsam-errors/src/adapters/gcp.js +14 -0
  104. package/packages/agentsam-errors/src/adapters/github.js +22 -0
  105. package/packages/agentsam-errors/src/adapters/google.js +17 -0
  106. package/packages/agentsam-errors/src/adapters/index.js +55 -0
  107. package/packages/agentsam-errors/src/adapters/internal.js +40 -0
  108. package/packages/agentsam-errors/src/adapters/oauth.js +24 -0
  109. package/packages/agentsam-errors/src/adapters/openai.js +17 -0
  110. package/packages/agentsam-errors/src/adapters/process.js +35 -0
  111. package/packages/agentsam-errors/src/adapters/provider.js +114 -0
  112. package/packages/agentsam-errors/src/envelope.js +186 -0
  113. package/packages/agentsam-errors/src/error.js +24 -0
  114. package/packages/agentsam-errors/src/fingerprint.js +35 -0
  115. package/packages/agentsam-errors/src/index.js +10 -0
  116. package/packages/agentsam-errors/src/normalize.js +30 -0
  117. package/packages/agentsam-errors/src/redaction.js +52 -0
  118. package/packages/agentsam-errors/src/render.js +16 -0
  119. package/packages/agentsam-errors/src/retry.js +10 -0
  120. package/packages/agentsam-errors/src/transport.js +52 -0
  121. package/packages/agentsam-errors/src/vocabulary.js +320 -0
  122. package/packages/agentsam-errors/test/envelope.test.mjs +70 -0
  123. package/packages/agentsam-errors/test/providers.test.mjs +99 -0
  124. package/packages/agentsam-errors/test/redaction.test.mjs +21 -0
  125. package/packages/agentsam-errors/test/runtime-cad-device.test.mjs +76 -0
  126. package/packages/agentsam-errors/test/transport.test.mjs +46 -0
  127. package/packages/agentsam-knowledge/package.json +15 -0
  128. package/packages/agentsam-knowledge/src/autorag/index.js +64 -0
  129. package/packages/agentsam-knowledge/src/backends/index.js +26 -0
  130. package/packages/agentsam-knowledge/src/index.js +3 -0
  131. package/packages/agentsam-knowledge/src/providers/index.js +95 -0
  132. package/packages/agentsam-knowledge/test/autorag.test.mjs +42 -0
  133. package/packages/agentsam-nav/README.md +40 -0
  134. package/packages/agentsam-nav/dist/Nav.d.ts +43 -0
  135. package/packages/agentsam-nav/dist/NavCollapsible.d.ts +10 -0
  136. package/packages/agentsam-nav/dist/NavContent.d.ts +2 -0
  137. package/packages/agentsam-nav/dist/NavFooter.d.ts +2 -0
  138. package/packages/agentsam-nav/dist/NavGroup.d.ts +3 -0
  139. package/packages/agentsam-nav/dist/NavHeader.d.ts +2 -0
  140. package/packages/agentsam-nav/dist/NavMenu.d.ts +22 -0
  141. package/packages/agentsam-nav/dist/NavProvider.d.ts +35 -0
  142. package/packages/agentsam-nav/dist/NavTrigger.d.ts +2 -0
  143. package/packages/agentsam-nav/dist/Surfaces.d.ts +41 -0
  144. package/packages/agentsam-nav/dist/browser.d.ts +11 -0
  145. package/packages/agentsam-nav/dist/browser.global.js +132 -0
  146. package/packages/agentsam-nav/dist/browser.js +613 -0
  147. package/packages/agentsam-nav/dist/contracts.d.ts +76 -0
  148. package/packages/agentsam-nav/dist/index.d.ts +11 -0
  149. package/packages/agentsam-nav/dist/index.js +614 -0
  150. package/packages/agentsam-nav/dist/legacy.css +83 -0
  151. package/packages/agentsam-nav/dist/shell.css +113 -0
  152. package/packages/agentsam-nav/dist/theme.css +113 -0
  153. package/packages/agentsam-nav/dist/utils.d.ts +1 -0
  154. package/packages/agentsam-nav/package.json +43 -0
  155. package/packages/agentsam-queue-control/README.md +107 -0
  156. package/packages/agentsam-queue-control/package.json +31 -0
  157. package/packages/agentsam-queue-control/schemas/job-envelope.schema.json +56 -0
  158. package/packages/agentsam-queue-control/src/adapters/cloudflare.js +152 -0
  159. package/packages/agentsam-queue-control/src/adapters/memory.js +38 -0
  160. package/packages/agentsam-queue-control/src/contracts.js +130 -0
  161. package/packages/agentsam-queue-control/src/control-plane.js +141 -0
  162. package/packages/agentsam-queue-control/src/dispatch.js +43 -0
  163. package/packages/agentsam-queue-control/src/index.js +7 -0
  164. package/packages/agentsam-queue-control/src/policy.js +88 -0
  165. package/packages/agentsam-queue-control/src/topology.js +66 -0
  166. package/packages/agentsam-queue-control/test/queue-control.test.mjs +100 -0
  167. package/packages/agentsam-repository/src/goap.js +718 -0
  168. package/packages/agentsam-repository/src/goap.js.bak-20260922011251 +670 -0
  169. package/packages/agentsam-repository/src/index.js +5 -0
  170. package/packages/agentsam-repository/src/merkle/cloudflare-persistence.js +2 -2
  171. package/packages/agentsam-repository/src/tickets.js +184 -0
  172. package/packages/agentsam-repository/src/work-tracking.js +199 -0
  173. package/packages/agentsam-repository/src/workspace-state.js +176 -0
  174. package/packages/agentsam-repository/test/goap-tickets-workspace-state.test.mjs +152 -0
  175. package/packages/connectors/cloudflare/src/index.js +297 -15
  176. package/packages/connectors/cloudflare/src/owner.js +43 -40
  177. package/packages/connectors/cloudflare/src/routes.js +167 -26
  178. package/packages/connectors/cloudflare/tests/connector.test.mjs +112 -2
  179. package/packages/heuristic-theme/README.md +11 -0
  180. package/packages/heuristic-theme/package.json +25 -0
  181. package/packages/heuristic-theme/src/index.js +2 -0
  182. package/packages/heuristic-theme/src/registry.js +36 -0
  183. package/packages/heuristic-theme/src/theme.js +41 -0
  184. package/packages/heuristic-theme/test/theme.test.mjs +26 -0
  185. package/packages/identity/.agentsam/features/oauth-login-portal/agentsam.feature.json +64 -0
  186. package/packages/identity/.agentsam/features/oauth-login-portal/providers.json +96 -0
  187. package/packages/identity/.agentsam/features/oauth-login-portal/resources.json +47 -0
  188. package/packages/identity/.agentsam/features/oauth-login-portal/routes.json +74 -0
  189. package/packages/identity/.agentsam/features/oauth-login-portal/ui.json +35 -0
  190. package/packages/identity/package.json +3 -2
  191. package/packages/identity/src/adapters/cloudflare-d1/ids.js +4 -0
  192. package/packages/identity/src/adapters/cloudflare-d1/index.js +39 -1
  193. package/packages/identity/src/contracts/provider.js +3 -2
  194. package/packages/identity/src/frontend/auth-portal/pages/login.html +7 -0
  195. package/packages/identity/src/index.js +2 -0
  196. package/packages/identity/src/oauth/credentials.js +13 -0
  197. package/packages/identity/src/oauth/iam-platform.js +5 -5
  198. package/packages/identity/src/providers/cloudflare/index.js +19 -0
  199. package/packages/identity/src/providers/cloudflare/mapper.js +21 -0
  200. package/packages/identity/src/providers/cloudflare/oauth.js +48 -0
  201. package/packages/identity/src/providers/cloudflare/profile.js +28 -0
  202. package/packages/identity/src/providers/index.js +18 -2
  203. package/packages/identity/src/server/identity-service.js +13 -3
  204. package/packages/identity/src/server/worker-router.js +63 -8
  205. package/packages/identity/tests/identity-service.test.mjs +15 -0
  206. package/packages/providers/completeful/README.md +38 -0
  207. package/packages/providers/completeful/package.json +29 -0
  208. package/packages/providers/completeful/src/client.js +162 -0
  209. package/packages/providers/completeful/src/events.js +49 -0
  210. package/packages/providers/completeful/src/index.js +22 -0
  211. package/packages/providers/completeful/src/tools.js +579 -0
  212. package/packages/providers/completeful/src/webhooks.js +55 -0
  213. package/packages/providers/completeful/test/provider.test.mjs +196 -0
  214. package/packages/theme-church-site/README.md +10 -0
  215. package/packages/theme-church-site/package.json +30 -0
  216. package/packages/theme-church-site/src/harvest.json +14 -0
  217. package/packages/theme-church-site/src/index.js +84 -0
  218. package/packages/theme-church-site/test/theme.test.mjs +19 -0
  219. package/packages/theme-companions-site/README.md +10 -0
  220. package/packages/theme-companions-site/package.json +30 -0
  221. package/packages/theme-companions-site/src/harvest.json +12 -0
  222. package/packages/theme-companions-site/src/index.js +82 -0
  223. package/packages/theme-companions-site/test/theme.test.mjs +19 -0
  224. package/packages/theme-floors-site/README.md +10 -0
  225. package/packages/theme-floors-site/package.json +30 -0
  226. package/packages/theme-floors-site/src/harvest.json +14 -0
  227. package/packages/theme-floors-site/src/index.js +82 -0
  228. package/packages/theme-floors-site/test/theme.test.mjs +19 -0
  229. package/packages/theme-fuelnfree-site/README.md +10 -0
  230. package/packages/theme-fuelnfree-site/package.json +30 -0
  231. package/packages/theme-fuelnfree-site/src/harvest.json +13 -0
  232. package/packages/theme-fuelnfree-site/src/index.js +81 -0
  233. package/packages/theme-fuelnfree-site/test/theme.test.mjs +19 -0
  234. package/packages/theme-handyman-site/README.md +10 -0
  235. package/packages/theme-handyman-site/package.json +30 -0
  236. package/packages/theme-handyman-site/src/harvest.json +10 -0
  237. package/packages/theme-handyman-site/src/index.js +83 -0
  238. package/packages/theme-handyman-site/test/theme.test.mjs +19 -0
  239. package/packages/theme-insurance-site/README.md +10 -0
  240. package/packages/theme-insurance-site/package.json +30 -0
  241. package/packages/theme-insurance-site/src/harvest.json +10 -0
  242. package/packages/theme-insurance-site/src/index.js +83 -0
  243. package/packages/theme-insurance-site/test/theme.test.mjs +19 -0
  244. package/packages/theme-shinshu-site/README.md +10 -0
  245. package/packages/theme-shinshu-site/package.json +30 -0
  246. package/packages/theme-shinshu-site/src/harvest.json +12 -0
  247. package/packages/theme-shinshu-site/src/index.js +83 -0
  248. package/packages/theme-shinshu-site/test/theme.test.mjs +19 -0
  249. package/packages/work-graph/README.md +49 -0
  250. package/packages/work-graph/package.json +19 -0
  251. package/packages/work-graph/prototype/README.md +32 -0
  252. package/packages/work-graph/prototype/data/demo-workgraph.js +47 -0
  253. package/packages/work-graph/prototype/renderers/timeline-model.js +21 -0
  254. package/packages/work-graph/prototype/renderers/workgraph-runtime.js +38 -0
  255. package/packages/work-graph/prototype-gnantt.html +655 -0
  256. package/packages/work-graph/src/adapters/business/projects.js +23 -0
  257. package/packages/work-graph/src/adapters/engineering/git.js +22 -0
  258. package/packages/work-graph/src/adapters/engineering/mcp.js +22 -0
  259. package/packages/work-graph/src/index.js +76 -0
  260. package/packages/work-graph/src/renderers/gantt-model.js +11 -0
  261. package/packages/work-graph/src/renderers/timeline.js +16 -0
  262. package/packages/work-graph/test/work-graph.test.mjs +37 -0
  263. package/protocol/README.md +12 -0
  264. package/protocol/capabilities/cloudflare-cpu-audit-input.schema.json +30 -6
  265. package/protocol/capabilities/cloudflare-cpu-profile-input.schema.json +18 -4
  266. package/protocol/capabilities/cloudflare-wrangler-native-input.schema.json +59 -10
  267. package/protocol/capabilities/knowledge-search-input.schema.json +35 -0
  268. package/protocol/capabilities/manifest.json +163 -1
  269. package/protocol/capabilities/repository-audit-input.schema.json +39 -6
  270. package/protocol/capabilities/repository-snapshot-input.schema.json +15 -3
  271. package/protocol/capabilities/terminal-exec-input.schema.json +55 -0
  272. package/protocol/commerce/catalog.v1.json +50 -0
  273. package/protocol/errors/error-catalog.json +164 -0
  274. package/protocol/errors/error-envelope.schema.json +544 -0
  275. package/protocol/features/README.md +57 -0
  276. package/protocol/features/agentsam.feature.v1.schema.json +290 -0
  277. package/protocol/features/catalog.json +65 -0
  278. package/protocol/features/examples/provider-resend.feature.json +17 -0
  279. package/protocol/go/agentsam-go-runtime.v1.json +17 -0
  280. package/protocol/knowledge/LIFECYCLE.md +140 -0
  281. package/protocol/knowledge/README.md +4 -0
  282. package/protocol/presets/catalog.json +128 -19
  283. package/protocol/rpc/v1/errors.proto +24 -0
  284. package/protocol/theme-refinery/d1-reconciliation.md +48 -0
  285. package/protocol/theme-refinery/product-metadata.schema.json +27 -0
  286. package/protocol/theme-refinery/receipts/products-registry-batch-20260924.json +318 -0
  287. package/protocol/theme-refinery/receipts/theme-harvest-20260924.json +472 -0
  288. package/protocol/theme-refinery/reconciliation-receipt.schema.json +83 -0
  289. package/services/cad/server.py +249 -2
  290. package/src/agent/capability-adapter.js +15 -5
  291. package/src/agent/index.js +2 -1
  292. package/src/agent/model-turn.js +51 -0
  293. package/src/agent/responses-runner.js +304 -38
  294. package/src/capabilities/index.js +1 -0
  295. package/src/capabilities/terminal-exec.js +78 -0
  296. package/src/cli.js +117 -9
  297. package/src/cloudflare/index.js +6 -0
  298. package/src/cloudflare/runtime-status.js +393 -0
  299. package/src/cloudflare/wrangler.js +17 -1
  300. package/src/commands/app.js +106 -0
  301. package/src/commands/autorag.js +77 -0
  302. package/src/commands/brand.js +293 -0
  303. package/src/commands/cad.js +1 -0
  304. package/src/commands/connections.js +126 -29
  305. package/src/commands/context-economics.js +8 -0
  306. package/src/commands/db.js +7 -0
  307. package/src/commands/env.js +5 -4
  308. package/src/commands/eval.js +209 -14
  309. package/src/commands/go.js +365 -0
  310. package/src/commands/goap.js +176 -0
  311. package/src/commands/identity-init.js +27 -3
  312. package/src/commands/identity-protocol.js +195 -0
  313. package/src/commands/knowledge.js +64 -5
  314. package/src/commands/mcp.js +341 -0
  315. package/src/commands/merkle-persist.js +3 -1
  316. package/src/commands/merkle.js +18 -3
  317. package/src/commands/models.js +109 -23
  318. package/src/commands/plugins.js +175 -0
  319. package/src/commands/preferences.js +28 -8
  320. package/src/commands/product.js +53 -10
  321. package/src/commands/providers.js +118 -37
  322. package/src/commands/resume.js +9 -5
  323. package/src/commands/runtime-status.js +154 -0
  324. package/src/commands/shell.js +466 -55
  325. package/src/commands/status.js +82 -7
  326. package/src/commands/tunnel.js +228 -195
  327. package/src/commands/whoami.js +78 -6
  328. package/src/context/budget.js +6 -0
  329. package/src/context/index.js +2 -1
  330. package/src/context/project-card.js +75 -0
  331. package/src/errors/contract.js +34 -211
  332. package/src/errors/diagnostic.js +95 -51
  333. package/src/errors/index.js +6 -13
  334. package/src/eval/index.js +6 -0
  335. package/src/eval/live.js +439 -0
  336. package/src/features/resolve.js +242 -0
  337. package/src/go/build.js +108 -0
  338. package/src/go/cloudflare.js +207 -0
  339. package/src/go/contract.js +139 -0
  340. package/src/go/discover.js +96 -0
  341. package/src/go/index.js +13 -0
  342. package/src/go/receipts.js +77 -0
  343. package/src/go/registry.js +223 -0
  344. package/src/go/verify.js +31 -0
  345. package/src/index.js +100 -1
  346. package/src/knowledge/config.js +13 -5
  347. package/src/knowledge/engine.js +23 -8
  348. package/src/knowledge/index.js +1 -0
  349. package/src/knowledge/lane-registry.js +46 -0
  350. package/src/knowledge/providers/gemini.js +48 -8
  351. package/src/knowledge/service/client.js +13 -1
  352. package/src/knowledge/service/grpc-codec.js +156 -53
  353. package/src/knowledge/service/job-engine.js +133 -11
  354. package/src/knowledge/service/job-worker.js +34 -5
  355. package/src/knowledge/service/server.js +10 -1
  356. package/src/knowledge/store-discovery.js +77 -0
  357. package/src/lib/account-session.js +8 -2
  358. package/src/lib/agent-instructions.js +3 -0
  359. package/src/lib/auth.js +7 -3
  360. package/src/lib/cad/blender.js +42 -3
  361. package/src/lib/cad/d1-project-store.js +43 -0
  362. package/src/lib/cad/discovery.js +616 -0
  363. package/src/lib/cad/docker-executor.js +352 -0
  364. package/src/lib/cad/freecad.js +253 -0
  365. package/src/lib/cad/index.js +40 -0
  366. package/src/lib/cad/openscad.js +198 -0
  367. package/src/lib/cad/project-cli.d.ts +2 -0
  368. package/src/lib/cad/project-cli.js +21 -0
  369. package/src/lib/cad/project-contract.d.ts +3 -0
  370. package/src/lib/cad/project-contract.js +1 -0
  371. package/src/lib/cad/project-recipe.js +30 -0
  372. package/src/lib/cad/project-runtime.d.ts +2 -0
  373. package/src/lib/cad/project-runtime.js +53 -0
  374. package/src/lib/cad/project-store.js +25 -0
  375. package/src/lib/cad/project-workflows.js +31 -0
  376. package/src/lib/cad-docker.js +21 -2
  377. package/src/lib/cli-preferences.js +17 -2
  378. package/src/lib/core-client.js +37 -18
  379. package/src/lib/deploy/local-studio.js +6 -5
  380. package/src/lib/dockerize.js +3 -0
  381. package/src/lib/execution-approvals.js +1 -0
  382. package/src/lib/identity-scaffold.js +4 -1
  383. package/src/lib/knowledge-docker.js +9 -1
  384. package/src/lib/local-sessions.js +124 -34
  385. package/src/lib/local-status.js +35 -14
  386. package/src/lib/project-config.js +9 -0
  387. package/src/lib/provider-credentials.js +73 -11
  388. package/src/lib/scaffold/resolve-cloudflare-account.js +37 -0
  389. package/src/lib/scaffold/wizards/cms.js +2 -8
  390. package/src/lib/scaffold/wizards/worker-api.js +2 -8
  391. package/src/lib/slash-commands.js +9 -2
  392. package/src/local/migrations.js +109 -1
  393. package/src/local/runtime-store.js +31 -5
  394. package/src/local/sqlite.js +36 -1
  395. package/src/mcp/authority.js +348 -0
  396. package/src/mcp/client-adapters.js +431 -0
  397. package/src/mcp/client.js +172 -0
  398. package/src/mcp/index.js +47 -0
  399. package/src/mcp/telemetry.js +103 -0
  400. package/src/models/catalog.js +329 -51
  401. package/src/models/discovery.js +24 -4
  402. package/src/models/index.js +2 -0
  403. package/src/models/inventory-core.js +182 -0
  404. package/src/models/policy.js +20 -0
  405. package/src/plugins/cloudflare.js +103 -0
  406. package/src/plugins/completeful.js +69 -0
  407. package/src/plugins/contracts.js +86 -0
  408. package/src/plugins/index.js +11 -0
  409. package/src/plugins/registry.js +207 -0
  410. package/src/plugins/resource-scope.js +45 -0
  411. package/src/plugins/runtime.js +118 -0
  412. package/src/plugins/vectorize.js +31 -0
  413. package/src/progression/engine.js +171 -0
  414. package/src/progression/index.js +1 -0
  415. package/src/providers/cloudflare-chat.js +1 -1
  416. package/src/providers/gemini-generate-content.js +2 -1
  417. package/src/providers/openai-responses.js +45 -16
  418. package/src/providers/tool-schema.js +85 -0
  419. package/src/repository/index.js +29 -0
  420. package/src/rpc/generated/errors_pb.js +961 -1
  421. package/src/security/local-vault.js +415 -0
  422. package/src/security/process.js +20 -4
  423. package/src/status/actions.js +192 -0
  424. package/src/tools/hydrate.js +5 -1
  425. package/src/tools/index.js +7 -0
  426. package/src/tools/redact.js +64 -0
  427. package/src/tools/registry.js +83 -0
  428. package/src/tools/runtime.js +257 -0
  429. package/src/tools/search.js +21 -8
  430. package/src/ui/ansi.js +117 -3
  431. package/src/ui/cli/activity.js +76 -7
  432. package/src/ui/cli/footer.js +110 -9
  433. package/src/ui/cli/help.js +11 -4
  434. package/src/ui/wireframes.js +166 -0
  435. package/test/account-session.test.mjs +28 -0
  436. package/test/apps-scaffold-contract.test.mjs +16 -1
  437. package/test/capabilities.test.mjs +1 -1
  438. package/test/cli/eval-live.test.mjs +219 -0
  439. package/test/cli/go.test.mjs +71 -0
  440. package/test/cli/local-vault-and-provider-setup.test.mjs +268 -0
  441. package/test/cli/mcp-client.test.mjs +245 -0
  442. package/test/cli/runtime-ui.test.mjs +69 -2
  443. package/test/cli/status-actions.test.mjs +88 -0
  444. package/test/cli/wireframes-go-registry.test.mjs +54 -0
  445. package/test/cloudflare-connector.test.mjs +3 -6
  446. package/test/cloudflare-runtime.test.mjs +8 -1
  447. package/test/context.test.mjs +15 -0
  448. package/test/error-diagnostics.test.mjs +9 -0
  449. package/test/fixtures/cad/courtyard-house.json +208 -0
  450. package/test/go/cloudflare-probe.test.mjs +53 -0
  451. package/test/integration/app-command.test.mjs +55 -0
  452. package/test/integration/cad-discovery.test.mjs +158 -0
  453. package/test/integration/cad-docker-executor.test.mjs +249 -0
  454. package/test/integration/cad-execution.test.mjs +184 -0
  455. package/test/integration/cad-project-app.test.mjs +31 -0
  456. package/test/integration/cad-project-d1.test.mjs +25 -0
  457. package/test/integration/cad-project-native.test.mjs +24 -0
  458. package/test/integration/cad-project-workflow.test.mjs +9 -0
  459. package/test/integration/cad-project.test.mjs +82 -0
  460. package/test/integration/cli-help.test.mjs +4 -0
  461. package/test/integration/cms-site-tenancy-contract.test.mjs +256 -0
  462. package/test/integration/core-client.integration.test.mjs +55 -0
  463. package/test/integration/error-runtime-rpc.test.mjs +71 -0
  464. package/test/integration/features-resolve.test.mjs +128 -0
  465. package/test/integration/install-script.test.mjs +107 -0
  466. package/test/integration/inventory-core.test.mjs +53 -0
  467. package/test/integration/plugins-cloudflare.integration.test.mjs +28 -0
  468. package/test/integration/provider-env-cli.test.mjs +1 -1
  469. package/test/integration/runtime-migrations.test.mjs +6 -1
  470. package/test/integration/runtime-status.integration.test.mjs +211 -0
  471. package/test/integration/scaffold-cloudflare.test.mjs +46 -0
  472. package/test/integration/storage-architecture.test.mjs +154 -0
  473. package/test/integration/store-discovery.test.mjs +44 -0
  474. package/test/integration/terminal-exec.integration.test.mjs +86 -0
  475. package/test/integration/tool-runtime.test.mjs +124 -0
  476. package/test/integration/tool-schema.test.mjs +59 -0
  477. package/test/knowledge-service.test.mjs +4 -0
  478. package/test/local-sessions.test.mjs +11 -2
  479. package/test/local-studio-deploy.test.mjs +1 -1
  480. package/test/model-catalog.test.mjs +28 -1
  481. package/test/models.test.mjs +159 -5
  482. package/test/openai-responses.test.mjs +60 -0
  483. package/test/provider-credentials.test.mjs +15 -5
  484. package/test/responses-runner.test.mjs +321 -6
  485. package/test/shell.test.mjs +149 -4
  486. package/test/smoke.mjs +2 -2
  487. package/test/tools-search.test.mjs +33 -0
  488. package/test/unit/website-assets-bindings.test.mjs +60 -0
  489. package/test/whoami-resume.test.mjs +82 -3
  490. package/examples/gorilla-shell/README.md +0 -15
  491. package/src/lib/gorilla-template.js +0 -54
  492. package/templates/gorilla-shell/App.tsx +0 -639
  493. package/templates/gorilla-shell/README.md +0 -34
  494. package/templates/gorilla-shell/index.html +0 -15
  495. package/templates/gorilla-shell/main.jsx +0 -9
  496. package/templates/gorilla-shell/package.json +0 -19
  497. package/templates/gorilla-shell/vite.config.js +0 -21
@@ -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.
@@ -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)
@@ -0,0 +1,113 @@
1
+ # AgentSam Interactive Shell — UI Requirements
2
+
3
+ Reference implementation: OpenAI Codex CLI's TUI, observed directly running
4
+ in `~/agentsam-sdk` on 2026-09-19. Codex is not the target — its specific
5
+ *patterns* are. Sam's stated reason for all five, verbatim: "trustworthy.
6
+ never wondering if my machine died/something failed. its present.
7
+ professional." That's the actual spec — every item below exists to answer
8
+ "is this thing still alive and what is it doing" at a glance, continuously,
9
+ without the user asking.
10
+
11
+ Read this whole file before touching UI code. Each item below is graded
12
+ against the real current state of `src/ui/cli/activity.js`,
13
+ `src/ui/cli/footer.js`, and `src/commands/shell.js` — checked directly, not
14
+ assumed.
15
+
16
+ ## 1. Elapsed-time "Working" indicator — mostly built, missing the interrupt hint
17
+
18
+ **Current state:** `src/ui/cli/activity.js`'s `createInlineActivity()` already
19
+ renders `◐ Working · 6.2s` with a live-updating spinner + elapsed time via
20
+ `setInterval`. This is the right foundation — reuse it, don't replace it.
21
+
22
+ **Gap:** Codex's line reads `Working (6s • esc to interrupt)`. Ours has no
23
+ interrupt hint. Add it to the `frame()` render in `activity.js`:
24
+
25
+ ```js
26
+ write(`\r${CLEAR_LINE} ${icon} ${label} ${pc.dim('· ' + elapsed(now() - startedAt) + ' · esc to interrupt')}`);
27
+ ```
28
+
29
+ Only show the hint when the shell is actually listening for an interrupt
30
+ keypress — don't print a false affordance. Wire the esc handler in
31
+ `shell.js` if one doesn't already exist for the active-task state.
32
+
33
+ ## 2. Shimmer/gradient sweep across the "Working" label
34
+
35
+ **Current state:** the spinner icon (◐◓◑◒) animates; the label text
36
+ (`Working`) is static plain `pc.cyan`. No gradient.
37
+
38
+ **Build:** a per-frame brightness/color sweep across the label characters —
39
+ the common technique is picking a moving highlight index into the string
40
+ and rendering characters near it brighter (or a different color) than the
41
+ rest, advancing the index each `frame()` tick alongside the spinner. This
42
+ stays inside `activity.js`'s existing `frame()` function — same timer, same
43
+ interval, just render the label through a small `shimmer(label, tick)`
44
+ helper instead of a flat `pc.cyan(label)`. Keep it subtle — "faint," per
45
+ the ask, not a strobe. Terminal color support varies; fall back to the
46
+ current flat rendering when `process.stdout` doesn't report truecolor/256
47
+ support, don't assume every terminal handles it.
48
+
49
+ ## 3. Persistent status footer — extend, don't rebuild
50
+
51
+ **Current state:** `renderCliFooter()` in `src/ui/cli/footer.js` already
52
+ renders `model · ctx N% · ↑tokens ↓tokens · [cache] · [tier] · [elapsed]`.
53
+ Solid foundation, wrong field set for this ask.
54
+
55
+ **Add two fields:**
56
+ - **Project/cwd** — the directory the session is rooted in. Codex shows
57
+ `directory: ~/agentsam-sdk` in its startup card and keeps it visible.
58
+ Pass `cwd` (already available everywhere `renderCliFooter` is called
59
+ from, per `shell.js`'s `state.cwd`) and prepend a shortened form (`~`-
60
+ collapsed, like Codex does) to the footer parts array.
61
+ - **Current action / connection state** — the live "what is this session
62
+ doing or waiting on" field, equivalent to Codex's `Log in to Cloudflare
63
+ API` in its title bar. This needs a piece of session state that gets set
64
+ whenever the shell is mid-auth-flow, mid-tool-call, or blocked on
65
+ something external, and cleared back to a neutral state (e.g. "Ready")
66
+ otherwise. Surface it in the footer render, not just the terminal title
67
+ bar — the terminal title updates only help if the user is looking at the
68
+ tab; the footer is always in view.
69
+
70
+ **Render order matters:** put project and current-action first/most
71
+ prominent since those answer "where am I and is it alive," with the
72
+ existing model/context/token detail after — that ordering matches why this
73
+ whole feature is being asked for.
74
+
75
+ ## 4. Inline diffs on file edits
76
+
77
+ **Current state:** not checked in depth against `fs_edit_file`/patch
78
+ call sites — flagging as a requirement, not yet scoped. When an
79
+ interactive session edits a file (`fs_edit_file`, `agentsam_github_patch`
80
+ equivalents, or anything routed through the scaffold/CMS write paths),
81
+ show a compact unified diff (red/green line-level) inline in the session
82
+ output, the way Codex renders a diff block immediately after an edit
83
+ tool call. Don't build a separate diff renderer if one already exists
84
+ elsewhere in the SDK (check `src/ui/` and `src/lib/` for an existing
85
+ diff-formatting utility before writing a new one — this is exactly the
86
+ kind of thing that gets silently reinvented).
87
+
88
+ ## 5. Paste-collapse for large pasted input
89
+
90
+ **Current state:** not present. Pasting a large block into the interactive
91
+ prompt currently shows the raw text inline (or is unhandled — check
92
+ `readline` setup in `shell.js`).
93
+
94
+ **Build:** detect a paste event (readline's `keypress`/bracketed-paste
95
+ handling, or a heuristic on input arriving faster than typing speed),
96
+ and once pasted content crosses a size threshold, collapse the prompt
97
+ display to `[Pasted Content N chars]` — keeping the full content as the
98
+ actual submitted value, only changing what's rendered in the input line.
99
+ Codex's threshold and exact wording are the reference; match that format
100
+ (`[Pasted Content <n> chars]`) since it's already a pattern the user
101
+ recognizes from daily use.
102
+
103
+ ## Implementation order
104
+
105
+ 1. §1 (interrupt hint) — smallest change, extends existing working code.
106
+ 2. §3 (footer fields) — second smallest, same file, no new subsystems.
107
+ 3. §5 (paste-collapse) — self-contained in `shell.js`'s input handling.
108
+ 4. §2 (shimmer) — cosmetic, do after the functional gaps are closed.
109
+ 5. §4 (inline diffs) — needs a scoping pass first (check for an existing
110
+ diff renderer before writing one); do last.
111
+
112
+ None of this blocks anything else in the current laundry list — it's a
113
+ parallel track, not a dependency of the auth-closure or scaffold work.
@@ -0,0 +1,85 @@
1
+ # AgentSam Interactive CLI UI/UX Requirements
2
+
3
+ **Authority:** `AGENTSAM.md`
4
+ **Status:** Implemented on `feat/cli-interactive-presence` (PR #56)
5
+ **Target:** Interactive terminal shell (`agentsam shell` / `src/commands/shell.js`)
6
+
7
+ ---
8
+
9
+ ## 1. Context & Motivation
10
+
11
+ AgentSam's interactive shell provides a developer-facing agent environment. While core reasoning and tool execution run beneath the surface, the terminal UI must deliver immediate responsiveness, spatial awareness, and non-blocking control comparable to Codex CLI.
12
+
13
+ Existing primitives (`src/ui/cli/activity.js`, `src/ui/cli/footer.js`) provide the baseline spinner, token counts, and basic footers. This specification establishes the five critical UX behaviors required for a production-grade interactive terminal.
14
+
15
+ ---
16
+
17
+ ## 2. The Five Core UX Patterns
18
+
19
+ ### 2.1 Elapsed Timer with Interrupt Hint
20
+ - **Behavior:** During model generation or tool execution, the inline activity indicator must display a running timer and explicit interrupt guidance.
21
+ - **Display format:**
22
+ ```text
23
+ ◐ Working · 6.2s · ctrl-c to cancel
24
+ ```
25
+ - **Lifecycle:**
26
+ - Spinner cycles through unicode states (`◐ ◓ ◑ ◒`).
27
+ - Timer updates at ~100ms intervals.
28
+ - On SIGINT (`Ctrl+C`), gracefully aborts the in-flight step and preserves session context.
29
+
30
+ ### 2.2 Shimmer / Active State Sweep
31
+ - **Behavior:** The active status label ("Working", "Executing tool", "Synthesizing") undergoes a smooth visual highlight sweep across the text, indicating live background compute.
32
+ - **Rendering details:**
33
+ - Truecolor ANSI gradient sweep across character indices.
34
+ - 256-color fallback on restricted terminals.
35
+ - Complete bypass (static text) when `NO_COLOR` is set in the environment or terminal does not support colors.
36
+
37
+ ### 2.3 Persistent Model, Project, and Connection Status Footer
38
+ - **Behavior:** Printed at shell start and refreshed after commands or state changes to maintain environmental orientation.
39
+ - **Fields:**
40
+ - **Project identity & root:** Name, directory path.
41
+ - **Git status:** Current branch, clean/dirty state.
42
+ - **Active model:** Model identifier, provider, reasoning mode.
43
+ - **Context window usage:** Input/output tokens, % of context window consumed.
44
+ - **Shortcuts bar:** Quick reference for `/` commands, `@` file references, `!` shell escapes, and cancellation.
45
+
46
+ ### 2.4 Diff Preview Formatter (`/diff`)
47
+ - **Behavior:** When the user enters `/diff` or asks for review, format git diffs with high-legibility syntax highlighting directly in the terminal stream.
48
+ - **Formatting rules:**
49
+ - Header lines: bold cyan / dim path metadata.
50
+ - Hunk headers (`@@ ... @@`): magenta / bold.
51
+ - Additions (`+`): emerald green.
52
+ - Deletions (`-`): rose red.
53
+ - Must strictly honor `NO_COLOR` to avoid corrupting scripted outputs or piped terminals.
54
+
55
+ ### 2.5 Bracketed Paste Collapsing
56
+ - **Behavior:** Pasting large blocks of code, error stack traces, or logs into the prompt must not flood the terminal scrollback or disorient the user.
57
+ - **Threshold:** Input exceeding **5 lines** OR **300 characters**.
58
+ - **Display format:**
59
+ ```text
60
+ [Pasted 42 lines (1,840 chars) — Enter to run, Backspace to clear]
61
+ ```
62
+ - **Keybindings:**
63
+ - `Enter`: Submit the collapsed payload directly to the model turn.
64
+ - `Backspace`: Discard the pasted block cleanly without leaving dangling characters.
65
+ - Normal typing remains un-collapsed.
66
+
67
+ ---
68
+
69
+ ## 3. Implementation Map
70
+
71
+ | Requirement | Module | Contract / Export |
72
+ |---|---|---|
73
+ | Elapsed timer & interrupt hint | `src/ui/cli/activity.js` | `createInlineActivity({ interruptHint: true })` |
74
+ | Truecolor shimmer sweep | `src/ui/cli/activity.js` | `renderShimmer(text, frame)` |
75
+ | Persistent status footer | `src/ui/cli/footer.js` | `renderCliFooter(state)` |
76
+ | Diff preview renderer | `src/ui/cli/footer.js` | `renderDiffPreview(diffText)` |
77
+ | Bracketed paste collapsing | `src/commands/shell.js` | Paste buffer interceptor in readline loop |
78
+
79
+ ---
80
+
81
+ ## 4. Verification Contract
82
+
83
+ - `test/cli/runtime-ui.test.mjs`: Validates ANSI formatting, shimmer fallback under `NO_COLOR`, footer fields, and diff coloration.
84
+ - `test/shell.test.mjs`: Validates readline paste collapse and command execution flow.
85
+ - Zero ANSI escape code leakage into non-interactive or file-redirected runs.