@agent-native/core 0.96.0 → 0.97.0

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 (450) hide show
  1. package/README.md +6 -0
  2. package/corpus/README.md +2 -2
  3. package/corpus/core/CHANGELOG.md +39 -0
  4. package/corpus/core/docs/content/audit-log.mdx +2 -1
  5. package/corpus/core/docs/content/automations.mdx +7 -7
  6. package/corpus/core/docs/content/creating-templates.mdx +1 -1
  7. package/corpus/core/docs/content/internationalization.mdx +2 -1
  8. package/corpus/core/docs/content/locales/ar-SA/audit-log.mdx +2 -1
  9. package/corpus/core/docs/content/locales/ar-SA/automations.mdx +7 -7
  10. package/corpus/core/docs/content/locales/ar-SA/getting-started.mdx +7 -1
  11. package/corpus/core/docs/content/locales/ar-SA/internationalization.mdx +1 -1
  12. package/corpus/core/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
  13. package/corpus/core/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
  14. package/corpus/core/docs/content/locales/ar-SA/security.mdx +8 -0
  15. package/corpus/core/docs/content/locales/de-DE/audit-log.mdx +2 -1
  16. package/corpus/core/docs/content/locales/de-DE/automations.mdx +7 -7
  17. package/corpus/core/docs/content/locales/de-DE/getting-started.mdx +7 -1
  18. package/corpus/core/docs/content/locales/de-DE/internationalization.mdx +1 -1
  19. package/corpus/core/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
  20. package/corpus/core/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
  21. package/corpus/core/docs/content/locales/de-DE/security.mdx +8 -0
  22. package/corpus/core/docs/content/locales/es-ES/audit-log.mdx +2 -1
  23. package/corpus/core/docs/content/locales/es-ES/automations.mdx +7 -7
  24. package/corpus/core/docs/content/locales/es-ES/getting-started.mdx +7 -1
  25. package/corpus/core/docs/content/locales/es-ES/internationalization.mdx +1 -1
  26. package/corpus/core/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
  27. package/corpus/core/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
  28. package/corpus/core/docs/content/locales/es-ES/security.mdx +8 -0
  29. package/corpus/core/docs/content/locales/fr-FR/audit-log.mdx +2 -1
  30. package/corpus/core/docs/content/locales/fr-FR/automations.mdx +7 -7
  31. package/corpus/core/docs/content/locales/fr-FR/getting-started.mdx +7 -1
  32. package/corpus/core/docs/content/locales/fr-FR/internationalization.mdx +1 -1
  33. package/corpus/core/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
  34. package/corpus/core/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
  35. package/corpus/core/docs/content/locales/fr-FR/security.mdx +8 -0
  36. package/corpus/core/docs/content/locales/hi-IN/audit-log.mdx +2 -1
  37. package/corpus/core/docs/content/locales/hi-IN/automations.mdx +7 -7
  38. package/corpus/core/docs/content/locales/hi-IN/getting-started.mdx +7 -1
  39. package/corpus/core/docs/content/locales/hi-IN/internationalization.mdx +1 -1
  40. package/corpus/core/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
  41. package/corpus/core/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
  42. package/corpus/core/docs/content/locales/hi-IN/security.mdx +8 -0
  43. package/corpus/core/docs/content/locales/ja-JP/audit-log.mdx +2 -1
  44. package/corpus/core/docs/content/locales/ja-JP/automations.mdx +7 -7
  45. package/corpus/core/docs/content/locales/ja-JP/getting-started.mdx +7 -1
  46. package/corpus/core/docs/content/locales/ja-JP/internationalization.mdx +1 -1
  47. package/corpus/core/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
  48. package/corpus/core/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
  49. package/corpus/core/docs/content/locales/ja-JP/security.mdx +8 -0
  50. package/corpus/core/docs/content/locales/ko-KR/audit-log.mdx +2 -1
  51. package/corpus/core/docs/content/locales/ko-KR/automations.mdx +7 -7
  52. package/corpus/core/docs/content/locales/ko-KR/getting-started.mdx +7 -1
  53. package/corpus/core/docs/content/locales/ko-KR/internationalization.mdx +1 -1
  54. package/corpus/core/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
  55. package/corpus/core/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
  56. package/corpus/core/docs/content/locales/ko-KR/security.mdx +8 -0
  57. package/corpus/core/docs/content/locales/pt-BR/audit-log.mdx +2 -1
  58. package/corpus/core/docs/content/locales/pt-BR/automations.mdx +7 -7
  59. package/corpus/core/docs/content/locales/pt-BR/getting-started.mdx +7 -1
  60. package/corpus/core/docs/content/locales/pt-BR/internationalization.mdx +1 -1
  61. package/corpus/core/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
  62. package/corpus/core/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
  63. package/corpus/core/docs/content/locales/pt-BR/security.mdx +8 -0
  64. package/corpus/core/docs/content/locales/zh-CN/audit-log.mdx +2 -1
  65. package/corpus/core/docs/content/locales/zh-CN/automations.mdx +7 -7
  66. package/corpus/core/docs/content/locales/zh-CN/getting-started.mdx +6 -4
  67. package/corpus/core/docs/content/locales/zh-CN/internationalization.mdx +1 -1
  68. package/corpus/core/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
  69. package/corpus/core/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
  70. package/corpus/core/docs/content/locales/zh-CN/security.mdx +8 -0
  71. package/corpus/core/docs/content/locales/zh-TW/audit-log.mdx +2 -1
  72. package/corpus/core/docs/content/locales/zh-TW/automations.mdx +7 -7
  73. package/corpus/core/docs/content/locales/zh-TW/getting-started.mdx +6 -4
  74. package/corpus/core/docs/content/locales/zh-TW/internationalization.mdx +1 -1
  75. package/corpus/core/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
  76. package/corpus/core/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
  77. package/corpus/core/docs/content/locales/zh-TW/security.mdx +8 -0
  78. package/corpus/core/docs/content/package-lifecycle.mdx +51 -0
  79. package/corpus/core/docs/content/sandbox-adapters.mdx +16 -5
  80. package/corpus/core/package.json +9 -2
  81. package/corpus/core/src/a2a/auth-policy.ts +33 -0
  82. package/corpus/core/src/agent/durable-background.ts +15 -7
  83. package/corpus/core/src/agent/run-store.ts +13 -4
  84. package/corpus/core/src/audit/actions/export-audit-events.ts +162 -0
  85. package/corpus/core/src/audit/store.ts +8 -3
  86. package/corpus/core/src/audit/types.ts +3 -0
  87. package/corpus/core/src/cli/doctor.ts +396 -0
  88. package/corpus/core/src/cli/index.ts +56 -0
  89. package/corpus/core/src/cli/info.ts +3 -3
  90. package/corpus/core/src/cli/package-lifecycle.ts +821 -0
  91. package/corpus/core/src/client/agent-chat-adapter.ts +9 -9
  92. package/corpus/core/src/guards/db-tool-scoping.ts +129 -0
  93. package/corpus/core/src/guards/index.ts +23 -0
  94. package/corpus/core/src/guards/no-drizzle-push.ts +116 -0
  95. package/corpus/core/src/guards/no-env-credentials.ts +229 -0
  96. package/corpus/core/src/guards/no-env-mutation.ts +114 -0
  97. package/corpus/core/src/guards/no-localhost-fallback.ts +124 -0
  98. package/corpus/core/src/guards/no-unscoped-credentials.ts +227 -0
  99. package/corpus/core/src/guards/no-unscoped-queries.ts +834 -0
  100. package/corpus/core/src/guards/scan-utils.ts +105 -0
  101. package/corpus/core/src/guards/types.ts +30 -0
  102. package/corpus/core/src/org/accept-pending.ts +9 -1
  103. package/corpus/core/src/org/migrations.ts +41 -0
  104. package/corpus/core/src/package-lifecycle/index.ts +1 -0
  105. package/corpus/core/src/package-lifecycle/manifest.ts +120 -0
  106. package/corpus/core/src/provider-api/custom-registry.ts +56 -0
  107. package/corpus/core/src/provider-api/index.ts +2 -0
  108. package/corpus/core/src/secrets/storage.ts +47 -27
  109. package/corpus/core/src/server/action-discovery.ts +4 -0
  110. package/corpus/core/src/server/agent-chat-plugin.ts +54 -12
  111. package/corpus/core/src/server/core-routes-plugin.ts +30 -14
  112. package/corpus/core/src/server/csrf.ts +24 -5
  113. package/corpus/core/src/server/framework-request-handler.ts +34 -0
  114. package/corpus/core/src/server/google-realtime-session.ts +1 -36
  115. package/corpus/core/src/server/poll.ts +24 -2
  116. package/corpus/core/src/server/realtime-voice.ts +9 -0
  117. package/corpus/core/src/server/request-origin.ts +63 -0
  118. package/corpus/core/src/server/transcribe-voice.ts +1 -50
  119. package/corpus/core/src/templates/default/package.json +2 -2
  120. package/corpus/core/src/templates/headless/package.json +0 -1
  121. package/corpus/core/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
  122. package/corpus/core/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
  123. package/corpus/core/src/templates/workspace-core/package.json +0 -1
  124. package/corpus/core/src/templates/workspace-root/package.json +0 -1
  125. package/corpus/core/src/triggers/actions.ts +11 -3
  126. package/corpus/core/src/triggers/types.ts +7 -1
  127. package/corpus/templates/analytics/actions/compose-dashboard.ts +65 -37
  128. package/corpus/templates/analytics/actions/mutate-dashboard.ts +73 -24
  129. package/corpus/templates/analytics/actions/reorder-dashboard-panels.ts +16 -13
  130. package/corpus/templates/analytics/actions/update-dashboard.ts +53 -42
  131. package/corpus/templates/analytics/changelog/2026-07-10-dashboard-edits-from-the-agent-and-the-ui-at-the-same-time-n.md +6 -0
  132. package/corpus/templates/analytics/changelog/2026-07-10-timed-out-bigquery-jobs-are-now-cancelled-so-they-stop-consu.md +6 -0
  133. package/corpus/templates/analytics/package.json +1 -2
  134. package/corpus/templates/analytics/server/lib/bigquery.ts +3 -2
  135. package/corpus/templates/analytics/server/lib/dashboards-store.ts +154 -11
  136. package/corpus/templates/assets/package.json +1 -2
  137. package/corpus/templates/brain/package.json +1 -2
  138. package/corpus/templates/calendar/package.json +1 -2
  139. package/corpus/templates/chat/package.json +1 -2
  140. package/corpus/templates/clips/changelog/2026-07-10-atomic-view-tracking.md +6 -0
  141. package/corpus/templates/clips/chrome-extension/package.json +3 -2
  142. package/corpus/templates/clips/desktop/package.json +6 -4
  143. package/corpus/templates/clips/desktop/src/lib/recorder.ts +26 -13
  144. package/corpus/templates/clips/desktop/src/lib/voice-dictation.ts +4 -1
  145. package/corpus/templates/clips/package.json +1 -2
  146. package/corpus/templates/clips/server/db/schema.ts +29 -17
  147. package/corpus/templates/clips/server/plugins/db.ts +8 -0
  148. package/corpus/templates/clips/server/routes/api/view-event.post.ts +260 -105
  149. package/corpus/templates/content/.agents/skills/notion-integration/SKILL.md +16 -0
  150. package/corpus/templates/content/AGENTS.md +72 -62
  151. package/corpus/templates/content/actions/_content-database-source-adapters.ts +84 -0
  152. package/corpus/templates/content/actions/_database-source-utils.ts +206 -96
  153. package/corpus/templates/content/actions/_notion-database-source-adapter.ts +216 -0
  154. package/corpus/templates/content/actions/_position-utils.ts +76 -0
  155. package/corpus/templates/content/actions/_property-utils.ts +31 -20
  156. package/corpus/templates/content/actions/add-database-item.ts +52 -39
  157. package/corpus/templates/content/actions/attach-content-database-source.ts +95 -11
  158. package/corpus/templates/content/actions/change-content-database-source-role.ts +24 -1
  159. package/corpus/templates/content/actions/configure-document-property.ts +36 -27
  160. package/corpus/templates/content/actions/create-content-database.ts +40 -30
  161. package/corpus/templates/content/actions/create-document.ts +39 -32
  162. package/corpus/templates/content/actions/duplicate-document-property.ts +37 -28
  163. package/corpus/templates/content/actions/list-notion-database-sources.ts +80 -0
  164. package/corpus/templates/content/actions/move-document.ts +64 -48
  165. package/corpus/templates/content/actions/refresh-content-database-source.ts +42 -3
  166. package/corpus/templates/content/actions/share-local-file-document.ts +36 -27
  167. package/corpus/templates/content/actions/suggest-source-join-key.ts +39 -16
  168. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +89 -23
  169. package/corpus/templates/content/app/components/editor/database/settings.tsx +1 -1
  170. package/corpus/templates/content/app/hooks/use-content-database.ts +18 -1
  171. package/corpus/templates/content/app/i18n/zh-TW.ts +4 -0
  172. package/corpus/templates/content/app/i18n-data.ts +40 -0
  173. package/corpus/templates/content/changelog/2026-07-10-failed-row-creation-and-source-attach-now-show-an-error-inst.md +6 -0
  174. package/corpus/templates/content/changelog/2026-07-10-items-added-at-the-same-time-no-longer-end-up-with-identical.md +6 -0
  175. package/corpus/templates/content/changelog/2026-07-10-notion-databases-can-add-read-only-details-to-content-tables.md +6 -0
  176. package/corpus/templates/content/package.json +1 -2
  177. package/corpus/templates/content/parity/matrix.md +25 -25
  178. package/corpus/templates/content/parity/matrix.ts +1 -0
  179. package/corpus/templates/content/server/routes/api/documents/[id]/move.patch.ts +43 -26
  180. package/corpus/templates/content/shared/api.ts +16 -1
  181. package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +8 -4
  182. package/corpus/templates/design/AGENTS.md +12 -2
  183. package/corpus/templates/design/DEVELOPING.md +10 -6
  184. package/corpus/templates/design/actions/apply-visual-edit.ts +191 -6
  185. package/corpus/templates/design/actions/duplicate-design.ts +31 -25
  186. package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +5 -1
  187. package/corpus/templates/design/changelog/2026-07-10-duplicating-a-design-can-no-longer-produce-a-copy-with-missi.md +6 -0
  188. package/corpus/templates/design/changelog/2026-07-10-local-visual-edits-can-now-save-safe-leaf-text-class-and.md +6 -0
  189. package/corpus/templates/design/package.json +1 -1
  190. package/corpus/templates/design/shared/local-jsx-visual-edit.ts +388 -0
  191. package/corpus/templates/dispatch/package.json +1 -2
  192. package/corpus/templates/forms/actions/patch-form-fields.ts +82 -44
  193. package/corpus/templates/forms/changelog/2026-07-10-simultaneous-edits-to-different-form-fields-no-longer-overwr.md +6 -0
  194. package/corpus/templates/forms/package.json +1 -2
  195. package/corpus/templates/macros/package.json +1 -2
  196. package/corpus/templates/mail/app/components/email/EmailThread.tsx +3 -1
  197. package/corpus/templates/mail/changelog/2026-07-10-fixed-calendar-rsvp-buttons-in-emails-firing-duplicate-respo.md +6 -0
  198. package/corpus/templates/mail/package.json +1 -2
  199. package/corpus/templates/plan/actions/restore-plan-version.ts +126 -96
  200. package/corpus/templates/plan/changelog/2026-07-10-restoring-a-plan-version-can-no-longer-leave-a-plan-half-res.md +6 -0
  201. package/corpus/templates/plan/package.json +1 -2
  202. package/corpus/templates/plan/server/plans.ts +9 -2
  203. package/corpus/templates/slides/actions/list-decks.ts +28 -0
  204. package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +41 -26
  205. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +4 -8
  206. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +2 -4
  207. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +4 -8
  208. package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +5 -12
  209. package/corpus/templates/slides/app/components/editor/HistoryPanel.tsx +3 -6
  210. package/corpus/templates/slides/app/components/editor/ImageDropPromptPopover.tsx +3 -6
  211. package/corpus/templates/slides/app/components/editor/PromptDialog.tsx +2 -5
  212. package/corpus/templates/slides/app/context/DeckContext.tsx +47 -4
  213. package/corpus/templates/slides/app/pages/DeckEditor.tsx +11 -30
  214. package/corpus/templates/slides/app/pages/Index.tsx +2 -3
  215. package/corpus/templates/slides/app/root.tsx +0 -5
  216. package/corpus/templates/slides/changelog/2026-07-10-deck-lists-load-much-faster-and-no-longer-re-download-slide-.md +6 -0
  217. package/corpus/templates/slides/package.json +1 -2
  218. package/dist/a2a/auth-policy.d.ts +19 -0
  219. package/dist/a2a/auth-policy.d.ts.map +1 -1
  220. package/dist/a2a/auth-policy.js +32 -0
  221. package/dist/a2a/auth-policy.js.map +1 -1
  222. package/dist/agent/durable-background.d.ts +8 -5
  223. package/dist/agent/durable-background.d.ts.map +1 -1
  224. package/dist/agent/durable-background.js +15 -8
  225. package/dist/agent/durable-background.js.map +1 -1
  226. package/dist/agent/run-store.d.ts.map +1 -1
  227. package/dist/agent/run-store.js +9 -4
  228. package/dist/agent/run-store.js.map +1 -1
  229. package/dist/audit/actions/export-audit-events.d.ts +27 -0
  230. package/dist/audit/actions/export-audit-events.d.ts.map +1 -0
  231. package/dist/audit/actions/export-audit-events.js +144 -0
  232. package/dist/audit/actions/export-audit-events.js.map +1 -0
  233. package/dist/audit/store.d.ts +1 -0
  234. package/dist/audit/store.d.ts.map +1 -1
  235. package/dist/audit/store.js +8 -3
  236. package/dist/audit/store.js.map +1 -1
  237. package/dist/audit/types.d.ts +3 -0
  238. package/dist/audit/types.d.ts.map +1 -1
  239. package/dist/audit/types.js.map +1 -1
  240. package/dist/cli/doctor.d.ts +83 -0
  241. package/dist/cli/doctor.d.ts.map +1 -0
  242. package/dist/cli/doctor.js +277 -0
  243. package/dist/cli/doctor.js.map +1 -0
  244. package/dist/cli/index.js +50 -0
  245. package/dist/cli/index.js.map +1 -1
  246. package/dist/cli/info.js +3 -3
  247. package/dist/cli/info.js.map +1 -1
  248. package/dist/cli/package-lifecycle.d.ts +50 -0
  249. package/dist/cli/package-lifecycle.d.ts.map +1 -0
  250. package/dist/cli/package-lifecycle.js +560 -0
  251. package/dist/cli/package-lifecycle.js.map +1 -0
  252. package/dist/client/agent-chat-adapter.js +7 -3
  253. package/dist/client/agent-chat-adapter.js.map +1 -1
  254. package/dist/collab/struct-routes.d.ts +1 -1
  255. package/dist/guards/db-tool-scoping.d.ts +38 -0
  256. package/dist/guards/db-tool-scoping.d.ts.map +1 -0
  257. package/dist/guards/db-tool-scoping.js +114 -0
  258. package/dist/guards/db-tool-scoping.js.map +1 -0
  259. package/dist/guards/index.d.ts +23 -0
  260. package/dist/guards/index.d.ts.map +1 -0
  261. package/dist/guards/index.js +19 -0
  262. package/dist/guards/index.js.map +1 -0
  263. package/dist/guards/no-drizzle-push.d.ts +14 -0
  264. package/dist/guards/no-drizzle-push.d.ts.map +1 -0
  265. package/dist/guards/no-drizzle-push.js +97 -0
  266. package/dist/guards/no-drizzle-push.js.map +1 -0
  267. package/dist/guards/no-env-credentials.d.ts +36 -0
  268. package/dist/guards/no-env-credentials.d.ts.map +1 -0
  269. package/dist/guards/no-env-credentials.js +204 -0
  270. package/dist/guards/no-env-credentials.js.map +1 -0
  271. package/dist/guards/no-env-mutation.d.ts +23 -0
  272. package/dist/guards/no-env-mutation.d.ts.map +1 -0
  273. package/dist/guards/no-env-mutation.js +90 -0
  274. package/dist/guards/no-env-mutation.js.map +1 -0
  275. package/dist/guards/no-localhost-fallback.d.ts +30 -0
  276. package/dist/guards/no-localhost-fallback.d.ts.map +1 -0
  277. package/dist/guards/no-localhost-fallback.js +105 -0
  278. package/dist/guards/no-localhost-fallback.js.map +1 -0
  279. package/dist/guards/no-unscoped-credentials.d.ts +28 -0
  280. package/dist/guards/no-unscoped-credentials.d.ts.map +1 -0
  281. package/dist/guards/no-unscoped-credentials.js +199 -0
  282. package/dist/guards/no-unscoped-credentials.js.map +1 -0
  283. package/dist/guards/no-unscoped-queries.d.ts +32 -0
  284. package/dist/guards/no-unscoped-queries.d.ts.map +1 -0
  285. package/dist/guards/no-unscoped-queries.js +720 -0
  286. package/dist/guards/no-unscoped-queries.js.map +1 -0
  287. package/dist/guards/scan-utils.d.ts +28 -0
  288. package/dist/guards/scan-utils.d.ts.map +1 -0
  289. package/dist/guards/scan-utils.js +92 -0
  290. package/dist/guards/scan-utils.js.map +1 -0
  291. package/dist/guards/types.d.ts +28 -0
  292. package/dist/guards/types.d.ts.map +1 -0
  293. package/dist/guards/types.js +11 -0
  294. package/dist/guards/types.js.map +1 -0
  295. package/dist/org/accept-pending.d.ts.map +1 -1
  296. package/dist/org/accept-pending.js +9 -1
  297. package/dist/org/accept-pending.js.map +1 -1
  298. package/dist/org/migrations.d.ts +7 -2
  299. package/dist/org/migrations.d.ts.map +1 -1
  300. package/dist/org/migrations.js +41 -0
  301. package/dist/org/migrations.js.map +1 -1
  302. package/dist/package-lifecycle/index.d.ts +2 -0
  303. package/dist/package-lifecycle/index.d.ts.map +1 -0
  304. package/dist/package-lifecycle/index.js +2 -0
  305. package/dist/package-lifecycle/index.js.map +1 -0
  306. package/dist/package-lifecycle/manifest.d.ts +24 -0
  307. package/dist/package-lifecycle/manifest.d.ts.map +1 -0
  308. package/dist/package-lifecycle/manifest.js +81 -0
  309. package/dist/package-lifecycle/manifest.js.map +1 -0
  310. package/dist/progress/routes.d.ts +1 -1
  311. package/dist/provider-api/custom-registry.d.ts +32 -1
  312. package/dist/provider-api/custom-registry.d.ts.map +1 -1
  313. package/dist/provider-api/custom-registry.js +41 -1
  314. package/dist/provider-api/custom-registry.js.map +1 -1
  315. package/dist/provider-api/index.d.ts +1 -1
  316. package/dist/provider-api/index.d.ts.map +1 -1
  317. package/dist/provider-api/index.js +1 -1
  318. package/dist/provider-api/index.js.map +1 -1
  319. package/dist/secrets/storage.d.ts.map +1 -1
  320. package/dist/secrets/storage.js +45 -27
  321. package/dist/secrets/storage.js.map +1 -1
  322. package/dist/server/action-discovery.d.ts.map +1 -1
  323. package/dist/server/action-discovery.js +4 -0
  324. package/dist/server/action-discovery.js.map +1 -1
  325. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  326. package/dist/server/agent-chat-plugin.js +47 -13
  327. package/dist/server/agent-chat-plugin.js.map +1 -1
  328. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  329. package/dist/server/core-routes-plugin.js +23 -12
  330. package/dist/server/core-routes-plugin.js.map +1 -1
  331. package/dist/server/csrf.d.ts.map +1 -1
  332. package/dist/server/csrf.js +18 -5
  333. package/dist/server/csrf.js.map +1 -1
  334. package/dist/server/framework-request-handler.d.ts.map +1 -1
  335. package/dist/server/framework-request-handler.js +34 -0
  336. package/dist/server/framework-request-handler.js.map +1 -1
  337. package/dist/server/google-realtime-session.d.ts.map +1 -1
  338. package/dist/server/google-realtime-session.js +2 -34
  339. package/dist/server/google-realtime-session.js.map +1 -1
  340. package/dist/server/poll.d.ts.map +1 -1
  341. package/dist/server/poll.js +24 -2
  342. package/dist/server/poll.js.map +1 -1
  343. package/dist/server/realtime-voice.d.ts.map +1 -1
  344. package/dist/server/realtime-voice.js +9 -0
  345. package/dist/server/realtime-voice.js.map +1 -1
  346. package/dist/server/request-origin.d.ts +10 -0
  347. package/dist/server/request-origin.d.ts.map +1 -0
  348. package/dist/server/request-origin.js +60 -0
  349. package/dist/server/request-origin.js.map +1 -0
  350. package/dist/server/transcribe-voice.d.ts.map +1 -1
  351. package/dist/server/transcribe-voice.js +2 -48
  352. package/dist/server/transcribe-voice.js.map +1 -1
  353. package/dist/templates/default/package.json +2 -2
  354. package/dist/templates/headless/package.json +0 -1
  355. package/dist/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
  356. package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
  357. package/dist/templates/workspace-core/package.json +0 -1
  358. package/dist/templates/workspace-root/package.json +0 -1
  359. package/dist/triggers/actions.d.ts.map +1 -1
  360. package/dist/triggers/actions.js +8 -3
  361. package/dist/triggers/actions.js.map +1 -1
  362. package/dist/triggers/types.d.ts +7 -1
  363. package/dist/triggers/types.d.ts.map +1 -1
  364. package/dist/triggers/types.js.map +1 -1
  365. package/docs/content/audit-log.mdx +2 -1
  366. package/docs/content/automations.mdx +7 -7
  367. package/docs/content/creating-templates.mdx +1 -1
  368. package/docs/content/internationalization.mdx +2 -1
  369. package/docs/content/locales/ar-SA/audit-log.mdx +2 -1
  370. package/docs/content/locales/ar-SA/automations.mdx +7 -7
  371. package/docs/content/locales/ar-SA/getting-started.mdx +7 -1
  372. package/docs/content/locales/ar-SA/internationalization.mdx +1 -1
  373. package/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
  374. package/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
  375. package/docs/content/locales/ar-SA/security.mdx +8 -0
  376. package/docs/content/locales/de-DE/audit-log.mdx +2 -1
  377. package/docs/content/locales/de-DE/automations.mdx +7 -7
  378. package/docs/content/locales/de-DE/getting-started.mdx +7 -1
  379. package/docs/content/locales/de-DE/internationalization.mdx +1 -1
  380. package/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
  381. package/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
  382. package/docs/content/locales/de-DE/security.mdx +8 -0
  383. package/docs/content/locales/es-ES/audit-log.mdx +2 -1
  384. package/docs/content/locales/es-ES/automations.mdx +7 -7
  385. package/docs/content/locales/es-ES/getting-started.mdx +7 -1
  386. package/docs/content/locales/es-ES/internationalization.mdx +1 -1
  387. package/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
  388. package/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
  389. package/docs/content/locales/es-ES/security.mdx +8 -0
  390. package/docs/content/locales/fr-FR/audit-log.mdx +2 -1
  391. package/docs/content/locales/fr-FR/automations.mdx +7 -7
  392. package/docs/content/locales/fr-FR/getting-started.mdx +7 -1
  393. package/docs/content/locales/fr-FR/internationalization.mdx +1 -1
  394. package/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
  395. package/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
  396. package/docs/content/locales/fr-FR/security.mdx +8 -0
  397. package/docs/content/locales/hi-IN/audit-log.mdx +2 -1
  398. package/docs/content/locales/hi-IN/automations.mdx +7 -7
  399. package/docs/content/locales/hi-IN/getting-started.mdx +7 -1
  400. package/docs/content/locales/hi-IN/internationalization.mdx +1 -1
  401. package/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
  402. package/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
  403. package/docs/content/locales/hi-IN/security.mdx +8 -0
  404. package/docs/content/locales/ja-JP/audit-log.mdx +2 -1
  405. package/docs/content/locales/ja-JP/automations.mdx +7 -7
  406. package/docs/content/locales/ja-JP/getting-started.mdx +7 -1
  407. package/docs/content/locales/ja-JP/internationalization.mdx +1 -1
  408. package/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
  409. package/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
  410. package/docs/content/locales/ja-JP/security.mdx +8 -0
  411. package/docs/content/locales/ko-KR/audit-log.mdx +2 -1
  412. package/docs/content/locales/ko-KR/automations.mdx +7 -7
  413. package/docs/content/locales/ko-KR/getting-started.mdx +7 -1
  414. package/docs/content/locales/ko-KR/internationalization.mdx +1 -1
  415. package/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
  416. package/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
  417. package/docs/content/locales/ko-KR/security.mdx +8 -0
  418. package/docs/content/locales/pt-BR/audit-log.mdx +2 -1
  419. package/docs/content/locales/pt-BR/automations.mdx +7 -7
  420. package/docs/content/locales/pt-BR/getting-started.mdx +7 -1
  421. package/docs/content/locales/pt-BR/internationalization.mdx +1 -1
  422. package/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
  423. package/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
  424. package/docs/content/locales/pt-BR/security.mdx +8 -0
  425. package/docs/content/locales/zh-CN/audit-log.mdx +2 -1
  426. package/docs/content/locales/zh-CN/automations.mdx +7 -7
  427. package/docs/content/locales/zh-CN/getting-started.mdx +6 -4
  428. package/docs/content/locales/zh-CN/internationalization.mdx +1 -1
  429. package/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
  430. package/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
  431. package/docs/content/locales/zh-CN/security.mdx +8 -0
  432. package/docs/content/locales/zh-TW/audit-log.mdx +2 -1
  433. package/docs/content/locales/zh-TW/automations.mdx +7 -7
  434. package/docs/content/locales/zh-TW/getting-started.mdx +6 -4
  435. package/docs/content/locales/zh-TW/internationalization.mdx +1 -1
  436. package/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
  437. package/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
  438. package/docs/content/locales/zh-TW/security.mdx +8 -0
  439. package/docs/content/package-lifecycle.mdx +51 -0
  440. package/docs/content/sandbox-adapters.mdx +16 -5
  441. package/package.json +10 -3
  442. package/src/templates/default/package.json +2 -2
  443. package/src/templates/headless/package.json +0 -1
  444. package/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
  445. package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
  446. package/src/templates/workspace-core/package.json +0 -1
  447. package/src/templates/workspace-root/package.json +0 -1
  448. package/corpus/templates/slides/app/components/ui/toast.tsx +0 -1
  449. package/corpus/templates/slides/app/components/ui/toaster.tsx +0 -1
  450. package/corpus/templates/slides/app/hooks/use-toast.ts +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-env-credentials.js","sourceRoot":"","sources":["../../src/guards/no-env-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,IAAI,GACL,MAAM,iBAAiB,CAAC;AAGzB,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,cAAc;IACd,qBAAqB;IACrB,UAAU;IACV,IAAI;IACJ,OAAO;IACP,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,cAAc;IACd,WAAW;IACX,0BAA0B;IAC1B,oBAAoB;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,sBAAsB;IACtB,qBAAqB;IACrB,0BAA0B;IAC1B,8BAA8B;IAC9B,aAAa;IACb,YAAY;IACZ,cAAc;IACd,MAAM;IACN,MAAM;IACN,wBAAwB;CACzB,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG;IACvB,MAAM;IACN,eAAe;IACf,QAAQ;IACR,UAAU;IACV,SAAS;IACT,KAAK;CACN,CAAC;AAEF;;;oDAGoD;AACpD,MAAM,sBAAsB,GAAG;IAC7B,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;CACb,CAAC;AAEF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAErD,MAAM,cAAc,GAAG,2CAA2C,CAAC;AACnE,MAAM,uBAAuB,GAAG,+CAA+C,CAAC;AAEhF,MAAM,cAAc,GAClB,0EAA0E,CAAC;AAE7E,MAAM,sBAAsB,GAC1B,wDAAwD,CAAC;AAE3D,SAAS,gBAAgB,CAAC,GAAW;IACnC,IAAI,eAAe,CAAC,GAAG,CAAC,GAAG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,EAAE,CAAC;YAC5D,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;YACrD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC;YACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;YACrC,IACE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;gBACvB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;gBACxB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EACxB,CAAC;gBACD,SAAS;YACX,CAAC;YACD,IAAI,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;gBACpC,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;gBACtE,IAAI,OAAO,CAAC,EAAE;oBAAE,SAAS;gBACzB,QAAQ,CAAC,IAAI,CAAC;oBACZ,IAAI,EAAE,GAAG;oBACT,IAAI;oBACJ,OAAO,EAAE,2CAA2C,OAAO,CAAC,GAAG,EAAE;iBAClE,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,GAAG;gBACT,IAAI;gBACJ,OAAO,EAAE,iFAAiF;aAC3F,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,CAAC;AAClD,CAAC","sourcesContent":["/**\n * scanEnvCredentials — ported from `scripts/guard-no-env-credentials.mjs`.\n *\n * User credentials are per-user (or per-org) data. They MUST live in SQL,\n * scoped by `userEmail` / `orgId`, never in `process.env` — a deployment's\n * env vars are shared by every signed-in user. This guard flags any\n * `process.env.<KEY>` / `process.env[\"KEY\"]` read whose key is not on the\n * deploy-level allowlist (`DATABASE_URL`, `BETTER_AUTH_SECRET`, etc.), plus\n * any dynamic `process.env[key]` read (the key is only known at runtime, so\n * it can never be allowlisted safely).\n *\n * Conditional guard — per report 005's V1 guard set table, this is \"the big\n * one\": the original only scans a curated set of monorepo subtrees\n * (`packages/core/src/{credentials,secrets,vault,agent}/`, template\n * credential libs/routes) via `FORBIDDEN_PATH_PREDICATES` — none of which\n * exist in a generated app, so nothing would ever be scanned. This port\n * replaces that default-allow-outside-a-curated-subtree behavior with\n * default-deny across the whole app source tree: every `process.env.<KEY>`\n * read anywhere in app source must be on the deploy-var allowlist (kept\n * verbatim) or carry the opt-out marker. `HIGH_RISK_ENV_KEY_ALLOWLIST`,\n * `HIGH_RISK_PROCESS_ENV_ALLOWLIST`, and `HIGH_RISK_ENV_VARS_WRITE_ALLOWLIST`\n * — the three monorepo-file-keyed exception maps for specific template\n * platform-adapter files — are dropped entirely per the report; with\n * default-deny scanning already covering every `process.env` read\n * everywhere, the narrower `env-config.ts`/`core-routes.ts`-specific\n * registration checks those maps supported become redundant (any\n * high-risk key would already be caught by the general scan) and are\n * dropped along with them. The per-line `// guard:allow-env-credential`\n * marker remains the only escape hatch.\n *\n * Opt-out (same line, or the line immediately above):\n * process.env.SOMETHING // guard:allow-env-credential — short reason\n */\n\nimport {\n lineColForOffset,\n readFileSafe,\n relPosix,\n walk,\n} from \"./scan-utils.js\";\nimport type { GuardFinding, GuardResult, GuardScanOptions } from \"./types.js\";\n\nconst ALLOWLIST_EXACT = new Set([\n \"DATABASE_URL\",\n \"DATABASE_AUTH_TOKEN\",\n \"NODE_ENV\",\n \"CI\",\n \"DEBUG\",\n \"NETLIFY\",\n \"VERCEL\",\n \"RENDER\",\n \"FLY_APP_NAME\",\n \"K_SERVICE\",\n \"AWS_LAMBDA_FUNCTION_NAME\",\n \"BETTER_AUTH_SECRET\",\n \"BETTER_AUTH_URL\",\n \"NOTION_CLIENT_ID\",\n \"NOTION_CLIENT_SECRET\",\n \"NOTION_STATE_SECRET\",\n \"GOOGLE_SIGN_IN_CLIENT_ID\",\n \"GOOGLE_SIGN_IN_CLIENT_SECRET\",\n \"AUTH_SECRET\",\n \"A2A_SECRET\",\n \"ACCESS_TOKEN\",\n \"PORT\",\n \"HOST\",\n \"SECRETS_ENCRYPTION_KEY\",\n]);\n\nconst ALLOWLIST_PREFIX = [\n \"npm_\",\n \"AGENT_NATIVE_\",\n \"AGENT_\",\n \"NETLIFY_\",\n \"VERCEL_\",\n \"CF_\",\n];\n\n/** Dev-only paths where ANTHROPIC_API_KEY etc. may legitimately be read\n * from env (local dev tooling, scripts, tests). Portable subset of the\n * original — the monorepo-only `packages/core/src/dev` predicate is\n * dropped (see report 005's V1 guard set table). */\nconst DEV_ONLY_PATH_PATTERNS = [\n /\\.spec\\.[tj]sx?$/,\n /\\.test\\.[tj]sx?$/,\n /^scripts\\//,\n];\n\nconst DEV_ONLY_KEYS = new Set([\"ANTHROPIC_API_KEY\"]);\n\nconst OPT_OUT_MARKER = /\\/\\/\\s*guard:allow-env-credential\\b[^\\n]*/;\nconst OPT_OUT_REQUIRES_REASON = /\\/\\/\\s*guard:allow-env-credential\\s*[—-]\\s*\\S/;\n\nconst ENV_READ_REGEX =\n /process\\.env(?:\\.([A-Z][A-Z0-9_]*)|\\[\\s*[\"']([A-Z][A-Z0-9_]*)[\"']\\s*\\])/g;\n\nconst ENV_DYNAMIC_READ_REGEX =\n /process\\.env(?:\\?\\.)?\\s*\\[\\s*(?![\"'])([^\\]\\n]+?)\\s*\\]/g;\n\nfunction isAllowlistedKey(key: string): boolean {\n if (ALLOWLIST_EXACT.has(key)) return true;\n return ALLOWLIST_PREFIX.some((prefix) => key.startsWith(prefix));\n}\n\nfunction isDevOnlyPath(rel: string): boolean {\n return DEV_ONLY_PATH_PATTERNS.some((re) => re.test(rel));\n}\n\nfunction hasOptOutOnLine(lines: string[], lineIdx: number): boolean {\n const cur = lines[lineIdx] ?? \"\";\n if (OPT_OUT_MARKER.test(cur)) return true;\n const prev = lines[lineIdx - 1] ?? \"\";\n if (/^\\s*\\/\\//.test(prev) && OPT_OUT_MARKER.test(prev)) return true;\n return false;\n}\n\nfunction optOutOnLineIsValid(\n lines: string[],\n lineIdx: number,\n key: string,\n rel: string,\n): { ok: boolean; why?: string } {\n const cur = lines[lineIdx] ?? \"\";\n const prev = lines[lineIdx - 1] ?? \"\";\n const candidate = OPT_OUT_REQUIRES_REASON.test(cur)\n ? cur\n : OPT_OUT_REQUIRES_REASON.test(prev)\n ? prev\n : null;\n if (!candidate) return { ok: false, why: \"missing or empty reason\" };\n\n if (/dev-only\\b/i.test(candidate)) {\n if (!DEV_ONLY_KEYS.has(key)) {\n return {\n ok: false,\n why: `key \"${key}\" is not in the dev-only credential allowlist`,\n };\n }\n if (!isDevOnlyPath(rel)) {\n return {\n ok: false,\n why: \"dev-only opt-out used outside dev / scripts / test paths\",\n };\n }\n }\n return { ok: true };\n}\n\nexport function scanEnvCredentials(options: GuardScanOptions): GuardResult {\n const { root } = options;\n const findings: GuardFinding[] = [];\n\n for (const file of walk(root)) {\n if (!/\\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(file)) continue;\n if (file.endsWith(\".d.ts\")) continue;\n const rel = relPosix(root, file);\n\n const contents = readFileSafe(file);\n if (contents === null || !contents.includes(\"process.env\")) continue;\n\n const lines = contents.split(\"\\n\");\n\n ENV_READ_REGEX.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = ENV_READ_REGEX.exec(contents)) !== null) {\n const key = m[1] ?? m[2];\n if (!key) continue;\n const { line } = lineColForOffset(contents, m.index);\n const lineIdx = line - 1;\n const lineText = lines[lineIdx] ?? \"\";\n const trimmed = lineText.trimStart();\n if (\n trimmed.startsWith(\"*\") ||\n trimmed.startsWith(\"//\") ||\n trimmed.startsWith(\"/*\")\n ) {\n continue;\n }\n if (isAllowlistedKey(key)) continue;\n if (hasOptOutOnLine(lines, lineIdx)) {\n const verdict = optOutOnLineIsValid(lines, lineIdx, key, rel);\n if (verdict.ok) continue;\n findings.push({\n file: rel,\n line,\n message: `process.env.${key} opt-out invalid: ${verdict.why}`,\n });\n continue;\n }\n findings.push({\n file: rel,\n line,\n message: `process.env.${key} read — not a deploy-level allowlisted key. User credentials must be read via resolveCredential(key, { userEmail, orgId }), never process.env.`,\n });\n }\n\n ENV_DYNAMIC_READ_REGEX.lastIndex = 0;\n while ((m = ENV_DYNAMIC_READ_REGEX.exec(contents)) !== null) {\n const { line } = lineColForOffset(contents, m.index);\n const lineIdx = line - 1;\n const lineText = lines[lineIdx] ?? \"\";\n const trimmed = lineText.trimStart();\n if (\n trimmed.startsWith(\"*\") ||\n trimmed.startsWith(\"//\") ||\n trimmed.startsWith(\"/*\")\n ) {\n continue;\n }\n if (hasOptOutOnLine(lines, lineIdx)) {\n const verdict = optOutOnLineIsValid(lines, lineIdx, \"<dynamic>\", rel);\n if (verdict.ok) continue;\n findings.push({\n file: rel,\n line,\n message: `process.env[<dynamic>] opt-out invalid: ${verdict.why}`,\n });\n continue;\n }\n findings.push({\n file: rel,\n line,\n message: `process.env[<dynamic key>] read — dynamic keys can never be allowlisted safely.`,\n });\n }\n }\n\n return { name: \"no-env-credentials\", findings };\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * scanEnvMutation — ported from `scripts/guard-no-env-mutation.mjs`.
