@inneranimalmedia/agentsam-sdk 2.6.7 → 2.6.9

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 (371) hide show
  1. package/README.md +37 -0
  2. package/apps/README.md +25 -0
  3. package/apps/cad-creator/shared/cad/package.json +1 -1
  4. package/apps/client-cms-editor/backend/package.json +4 -6
  5. package/apps/client-cms-editor/frontend/package.json +6 -8
  6. package/apps/client-cms-editor/frontend/tsconfig.json +27 -8
  7. package/apps/client-cms-editor/package.json +1 -1
  8. package/apps/client-cms-editor/shared/cms/package.json +4 -6
  9. package/docs/LOCAL_ENGINE_COMPUTE_AUDIT_PLAN.md +299 -0
  10. package/docs/REPO_FILE_MAP.txt +132 -0
  11. package/migrations/d1/0018_goap_control_plane_remaster.sql +40 -0
  12. package/migrations/d1/0019_agentsam_agent_run_plan_todo.sql +14 -0
  13. package/migrations/d1/README_PORTABLE_CONTROL_PLANE.md +20 -9
  14. package/migrations/runtime/0002_goap_blackboard_v1.sql +15 -0
  15. package/migrations/runtime/0004_agent_run_plan_linkage.sql +8 -0
  16. package/native/agentsam-machine/cli/Cargo.toml +8 -1
  17. package/native/agentsam-machine/cli/README.md +21 -0
  18. package/native/agentsam-machine/core/Cargo.toml +7 -0
  19. package/native/agentsam-machine/core/README.md +14 -0
  20. package/native/agentsam-machine/core/build.rs +33 -0
  21. package/native/agentsam-machine/core/contracts/source-types.v1.json +353 -0
  22. package/native/agentsam-machine/core/src/lib.rs +6 -0
  23. package/native/agentsam-machine/core/src/source_types.rs +2 -2
  24. package/package.json +31 -10
  25. package/packages/agentsam-brand/package.json +1 -1
  26. package/packages/agentsam-contracts/package.json +71 -20
  27. package/packages/agentsam-contracts/scripts/build.mjs +18 -0
  28. package/packages/agentsam-contracts/test/contracts.test.mjs +4 -1
  29. package/packages/agentsam-contracts/test/repository.test.mjs +4 -1
  30. package/packages/agentsam-contracts/tsconfig.build.json +10 -0
  31. package/packages/agentsam-errors/package.json +3 -2
  32. package/packages/agentsam-errors/src/index.js +1 -0
  33. package/packages/agentsam-errors/src/tool.js +56 -0
  34. package/packages/agentsam-errors/test/tool.test.mjs +58 -0
  35. package/packages/agentsam-goap/README.md +52 -0
  36. package/packages/agentsam-goap/package.json +37 -0
  37. package/packages/agentsam-goap/src/adapters/d1-sqlite.js +570 -0
  38. package/packages/agentsam-goap/src/adapters/memory.js +199 -0
  39. package/packages/agentsam-goap/src/contracts.js +226 -0
  40. package/packages/agentsam-goap/src/control-plane.js +112 -0
  41. package/packages/agentsam-goap/src/errors.js +157 -0
  42. package/packages/agentsam-goap/src/index.js +5 -0
  43. package/packages/agentsam-goap/src/world.js +202 -0
  44. package/packages/agentsam-goap/test/goap-control-plane.test.mjs +245 -0
  45. package/packages/agentsam-goap/test/world.test.mjs +79 -0
  46. package/packages/agentsam-knowledge/package.json +3 -2
  47. package/packages/agentsam-nav/package.json +1 -1
  48. package/packages/agentsam-queue-control/package.json +1 -1
  49. package/packages/agentsam-rapid-rust/src/main.rs +1 -0
  50. package/packages/agentsam-repository/package.json +3 -2
  51. package/packages/agentsam-repository/src/goap.js +13 -14
  52. package/packages/agentsam-repository/src/tickets.js +15 -22
  53. package/packages/agentsam-repository/test/goap-tickets-workspace-state.test.mjs +19 -8
  54. package/packages/agentsam-vault/package.json +8 -5
  55. package/packages/agentsam-workbench/package.json +44 -17
  56. package/packages/connectors/cloudflare/package.json +4 -2
  57. package/packages/heuristic-theme/package.json +1 -1
  58. package/packages/identity/package.json +4 -3
  59. package/packages/identity/tests/lane1-packed-consumer.test.mjs +10 -2
  60. package/packages/providers/completeful/package.json +1 -1
  61. package/packages/theme-church-site/README.md +2 -2
  62. package/packages/theme-church-site/package.json +3 -4
  63. package/packages/theme-church-site/src/index.js +1 -1
  64. package/packages/theme-church-site/test/theme.test.mjs +1 -1
  65. package/packages/theme-companions-site/README.md +2 -2
  66. package/packages/theme-companions-site/package.json +3 -4
  67. package/packages/theme-companions-site/src/index.js +1 -1
  68. package/packages/theme-companions-site/test/theme.test.mjs +1 -1
  69. package/packages/theme-floors-site/README.md +2 -2
  70. package/packages/theme-floors-site/package.json +3 -4
  71. package/packages/theme-floors-site/src/index.js +1 -1
  72. package/packages/theme-floors-site/test/theme.test.mjs +1 -1
  73. package/packages/theme-fuelnfree-site/README.md +2 -2
  74. package/packages/theme-fuelnfree-site/package.json +3 -4
  75. package/packages/theme-fuelnfree-site/src/index.js +1 -1
  76. package/packages/theme-fuelnfree-site/test/theme.test.mjs +1 -1
  77. package/packages/theme-handyman-site/README.md +2 -2
  78. package/packages/theme-handyman-site/package.json +3 -4
  79. package/packages/theme-handyman-site/src/index.js +1 -1
  80. package/packages/theme-handyman-site/test/theme.test.mjs +1 -1
  81. package/packages/theme-insurance-site/README.md +2 -2
  82. package/packages/theme-insurance-site/package.json +3 -4
  83. package/packages/theme-insurance-site/src/index.js +1 -1
  84. package/packages/theme-insurance-site/test/theme.test.mjs +1 -1
  85. package/packages/theme-scenes/package.json +1 -1
  86. package/packages/theme-shinshu-site/README.md +2 -2
  87. package/packages/theme-shinshu-site/package.json +3 -4
  88. package/packages/theme-shinshu-site/src/index.js +1 -1
  89. package/packages/theme-shinshu-site/test/theme.test.mjs +1 -1
  90. package/packages/work-graph/package.json +3 -2
  91. package/protocol/local-engine/benchmark.v1.schema.json +14 -0
  92. package/protocol/local-engine/engine.v1.schema.json +17 -0
  93. package/python/agentsam_sdk/repository/intelligence/discovery.py +27 -2
  94. package/python/agentsam_sdk/repository/intelligence/git.py +4 -0
  95. package/python/tests/test_repository_intelligence.py +30 -0
  96. package/src/cli/command-catalog.js +3 -1
  97. package/src/cli.js +20 -1
  98. package/src/commands/app.js +10 -0
  99. package/src/commands/engine.js +10 -0
  100. package/src/commands/goap-world.js +134 -0
  101. package/src/commands/goap.js +11 -4
  102. package/src/commands/machine-binary.js +33 -27
  103. package/src/commands/machine-runtime.js +266 -0
  104. package/src/commands/machine.js +155 -51
  105. package/src/commands/package.js +537 -0
  106. package/src/commands/plan-ledger.js +370 -0
  107. package/src/commands/plan.js +183 -0
  108. package/src/commands/runtime.js +25 -10
  109. package/src/commands/setup.js +30 -6
  110. package/src/commands/skill.js +78 -17
  111. package/src/commands/terminal.js +20 -8
  112. package/src/errors/contract.js +4 -4
  113. package/src/errors/diagnostic.js +1 -1
  114. package/src/errors/index.js +1 -1
  115. package/src/index.js +20 -0
  116. package/src/indexing/ingest/materials.js +237 -30
  117. package/src/knowledge/source.js +1 -1
  118. package/src/lib/setup/runtime.js +4 -2
  119. package/src/lib/slash-commands.js +1 -1
  120. package/src/local/runtime-store.js +24 -2
  121. package/src/local/sqlite.js +17 -0
  122. package/src/local-engine/assets.js +37 -0
  123. package/src/local-engine/audit.js +133 -0
  124. package/src/local-engine/benchmark.js +26 -0
  125. package/src/local-engine/contracts.js +101 -0
  126. package/src/local-engine/engines.js +142 -0
  127. package/src/local-engine/index.js +18 -0
  128. package/src/local-engine/runtime.js +39 -0
  129. package/src/sam/operations/package-audit.js +41 -0
  130. package/src/sam/seed.js +2 -0
  131. package/skills/grok-auth/SKILL.md +0 -110
  132. package/skills/grok-auth/agentsam.skill.json +0 -25
  133. package/skills/grok-auth/references/grok-identity.md +0 -64
  134. package/skills/grok-auth/references/per-user-data.md +0 -49
  135. package/skills/grok-auth/references/prewired-and-env.md +0 -54
  136. package/skills/grok-auth/references/session-ui.md +0 -133
  137. package/skills/grok-auth/references/sign-in-methods.md +0 -55
  138. package/skills/grok-auth/references/wiring.md +0 -71
  139. package/skills/grok-building-games/SKILL.md +0 -213
  140. package/skills/grok-building-games/agentsam.skill.json +0 -25
  141. package/skills/grok-building-games/references/3d-libs.md +0 -64
  142. package/skills/grok-building-games/references/ai-pathfinding.md +0 -122
  143. package/skills/grok-building-games/references/audio.md +0 -129
  144. package/skills/grok-building-games/references/babylon.md +0 -202
  145. package/skills/grok-building-games/references/collision-physics.md +0 -122
  146. package/skills/grok-building-games/references/ecs-architecture.md +0 -111
  147. package/skills/grok-building-games/references/game-feel-juice.md +0 -110
  148. package/skills/grok-building-games/references/genres/board-card-chess.md +0 -89
  149. package/skills/grok-building-games/references/genres/endless-runner.md +0 -83
  150. package/skills/grok-building-games/references/genres/fps.md +0 -105
  151. package/skills/grok-building-games/references/genres/platformer-2d.md +0 -97
  152. package/skills/grok-building-games/references/genres/puzzle-match3-tetris.md +0 -131
  153. package/skills/grok-building-games/references/genres/racing-kart.md +0 -106
  154. package/skills/grok-building-games/references/genres/topdown-twin-stick.md +0 -97
  155. package/skills/grok-building-games/references/genres/tower-defense.md +0 -84
  156. package/skills/grok-building-games/references/genres/voxel-minecraft.md +0 -89
  157. package/skills/grok-building-games/references/input.md +0 -139
  158. package/skills/grok-building-games/references/phaser.md +0 -277
  159. package/skills/grok-building-games/references/procedural-generation.md +0 -141
  160. package/skills/grok-building-games/references/save-persistence.md +0 -108
  161. package/skills/grok-building-games/references/threejs-foundational.md +0 -148
  162. package/skills/grok-controls/SKILL.md +0 -274
  163. package/skills/grok-controls/agentsam.skill.json +0 -25
  164. package/skills/grok-design-ui/SKILL.md +0 -122
  165. package/skills/grok-design-ui/agentsam.skill.json +0 -25
  166. package/skills/grok-design-ui/references/animations.md +0 -379
  167. package/skills/grok-design-ui/references/performance.md +0 -88
  168. package/skills/grok-design-ui/references/refined-ui.md +0 -384
  169. package/skills/grok-design-ui/references/surfaces.md +0 -247
  170. package/skills/grok-design-ui/references/typography.md +0 -123
  171. package/skills/grok-game-animation-frames/SKILL.md +0 -84
  172. package/skills/grok-game-animation-frames/agentsam.skill.json +0 -25
  173. package/skills/grok-game-asset-core/SKILL.md +0 -69
  174. package/skills/grok-game-asset-core/agentsam.skill.json +0 -25
  175. package/skills/grok-game-character-consistency/SKILL.md +0 -69
  176. package/skills/grok-game-character-consistency/agentsam.skill.json +0 -25
  177. package/skills/grok-game-tilesets/SKILL.md +0 -65
  178. package/skills/grok-game-tilesets/agentsam.skill.json +0 -25
  179. package/skills/grok-game-ui-icons/SKILL.md +0 -56
  180. package/skills/grok-game-ui-icons/agentsam.skill.json +0 -25
  181. package/skills/grok-generate2dmap/LICENSE +0 -21
  182. package/skills/grok-generate2dmap/SKILL.md +0 -120
  183. package/skills/grok-generate2dmap/SOURCE.md +0 -6
  184. package/skills/grok-generate2dmap/agentsam.skill.json +0 -25
  185. package/skills/grok-generate2dmap/references/deliverables.md +0 -101
  186. package/skills/grok-generate2dmap/references/layered-map-contract.md +0 -209
  187. package/skills/grok-generate2dmap/references/map-strategies.md +0 -341
  188. package/skills/grok-generate2dmap/references/object-production-gate.md +0 -24
  189. package/skills/grok-generate2dmap/references/pipeline.md +0 -149
  190. package/skills/grok-generate2dmap/references/prop-pack-contract.md +0 -174
  191. package/skills/grok-generate2dmap/references/side-scroll-stages.md +0 -29
  192. package/skills/grok-generate2dmap/scripts/compose_layered_preview.py +0 -157
  193. package/skills/grok-generate2dmap/scripts/extract_prop_pack.py +0 -369
  194. package/skills/grok-generate2dsprite/LICENSE +0 -21
  195. package/skills/grok-generate2dsprite/SKILL.md +0 -313
  196. package/skills/grok-generate2dsprite/SOURCE.md +0 -6
  197. package/skills/grok-generate2dsprite/agentsam.skill.json +0 -25
  198. package/skills/grok-generate2dsprite/references/modes.md +0 -124
  199. package/skills/grok-generate2dsprite/references/prompt-rules.md +0 -315
  200. package/skills/grok-generate2dsprite/scripts/generate2dsprite.py +0 -1031
  201. package/skills/grok-generate2dsprite/scripts/make_layout_guide.py +0 -109
  202. package/skills/grok-imagine/SKILL.md +0 -201
  203. package/skills/grok-imagine/agentsam.skill.json +0 -25
  204. package/skills/grok-multiplayer-p2p/SKILL.md +0 -111
  205. package/skills/grok-multiplayer-p2p/agentsam.skill.json +0 -25
  206. package/skills/grok-multiplayer-p2p/references/react-binding.md +0 -144
  207. package/skills/grok-multiplayer-p2p/references/signaling-relay.md +0 -269
  208. package/skills/grok-neon/SKILL.md +0 -157
  209. package/skills/grok-neon/agentsam.skill.json +0 -25
  210. package/skills/grok-og/SKILL.md +0 -102
  211. package/skills/grok-og/agentsam.skill.json +0 -25
  212. package/skills/grok-og/references/brand-pass.md +0 -53
  213. package/skills/grok-og/references/custom-card.md +0 -107
  214. package/skills/grok-og/references/favicon-and-icons.md +0 -48
  215. package/skills/grok-og/references/og-type-contract.md +0 -18
  216. package/skills/grok-og/references/placeholder-card.md +0 -21
  217. package/skills/grok-og/references/x-banner.md +0 -41
  218. package/skills/grok-threejs/SKILL.md +0 -67
  219. package/skills/grok-threejs/agentsam.skill.json +0 -25
  220. package/skills/grok-threejs/references/llms-full.txt +0 -2780
  221. package/skills/grok-video2dsprite/LICENSE +0 -21
  222. package/skills/grok-video2dsprite/SKILL.md +0 -236
  223. package/skills/grok-video2dsprite/SOURCE.md +0 -6
  224. package/skills/grok-video2dsprite/agentsam.skill.json +0 -25
  225. package/skills/grok-video2dsprite/references/pipeline.md +0 -90
  226. package/skills/grok-video2dsprite/references/prompt-rules.md +0 -63
  227. package/skills/grok-video2dsprite/scripts/video2dsprite.py +0 -490
  228. package/skills/grok-xai-api/SKILL.md +0 -152
  229. package/skills/grok-xai-api/agentsam.skill.json +0 -25
  230. package/test/account-session.test.mjs +0 -101
  231. package/test/agent-capabilities.test.mjs +0 -67
  232. package/test/app-authority-context.test.mjs +0 -32
  233. package/test/app-building-skills.test.mjs +0 -61
  234. package/test/apps-scaffold-contract.test.mjs +0 -115
  235. package/test/blender-cad.test.mjs +0 -146
  236. package/test/cad-docker.test.mjs +0 -96
  237. package/test/capabilities.test.mjs +0 -133
  238. package/test/cli/api-key-env-whoami.test.mjs +0 -129
  239. package/test/cli/catalog-authority.test.mjs +0 -64
  240. package/test/cli/codebaseindex-plan-ux.test.mjs +0 -37
  241. package/test/cli/eval-live.test.mjs +0 -219
  242. package/test/cli/go.test.mjs +0 -128
  243. package/test/cli/local-vault-and-provider-setup.test.mjs +0 -268
  244. package/test/cli/machine-command.test.mjs +0 -34
  245. package/test/cli/mcp-client.test.mjs +0 -256
  246. package/test/cli/preferences-runtime.test.mjs +0 -11
  247. package/test/cli/runtime-persist.test.mjs +0 -56
  248. package/test/cli/runtime-ui.test.mjs +0 -141
  249. package/test/cli/rust-command.test.mjs +0 -21
  250. package/test/cli/skill-npm-and-env.test.mjs +0 -52
  251. package/test/cli/status-actions.test.mjs +0 -88
  252. package/test/cli/wireframes-go-registry.test.mjs +0 -139
  253. package/test/cli-preferences.test.mjs +0 -46
  254. package/test/cloudflare-connector.test.mjs +0 -93
  255. package/test/cloudflare-runtime.test.mjs +0 -82
  256. package/test/context.test.mjs +0 -159
  257. package/test/credentials-audit.test.mjs +0 -113
  258. package/test/deploy-health-scan.test.mjs +0 -95
  259. package/test/deploy-receipt.test.mjs +0 -91
  260. package/test/dockerize.test.mjs +0 -93
  261. package/test/error-diagnostics.test.mjs +0 -124
  262. package/test/eval-context.test.mjs +0 -37
  263. package/test/execution-approvals.test.mjs +0 -27
  264. package/test/fixtures/cad/courtyard-house.json +0 -208
  265. package/test/fixtures/knowledge-rpc-worker.mjs +0 -16
  266. package/test/fixtures/project-authority/customer-app/.agentsam/app.json +0 -5
  267. package/test/fixtures/project-authority/customer-app/apps/my-product/index.ts +0 -1
  268. package/test/fixtures/project-authority/customer-app/wrangler.toml +0 -17
  269. package/test/gcloud-auth.test.mjs +0 -111
  270. package/test/go/build-source-identity.test.mjs +0 -31
  271. package/test/go/cloudflare-probe.test.mjs +0 -317
  272. package/test/go/distribution.test.mjs +0 -28
  273. package/test/google-cloud-connection.test.mjs +0 -83
  274. package/test/google-cloud-inventory.test.mjs +0 -64
  275. package/test/indexing-provider.test.mjs +0 -29
  276. package/test/init-options.test.mjs +0 -35
  277. package/test/integration/ai-access-onboarding.test.mjs +0 -47
  278. package/test/integration/app-command.test.mjs +0 -85
  279. package/test/integration/autorag-project-authority.integration.test.mjs +0 -51
  280. package/test/integration/autorag-runtime-discovery.test.mjs +0 -107
  281. package/test/integration/cad-discovery.test.mjs +0 -158
  282. package/test/integration/cad-docker-executor.test.mjs +0 -249
  283. package/test/integration/cad-execution.test.mjs +0 -184
  284. package/test/integration/cad-project-app.test.mjs +0 -31
  285. package/test/integration/cad-project-d1.test.mjs +0 -25
  286. package/test/integration/cad-project-native.test.mjs +0 -24
  287. package/test/integration/cad-project-workflow.test.mjs +0 -9
  288. package/test/integration/cad-project.test.mjs +0 -85
  289. package/test/integration/cli-help.test.mjs +0 -41
  290. package/test/integration/cms-app-scaffold.test.mjs +0 -77
  291. package/test/integration/cms-site-tenancy-contract.test.mjs +0 -268
  292. package/test/integration/codebaseindex-ingest.test.mjs +0 -255
  293. package/test/integration/core-client.integration.test.mjs +0 -55
  294. package/test/integration/database-hosted-honesty.test.mjs +0 -49
  295. package/test/integration/desktop-keychain-boundary.test.mjs +0 -45
  296. package/test/integration/error-runtime-rpc.test.mjs +0 -71
  297. package/test/integration/features-resolve.test.mjs +0 -147
  298. package/test/integration/hosted-work-host-authority.test.mjs +0 -47
  299. package/test/integration/icon-registry.test.mjs +0 -67
  300. package/test/integration/ingest-discover-models.test.mjs +0 -30
  301. package/test/integration/inspect-path-cli.test.mjs +0 -46
  302. package/test/integration/install-script.test.mjs +0 -110
  303. package/test/integration/inventory-core.test.mjs +0 -53
  304. package/test/integration/inventory-eligibility.test.mjs +0 -59
  305. package/test/integration/inventory-evidence.test.mjs +0 -125
  306. package/test/integration/knowledge-rpc.test.mjs +0 -112
  307. package/test/integration/local-fs.test.mjs +0 -113
  308. package/test/integration/local-provider-bridge.test.mjs +0 -65
  309. package/test/integration/local-studio-settings-production.test.mjs +0 -40
  310. package/test/integration/lockfile-sync.test.mjs +0 -26
  311. package/test/integration/merkle-cli.test.mjs +0 -61
  312. package/test/integration/merkle-persistence-identity.test.mjs +0 -48
  313. package/test/integration/plugins-cloudflare.integration.test.mjs +0 -28
  314. package/test/integration/provider-env-cli.test.mjs +0 -60
  315. package/test/integration/provider-factory.test.mjs +0 -197
  316. package/test/integration/repository-company-graph.test.mjs +0 -90
  317. package/test/integration/runtime-migrations.test.mjs +0 -87
  318. package/test/integration/runtime-status.integration.test.mjs +0 -227
  319. package/test/integration/sam-activity-recovery.test.mjs +0 -147
  320. package/test/integration/sam-decision.test.mjs +0 -584
  321. package/test/integration/sam-kernel.test.mjs +0 -99
  322. package/test/integration/sam-planning-astar.test.mjs +0 -279
  323. package/test/integration/scaffold-cloudflare.test.mjs +0 -46
  324. package/test/integration/skill-runtime.test.mjs +0 -240
  325. package/test/integration/storage-architecture.test.mjs +0 -154
  326. package/test/integration/store-discovery.test.mjs +0 -44
  327. package/test/integration/studio-fs-pty-e2e.test.mjs +0 -294
  328. package/test/integration/terminal-exec.integration.test.mjs +0 -86
  329. package/test/integration/theme-package-registry.test.mjs +0 -31
  330. package/test/integration/tool-runtime.test.mjs +0 -124
  331. package/test/integration/tool-schema.test.mjs +0 -59
  332. package/test/jr-dev-skill.test.mjs +0 -26
  333. package/test/knowledge-context-pack.test.mjs +0 -19
  334. package/test/knowledge-postgres.test.mjs +0 -40
  335. package/test/knowledge-service.test.mjs +0 -110
  336. package/test/knowledge.test.mjs +0 -206
  337. package/test/live/terminal-transport.live.test.mjs +0 -24
  338. package/test/local-sessions.test.mjs +0 -57
  339. package/test/local-studio-deploy.test.mjs +0 -83
  340. package/test/loopback-oauth.test.mjs +0 -53
  341. package/test/merkle-render.test.mjs +0 -31
  342. package/test/mini.test.mjs +0 -140
  343. package/test/model-catalog.test.mjs +0 -70
  344. package/test/models.test.mjs +0 -309
  345. package/test/npm10-lock.test.mjs +0 -29
  346. package/test/ollama.test.mjs +0 -137
  347. package/test/open-url.test.mjs +0 -64
  348. package/test/openai-responses.test.mjs +0 -155
  349. package/test/portable-context.test.mjs +0 -94
  350. package/test/project-config.test.mjs +0 -81
  351. package/test/project-rules.test.mjs +0 -44
  352. package/test/provider-credentials.test.mjs +0 -106
  353. package/test/rehydrate.test.mjs +0 -25
  354. package/test/release-hygiene.test.mjs +0 -42
  355. package/test/repository-snapshot-view.test.mjs +0 -112
  356. package/test/responses-runner.test.mjs +0 -465
  357. package/test/runtime-activity.test.mjs +0 -98
  358. package/test/sdk-worker-contract.test.mjs +0 -72
  359. package/test/security.test.mjs +0 -266
  360. package/test/setup-planner.test.mjs +0 -74
  361. package/test/setup-runtime.test.mjs +0 -51
  362. package/test/shell.test.mjs +0 -281
  363. package/test/skills.test.mjs +0 -22
  364. package/test/smoke.mjs +0 -122
  365. package/test/telemetry.test.mjs +0 -79
  366. package/test/terminal/local-pty.mock.test.mjs +0 -153
  367. package/test/terminal-machine-identity.test.mjs +0 -88
  368. package/test/theme-portability.test.mjs +0 -14
  369. package/test/tools-search.test.mjs +0 -73
  370. package/test/unit/website-assets-bindings.test.mjs +0 -60
  371. package/test/whoami-resume.test.mjs +0 -157
