@inneranimalmedia/agentsam-sdk 2.6.5 → 2.6.7

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/AGENTSAM.md +29 -0
  2. package/apps/README.md +5 -0
  3. package/apps/cad-creator/README.md +4 -4
  4. package/apps/cad-creator/shared/cad/package.json +1 -1
  5. package/apps/client-cms-editor/AGENTS.md +12 -7
  6. package/apps/client-cms-editor/README.md +76 -48
  7. package/apps/client-cms-editor/agentsam.app.json +26 -9
  8. package/apps/client-cms-editor/backend/package.json +20 -3
  9. package/apps/client-cms-editor/backend/src/api/client.ts +134 -101
  10. package/apps/client-cms-editor/backend/src/index.ts +1 -1
  11. package/apps/client-cms-editor/backend/src/model.ts +11 -115
  12. package/apps/client-cms-editor/backend/src/preview/bridge.ts +1 -1
  13. package/apps/client-cms-editor/backend/tsconfig.json +6 -1
  14. package/apps/client-cms-editor/bin/agentsam-cms.js +262 -0
  15. package/apps/client-cms-editor/bin/agentsam-cms.mjs +2 -228
  16. package/apps/client-cms-editor/frontend/package.json +16 -7
  17. package/apps/client-cms-editor/frontend/src/AgentSamDrawer.tsx +9 -41
  18. package/apps/client-cms-editor/frontend/src/CmsAgentSurface.tsx +19 -174
  19. package/apps/client-cms-editor/frontend/src/adapters/heuristic.ts +29 -0
  20. package/apps/client-cms-editor/frontend/src/adapters/http.ts +628 -0
  21. package/apps/client-cms-editor/frontend/src/adapters/memory.ts +510 -0
  22. package/apps/client-cms-editor/frontend/src/editor/CmsEditor.tsx +213 -0
  23. package/apps/client-cms-editor/frontend/src/editor/CmsEditorProvider.tsx +20 -0
  24. package/apps/client-cms-editor/frontend/src/editor/canvas/PreviewCanvas.tsx +53 -0
  25. package/apps/client-cms-editor/frontend/src/{CmsEditor.tsx → editor/legacy/CmsEditorPrototype.tsx} +52 -23
  26. package/apps/client-cms-editor/frontend/src/editor/useCmsEditorController.ts +218 -0
  27. package/apps/client-cms-editor/frontend/src/index.ts +19 -5
  28. package/apps/client-cms-editor/frontend/src/lib/agent-host.ts +24 -0
  29. package/apps/client-cms-editor/frontend/src/main.tsx +82 -8
  30. package/apps/client-cms-editor/frontend/src/mount.tsx +92 -30
  31. package/apps/client-cms-editor/frontend/src/styles/agentsam-drawer.css +1 -1
  32. package/apps/client-cms-editor/frontend/src/styles/cmsShell.css +8 -8
  33. package/apps/client-cms-editor/frontend/src/styles/studio.css +55 -3
  34. package/apps/client-cms-editor/frontend/tsconfig.json +12 -1
  35. package/apps/client-cms-editor/frontend/vite.config.ts +12 -0
  36. package/apps/client-cms-editor/package-lock.json +973 -134
  37. package/apps/client-cms-editor/package.json +118 -6
  38. package/apps/client-cms-editor/reference/harvest/HARVEST_RECEIPT.json +201 -0
  39. package/apps/client-cms-editor/reference/harvest/PROVENANCE_HISTORY.txt +10 -0
  40. package/apps/client-cms-editor/reference/harvest/README.md +8 -0
  41. package/apps/client-cms-editor/reference/harvest/plans/ARCHIVE-INTAKE.md +135 -0
  42. package/apps/client-cms-editor/reference/harvest/plans/CHATGPT-IDENTITY-HARVEST.md +83 -0
  43. package/apps/client-cms-editor/reference/harvest/plans/CMS-EDITOR-HARVEST.md +166 -0
  44. package/apps/client-cms-editor/reference/harvest/plans/HARVEST-INDEX.md +196 -0
  45. package/apps/client-cms-editor/reference/harvest/plans/INNERANIMALS-CONTENT-001.md +137 -0
  46. package/apps/client-cms-editor/reference/harvest/plans/NO-IMPLICIT-SIDE-EFFECTS.md +87 -0
  47. package/apps/client-cms-editor/reference/harvest/plans/STOREFRONT-SURFACE-MAP.md +140 -0
  48. package/apps/client-cms-editor/reference/harvest/plans/THEME-INNERANIMALS-HARVEST.md +137 -0
  49. package/apps/client-cms-editor/reference/harvest/plans/TOOLING-LAB.md +63 -0
  50. package/apps/client-cms-editor/reference/harvest/plans/harvest-manifest.json +97 -0
  51. package/apps/client-cms-editor/reference/harvest/plans/local-cms-harvest-schema.sql +328 -0
  52. package/apps/client-cms-editor/shared/cms/package.json +17 -7
  53. package/apps/client-cms-editor/shared/cms/src/adapter.ts +204 -0
  54. package/apps/client-cms-editor/shared/cms/src/agent-context.ts +7 -5
  55. package/apps/client-cms-editor/shared/cms/src/editor-types.ts +32 -0
  56. package/apps/client-cms-editor/shared/cms/src/host.ts +82 -0
  57. package/apps/client-cms-editor/shared/cms/src/index.ts +4 -0
  58. package/apps/client-cms-editor/shared/cms/src/map.ts +115 -0
  59. package/apps/client-cms-editor/shared/cms/src/starter-pack.ts +158 -0
  60. package/contracts/source-types.v1.json +353 -0
  61. package/docs/CMS_CONTEXTUAL_COMPOSER.md +1 -1
  62. package/docs/PRODUCT_LIFECYCLE.md +566 -0
  63. package/docs/THEME_REFINERY.md +2 -2
  64. package/docs/architecture/AGENTSAM_RUNTIME_PROTOCOL.md +40 -20
  65. package/docs/content-studio/REVISION_GATE_2026-09-27.md +1 -1
  66. package/docs/plans/LOCAL_STUDIO_DESKTOP_RELEASE_2026-09-29.md +150 -0
  67. package/migrations/d1/0017_identity_native_oauth.sql +21 -0
  68. package/native/agentsam-machine/Cargo.lock +426 -0
  69. package/native/agentsam-machine/Cargo.toml +9 -0
  70. package/native/agentsam-machine/cli/Cargo.toml +14 -0
  71. package/native/agentsam-machine/cli/src/main.rs +77 -0
  72. package/native/agentsam-machine/core/Cargo.toml +15 -0
  73. package/native/agentsam-machine/core/src/assets.rs +790 -0
  74. package/native/agentsam-machine/core/src/bound.rs +298 -0
  75. package/native/agentsam-machine/core/src/enrich.rs +706 -0
  76. package/native/agentsam-machine/core/src/frontend.rs +442 -0
  77. package/native/agentsam-machine/core/src/lib.rs +1086 -0
  78. package/native/agentsam-machine/core/src/liquid.rs +528 -0
  79. package/native/agentsam-machine/core/src/source_types.rs +78 -0
  80. package/package.json +51 -21
  81. package/packages/agentsam-brand/README.md +1 -1
  82. package/packages/agentsam-brand/package.json +4 -4
  83. package/packages/agentsam-brand/src/index.js +1 -1
  84. package/packages/agentsam-contracts/package.json +13 -3
  85. package/packages/agentsam-contracts/src/tools.ts +22 -0
  86. package/packages/agentsam-errors/package.json +13 -3
  87. package/packages/agentsam-knowledge/package.json +18 -4
  88. package/packages/agentsam-knowledge/src/autorag/index.js +10 -3
  89. package/packages/agentsam-knowledge/src/backends/index.js +33 -1
  90. package/packages/agentsam-knowledge/test/autorag.test.mjs +60 -1
  91. package/packages/agentsam-nav/package.json +24 -6
  92. package/packages/agentsam-queue-control/README.md +1 -1
  93. package/packages/agentsam-queue-control/package.json +7 -2
  94. package/packages/agentsam-rapid-rust/src/main.rs +1 -1
  95. package/packages/agentsam-repository/package.json +13 -3
  96. package/packages/agentsam-repository/src/source-types.js +8 -0
  97. package/packages/agentsam-vault/package.json +14 -4
  98. package/packages/agentsam-workbench/package.json +15 -4
  99. package/packages/agentsam-workbench/src/agent/ToolPermissionRequest.tsx +94 -0
  100. package/packages/agentsam-workbench/src/agent/index.ts +2 -0
  101. package/packages/agentsam-workbench/src/agent/tool-permission.css +134 -0
  102. package/packages/connectors/cloudflare/package.json +13 -3
  103. package/packages/connectors/cloudflare/src/api-client.js +3 -2
  104. package/packages/connectors/cloudflare/src/families/vectorize.js +127 -0
  105. package/packages/connectors/cloudflare/src/index.js +1 -0
  106. package/packages/heuristic-theme/README.md +2 -2
  107. package/packages/heuristic-theme/package.json +8 -3
  108. package/packages/heuristic-theme/src/registry.js +2 -2
  109. package/packages/heuristic-theme/src/theme.js +1 -1
  110. package/packages/heuristic-theme/test/theme.test.mjs +1 -1
  111. package/packages/identity/.agentsam/features/oauth-login-portal/agentsam.feature.json +1 -1
  112. package/packages/identity/.agentsam/features/oauth-login-portal/providers.json +27 -7
  113. package/packages/identity/README.md +2 -2
  114. package/packages/identity/migrations/D1_SCHEMA_MAPPING.md +18 -15
  115. package/packages/identity/migrations/apply-portable.js +109 -0
  116. package/packages/identity/migrations/sqlite/004_identity_oauth_consent_catalog.sql +1 -1
  117. package/packages/identity/migrations/sqlite/005_identity_company_native.sql +52 -0
  118. package/packages/identity/package.json +27 -6
  119. package/packages/identity/schema/agentsam.identity/manifest.json +101 -0
  120. package/packages/identity/scripts/local-identity-bridge.mjs +13 -7
  121. package/packages/identity/scripts/preview-auth-portal.mjs +6 -6
  122. package/packages/identity/src/adapters/cloudflare-d1/index.js +8 -401
  123. package/packages/identity/src/adapters/iam-compat/index.js +540 -0
  124. package/packages/identity/src/adapters/portable-d1/index.js +18 -0
  125. package/packages/identity/src/adapters/portable-store.js +479 -0
  126. package/packages/identity/src/adapters/sqlite/index.js +13 -312
  127. package/packages/identity/src/contracts/auth-config.js +0 -1
  128. package/packages/identity/src/contracts/identity-store.js +56 -5
  129. package/packages/identity/src/contracts/provider.js +1 -0
  130. package/packages/identity/src/contracts/sign-in-options.js +104 -0
  131. package/packages/identity/src/core/constants.js +1 -1
  132. package/packages/identity/src/core/session-policy.js +31 -0
  133. package/packages/identity/src/frontend/auth-portal/pages/login.html +6 -6
  134. package/packages/identity/src/frontend/auth-portal/pages/reset.html +5 -5
  135. package/packages/identity/src/frontend/auth-portal/pages/signup.html +5 -5
  136. package/packages/identity/src/frontend/auth-portal/shared/company-branding.js +1 -1
  137. package/packages/identity/src/frontend/auth-portal/shared/desktop-identity-bridge.js +6 -37
  138. package/packages/identity/src/index.js +28 -1
  139. package/packages/identity/src/migrations/README.md +23 -23
  140. package/packages/identity/src/oauth/README.md +1 -1
  141. package/packages/identity/src/oauth/credentials.js +10 -11
  142. package/packages/identity/src/oauth/google-desktop-exchange.js +195 -27
  143. package/packages/identity/src/oauth/iam-platform.js +21 -9
  144. package/packages/identity/src/oauth/native-handoff.js +136 -0
  145. package/packages/identity/src/providers/chatgpt/headers.js +65 -0
  146. package/packages/identity/src/providers/chatgpt/index.js +86 -0
  147. package/packages/identity/src/providers/chatgpt/mapper.js +43 -0
  148. package/packages/identity/src/providers/chatgpt/paths.js +45 -0
  149. package/packages/identity/src/providers/github/oauth.js +1 -2
  150. package/packages/identity/src/providers/github/profile.js +16 -2
  151. package/packages/identity/src/providers/index.js +11 -3
  152. package/packages/identity/src/server/identity-service.js +2 -1
  153. package/packages/identity/src/server/worker-router.js +71 -18
  154. package/packages/identity/tests/chatgpt-provider.test.mjs +75 -0
  155. package/packages/identity/tests/google-desktop-identity-login.test.mjs +210 -0
  156. package/packages/identity/tests/identity-init-scaffold.test.mjs +15 -4
  157. package/packages/identity/tests/lane1-identity-store-parity.test.mjs +527 -0
  158. package/packages/identity/tests/lane1-packed-consumer.test.mjs +175 -0
  159. package/packages/identity/tests/native-oauth-handoff.test.mjs +292 -0
  160. package/packages/identity/tests/oauth-credentials.test.mjs +4 -4
  161. package/packages/identity/tests/preview-auth-portal.test.mjs +4 -2
  162. package/packages/identity/tests/session-routes-policy.test.mjs +13 -1
  163. package/packages/identity/tests/worker-runtime-boundary.test.mjs +11 -0
  164. package/packages/providers/completeful/package.json +7 -2
  165. package/packages/theme-church-site/package.json +17 -6
  166. package/packages/theme-church-site/src/harvest.json +4 -2
  167. package/packages/theme-church-site/src/index.js +7 -3
  168. package/packages/theme-church-site/test/theme.test.mjs +4 -2
  169. package/packages/theme-companions-site/package.json +17 -6
  170. package/packages/theme-companions-site/src/harvest.json +4 -2
  171. package/packages/theme-companions-site/src/index.js +7 -3
  172. package/packages/theme-companions-site/test/theme.test.mjs +4 -2
  173. package/packages/theme-floors-site/package.json +17 -6
  174. package/packages/theme-floors-site/src/harvest.json +4 -2
  175. package/packages/theme-floors-site/src/index.js +7 -3
  176. package/packages/theme-floors-site/test/theme.test.mjs +4 -2
  177. package/packages/theme-fuelnfree-site/package.json +17 -6
  178. package/packages/theme-fuelnfree-site/src/harvest.json +4 -2
  179. package/packages/theme-fuelnfree-site/src/index.js +7 -3
  180. package/packages/theme-fuelnfree-site/test/theme.test.mjs +4 -2
  181. package/packages/theme-handyman-site/package.json +17 -6
  182. package/packages/theme-handyman-site/src/harvest.json +4 -2
  183. package/packages/theme-handyman-site/src/index.js +7 -3
  184. package/packages/theme-handyman-site/test/theme.test.mjs +4 -2
  185. package/packages/theme-insurance-site/package.json +17 -6
  186. package/packages/theme-insurance-site/src/harvest.json +4 -2
  187. package/packages/theme-insurance-site/src/index.js +7 -3
  188. package/packages/theme-insurance-site/test/theme.test.mjs +4 -2
  189. package/packages/theme-scenes/README.md +1 -1
  190. package/packages/theme-scenes/package.json +4 -3
  191. package/packages/theme-scenes/src/registry.js +187 -0
  192. package/packages/theme-shinshu-site/package.json +17 -6
  193. package/packages/theme-shinshu-site/src/harvest.json +4 -2
  194. package/packages/theme-shinshu-site/src/index.js +7 -3
  195. package/packages/theme-shinshu-site/test/theme.test.mjs +4 -2
  196. package/packages/work-graph/package.json +14 -4
  197. package/protocol/FILEMETA_V1.md +2 -2
  198. package/protocol/capabilities/manifest.json +1 -1
  199. package/protocol/database/agentsam.schema-pack.v1.schema.json +72 -0
  200. package/protocol/presets/catalog.json +2 -2
  201. package/protocol/theme-refinery/lineage-registry.json +105 -0
  202. package/protocol/theme-refinery/product-metadata.schema.json +21 -1
  203. package/skills/grok-auth/SKILL.md +110 -0
  204. package/skills/grok-auth/agentsam.skill.json +25 -0
  205. package/skills/grok-auth/references/grok-identity.md +64 -0
  206. package/skills/grok-auth/references/per-user-data.md +49 -0
  207. package/skills/grok-auth/references/prewired-and-env.md +54 -0
  208. package/skills/grok-auth/references/session-ui.md +133 -0
  209. package/skills/grok-auth/references/sign-in-methods.md +55 -0
  210. package/skills/grok-auth/references/wiring.md +71 -0
  211. package/skills/grok-building-games/SKILL.md +213 -0
  212. package/skills/grok-building-games/agentsam.skill.json +25 -0
  213. package/skills/grok-building-games/references/3d-libs.md +64 -0
  214. package/skills/grok-building-games/references/ai-pathfinding.md +122 -0
  215. package/skills/grok-building-games/references/audio.md +129 -0
  216. package/skills/grok-building-games/references/babylon.md +202 -0
  217. package/skills/grok-building-games/references/collision-physics.md +122 -0
  218. package/skills/grok-building-games/references/ecs-architecture.md +111 -0
  219. package/skills/grok-building-games/references/game-feel-juice.md +110 -0
  220. package/skills/grok-building-games/references/genres/board-card-chess.md +89 -0
  221. package/skills/grok-building-games/references/genres/endless-runner.md +83 -0
  222. package/skills/grok-building-games/references/genres/fps.md +105 -0
  223. package/skills/grok-building-games/references/genres/platformer-2d.md +97 -0
  224. package/skills/grok-building-games/references/genres/puzzle-match3-tetris.md +131 -0
  225. package/skills/grok-building-games/references/genres/racing-kart.md +106 -0
  226. package/skills/grok-building-games/references/genres/topdown-twin-stick.md +97 -0
  227. package/skills/grok-building-games/references/genres/tower-defense.md +84 -0
  228. package/skills/grok-building-games/references/genres/voxel-minecraft.md +89 -0
  229. package/skills/grok-building-games/references/input.md +139 -0
  230. package/skills/grok-building-games/references/phaser.md +277 -0
  231. package/skills/grok-building-games/references/procedural-generation.md +141 -0
  232. package/skills/grok-building-games/references/save-persistence.md +108 -0
  233. package/skills/grok-building-games/references/threejs-foundational.md +148 -0
  234. package/skills/grok-controls/SKILL.md +274 -0
  235. package/skills/grok-controls/agentsam.skill.json +25 -0
  236. package/skills/grok-design-ui/SKILL.md +122 -0
  237. package/skills/grok-design-ui/agentsam.skill.json +25 -0
  238. package/skills/grok-design-ui/references/animations.md +379 -0
  239. package/skills/grok-design-ui/references/performance.md +88 -0
  240. package/skills/grok-design-ui/references/refined-ui.md +384 -0
  241. package/skills/grok-design-ui/references/surfaces.md +247 -0
  242. package/skills/grok-design-ui/references/typography.md +123 -0
  243. package/skills/grok-game-animation-frames/SKILL.md +84 -0
  244. package/skills/grok-game-animation-frames/agentsam.skill.json +25 -0
  245. package/skills/grok-game-asset-core/SKILL.md +69 -0
  246. package/skills/grok-game-asset-core/agentsam.skill.json +25 -0
  247. package/skills/grok-game-character-consistency/SKILL.md +69 -0
  248. package/skills/grok-game-character-consistency/agentsam.skill.json +25 -0
  249. package/skills/grok-game-tilesets/SKILL.md +65 -0
  250. package/skills/grok-game-tilesets/agentsam.skill.json +25 -0
  251. package/skills/grok-game-ui-icons/SKILL.md +56 -0
  252. package/skills/grok-game-ui-icons/agentsam.skill.json +25 -0
  253. package/skills/grok-generate2dmap/LICENSE +21 -0
  254. package/skills/grok-generate2dmap/SKILL.md +120 -0
  255. package/skills/grok-generate2dmap/SOURCE.md +6 -0
  256. package/skills/grok-generate2dmap/agentsam.skill.json +25 -0
  257. package/skills/grok-generate2dmap/references/deliverables.md +101 -0
  258. package/skills/grok-generate2dmap/references/layered-map-contract.md +209 -0
  259. package/skills/grok-generate2dmap/references/map-strategies.md +341 -0
  260. package/skills/grok-generate2dmap/references/object-production-gate.md +24 -0
  261. package/skills/grok-generate2dmap/references/pipeline.md +149 -0
  262. package/skills/grok-generate2dmap/references/prop-pack-contract.md +174 -0
  263. package/skills/grok-generate2dmap/references/side-scroll-stages.md +29 -0
  264. package/skills/grok-generate2dmap/scripts/compose_layered_preview.py +157 -0
  265. package/skills/grok-generate2dmap/scripts/extract_prop_pack.py +369 -0
  266. package/skills/grok-generate2dsprite/LICENSE +21 -0
  267. package/skills/grok-generate2dsprite/SKILL.md +313 -0
  268. package/skills/grok-generate2dsprite/SOURCE.md +6 -0
  269. package/skills/grok-generate2dsprite/agentsam.skill.json +25 -0
  270. package/skills/grok-generate2dsprite/references/modes.md +124 -0
  271. package/skills/grok-generate2dsprite/references/prompt-rules.md +315 -0
  272. package/skills/grok-generate2dsprite/scripts/generate2dsprite.py +1031 -0
  273. package/skills/grok-generate2dsprite/scripts/make_layout_guide.py +109 -0
  274. package/skills/grok-imagine/SKILL.md +201 -0
  275. package/skills/grok-imagine/agentsam.skill.json +25 -0
  276. package/skills/grok-multiplayer-p2p/SKILL.md +111 -0
  277. package/skills/grok-multiplayer-p2p/agentsam.skill.json +25 -0
  278. package/skills/grok-multiplayer-p2p/references/react-binding.md +144 -0
  279. package/skills/grok-multiplayer-p2p/references/signaling-relay.md +269 -0
  280. package/skills/grok-neon/SKILL.md +157 -0
  281. package/skills/grok-neon/agentsam.skill.json +25 -0
  282. package/skills/grok-og/SKILL.md +102 -0
  283. package/skills/grok-og/agentsam.skill.json +25 -0
  284. package/skills/grok-og/references/brand-pass.md +53 -0
  285. package/skills/grok-og/references/custom-card.md +107 -0
  286. package/skills/grok-og/references/favicon-and-icons.md +48 -0
  287. package/skills/grok-og/references/og-type-contract.md +18 -0
  288. package/skills/grok-og/references/placeholder-card.md +21 -0
  289. package/skills/grok-og/references/x-banner.md +41 -0
  290. package/skills/grok-threejs/SKILL.md +67 -0
  291. package/skills/grok-threejs/agentsam.skill.json +25 -0
  292. package/skills/grok-threejs/references/llms-full.txt +2780 -0
  293. package/skills/grok-video2dsprite/LICENSE +21 -0
  294. package/skills/grok-video2dsprite/SKILL.md +236 -0
  295. package/skills/grok-video2dsprite/SOURCE.md +6 -0
  296. package/skills/grok-video2dsprite/agentsam.skill.json +25 -0
  297. package/skills/grok-video2dsprite/references/pipeline.md +90 -0
  298. package/skills/grok-video2dsprite/references/prompt-rules.md +63 -0
  299. package/skills/grok-video2dsprite/scripts/video2dsprite.py +490 -0
  300. package/skills/grok-xai-api/SKILL.md +152 -0
  301. package/skills/grok-xai-api/agentsam.skill.json +25 -0
  302. package/src/cli/command-catalog.js +46 -4
  303. package/src/cli/dispatch.js +1 -0
  304. package/src/cli.js +10 -0
  305. package/src/cloudflare/runtime-status.js +2 -1
  306. package/src/commands/autorag.js +67 -13
  307. package/src/commands/cheat-sheet.js +29 -4
  308. package/src/commands/codebaseindex.js +45 -2
  309. package/src/commands/knowledge.js +59 -2
  310. package/src/commands/machine-binary.js +103 -0
  311. package/src/commands/machine.js +137 -0
  312. package/src/commands/security.js +67 -4
  313. package/src/commands/setup.js +33 -16
  314. package/src/commands/status.js +8 -1
  315. package/src/features/resolve.js +1 -0
  316. package/src/knowledge/engine.js +21 -2
  317. package/src/knowledge/runtime-discovery.js +127 -0
  318. package/src/lib/identity-scaffold.js +53 -13
  319. package/src/lib/setup/recipes.js +1 -1
  320. package/src/models/discovery.js +40 -22
  321. package/src/models/inventory-core.d.ts +105 -0
  322. package/src/models/inventory-core.js +54 -6
  323. package/src/security/logs.js +3 -0
  324. package/src/ui/cli/help.js +41 -0
  325. package/test/apps-scaffold-contract.test.mjs +3 -2
  326. package/test/cli/api-key-env-whoami.test.mjs +2 -2
  327. package/test/cli/catalog-authority.test.mjs +64 -0
  328. package/test/cli/machine-command.test.mjs +34 -0
  329. package/test/fixtures/project-authority/customer-app/.agentsam/app.json +5 -0
  330. package/test/fixtures/project-authority/customer-app/apps/my-product/index.ts +1 -0
  331. package/test/fixtures/project-authority/customer-app/wrangler.toml +17 -0
  332. package/test/integration/autorag-project-authority.integration.test.mjs +51 -0
  333. package/test/integration/autorag-runtime-discovery.test.mjs +107 -0
  334. package/test/integration/cms-app-scaffold.test.mjs +37 -31
  335. package/test/integration/cms-site-tenancy-contract.test.mjs +28 -17
  336. package/test/integration/codebaseindex-ingest.test.mjs +41 -0
  337. package/test/integration/database-hosted-honesty.test.mjs +49 -0
  338. package/test/integration/desktop-keychain-boundary.test.mjs +45 -0
  339. package/test/integration/hosted-work-host-authority.test.mjs +47 -0
  340. package/test/integration/inventory-eligibility.test.mjs +59 -0
  341. package/test/integration/local-provider-bridge.test.mjs +65 -0
  342. package/test/integration/local-studio-settings-production.test.mjs +40 -0
  343. package/test/integration/lockfile-sync.test.mjs +26 -0
  344. package/test/integration/provider-env-cli.test.mjs +13 -3
  345. package/test/integration/runtime-status.integration.test.mjs +16 -1
  346. package/test/integration/theme-package-registry.test.mjs +31 -0
  347. package/test/repository-snapshot-view.test.mjs +2 -2
  348. package/test/security.test.mjs +14 -0
  349. package/test/terminal-machine-identity.test.mjs +2 -2
  350. package/apps/client-cms-editor/backend/src/demo-bootstrap.ts +0 -145
  351. package/packages/agentsam-nav/dist/Nav.d.ts +0 -43
  352. package/packages/agentsam-nav/dist/NavCollapsible.d.ts +0 -10
  353. package/packages/agentsam-nav/dist/NavContent.d.ts +0 -2
  354. package/packages/agentsam-nav/dist/NavFooter.d.ts +0 -2
  355. package/packages/agentsam-nav/dist/NavGroup.d.ts +0 -3
  356. package/packages/agentsam-nav/dist/NavHeader.d.ts +0 -2
  357. package/packages/agentsam-nav/dist/NavMenu.d.ts +0 -22
  358. package/packages/agentsam-nav/dist/NavProvider.d.ts +0 -35
  359. package/packages/agentsam-nav/dist/NavTrigger.d.ts +0 -2
  360. package/packages/agentsam-nav/dist/Surfaces.d.ts +0 -41
  361. package/packages/agentsam-nav/dist/browser.d.ts +0 -11
  362. package/packages/agentsam-nav/dist/browser.global.js +0 -132
  363. package/packages/agentsam-nav/dist/browser.js +0 -613
  364. package/packages/agentsam-nav/dist/contracts.d.ts +0 -76
  365. package/packages/agentsam-nav/dist/index.d.ts +0 -11
  366. package/packages/agentsam-nav/dist/index.js +0 -614
  367. package/packages/agentsam-nav/dist/legacy.css +0 -83
  368. package/packages/agentsam-nav/dist/shell.css +0 -113
  369. package/packages/agentsam-nav/dist/theme.css +0 -113
  370. package/packages/agentsam-nav/dist/utils.d.ts +0 -1
  371. package/packages/agentsam-repository/src/goap.js.bak-20260922011251 +0 -670