3
+ *
4
+ * Refuse to let production code MUTATE `process.env` (e.g.
5
+ * `process.env.AGENT_USER_EMAIL = userEmail`). `process.env` is
6
+ * process-scoped, not request-scoped — on serverless, every warm container
7
+ * handles many concurrent requests in one Node process, so mutating
8
+ * `process.env` in a request handler leaks state across requests. Use
9
+ * `runWithRequestContext` instead.
10
+ *
11
+ * Conditional guard — per report 005's V1 guard set table: the original
12
+ * has 9 `ALLOWED_PATH_PREDICATES`; 4 are monorepo-only
13
+ * (`packages/core/src/dev`, `templates/*\/test(s)/`, `packages/cli/`,
14
+ * `packages/create-agent-native/`) and dropped here. The 5 portable ones
15
+ * (`scripts/**`, `*.spec.*`, `*.test.*`, `/cli/`, `/scaffold/`) are kept
16
+ * verbatim — they already work unmodified for a generated app.
17
+ *
18
+ * Opt-out (same line, or the line immediately above):
19
+ * process.env.X = y // guard:allow-env-mutation — short reason
20
+ */
21
+ import type { GuardResult, GuardScanOptions } from "./types.js";
22
+ export declare function scanEnvMutation(options: GuardScanOptions): GuardResult;
23
+ //# sourceMappingURL=no-env-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-env-mutation.d.ts","sourceRoot":"","sources":["../../src/guards/no-env-mutation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,OAAO,KAAK,EAAgB,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA+C9E,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW,CAsCtE"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * scanEnvMutation — ported from `scripts/guard-no-env-mutation.mjs`.
3
+ *
4
+ * Refuse to let production code MUTATE `process.env` (e.g.
5
+ * `process.env.AGENT_USER_EMAIL = userEmail`). `process.env` is
6
+ * process-scoped, not request-scoped — on serverless, every warm container
7
+ * handles many concurrent requests in one Node process, so mutating
8
+ * `process.env` in a request handler leaks state across requests. Use
9
+ * `runWithRequestContext` instead.
10
+ *
11
+ * Conditional guard — per report 005's V1 guard set table: the original
12
+ * has 9 `ALLOWED_PATH_PREDICATES`; 4 are monorepo-only
13
+ * (`packages/core/src/dev`, `templates/*\/test(s)/`, `packages/cli/`,
14
+ * `packages/create-agent-native/`) and dropped here. The 5 portable ones
15
+ * (`scripts/**`, `*.spec.*`, `*.test.*`, `/cli/`, `/scaffold/`) are kept
16
+ * verbatim — they already work unmodified for a generated app.
17
+ *
18
+ * Opt-out (same line, or the line immediately above):
19
+ * process.env.X = y // guard:allow-env-mutation — short reason
20
+ */
21
+ import { isCommentLine, lineColForOffset, readFileSafe, relPosix, walk, } from "./scan-utils.js";
22
+ const ALLOWED_PATH_PREDICATES = [
23
+ (rel) => /^scripts\//.test(rel),
24
+ (rel) => /\.spec\.[tj]sx?$/.test(rel),
25
+ (rel) => /\.test\.[tj]sx?$/.test(rel),
26
+ (rel) => /\/cli\//.test(rel),
27
+ (rel) => /\/scaffold\//.test(rel),
28
+ ];
29
+ const OPT_OUT_MARKER = /\/\/\s*guard:allow-env-mutation\b[^\n]*/;
30
+ const OPT_OUT_REQUIRES_REASON = /\/\/\s*guard:allow-env-mutation\s*[—-]\s*\S/;
31
+ const ASSIGN_TAIL = String.raw `(?:\s*(?:=(?!=)|\+=|-=|\*=|/=|\?\?=|\|\|=|&&=))`;
32
+ const MEMBER_FORM = new RegExp(String.raw `process\.env\.[A-Z_][A-Z0-9_]*${ASSIGN_TAIL}`, "g");
33
+ const BRACKET_FORM = new RegExp(String.raw `process\.env\[\s*["'][A-Z_][A-Z0-9_]+["']\s*\]${ASSIGN_TAIL}`, "g");
34
+ const DELETE_MEMBER_FORM = new RegExp(String.raw `\bdelete\s+process\.env\.[A-Z_][A-Z0-9_]*\b`, "g");
35
+ const DELETE_BRACKET_FORM = new RegExp(String.raw `\bdelete\s+process\.env\[\s*["'][A-Z_][A-Z0-9_]+["']\s*\]`, "g");
36
+ function isAllowedPath(rel) {
37
+ return ALLOWED_PATH_PREDICATES.some((p) => p(rel));
38
+ }
39
+ function hasValidOptOut(lines, lineIdx) {
40
+ const cur = lines[lineIdx] ?? "";
41
+ if (OPT_OUT_MARKER.test(cur)) {
42
+ return OPT_OUT_REQUIRES_REASON.test(cur);
43
+ }
44
+ const prev = lines[lineIdx - 1] ?? "";
45
+ if (/^\s*\/\//.test(prev) && OPT_OUT_MARKER.test(prev)) {
46
+ return OPT_OUT_REQUIRES_REASON.test(prev);
47
+ }
48
+ return false;
49
+ }
50
+ export function scanEnvMutation(options) {
51
+ const { root } = options;
52
+ const findings = [];
53
+ for (const file of walk(root)) {
54
+ if (!/\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(file))
55
+ continue;
56
+ if (file.endsWith(".d.ts"))
57
+ continue;
58
+ const rel = relPosix(root, file);
59
+ if (isAllowedPath(rel))
60
+ continue;
61
+ const contents = readFileSafe(file);
62
+ if (contents === null || !contents.includes("process.env"))
63
+ continue;
64
+ const lines = contents.split("\n");
65
+ for (const re of [
66
+ MEMBER_FORM,
67
+ BRACKET_FORM,
68
+ DELETE_MEMBER_FORM,
69
+ DELETE_BRACKET_FORM,
70
+ ]) {
71
+ re.lastIndex = 0;
72
+ let m;
73
+ while ((m = re.exec(contents)) !== null) {
74
+ const { line } = lineColForOffset(contents, m.index);
75
+ const lineText = lines[line - 1] ?? "";
76
+ if (isCommentLine(lineText))
77
+ continue;
78
+ if (hasValidOptOut(lines, line - 1))
79
+ continue;
80
+ findings.push({
81
+ file: rel,
82
+ line,
83
+ message: `process.env mutated in production code: ${lineText.trim()}. process.env is process-scoped, not request-scoped — use runWithRequestContext instead.`,
84
+ });
85
+ }
86
+ }
87
+ }
88
+ return { name: "no-env-mutation", findings };
89
+ }
90
+ //# sourceMappingURL=no-env-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-env-mutation.js","sourceRoot":"","sources":["../../src/guards/no-env-mutation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,IAAI,GACL,MAAM,iBAAiB,CAAC;AAGzB,MAAM,uBAAuB,GAAoC;IAC/D,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;IAC/B,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC;IACrC,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC;IACrC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;IAC5B,CAAC,GAAG,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c,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC;oBAAE,SAAS;gBAC9C,QAAQ,CAAC,IAAI,CAAC;oBACZ,IAAI,EAAE,GAAG;oBACT,IAAI;oBACJ,OAAO,EAAE,2CAA2C,QAAQ,CAAC,IAAI,EAAE,0FAA0F;iBAC9J,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC;AAC/C,CAAC","sourcesContent":["/**\n * scanEnvMutation — ported from `scripts/guard-no-env-mutation.mjs`.\n *\n * Refuse to let production code MUTATE `process.env` (e.g.\n * `process.env.AGENT_USER_EMAIL = userEmail`). `process.env` is\n * process-scoped, not request-scoped — on serverless, every warm container\n * handles many concurrent requests in one Node process, so mutating\n * `process.env` in a request handler leaks state across requests. Use\n * `runWithRequestContext` instead.\n *\n * Conditional guard — per report 005's V1 guard set table: the original\n * has 9 `ALLOWED_PATH_PREDICATES`; 4 are monorepo-only\n * (`packages/core/src/dev`, `templates/*\\/test(s)/`, `packages/cli/`,\n * `packages/create-agent-native/`) and dropped here. The 5 portable ones\n * (`scripts/**`, `*.spec.*`, `*.test.*`, `/cli/`, `/scaffold/`) are kept\n * verbatim — they already work unmodified for a generated app.\n *\n * Opt-out (same line, or the line immediately above):\n * process.env.X = y // guard:allow-env-mutation — short reason\n */\n\nimport {\n isCommentLine,\n lineColForOffset,\n readFileSafe,\n relPosix,\n walk,\n} from \"./scan-utils.js\";\nimport type { GuardFinding, GuardResult, GuardScanOptions } from \"./types.js\";\n\nconst ALLOWED_PATH_PREDICATES: Array<(rel: string) => boolean> = [\n (rel) => /^scripts\\//.test(rel),\n (rel) => /\\.spec\\.[tj]sx?$/.test(rel),\n (rel) => /\\.test\\.[tj]sx?$/.test(rel),\n (rel) => /\\/cli\\//.test(rel),\n (rel) => /\\/scaffold\\//.test(rel),\n];\n\nconst OPT_OUT_MARKER = /\\/\\/\\s*guard:allow-env-mutation\\b[^\\n]*/;\nconst OPT_OUT_REQUIRES_REASON = /\\/\\/\\s*guard:allow-env-mutation\\s*[—-]\\s*\\S/;\n\nconst ASSIGN_TAIL = String.raw`(?:\\s*(?:=(?!=)|\\+=|-=|\\*=|/=|\\?\\?=|\\|\\|=|&&=))`;\nconst MEMBER_FORM = new RegExp(\n String.raw`process\\.env\\.[A-Z_][A-Z0-9_]*${ASSIGN_TAIL}`,\n \"g\",\n);\nconst BRACKET_FORM = new RegExp(\n String.raw`process\\.env\\[\\s*[\"'][A-Z_][A-Z0-9_]+[\"']\\s*\\]${ASSIGN_TAIL}`,\n \"g\",\n);\nconst DELETE_MEMBER_FORM = new RegExp(\n String.raw`\\bdelete\\s+process\\.env\\.[A-Z_][A-Z0-9_]*\\b`,\n \"g\",\n);\nconst DELETE_BRACKET_FORM = new RegExp(\n String.raw`\\bdelete\\s+process\\.env\\[\\s*[\"'][A-Z_][A-Z0-9_]+[\"']\\s*\\]`,\n \"g\",\n);\n\nfunction isAllowedPath(rel: string): boolean {\n return ALLOWED_PATH_PREDICATES.some((p) => p(rel));\n}\n\nfunction hasValidOptOut(lines: string[], lineIdx: number): boolean {\n const cur = lines[lineIdx] ?? \"\";\n if (OPT_OUT_MARKER.test(cur)) {\n return OPT_OUT_REQUIRES_REASON.test(cur);\n }\n const prev = lines[lineIdx - 1] ?? \"\";\n if (/^\\s*\\/\\//.test(prev) && OPT_OUT_MARKER.test(prev)) {\n return OPT_OUT_REQUIRES_REASON.test(prev);\n }\n return false;\n}\n\nexport function scanEnvMutation(options: GuardScanOptions): GuardResult {\n const { root } = options;\n const findings: GuardFinding[] = [];\n\n for (const file of walk(root)) {\n if (!/\\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(file)) continue;\n if (file.endsWith(\".d.ts\")) continue;\n const rel = relPosix(root, file);\n if (isAllowedPath(rel)) continue;\n\n const contents = readFileSafe(file);\n if (contents === null || !contents.includes(\"process.env\")) continue;\n\n const lines = contents.split(\"\\n\");\n\n for (const re of [\n MEMBER_FORM,\n BRACKET_FORM,\n DELETE_MEMBER_FORM,\n DELETE_BRACKET_FORM,\n ]) {\n re.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = re.exec(contents)) !== null) {\n const { line } = lineColForOffset(contents, m.index);\n const lineText = lines[line - 1] ?? \"\";\n if (isCommentLine(lineText)) continue;\n if (hasValidOptOut(lines, line - 1)) continue;\n findings.push({\n file: rel,\n line,\n message: `process.env mutated in production code: ${lineText.trim()}. process.env is process-scoped, not request-scoped — use runWithRequestContext instead.`,\n });\n }\n }\n }\n\n return { name: \"no-env-mutation\", findings };\n}\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * scanLocalhostFallback — ported from
3
+ * `scripts/guard-no-localhost-fallback.mjs`.
4
+ *
5
+ * Refuse to let production code use the literal `local@localhost` (or the
6
+ * `DEV_MODE_USER_EMAIL` symbolic alias) as a fallback identity when no
7
+ * session is present — that pools every unauthenticated request onto one
8
+ * shared tenant. The right behavior in production is to throw/401 when
9
+ * there's no session, not fall back to a sentinel identity.
10
+ *
11
+ * Conditional guard — per report 005's V1 guard set table: the original
12
+ * hardcodes framework-file exemptions (`packages/core/src/server/auth.ts`,
13
+ * `packages/core/src/org/context.ts`, etc. — files that either define or
14
+ * intentionally handle the dev-mode sentinel). Those live in `node_modules`
15
+ * for a generated app and are already excluded by `SKIP_DIRS`, so they're
16
+ * moved behind an optional `extraExemptPaths` param (default `[]`) instead
17
+ * of hardcoded. The generic allowlist predicates (`*.spec.*`, `*.test.*`,
18
+ * `scripts/**`, `**\/seed(s)/**`) are kept verbatim.
19
+ *
20
+ * Opt-out (same line, or the line immediately above):
21
+ * const x = email ?? "local@localhost" // guard:allow-localhost-fallback — short reason
22
+ */
23
+ import type { GuardResult, GuardScanOptions } from "./types.js";
24
+ export interface LocalhostFallbackOptions extends GuardScanOptions {
25
+ /** Exact repo-relative paths to exempt in addition to the generic
26
+ * predicates (spec/test/scripts/seed). Default `[]`. */
27
+ extraExemptPaths?: string[];
28
+ }
29
+ export declare function scanLocalhostFallback(options: LocalhostFallbackOptions): GuardResult;
30
+ //# sourceMappingURL=no-localhost-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-localhost-fallback.d.ts","sourceRoot":"","sources":["../../src/guards/no-localhost-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH,OAAO,KAAK,EAAgB,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9E,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE;4DACwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAsCD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,wBAAwB,GAChC,WAAW,CA+Cb"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * scanLocalhostFallback — ported from
3
+ * `scripts/guard-no-localhost-fallback.mjs`.
4
+ *
5
+ * Refuse to let production code use the literal `local@localhost` (or the
6
+ * `DEV_MODE_USER_EMAIL` symbolic alias) as a fallback identity when no
7
+ * session is present — that pools every unauthenticated request onto one
8
+ * shared tenant. The right behavior in production is to throw/401 when
9
+ * there's no session, not fall back to a sentinel identity.
10
+ *
11
+ * Conditional guard — per report 005's V1 guard set table: the original
12
+ * hardcodes framework-file exemptions (`packages/core/src/server/auth.ts`,
13
+ * `packages/core/src/org/context.ts`, etc. — files that either define or
14
+ * intentionally handle the dev-mode sentinel). Those live in `node_modules`
15
+ * for a generated app and are already excluded by `SKIP_DIRS`, so they're
16
+ * moved behind an optional `extraExemptPaths` param (default `[]`) instead
17
+ * of hardcoded. The generic allowlist predicates (`*.spec.*`, `*.test.*`,
18
+ * `scripts/**`, `**\/seed(s)/**`) are kept verbatim.
19
+ *
20
+ * Opt-out (same line, or the line immediately above):
21
+ * const x = email ?? "local@localhost" // guard:allow-localhost-fallback — short reason
22
+ */
23
+ import { isCommentLine, lineColForOffset, readFileSafe, relPosix, walk, } from "./scan-utils.js";
24
+ const GENERIC_ALLOWED_PATH_PREDICATES = [
25
+ (rel) => /\.spec\.[tj]sx?$/.test(rel),
26
+ (rel) => /\.test\.[tj]sx?$/.test(rel),
27
+ (rel) => /^scripts\//.test(rel),
28
+ (rel) => /\/seed\//.test(rel),
29
+ (rel) => /\/seeds\//.test(rel),
30
+ ];
31
+ const OPT_OUT_MARKER = /\/\/\s*guard:allow-localhost-fallback\b[^\n]*/;
32
+ const OPT_OUT_REQUIRES_REASON = /\/\/\s*guard:allow-localhost-fallback\s*[—-]\s*\S/;
33
+ const LITERAL_RE = /(?:"local@localhost"|'local@localhost'|`local@localhost`)/g;
34
+ const SYMBOLIC_FALLBACK_RE = /(?:\?\?|\|\|)\s*DEV_MODE_USER_EMAIL\b/g;
35
+ const SQL_DEFAULT_RE = /\bDEFAULT\s+['"`]local@localhost['"`]/i;
36
+ const DRIZZLE_DEFAULT_RE = /\.default\s*\(\s*['"`]local@localhost['"`]\s*\)/;
37
+ function isAllowedPath(rel, extraExemptPaths) {
38
+ if (extraExemptPaths?.includes(rel))
39
+ return true;
40
+ return GENERIC_ALLOWED_PATH_PREDICATES.some((p) => p(rel));
41
+ }
42
+ function hasValidOptOut(lines, lineIdx) {
43
+ const cur = lines[lineIdx] ?? "";
44
+ if (OPT_OUT_MARKER.test(cur)) {
45
+ return OPT_OUT_REQUIRES_REASON.test(cur);
46
+ }
47
+ const prev = lines[lineIdx - 1] ?? "";
48
+ if (/^\s*\/\//.test(prev) && OPT_OUT_MARKER.test(prev)) {
49
+ return OPT_OUT_REQUIRES_REASON.test(prev);
50
+ }
51
+ return false;
52
+ }
53
+ export function scanLocalhostFallback(options) {
54
+ const { root, extraExemptPaths } = options;
55
+ const findings = [];
56
+ for (const file of walk(root)) {
57
+ if (!/\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(file))
58
+ continue;
59
+ if (file.endsWith(".d.ts"))
60
+ continue;
61
+ const rel = relPosix(root, file);
62
+ if (isAllowedPath(rel, extraExemptPaths))
63
+ continue;
64
+ const contents = readFileSafe(file);
65
+ if (contents === null || !contents.includes("local@localhost"))
66
+ continue;
67
+ const lines = contents.split("\n");
68
+ LITERAL_RE.lastIndex = 0;
69
+ let m;
70
+ while ((m = LITERAL_RE.exec(contents)) !== null) {
71
+ const { line } = lineColForOffset(contents, m.index);
72
+ const lineText = lines[line - 1] ?? "";
73
+ if (isCommentLine(lineText))
74
+ continue;
75
+ if (SQL_DEFAULT_RE.test(lineText))
76
+ continue;
77
+ if (DRIZZLE_DEFAULT_RE.test(lineText))
78
+ continue;
79
+ if (hasValidOptOut(lines, line - 1))
80
+ continue;
81
+ findings.push({
82
+ file: rel,
83
+ line,
84
+ message: `"local@localhost" used as a fallback identity: ${lineText.trim()}. Throw/401 on missing session instead — this pools every unauthenticated request onto one shared tenant.`,
85
+ });
86
+ }
87
+ SYMBOLIC_FALLBACK_RE.lastIndex = 0;
88
+ let s;
89
+ while ((s = SYMBOLIC_FALLBACK_RE.exec(contents)) !== null) {
90
+ const { line } = lineColForOffset(contents, s.index);
91
+ const lineText = lines[line - 1] ?? "";
92
+ if (isCommentLine(lineText))
93
+ continue;
94
+ if (hasValidOptOut(lines, line - 1))
95
+ continue;
96
+ findings.push({
97
+ file: rel,
98
+ line,
99
+ message: `DEV_MODE_USER_EMAIL used as a fallback identity: ${lineText.trim()}. Throw/401 on missing session instead.`,
100
+ });
101
+ }
102
+ }
103
+ return { name: "no-localhost-fallback", findings };
104
+ }
105
+ //# sourceMappingURL=no-localhost-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-localhost-fallback.js","sourceRoot":"","sources":["../../src/guards/no-localhost-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,IAAI,GACL,MAAM,iBAAiB,CAAC;AASzB,MAAM,+BAA+B,GAAoC;IACvE,CAAC,GAA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I,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,SAAS;YAC5C,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,SAAS;YAChD,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC;gBAAE,SAAS;YAC9C,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,GAAG;gBACT,IAAI;gBACJ,OAAO,EAAE,kDAAkD,QAAQ,CAAC,IAAI,EAAE,2GAA2G;aACtL,CAAC,CAAC;QACL,CAAC;QAED,oBAAoB,CAAC,SAAS,GAAG,CAAC,CAAC;QACnC,IAAI,CAAyB,CAAC;QAC9B,OAAO,CAAC,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAC1D,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;YACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YACvC,IAAI,aAAa,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACtC,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC;gBAAE,SAAS;YAC9C,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,GAAG;gBACT,IAAI;gBACJ,OAAO,EAAE,oDAAoD,QAAQ,CAAC,IAAI,EAAE,yCAAyC;aACtH,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,QAAQ,EAAE,CAAC;AACrD,CAAC","sourcesContent":["/**\n * scanLocalhostFallback — ported from\n * `scripts/guard-no-localhost-fallback.mjs`.\n *\n * Refuse to let production code use the literal `local@localhost` (or the\n * `DEV_MODE_USER_EMAIL` symbolic alias) as a fallback identity when no\n * session is present — that pools every unauthenticated request onto one\n * shared tenant. The right behavior in production is to throw/401 when\n * there's no session, not fall back to a sentinel identity.\n *\n * Conditional guard — per report 005's V1 guard set table: the original\n * hardcodes framework-file exemptions (`packages/core/src/server/auth.ts`,\n * `packages/core/src/org/context.ts`, etc. — files that either define or\n * intentionally handle the dev-mode sentinel). Those live in `node_modules`\n * for a generated app and are already excluded by `SKIP_DIRS`, so they're\n * moved behind an optional `extraExemptPaths` param (default `[]`) instead\n * of hardcoded. The generic allowlist predicates (`*.spec.*`, `*.test.*`,\n * `scripts/**`, `**\\/seed(s)/**`) are kept verbatim.\n *\n * Opt-out (same line, or the line immediately above):\n * const x = email ?? \"local@localhost\" // guard:allow-localhost-fallback — short reason\n */\n\nimport {\n isCommentLine,\n lineColForOffset,\n readFileSafe,\n relPosix,\n walk,\n} from \"./scan-utils.js\";\nimport type { GuardFinding, GuardResult, GuardScanOptions } from \"./types.js\";\n\nexport interface LocalhostFallbackOptions extends GuardScanOptions {\n /** Exact repo-relative paths to exempt in addition to the generic\n * predicates (spec/test/scripts/seed). Default `[]`. */\n extraExemptPaths?: string[];\n}\n\nconst GENERIC_ALLOWED_PATH_PREDICATES: Array<(rel: string) => boolean> = [\n (rel) => /\\.spec\\.[tj]sx?$/.test(rel),\n (rel) => /\\.test\\.[tj]sx?$/.test(rel),\n (rel) => /^scripts\\//.test(rel),\n (rel) => /\\/seed\\//.test(rel),\n (rel) => /\\/seeds\\//.test(rel),\n];\n\nconst OPT_OUT_MARKER = /\\/\\/\\s*guard:allow-localhost-fallback\\b[^\\n]*/;\nconst OPT_OUT_REQUIRES_REASON =\n /\\/\\/\\s*guard:allow-localhost-fallback\\s*[—-]\\s*\\S/;\n\nconst LITERAL_RE = /(?:\"local@localhost\"|'local@localhost'|`local@localhost`)/g;\n\nconst SYMBOLIC_FALLBACK_RE = /(?:\\?\\?|\\|\\|)\\s*DEV_MODE_USER_EMAIL\\b/g;\n\nconst SQL_DEFAULT_RE = /\\bDEFAULT\\s+['\"`]local@localhost['\"`]/i;\nconst DRIZZLE_DEFAULT_RE = /\\.default\\s*\\(\\s*['\"`]local@localhost['\"`]\\s*\\)/;\n\nfunction isAllowedPath(rel: string, extraExemptPaths?: string[]): boolean {\n if (extraExemptPaths?.includes(rel)) return true;\n return GENERIC_ALLOWED_PATH_PREDICATES.some((p) => p(rel));\n}\n\nfunction hasValidOptOut(lines: string[], lineIdx: number): boolean {\n const cur = lines[lineIdx] ?? \"\";\n if (OPT_OUT_MARKER.test(cur)) {\n return OPT_OUT_REQUIRES_REASON.test(cur);\n }\n const prev = lines[lineIdx - 1] ?? \"\";\n if (/^\\s*\\/\\//.test(prev) && OPT_OUT_MARKER.test(prev)) {\n return OPT_OUT_REQUIRES_REASON.test(prev);\n }\n return false;\n}\n\nexport function scanLocalhostFallback(\n options: LocalhostFallbackOptions,\n): GuardResult {\n const { root, extraExemptPaths } = options;\n const findings: GuardFinding[] = [];\n\n for (const file of walk(root)) {\n if (!/\\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(file)) continue;\n if (file.endsWith(\".d.ts\")) continue;\n const rel = relPosix(root, file);\n if (isAllowedPath(rel, extraExemptPaths)) continue;\n\n const contents = readFileSafe(file);\n if (contents === null || !contents.includes(\"local@localhost\")) continue;\n\n const lines = contents.split(\"\\n\");\n\n LITERAL_RE.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = LITERAL_RE.exec(contents)) !== null) {\n const { line } = lineColForOffset(contents, m.index);\n const lineText = lines[line - 1] ?? \"\";\n if (isCommentLine(lineText)) continue;\n if (SQL_DEFAULT_RE.test(lineText)) continue;\n if (DRIZZLE_DEFAULT_RE.test(lineText)) continue;\n if (hasValidOptOut(lines, line - 1)) continue;\n findings.push({\n file: rel,\n line,\n message: `\"local@localhost\" used as a fallback identity: ${lineText.trim()}. Throw/401 on missing session instead — this pools every unauthenticated request onto one shared tenant.`,\n });\n }\n\n SYMBOLIC_FALLBACK_RE.lastIndex = 0;\n let s: RegExpExecArray | null;\n while ((s = SYMBOLIC_FALLBACK_RE.exec(contents)) !== null) {\n const { line } = lineColForOffset(contents, s.index);\n const lineText = lines[line - 1] ?? \"\";\n if (isCommentLine(lineText)) continue;\n if (hasValidOptOut(lines, line - 1)) continue;\n findings.push({\n file: rel,\n line,\n message: `DEV_MODE_USER_EMAIL used as a fallback identity: ${lineText.trim()}. Throw/401 on missing session instead.`,\n });\n }\n }\n\n return { name: \"no-localhost-fallback\", findings };\n}\n"]}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * scanUnscopedCredentials — ported from
3
+ * `scripts/guard-no-unscoped-credentials.mjs`.
4
+ *
5
+ * Refuse to let any caller invoke `resolveCredential` / `hasCredential` /
6
+ * `saveCredential` / `deleteCredential` with only one argument. The
7
+ * contract requires a second argument carrying the per-user / per-org
8
+ * context object — `(key, { userEmail, orgId })` — so the credential
9
+ * lookup is scoped to the requesting principal.
10
+ *
11
+ * Generic guard, shipped as-is: the detection regex, arg-balancing parser,
12
+ * and marker semantics are unchanged from the monorepo original. The one
13
+ * difference from the monorepo script is scan scope: the original restricts
14
+ * its walk to `packages/`, `templates/`, `app/` — a monorepo-specific
15
+ * optimization that also happens to exclude its own dotfile/doc trees. A
16
+ * generated app's source lives at `actions/`, `app/`, `server/` (no
17
+ * `packages/`/`templates/` wrapper — see report 005's "Path resolution"),
18
+ * so keeping that literal subtree filter would silently skip `actions/`
19
+ * and `server/`. This port scans the whole app root (still respecting
20
+ * `SKIP_DIRS`) instead, which is a superset of the original's coverage and
21
+ * has no false-negative risk for a single-app tree.
22
+ *
23
+ * Opt-out (same line only):
24
+ * resolveCredential(key) // guard:allow-unscoped-credential — short reason
25
+ */
26
+ import type { GuardResult, GuardScanOptions } from "./types.js";
27
+ export declare function scanUnscopedCredentials(options: GuardScanOptions): GuardResult;
28
+ //# sourceMappingURL=no-unscoped-credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unscoped-credentials.d.ts","sourceRoot":"","sources":["../../src/guards/no-unscoped-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH,OAAO,KAAK,EAAgB,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqI9E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,GACxB,WAAW,CA2Db"}
@@ -0,0 +1,199 @@
1
+ /**
2
+ * scanUnscopedCredentials — ported from
3
+ * `scripts/guard-no-unscoped-credentials.mjs`.
4
+ *
5
+ * Refuse to let any caller invoke `resolveCredential` / `hasCredential` /
6
+ * `saveCredential` / `deleteCredential` with only one argument. The
7
+ * contract requires a second argument carrying the per-user / per-org
8
+ * context object — `(key, { userEmail, orgId })` — so the credential
9
+ * lookup is scoped to the requesting principal.
10
+ *
11
+ * Generic guard, shipped as-is: the detection regex, arg-balancing parser,
12
+ * and marker semantics are unchanged from the monorepo original. The one
13
+ * difference from the monorepo script is scan scope: the original restricts
14
+ * its walk to `packages/`, `templates/`, `app/` — a monorepo-specific
15
+ * optimization that also happens to exclude its own dotfile/doc trees. A
16
+ * generated app's source lives at `actions/`, `app/`, `server/` (no
17
+ * `packages/`/`templates/` wrapper — see report 005's "Path resolution"),
18
+ * so keeping that literal subtree filter would silently skip `actions/`
19
+ * and `server/`. This port scans the whole app root (still respecting
20
+ * `SKIP_DIRS`) instead, which is a superset of the original's coverage and
21
+ * has no false-negative risk for a single-app tree.
22
+ *
23
+ * Opt-out (same line only):
24
+ * resolveCredential(key) // guard:allow-unscoped-credential — short reason
25
+ */
26
+ import { lineColForOffset, readFileSafe, relPosix, walk, } from "./scan-utils.js";
27
+ const FUNCTIONS = [
28
+ "resolveCredential",
29
+ "hasCredential",
30
+ "saveCredential",
31
+ "deleteCredential",
32
+ ];
33
+ const FUNC_NAME_RE = new RegExp(`(?<![\\w$.])(${FUNCTIONS.join("|")})\\s*\\(`, "g");
34
+ const OPT_OUT_MARKER = /\/\/\s*guard:allow-unscoped-credential\b[^\n]*[—-]\s*\S/;
35
+ /** Files that legitimately use the one-arg form because they ARE the
36
+ * implementation under guard — the definition file itself. In an app this
37
+ * file only ever exists inside `node_modules`, already excluded by
38
+ * SKIP_DIRS, so this allowlist is effectively a no-op for app mode; kept
39
+ * for parity with the source guard. */
40
+ const FILE_ALLOWLIST = new Set(["packages/core/src/credentials/index.ts"]);
41
+ /**
42
+ * Starting at openParenIdx (the index of the `(` after the function name),
43
+ * walk forward, balancing nested parens / braces / brackets / strings, and
44
+ * return the top-level comma count. Ported verbatim.
45
+ */
46
+ function analyzeArgs(contents, openParenIdx) {
47
+ let depth = 0;
48
+ let topLevelCommas = 0;
49
+ let i = openParenIdx;
50
+ let mode = "code";
51
+ let templateDepth = 0;
52
+ while (i < contents.length) {
53
+ const ch = contents[i];
54
+ const next = contents[i + 1];
55
+ if (mode === "code") {
56
+ if (ch === "/" && next === "/") {
57
+ while (i < contents.length && contents[i] !== "\n")
58
+ i++;
59
+ continue;
60
+ }
61
+ if (ch === "/" && next === "*") {
62
+ i += 2;
63
+ while (i < contents.length - 1 &&
64
+ !(contents[i] === "*" && contents[i + 1] === "/"))
65
+ i++;
66
+ i += 2;
67
+ continue;
68
+ }
69
+ if (ch === '"' || ch === "'") {
70
+ mode = ch;
71
+ i++;
72
+ continue;
73
+ }
74
+ if (ch === "`") {
75
+ mode = "tmpl";
76
+ i++;
77
+ continue;
78
+ }
79
+ if (ch === "(" || ch === "[" || ch === "{") {
80
+ depth++;
81
+ i++;
82
+ continue;
83
+ }
84
+ if (ch === ")" || ch === "]" || ch === "}") {
85
+ depth--;
86
+ if (depth === 0 && ch === ")") {
87
+ return { topLevelCommas, endIdx: i };
88
+ }
89
+ i++;
90
+ continue;
91
+ }
92
+ if (ch === "," && depth === 1) {
93
+ topLevelCommas++;
94
+ i++;
95
+ continue;
96
+ }
97
+ i++;
98
+ continue;
99
+ }
100
+ if (mode === '"' || mode === "'") {
101
+ if (ch === "\\") {
102
+ i += 2;
103
+ continue;
104
+ }
105
+ if (ch === mode) {
106
+ mode = "code";
107
+ i++;
108
+ continue;
109
+ }
110
+ i++;
111
+ continue;
112
+ }
113
+ if (mode === "tmpl") {
114
+ if (ch === "\\") {
115
+ i += 2;
116
+ continue;
117
+ }
118
+ if (ch === "`" && templateDepth === 0) {
119
+ mode = "code";
120
+ i++;
121
+ continue;
122
+ }
123
+ if (ch === "$" && next === "{") {
124
+ templateDepth++;
125
+ i += 2;
126
+ continue;
127
+ }
128
+ if (ch === "}" && templateDepth > 0) {
129
+ templateDepth--;
130
+ i++;
131
+ continue;
132
+ }
133
+ i++;
134
+ continue;
135
+ }
136
+ i++;
137
+ }
138
+ return null;
139
+ }
140
+ export function scanUnscopedCredentials(options) {
141
+ const { root } = options;
142
+ const findings = [];
143
+ for (const file of walk(root)) {
144
+ if (!/\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(file))
145
+ continue;
146
+ if (file.endsWith(".d.ts"))
147
+ continue;
148
+ const rel = relPosix(root, file);
149
+ if (FILE_ALLOWLIST.has(rel))
150
+ continue;
151
+ const contents = readFileSafe(file);
152
+ if (contents === null)
153
+ continue;
154
+ let anyHit = false;
155
+ for (const fn of FUNCTIONS) {
156
+ if (contents.includes(fn + "(") || contents.includes(fn + " (")) {
157
+ anyHit = true;
158
+ break;
159
+ }
160
+ }
161
+ if (!anyHit)
162
+ continue;
163
+ const lines = contents.split("\n");
164
+ FUNC_NAME_RE.lastIndex = 0;
165
+ let m;
166
+ while ((m = FUNC_NAME_RE.exec(contents)) !== null) {
167
+ const fnName = m[1];
168
+ const openParenIdx = m.index + m[0].length - 1;
169
+ const before = contents.slice(Math.max(0, m.index - 30), m.index);
170
+ if (/\bfunction\s+$/.test(before) ||
171
+ /\bexport\s+(default\s+)?(async\s+)?function\s+$/.test(before) ||
172
+ /\b(const|let|var)\s+$/.test(before)) {
173
+ continue;
174
+ }
175
+ const { line } = lineColForOffset(contents, m.index);
176
+ const lineText = lines[line - 1] ?? "";
177
+ const trimmed = lineText.trimStart();
178
+ if (trimmed.startsWith("*") ||
179
+ trimmed.startsWith("//") ||
180
+ trimmed.startsWith("/*")) {
181
+ continue;
182
+ }
183
+ const analysis = analyzeArgs(contents, openParenIdx);
184
+ if (!analysis)
185
+ continue;
186
+ if (analysis.topLevelCommas >= 1)
187
+ continue;
188
+ if (OPT_OUT_MARKER.test(lineText))
189
+ continue;
190
+ findings.push({
191
+ file: rel,
192
+ line,
193
+ message: `${fnName}(...) called with only one argument — must pass a context object: ${fnName}(key, { userEmail, orgId })`,
194
+ });
195
+ }
196
+ }
197
+ return { name: "no-unscoped-credentials", findings };
198
+ }
199
+ //# sourceMappingURL=no-unscoped-credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unscoped-credentials.js","sourceRoot":"","sources":["../../src/guards/no-unscoped-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,IAAI,GACL,MAAM,iBAAiB,CAAC;AAGzB,MAAM,SAAS,GAAG;IAChB,mBAAmB;IACnB,eAAe;IACf,gBAAgB;IAChB,kBAAkB;CACnB,CAAC;AAEF,MAAM,YAAY,GAAG,IAAI,MAAM,CAC7B,gBAAgB,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAC7C,GAAG,CACJ,CAAC;AAEF,MAAM,cAAc,GAClB,yDAAyD,CAAC;AAE5D;;;;uCAIuC;AACvC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC;AAO3E;;;;GAIG;AACH,SAAS,WAAW,CAClB,QAAgB,EAChB,YAAoB;IAEpB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,YAAY,CAAC;IACrB,IAAI,IAAI,GAAgC,MAAM,CAAC;IAC/C,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,OAAO,CAAC,GAAG,QAAQ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gBACZ,IAAI,EAAE,GAAG;gBACT,IAAI;gBACJ,OAAO,EAAE,GAAG,MAAM,qEAAqE,MAAM,6BAA6B;aAC3H,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC","sourcesContent":["/**\n * scanUnscopedCredentials — ported from\n * `scripts/guard-no-unscoped-credentials.mjs`.\n *\n * Refuse to let any caller invoke `resolveCredential` / `hasCredential` /\n * `saveCredential` / `deleteCredential` with only one argument. The\n * contract requires a second argument carrying the per-user / per-org\n * context object — `(key, { userEmail, orgId })` — so the credential\n * lookup is scoped to the requesting principal.\n *\n * Generic guard, shipped as-is: the detection regex, arg-balancing parser,\n * and marker semantics are unchanged from the monorepo original. The one\n * difference from the monorepo script is scan scope: the original restricts\n * its walk to `packages/`, `templates/`, `app/` — a monorepo-specific\n * optimization that also happens to exclude its own dotfile/doc trees. A\n * generated app's source lives at `actions/`, `app/`, `server/` (no\n * `packages/`/`templates/` wrapper — see report 005's \"Path resolution\"),\n * so keeping that literal subtree filter would silently skip `actions/`\n * and `server/`. This port scans the whole app root (still respecting\n * `SKIP_DIRS`) instead, which is a superset of the original's coverage and\n * has no false-negative risk for a single-app tree.\n *\n * Opt-out (same line only):\n * resolveCredential(key) // guard:allow-unscoped-credential — short reason\n */\n\nimport {\n lineColForOffset,\n readFileSafe,\n relPosix,\n walk,\n} from \"./scan-utils.js\";\nimport type { GuardFinding, GuardResult, GuardScanOptions } from \"./types.js\";\n\nconst FUNCTIONS = [\n \"resolveCredential\",\n \"hasCredential\",\n \"saveCredential\",\n \"deleteCredential\",\n];\n\nconst FUNC_NAME_RE = new RegExp(\n `(?<![\\\\w$.])(${FUNCTIONS.join(\"|\")})\\\\s*\\\\(`,\n \"g\",\n);\n\nconst OPT_OUT_MARKER =\n /\\/\\/\\s*guard:allow-unscoped-credential\\b[^\\n]*[—-]\\s*\\S/;\n\n/** Files that legitimately use the one-arg form because they ARE the\n * implementation under guard — the definition file itself. In an app this\n * file only ever exists inside `node_modules`, already excluded by\n * SKIP_DIRS, so this allowlist is effectively a no-op for app mode; kept\n * for parity with the source guard. */\nconst FILE_ALLOWLIST = new Set([\"packages/core/src/credentials/index.ts\"]);\n\ninterface ArgAnalysis {\n topLevelCommas: number;\n endIdx: number;\n}\n\n/**\n * Starting at openParenIdx (the index of the `(` after the function name),\n * walk forward, balancing nested parens / braces / brackets / strings, and\n * return the top-level comma count. Ported verbatim.\n */\nfunction analyzeArgs(\n contents: string,\n openParenIdx: number,\n): ArgAnalysis | null {\n let depth = 0;\n let topLevelCommas = 0;\n let i = openParenIdx;\n let mode: \"code\" | '\"' | \"'\" | \"tmpl\" = \"code\";\n let templateDepth = 0;\n while (i < contents.length) {\n const ch = contents[i];\n const next = contents[i + 1];\n if (mode === \"code\") {\n if (ch === \"/\" && next === \"/\") {\n while (i < contents.length && contents[i] !== \"\\n\") i++;\n continue;\n }\n if (ch === \"/\" && next === \"*\") {\n i += 2;\n while (\n i < contents.length - 1 &&\n !(contents[i] === \"*\" && contents[i + 1] === \"/\")\n )\n i++;\n i += 2;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n mode = ch;\n i++;\n continue;\n }\n if (ch === \"`\") {\n mode = \"tmpl\";\n i++;\n continue;\n }\n if (ch === \"(\" || ch === \"[\" || ch === \"{\") {\n depth++;\n i++;\n continue;\n }\n if (ch === \")\" || ch === \"]\" || ch === \"}\") {\n depth--;\n if (depth === 0 && ch === \")\") {\n return { topLevelCommas, endIdx: i };\n }\n i++;\n continue;\n }\n if (ch === \",\" && depth === 1) {\n topLevelCommas++;\n i++;\n continue;\n }\n i++;\n continue;\n }\n if (mode === '\"' || mode === \"'\") {\n if (ch === \"\\\\\") {\n i += 2;\n continue;\n }\n if (ch === mode) {\n mode = \"code\";\n i++;\n continue;\n }\n i++;\n continue;\n }\n if (mode === \"tmpl\") {\n if (ch === \"\\\\\") {\n i += 2;\n continue;\n }\n if (ch === \"`\" && templateDepth === 0) {\n mode = \"code\";\n i++;\n continue;\n }\n if (ch === \"$\" && next === \"{\") {\n templateDepth++;\n i += 2;\n continue;\n }\n if (ch === \"}\" && templateDepth > 0) {\n templateDepth--;\n i++;\n continue;\n }\n i++;\n continue;\n }\n i++;\n }\n return null;\n}\n\nexport function scanUnscopedCredentials(\n options: GuardScanOptions,\n): GuardResult {\n const { root } = options;\n const findings: GuardFinding[] = [];\n\n for (const file of walk(root)) {\n if (!/\\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(file)) continue;\n if (file.endsWith(\".d.ts\")) continue;\n const rel = relPosix(root, file);\n if (FILE_ALLOWLIST.has(rel)) continue;\n\n const contents = readFileSafe(file);\n if (contents === null) continue;\n\n let anyHit = false;\n for (const fn of FUNCTIONS) {\n if (contents.includes(fn + \"(\") || contents.includes(fn + \" (\")) {\n anyHit = true;\n break;\n }\n }\n if (!anyHit) continue;\n\n const lines = contents.split(\"\\n\");\n FUNC_NAME_RE.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = FUNC_NAME_RE.exec(contents)) !== null) {\n const fnName = m[1];\n const openParenIdx = m.index + m[0].length - 1;\n const before = contents.slice(Math.max(0, m.index - 30), m.index);\n if (\n /\\bfunction\\s+$/.test(before) ||\n /\\bexport\\s+(default\\s+)?(async\\s+)?function\\s+$/.test(before) ||\n /\\b(const|let|var)\\s+$/.test(before)\n ) {\n continue;\n }\n const { line } = lineColForOffset(contents, m.index);\n const lineText = lines[line - 1] ?? \"\";\n const trimmed = lineText.trimStart();\n if (\n trimmed.startsWith(\"*\") ||\n trimmed.startsWith(\"//\") ||\n trimmed.startsWith(\"/*\")\n ) {\n continue;\n }\n const analysis = analyzeArgs(contents, openParenIdx);\n if (!analysis) continue;\n if (analysis.topLevelCommas >= 1) continue;\n if (OPT_OUT_MARKER.test(lineText)) continue;\n findings.push({\n file: rel,\n line,\n message: `${fnName}(...) called with only one argument — must pass a context object: ${fnName}(key, { userEmail, orgId })`,\n });\n }\n }\n\n return { name: \"no-unscoped-credentials\", findings };\n}\n"]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * scanUnscopedQueries — ported from `scripts/guard-no-unscoped-queries.mjs`.
3
+ *
4
+ * Refuse to let any code query an "ownable" resource table (one that
5
+ * spreads `...ownableColumns()`) without going through framework access
6
+ * control: `accessFilter` / `resolveAccess` / `assertAccess`, or an
7
+ * explicit `ownerEmail` / `userEmail` / `orgId` filter. The check is
8
+ * per-STATEMENT, scoped to the enclosing block, so a sibling `if` branch
9
+ * that correctly scopes its query does not defuse an unscoped sibling.
10
+ *
11
+ * Conditional guard — per report 005's V1 guard set table: the original
12
+ * restricts scanning to `templates/[^/]+/(server|actions)/` and
13
+ * `packages/[^/]+/src/`, and hardcodes a `FILE_ALLOWLIST` of this
14
+ * framework's own sharing-primitive implementation files. For a generated
15
+ * app (no `templates/`/`packages/` wrapper — source lives at `actions/`
16
+ * and `server/` under the app root), this port scans `actions/` and
17
+ * `server/` directly and drops the hardcoded allowlist in favor of an
18
+ * optional `extraExemptPaths` param (default `[]`).
19
+ *
20
+ * Opt-out (within the enclosing block, or as a file header for whole-file
21
+ * opt-outs):
22
+ * // guard:allow-unscoped — short reason
23
+ */
24
+ import type { GuardResult, GuardScanOptions } from "./types.js";
25
+ export interface UnscopedQueriesOptions extends GuardScanOptions {
26
+ /** Exact repo-relative paths to exempt from the per-statement scan
27
+ * (e.g. this app's own sharing-primitive implementation, if any).
28
+ * Default `[]`. */
29
+ extraExemptPaths?: string[];
30
+ }
31
+ export declare function scanUnscopedQueries(options: UnscopedQueriesOptions): GuardResult;
32
+ //# sourceMappingURL=no-unscoped-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unscoped-queries.d.ts","sourceRoot":"","sources":["../../src/guards/no-unscoped-queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAgB,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9E,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D;;uBAEmB;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AA6vBD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,sBAAsB,GAC9B,WAAW,CAkCb"}