@@ -1,268 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import test from 'node:test';
5
- import { fileURLToPath } from 'node:url';
6
- import { assertProjectSlug, createCmsDbClient } from '../../apps/local-studio/backend/worker/cms-db.js';
7
- import { injectSitePartials, fetchSitePartial, putSitePartial } from '../../apps/local-studio/backend/worker/site-partials.js';
8
-
9
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
10
- const at = (...parts) => path.join(root, ...parts);
11
- const read = (...parts) => fs.readFileSync(at(...parts), 'utf8');
12
-
13
- test('CMS D1 query helper strictly enforces projectSlug tenancy invariant', () => {
14
- // Empty or invalid projectSlug must throw immediately
15
- assert.throws(() => assertProjectSlug(''), /CMS Tenancy Invariant Violation/);
16
- assert.throws(() => assertProjectSlug(' '), /CMS Tenancy Invariant Violation/);
17
- assert.throws(() => assertProjectSlug(null), /CMS Tenancy Invariant Violation/);
18
- assert.throws(() => assertProjectSlug(undefined), /CMS Tenancy Invariant Violation/);
19
- assert.throws(() => createCmsDbClient({}, ''), /CMS Tenancy Invariant Violation/);
20
-
21
- assert.equal(assertProjectSlug('agentsam-sdk'), 'agentsam-sdk');
22
- });
23
-
24
- test('CMS D1 queries all enforce project-scoped tenancy without cross-tenant leaks', async () => {
25
- const capturedQueries = [];
26
- const mockDb = {
27
- prepare(query) {
28
- return {
29
- bind(...args) {
30
- capturedQueries.push({ query, args });
31
- return {
32
- async all() {
33
- if (query.includes('FROM cms_pages WHERE project_slug = ?')) {
34
- return { results: [{ id: 'page_test', project_slug: 'agentsam-sdk', title: 'Test' }] };
35
- }
36
- if (query.includes('FROM cms_pages WHERE id = ? AND project_slug = ?')) {
37
- return { results: [{ id: args[0], project_slug: 'agentsam-sdk', title: 'Test' }] };
38
- }
39
- if (query.includes('SELECT s.id FROM cms_page_sections s')) {
40
- return { results: [{ id: 'sec_test' }] };
41
- }
42
- if (query.includes('SELECT b.* FROM cms_section_components b')) {
43
- return { results: [{ id: 'blk_test', component_type: 'card', component_data: '{}' }] };
44
- }
45
- if (query.includes('SELECT s.* FROM cms_page_sections s')) {
46
- return { results: [{ id: 'sec_test', section_name: 'Test', section_data: '{}' }] };
47
- }
48
- return { results: [] };
49
- },
50
- async run() {
51
- return { success: true };
52
- },
53
- };
54
- },
55
- };
56
- },
57
- };
58
-
59
- const client = createCmsDbClient(mockDb, 'agentsam-sdk');
60
-
61
- await client.getProject();
62
- await client.getPages();
63
- await client.getPageById('page_123');
64
- await client.getSectionsForPage('page_123');
65
- await client.getAllSectionsForSite();
66
- await client.getAllBlocksForSite();
67
- await client.getBlocksForSection('sec_123');
68
- await client.getThemeOverrides();
69
- await client.getLiquidImports();
70
- await client.getActivity();
71
- await client.getTemplates();
72
-
73
- // Audit every captured query
74
- for (const { query, args } of capturedQueries) {
75
- const hasProjectSlugConstraint =
76
- query.includes('project_slug') ||
77
- query.includes('iam_project_slug') ||
78
- query.includes('project_id') ||
79
- query.includes('projects WHERE id = ?');
80
- assert.ok(
81
- hasProjectSlugConstraint,
82
- `Query must enforce project scoping: ${query}`,
83
- );
84
- assert.ok(
85
- args.some((arg) => typeof arg === 'string' && (arg.includes('agentsam-sdk') || arg.includes('agentsam_sdk'))),
86
- `Args must bind project slug: ${JSON.stringify(args)} for ${query}`,
87
- );
88
- }
89
- });
90
-
91
- test('Local Studio declares portable registry versions for client-cms-editor dependencies', () => {
92
- const pkgPath = at('apps', 'local-studio', 'frontend', 'package.json');
93
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
94
- const rootPkg = JSON.parse(fs.readFileSync(at('package.json'), 'utf8'));
95
-
96
- for (const name of [
97
- '@inneranimalmedia/agentsam-cms-frontend',
98
- '@inneranimalmedia/agentsam-cms-backend',
99
- '@inneranimalmedia/agentsam-cms-shared',
100
- ]) {
101
- const declared = pkg.dependencies[name];
102
- assert.ok(declared, 'missing ' + name);
103
- assert.equal(declared, rootPkg.version, name + ' must track the lockstep SDK release');
104
- assert.doesNotMatch(declared, /^(?:file:|link:|workspace:)/, name + ' must install from the registry');
105
- }
106
- });
107
-
108
- test('Local Studio mounts CMS route with default site agentsam-sdk', () => {
109
- const liveRoute = at('apps', 'local-studio', 'frontend', 'src', 'routes', '(apps)', 'cms.tsx');
110
- assert.ok(fs.existsSync(liveRoute), 'live CMS route must be routes/(apps)/cms.tsx');
111
- const routeContent = read('apps', 'local-studio', 'frontend', 'src', 'routes', '(apps)', 'cms.tsx');
112
-
113
- // Superseded donor must stay inert — do not revive obsolete _app/cms.tsx contracts.
114
- const donor = read('apps', 'local-studio', 'frontend', 'src', 'routes', '_app', 'cms.tsx');
115
- assert.match(donor, /SUPERSEDED/);
116
- assert.doesNotMatch(donor, /from ["']@inneranimalmedia\/agentsam-cms-frontend["']/);
117
- assert.doesNotMatch(donor, /createFileRoute\(/);
118
- assert.match(donor, /export\s*\{\s*\}\s*;/);
119
-
120
- // Live route defaults to agentsam-sdk and uses HttpCmsAdapter + site catalog.
121
- assert.match(routeContent, /createHttpCmsAdapter/);
122
- assert.match(routeContent, /slug:\s*"agentsam-sdk"/);
123
- assert.match(routeContent, /search\.site \|\| search\.project_slug \|\| search\.project \|\| "agentsam-sdk"/);
124
- assert.doesNotMatch(routeContent, /default\s*:\s*["']inneranimalmedia["']/);
125
-
126
- // NavRail must include CMS entry
127
- const navRail = read('apps', 'local-studio', 'frontend', 'src', 'components', 'shell', 'nav-rail.tsx');
128
- assert.match(navRail, /to:\s*"\/cms"/);
129
- assert.match(navRail, /label:\s*"CMS"/);
130
- });
131
-
132
- test('Local Studio Worker dispatches /api/cms/* with strict tenant isolation', () => {
133
- const workerContent = read('apps', 'local-studio', 'backend', 'worker', 'index.js');
134
- assert.match(workerContent, /url\.pathname\.startsWith\("\/api\/cms\/"\)/);
135
- assert.match(workerContent, /handleCmsWorkerRequest/);
136
-
137
- const cmsService = read('apps', 'local-studio', 'backend', 'worker', 'cms-service.js');
138
- // Worker requests must name their tenant explicitly; the UI may choose its own default.
139
- assert.match(cmsService, /site_slug_required/);
140
- assert.doesNotMatch(cmsService, /['"]agentsam-sdk['"]/);
141
- assert.match(cmsService, /createCmsDbClient\(env\.DB,\s*siteSlug\)/);
142
- });
143
-
144
- test('homepage.html is decomposed into reusable site partials with relative links and edge injection markers', () => {
145
- assert.ok(fs.existsSync(at('sites', 'agentsam-sdk', 'partials', 'header.html')));
146
- assert.ok(fs.existsSync(at('sites', 'agentsam-sdk', 'partials', 'footer.html')));
147
- assert.ok(fs.existsSync(at('apps', 'frontend', 'public', 'site', 'global', 'asbd-header.html')));
148
- assert.ok(fs.existsSync(at('apps', 'frontend', 'public', 'site', 'global', 'asbd-footer.html')));
149
-
150
- const header = read('sites', 'agentsam-sdk', 'partials', 'header.html');
151
- const footer = read('sites', 'agentsam-sdk', 'partials', 'footer.html');
152
- const homepage = read('apps', 'frontend', 'public', 'site', 'homepage.html');
153
-
154
- // Header and footer are non-empty
155
- assert.ok(header.length > 500, 'header.html must contain full header content');
156
- assert.ok(footer.length > 500, 'footer.html must contain full footer content');
157
-
158
- // AgentSam public header navigation is relative and product-specific (R2 partial SSOT).
159
- assert.match(header, /href="\/"/);
160
- assert.match(header, /href="\/learn\/"/);
161
- assert.match(header, /href="\/themes\/"/);
162
- assert.match(header, /href="\/packages\/sdk\/help\/"/);
163
- assert.match(header, /href="\/auth\/login\?next=\/agentsam"/);
164
- assert.doesNotMatch(header, /href="https:\/\/inneranimalmedia\.com\/(learn|themes|packages\/sdk|agentsam)"/);
165
-
166
- assert.match(footer, /href="\/work"/);
167
- assert.match(footer, /href="\/about"/);
168
- assert.match(footer, /href="\/services"/);
169
- assert.match(footer, /href="\/contact"/);
170
- assert.match(footer, /href="\/privacy"/);
171
- assert.match(footer, /href="\/terms"/);
172
- assert.match(footer, /href="\/sitemap"/);
173
- assert.doesNotMatch(footer, /href="https:\/\/inneranimalmedia\.com\/(work|about|services|contact|privacy|terms|sitemap)"/);
174
-
175
- // Public homepage shell uses ASBD mounts + client inject of global partials
176
- // (R2 sites/{site}/partials remain the publish/edge SSOT via publish-website-assets).
177
- assert.match(homepage, /id="asbd-header-mount"/);
178
- assert.match(homepage, /id="asbd-footer-mount"/);
179
- assert.match(homepage, /inject\('asbd-header-mount',\s*'\/site\/global\/asbd-header\.html'\)/);
180
- assert.match(homepage, /inject\('asbd-footer-mount',\s*'\/site\/global\/asbd-footer\.html'\)/);
181
- assert.doesNotMatch(homepage, /<nav class="iam-sidenav" id="iamSidenav"/, 'inline sidenav should be in partials');
182
- });
183
-
184
- function r2Stub(store = new Map()) {
185
- return {
186
- async get(key) {
187
- if (!store.has(key)) return null;
188
- return { text: async () => store.get(key) };
189
- },
190
- async put(key, content) {
191
- store.set(key, typeof content === 'string' ? content : String(content));
192
- return { key };
193
- },
194
- async head() {
195
- return null;
196
- },
197
- async list() {
198
- return { objects: [] };
199
- },
200
- };
201
- }
202
-
203
- test('site-partials service injects header and footer from R2 into HTML response', async () => {
204
- const store = new Map();
205
- store.set('sites/agentsam-sdk/partials/header.html', '<header id="injected-header">Header Content</header>');
206
- store.set('sites/agentsam-sdk/partials/footer.html', '<footer id="injected-footer">Footer Content</footer>');
207
-
208
- const env = { WEBSITE_ASSETS: r2Stub(store) };
209
-
210
- // Fetch and put partials
211
- const fetchedHeader = await fetchSitePartial(env, 'agentsam-sdk', 'header');
212
- assert.equal(fetchedHeader, '<header id="injected-header">Header Content</header>');
213
-
214
- await putSitePartial(env, 'agentsam-sdk', 'header', '<header id="updated">Updated</header>');
215
- const updatedHeader = await fetchSitePartial(env, 'agentsam-sdk', 'header');
216
- assert.equal(updatedHeader, '<header id="updated">Updated</header>');
217
-
218
- // Test HTML injection
219
- const baseHtml = '<!DOCTYPE html><html><head><title>Test</title></head><body><main>Main Content</main></body></html>';
220
- const initialResponse = new Response(baseHtml, {
221
- headers: { 'content-type': 'text/html; charset=utf-8' },
222
- });
223
-
224
- const injectedResponse = await injectSitePartials(initialResponse, env, 'agentsam-sdk');
225
- const transformedText = await injectedResponse.text();
226
-
227
- assert.ok(transformedText.includes('<header id="updated">Updated</header>'), 'Response must contain injected header');
228
- assert.ok(transformedText.includes('<footer id="injected-footer">Footer Content</footer>'), 'Response must contain injected footer');
229
- assert.ok(transformedText.includes('<main>Main Content</main>'), 'Response must preserve main content');
230
-
231
- // Verify non-text/html responses are guarded and untouched
232
- const jsonResponse = new Response(JSON.stringify({ ok: true }), {
233
- headers: { 'content-type': 'application/json' },
234
- });
235
- const unedited = await injectSitePartials(jsonResponse, env, 'agentsam-sdk');
236
- assert.equal(await unedited.text(), JSON.stringify({ ok: true }));
237
- });
238
-
239
- test('Local Studio canonical homepage serves with edge HTMLRewriter partial injection and text/html', async () => {
240
- const { serveCanonicalHomepage } = await import('../../apps/local-studio/backend/worker/canonical-homepage.js');
241
-
242
- const store = new Map([
243
- ['sites/agentsam-sdk/partials/header.html', '<header id="live-header">SDK Header</header>'],
244
- ['sites/agentsam-sdk/partials/footer.html', '<footer id="live-footer">SDK Footer</footer>'],
245
- ]);
246
- const env = { WEBSITE_ASSETS: r2Stub(store) };
247
-
248
- const rootReq = new Request('https://agentsam.inneranimalmedia.com/', { method: 'GET' });
249
- const rootRes = await serveCanonicalHomepage(rootReq, env, 'agentsam-sdk');
250
- assert.equal(rootRes.status, 200);
251
- assert.ok(rootRes.headers.get('content-type')?.includes('text/html'), 'Content type must be text/html');
252
- const rootText = await rootRes.text();
253
- assert.ok(rootText.includes('<header id="live-header">SDK Header</header>'), 'Edge injection must inject header at /');
254
- assert.ok(rootText.includes('<footer id="live-footer">SDK Footer</footer>'), 'Edge injection must inject footer at /');
255
- assert.ok(rootText.includes('@inneranimalmedia/agentsam-sdk'), 'Canonical homepage content must be present');
256
-
257
- // Verify index.js routes / and /index.html to serveCanonicalHomepage
258
- const indexJsContent = fs.readFileSync(at('apps/local-studio/backend/worker/index.js'), 'utf8');
259
- assert.ok(
260
- indexJsContent.includes('serveCanonicalHomepage(request, env)'),
261
- 'index.js must call serveCanonicalHomepage for root route'
262
- );
263
- assert.ok(
264
- indexJsContent.includes('url.pathname === "/" || url.pathname === "/index.html"'),
265
- 'index.js must match both / and /index.html'
266
- );
267
- });
268
-
@@ -1,255 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { describe, it, before } from 'node:test';
3
- import fs from 'node:fs';
4
- import os from 'node:os';
5
- import path from 'node:path';
6
- import { execFileSync } from 'node:child_process';
7
- import {
8
- getCliCommand,
9
- listCliCommands,
10
- printAssistTip,
11
- suggestCliCommands,
12
- } from '../../src/cli/command-catalog.js';
13
- import { parsePastedPaths, classifyMaterial, stageMaterials } from '../../src/indexing/ingest/materials.js';
14
- import { ensureSeedOperations, getSamOperation, AgentSamClient } from '../../src/sam/index.js';
15
- import { getSkill, loadSkill } from '../../src/skills/index.js';
16
- import { resolveHelpTopic, renderHelpOverview } from '../../src/ui/cli/help.js';
17
- import { runCodebaseindexIngest } from '../../src/commands/codebaseindex.js';
18
- import { buildInventory } from '../../src/indexing/ingest/inventory.js';
19
-
20
- describe('CLI command catalog assist', () => {
21
- it('maps ingest alias to codebaseindex with skill tip', () => {
22
- const entry = getCliCommand('ingest');
23
- assert.equal(entry?.id, 'codebaseindex');
24
- assert.equal(entry?.skill, 'agentsam-codebaseindex');
25
- assert.equal(entry?.operation, 'codebaseindex.ingest');
26
- });
27
-
28
- it('prints tip: use skill for every catalogued command', () => {
29
- const chunks = [];
30
- for (const entry of listCliCommands()) {
31
- if (!entry.skill) continue;
32
- printAssistTip(entry, { write: (s) => chunks.push(s) });
33
- }
34
- const text = chunks.join('');
35
- assert.match(text, /tip: use skill agentsam-codebaseindex/);
36
- assert.match(text, /tip: use skill agentsam-app-fundamentals/);
37
- });
38
-
39
- it('suggests commands for typos', () => {
40
- const hits = suggestCliCommands('codebase');
41
- assert.ok(hits.some((h) => h.id === 'codebaseindex'));
42
- });
43
- });
44
-
45
- describe('material paste/drop intake', () => {
46
- it('parses pasted multi-path text', () => {
47
- const paths = parsePastedPaths('/tmp/a.tar.gz\n"./site build"/index.html screenshot.png');
48
- assert.ok(paths.includes('/tmp/a.tar.gz'));
49
- assert.ok(paths.some((p) => p.includes('index.html') || p.endsWith('screenshot.png')));
50
- });
51
-
52
- it('stages html and classifies archives', () => {
53
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-ingest-'));
54
- const html = path.join(root, 'page.html');
55
- fs.writeFileSync(html, '<html><body>hi</body></html>');
56
- const classified = classifyMaterial(html);
57
- assert.equal(classified.kind, 'document');
58
-
59
- const tarPath = path.join(root, 'site.tar');
60
- const bundle = path.join(root, 'bundle');
61
- fs.mkdirSync(bundle);
62
- fs.writeFileSync(path.join(bundle, 'index.html'), '<html>build</html>');
63
- execFileSync('tar', ['-cf', tarPath, '-C', bundle, '.']);
64
-
65
- const staged = stageMaterials({ root, materials: [html, tarPath] });
66
- assert.equal(staged.schema, 'agentsam.ingest.materials.v1');
67
- assert.ok(staged.include.length >= 1);
68
- assert.ok(staged.assets.some((a) => a.kind === 'document') || staged.items.some((i) => i.kind === 'archive'));
69
- assert.ok(fs.existsSync(path.join(root, staged.stage_root, 'manifest.json')));
70
- });
71
- });
72
-
73
- describe('codebaseindex SAM primitive', () => {
74
- before(() => ensureSeedOperations());
75
-
76
- it('registers codebaseindex.ingest', () => {
77
- const op = getSamOperation('codebaseindex.ingest');
78
- assert.ok(op);
79
- assert.equal(op.execution.model, 'optional');
80
- assert.deepEqual(op.cli.command[0], ['codebaseindex']);
81
- });
82
-
83
- it('skill agentsam-codebaseindex loads', () => {
84
- assert.ok(getSkill('ingest'));
85
- const loaded = loadSkill('agentsam-codebaseindex');
86
- assert.match(loaded.instructions, /codebaseindex\.ingest/);
87
- assert.match(loaded.instructions, /sam\.codebaseindex\.index\.run/);
88
- });
89
-
90
- it('describe + discover surface ingest', async () => {
91
- const sam = new AgentSamClient();
92
- const info = await sam.describe('codebaseindex.ingest');
93
- assert.equal(info.ok, true);
94
- const found = await sam.discover({ query: 'ingest archive embedding' });
95
- assert.ok(found.operations.some((c) => c.id === 'codebaseindex.ingest'));
96
- });
97
-
98
- it('plan-only ingest via invoke (repo allowlist)', async () => {
99
- const sam = new AgentSamClient();
100
- const result = await sam.invoke('codebaseindex.ingest', {
101
- root: process.cwd(),
102
- include: ['src/sam'],
103
- exclude: ['node_modules', '.git'],
104
- embeddingChoice: 'none',
105
- planOnly: true,
106
- });
107
- assert.equal(result.ok, true);
108
- assert.equal(result.data?.pipeline, 'sam.codebaseindex.index.run');
109
- assert.equal(result.data?.mode, 'plan');
110
- });
111
- });
112
-
113
- describe('codebaseindex real execution', () => {
114
- it('publishes, smoke-searches, completes the graph, and returns portable paths', async () => {
115
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-codebaseindex-run-'));
116
- fs.mkdirSync(path.join(root, 'src'), { recursive: true });
117
- fs.writeFileSync(
118
- path.join(root, 'src', 'demo.js'),
119
- 'export function hello() { return "hello AgentSam"; }\n',
120
- );
121
-
122
- const result = await runCodebaseindexIngest({
123
- root,
124
- include: ['src'],
125
- exclude: [],
126
- embeddingChoice: 'none',
127
- embed: false,
128
- planOnly: false,
129
- });
130
-
131
- assert.equal(result.mode, 'run');
132
- assert.equal(result.root, '.');
133
- assert.equal(result.inventory.root, '.');
134
-
135
- assert.equal(result.index.published, true);
136
- assert.equal(result.job_graph.status, 'completed');
137
- assert.equal(result.job_graph.current, null);
138
- assert.equal(
139
- result.job_graph.nodes.find((node) => node.id === 'embedding.generate')?.status,
140
- 'skipped',
141
- );
142
- assert.equal(
143
- result.job_graph.nodes.find((node) => node.id === 'search.smoke')?.status,
144
- 'done',
145
- );
146
-
147
- assert.equal(
148
- result.search_smoke.generation_id,
149
- result.index.generation_id,
150
- );
151
- assert.ok(result.search_smoke.sources_included >= 1);
152
- });
153
- it('executes a declared Vectorize lane through the Worker binding before publish', async () => {
154
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-codebaseindex-vectorize-'));
155
- fs.mkdirSync(path.join(root, 'src'), { recursive: true });
156
- fs.writeFileSync(path.join(root, 'src', 'demo.js'), 'export const vectorized = true;\n');
157
- fs.writeFileSync(path.join(root, 'wrangler.toml'), [
158
- 'name = \"customer-worker\"',
159
- '[[vectorize]]',
160
- 'binding = \"MY_VECTORS\"',
161
- 'index_name = \"customer-code-index\"',
162
- '',
163
- ].join('\n'));
164
- const upserts = [];
165
- const workerBinding = {
166
- async upsert(records) { upserts.push(records); return { mutationId: 'fixture' }; },
167
- async query() { return { matches: [] }; },
168
- async getByIds(ids) { return ids.map(id => ({ id })); },
169
- async deleteByIds() { return { mutationId: 'fixture-delete' }; },
170
- };
171
-
172
- const result = await runCodebaseindexIngest({
173
- root,
174
- include: ['src'],
175
- exclude: [],
176
- embeddingChoice: 'fixture|deterministic|3',
177
- embed: true,
178
- vectors: 'vectorize',
179
- workerBinding,
180
- planOnly: false,
181
- });
182
-
183
- assert.equal(result.index.published, true);
184
- assert.equal(result.index.vector_upsert?.transport, 'worker_binding');
185
- assert.equal(result.storage_lanes.vectors, 'vectorize');
186
- assert.equal(upserts.length, 1);
187
- assert.ok(upserts[0].length >= 1);
188
- assert.equal(upserts[0][0].values.length, 3);
189
- const config = JSON.parse(fs.readFileSync(path.join(root, '.agentsam', 'knowledge.json'), 'utf8'));
190
- assert.equal(config.lane.backend, 'cloudflare_vectorize');
191
- assert.equal(config.lane.binding, 'MY_VECTORS');
192
- assert.equal(config.lane.index, 'customer-code-index');
193
- });
194
- });
195
-
196
- describe('catalog-driven help', () => {
197
- it('resolves ingest topic from catalog', () => {
198
- const topic = resolveHelpTopic('ingest');
199
- assert.ok(topic);
200
- assert.ok(topic.rows.some(([cmd]) => cmd.includes('codebaseindex')));
201
- });
202
-
203
- it('overview mentions skill baseline', () => {
204
- const text = renderHelpOverview('2.6.3');
205
- assert.match(text, /tip: use skill/);
206
- assert.match(text, /command catalog/i);
207
- });
208
- });
209
-
210
- describe('Cargo workspace inventory', () => {
211
- it('treats workspace members as source and keeps generated/operational state out of the starting scope', () => {
212
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-cargo-workspace-'));
213
- try {
214
- fs.writeFileSync(path.join(root, 'Cargo.toml'), `[workspace]
215
- members = [
216
- "core",
217
- "worker",
218
- ]
219
- resolver = "2"
220
- `);
221
- for (const crate of ['core', 'worker']) {
222
- fs.mkdirSync(path.join(root, crate, 'src'), { recursive: true });
223
- fs.writeFileSync(path.join(root, crate, 'Cargo.toml'), `[package]
224
- name = "${crate}"
225
- version = "0.1.0"
226
- edition = "2024"
227
- `);
228
- fs.writeFileSync(path.join(root, crate, 'src', 'lib.rs'), `pub fn ${crate}_value() -> u32 { 1 }
229
- `);
230
- }
231
- fs.mkdirSync(path.join(root, 'docs'), { recursive: true });
232
- fs.writeFileSync(path.join(root, 'docs', 'README.md'), '# docs\n');
233
- fs.mkdirSync(path.join(root, 'target'), { recursive: true });
234
- fs.writeFileSync(path.join(root, 'target', 'build.txt'), 'generated\n');
235
- fs.mkdirSync(path.join(root, '.agentsam', 'machine'), { recursive: true });
236
- fs.writeFileSync(path.join(root, '.agentsam', 'machine', 'state.sqlite'), '');
237
-
238
- const inventory = buildInventory({ root });
239
- assert.deepEqual(inventory.cargo_workspace_roots, ['core', 'worker']);
240
- assert.ok(inventory.categories.source.includes('core'));
241
- assert.ok(inventory.categories.source.includes('worker'));
242
- assert.ok(inventory.categories.docs.includes('docs'));
243
- assert.ok(inventory.categories.dependencies.includes('target'));
244
- assert.ok(inventory.categories.operational.includes('.agentsam'));
245
-
246
- assert.ok(inventory.suggested.include.includes('core'));
247
- assert.ok(inventory.suggested.include.includes('worker'));
248
- assert.ok(inventory.suggested.include.includes('docs'));
249
- assert.ok(inventory.suggested.exclude.includes('target'));
250
- assert.ok(inventory.suggested.exclude.includes('.agentsam'));
251
- } finally {
252
- fs.rmSync(root, { recursive: true, force: true });
253
- }
254
- });
255
- });
@@ -1,55 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import fs from 'node:fs';
3
- import os from 'node:os';
4
- import path from 'node:path';
5
- import test from 'node:test';
6
- import { getJson } from '../../src/lib/core-client.js';
7
- import { saveAccountSession } from '../../src/lib/account-session.js';
8
-
9
- test('core client accepts an already-resolved browser OAuth bearer without reclassifying it as an API key', async () => {
10
- let authorization = '';
11
- const result = await getJson('/api/sdk/context', {
12
- bearer: 'browser_oauth_access_token',
13
- env: { IAM_OAUTH_ISSUER: 'https://iam.example.test' },
14
- fetchImpl: async (_url, options) => {
15
- authorization = options.headers.Authorization;
16
- return { ok: true, async json() { return { ok: true }; } };
17
- },
18
- });
19
- assert.equal(result.ok, true);
20
- assert.equal(authorization, 'Bearer browser_oauth_access_token');
21
- });
22
-
23
- test('legacy string credential form is treated as a resolved bearer for both API keys and OAuth tokens', async () => {
24
- const original = globalThis.fetch;
25
- let authorization = '';
26
- globalThis.fetch = async (_url, options) => {
27
- authorization = options.headers.Authorization;
28
- return { ok: true, async json() { return { ok: true }; } };
29
- };
30
- try {
31
- await getJson('/api/sdk/context', 'browser_oauth_access_token');
32
- assert.equal(authorization, 'Bearer browser_oauth_access_token');
33
- } finally {
34
- globalThis.fetch = original;
35
- }
36
- });
37
-
38
- test('core client refreshes browser OAuth once when IAM returns 401 before local expiry', async t => {
39
- const home = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-core-client-'));
40
- t.after(() => fs.rmSync(home, { recursive: true, force: true }));
41
- saveAccountSession({ access_token: 'stale_browser_token', refresh_token: 'refresh_token', expires_in: 3600 }, { home });
42
- const seen = [];
43
- const result = await getJson('/api/sdk/context', {
44
- home,
45
- env: { IAM_OAUTH_ISSUER: 'https://iam.example.test' },
46
- refreshImpl: async () => ({ access_token: 'fresh_browser_token', refresh_token: 'refresh_token' }),
47
- fetchImpl: async (_url, options) => {
48
- seen.push(options.headers.Authorization);
49
- const ok = seen.length > 1;
50
- return { ok, status: ok ? 200 : 401, async json() { return ok ? { ok: true } : { error: 'Unauthorized' }; } };
51
- },
52
- });
53
- assert.equal(result.ok, true);
54
- assert.deepEqual(seen, ['Bearer stale_browser_token', 'Bearer fresh_browser_token']);
55
- });
@@ -1,49 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
- import { readFileSync } from "node:fs";
4
- import { fileURLToPath } from "node:url";
5
- import path from "node:path";
6
-
7
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
8
-
9
- test("listSources prefers oauth catalog and annotates deployment bindings", () => {
10
- const src = readFileSync(
11
- path.join(root, "apps/local-studio/backend/worker/database-service.js"),
12
- "utf8",
13
- );
14
- assert.match(src, /source_kind: 'oauth_resource'/);
15
- assert.match(src, /source_kind: 'deployment_binding'/);
16
- assert.match(src, /owner_scope: 'deployment'/);
17
- assert.match(src, /\.\.\.oauthD1,\s*\n\s*\.\.\.deploymentSources/s);
18
- assert.match(src, /isOpaqueBindingDatabaseId/);
19
- assert.match(src, /Never treat env\.DB as a generic user's Cloudflare catalog/);
20
- });
21
-
22
- test("local sqlite bridge hard-fails on hosted Worker runtime", () => {
23
- const src = readFileSync(
24
- path.join(root, "apps/local-studio/frontend/src/routes/api/database.local.bridge.ts"),
25
- "utf8",
26
- );
27
- assert.match(src, /requires_local_runtime/);
28
- assert.match(src, /isHostedWorkerRuntime/);
29
- assert.match(src, /WebSocketPair/);
30
- assert.match(src, /status: 501/);
31
- });
32
-
33
- test("database editor preserves null metrics and uses host font tokens", () => {
34
- const app = readFileSync(
35
- path.join(root, "packages/agentsam-database-editor/src/ui/DatabaseEditorApp.tsx"),
36
- "utf8",
37
- );
38
- const css = readFileSync(
39
- path.join(root, "packages/agentsam-database-editor/src/ui/database-editor.css"),
40
- "utf8",
41
- );
42
- assert.doesNotMatch(app, /Number\(point\.queries \|\| 0\)/);
43
- assert.match(app, /numOrNull/);
44
- assert.match(app, /data-metrics-wired/);
45
- assert.match(css, /var\(--font-sans/);
46
- assert.match(css, /var\(--font-mono/);
47
- assert.match(css, /data-provider="cloudflare"/);
48
- assert.match(css, /data-provider="supabase"/);
49
- });