@@ -2,10 +2,12 @@ import assert from 'node:assert/strict';
2
2
  import test from 'node:test';
3
3
  import { createTheme, createProductRow } from '../src/index.js';
4
4
 
5
- test('shinshu-site theme package exports installable contract', () => {
5
+ test('shinshu-site theme package exports harvested (not installable) contract', () => {
6
6
  const theme = createTheme();
7
7
  assert.equal(theme.slug, "shinshu-site");
8
- assert.equal(theme.installable, true);
8
+ assert.equal(theme.installable, false);
9
+ assert.equal(theme.lineage, "shin");
10
+ assert.equal(theme.family, "consulting-portfolio");
9
11
  assert.equal(theme.package, "@inneranimalmedia/theme-shinshu-site");
10
12
  assert.ok(Array.isArray(theme.pages));
11
13
  });
@@ -1,7 +1,6 @@
1
1
  {
2
- "name": "@inneranimalmedia/work-graph",
3
- "version": "0.1.0",
4
- "private": true,
2
+ "name": "@inneranimalmedia/agentsam-work-graph",
3
+ "version": "2.6.7",
5
4
  "description": "Core AgentSam work-graph primitive: one graph model (WorkItem, Dependency, TimelineEvent, Artifact, Evidence, Actor) powering an engineering adapter (git/MCP/tests/deploys) and a business adapter (projects/clients/approvals/milestones), with Gantt/timeline rendering as a pure projection over the graph rather than its own source of truth.",
6
5
  "type": "module",
7
6
  "main": "./src/index.js",
@@ -15,5 +14,16 @@
15
14
  },
16
15
  "scripts": {
17
16
  "test": "node --test test/*.test.mjs"
18
- }
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/SamPrimeaux/agentsam-sdk.git",
24
+ "directory": "packages/work-graph"
25
+ },
26
+ "files": [
27
+ "src"
28
+ ]
19
29
  }
