@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,281 +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 { spawnSync } from 'node:child_process';
6
- import test from 'node:test';
7
- import { dispatchShellLine, installPasteCollapse, renderCollapsedPaste, renderShellCatalog, renderShellPrompt, shouldCollapsePaste, tokenizeShellLine } from '../src/commands/shell.js';
8
- import { readCliPreferences, writeCliPreferences } from '../src/lib/cli-preferences.js';
9
-
10
- const repoRoot = path.resolve(new URL('..', import.meta.url).pathname);
11
-
12
- test('shell tokenizer preserves Windows paths and quoted arguments', () => {
13
- assert.deepEqual(tokenizeShellLine('/cd C:\\Users\\conno\\fuelnreetime'), ['/cd', 'C:\\Users\\conno\\fuelnreetime']);
14
- assert.deepEqual(tokenizeShellLine('/cd "C:\\Users\\Connor Smith\\repo"'), ['/cd', 'C:\\Users\\Connor Smith\\repo']);
15
- assert.deepEqual(tokenizeShellLine('/agent "inspect this repo"'), ['/agent', 'inspect this repo']);
16
- });
17
-
18
- test('interactive prompt derives username and cwd instead of hardcoding Agent Sam identity', () => {
19
- const env = { USER: 'alice', HOME: '/Users/alice' };
20
- assert.equal(renderShellPrompt('/Users/alice/code/demo', env), 'alice ~/code/demo > ');
21
- assert.equal(renderShellPrompt('/Users/alice', env), 'alice ~ > ');
22
- assert.equal(renderShellPrompt('/tmp/demo', env), 'alice /tmp/demo > ');
23
- });
24
-
25
- test('shell startup stays quiet and points to the picker', () => {
26
- const catalog = renderShellCatalog();
27
- for (const command of ['/model', '/usage', '/help', '/exit']) {
28
- assert.match(catalog, new RegExp(command.replace('/', '\\/')));
29
- }
30
- assert.match(catalog, /command picker/);
31
- assert.match(catalog, /Type normally to work with the selected model/);
32
- assert.doesNotMatch(catalog, /Slash commands \(/);
33
- assert.doesNotMatch(catalog, /\/reasoning\s+Set reasoning/);
34
- });
35
-
36
- test('dispatch handles help, menu fallback, pwd, cd, and exit without falling through to host shell', async () => {
37
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-'));
38
- const child = path.join(root, 'child folder');
39
- fs.mkdirSync(child);
40
- let output = '';
41
- const state = { cwd: root, write: (text) => { output += text; }, interactive: false };
42
- let result = await dispatchShellLine('/help', state);
43
- assert.equal(result.handled, true);
44
- assert.match(output, /SAM = Systematic Autonomous Machinery/);
45
- assert.match(output, /agentsam help <topic>/);
46
- output = '';
47
- await dispatchShellLine('/', state);
48
- assert.match(output, /command picker/);
49
- output = '';
50
- await dispatchShellLine('/pwd', state);
51
- assert.equal(output.trim(), root);
52
- output = '';
53
- await dispatchShellLine('/cd "child folder"', state);
54
- assert.equal(state.cwd, child);
55
- assert.equal(output.trim(), child);
56
- result = await dispatchShellLine('/exit', state);
57
- assert.equal(result.exit, true);
58
- });
59
-
60
- const stripAnsi = (text) => String(text || '').replace(/\x1B\[[0-9;]*[a-zA-Z]/g, '');
61
-
62
- test('/usage renders the current session receipt without ending the session', async () => {
63
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-usage-'));
64
- let output = '';
65
- const state = {
66
- cwd: root, interactive: false, write: (text) => { output += text; },
67
- session: {
68
- id: 'asess_00000000-0000-4000-8000-000000000001', title: 'Usage test', model_key: 'openai:gpt-6-astra',
69
- cumulative_usage: { input_tokens: 21_244, cached_input_tokens: 60_544, output_tokens: 219 },
70
- total_cost_usd: 0.42, cost_breakdown_usd: { input: 0.2, cached_input: 0.02, output: 0.2 },
71
- },
72
- };
73
- const result = await dispatchShellLine('/usage', state);
74
- assert.equal(result.exit, false);
75
- const clean = stripAnsi(output);
76
- assert.match(clean, /AgentSam · Usage/);
77
- assert.match(clean, /input\s+21\.2k/);
78
- assert.match(clean, /output\s+219/);
79
- assert.match(clean, /cached\s+60\.5k/);
80
- assert.match(clean, /cost\s+\$0\.420/);
81
- assert.match(clean, /agentsam resume asess_00000000-0000-4000-8000-000000000001/);
82
- });
83
-
84
- test('/logout signs out locally and emits the same resumable usage receipt', async () => {
85
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-logout-'));
86
- const home = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-home-'));
87
- let output = '';
88
- const state = {
89
- cwd: root, home, interactive: false, write: (text) => { output += text; },
90
- session: {
91
- id: 'asess_00000000-0000-4000-8000-000000000002', title: 'Logout test', model_key: 'openai:gpt-6-astra',
92
- cumulative_usage: { input_tokens: 100, cached_input_tokens: 50, output_tokens: 25 },
93
- total_cost_usd: 0.0125, cost_breakdown_usd: { input: 0.005, cached_input: 0.0025, output: 0.005 },
94
- },
95
- };
96
- const result = await dispatchShellLine('/logout', state);
97
- assert.equal(result.exit, false);
98
- assert.match(output, /No local Agent Sam IAM session was stored/);
99
- assert.match(output, /Token usage: total=125 input=100 \(\+ 50 cached\) output=25/);
100
- assert.match(output, /Spent: \$0\.0125/);
101
- assert.match(output, /agentsam resume asess_00000000-0000-4000-8000-000000000002/);
102
- });
103
-
104
- test('reasoning and service-tier commands persist only supported controls for an exact model', async () => {
105
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-model-'));
106
- fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'model-demo' }));
107
- writeCliPreferences(root, { trustedDirectory: true, modelPreference: 'openai:gpt-6-astra', reasoningEffort: 'low', serviceTier: 'default' });
108
- let output = '';
109
- const state = { cwd: root, write: (text) => { output += text; }, interactive: false };
110
- await dispatchShellLine('/reasoning high', state);
111
- assert.equal(readCliPreferences(root).reasoningEffort, 'high');
112
- await dispatchShellLine('/fast', state);
113
- assert.equal(readCliPreferences(root).serviceTier, 'fast');
114
- await dispatchShellLine('/flex', state);
115
- assert.equal(readCliPreferences(root).serviceTier, 'flex');
116
- await dispatchShellLine('/standard', state);
117
- assert.equal(readCliPreferences(root).serviceTier, 'default');
118
- assert.match(output, /reasoning → high/);
119
- assert.match(output, /Fast is a paid latency choice/);
120
- assert.match(output, /Flex trades latency/);
121
- });
122
-
123
- test('stale provider snapshots hydrate GPT-6 reasoning controls from the current catalog', async () => {
124
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-stale-model-'));
125
- fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'stale-model-demo' }));
126
- writeCliPreferences(root, {
127
- trustedDirectory: true,
128
- modelPreference: 'openai:gpt-6-luna',
129
- reasoningEffort: 'auto',
130
- serviceTier: 'default',
131
- modelSnapshot: {
132
- model_key: 'openai:gpt-6-luna',
133
- provider: 'openai',
134
- provider_model_id: 'gpt-6-luna',
135
- label: 'gpt-6-luna',
136
- availability: 'available',
137
- availability_source: 'provider_api',
138
- context_window: null,
139
- context_window_source: 'unknown',
140
- max_output_tokens: null,
141
- max_output_tokens_source: 'unknown',
142
- reasoning_efforts: ['auto'],
143
- service_tiers: ['default'],
144
- capabilities: { responses: true },
145
- },
146
- });
147
-
148
- let output = '';
149
- const state = { cwd: root, write: (text) => { output += text; }, interactive: false };
150
- await dispatchShellLine('/reasoning', state);
151
- assert.match(output, /auto \| none \| low \| medium \| high \| xhigh \| max/);
152
- assert.match(output, /provider default: medium/);
153
-
154
- output = '';
155
- await dispatchShellLine('/reasoning high', state);
156
- assert.equal(readCliPreferences(root).reasoningEffort, 'high');
157
- assert.match(output, /reasoning → high/);
158
-
159
- output = '';
160
- await dispatchShellLine('/context', state);
161
- assert.match(output, /1,050,000/);
162
- });
163
-
164
- test('bare /context shows truthful economics without inventing active token usage', async () => {
165
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-context-'));
166
- fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'context-demo' }));
167
- writeCliPreferences(root, { trustedDirectory: true, modelPreference: 'openai:gpt-6-astra', reasoningEffort: 'medium', serviceTier: 'default' });
168
- let output = '';
169
- await dispatchShellLine('/context', { cwd: root, write: (text) => { output += text; }, interactive: false });
170
- assert.match(output, /1,050,000/);
171
- assert.match(output, /272,000/);
172
- assert.match(output, /180,000/);
173
- assert.match(output, /unavailable · no provider\/local usage snapshot yet/);
174
- assert.match(output, /Batch is a separate asynchronous execution lane/);
175
- });
176
-
177
- test('CLI supports a deterministic one-shot slash command for regression tests', () => {
178
- const result = spawnSync(process.execPath, ['src/cli.js', 'shell', '--command', '/help'], { cwd: repoRoot, encoding: 'utf8' });
179
- assert.equal(result.status, 0, result.stderr);
180
- assert.match(result.stdout, /SAM = Systematic Autonomous Machinery/);
181
- assert.match(result.stdout, /agentsam help <topic>/);
182
- assert.match(result.stdout, /command picker/);
183
- });
184
-
185
- test('large pastes collapse into a single confirmation line', () => {
186
- const pasted = ['one', 'two', 'three', 'four', 'five', 'six'].join('\n');
187
- assert.equal(shouldCollapsePaste('short'), false);
188
- assert.equal(shouldCollapsePaste(pasted), true);
189
- assert.equal(shouldCollapsePaste('x'.repeat(301)), true);
190
- assert.equal(renderCollapsedPaste(pasted), '[Pasted 6 lines — Enter to run, Backspace to clear]');
191
-
192
- const writes = [];
193
- const rl = {
194
- terminal: true,
195
- line: '',
196
- cursor: 0,
197
- _refreshLine() { writes.push(this.line); },
198
- _ttyWrite(s) { this.line += s || ''; this.cursor = this.line.length; },
199
- };
200
- const restore = installPasteCollapse(rl);
201
- rl._ttyWrite(pasted);
202
- assert.equal(rl.line, '[Pasted 6 lines — Enter to run, Backspace to clear]');
203
- rl._ttyWrite('', { name: 'backspace' });
204
- assert.equal(rl.line, '');
205
- restore();
206
- });
207
-
208
- test('dispatchShellLine accepts "agentsam <cmd>" and bare common verbs without slash prefix', async () => {
209
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-shell-verb-'));
210
- let output = '';
211
- const state = { cwd: root, write: (text) => { output += text; }, interactive: false };
212
-
213
- const r1 = await dispatchShellLine('agentsam help', state);
214
- assert.equal(r1.handled, true);
215
- assert.match(output, /SAM = Systematic Autonomous Machinery/);
216
-
217
- output = '';
218
- const r2 = await dispatchShellLine('help', state);
219
- assert.equal(r2.handled, true);
220
- assert.match(output, /SAM = Systematic Autonomous Machinery/);
221
-
222
- const r3 = await dispatchShellLine('exit', state);
223
- assert.equal(r3.exit, true);
224
- });
225
-
226
- test('/compact is discoverable, invokes native compaction, persists exact continuation and usage across resume', async () => {
227
- const { SLASH_COMMANDS } = await import('../src/lib/slash-commands.js');
228
- const { createLocalSession, loadLocalSession, loadSessionContinuation } = await import('../src/lib/local-sessions.js');
229
- const { runResponsesAgent } = await import('../src/agent/responses-runner.js');
230
- const { createOpenAIResponsesAdapter } = await import('../src/providers/openai-responses.js');
231
- assert.ok(SLASH_COMMANDS.some(row => row.cmd === '/compact'));
232
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-compact-'));
233
- fs.writeFileSync(path.join(root, 'package.json'), '{"name":"compact-test"}');
234
- writeCliPreferences(root, { modelPreference: 'openai:gpt-6-astra', reasoningEffort: 'low', serviceTier: 'default' });
235
- const session = createLocalSession({ cwd: root, project_root: root, model_key: 'openai:gpt-6-astra', reasoning_effort: 'low', requested_service_tier: 'default', provider_state: { provider: 'openai', previous_response_id: 'resp_prior' }, cumulative_usage: { input_tokens: 10 } });
236
- const output = [{ type: 'message', role: 'user', content: [{ type: 'input_text', text: 'Keep the selected architecture' }] }, { type: 'compaction', id: 'cmp_item', encrypted_content: 'opaque+/==exact' }];
237
- const oldKey = process.env.OPENAI_API_KEY;
238
- process.env.OPENAI_API_KEY = 'fixture-key';
239
- let rendered = '', calls = 0;
240
- const state = { cwd: root, projectRoot: root, interactive: false, session, write: text => { rendered += text; }, providerFetchImpl: async (url, init) => {
241
- calls++;
242
- assert.match(url, /responses\/compact$/);
243
- assert.equal(JSON.parse(init.body).previous_response_id, 'resp_prior');
244
- return { ok: true, status: 200, json: async () => ({ id: 'cmp_test', output, usage: { input_tokens: 1000, output_tokens: 100, input_tokens_details: { cached_tokens: 100 } } }) };
245
- } };
246
- try { await dispatchShellLine('/compact', state); }
247
- finally { if (oldKey === undefined) delete process.env.OPENAI_API_KEY; else process.env.OPENAI_API_KEY = oldKey; }
248
- assert.equal(calls, 1);
249
- assert.match(rendered, /continuation saved/);
250
- const resumed = loadLocalSession(session.id, { projectRoot: root });
251
- assert.equal(resumed.cumulative_usage.input_tokens, 1010);
252
- assert.equal(resumed.cumulative_usage.cached_input_tokens, 100);
253
- assert.ok(resumed.total_cost_usd > 0);
254
- assert.equal(resumed.latest_compaction.compaction_id, 'cmp_test');
255
- const continuation = loadSessionContinuation(resumed);
256
- assert.deepEqual(continuation.compacted_input, output);
257
- assert.equal(resumed.provider_state.previous_response_id, undefined);
258
- const adapter = createOpenAIResponsesAdapter({ apiKey: 'test', fetchImpl: async (_, init) => {
259
- const body = JSON.parse(init.body);
260
- assert.deepEqual(body.input.slice(0, output.length), output);
261
- assert.equal(body.previous_response_id, undefined);
262
- return { ok: true, status: 200, json: async () => ({ id: 'resp_next', output_text: 'done', output: [], usage: { input_tokens: 120, output_tokens: 10 } }) };
263
- } });
264
- await runResponsesAgent({ provider: adapter, capabilityAdapter: { toolDescriptors: () => [] }, model: 'gpt-6-astra', prompt: 'continue', cwd: root, instructions: '', previousProviderState: continuation, previousUsageSnapshot: resumed.usage_snapshot });
265
- rendered = '';
266
- await dispatchShellLine('/compact status', state);
267
- assert.match(rendered, /180000/);
268
- assert.match(rendered, /cmp_test/);
269
- await dispatchShellLine('/session', state);
270
- assert.match(rendered, /Latest compaction: cmp_test/);
271
- });
272
-
273
- test('/compact fails closed for unsupported provider without an HTTP request', async () => {
274
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-compact-unsupported-'));
275
- fs.writeFileSync(path.join(root, 'package.json'), '{"name":"unsupported"}');
276
- writeCliPreferences(root, { modelPreference: 'gemini:test', modelSnapshot: { provider: 'gemini', model_key: 'gemini:test', provider_model_id: 'test', context_window: 128000, capabilities: {} } });
277
- let rendered = '', calls = 0;
278
- await dispatchShellLine('/compact', { cwd: root, interactive: false, write: text => { rendered += text; }, providerFetchImpl: async () => { calls++; } });
279
- assert.equal(calls, 0);
280
- assert.match(rendered, /native_compaction_unavailable:gemini/);
281
- });
@@ -1,22 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import test from 'node:test';
3
- import { getSkill, listSkills, loadSkill } from '../src/skills/index.js';
4
-
5
- test('portable skill registry exposes AgentSam Jr Dev by id and alias', () => {
6
- const listed = listSkills();
7
- assert.ok(listed.some((skill) => skill.id === 'agentsam-jr-dev'));
8
-
9
- assert.equal(getSkill('agentsam_jr_dev')?.id, 'agentsam-jr-dev');
10
- assert.equal(getSkill('jr-dev')?.id, 'agentsam-jr-dev');
11
- });
12
-
13
- test('AgentSam Jr Dev loads compact instructions and references on demand', () => {
14
- const compact = loadSkill('agentsam-jr-dev');
15
- assert.match(compact.instructions, /# AgentSam Jr Dev/);
16
- assert.equal('references' in compact, false);
17
-
18
- const full = loadSkill('agentsam_jr_dev', { references: true });
19
- assert.equal(full.references.length, 2);
20
- assert.match(full.references[0].content, /## HTTP/);
21
- assert.match(full.references[1].content, /# Real Application Logic/);
22
- });
package/test/smoke.mjs DELETED
@@ -1,122 +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 { fileURLToPath } from 'node:url';
6
- import { AgentSam, routeIntent, getToolCatalog } from '../src/index.js';
7
- import { buildLocalScaffoldMeta, sdkDependencySpec } from '../src/lib/local-scaffold.js';
8
- import { writeScaffoldFiles } from '../src/lib/write-files.js';
9
- import { initializeLocalSqlite, createLocalSqliteDatabase } from '../src/local/sqlite.js';
10
- import { printContextSummary, missingForInit } from '../src/lib/detect-context.js';
11
-
12
- const app = new AgentSam({ project: 'smoke', lane: 'cms', agent: 'cms' });
13
- let res = await app.handle(new Request('https://example.com/api/health'));
14
- assert.equal(res.status, 200);
15
- assert.equal((await res.json()).ok, true);
16
-
17
- res = await app.handle(new Request('https://example.com/api/agentsam/info'));
18
- const info = await res.json();
19
- assert.equal(info.agent, 'cms');
20
- assert.ok(info.capabilities.includes('page'));
21
-
22
- res = await app.handle(new Request('https://example.com/api/agentsam/message', {
23
- method: 'POST',
24
- body: JSON.stringify({ message: 'create an analytics page in the cms' }),
25
- }));
26
- const message = await res.json();
27
- assert.equal(message.agent, 'cms');
28
- assert.equal(message.intent, 'cms_build');
29
-
30
- assert.equal(routeIntent({ message: 'drop table users' }).requires_approval, true);
31
- assert.ok(getToolCatalog('Data Solutions').some((tool) => tool.name === 'query'));
32
-
33
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-sdk-test-'));
34
- const dir = writeScaffoldFiles(path.join(tmp, 'demo-project'), [
35
- { path: 'src/agent.js', content: 'export function createAgent() {}\n' },
36
- { path: 'db/schema.sql', content: 'CREATE TABLE cms_pages (id TEXT PRIMARY KEY);\n' },
37
- { path: '.env.example', content: 'AGENTSAM_DB=.agentsam/data/agentsam.sqlite\n' },
38
- ]);
39
- assert.ok(fs.existsSync(path.join(dir, 'src/agent.js')));
40
- assert.ok(fs.readFileSync(path.join(dir, 'db/schema.sql'), 'utf8').includes('cms_pages'));
41
- assert.ok(fs.readFileSync(path.join(dir, '.env.example'), 'utf8').includes('AGENTSAM_DB'));
42
-
43
- import { SLASH_COMMANDS, listSlashCommands } from '../src/lib/slash-commands.js';
44
- import { createIdentityClient, AUTH_COOKIE_NAME } from '../src/index.js';
45
- import { finalizeInboundOAuth } from '../packages/identity/src/oauth/callback.js';
46
- assert.equal(AUTH_COOKIE_NAME, 'session');
47
- assert.equal(createIdentityClient().providers.google()?.id, 'google');
48
- const { GoogleProvider } = await import('@inneranimalmedia/agentsam-sdk/identity/providers/google');
49
- assert.equal(GoogleProvider.id, 'google');
50
- const { handleIdentityWorkerRequest } = await import('@inneranimalmedia/agentsam-sdk/identity/server/worker-router');
51
- assert.equal(typeof handleIdentityWorkerRequest, 'function');
52
- const { buildIdentityAppScaffold } = await import('../src/lib/identity-scaffold.js');
53
- assert.ok(buildIdentityAppScaffold({ projectName: 'x' })['backend/src/index.js']);
54
- await assert.rejects(() => finalizeInboundOAuth({}, new Request('https://x'), {}), /adapter/);
55
- assert.ok(SLASH_COMMANDS.some((c) => c.cmd === '/deploy'));
56
- assert.ok(SLASH_COMMANDS.some((c) => c.cmd === '/db'));
57
- assert.ok(SLASH_COMMANDS.some((c) => c.cmd === '/agent'));
58
- assert.ok(SLASH_COMMANDS.some((c) => c.cmd === '/model'));
59
- assert.ok(SLASH_COMMANDS.some((c) => c.cmd === '/providers'));
60
- assert.ok(SLASH_COMMANDS.some((c) => c.cmd === '/reasoning'));
61
- assert.ok(SLASH_COMMANDS.some((c) => c.cmd === '/fast'));
62
- assert.deepEqual(
63
- listSlashCommands({ lane: 'deploy' }).map(({ cmd }) => cmd),
64
- ['/settings', '/deploy', '/help', '/exit'],
65
- 'deploy lane keeps global shell controls and excludes commands from other lanes',
66
- );
67
-
68
- printContextSummary({
69
- iam: { ready: true, source: 'api_key', detail: 'AGENTSAM_API_KEY' },
70
- gcp: { source: 'vm-metadata', email: 'execos@project.iam.gserviceaccount.com' },
71
- gcp_vm: true,
72
- github: { source: 'gh-cli', account: 'user@example.com' },
73
- cloudflare: { source: 'wrangler', account: 'user@cloudflare.test' },
74
- });
75
- assert.deepEqual(missingForInit({ iam: { ready: false } }, '', { runTarget: 'local' }), []);
76
- assert.deepEqual(missingForInit({ iam: { ready: false } }, '', { runTarget: 'cloudflare' }), ['iam']);
77
-
78
- assert.equal(sdkDependencySpec('2.0.0-alpha.identity.12'), '2.0.0-alpha.identity.12');
79
- assert.equal(sdkDependencySpec('2.1.3'), '^2.1.3');
80
- const prereleaseMeta = buildLocalScaffoldMeta(
81
- { projectName: 'alpha-demo', lane: 'fullstack', runTarget: 'local' },
82
- '2.0.0-alpha.identity.12',
83
- );
84
- const prereleasePackage = JSON.parse(prereleaseMeta.files.find((f) => f.path === 'package.json').content);
85
- assert.equal(
86
- prereleasePackage.dependencies['@inneranimalmedia/agentsam-sdk'],
87
- '2.0.0-alpha.identity.12',
88
- );
89
-
90
- const localMeta = buildLocalScaffoldMeta({ projectName: 'demo', lane: 'cms', runTarget: 'local' });
91
- assert.equal(localMeta.laneKey, 'cms');
92
- assert.ok(localMeta.files.some((f) => f.path === '.agentsam/start-local.md'));
93
- assert.ok(localMeta.files.some((f) => f.path === 'db/schema.sql'));
94
- assert.ok(localMeta.files.some((f) => f.path === '.env'));
95
- assert.ok(localMeta.files.some((f) => f.path === '.env.example'));
96
- assert.ok(localMeta.files.some((f) => f.path === 'src/agent.js'));
97
- assert.ok(!localMeta.files.some((f) => f.path === 'wrangler.toml'));
98
- assert.ok(!localMeta.files.some((f) => f.path.startsWith('gorilla/')));
99
- assert.ok(!localMeta.files.some((f) => f.path.includes('execos')));
100
-
101
- const localDir = path.join(tmp, 'local-project');
102
- writeScaffoldFiles(localDir, localMeta.files);
103
- const localDb = await initializeLocalSqlite({
104
- dbPath: path.join(localDir, '.agentsam', 'data', 'agentsam.sqlite'),
105
- schemaPath: path.join(localDir, 'db', 'schema.sql'),
106
- });
107
- assert.ok(localDb.tables.includes('agent_sessions'));
108
- const d1Like = await createLocalSqliteDatabase(localDb.dbPath);
109
- await d1Like.prepare('INSERT INTO agent_sessions (id, agent, lane, status) VALUES (?, ?, ?, ?)').bind(
110
- 'sess_test', 'cms', 'cms', 'created',
111
- ).run();
112
- const persisted = await d1Like.prepare('SELECT id FROM agent_sessions WHERE id = ?').bind('sess_test').first();
113
- assert.equal(persisted.id, 'sess_test');
114
- d1Like.close();
115
-
116
- const tunnelPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'src', 'commands', 'tunnel.js');
117
- const tunnelSrc = fs.readFileSync(tunnelPath, 'utf8');
118
- assert.ok(tunnelSrc.includes('parseWranglerTunnelList'));
119
- assert.ok(tunnelSrc.includes('wrangler'));
120
- assert.ok(fs.existsSync(tunnelPath));
121
-
122
- console.log('SDK smoke tests passed');
@@ -1,79 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import test from 'node:test';
3
- import { createAgentEvent, createUsageSnapshot } from '../src/telemetry/index.js';
4
-
5
- test('AgentEvent is compact serializable provider-neutral telemetry', () => {
6
- const event = createAgentEvent('context.compaction.completed', { before: 181_000, after: 72_000 }, {
7
- runId: 'run_test', sequence: 4, timestamp: '2026-09-12T00:00:00.000Z',
8
- });
9
- assert.equal(event.type, 'context.compaction.completed');
10
- assert.equal(event.run_id, 'run_test');
11
- assert.doesNotThrow(() => JSON.stringify(event));
12
- });
13
-
14
- test('current active context and cumulative run usage are different metrics', () => {
15
- const usage = createUsageSnapshot({
16
- current_context: { input_tokens: 48_000, window_tokens: 1_050_000 },
17
- cumulative: { input_tokens: 310_000, output_tokens: 22_000, cached_input_tokens: 120_000, cache_write_tokens: 12_000, reasoning_tokens: 8_000 },
18
- estimate_kind: 'provider',
19
- });
20
- assert.equal(usage.current_context.input_tokens, 48_000);
21
- assert.equal(usage.cumulative.input_tokens, 310_000);
22
- assert.equal(usage.provider_authoritative, true);
23
- });
24
-
25
- import {
26
- createRunReceipt,
27
- createUsageReceipt,
28
- createApprovalReceipt,
29
- createTerminalJobReceipt,
30
- } from '../src/telemetry/index.js';
31
-
32
- test('runtime receipts are account-owned and emit no tenant/workspace/user ownership aliases', () => {
33
- const run = createRunReceipt({
34
- id: 'arun_1', account_id: 'au_1', mode: 'agent', status: 'running',
35
- source_client: 'cli', surface: 'cli', reasoning_effort: 'high', requested_service_tier: 'fast',
36
- });
37
- assert.equal(run.account_id, 'au_1');
38
- assert.equal(run.source_client, 'cli');
39
- assert.equal(run.requested_service_tier, 'fast');
40
- assert.equal('user_id' in run, false);
41
- assert.equal('tenant_id' in run, false);
42
- assert.equal('workspace_id' in run, false);
43
- });
44
-
45
- test('usage receipt models exactly one provider call and keeps cache/reasoning economics', () => {
46
- const usage = createUsageReceipt({
47
- id: 'ue_1', account_id: 'au_1', agent_run_id: 'arun_1', provider: 'openai', model_key: 'gpt-6-astra',
48
- model_call_index: 2, provider_request_id: 'resp_1', input_tokens: 1000, cached_input_tokens: 600,
49
- cache_write_tokens: 20, output_tokens: 100, reasoning_tokens: 40, cost_usd: 0.12, cost_basis: 'provider',
50
- });
51
- assert.equal(usage.total_tokens, 1100);
52
- assert.equal(usage.cached_input_tokens, 600);
53
- assert.equal(usage.reasoning_tokens, 40);
54
- assert.equal(usage.model_call_index, 2);
55
- });
56
-
57
- test('approval and terminal receipts preserve lineage without turning D1 into transcript storage', () => {
58
- const approval = createApprovalReceipt({
59
- id: 'appr_1', account_id: 'au_1', agent_run_id: 'arun_1', tool_call_id: 'call_1', terminal_job_id: 'tjob_1',
60
- action_summary: 'Deploy worker', sanitizedInput: { worker: 'api' }, risk_level: 'high',
61
- });
62
- assert.equal(approval.terminal_job_id, 'tjob_1');
63
- assert.match(approval.sanitized_input_json, /worker/);
64
-
65
- const job = createTerminalJobReceipt({
66
- id: 'tjob_1', account_id: 'au_1', instance_id: 'tinst_1', connection_id: 'conn_1',
67
- execos_run_id: 'xrun_1', status: 'running', idempotency_key: 'idem_1', max_attempts: 1,
68
- });
69
- assert.equal(job.execos_run_id, 'xrun_1');
70
- assert.equal(job.max_attempts, 1);
71
- assert.equal('stdout' in job, false);
72
- assert.equal('stderr' in job, false);
73
- assert.equal('command' in job, false);
74
- });
75
-
76
- test('runtime receipts refuse model-invented account identity', () => {
77
- assert.throws(() => createRunReceipt({ id: 'arun_1' }), /account_id is required/);
78
- assert.throws(() => createUsageReceipt({ id: 'ue_1', provider: 'openai', model_key: 'gpt-6-astra' }), /account_id is required/);
79
- });
@@ -1,153 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { EventEmitter } from 'node:events';
3
- import fs from 'node:fs';
4
- import os from 'node:os';
5
- import path from 'node:path';
6
- import test from 'node:test';
7
- import { pathToFileURL } from 'node:url';
8
- import {
9
- attachLocalPtySession,
10
- ensureNodePtySpawnHelperExecutable,
11
- startLocalPtyServer,
12
- } from '../../src/local-pty/server.js';
13
-
14
- function fakeTransports() {
15
- const writes = [];
16
- const resizes = [];
17
- let killed = 0;
18
- let dataHandler = null;
19
- let exitHandler = null;
20
-
21
- const pty = {
22
- spawn(shell, args, options) {
23
- assert.equal(Array.isArray(args), true);
24
- assert.equal(options.env.AGENTSAM_LOCAL_PTY, '1');
25
- return {
26
- write(value) { writes.push(value); },
27
- resize(cols, rows) { resizes.push([cols, rows]); },
28
- kill() { killed += 1; },
29
- onData(fn) { dataHandler = fn; },
30
- onExit(fn) { exitHandler = fn; },
31
- };
32
- },
33
- };
34
-
35
- class FakeWs extends EventEmitter {
36
- OPEN = 1;
37
- readyState = 1;
38
- sent = [];
39
- send(value) { this.sent.push(String(value)); }
40
- close() {
41
- if (this.readyState !== this.OPEN) return;
42
- this.readyState = 3;
43
- this.emit('close');
44
- }
45
- }
46
-
47
- const ws = new FakeWs();
48
- return {
49
- pty,
50
- ws,
51
- writes,
52
- resizes,
53
- killed: () => killed,
54
- emitData(value) { dataHandler?.(value); },
55
- emitExit() { exitHandler?.(); },
56
- };
57
- }
58
-
59
- test('macOS node-pty helper is made executable before runtime import', (t) => {
60
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-node-pty-helper-'));
61
- t.after(() => fs.rmSync(root, { recursive: true, force: true }));
62
- const libDir = path.join(root, 'lib');
63
- const helperDir = path.join(root, 'prebuilds', 'darwin-arm64');
64
- fs.mkdirSync(libDir, { recursive: true });
65
- fs.mkdirSync(helperDir, { recursive: true });
66
- fs.writeFileSync(path.join(libDir, 'index.js'), '');
67
- const helper = path.join(helperDir, 'spawn-helper');
68
- fs.writeFileSync(helper, 'fake');
69
- fs.chmodSync(helper, 0o644);
70
-
71
- const result = ensureNodePtySpawnHelperExecutable({
72
- platform: 'darwin',
73
- arch: 'arm64',
74
- resolveModule: () => pathToFileURL(path.join(libDir, 'index.js')).href,
75
- });
76
-
77
- assert.equal(result.checked, true);
78
- assert.equal(result.changed, true);
79
- assert.equal(result.path, helper);
80
- assert.notEqual(fs.statSync(helper).mode & 0o111, 0);
81
-
82
- const second = ensureNodePtySpawnHelperExecutable({
83
- platform: 'darwin',
84
- arch: 'arm64',
85
- resolveModule: () => pathToFileURL(path.join(libDir, 'index.js')).href,
86
- });
87
- assert.equal(second.changed, false);
88
- });
89
-
90
- test('local PTY wire protocol is release-testable entirely in memory', () => {
91
- const transport = fakeTransports();
92
- const session = attachLocalPtySession({
93
- ws: transport.ws,
94
- pty: transport.pty,
95
- shell: '/bin/test-shell',
96
- cwd: '/tmp/test-project',
97
- cols: 80,
98
- rows: 24,
99
- env: {},
100
- sessionId: 'local_test',
101
- });
102
-
103
- assert.equal(session.session_id, 'local_test');
104
- assert.deepEqual(JSON.parse(transport.ws.sent[0]), {
105
- type: 'session_id',
106
- session_id: 'local_test',
107
- });
108
-
109
- transport.ws.emit('message', Buffer.from(JSON.stringify({ type: 'resize', cols: 120, rows: 40 })));
110
- transport.ws.emit('message', Buffer.from(JSON.stringify({ type: 'slash', line: '/pwd' })));
111
- transport.ws.emit('message', Buffer.from('raw input'));
112
-
113
- assert.deepEqual(transport.resizes, [[120, 40]]);
114
- assert.deepEqual(transport.writes, ['/pwd\r', 'raw input']);
115
-
116
- transport.emitData('terminal output');
117
- assert.equal(transport.ws.sent.at(-1), 'terminal output');
118
-
119
- transport.ws.close();
120
- assert.equal(transport.killed(), 1);
121
-
122
- // Cleanup is idempotent even when transport error/close paths race.
123
- transport.ws.emit('error', new Error('synthetic transport close'));
124
- session.cleanup();
125
- assert.equal(transport.killed(), 1);
126
- });
127
-
128
- test('local PTY server health check uses an ephemeral local port and no ExecOS tunnel', async () => {
129
- const transport = fakeTransports();
130
- const server = await startLocalPtyServer({
131
- cwd: process.cwd(),
132
- host: '127.0.0.1',
133
- port: 0,
134
- pty: transport.pty,
135
- });
136
-
137
- try {
138
- const health = await fetch(server.healthUrl);
139
- assert.equal(health.status, 200);
140
- const body = await health.json();
141
- assert.equal(body.ok, true);
142
- assert.equal(body.service, 'agentsam.local.runtime');
143
- assert.equal(body.plane, 'local');
144
- assert.equal(body.service_legacy, 'agentsam-local-pty');
145
- assert.equal(body.port, server.port);
146
- assert.equal(server.port > 0, true);
147
- } finally {
148
- await server.close();
149
- }
150
-
151
- // No WebSocket session was opened, so the PTY process was never spawned.
152
- assert.equal(transport.killed(), 0);
153
- });