@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
@@ -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.
@@ -0,0 +1,181 @@
1
+ # AgentSam as an MCP client — plan
2
+
3
+ `main` @ `14b6454` (PR #58 merged). Read this whole file before touching
4
+ anything. This closes a real, verified gap, not a speculative feature:
5
+ `agentsam_tool_call_log` — the account's own real call-telemetry table —
6
+ shows zero rows with `source_client: cursor` or `codex`, ever, while
7
+ `chatgpt` and `claude_ai` have thousands between them. Cursor's own
8
+ `~/.cursor/mcp.json` is `{"mcpServers": {}}` — genuinely never configured,
9
+ globally. `agentsam mcp add` does not exist; `agentsam add` is a different,
10
+ unrelated command (`runAdd()` writes `.agentsam/features.json` for product
11
+ add-ons, nothing to do with MCP).
12
+
13
+ ## Why this is worth building now, not later
14
+
15
+ `inneranimalmedia-mcp-server` is proven infrastructure — real accounts, ~218
16
+ tools, actively used daily by two people, with its own D1-backed telemetry
17
+ already built for exactly this purpose (`agentsam_tool_call_log`,
18
+ `agentsam_mcp_tool_execution`). Making `agentsam` itself a client of it means
19
+ every native-agentsam tool call gets the same receipt quality Cursor/Codex
20
+ calls already get when they're properly connected — not a separate
21
+ observability project, a side effect of wiring this correctly once.
22
+
23
+ The live server: `https://mcp.inneranimalmedia.com/mcp`, OAuth beginning at
24
+ `https://mcp.inneranimalmedia.com/auth/connect`. The external-client spine
25
+ already recognizes Cursor specifically —
26
+ `src/mcp/dispatch/external-mcp-spine.js` (in `inneranimalmedia`) mints
27
+ `cursor_mcp:<external-chat>` conversation ids, `arun_mcp_cursor_<short>` run
28
+ ids, `source_client: cursor` — the server side is ready and waiting. The gap
29
+ is entirely client-side, in `agentsam-sdk`.
30
+
31
+ ## What NOT to build
32
+
33
+ - Don't hand-roll the MCP JSON-RPC protocol. Use `@modelcontextprotocol/sdk`
34
+ — a standard client library exists; this is transport plumbing, not novel
35
+ design.
36
+ - Don't make `~/.cursor/mcp.json` (or any one client's config file) the
37
+ authority. It's an adapter output, not the source of truth — same pattern
38
+ as everything else in this repo. AgentSam's own connection state is
39
+ authoritative; each client config gets generated/synced from it.
40
+ - Don't overload the existing `agentsam add` command. MCP is a distinct
41
+ first-class noun.
42
+ - Don't conflate this with `agentsam eval live` (below) — MCP client wiring
43
+ produces the raw telemetry; eval-live turns telemetry into graded
44
+ observations. Two different pieces, sequenced, not merged into one PR.
45
+
46
+ ## CLI surface
47
+
48
+ ```
49
+ agentsam mcp add inneranimalmedia
50
+ agentsam mcp add inneranimalmedia --client cursor
51
+ agentsam mcp status
52
+ agentsam mcp doctor inneranimalmedia
53
+ agentsam mcp list
54
+ agentsam mcp remove inneranimalmedia
55
+ ```
56
+
57
+ `agentsam mcp add inneranimalmedia` flow:
58
+
59
+ ```
60
+ agentsam mcp add inneranimalmedia
61
+ │
62
+ ├── detect installed clients (Cursor / Claude / etc.)
63
+ ├── open IAM OAuth (mcp.inneranimalmedia.com/auth/connect)
64
+ ├── user consents
65
+ ├── receive MCP credential
66
+ ├── store credential securely under ~/.agentsam/mcp/inneranimalmedia.json
67
+ ├── materialize client adapter(s)
68
+ │ └── e.g. ~/.cursor/mcp.json, generated from AgentSam's own state
69
+ ├── call MCP initialize
70
+ ├── tools/list
71
+ ├── ping
72
+ └── ✓ connected
73
+ ```
74
+
75
+ Same shape as `codex mcp add cloudflare-api --url ... ` — that's the UX bar,
76
+ not just an analogy.
77
+
78
+ ## Where state lives
79
+
80
+ `~/.agentsam/mcp/<server-name>.json` is the connection authority. Client
81
+ configs (`~/.cursor/mcp.json`, Claude Desktop's config, etc.) are generated
82
+ adapters written *from* that state, not edited by hand and not treated as
83
+ sources of truth. Same "one authority, N adapters" pattern as everything
84
+ else audited in this repo tonight — don't special-case MCP.
85
+
86
+ ### The role of `~/.agentsam/mcp.json` vs the connection authority
87
+
88
+ A natural question arises: why not also materialize `~/.agentsam/mcp.json`?
89
+
90
+ 1. **Not for the main CLI itself (avoiding self-indirection):**
91
+ The main CLI process is the codebase that owns the authority
92
+ (`~/.agentsam/mcp/<server>.json`). That authoritative file holds rich
93
+ metadata: protocol, auth flow details, registered clients, health metrics,
94
+ and custom headers. Having the main CLI write a stripped-down
95
+ `~/.agentsam/mcp.json` (`{ mcpServers: { ... } }`) and then read that back
96
+ would be pure self-indirection and introduces drift between two
97
+ representations of the same state in the exact same process.
98
+
99
+ 2. **As the portable adapter for the `apps/` family and standalone SEAs:**
100
+ Where `~/.agentsam/mcp.json` is genuinely useful is serving other
101
+ independent binaries in the AgentSam ecosystem (`apps/cad-creator`,
102
+ `apps/local-studio`, `agentsam-cms`, or standalone Node-free SEAs). These
103
+ are separate executables that may act as MCP clients. They must NOT be
104
+ tightly coupled to the CLI's internal `authority.js` module or its internal
105
+ file layout. Materializing `~/.agentsam/mcp.json` provides a standard,
106
+ portable, standards-compliant `{ "mcpServers": { ... } }` config that any
107
+ sibling app can read directly without module coupling.
108
+
109
+ Therefore, `~/.agentsam/mcp.json` is treated strictly as an **adapter for
110
+ sibling apps/binaries**, never as the CLI's internal source of truth.
111
+
112
+ ## Catalog merging — the actual hard part
113
+
114
+ Once connected, an MCP server's tool list has to sit alongside the native
115
+ `protocol/capabilities/manifest.json` catalog for whatever model the
116
+ interactive session is driving — not as a second, separately-searched
117
+ system. Extend the existing `src/tools/search.js`/`hydrate.js` layer to
118
+ treat a connected MCP server's `tools/list` result as another source
119
+ feeding the same search/hydrate index, tagged with its origin so collisions
120
+ (a connected server offering something the native manifest already has) are
121
+ detectable the same way the tools.js dedup audit found `handler_key`
122
+ collisions earlier tonight. Don't build a second, parallel discovery path.
123
+
124
+ ## Telemetry — the actual payoff
125
+
126
+ Every call made through a connected MCP server from an `agentsam` session
127
+ should land in `agentsam_tool_call_log` with real `source_client`
128
+ attribution (`agentsam`, not blank/unknown), the same schema Cursor and
129
+ Codex would use if *they* were writing there. This is what closes the
130
+ observability gap — not a new table, just making sure agentsam's own calls
131
+ go through the same pipe.
132
+
133
+ ## Related, sequenced after this: `agentsam eval live`
134
+
135
+ Don't overload the existing deterministic `agentsam eval context` (which
136
+ explicitly reports `live_provider_used: false` — it's offline/deterministic
137
+ by design, leave it that way). Add a separate live-capture path:
138
+
139
+ ```
140
+ agentsam eval live start \
141
+ --suite sdk-real-work-20260919 \
142
+ --case cad-shell-unification \
143
+ --client cursor \
144
+ --provider cursor \
145
+ --model "Muse Spark 1.3" \
146
+ --reasoning high
147
+
148
+ ... real work happens, MCP calls land in agentsam_tool_call_log /
149
+ agentsam_mcp_tool_execution / agentsam_tool_call_outcomes /
150
+ agentsam_tool_chain via the client wired above ...
151
+
152
+ agentsam eval live finish
153
+ ```
154
+
155
+ `eval live finish` aggregates the real receipts collected during the
156
+ session and writes to `agentsam_eval_runs` (the primary model-comparison
157
+ row) and `agentsam_model_eval_observations` (supporting evidence) —
158
+ built from *actual* tool-call receipts, not re-typed after the fact. One
159
+ important constraint to respect: the MCP server can know what tool was
160
+ called, when, duration, success/failure, cache state, resource touched,
161
+ retries, authorization outcome — it cannot know a connected client's own
162
+ hidden model token usage. Combine what MCP telemetry actually knows with
163
+ whatever the client/CLI session itself reports (git/test/CI evidence,
164
+ commit/PR references) rather than inventing precision that isn't there.
165
+ Model tokens/cost from a third-party client should read "unknown /
166
+ client-reported if available," not a fabricated number.
167
+
168
+ ## Order of operations
169
+
170
+ 1. `agentsam mcp add/status/doctor/list/remove` — the client transport +
171
+ connection-state authority + first adapter (Cursor, since that's the
172
+ proven daily-use client with zero current telemetry).
173
+ 2. Catalog merge in `search.js`/`hydrate.js`.
174
+ 3. Telemetry wiring into `agentsam_tool_call_log` with correct
175
+ `source_client`.
176
+ 4. `agentsam eval live start/finish`, once real MCP telemetry is flowing —
177
+ this step is worthless without step 3 landing first.
178
+
179
+ Do not skip ahead to `eval live` before the transport and telemetry wiring
180
+ are real — that would just recreate the exact "manual/intentional eval
181
+ recording, not an automatic facility" gap this plan exists to close.
@@ -0,0 +1,34 @@
1
+ # Portable WorkGraph / Gantt UI — deferred
2
+
3
+ **Priority:** low (plan only — do not block ASBD home / help / CMS work)
4
+
5
+ ## Intent
6
+
7
+ Salvage `agentsam-lab` `prototype-gnantt.html` into a **lightweight portable UI** that can mount inside:
8
+
9
+ - `apps/local-studio` work surface
10
+ - optional CLI-adjacent localhost monitor for AgentSam agent work
11
+ - future package distribution (not required for first cut)
12
+
13
+ ## Constraints
14
+
15
+ - Visual shell must use **ASBD** (`asbd-tokens` / header/footer or studio nav from `@inneranimalmedia/agentsam-nav`) — not the purple lab prototype tokens as SSOT
16
+ - Keep WorkGraph data contract aligned with `agentsam-sdk/packages/work-graph` (canonical; lab copy is stale)
17
+ - No new product world; this is a reusable widget, not a standalone app
18
+
19
+ ## Suggested peel
20
+
21
+ ```text
22
+ packages/agentsam-workgraph-ui/ (or apps/local-studio/frontend widget)
23
+ ├── board/ list/ gantt projections
24
+ ├── ASBD token mapping
25
+ └── mount API for Studio + static preview
26
+ ```
27
+
28
+ ## Non-goals now
29
+
30
+ - Full rewrite of lab Worker
31
+ - Shipping Gantt as the AgentSam marketing homepage
32
+ - Blocking packages/services help page publish
33
+
34
+ Resume after ASBD home + help/doc pattern are live on `agentsam.inneranimalmedia.com`.
@@ -0,0 +1,258 @@
1
+ # Astra Brief — agentsam-sdk consolidation, 2026-09-18
2
+
3
+ > **HISTORICAL / BACKLOG ONLY — not live status.**
4
+ >
5
+ > Current status authority:
6
+ > [`RECONCILIATION-2026-09-19.md`](./RECONCILIATION-2026-09-19.md)
7
+ >
8
+ > As of 2026-09-19, `main` / `origin/main` is
9
+ > `88cb30daadf20b8ca22aad29dad826055cec6998` (PR #51 merged — project-owned
10
+ > SQLite runtime). Do **not** use the old “main is at 0795d92 (PR #50)” line.
11
+ >
12
+ > Also superseded here: auth-closure “still open”, `help all` broken,
13
+ > work-graph still orphaned, and treating `platform_identity_missing` as an
14
+ > OAuth/auth-closure fix. Remote terminal enrollment remains open as a
15
+ > **separate** pairing/provisioning gap — see the reconciliation doc.
16
+
17
+ This file remains useful as backlog/reference for architectural drift items
18
+ and scaffold-from-real-app design questions. It is **not** ground truth over
19
+ live git. Recheck every “still open” claim against the reconciliation doc
20
+ and `origin/main` before acting.
21
+
22
+ ---
23
+
24
+ ## 0. Operating rules (apply to all of this, not just one task)
25
+
26
+ - Patches over rewrites. Backup before editing (`cp file file.bak`), verify
27
+ with `node -c` after any JS edit, diff against the backup before trusting
28
+ a change.
29
+ - Never hardcode IDs (account IDs, D1 database IDs, etc). Auto-detect from
30
+ existing credential/registry systems — see the Cloudflare account fix
31
+ below for the pattern.
32
+ - Non-fatal DB writes always.
33
+ - No `npm publish` unless explicitly told to. The human publishes after
34
+ final validation.
35
+ - Before declaring anything "done," run it live and paste the actual
36
+ output. Do not report completion on code you haven't executed.
37
+ - Do not delete useful historical branches/worktrees.
38
+ - If you find a scaffold/generator/duplicate that already exists somewhere
39
+ else in the repo or in a sibling app, map old → new capability before
40
+ writing anything new. Do not silently reinvent something already built —
41
+ check `protocol/capabilities/manifest.json` and the D1 `agentsam_tools`
42
+ registry first.
43
+
44
+ ---
45
+
46
+ ## 1. Already done tonight — do not redo, verify then build on top
47
+
48
+ 1. **`src/cli.js`**: `scaffold` is now a registered command
49
+ (`agentsam scaffold`, `agentsam scaffold cms`, `agentsam scaffold
50
+ worker-api` all reach the wizard — previously "Unknown command").
51
+ Backup: `src/cli.js.bak`.
52
+ 2. **Cloudflare account auto-detection**: `src/commands/env.js` now
53
+ exports `detectCloudflareAccounts()` (was private). New shared module
54
+ `src/lib/scaffold/resolve-cloudflare-account.js` wraps it — auto-fills
55
+ the account ID silently when exactly one account is detected, offers a
56
+ picker when there are multiple, only falls back to manual text entry if
57
+ detection genuinely fails. Both `wizards/cms.js` and
58
+ `wizards/worker-api.js` now call this instead of a raw `text()` prompt
59
+ asking the user to hand-paste an ID that `agentsam cloudflare` already
60
+ knows. Verified live: resolves to `ede6590ac0d2fb7daf155b35653457b2`
61
+ ("Info@inneranimals.com's Account") with zero prompts.
62
+ 3. **`src/lib/scaffold/templates/worker-api/index.js` +
63
+ `templates/cms/index.js` + `templates/wrangler-dev/...`** (3 templates
64
+ total, confirmed by grep): added `RUN apk add --no-cache python3 make
65
+ g++` before `npm ci`/`npm install` in every generated Dockerfile. Root
66
+ cause was `node-pty` (and any other native addon) failing to build
67
+ inside `node:20-alpine` because alpine ships no Python/build toolchain
68
+ by default. Verified against the actual `docker build` failure log from
69
+ `agentsam dockerize`.
70
+ 4. **Downloads cleanup**: `~/Downloads/agentsam-cmsstack-sdk` (+ `.zip`)
71
+ deleted — confirmed to be a stray duplicate download of this exact repo
72
+ (identical `cms.js`, same package name/version, contained a dead
73
+ `/mnt/user-data/outputs/` container path proving it was a leftover AI
74
+ session export). Nothing unique was lost.
75
+ 5. **`~/agent-worktrees/`**: pruned from 4.1GB/140 dirs to 1.6GB/8 dirs.
76
+ Every deletion was verified via `git merge-base --is-ancestor <sha>
77
+ origin/main` before removal — nothing unmerged was touched. `git
78
+ worktree prune` was run on all 5 affected canonical repos afterward so
79
+ git's own metadata doesn't reference dead paths.
80
+ 6. **`.bak` file sweep**: cleared stray `.bak` files across the user's
81
+ home directory. Deliberately left alone: anything inside another app's
82
+ own state (Chrome, Codex, pm2, CapCut), anything in a named backup
83
+ directory (`.agentsam/backups/`, `.local-backups/`), and
84
+ `agentsam-sdk/src/cli.js.bak`/`env.js.bak`/wizard `.bak` files created
85
+ tonight as active revert points for the fixes above — do not delete
86
+ those without checking they're no longer needed first.
87
+
88
+ ---
89
+
90
+ ## 2. The real architectural problem: three overlapping "AgentSam" truths
91
+
92
+ This surfaced from an external audit (pasted into this session, not
93
+ generated by me) auditing `agentsam-sdk/main @ c8461522`. It is accurate
94
+ and still the single highest-leverage finding. Full detail in that audit;
95
+ summary of what to actually do:
96
+
97
+ - **Legacy runtime island.** `src/AgentSam.js`, `src/lib/router.js`,
98
+ `src/lib/sessions.js`, `src/lib/tools.js` are a compatibility surface
99
+ still publicly exported, coexisting with the real modern runtime
100
+ (`src/local/runtime-store.js` → `agentsam_agent_run`). Label this
101
+ `LEGACY COMPATIBILITY SURFACE / NOT RUNTIME AUTHORITY`, don't delete
102
+ blind — consumer-search → deprecate → adapter → remove.
103
+ - **Tool duplication.** `src/lib/tools.js` (fake `fullstack/cms/data` tool
104
+ names) duplicates the real, much more mature
105
+ `protocol/capabilities/manifest.json` + `src/tools/search.js` +
106
+ `src/tools/hydrate.js` (search cheap cards → hydrate full schema only
107
+ when needed). `tools.js` should not remain a second tool authority —
108
+ route everything through the capability manifest + search/hydrate
109
+ pattern instead.
110
+ - **Command dispatcher drift.** `src/cli.js`'s if/else chain (~35 cases),
111
+ `src/lib/slash-commands.js` (27 interactive commands), and help text are
112
+ three independently-maintained descriptions of the same surface. Target:
113
+ a single command manifest (schema: cli aliases, slash aliases, handler
114
+ module, capability id, requirements, side effects, help text) that
115
+ generates CLI routing, slash routing, help output, and tool-card
116
+ discovery from one source. `printLegacyHelp()` is already known-stale —
117
+ delete/replace it once the manifest exists.
118
+ - **`agentsam help all`** — **superseded 2026-09-19:** implemented in
119
+ `src/ui/cli/help.js` (`all` / `--all` → full map). Verified live on main.
120
+ - **Stale vocabulary.** `workspace_id` is marked deprecated in
121
+ `protocol/knowledge/retrieval-query.schema.json` but still actively
122
+ validated in `src/knowledge/contracts.js`. Needs a
123
+ `architecture/vocabulary.yaml` with `forbidden_new_identifiers` that CI
124
+ enforces, with explicit exemptions for genuine back-compat code.
125
+ - **No lineage object.** IDs exist everywhere (trace_id, run_id,
126
+ tool_call_id, terminal_job_id) but nothing ties them together end to
127
+ end. Introduce a minimal `ExecutionLineage` identity object (see full
128
+ audit for the shape) — not a mega-record, just an id-correlation type
129
+ that every subsystem's receipts carry.
130
+ - **`architecture/modules.yaml` + extend `scripts/verify-source-boundaries.mjs`.**
131
+ The verifier already catches cross-boundary imports; it doesn't yet know
132
+ about module ownership/authority. Define modules (identity, models,
133
+ repository, workbench, telemetry, knowledge, etc.) with declared
134
+ ownership and forbidden dependencies, then let CI enforce it.
135
+
136
+ None of this is urgent-tonight work. It's the map for anything bigger than
137
+ a one-off patch — check it before doing structural work so you're not
138
+ fighting the same drift the audit already named.
139
+
140
+ ---
141
+
142
+ ## 3. Scaffold system: real apps exist, `scaffold` doesn't know about them
143
+
144
+ **Confirmed by direct inspection, not assumption:**
145
+
146
+ - `apps/client-cms-editor/` — real backend Worker (`backend/src`,
147
+ `backend/worker`), real frontend (Vite, has a built `dist/`),
148
+ `shared/cms/`, `IMPORT_PROVENANCE.json` tracking a donor import. This is
149
+ a working CMS editor app — the actual thing shown live at
150
+ `inneranimalmedia.com/dashboard/cms/templates` (media panel,
151
+ Content/Style/Page/Theme/Crm tabs, Publish button, draft/live state).
152
+ - `apps/cad-creator/` — same shape: real backend + frontend, `shared/cad/`,
153
+ its own `bin/agentsam-cad-creator.mjs`, a pre-built publishable tarball
154
+ (`inneranimalmedia-agentsam-sdk-cad-creator-0.1.0.tgz`), a
155
+ `scripts/verify-publish-package.mjs`. Sam calls this "still in shambles"
156
+ visually/UX-wise, not structurally — the plumbing toward "this becomes
157
+ its own installable package" already exists.
158
+ - `apps/local-studio/` — this **is** `agentsam.inneranimalmedia.com`,
159
+ confirmed live (HTTP 200, serving the real production app — the
160
+ lead-chat + co-worker split-pane + in-browser preview + Monaco file
161
+ browser UX shown in tonight's screenshots).
162
+
163
+ **The gap:** `agentsam scaffold cms` currently runs the old, thin
164
+ `wizards/cms.js` → `templates/cms/index.js` generator, which produces a
165
+ disconnected static Worker+D1+R2 skeleton with content *routes* but zero
166
+ editor (`grep -il "editor\|admin\|dashboard"` across its generated file
167
+ tree returns nothing). `agentsam scaffold cad-creator` doesn't exist at
168
+ all. Both scaffolds should instead **stand up a real instance of the
169
+ actual app** (`apps/client-cms-editor`, `apps/cad-creator`) — parameterized
170
+ the way `client-cms-editor`'s own `IMPORT_PROVENANCE.json` already tracks
171
+ donor-import parameterization — not regenerate a toy from scratch.
172
+
173
+ **Task, when picked up:** design the scaffold-from-real-app flow. Open
174
+ questions to resolve, don't guess:
175
+ - What's template vs. fixed platform code in each app (which files get
176
+ parameterized per new project vs. which are shared platform code that
177
+ shouldn't fork).
178
+ - Whether D1/R2/Worker bindings get created fresh per scaffolded project or
179
+ reuse a shared multi-tenant backend.
180
+ - Whether this is a `git subtree`/template-repo mechanism or an explicit
181
+ file-copy-and-parameterize step in `src/lib/scaffold/`.
182
+
183
+ Do not build this blind — come back with the plan before writing scaffold
184
+ code for either.
185
+
186
+ ---
187
+
188
+ ## 4. `packages/work-graph` — pull it out of `agentsam-lab`, register it
189
+
190
+ `~/agent-worktrees/agentsam-lab/packages/work-graph/` has a real, working
191
+ implementation: `src/index.js`, `renderers/{gantt-model,timeline}.js`,
192
+ `adapters/engineering/{git,mcp}.js`, `adapters/business/projects.js`. One
193
+ graph model (WorkItem, Dependency, TimelineEvent, Artifact, Evidence,
194
+ Actor) powers two adapters (engineering: git/MCP/tests/deploys; business:
195
+ projects/clients/approvals/milestones) with the Gantt/timeline UI as a
196
+ pure renderer over it — correct architecture, just orphaned. It was
197
+ deployed once to `agentsam.inneranimalmedia.com` but that route is now
198
+ superseded by the real production app (`local-studio`); the prototype
199
+ (`prototype-gnantt.html` + `workgraph-runtime.js` + `timeline-model.js` +
200
+ `demo-workgraph.js`) is intact but unreachable.
201
+
202
+ Given the existing `packages/` layout (`agentsam-contracts`,
203
+ `agentsam-repository`, `agentsam-shell-kit`, `agentsam-site-scrape`,
204
+ `agentsam-workbench`, `connectors`, `identity`), this becomes its own
205
+ sibling: **`packages/work-graph`** — not folded into `agentsam-workbench`
206
+ (that's UI-only) or `agentsam-contracts` (that's schemas). Once it has a
207
+ real `package.json`, register it in
208
+ `protocol/capabilities/manifest.json` so it's the answer next time
209
+ anything (local-studio, client-cms-editor, cad-creator) needs a task
210
+ timeline instead of a fresh one-off getting built and re-orphaned.
211
+
212
+ Mechanical, low-risk — good first pickup if the scaffold-app design work
213
+ above is blocked on decisions.
214
+
215
+ ---
216
+
217
+ ## 5. `release/2.6.2-auth-closure` — SUPERSEDED (merged)
218
+
219
+ **Superseded 2026-09-19:** this branch tip is an ancestor of `main`. Do not
220
+ treat auth-closure as still open.
221
+
222
+ **Remote terminal note (corrected):** `platform_identity_missing` on
223
+ `terminal_remote` is **not** the CLI OAuth bug and was **not** closed by
224
+ auth-closure / PR #450. Live host evidence showed `connection_key_set: false`
225
+ with null `account_id` / `connection_id` / `instance_id` under
226
+ `control_plane_auth_mode: platform_bridge` — an enrollment/pairing gap.
227
+ See `RECONCILIATION-2026-09-19.md` §B.
228
+
229
+ ---
230
+
231
+ ## 6. Small standalone fix, do anytime — `agentsam` self-update UX
232
+
233
+ Codex CLI (`~/.nvm/.../bin/codex`) shows a clean "Update available:
234
+ 0.154.0 → 0.155.1, release notes: <link>, [1] Update now / [2] Skip / [3]
235
+ Skip until next version" prompt on launch. `agentsam` has no equivalent —
236
+ add a lightweight version-check-on-launch (compare local package version
237
+ against the published npm registry version, non-blocking, same
238
+ update-now/skip/skip-until-next-version shape). Keep it out of the hot
239
+ path if the check would add latency — background check + cache is fine.
240
+
241
+ ---
242
+
243
+ ## 7. Suggested order of operations
244
+
245
+ Order superseded — use `RECONCILIATION-2026-09-19.md` §D. Historical list
246
+ kept only for archaeology:
247
+
248
+ 1. ~~`agentsam help all`~~ done on main.
249
+ 2. ~~`packages/work-graph` extraction~~ present on main.
250
+ 3. Scaffold-from-real-app design doc for `cms`/`cad-creator` (still open).
251
+ 4. ~~`release/2.6.2-auth-closure`~~ merged; remote terminal is a separate enrollment track.
252
+ 5. `agentsam` self-update UX (still open, low priority).
253
+ 6. Bigger architectural items in §2 — backlog only.
254
+
255
+ Report back the way the auth-closure brief specifies: what's done, what's
256
+ verified live (paste actual output, not "should work"), what's
257
+ intentionally deferred and why, and the exact single next action if
258
+ something needs Sam directly (a credential, a login, a decision).