@@ -36,7 +36,7 @@ Semantic entries correspond one-for-one with non-directory content entries and r
36
36
  "size": 213,
37
37
  "mode": 420,
38
38
  "hash": "sha256:...",
39
- "package": "@inneranimalmedia/agentsam-sdk-identity",
39
+ "package": "@inneranimalmedia/agentsam-identity",
40
40
  "package_root": "packages/identity",
41
41
  "package_kind": "library",
42
42
  "system": "identity",
@@ -70,7 +70,7 @@ A package may declare stable package-level semantics without tagging every file:
70
70
 
71
71
  ```json
72
72
  {
73
- "name": "@inneranimalmedia/agentsam-sdk-identity",
73
+ "name": "@inneranimalmedia/agentsam-identity",
74
74
  "agentsam": {
75
75
  "system": "identity",
76
76
  "kind": "library",
@@ -481,7 +481,7 @@
481
481
  "version": 1,
482
482
  "domain": "theme",
483
483
  "runtime": "node",
484
- "package": "@inneranimalmedia/heuristic-theme",
484
+ "package": "@inneranimalmedia/theme-heuristic",
485
485
  "export": "createStorefrontShellTheme",
486
486
  "description": "Resolve the stock AgentSam CMS storefront shell theme contract.",
487
487
  "deterministic": true,
@@ -0,0 +1,72 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://agentsam.dev/protocol/database/agentsam.schema-pack.v1.schema.json",
4
+ "title": "AgentSam schema pack family manifest",
5
+ "description": "Generic reusable contract for product schema packs (Identity, CMS, CAD, …). Packs own their manifests; this schema is protocol authority.",
6
+ "type": "object",
7
+ "additionalProperties": true,
8
+ "required": ["schema", "id", "version", "components"],
9
+ "properties": {
10
+ "schema": { "const": "agentsam.schema-pack.v1" },
11
+ "id": { "type": "string", "minLength": 1 },
12
+ "version": { "type": "string", "minLength": 1 },
13
+ "pack_family": { "type": "string", "minLength": 1 },
14
+ "components": {
15
+ "type": "array",
16
+ "minItems": 1,
17
+ "items": { "type": "string", "minLength": 1 }
18
+ },
19
+ "component_dependencies": {
20
+ "type": "object",
21
+ "additionalProperties": {
22
+ "type": "array",
23
+ "items": { "type": "string" }
24
+ }
25
+ },
26
+ "adapters": {
27
+ "type": "array",
28
+ "items": { "type": "string", "minLength": 1 }
29
+ },
30
+ "sql": {
31
+ "type": "object",
32
+ "properties": {
33
+ "portable_dir": { "type": "string" },
34
+ "files": {
35
+ "type": "object",
36
+ "additionalProperties": {
37
+ "type": "array",
38
+ "items": { "type": "string" }
39
+ }
40
+ },
41
+ "apply_order_fresh": {
42
+ "type": "array",
43
+ "items": { "type": "string" }
44
+ },
45
+ "apply_order_upgrade_v1_to_v2": {
46
+ "type": "array",
47
+ "items": { "type": "string" }
48
+ },
49
+ "optional_after_core": {
50
+ "type": "array",
51
+ "items": { "type": "string" }
52
+ }
53
+ }
54
+ },
55
+ "tables": {
56
+ "type": "object",
57
+ "additionalProperties": {
58
+ "type": "array",
59
+ "items": { "type": "string" }
60
+ }
61
+ },
62
+ "table_patterns": {
63
+ "type": "array",
64
+ "items": { "type": "string" }
65
+ },
66
+ "seed_policy": { "type": "string" },
67
+ "compatibility": { "type": "object" },
68
+ "recovery": { "type": "object" },
69
+ "owner": { "type": "string" },
70
+ "notes": { "type": "string" }
71
+ }
72
+ }
@@ -54,7 +54,7 @@
54
54
  "composer": "agentsam.mini-composer"
55
55
  },
56
56
  "packages": {
57
- "theme": "@inneranimalmedia/heuristic-theme",
57
+ "theme": "@inneranimalmedia/theme-heuristic",
58
58
  "composer": "@inneranimalmedia/agentsam-workbench",
59
59
  "analytics": "@inneranimalmedia/commerce-analytics"
60
60
  },
@@ -128,7 +128,7 @@
128
128
  "capabilities": [
129
129
  "theme.storefront.shell"
130
130
  ],
131
- "description": "Stock storefront theme selection — default package @inneranimalmedia/heuristic-theme (theme.storefront.shell). Theme is a projection of Brand, not brand authority."
131
+ "description": "Stock storefront theme selection — default package @inneranimalmedia/theme-heuristic (theme.storefront.shell). Theme is a projection of Brand, not brand authority."
132
132
  },
133
133
  "brand": {
134
134
  "id": "brand",
@@ -0,0 +1,105 @@
1
+ {
2
+ "schema": "agentsam.theme-refinery.lineage.v1",
3
+ "note": "Donor evidence stays private. Package identity uses lineage codes until remaster gates pass. installable=false until PACKAGE-READY.",
4
+ "lineages": {
5
+ "fnf": {
6
+ "display": "FNF",
7
+ "family": "editorial-commerce",
8
+ "donor": "fuelnfreetime",
9
+ "donor_display": "Fuel & Free Time",
10
+ "package_current": "@inneranimalmedia/theme-fuelnfree-site",
11
+ "package_target": "@inneranimalmedia/theme-ember",
12
+ "gallery_slug": "fuelnfree-site",
13
+ "status": "needs_normalization",
14
+ "installable": false,
15
+ "canonical_id": "ember"
16
+ },
17
+ "afm": {
18
+ "display": "AFM",
19
+ "family": "service-gallery",
20
+ "donor": "anything-floors",
21
+ "donor_display": "Anything Floors & More",
22
+ "package_current": "@inneranimalmedia/theme-floors-site",
23
+ "package_target": "@inneranimalmedia/theme-grove",
24
+ "gallery_slug": "floors-site",
25
+ "status": "needs_normalization",
26
+ "installable": false,
27
+ "canonical_id": "grove"
28
+ },
29
+ "phs": {
30
+ "display": "PHS",
31
+ "family": "trade-services",
32
+ "donor": "primeaux-handyman",
33
+ "donor_display": "Primeaux Handyman Services",
34
+ "package_current": "@inneranimalmedia/theme-handyman-site",
35
+ "package_target": "@inneranimalmedia/theme-forge",
36
+ "gallery_slug": "handyman-site",
37
+ "status": "needs_normalization",
38
+ "installable": false,
39
+ "canonical_id": "forge"
40
+ },
41
+ "nic": {
42
+ "display": "NIC",
43
+ "family": "community-faith",
44
+ "donor": "new-iberia-church",
45
+ "donor_display": "New Iberia Church of Christ",
46
+ "package_current": "@inneranimalmedia/theme-church-site",
47
+ "package_target": "@inneranimalmedia/theme-cypress",
48
+ "gallery_slug": "church-site",
49
+ "status": "needs_normalization",
50
+ "installable": false,
51
+ "canonical_id": "cypress"
52
+ },
53
+ "coc": {
54
+ "display": "COC",
55
+ "family": "nonprofit-campaign",
56
+ "donor": "companions-of-caddo",
57
+ "donor_display": "Companions of Caddo",
58
+ "package_current": "@inneranimalmedia/theme-companions-site",
59
+ "package_target": "@inneranimalmedia/theme-violet",
60
+ "gallery_slug": "companions-site",
61
+ "status": "needs_normalization",
62
+ "installable": false,
63
+ "canonical_id": "violet"
64
+ },
65
+ "cci": {
66
+ "display": "CCI",
67
+ "family": "professional-leadgen",
68
+ "donor": "chrystal-clear-insurance",
69
+ "donor_display": "Chrystal Clear Insurance",
70
+ "package_current": "@inneranimalmedia/theme-insurance-site",
71
+ "package_target": "@inneranimalmedia/theme-harbor",
72
+ "gallery_slug": "insurance-site",
73
+ "status": "needs_normalization",
74
+ "installable": false,
75
+ "canonical_id": "harbor"
76
+ },
77
+ "shin": {
78
+ "display": "SHIN",
79
+ "family": "consulting-portfolio",
80
+ "donor": "shinshu-solutions",
81
+ "donor_display": "Shinshu Solutions",
82
+ "package_current": "@inneranimalmedia/theme-shinshu-site",
83
+ "package_target": "@inneranimalmedia/theme-summit",
84
+ "gallery_slug": "shinshu-site",
85
+ "status": "needs_normalization",
86
+ "installable": false,
87
+ "canonical_id": "summit"
88
+ }
89
+ },
90
+ "stages": [
91
+ "raw",
92
+ "harvested",
93
+ "needs_normalization",
94
+ "normalized",
95
+ "remastered",
96
+ "package_ready",
97
+ "published"
98
+ ],
99
+ "pipeline": [
100
+ "agentsam-machine (inventory/types/parse/literal edges/assets/cache)",
101
+ "agentsam-brand (tokens/ingest/optimize/receipts)",
102
+ "theme-scenes + CMS contracts (shell/sections/pages)",
103
+ "refinery UI (keep / use primitive / ignore)"
104
+ ]
105
+ }
@@ -11,7 +11,27 @@
11
11
  "harvest_batch": { "type": "string" },
12
12
  "normalization_state": {
13
13
  "type": "string",
14
- "enum": ["fingerprinted", "portable", "portable-preview", "normalized", "wired", "promoted"]
14
+ "enum": [
15
+ "fingerprinted",
16
+ "harvested",
17
+ "needs_normalization",
18
+ "scaffolded",
19
+ "portable",
20
+ "portable-preview",
21
+ "normalized",
22
+ "remastered",
23
+ "package_ready",
24
+ "wired",
25
+ "promoted"
26
+ ]
27
+ },
28
+ "lineage": {
29
+ "type": "string",
30
+ "description": "Short remaster codename (fnf, afm, phs, …). Not the customer/donor product name."
31
+ },
32
+ "family": {
33
+ "type": "string",
34
+ "description": "Generic reusable family (editorial-commerce, service-gallery, …)."
15
35
  },
16
36
  "source_hash": { "type": "string" },
17
37
  "app_manifest": { "type": "string" },
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: auth
3
+ description: >
4
+ Add user accounts and sign-in to this TanStack Start app. Use when the app
5
+ needs authentication, sign-in, user accounts, protected routes, or per-user
6
+ data. Triggers on "auth", "login", "log in", "sign in", "sign up", "account",
7
+ "users", "authentication", "protected", "who is logged in", "current user",
8
+ "per-user".
9
+ metadata:
10
+ short-description: "Auth via the Grok broker (Google, X) or local email/password — no other methods supported"
11
+ user-invocable: false
12
+ ---
13
+
14
+ # Auth
15
+
16
+ This app runs its **own** [Better Auth](https://better-auth.com) at
17
+ `/api/auth/*`, federating to the shared **Grok auth broker** (`auth.grok.me`)
18
+ via the `genericOAuth` plugin. This template wires **Google** and **X**.
19
+
20
+ **Supported sign-in methods — use ONLY these three; nothing else is supported:
21
+ Google, X, and email/password.** No other social/OAuth provider (GitHub, Apple,
22
+ Discord, …), no magic links, passkeys, OTP, phone/SMS, or anonymous sign-in. Do
23
+ not add entries to `GROK_PROVIDERS`. Method detail and the email/password switch
24
+ (edit **only** `src/lib/auth/email-password.ts`): `references/sign-in-methods.md`.
25
+ **Exception — gate viewers are signed in already; NEVER render login/re-auth
26
+ buttons for them. Connector / app-data apps: ONLY gate "Continue with Grok",
27
+ no Google/X buttons**: `references/grok-identity.md`.
28
+
29
+ **Sign-in is OFF by default** — the template ships `.grok/app-env.json` with
30
+ `{"VITE_AUTH_ENABLED": "false"}`, so only add accounts when the ask calls for
31
+ them (AGENTS.md §0.5). Switching it on is "Turning sign-in on" below.
32
+
33
+ **Once on, sign-in is REAL — including in the sandbox live preview.** Do **NOT**
34
+ scaffold demo/mock/hardcoded users. Preview: popup + baked preview client;
35
+ deployed: per-app client + `DATABASE_URL` + zero-click gate sign-in
36
+ (`references/prewired-and-env.md`).
37
+
38
+ **While OFF** (`VITE_AUTH_ENABLED=false`) a **dev user** is returned so a
39
+ non-auth app renders without a signed-in visitor — dev and preview only.
40
+ Deployed, the flag is the platform's (always `"true"`), so `requireUserId`
41
+ rejects every visitor — auth-off apps use neither it nor `authMiddleware`.
42
+
43
+ Everything is **preinstalled and pre-wired in `src/lib/auth/`** — do not
44
+ `npm install` anything; `better-auth` is the only auth package (never
45
+ `@neondatabase/*`, `@stackframe/*`, or `@clerk/*`). **Do not edit or rewrite any
46
+ file under `src/lib/auth/`** — `server.ts` least of all — except
47
+ `email-password.ts` for its one flag. Per-file map:
48
+ `references/prewired-and-env.md`.
49
+
50
+ **`/auth/popup` is already handled by the template Vite plugin**
51
+ (`vite.config.ts` → `popup.server.ts`): it never paints the React app. **Do NOT
52
+ create `src/routes/auth/popup.tsx`** (or any React page / client OAuth at that
53
+ path) — that shows the full app inside the popup, the common failure mode.
54
+
55
+ **Never write a `.env` / `.env.local` / `.env.example`** in this sandbox: live
56
+ preview needs **zero** env configuration and a deployed app gets its vars
57
+ injected by the platform. The knobs that exist are in
58
+ `references/prewired-and-env.md` — never expose a non-`VITE_` var to the client.
59
+
60
+ `migrations/auth/0001_auth.sql` is the Better Auth schema — **do not edit**. It
61
+ sits outside the globbed `migrations/` directory (neither applier descends), so
62
+ it is not applied to apps without sign-in; "Turning sign-in on" copies it up.
63
+
64
+ ## Turning sign-in on
65
+
66
+ Do all of this — the routes alone render the disabled branch:
67
+
68
+ 1. **Flag:** delete the `VITE_AUTH_ENABLED` key from `.grok/app-env.json` and
69
+ **restart the dev server**. Vite reads env at startup, so HMR will not pick
70
+ it up. `npm run dev`, `npm run build` and `npm run preview` all read that
71
+ file through `scripts/with-app-env.mjs`, so preview and the built output flip
72
+ together — never start Vite directly.
73
+ 2. **Schema:** `cp migrations/auth/0001_auth.sql migrations/0001_auth.sql`, then
74
+ restart so it applies. It is tracked by basename in `_migrations`, so a
75
+ database that already has it will not re-run it.
76
+ 3. **Routes:** add `src/routes/api/auth/$.ts` + `src/routes/login.tsx` — copy
77
+ both from `references/wiring.md` (the catch-all API route is what makes
78
+ `/api/auth/*` and the broker callback work).
79
+ 4. **Sign out:** a login with no way out is not done — render `<UserButton />`
80
+ from `@/lib/auth/gates` (wires `signOut()`; hides sign-out for gate sessions).
81
+ 5. **Existing data:** wrap the app's server functions in `authMiddleware` (an
82
+ auth-off app must not have been using it — see the `neon` skill). Rows from
83
+ before sign-in existed are **development data**: drop and recreate them
84
+ unless the user says otherwise — don't hand them to whoever signs in first.
85
+
86
+ ## Building on it once it's on
87
+
88
+ - **Sign in / out:** `signIn(providerId)` and `signOut()` from
89
+ `@/lib/auth/client`; `GROK_PROVIDERS` renders the buttons. The popup,
90
+ bearer-token hand-off, and request attachment are internal — leave them alone.
91
+ Prefer `<UserButton />` (it handles the pending and failure states); `signOut()`
92
+ rejects when deployed if the server never confirms — catch it. Never
93
+ `authClient.signOut()`: it leaves the preview bearer token attached to every
94
+ later request, so the visitor stays signed in.
95
+ - **Reading the user:** `useCurrentUser()` is display-only (`null` means
96
+ *loading OR signed out*, so never redirect on it alone); guard on
97
+ `useCurrentUserState()`'s `isPending` instead. Gates (`SignedIn`, `SignedOut`,
98
+ `SignInGate`, `RedirectToSignIn`, `UserButton`) live in `@/lib/auth/gates`.
99
+ CTA hard rules, skeleton, and cookie-SSR zero-flash: `references/session-ui.md`.
100
+ - **Per-user data (mandatory):** every server function that touches per-user data
101
+ must use the prewired `authMiddleware` and scope every read **and** write to
102
+ `context.userId` — a Postgres driver has full DB access, so nothing else limits
103
+ the query. Keep `user_id` columns `TEXT`; never trust a client-supplied user id;
104
+ signed out, the middleware throws `UnauthorizedError` (401). Code and
105
+ disabled-mode semantics: `references/per-user-data.md`.
106
+ - **Security model:** headless broker, `__Host-` cookies + `trustedOrigins`, and
107
+ Fetch-Metadata sibling isolation are already wired — never weaken them to make
108
+ an error go away (`references/sign-in-methods.md` covers the model and the
109
+ "Invalid origin" fix).
110
+
@@ -0,0 +1,25 @@
1
+ {
2
+ "schema": "agentsam.skill.v1",
3
+ "id": "grok-auth",
4
+ "name": "Grok \u00b7 auth",
5
+ "description": "Auth via the Grok broker (Google, X) or local email/password \u2014 no other methods supported",
6
+ "icon": "skill",
7
+ "slash": {
8
+ "suggested": "/grok-auth"
9
+ },
10
+ "instructions": {
11
+ "source": "local_file",
12
+ "ref": "SKILL.md"
13
+ },
14
+ "execution": {
15
+ "mode": "turn",
16
+ "tools": [],
17
+ "operations": [],
18
+ "capabilities": []
19
+ },
20
+ "provenance": {
21
+ "source": "apps/local-studio/.grok/skills",
22
+ "vendor": "grok",
23
+ "status": "imported"
24
+ }
25
+ }
@@ -0,0 +1,64 @@
1
+ # Sign in with Grok (deployed apps — zero clicks)
2
+
3
+ Behind the edge gate, every proxied request from a signed-in Grok viewer
4
+ carries an unforgeable `x-grok-identity` JWT (EdDSA, minted per request; the
5
+ gate strips any client-supplied copy). The pre-wired `gateIdentitySessions`
6
+ plugin (`src/lib/auth/gate-session.server.ts`) verifies it against the gate's
7
+ JWKS (`/__gate/identity-key`, via `src/lib/auth/gate-identity.server.ts`) and,
8
+ when the app has no session yet, materializes the Better Auth session for that
9
+ viewer automatically — no sign-in button, no redirect, no broker round-trip.
10
+ `useSession` / `useCurrentUser` simply return the Grok user.
11
+
12
+ The broker OAuth flow is the **fallback** for anonymous/public viewers and for
13
+ contexts without the gate. The live preview gets the same zero-click identity
14
+ from the in-VM preview proxy at `http://127.0.0.1:6014` (preview tokens carry
15
+ audience `preview`); the popup mechanism remains the fallback there.
16
+
17
+ ## Never render sign-in or re-auth UI to a gate viewer
18
+
19
+ A gate-authenticated viewer is **already signed in**, and the gate refreshes
20
+ connector tokens on every proxied request — **the platform has no re-auth
21
+ concept**. Never render "Re-auth with Grok", "Sign in again", "Refresh
22
+ session", or a standing "Continue with Grok" button: sign-in UI may appear
23
+ only in the `app-data` skill's `login` error state, after a connector call
24
+ actually returned `loginRequired: true`.
25
+
26
+ The live preview gets the same zero-click session, so a sign-in button visible
27
+ to the owner in the preview indicates a bug (a CTA rendered while the session
28
+ check was still pending, or rendered in reaction to a data error) — fix it,
29
+ don't restyle it. For any fallback sign-in surface use `<SignInGate>` from
30
+ `@/lib/auth/gates`: it renders sign-in UI only after the session check resolved
31
+ to no user, never during loading and never from a data error.
32
+
33
+ Sign-out is also a no-op for a gate session — the next request re-materializes
34
+ it from `x-grok-identity`, an instant sign-back-in loop. `<UserButton />`
35
+ already hides its sign-out control for gate sessions; never build a custom
36
+ sign-out (or any sign-out route/handler) for gate viewers.
37
+
38
+ ## Files (pre-wired — do not edit)
39
+
40
+ | File | Role |
41
+ |---|---|
42
+ | `gate-identity.server.ts` | Verifies the gate's `x-grok-identity` viewer JWT (EdDSA vs the gate JWKS; fail-closed). Server-only. |
43
+ | `gate-session.server.ts` | Better Auth plugin that turns a verified gate identity into the app session with zero clicks. Already registered in `server.ts`. |
44
+
45
+ ## Env (deployer-injected)
46
+
47
+ | Var | Scope | Meaning |
48
+ |---|---|---|
49
+ | `GROK_PROJECT_ID` | server | deployed apps: enables "Sign in with Grok" (`x-grok-identity` audience check `app:<project_id>`) |
50
+ | `GROK_GATE_ORIGIN` | server | gate public origin override (JWKS + issuer pin); unset → preview mode (no `GROK_PROJECT_ID`) defaults to the in-VM proxy `http://127.0.0.1:6014` (audience `preview`), deployed mode derives it from the inbound host |
51
+
52
+ Deployed behavior: gate-authenticated viewers are signed in automatically from
53
+ `x-grok-identity`; the deployer also injects a per-app broker client +
54
+ `DATABASE_URL`, so the fallback sign-in persists identities in Postgres.
55
+
56
+ ## Connector / app-data apps: gate sign-in only
57
+
58
+ When the `app-data` skill applies, the login page offers ONLY "Continue with
59
+ Grok" via the gate sign-in — the zero-click `x-grok-identity` session above, or
60
+ the gate-built `loginUrl` returned by a connector call. Do not wire Google/X
61
+ buttons for these apps: a broker login can mint an identity that is not the
62
+ gate viewer the connector data belongs to. The three-method rule applies to
63
+ apps without connector data. Still no new `GROK_PROVIDERS` entries, still never
64
+ edit `src/lib/auth/`.
@@ -0,0 +1,49 @@
1
+ # Per-user data (server-side — mandatory)
2
+
3
+ Pair auth with the DB (see the `neon` skill). A regular Postgres driver has full
4
+ DB access, so **every** server function that touches per-user data must verify
5
+ the caller and scope rows to them. Use the prewired **`authMiddleware`**: it
6
+ resolves the same-origin session to a verified `context.userId` (and rejects
7
+ scripted cross-site/sibling requests) — no token threading:
8
+
9
+ ```ts
10
+ import { createServerFn } from "@tanstack/react-start";
11
+ import { getSql } from "@/lib/db";
12
+ import { authMiddleware } from "@/lib/auth/middleware";
13
+
14
+ export const listTodos = createServerFn({ method: "GET" })
15
+ .middleware([authMiddleware])
16
+ .handler(async ({ context }) => {
17
+ const sql = await getSql();
18
+ // Type the row shape — a server fn's return must be provably serializable.
19
+ return sql<{ id: number; title: string; done: boolean }>`select id, title, done from todos where user_id = ${context.userId} order by id desc`;
20
+ });
21
+
22
+ // Inputs go through `.validator()` (the current API); the client passes `{ data }`:
23
+ export const addTodo = createServerFn({ method: "POST" })
24
+ .validator((title: string) => title.trim())
25
+ .middleware([authMiddleware])
26
+ .handler(async ({ context, data: title }) => {
27
+ if (!title) return;
28
+ const sql = await getSql();
29
+ await sql`insert into todos (user_id, title) values (${context.userId}, ${title})`;
30
+ });
31
+ // mutations must scope writes too: `... where id = ${id} and user_id = ${context.userId}`
32
+ ```
33
+
34
+ Call these from **client code** (effects, event handlers, React Query) — that's
35
+ where `Sec-Fetch-Site: same-origin` holds:
36
+
37
+ ```ts
38
+ useEffect(() => { listTodos().then(setTodos).catch(() => setTodos([])); }, []);
39
+ ```
40
+
41
+ Semantics: signed out → the middleware throws `UnauthorizedError` (message
42
+ `"Unauthorized"`, `status` 401 — match it to send the visitor to sign-in), in the
43
+ live preview too (real auth). With auth disabled (`VITE_AUTH_ENABLED=false`) it
44
+ resolves the dev user (`"dev-user"`) in dev and preview only — the deployed flag
45
+ comes from the deployer (today always `"true"`), so deployed it rejects every
46
+ visitor — which is why an app without sign-in must not use the middleware at all
47
+ (see the `neon` skill). Keep `user_id` columns
48
+ `TEXT` (Better Auth uses text ids; the disabled dev user is `'dev-user'`). Never
49
+ trust a client-supplied user id — only the middleware / `requireUserId()` result.
@@ -0,0 +1,54 @@
1
+ # What's pre-wired, and the env vars
2
+
3
+ ## `src/lib/auth/`
4
+
5
+ | File | Use it for |
6
+ |---|---|
7
+ | `client.ts` | Browser client. `signIn(providerId)`, `signOut()`, `authEnabled`, `GROK_PROVIDERS`. |
8
+ | `server.ts` | The Better Auth instance (server-only). **Do not edit or rewrite.** Import only from `/api/auth/$`. |
9
+ | `email-password.ts` | **Only** place to enable local email/password (`emailAndPasswordEnabled = true`). |
10
+ | `popup.server.ts` | Live-preview popup handler (server-only). Already wired by the Vite plugin — do not create a route for it. |
11
+ | `providers.ts` | `GROK_PROVIDERS` — the fixed broker upstream list (Google and X only; don't add others). |
12
+ | `use-current-user.ts` | `useCurrentUser()` / `useCurrentUserState()` React hooks. |
13
+ | `gates.tsx` | `SignedIn`, `SignedOut`, `RedirectToSignIn`, `UserButton`. |
14
+ | `middleware.ts` | `authMiddleware` for server functions → verified `context.userId`. |
15
+ | `verify.server.ts` | `requireUserId()` / `getSessionUser()` (server-only) for manual wiring. |
16
+
17
+ ## How each mode gets its credentials
18
+
19
+ - **Live preview** (`*.grok-sandbox.com`): the app is an embedded iframe, so
20
+ sign-in opens a **popup** (a top-level redirect to the broker can't work inside
21
+ the iframe) and federates via a baked shared **preview client**
22
+ (`src/lib/auth/preview.ts`). The handler 302s straight to the broker/upstream
23
+ login; on return the popup posts the session bearer back in a tiny HTML page.
24
+ Sessions (and email/password users) persist in the app's embedded PGLite DB —
25
+ the SAME DB as app data — and, since the iframe's cookies are partitioned,
26
+ ride that bearer token; all of it lives in `src/lib/auth`.
27
+ Restarting the preview resets the DB.
28
+ - **Deployed**: the deployer injects a per-app client + `DATABASE_URL`, so
29
+ sign-in persists identities in Postgres.
30
+
31
+ ## Env vars — do **not** create a `.env` file
32
+
33
+ **Never write a `.env` / `.env.local` / `.env.example` for auth (or anything
34
+ else) in this sandbox.** Live preview sign-in works out of the box with **zero**
35
+ env configuration: the server falls back to the baked preview client in
36
+ `src/lib/auth/preview.ts`, derives the `*.grok-sandbox.com` origin per-request,
37
+ mints a process-stable session secret, and persists sessions in embedded
38
+ PGLite. Deployed apps get `GROK_AUTH_*` / `BETTER_AUTH_*` / `DATABASE_URL`
39
+ injected by the platform — still not something you write into a file.
40
+
41
+ Optional process-env knobs (platform / rare overrides only — **do not** put
42
+ these in a file you create):
43
+
44
+ | Var | Where | Purpose |
45
+ |---|---|---|
46
+ | `VITE_AUTH_ENABLED` | client | `"false"` in the shipped `.grok/app-env.json` (dev user); drop the key to turn sign-in ON. Only client-visible auth flag |
47
+ | `BETTER_AUTH_URL` | server | app's own public origin; unset in preview (origin is derived per-request) |
48
+ | `BETTER_AUTH_SECRET` | server | signs this app's own sessions (process-stable fallback in preview; survives HMR) |
49
+ | `GROK_AUTH_ISSUER` | server | the shared broker (defaults to `https://auth.grok.me`) |
50
+ | `GROK_AUTH_CLIENT_ID` / `GROK_AUTH_CLIENT_SECRET` | server | per-app client (falls back to the preview client) |
51
+ | `DATABASE_URL` | server | when deployed, Better Auth persists here (preview persists to the embedded PGLite — same DB as app data) |
52
+
53
+ Never expose a non-`VITE_` var to the client. The preview client id/secret live
54
+ server-only in `src/lib/auth/preview.ts`.