aimeat 3.1.0 → 3.3.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 (824) hide show
  1. package/dist/.env.example +58 -1
  2. package/dist/build-stamp.json +4 -4
  3. package/dist/locales/en.json +9225 -9103
  4. package/dist/locales/es.json +9217 -9095
  5. package/dist/locales/fi.json +9225 -9103
  6. package/dist/public/changelog.json +12 -0
  7. package/dist/public/css/views/admin.css +11 -0
  8. package/dist/public/css/views/chat.css +388 -0
  9. package/dist/public/css/views/profile.css +41 -0
  10. package/dist/public/js/services/admin.js +346 -331
  11. package/dist/public/js/services/chat.js +190 -0
  12. package/dist/public/js/services/organism-roles.js +51 -0
  13. package/dist/public/js/services/organisms.js +5 -25
  14. package/dist/public/js/services/speech-reader.js +26 -0
  15. package/dist/public/lib/VENDORED.md +1 -0
  16. package/dist/public/lib/duckdb-wasm@1.32.0/duckdb-browser-eh.worker.js +14 -0
  17. package/dist/public/lib/duckdb-wasm@1.32.0/duckdb-browser.js +23 -0
  18. package/dist/public/lib/duckdb-wasm@1.32.0/duckdb-eh.wasm +0 -0
  19. package/dist/public/lib/duckdb-wasm@1.32.0/extensions/v1.4.3/wasm_eh/parquet.duckdb_extension.wasm +0 -0
  20. package/dist/public/lib/vendored-assets.json +19 -0
  21. package/dist/public/llms-full-template.txt +2706 -0
  22. package/dist/public/llms-index-template.txt +60 -0
  23. package/dist/public/robots.node.txt +64 -23
  24. package/dist/public/spa.html +9 -1
  25. package/dist/public/views/admin/organism-ownership-tab.js +124 -0
  26. package/dist/public/views/admin/owners-tab.js +15 -4
  27. package/dist/public/views/admin/usage-tab.calls.js +120 -0
  28. package/dist/public/views/admin/usage-tab.js +18 -4
  29. package/dist/public/views/admin.js +2 -0
  30. package/dist/public/views/chat/parts.js +257 -0
  31. package/dist/public/views/chat.js +327 -0
  32. package/dist/public/views/landing.js +24 -1
  33. package/dist/public/views/profile/agents/scope-model.js +320 -296
  34. package/dist/public/views/profile/landing-page.cards.js +1 -0
  35. package/dist/public/views/profile/organisms/home.js +3 -1
  36. package/dist/public/views/profile/organisms/members.js +29 -4
  37. package/dist/public/views/profile/usage-tab.js +204 -0
  38. package/dist/public/views/profile.js +2 -0
  39. package/dist/scripts/audit-mcp-schemas.js +41 -0
  40. package/dist/scripts/audit-mcp-schemas.js.map +1 -1
  41. package/dist/scripts/build-sdk-libs.d.ts.map +1 -1
  42. package/dist/scripts/build-sdk-libs.js +1 -0
  43. package/dist/scripts/build-sdk-libs.js.map +1 -1
  44. package/dist/scripts/check-ai-disclosure.js +11 -0
  45. package/dist/scripts/check-ai-disclosure.js.map +1 -1
  46. package/dist/scripts/check-commit-msg.d.ts +8 -0
  47. package/dist/scripts/check-commit-msg.d.ts.map +1 -0
  48. package/dist/scripts/check-commit-msg.js +118 -0
  49. package/dist/scripts/check-commit-msg.js.map +1 -0
  50. package/dist/scripts/check-denial-coverage.d.ts +29 -0
  51. package/dist/scripts/check-denial-coverage.d.ts.map +1 -0
  52. package/dist/scripts/check-denial-coverage.js +237 -0
  53. package/dist/scripts/check-denial-coverage.js.map +1 -0
  54. package/dist/scripts/check-ext-entrypoints.js +14 -2
  55. package/dist/scripts/check-ext-entrypoints.js.map +1 -1
  56. package/dist/scripts/check-liaison-surface.js +27 -2
  57. package/dist/scripts/check-liaison-surface.js.map +1 -1
  58. package/dist/scripts/check-locales.js +38 -0
  59. package/dist/scripts/check-locales.js.map +1 -1
  60. package/dist/scripts/check-outbound-fetch.d.ts.map +1 -1
  61. package/dist/scripts/check-outbound-fetch.js +16 -2
  62. package/dist/scripts/check-outbound-fetch.js.map +1 -1
  63. package/dist/scripts/check-route-scopes.d.ts.map +1 -1
  64. package/dist/scripts/check-route-scopes.js +33 -4
  65. package/dist/scripts/check-route-scopes.js.map +1 -1
  66. package/dist/scripts/check-shared-implementation.js +28 -11
  67. package/dist/scripts/check-shared-implementation.js.map +1 -1
  68. package/dist/scripts/check-sse-parity.js +14 -0
  69. package/dist/scripts/check-sse-parity.js.map +1 -1
  70. package/dist/scripts/check-trusted-keys.d.ts +90 -1
  71. package/dist/scripts/check-trusted-keys.d.ts.map +1 -1
  72. package/dist/scripts/check-trusted-keys.js +521 -52
  73. package/dist/scripts/check-trusted-keys.js.map +1 -1
  74. package/dist/scripts/indexnow.js +9 -7
  75. package/dist/scripts/indexnow.js.map +1 -1
  76. package/dist/src/auth/middleware.d.ts +69 -6
  77. package/dist/src/auth/middleware.d.ts.map +1 -1
  78. package/dist/src/auth/middleware.js +130 -28
  79. package/dist/src/auth/middleware.js.map +1 -1
  80. package/dist/src/cli/connect/mcp/tools/agent-tasks.d.ts +5 -0
  81. package/dist/src/cli/connect/mcp/tools/agent-tasks.d.ts.map +1 -1
  82. package/dist/src/cli/connect/mcp/tools/agent-tasks.js +20 -2
  83. package/dist/src/cli/connect/mcp/tools/agent-tasks.js.map +1 -1
  84. package/dist/src/cli/connect/mcp/tools/agent-telemetry.d.ts +7 -1
  85. package/dist/src/cli/connect/mcp/tools/agent-telemetry.d.ts.map +1 -1
  86. package/dist/src/cli/connect/mcp/tools/agent-telemetry.js +24 -0
  87. package/dist/src/cli/connect/mcp/tools/agent-telemetry.js.map +1 -1
  88. package/dist/src/cli/connect/mcp/tools/apps.d.ts.map +1 -1
  89. package/dist/src/cli/connect/mcp/tools/apps.js +88 -0
  90. package/dist/src/cli/connect/mcp/tools/apps.js.map +1 -1
  91. package/dist/src/cli/connect/mcp/tools/core.d.ts +7 -0
  92. package/dist/src/cli/connect/mcp/tools/core.d.ts.map +1 -1
  93. package/dist/src/cli/connect/mcp/tools/core.js +83 -4
  94. package/dist/src/cli/connect/mcp/tools/core.js.map +1 -1
  95. package/dist/src/cli/connect/mcp/tools/organisms.d.ts +2 -0
  96. package/dist/src/cli/connect/mcp/tools/organisms.d.ts.map +1 -1
  97. package/dist/src/cli/connect/mcp/tools/organisms.js +16 -0
  98. package/dist/src/cli/connect/mcp/tools/organisms.js.map +1 -1
  99. package/dist/src/cli/connect/onboarding-prompt.js +1 -1
  100. package/dist/src/cli/connect/skill-bundle.js +1 -1
  101. package/dist/src/cli/connect/tool-call-defs-agent.d.ts +1 -0
  102. package/dist/src/cli/connect/tool-call-defs-agent.d.ts.map +1 -1
  103. package/dist/src/cli/connect/tool-call-defs-agent.js +6 -0
  104. package/dist/src/cli/connect/tool-call-defs-agent.js.map +1 -1
  105. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.d.ts +21 -0
  106. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.d.ts.map +1 -0
  107. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.js +137 -0
  108. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.js.map +1 -0
  109. package/dist/src/cli/connect/tool-call-defs-core.d.ts +1 -0
  110. package/dist/src/cli/connect/tool-call-defs-core.d.ts.map +1 -1
  111. package/dist/src/cli/connect/tool-call-defs-core.js +30 -0
  112. package/dist/src/cli/connect/tool-call-defs-core.js.map +1 -1
  113. package/dist/src/cli/connect/tool-call.d.ts.map +1 -1
  114. package/dist/src/cli/connect/tool-call.js +2 -0
  115. package/dist/src/cli/connect/tool-call.js.map +1 -1
  116. package/dist/src/config-types-ai.d.ts +76 -0
  117. package/dist/src/config-types-ai.d.ts.map +1 -0
  118. package/dist/src/config-types-ai.js +15 -0
  119. package/dist/src/config-types-ai.js.map +1 -0
  120. package/dist/src/config-types.d.ts +11 -2
  121. package/dist/src/config-types.d.ts.map +1 -1
  122. package/dist/src/config.d.ts.map +1 -1
  123. package/dist/src/config.js +25 -4
  124. package/dist/src/config.js.map +1 -1
  125. package/dist/src/data/appdev-pitfalls.d.ts +1 -0
  126. package/dist/src/data/appdev-pitfalls.d.ts.map +1 -1
  127. package/dist/src/data/appdev-pitfalls.js +11 -0
  128. package/dist/src/data/appdev-pitfalls.js.map +1 -1
  129. package/dist/src/data/builtin-skills.d.ts.map +1 -1
  130. package/dist/src/data/builtin-skills.js +3 -2
  131. package/dist/src/data/builtin-skills.js.map +1 -1
  132. package/dist/src/data/digital-signage-package.js +1 -1
  133. package/dist/src/data/library-packs/sdk.d.ts.map +1 -1
  134. package/dist/src/data/library-packs/sdk.js +76 -0
  135. package/dist/src/data/library-packs/sdk.js.map +1 -1
  136. package/dist/src/data/library-packs/vendored.d.ts.map +1 -1
  137. package/dist/src/data/library-packs/vendored.js +81 -0
  138. package/dist/src/data/library-packs/vendored.js.map +1 -1
  139. package/dist/src/data/library-packs.d.ts +2 -2
  140. package/dist/src/data/library-packs.js +2 -2
  141. package/dist/src/data/public-pages.d.ts +13 -0
  142. package/dist/src/data/public-pages.d.ts.map +1 -1
  143. package/dist/src/data/public-pages.js +153 -113
  144. package/dist/src/data/public-pages.js.map +1 -1
  145. package/dist/src/generated/api-types.d.ts +2251 -102
  146. package/dist/src/generated/api-types.d.ts.map +1 -1
  147. package/dist/src/index-start.d.ts.map +1 -1
  148. package/dist/src/index-start.js +21 -1
  149. package/dist/src/index-start.js.map +1 -1
  150. package/dist/src/mcp/agent-tasks.d.ts +16 -0
  151. package/dist/src/mcp/agent-tasks.d.ts.map +1 -1
  152. package/dist/src/mcp/agent-tasks.js +84 -54
  153. package/dist/src/mcp/agent-tasks.js.map +1 -1
  154. package/dist/src/mcp/agent-telemetry.d.ts +6 -1
  155. package/dist/src/mcp/agent-telemetry.d.ts.map +1 -1
  156. package/dist/src/mcp/agent-telemetry.js +37 -1
  157. package/dist/src/mcp/agent-telemetry.js.map +1 -1
  158. package/dist/src/mcp/ai-image.d.ts +22 -0
  159. package/dist/src/mcp/ai-image.d.ts.map +1 -0
  160. package/dist/src/mcp/ai-image.js +60 -0
  161. package/dist/src/mcp/ai-image.js.map +1 -0
  162. package/dist/src/mcp/annotations.d.ts +5 -0
  163. package/dist/src/mcp/annotations.d.ts.map +1 -1
  164. package/dist/src/mcp/annotations.js +23 -0
  165. package/dist/src/mcp/annotations.js.map +1 -1
  166. package/dist/src/mcp/apps-draft-edit.d.ts +28 -0
  167. package/dist/src/mcp/apps-draft-edit.d.ts.map +1 -0
  168. package/dist/src/mcp/apps-draft-edit.js +164 -0
  169. package/dist/src/mcp/apps-draft-edit.js.map +1 -0
  170. package/dist/src/mcp/apps-screenshot.d.ts +26 -0
  171. package/dist/src/mcp/apps-screenshot.d.ts.map +1 -0
  172. package/dist/src/mcp/apps-screenshot.js +39 -0
  173. package/dist/src/mcp/apps-screenshot.js.map +1 -0
  174. package/dist/src/mcp/catalog/definitions/agent-messaging.d.ts.map +1 -1
  175. package/dist/src/mcp/catalog/definitions/agent-messaging.js +18 -0
  176. package/dist/src/mcp/catalog/definitions/agent-messaging.js.map +1 -1
  177. package/dist/src/mcp/catalog/definitions/discovery-work-boards.d.ts +1 -0
  178. package/dist/src/mcp/catalog/definitions/discovery-work-boards.d.ts.map +1 -1
  179. package/dist/src/mcp/catalog/definitions/discovery-work-boards.js +59 -0
  180. package/dist/src/mcp/catalog/definitions/discovery-work-boards.js.map +1 -1
  181. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.d.ts +3 -0
  182. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.d.ts.map +1 -1
  183. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.js +96 -2
  184. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.js.map +1 -1
  185. package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.d.ts +2 -0
  186. package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.d.ts.map +1 -1
  187. package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.js +7 -3
  188. package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.js.map +1 -1
  189. package/dist/src/mcp/catalog/scopes.d.ts.map +1 -1
  190. package/dist/src/mcp/catalog/scopes.js +34 -1
  191. package/dist/src/mcp/catalog/scopes.js.map +1 -1
  192. package/dist/src/mcp/catalog/surfaces.d.ts.map +1 -1
  193. package/dist/src/mcp/catalog/surfaces.js +26 -7
  194. package/dist/src/mcp/catalog/surfaces.js.map +1 -1
  195. package/dist/src/mcp/core-admin.d.ts +7 -3
  196. package/dist/src/mcp/core-admin.d.ts.map +1 -1
  197. package/dist/src/mcp/core-admin.js +60 -3
  198. package/dist/src/mcp/core-admin.js.map +1 -1
  199. package/dist/src/mcp/core-datapackage.d.ts +32 -0
  200. package/dist/src/mcp/core-datapackage.d.ts.map +1 -0
  201. package/dist/src/mcp/core-datapackage.js +188 -0
  202. package/dist/src/mcp/core-datapackage.js.map +1 -0
  203. package/dist/src/mcp/core-storage.d.ts +7 -3
  204. package/dist/src/mcp/core-storage.d.ts.map +1 -1
  205. package/dist/src/mcp/core-storage.js +27 -4
  206. package/dist/src/mcp/core-storage.js.map +1 -1
  207. package/dist/src/mcp/core.d.ts.map +1 -1
  208. package/dist/src/mcp/core.js +3 -0
  209. package/dist/src/mcp/core.js.map +1 -1
  210. package/dist/src/mcp/extensions.d.ts.map +1 -1
  211. package/dist/src/mcp/extensions.js +11 -1
  212. package/dist/src/mcp/extensions.js.map +1 -1
  213. package/dist/src/mcp/index.d.ts +9 -0
  214. package/dist/src/mcp/index.d.ts.map +1 -1
  215. package/dist/src/mcp/index.js +43 -2
  216. package/dist/src/mcp/index.js.map +1 -1
  217. package/dist/src/mcp/organisms-email-invites.d.ts.map +1 -1
  218. package/dist/src/mcp/organisms-email-invites.js +2 -1
  219. package/dist/src/mcp/organisms-email-invites.js.map +1 -1
  220. package/dist/src/mcp/organisms-name-invites.d.ts.map +1 -1
  221. package/dist/src/mcp/organisms-name-invites.js +40 -1
  222. package/dist/src/mcp/organisms-name-invites.js.map +1 -1
  223. package/dist/src/mcp/organisms.d.ts.map +1 -1
  224. package/dist/src/mcp/organisms.js +6 -1
  225. package/dist/src/mcp/organisms.js.map +1 -1
  226. package/dist/src/mcp/tool-usage-wrap.d.ts +9 -0
  227. package/dist/src/mcp/tool-usage-wrap.d.ts.map +1 -0
  228. package/dist/src/mcp/tool-usage-wrap.js +87 -0
  229. package/dist/src/mcp/tool-usage-wrap.js.map +1 -0
  230. package/dist/src/mcp/workspaces.d.ts.map +1 -1
  231. package/dist/src/mcp/workspaces.js +9 -0
  232. package/dist/src/mcp/workspaces.js.map +1 -1
  233. package/dist/src/middleware/idempotency.d.ts +6 -0
  234. package/dist/src/middleware/idempotency.d.ts.map +1 -1
  235. package/dist/src/middleware/idempotency.js +23 -2
  236. package/dist/src/middleware/idempotency.js.map +1 -1
  237. package/dist/src/models/agent-task-schemas.d.ts.map +1 -1
  238. package/dist/src/models/agent-task-schemas.js +12 -1
  239. package/dist/src/models/agent-task-schemas.js.map +1 -1
  240. package/dist/src/models/webhook-schemas.d.ts +2 -2
  241. package/dist/src/models/workflow-schemas.d.ts +178 -1
  242. package/dist/src/models/workflow-schemas.d.ts.map +1 -1
  243. package/dist/src/models/workflow-schemas.js +75 -0
  244. package/dist/src/models/workflow-schemas.js.map +1 -1
  245. package/dist/src/routes/admin-extensions.d.ts +4 -0
  246. package/dist/src/routes/admin-extensions.d.ts.map +1 -1
  247. package/dist/src/routes/admin-extensions.js +135 -142
  248. package/dist/src/routes/admin-extensions.js.map +1 -1
  249. package/dist/src/routes/admin-monitoring.d.ts +2 -0
  250. package/dist/src/routes/admin-monitoring.d.ts.map +1 -1
  251. package/dist/src/routes/admin-monitoring.js +32 -0
  252. package/dist/src/routes/admin-monitoring.js.map +1 -1
  253. package/dist/src/routes/admin-organisms.d.ts +28 -0
  254. package/dist/src/routes/admin-organisms.d.ts.map +1 -0
  255. package/dist/src/routes/admin-organisms.js +99 -0
  256. package/dist/src/routes/admin-organisms.js.map +1 -0
  257. package/dist/src/routes/admin-usage.d.ts +33 -0
  258. package/dist/src/routes/admin-usage.d.ts.map +1 -0
  259. package/dist/src/routes/admin-usage.js +198 -0
  260. package/dist/src/routes/admin-usage.js.map +1 -0
  261. package/dist/src/routes/agent-conventions.d.ts.map +1 -1
  262. package/dist/src/routes/agent-conventions.js +4 -2
  263. package/dist/src/routes/agent-conventions.js.map +1 -1
  264. package/dist/src/routes/agent-docs.d.ts +4 -4
  265. package/dist/src/routes/agent-docs.js +145 -145
  266. package/dist/src/routes/agent-docs.js.map +1 -1
  267. package/dist/src/routes/agent-messages.d.ts +6 -0
  268. package/dist/src/routes/agent-messages.d.ts.map +1 -1
  269. package/dist/src/routes/agent-messages.js +23 -1
  270. package/dist/src/routes/agent-messages.js.map +1 -1
  271. package/dist/src/routes/agent-tasks/completion.d.ts +5 -0
  272. package/dist/src/routes/agent-tasks/completion.d.ts.map +1 -1
  273. package/dist/src/routes/agent-tasks/completion.js +35 -54
  274. package/dist/src/routes/agent-tasks/completion.js.map +1 -1
  275. package/dist/src/routes/agent-tasks/create-read.d.ts.map +1 -1
  276. package/dist/src/routes/agent-tasks/create-read.js +8 -1
  277. package/dist/src/routes/agent-tasks/create-read.js.map +1 -1
  278. package/dist/src/routes/agent-tasks/lifecycle.d.ts +4 -1
  279. package/dist/src/routes/agent-tasks/lifecycle.d.ts.map +1 -1
  280. package/dist/src/routes/agent-tasks/lifecycle.js +80 -2
  281. package/dist/src/routes/agent-tasks/lifecycle.js.map +1 -1
  282. package/dist/src/routes/agents/device-auth.d.ts.map +1 -1
  283. package/dist/src/routes/agents/device-auth.js +27 -4
  284. package/dist/src/routes/agents/device-auth.js.map +1 -1
  285. package/dist/src/routes/ai.d.ts +5 -0
  286. package/dist/src/routes/ai.d.ts.map +1 -1
  287. package/dist/src/routes/ai.js +51 -1
  288. package/dist/src/routes/ai.js.map +1 -1
  289. package/dist/src/routes/app-grants.d.ts.map +1 -1
  290. package/dist/src/routes/app-grants.js +5 -0
  291. package/dist/src/routes/app-grants.js.map +1 -1
  292. package/dist/src/routes/apps/drafts.d.ts +6 -0
  293. package/dist/src/routes/apps/drafts.d.ts.map +1 -1
  294. package/dist/src/routes/apps/drafts.js +133 -1
  295. package/dist/src/routes/apps/drafts.js.map +1 -1
  296. package/dist/src/routes/apps/read.d.ts +4 -0
  297. package/dist/src/routes/apps/read.d.ts.map +1 -1
  298. package/dist/src/routes/apps/read.js +47 -2
  299. package/dist/src/routes/apps/read.js.map +1 -1
  300. package/dist/src/routes/auth-otk.d.ts +28 -0
  301. package/dist/src/routes/auth-otk.d.ts.map +1 -0
  302. package/dist/src/routes/auth-otk.js +190 -0
  303. package/dist/src/routes/auth-otk.js.map +1 -0
  304. package/dist/src/routes/auth.d.ts +17 -0
  305. package/dist/src/routes/auth.d.ts.map +1 -1
  306. package/dist/src/routes/auth.js +44 -153
  307. package/dist/src/routes/auth.js.map +1 -1
  308. package/dist/src/routes/bootstrap.d.ts +6 -0
  309. package/dist/src/routes/bootstrap.d.ts.map +1 -1
  310. package/dist/src/routes/bootstrap.js +47 -20
  311. package/dist/src/routes/bootstrap.js.map +1 -1
  312. package/dist/src/routes/capabilities.d.ts +17 -0
  313. package/dist/src/routes/capabilities.d.ts.map +1 -1
  314. package/dist/src/routes/capabilities.js +187 -4
  315. package/dist/src/routes/capabilities.js.map +1 -1
  316. package/dist/src/routes/chat.d.ts +23 -0
  317. package/dist/src/routes/chat.d.ts.map +1 -0
  318. package/dist/src/routes/chat.js +165 -0
  319. package/dist/src/routes/chat.js.map +1 -0
  320. package/dist/src/routes/commerce.js +4 -4
  321. package/dist/src/routes/commerce.js.map +1 -1
  322. package/dist/src/routes/datapackages.d.ts +35 -0
  323. package/dist/src/routes/datapackages.d.ts.map +1 -0
  324. package/dist/src/routes/datapackages.js +217 -0
  325. package/dist/src/routes/datapackages.js.map +1 -0
  326. package/dist/src/routes/disputes.d.ts +27 -0
  327. package/dist/src/routes/disputes.d.ts.map +1 -1
  328. package/dist/src/routes/disputes.js +74 -79
  329. package/dist/src/routes/disputes.js.map +1 -1
  330. package/dist/src/routes/ecosystem-apps-advisories.d.ts +16 -0
  331. package/dist/src/routes/ecosystem-apps-advisories.d.ts.map +1 -0
  332. package/dist/src/routes/ecosystem-apps-advisories.js +104 -0
  333. package/dist/src/routes/ecosystem-apps-advisories.js.map +1 -0
  334. package/dist/src/routes/ecosystem-apps.d.ts +6 -0
  335. package/dist/src/routes/ecosystem-apps.d.ts.map +1 -1
  336. package/dist/src/routes/ecosystem-apps.js +31 -99
  337. package/dist/src/routes/ecosystem-apps.js.map +1 -1
  338. package/dist/src/routes/extensions/actions.d.ts.map +1 -1
  339. package/dist/src/routes/extensions/actions.js +29 -1
  340. package/dist/src/routes/extensions/actions.js.map +1 -1
  341. package/dist/src/routes/federation-sync/messaging.d.ts +6 -0
  342. package/dist/src/routes/federation-sync/messaging.d.ts.map +1 -1
  343. package/dist/src/routes/federation-sync/messaging.js +22 -1
  344. package/dist/src/routes/federation-sync/messaging.js.map +1 -1
  345. package/dist/src/routes/federation-sync/routing.d.ts.map +1 -1
  346. package/dist/src/routes/federation-sync/routing.js +12 -3
  347. package/dist/src/routes/federation-sync/routing.js.map +1 -1
  348. package/dist/src/routes/glossary.js +1 -1
  349. package/dist/src/routes/glossary.js.map +1 -1
  350. package/dist/src/routes/home/track.d.ts +5 -1
  351. package/dist/src/routes/home/track.d.ts.map +1 -1
  352. package/dist/src/routes/home/track.js +20 -6
  353. package/dist/src/routes/home/track.js.map +1 -1
  354. package/dist/src/routes/instances/install.d.ts +7 -0
  355. package/dist/src/routes/instances/install.d.ts.map +1 -1
  356. package/dist/src/routes/instances/install.js +31 -24
  357. package/dist/src/routes/instances/install.js.map +1 -1
  358. package/dist/src/routes/library-packs.d.ts +7 -0
  359. package/dist/src/routes/library-packs.d.ts.map +1 -1
  360. package/dist/src/routes/library-packs.js +32 -8
  361. package/dist/src/routes/library-packs.js.map +1 -1
  362. package/dist/src/routes/libs.js +1 -1
  363. package/dist/src/routes/libs.js.map +1 -1
  364. package/dist/src/routes/markdown-mirrors.js +1 -1
  365. package/dist/src/routes/markdown-mirrors.js.map +1 -1
  366. package/dist/src/routes/messages.d.ts +6 -0
  367. package/dist/src/routes/messages.d.ts.map +1 -1
  368. package/dist/src/routes/messages.js +15 -3
  369. package/dist/src/routes/messages.js.map +1 -1
  370. package/dist/src/routes/odata.d.ts +36 -0
  371. package/dist/src/routes/odata.d.ts.map +1 -0
  372. package/dist/src/routes/odata.js +143 -0
  373. package/dist/src/routes/odata.js.map +1 -0
  374. package/dist/src/routes/openrouter.d.ts +4 -0
  375. package/dist/src/routes/openrouter.d.ts.map +1 -1
  376. package/dist/src/routes/openrouter.js +10 -1
  377. package/dist/src/routes/openrouter.js.map +1 -1
  378. package/dist/src/routes/organisms/crud.d.ts +4 -0
  379. package/dist/src/routes/organisms/crud.d.ts.map +1 -1
  380. package/dist/src/routes/organisms/crud.js +25 -7
  381. package/dist/src/routes/organisms/crud.js.map +1 -1
  382. package/dist/src/routes/organisms/gates.d.ts.map +1 -1
  383. package/dist/src/routes/organisms/gates.js +19 -2
  384. package/dist/src/routes/organisms/gates.js.map +1 -1
  385. package/dist/src/routes/organisms/membership.d.ts +4 -0
  386. package/dist/src/routes/organisms/membership.d.ts.map +1 -1
  387. package/dist/src/routes/organisms/membership.js +88 -36
  388. package/dist/src/routes/organisms/membership.js.map +1 -1
  389. package/dist/src/routes/organisms/shared.d.ts.map +1 -1
  390. package/dist/src/routes/organisms/shared.js +2 -1
  391. package/dist/src/routes/organisms/shared.js.map +1 -1
  392. package/dist/src/routes/organisms/workspace-access.d.ts +5 -0
  393. package/dist/src/routes/organisms/workspace-access.d.ts.map +1 -1
  394. package/dist/src/routes/organisms/workspace-access.js +41 -2
  395. package/dist/src/routes/organisms/workspace-access.js.map +1 -1
  396. package/dist/src/routes/organisms/workspace-ops.d.ts +2 -0
  397. package/dist/src/routes/organisms/workspace-ops.d.ts.map +1 -1
  398. package/dist/src/routes/organisms/workspace-ops.js +10 -6
  399. package/dist/src/routes/organisms/workspace-ops.js.map +1 -1
  400. package/dist/src/routes/organisms/workspace-read.d.ts +3 -0
  401. package/dist/src/routes/organisms/workspace-read.d.ts.map +1 -1
  402. package/dist/src/routes/organisms/workspace-read.js +13 -7
  403. package/dist/src/routes/organisms/workspace-read.js.map +1 -1
  404. package/dist/src/routes/portal.d.ts +1 -0
  405. package/dist/src/routes/portal.d.ts.map +1 -1
  406. package/dist/src/routes/portal.js +13 -0
  407. package/dist/src/routes/portal.js.map +1 -1
  408. package/dist/src/routes/schedules.d.ts +4 -0
  409. package/dist/src/routes/schedules.d.ts.map +1 -1
  410. package/dist/src/routes/schedules.js +9 -1
  411. package/dist/src/routes/schedules.js.map +1 -1
  412. package/dist/src/routes/storage-files.d.ts +23 -0
  413. package/dist/src/routes/storage-files.d.ts.map +1 -1
  414. package/dist/src/routes/storage-files.js +103 -82
  415. package/dist/src/routes/storage-files.js.map +1 -1
  416. package/dist/src/routes/subdomains.d.ts +9 -1
  417. package/dist/src/routes/subdomains.d.ts.map +1 -1
  418. package/dist/src/routes/subdomains.js +55 -1
  419. package/dist/src/routes/subdomains.js.map +1 -1
  420. package/dist/src/routes/usage-reports.d.ts +31 -0
  421. package/dist/src/routes/usage-reports.d.ts.map +1 -0
  422. package/dist/src/routes/usage-reports.js +107 -0
  423. package/dist/src/routes/usage-reports.js.map +1 -0
  424. package/dist/src/routes/validate.d.ts.map +1 -1
  425. package/dist/src/routes/validate.js +1 -0
  426. package/dist/src/routes/validate.js.map +1 -1
  427. package/dist/src/routes/workflows.d.ts.map +1 -1
  428. package/dist/src/routes/workflows.js +9 -1
  429. package/dist/src/routes/workflows.js.map +1 -1
  430. package/dist/src/server-bootstrap/routes-loader.d.ts +2 -0
  431. package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
  432. package/dist/src/server-bootstrap/routes-loader.js +32 -2
  433. package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
  434. package/dist/src/server-bootstrap/service-init.d.ts.map +1 -1
  435. package/dist/src/server-bootstrap/service-init.js +12 -7
  436. package/dist/src/server-bootstrap/service-init.js.map +1 -1
  437. package/dist/src/server-bootstrap/static-files.d.ts.map +1 -1
  438. package/dist/src/server-bootstrap/static-files.js +44 -10
  439. package/dist/src/server-bootstrap/static-files.js.map +1 -1
  440. package/dist/src/services/agent-task-fanout.d.ts +61 -0
  441. package/dist/src/services/agent-task-fanout.d.ts.map +1 -1
  442. package/dist/src/services/agent-task-fanout.js +114 -2
  443. package/dist/src/services/agent-task-fanout.js.map +1 -1
  444. package/dist/src/services/agent-task-write.d.ts.map +1 -1
  445. package/dist/src/services/agent-task-write.js +6 -0
  446. package/dist/src/services/agent-task-write.js.map +1 -1
  447. package/dist/src/services/ai-allowance.d.ts +82 -0
  448. package/dist/src/services/ai-allowance.d.ts.map +1 -0
  449. package/dist/src/services/ai-allowance.js +117 -0
  450. package/dist/src/services/ai-allowance.js.map +1 -0
  451. package/dist/src/services/ai-completion.d.ts +39 -0
  452. package/dist/src/services/ai-completion.d.ts.map +1 -1
  453. package/dist/src/services/ai-completion.js +77 -10
  454. package/dist/src/services/ai-completion.js.map +1 -1
  455. package/dist/src/services/ai-image.d.ts +70 -0
  456. package/dist/src/services/ai-image.d.ts.map +1 -0
  457. package/dist/src/services/ai-image.js +104 -0
  458. package/dist/src/services/ai-image.js.map +1 -0
  459. package/dist/src/services/ai-model-defaults.d.ts +45 -0
  460. package/dist/src/services/ai-model-defaults.d.ts.map +1 -0
  461. package/dist/src/services/ai-model-defaults.js +42 -0
  462. package/dist/src/services/ai-model-defaults.js.map +1 -0
  463. package/dist/src/services/ai-tool-setup.d.ts +5 -1
  464. package/dist/src/services/ai-tool-setup.d.ts.map +1 -1
  465. package/dist/src/services/ai-tool-setup.js +36 -0
  466. package/dist/src/services/ai-tool-setup.js.map +1 -1
  467. package/dist/src/services/ai-transcription.d.ts +5 -0
  468. package/dist/src/services/ai-transcription.d.ts.map +1 -1
  469. package/dist/src/services/ai-transcription.js +10 -2
  470. package/dist/src/services/ai-transcription.js.map +1 -1
  471. package/dist/src/services/ai-usage-admin.d.ts +19 -8
  472. package/dist/src/services/ai-usage-admin.d.ts.map +1 -1
  473. package/dist/src/services/ai-usage-admin.js +30 -35
  474. package/dist/src/services/ai-usage-admin.js.map +1 -1
  475. package/dist/src/services/app-agent-surfaces.js +4 -4
  476. package/dist/src/services/app-agent-surfaces.js.map +1 -1
  477. package/dist/src/services/app-artifact-lint.d.ts +4 -0
  478. package/dist/src/services/app-artifact-lint.d.ts.map +1 -1
  479. package/dist/src/services/app-artifact-lint.js +49 -0
  480. package/dist/src/services/app-artifact-lint.js.map +1 -1
  481. package/dist/src/services/app-draft-edit.d.ts +144 -0
  482. package/dist/src/services/app-draft-edit.d.ts.map +1 -0
  483. package/dist/src/services/app-draft-edit.js +203 -0
  484. package/dist/src/services/app-draft-edit.js.map +1 -0
  485. package/dist/src/services/app-spec-gate.d.ts +4 -0
  486. package/dist/src/services/app-spec-gate.d.ts.map +1 -1
  487. package/dist/src/services/app-spec-gate.js +16 -1
  488. package/dist/src/services/app-spec-gate.js.map +1 -1
  489. package/dist/src/services/attachment-duplication.d.ts +4 -0
  490. package/dist/src/services/attachment-duplication.d.ts.map +1 -1
  491. package/dist/src/services/attachment-duplication.js +15 -0
  492. package/dist/src/services/attachment-duplication.js.map +1 -1
  493. package/dist/src/services/auth-md.js +2 -2
  494. package/dist/src/services/auth-md.js.map +1 -1
  495. package/dist/src/services/board-write.d.ts +11 -3
  496. package/dist/src/services/board-write.d.ts.map +1 -1
  497. package/dist/src/services/board-write.js +24 -3
  498. package/dist/src/services/board-write.js.map +1 -1
  499. package/dist/src/services/capability-record.d.ts.map +1 -1
  500. package/dist/src/services/capability-record.js +22 -9
  501. package/dist/src/services/capability-record.js.map +1 -1
  502. package/dist/src/services/chat-agent.d.ts +36 -0
  503. package/dist/src/services/chat-agent.d.ts.map +1 -0
  504. package/dist/src/services/chat-agent.js +123 -0
  505. package/dist/src/services/chat-agent.js.map +1 -0
  506. package/dist/src/services/chat-session.d.ts +58 -0
  507. package/dist/src/services/chat-session.d.ts.map +1 -0
  508. package/dist/src/services/chat-session.js +151 -0
  509. package/dist/src/services/chat-session.js.map +1 -0
  510. package/dist/src/services/chat-threads.d.ts +61 -0
  511. package/dist/src/services/chat-threads.d.ts.map +1 -0
  512. package/dist/src/services/chat-threads.js +137 -0
  513. package/dist/src/services/chat-threads.js.map +1 -0
  514. package/dist/src/services/config-schema.d.ts.map +1 -1
  515. package/dist/src/services/config-schema.js +2 -1
  516. package/dist/src/services/config-schema.js.map +1 -1
  517. package/dist/src/services/core-jobs.d.ts +2 -0
  518. package/dist/src/services/core-jobs.d.ts.map +1 -1
  519. package/dist/src/services/core-jobs.js +11 -0
  520. package/dist/src/services/core-jobs.js.map +1 -1
  521. package/dist/src/services/datapackage/contract.d.ts +198 -0
  522. package/dist/src/services/datapackage/contract.d.ts.map +1 -0
  523. package/dist/src/services/datapackage/contract.js +140 -0
  524. package/dist/src/services/datapackage/contract.js.map +1 -0
  525. package/dist/src/services/datapackage/ext-capability.d.ts +85 -0
  526. package/dist/src/services/datapackage/ext-capability.d.ts.map +1 -0
  527. package/dist/src/services/datapackage/ext-capability.js +72 -0
  528. package/dist/src/services/datapackage/ext-capability.js.map +1 -0
  529. package/dist/src/services/datapackage/odata.d.ts +92 -0
  530. package/dist/src/services/datapackage/odata.d.ts.map +1 -0
  531. package/dist/src/services/datapackage/odata.js +256 -0
  532. package/dist/src/services/datapackage/odata.js.map +1 -0
  533. package/dist/src/services/datapackage/odps.d.ts +24 -0
  534. package/dist/src/services/datapackage/odps.d.ts.map +1 -0
  535. package/dist/src/services/datapackage/odps.js +183 -0
  536. package/dist/src/services/datapackage/odps.js.map +1 -0
  537. package/dist/src/services/datapackage/store.d.ts +143 -0
  538. package/dist/src/services/datapackage/store.d.ts.map +1 -0
  539. package/dist/src/services/datapackage/store.js +533 -0
  540. package/dist/src/services/datapackage/store.js.map +1 -0
  541. package/dist/src/services/datapackage/table.d.ts +67 -0
  542. package/dist/src/services/datapackage/table.d.ts.map +1 -0
  543. package/dist/src/services/datapackage/table.js +0 -0
  544. package/dist/src/services/datapackage/table.js.map +1 -0
  545. package/dist/src/services/extension-ctx.d.ts +1 -0
  546. package/dist/src/services/extension-ctx.d.ts.map +1 -1
  547. package/dist/src/services/extension-ctx.js +31 -6
  548. package/dist/src/services/extension-ctx.js.map +1 -1
  549. package/dist/src/services/extension-files.d.ts +20 -0
  550. package/dist/src/services/extension-files.d.ts.map +1 -1
  551. package/dist/src/services/extension-files.js +9 -2
  552. package/dist/src/services/extension-files.js.map +1 -1
  553. package/dist/src/services/extension-lifecycle.d.ts +3 -0
  554. package/dist/src/services/extension-lifecycle.d.ts.map +1 -1
  555. package/dist/src/services/extension-lifecycle.js +2 -26
  556. package/dist/src/services/extension-lifecycle.js.map +1 -1
  557. package/dist/src/services/extension-runtime.d.ts +28 -2
  558. package/dist/src/services/extension-runtime.d.ts.map +1 -1
  559. package/dist/src/services/extension-runtime.js +22 -0
  560. package/dist/src/services/extension-runtime.js.map +1 -1
  561. package/dist/src/services/extension-schedules.d.ts +90 -0
  562. package/dist/src/services/extension-schedules.d.ts.map +1 -0
  563. package/dist/src/services/extension-schedules.js +123 -0
  564. package/dist/src/services/extension-schedules.js.map +1 -0
  565. package/dist/src/services/extension-system-run.d.ts +91 -0
  566. package/dist/src/services/extension-system-run.d.ts.map +1 -0
  567. package/dist/src/services/extension-system-run.js +100 -0
  568. package/dist/src/services/extension-system-run.js.map +1 -0
  569. package/dist/src/services/extension-upsert.d.ts +2 -0
  570. package/dist/src/services/extension-upsert.d.ts.map +1 -1
  571. package/dist/src/services/extension-upsert.js +6 -24
  572. package/dist/src/services/extension-upsert.js.map +1 -1
  573. package/dist/src/services/goose-acp.d.ts +84 -0
  574. package/dist/src/services/goose-acp.d.ts.map +1 -0
  575. package/dist/src/services/goose-acp.js +304 -0
  576. package/dist/src/services/goose-acp.js.map +1 -0
  577. package/dist/src/services/invitations.d.ts +0 -20
  578. package/dist/src/services/invitations.d.ts.map +1 -1
  579. package/dist/src/services/invitations.js +30 -0
  580. package/dist/src/services/invitations.js.map +1 -1
  581. package/dist/src/services/job-seeding.d.ts +1 -0
  582. package/dist/src/services/job-seeding.d.ts.map +1 -1
  583. package/dist/src/services/job-seeding.js +6 -0
  584. package/dist/src/services/job-seeding.js.map +1 -1
  585. package/dist/src/services/ledger-admin.d.ts +18 -4
  586. package/dist/src/services/ledger-admin.d.ts.map +1 -1
  587. package/dist/src/services/ledger-admin.js +47 -33
  588. package/dist/src/services/ledger-admin.js.map +1 -1
  589. package/dist/src/services/markdown-negotiation.js +1 -1
  590. package/dist/src/services/markdown-negotiation.js.map +1 -1
  591. package/dist/src/services/message-broadcast.d.ts.map +1 -1
  592. package/dist/src/services/message-broadcast.js +29 -1
  593. package/dist/src/services/message-broadcast.js.map +1 -1
  594. package/dist/src/services/metered-access.d.ts +9 -2
  595. package/dist/src/services/metered-access.d.ts.map +1 -1
  596. package/dist/src/services/metered-access.js +92 -12
  597. package/dist/src/services/metered-access.js.map +1 -1
  598. package/dist/src/services/openrouter.d.ts +20 -1
  599. package/dist/src/services/openrouter.d.ts.map +1 -1
  600. package/dist/src/services/openrouter.js +66 -0
  601. package/dist/src/services/openrouter.js.map +1 -1
  602. package/dist/src/services/organism-import.d.ts.map +1 -1
  603. package/dist/src/services/organism-import.js +4 -1
  604. package/dist/src/services/organism-import.js.map +1 -1
  605. package/dist/src/services/organism-lifecycle.d.ts.map +1 -1
  606. package/dist/src/services/organism-lifecycle.js +5 -1
  607. package/dist/src/services/organism-lifecycle.js.map +1 -1
  608. package/dist/src/services/organism-ownership.d.ts +56 -0
  609. package/dist/src/services/organism-ownership.d.ts.map +1 -0
  610. package/dist/src/services/organism-ownership.js +174 -0
  611. package/dist/src/services/organism-ownership.js.map +1 -0
  612. package/dist/src/services/organism-privacy.d.ts.map +1 -1
  613. package/dist/src/services/organism-privacy.js +2 -1
  614. package/dist/src/services/organism-privacy.js.map +1 -1
  615. package/dist/src/services/prompt-defaults/tiers-core.js +4 -4
  616. package/dist/src/services/scheduler-extension-job.d.ts +29 -6
  617. package/dist/src/services/scheduler-extension-job.d.ts.map +1 -1
  618. package/dist/src/services/scheduler-extension-job.js +29 -75
  619. package/dist/src/services/scheduler-extension-job.js.map +1 -1
  620. package/dist/src/services/scope-vocabulary-migration.d.ts +54 -1
  621. package/dist/src/services/scope-vocabulary-migration.d.ts.map +1 -1
  622. package/dist/src/services/scope-vocabulary-migration.js +101 -6
  623. package/dist/src/services/scope-vocabulary-migration.js.map +1 -1
  624. package/dist/src/services/screenshot-capture.d.ts +40 -1
  625. package/dist/src/services/screenshot-capture.d.ts.map +1 -1
  626. package/dist/src/services/screenshot-capture.js +142 -60
  627. package/dist/src/services/screenshot-capture.js.map +1 -1
  628. package/dist/src/services/skill-bundle/generator.js +1 -1
  629. package/dist/src/services/skill-bundle/generic-adapter.js +1 -1
  630. package/dist/src/services/skill-bundle/hermes-adapter.js +1 -1
  631. package/dist/src/services/storage-file-write.d.ts +36 -1
  632. package/dist/src/services/storage-file-write.d.ts.map +1 -1
  633. package/dist/src/services/storage-file-write.js +49 -3
  634. package/dist/src/services/storage-file-write.js.map +1 -1
  635. package/dist/src/services/task-outcome.d.ts +53 -0
  636. package/dist/src/services/task-outcome.d.ts.map +1 -0
  637. package/dist/src/services/task-outcome.js +28 -0
  638. package/dist/src/services/task-outcome.js.map +1 -0
  639. package/dist/src/services/usage/archive-job.d.ts +25 -0
  640. package/dist/src/services/usage/archive-job.d.ts.map +1 -0
  641. package/dist/src/services/usage/archive-job.js +36 -0
  642. package/dist/src/services/usage/archive-job.js.map +1 -0
  643. package/dist/src/services/usage/record-app-open.d.ts +8 -0
  644. package/dist/src/services/usage/record-app-open.d.ts.map +1 -0
  645. package/dist/src/services/usage/record-app-open.js +52 -0
  646. package/dist/src/services/usage/record-app-open.js.map +1 -0
  647. package/dist/src/services/usage/rollup-cuts.d.ts +44 -0
  648. package/dist/src/services/usage/rollup-cuts.d.ts.map +1 -0
  649. package/dist/src/services/usage/rollup-cuts.js +81 -0
  650. package/dist/src/services/usage/rollup-cuts.js.map +1 -0
  651. package/dist/src/services/usage/rollup-engine.d.ts +71 -0
  652. package/dist/src/services/usage/rollup-engine.d.ts.map +1 -0
  653. package/dist/src/services/usage/rollup-engine.js +237 -0
  654. package/dist/src/services/usage/rollup-engine.js.map +1 -0
  655. package/dist/src/services/usage/usage-buffer.d.ts +25 -0
  656. package/dist/src/services/usage/usage-buffer.d.ts.map +1 -0
  657. package/dist/src/services/usage/usage-buffer.js +146 -0
  658. package/dist/src/services/usage/usage-buffer.js.map +1 -0
  659. package/dist/src/services/usage/usage-read.d.ts +115 -0
  660. package/dist/src/services/usage/usage-read.d.ts.map +1 -0
  661. package/dist/src/services/usage/usage-read.js +246 -0
  662. package/dist/src/services/usage/usage-read.js.map +1 -0
  663. package/dist/src/services/usage-metering.d.ts +5 -0
  664. package/dist/src/services/usage-metering.d.ts.map +1 -1
  665. package/dist/src/services/usage-metering.js +7 -0
  666. package/dist/src/services/usage-metering.js.map +1 -1
  667. package/dist/src/services/workflow/engine-human.d.ts +15 -0
  668. package/dist/src/services/workflow/engine-human.d.ts.map +1 -1
  669. package/dist/src/services/workflow/engine-human.js +10 -1
  670. package/dist/src/services/workflow/engine-human.js.map +1 -1
  671. package/dist/src/services/workflow/engine-steps.d.ts +48 -3
  672. package/dist/src/services/workflow/engine-steps.d.ts.map +1 -1
  673. package/dist/src/services/workflow/engine-steps.js +361 -0
  674. package/dist/src/services/workflow/engine-steps.js.map +1 -1
  675. package/dist/src/services/workflow/engine.d.ts +1 -0
  676. package/dist/src/services/workflow/engine.d.ts.map +1 -1
  677. package/dist/src/services/workflow/engine.js +2 -1
  678. package/dist/src/services/workflow/engine.js.map +1 -1
  679. package/dist/src/services/workflow/store.d.ts.map +1 -1
  680. package/dist/src/services/workflow/store.js +60 -4
  681. package/dist/src/services/workflow/store.js.map +1 -1
  682. package/dist/src/services/write-guards.d.ts +27 -1
  683. package/dist/src/services/write-guards.d.ts.map +1 -1
  684. package/dist/src/services/write-guards.js +39 -9
  685. package/dist/src/services/write-guards.js.map +1 -1
  686. package/dist/src/storage/interface.d.ts +4 -1
  687. package/dist/src/storage/interface.d.ts.map +1 -1
  688. package/dist/src/storage/interface.js +1 -0
  689. package/dist/src/storage/interface.js.map +1 -1
  690. package/dist/src/storage/providers/postgres-kysely/db-types.d.ts +119 -0
  691. package/dist/src/storage/providers/postgres-kysely/db-types.d.ts.map +1 -1
  692. package/dist/src/storage/providers/postgres-kysely/index.d.ts.map +1 -1
  693. package/dist/src/storage/providers/postgres-kysely/index.js +2 -1
  694. package/dist/src/storage/providers/postgres-kysely/index.js.map +1 -1
  695. package/dist/src/storage/providers/postgres-kysely/methods/agent-tasks.d.ts.map +1 -1
  696. package/dist/src/storage/providers/postgres-kysely/methods/agent-tasks.js +3 -0
  697. package/dist/src/storage/providers/postgres-kysely/methods/agent-tasks.js.map +1 -1
  698. package/dist/src/storage/providers/postgres-kysely/methods/agent-usage.d.ts.map +1 -1
  699. package/dist/src/storage/providers/postgres-kysely/methods/agent-usage.js +4 -0
  700. package/dist/src/storage/providers/postgres-kysely/methods/agent-usage.js.map +1 -1
  701. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.d.ts +1 -0
  702. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.d.ts.map +1 -1
  703. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.js +3 -0
  704. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.js.map +1 -1
  705. package/dist/src/storage/providers/postgres-kysely/methods/files.d.ts +2 -0
  706. package/dist/src/storage/providers/postgres-kysely/methods/files.d.ts.map +1 -1
  707. package/dist/src/storage/providers/postgres-kysely/methods/files.js +34 -2
  708. package/dist/src/storage/providers/postgres-kysely/methods/files.js.map +1 -1
  709. package/dist/src/storage/providers/postgres-kysely/methods/organisms.d.ts.map +1 -1
  710. package/dist/src/storage/providers/postgres-kysely/methods/organisms.js +11 -2
  711. package/dist/src/storage/providers/postgres-kysely/methods/organisms.js.map +1 -1
  712. package/dist/src/storage/providers/postgres-kysely/methods/usage.d.ts +32 -0
  713. package/dist/src/storage/providers/postgres-kysely/methods/usage.d.ts.map +1 -0
  714. package/dist/src/storage/providers/postgres-kysely/methods/usage.js +336 -0
  715. package/dist/src/storage/providers/postgres-kysely/methods/usage.js.map +1 -0
  716. package/dist/src/storage/providers/postgres-kysely/migrations/0036_usage_telemetry.sql +181 -0
  717. package/dist/src/storage/providers/postgres-kysely/migrations/0037_task_created_by.sql +18 -0
  718. package/dist/src/storage/providers/postgres-kysely/migrations/0038_organism_owners.sql +31 -0
  719. package/dist/src/storage/providers/postgres-kysely/migrations/0039_storage_file_utf8_verified.sql +19 -0
  720. package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -1
  721. package/dist/src/storage/providers/sqlite/index.js +3 -1
  722. package/dist/src/storage/providers/sqlite/index.js.map +1 -1
  723. package/dist/src/storage/providers/sqlite/methods/apps.d.ts +1 -0
  724. package/dist/src/storage/providers/sqlite/methods/apps.d.ts.map +1 -1
  725. package/dist/src/storage/providers/sqlite/methods/apps.js +33 -28
  726. package/dist/src/storage/providers/sqlite/methods/apps.js.map +1 -1
  727. package/dist/src/storage/providers/sqlite/methods/governance.d.ts +2 -0
  728. package/dist/src/storage/providers/sqlite/methods/governance.d.ts.map +1 -1
  729. package/dist/src/storage/providers/sqlite/methods/governance.js +25 -4
  730. package/dist/src/storage/providers/sqlite/methods/governance.js.map +1 -1
  731. package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts +1 -12
  732. package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts.map +1 -1
  733. package/dist/src/storage/providers/sqlite/methods/identity-nodes.js +28 -135
  734. package/dist/src/storage/providers/sqlite/methods/identity-nodes.js.map +1 -1
  735. package/dist/src/storage/providers/sqlite/methods/storage-files.d.ts +38 -0
  736. package/dist/src/storage/providers/sqlite/methods/storage-files.d.ts.map +1 -0
  737. package/dist/src/storage/providers/sqlite/methods/storage-files.js +109 -0
  738. package/dist/src/storage/providers/sqlite/methods/storage-files.js.map +1 -0
  739. package/dist/src/storage/providers/sqlite/methods/usage.d.ts +43 -0
  740. package/dist/src/storage/providers/sqlite/methods/usage.d.ts.map +1 -0
  741. package/dist/src/storage/providers/sqlite/methods/usage.js +37 -0
  742. package/dist/src/storage/providers/sqlite/methods/usage.js.map +1 -0
  743. package/dist/src/storage/providers/sqlite/repos/agent-task.d.ts +1 -0
  744. package/dist/src/storage/providers/sqlite/repos/agent-task.d.ts.map +1 -1
  745. package/dist/src/storage/providers/sqlite/repos/agent-task.js +4 -2
  746. package/dist/src/storage/providers/sqlite/repos/agent-task.js.map +1 -1
  747. package/dist/src/storage/providers/sqlite/repos/agent-usage.d.ts.map +1 -1
  748. package/dist/src/storage/providers/sqlite/repos/agent-usage.js +4 -2
  749. package/dist/src/storage/providers/sqlite/repos/agent-usage.js.map +1 -1
  750. package/dist/src/storage/providers/sqlite/repos/community.d.ts.map +1 -1
  751. package/dist/src/storage/providers/sqlite/repos/community.js +20 -0
  752. package/dist/src/storage/providers/sqlite/repos/community.js.map +1 -1
  753. package/dist/src/storage/providers/sqlite/repos/usage.d.ts +35 -0
  754. package/dist/src/storage/providers/sqlite/repos/usage.d.ts.map +1 -0
  755. package/dist/src/storage/providers/sqlite/repos/usage.js +352 -0
  756. package/dist/src/storage/providers/sqlite/repos/usage.js.map +1 -0
  757. package/dist/src/storage/providers/sqlite/schema-tables-1.d.ts.map +1 -1
  758. package/dist/src/storage/providers/sqlite/schema-tables-1.js +2 -0
  759. package/dist/src/storage/providers/sqlite/schema-tables-1.js.map +1 -1
  760. package/dist/src/storage/providers/sqlite/schema-tables-3.d.ts +1 -0
  761. package/dist/src/storage/providers/sqlite/schema-tables-3.d.ts.map +1 -1
  762. package/dist/src/storage/providers/sqlite/schema-tables-3.js +1 -0
  763. package/dist/src/storage/providers/sqlite/schema-tables-3.js.map +1 -1
  764. package/dist/src/storage/providers/sqlite/schema-tables-4.d.ts +2 -0
  765. package/dist/src/storage/providers/sqlite/schema-tables-4.d.ts.map +1 -1
  766. package/dist/src/storage/providers/sqlite/schema-tables-4.js +131 -0
  767. package/dist/src/storage/providers/sqlite/schema-tables-4.js.map +1 -1
  768. package/dist/src/storage/providers/sqlite/schema.d.ts +2 -0
  769. package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
  770. package/dist/src/storage/providers/sqlite/schema.js +155 -130
  771. package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
  772. package/dist/src/storage/repositories/app-grant.repository.d.ts +11 -0
  773. package/dist/src/storage/repositories/app-grant.repository.d.ts.map +1 -1
  774. package/dist/src/storage/repositories/file.repository.d.ts +13 -0
  775. package/dist/src/storage/repositories/file.repository.d.ts.map +1 -1
  776. package/dist/src/storage/repositories/usage.repository.d.ts +80 -0
  777. package/dist/src/storage/repositories/usage.repository.d.ts.map +1 -0
  778. package/dist/src/storage/repositories/usage.repository.js +23 -0
  779. package/dist/src/storage/repositories/usage.repository.js.map +1 -0
  780. package/dist/src/storage/types/agents-messaging.d.ts +24 -0
  781. package/dist/src/storage/types/agents-messaging.d.ts.map +1 -1
  782. package/dist/src/storage/types/agents-messaging.js +1 -0
  783. package/dist/src/storage/types/agents-messaging.js.map +1 -1
  784. package/dist/src/storage/types/commerce.d.ts +6 -0
  785. package/dist/src/storage/types/commerce.d.ts.map +1 -1
  786. package/dist/src/storage/types/organisms-federation.d.ts +21 -0
  787. package/dist/src/storage/types/organisms-federation.d.ts.map +1 -1
  788. package/dist/src/storage/types/usage.d.ts +186 -0
  789. package/dist/src/storage/types/usage.d.ts.map +1 -0
  790. package/dist/src/storage/types/usage.js +24 -0
  791. package/dist/src/storage/types/usage.js.map +1 -0
  792. package/dist/src/utils/agent-footer.d.ts.map +1 -1
  793. package/dist/src/utils/agent-footer.js +1 -0
  794. package/dist/src/utils/agent-footer.js.map +1 -1
  795. package/dist/src/utils/app-content-type.d.ts +57 -3
  796. package/dist/src/utils/app-content-type.d.ts.map +1 -1
  797. package/dist/src/utils/app-content-type.js +81 -12
  798. package/dist/src/utils/app-content-type.js.map +1 -1
  799. package/dist/src/utils/env-config/sections-features.d.ts.map +1 -1
  800. package/dist/src/utils/env-config/sections-features.js +9 -3
  801. package/dist/src/utils/env-config/sections-features.js.map +1 -1
  802. package/dist/src/utils/file-download-headers.d.ts +5 -3
  803. package/dist/src/utils/file-download-headers.d.ts.map +1 -1
  804. package/dist/src/utils/file-download-headers.js +18 -5
  805. package/dist/src/utils/file-download-headers.js.map +1 -1
  806. package/dist/src/utils/http-range.d.ts +151 -0
  807. package/dist/src/utils/http-range.d.ts.map +1 -0
  808. package/dist/src/utils/http-range.js +190 -0
  809. package/dist/src/utils/http-range.js.map +1 -0
  810. package/dist/src/utils/page-head.d.ts +5 -0
  811. package/dist/src/utils/page-head.d.ts.map +1 -1
  812. package/dist/src/utils/page-head.js +10 -1
  813. package/dist/src/utils/page-head.js.map +1 -1
  814. package/dist/src/utils/reserved-keys.d.ts +4 -1
  815. package/dist/src/utils/reserved-keys.d.ts.map +1 -1
  816. package/dist/src/utils/reserved-keys.js +4 -1
  817. package/dist/src/utils/reserved-keys.js.map +1 -1
  818. package/dist/src/utils/scope-coverage.d.ts +21 -0
  819. package/dist/src/utils/scope-coverage.d.ts.map +1 -1
  820. package/dist/src/utils/scope-coverage.js +22 -1
  821. package/dist/src/utils/scope-coverage.js.map +1 -1
  822. package/dist/static/sdk-libs/datapackage/index.js +336 -0
  823. package/dist/static/sdk-libs/dist/aimeat-datapackage.js +305 -0
  824. package/package.json +13 -2
@@ -11,33 +11,91 @@
11
11
  * two of the unprotected ones were a cross-owner authorization list and a payout address with a
12
12
  * Stripe secret beside it.
13
13
  *
14
+ * WHY THE KEY EXPRESSION IS RESOLVED RATHER THAN MATCHED. Both keys the audit found by hand are
15
+ * invisible to a scan that only reads inline string literals. `finance.accountants` (H-6) sits in
16
+ * a module constant and reaches storage through a two-line helper that takes the key as a
17
+ * parameter; `commerce.psp` (H-23) is inline in five places and behind `PSP_KEY` in a sixth. So
18
+ * this script resolves the key ARGUMENT: a literal, a module constant (local or imported), a
19
+ * key-builder function returning a template with a literal prefix, or a helper that took the key as
20
+ * a parameter, in which case the judgement moves up to the call site where the constant is spelled.
21
+ * What it still cannot resolve it COUNTS and prints, because the honest measure of a scanner is how
22
+ * blind it admits to being.
23
+ *
24
+ * A PREFIX SCAN IS A READ. `listAllMemory({ prefix: 'bensplit.' })` walks EVERY owner's namespace
25
+ * and the server pays out on what it finds, so a prefix carries the same weight here as a key.
26
+ *
14
27
  * Ratchet, not a wall: seeded with today's reads, so the gate fails only on a NEW unprotected key.
28
+ * An exemption carries prose saying why the key is not server-trusted configuration. A reason is
29
+ * the entire point of the file: "the server reads this and it is fine" is a claim, and the two the
30
+ * audit found were keys where nobody had ever made it. An empty reason therefore fails the gate,
31
+ * and a reason that begins with UNREVIEWED counts as backlog rather than as a claim.
15
32
  * @structure
16
- * - collectReads(): every resolvable storage.getMemory / getPublicMemory key in the server code
17
- * - main(): compare against security/trusted-key-exemptions.json; --strict gates; --seed rewrites
33
+ * - stripComments / collectKeyConstants / collectKeyBuilders / scanForwarders: resolution tables
34
+ * - splitCallArgs + resolveKeyExpression: what key does this read actually ask for
35
+ * - scanSources(): the pure scan (getMemory, the list calls, and the forwarder call sites)
36
+ * - validateReasons(): empty reason fails, UNREVIEWED counts as debt
37
+ * - main(): compare against security/trusted-key-exemptions.json; --strict gates; --seed merges
18
38
  * @usage
19
- * cd aimeat && pnpm check:trusted-keys # report
20
- * cd aimeat && pnpm check:trusted-keys --strict # the hook/CI gate
21
- * cd aimeat && pnpm check:trusted-keys --seed # rewrite the exemption file
39
+ * cd aimeat && pnpm check:trusted-keys:report # the backlog, without gating
40
+ * cd aimeat && pnpm check:trusted-keys # the hook/CI gate (--strict)
41
+ * cd aimeat && pnpm check:trusted-keys:seed # merge today's reads into the exemption file
42
+ * ... --root <dir> # scan a fixture tree instead of this one
22
43
  * @version-history
44
+ * v2.0.0 — 2026-08-14 — The gate finds the keys the audit found by hand. Each change has its own
45
+ * failing case in test/unit/check-trusted-keys.test.ts: the key argument is RESOLVED through
46
+ * module constants, key builders and key-forwarding helpers (v1 saw inline literals only, so H-6
47
+ * finance.accountants was invisible to it); prefix scans count as reads, which is how the
48
+ * revenue-split and entitlement keys became visible; the scan covers the whole server rather than
49
+ * four directories, since middleware and auth read memory too; and an exemption with an empty
50
+ * reason now fails, which is the difference between a written claim and a filed key name.
51
+ * Comments are stripped first, so a docblock example is no longer a finding, and a scan that
52
+ * matched no files at all is an error rather than a pass. Re-seeded: 36 reads / 12 distinct keys
53
+ * became 231 reads / 62 distinct keys, of which 153 were invisible to v1, and all 124 entries
54
+ * carry the UNREVIEWED marker because nobody has yet judged any of them.
23
55
  * v1.0.0 — 2026-08-10 — Initial (August 2026 audit, systemic pattern 3).
24
56
  */
25
57
  import { readFileSync, writeFileSync, existsSync, readdirSync, statSync } from 'node:fs';
26
- import { join, relative } from 'node:path';
58
+ import { join, relative, resolve } from 'node:path';
59
+ import { fileURLToPath } from 'node:url';
27
60
  import { RESERVED_OWNER_KEY_PREFIXES } from '../src/utils/reserved-keys.js';
28
- const ROOT = process.cwd();
29
- const AREAS = ['services', 'routes', 'commerce', 'mcp'].map(d => join(ROOT, 'src', d));
61
+ /**
62
+ * The tree to scan: the working directory, which `pnpm check:trusted-keys` sets to the package, or
63
+ * `--root <dir>`. The flag exists so the whole gate can be run against a miniature fixture tree, and
64
+ * that is how its failing cases are proven without writing a probe into the real src/ while other
65
+ * work is in flight. A run that finds no files at all is an error rather than a pass.
66
+ */
67
+ const rootFlag = process.argv.indexOf('--root');
68
+ const ROOT = rootFlag > 0 && process.argv[rootFlag + 1] ? resolve(process.argv[rootFlag + 1]) : process.cwd();
69
+ const SRC = join(ROOT, 'src');
70
+ /**
71
+ * Directories under src/ that are not the server acting on data: the storage providers ARE the
72
+ * memory implementation (every read in them is the mechanism, not a decision), and generated,
73
+ * static and data are outputs and fixtures. Everything else is in scope, including middleware and
74
+ * auth, because "does the server change what it does because of this value" is not a question only
75
+ * four directories can answer.
76
+ */
77
+ const SKIP_DIRS = ['storage', 'generated', 'static', 'data', 'types', 'schemas'];
30
78
  const EXEMPTIONS = join(ROOT, 'security', 'trusted-key-exemptions.json');
31
79
  /** Identities no owner-scoped principal can address, so a key under one is already out of reach. */
32
80
  const SYSTEM_IDENTITIES = ['__network_policy__', 'SITE_OWNER_GAII', '__genesis__', 'system@', '__system__'];
33
- function walk(dir, out = []) {
81
+ /** Marker that turns an exemption into countable debt instead of a claim someone stands behind. */
82
+ const UNREVIEWED = 'UNREVIEWED';
83
+ /**
84
+ * Shortest thing that can carry a reason. "ok", "user data" and "fine" are not reasons; they are the
85
+ * same silence the file exists to prevent, typed out. The number is arbitrary and its job is only to
86
+ * make the shortest possible dodge cost more than writing the sentence.
87
+ */
88
+ const MIN_REASON = 25;
89
+ function walk(dir, out = [], depth = 0) {
34
90
  if (!existsSync(dir))
35
91
  return out;
36
92
  for (const entry of readdirSync(dir)) {
93
+ if (depth === 0 && SKIP_DIRS.includes(entry))
94
+ continue;
37
95
  const full = join(dir, entry);
38
96
  if (statSync(full).isDirectory())
39
- walk(full, out);
40
- else if (entry.endsWith('.ts'))
97
+ walk(full, out, depth + 1);
98
+ else if (entry.endsWith('.ts') && !entry.endsWith('.d.ts'))
41
99
  out.push(full);
42
100
  }
43
101
  return out;
@@ -46,61 +104,446 @@ function walk(dir, out = []) {
46
104
  function isReserved(key) {
47
105
  return RESERVED_OWNER_KEY_PREFIXES.some(p => key.startsWith(p));
48
106
  }
49
- export function collectReads(files) {
50
- const findings = [];
51
- // getMemory(identity, 'literal.key') or getMemory(identity, `literal.${x}`) only the resolvable
52
- // ones. A key built entirely from variables cannot be judged here and is not reported.
53
- const re = /\b(?:getMemory|getPublicMemory)\s*\(\s*([^,]+?)\s*,\s*(['"`])([A-Za-z0-9_.:-]+)/g;
54
- for (const file of files) {
55
- const source = readFileSync(file, 'utf-8');
56
- const rel = relative(ROOT, file).replace(/\\/g, '/');
107
+ /**
108
+ * Blanks comments while keeping every byte's position, so line numbers stay honest and a docblock
109
+ * showing `storage.getMemory(sellerGhii, appToolsKey(appId))` as an example stops being a finding.
110
+ */
111
+ export function stripComments(source) {
112
+ const blank = (m) => m.replace(/[^\n]/g, ' ');
113
+ return source
114
+ .replace(/\/\*[\s\S]*?\*\//g, blank)
115
+ .replace(/(^|[^:])\/\/[^\n]*/g, (m, lead) => lead + blank(m.slice(lead.length)));
116
+ }
117
+ /** A key-shaped string: no whitespace, no path separators, short enough to be an address. */
118
+ function isKeyish(value) {
119
+ return value.length > 0 && value.length <= 120 && /^[A-Za-z0-9_.:@#$%|~-]+$/.test(value);
120
+ }
121
+ /**
122
+ * `const ACCOUNTANTS_KEY = 'finance.accountants'` and its `export` form, which is how the H-6 key
123
+ * was written and why the first version of this gate never saw it.
124
+ */
125
+ export function collectKeyConstants(source, exportedOnly = false) {
126
+ const out = new Map();
127
+ const re = exportedOnly
128
+ ? /(?:^|[;{}\n])\s*export\s+const\s+([A-Za-z_$][\w$]*)\s*(?::\s*string\s*)?=\s*(['"`])([^'"`\n]*?)(?:\$\{|\2)/g
129
+ : /(?:^|[;{}\n])\s*(?:export\s+)?const\s+([A-Za-z_$][\w$]*)\s*(?::\s*string\s*)?=\s*(['"`])([^'"`\n]*?)(?:\$\{|\2)/g;
130
+ let m;
131
+ while ((m = re.exec(source))) {
132
+ const [, name, , value] = m;
133
+ if (isKeyish(value))
134
+ out.set(name, value);
135
+ }
136
+ return out;
137
+ }
138
+ /**
139
+ * Key builders: `const holdKey = (id: string) => \`commerce.hold.${id}\`` and the `function` form.
140
+ * Only the literal prefix is taken, which is all a prefix denylist needs anyway.
141
+ */
142
+ export function collectKeyBuilders(source, exportedOnly = false) {
143
+ const out = new Map();
144
+ const lead = exportedOnly ? 'export\\s+' : '(?:export\\s+)?';
145
+ const arrow = new RegExp(`${lead}const\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=\\n]*)?=\\s*\\(?[^)=\\n]*\\)?\\s*(?::\\s*string\\s*)?=>\\s*\`([^\`$\\n]*)\\$\\{`, 'g');
146
+ const fn = new RegExp(`${lead}function\\s+([A-Za-z_$][\\w$]*)\\s*\\([^)]*\\)[^{\\n]*\\{\\s*return\\s+\`([^\`$\\n]*)\\$\\{`, 'g');
147
+ for (const re of [arrow, fn]) {
148
+ let m;
149
+ while ((m = re.exec(source))) {
150
+ const [, name, prefix] = m;
151
+ if (isKeyish(prefix))
152
+ out.set(name, prefix);
153
+ }
154
+ }
155
+ return out;
156
+ }
157
+ /**
158
+ * The top-level arguments of a call whose `(` sits at `open`. Depth-aware, so `appToolsKey(appId)`
159
+ * arrives as one argument rather than two halves, and quoted commas do not split anything.
160
+ */
161
+ export function splitCallArgs(source, open, max = 600) {
162
+ const args = [];
163
+ let depth = 0;
164
+ let quote = '';
165
+ let current = '';
166
+ for (let i = open + 1; i < source.length && i < open + max; i++) {
167
+ const ch = source[i];
168
+ if (quote) {
169
+ current += ch;
170
+ if (ch === quote && source[i - 1] !== '\\')
171
+ quote = '';
172
+ continue;
173
+ }
174
+ if (ch === "'" || ch === '"' || ch === '`') {
175
+ quote = ch;
176
+ current += ch;
177
+ continue;
178
+ }
179
+ if ('([{'.includes(ch)) {
180
+ depth++;
181
+ current += ch;
182
+ continue;
183
+ }
184
+ if (')]}'.includes(ch)) {
185
+ if (ch === ')' && depth === 0) {
186
+ args.push(current.trim());
187
+ return args;
188
+ }
189
+ depth--;
190
+ current += ch;
191
+ continue;
192
+ }
193
+ if (ch === ',' && depth === 0) {
194
+ args.push(current.trim());
195
+ current = '';
196
+ continue;
197
+ }
198
+ current += ch;
199
+ }
200
+ if (current.trim())
201
+ args.push(current.trim());
202
+ return args;
203
+ }
204
+ /**
205
+ * What key does this argument ask for? A literal answers directly; an identifier is looked up in the
206
+ * file's own constants first and the exported constants of the whole server second; a call is looked
207
+ * up among the key builders. `a ?? b` resolves through its first resolvable side, which is the shape
208
+ * `getMemory(x, holdKey(id)) ?? getMemory(x, holdInKey(id))` produces.
209
+ */
210
+ export function resolveKeyExpression(expr, t) {
211
+ const trimmed = expr.trim();
212
+ if (!trimmed)
213
+ return null;
214
+ const literal = /^(['"])([^'"]*)\1$/.exec(trimmed);
215
+ if (literal && isKeyish(literal[2]))
216
+ return { key: literal[2], via: 'literal' };
217
+ const template = /^`([^`$]*)(?:\$\{|`)/.exec(trimmed);
218
+ if (template && isKeyish(template[1]))
219
+ return { key: template[1], via: 'literal' };
220
+ const ident = /^([A-Za-z_$][\w$]*)$/.exec(trimmed);
221
+ if (ident) {
222
+ const local = t.consts.get(ident[1]);
223
+ if (local)
224
+ return { key: local, via: 'constant' };
225
+ // null means the name is exported from two files with different values: guessing which one
226
+ // this file imported would be worse than admitting the read is unresolved.
227
+ const shared = t.sharedConsts.get(ident[1]);
228
+ if (shared)
229
+ return { key: shared, via: 'constant' };
230
+ return null;
231
+ }
232
+ const call = /^([A-Za-z_$][\w$]*)\s*\(/.exec(trimmed);
233
+ if (call) {
234
+ const local = t.builders.get(call[1]);
235
+ if (local)
236
+ return { key: local, via: 'builder' };
237
+ const shared = t.sharedBuilders.get(call[1]);
238
+ if (shared)
239
+ return { key: shared, via: 'builder' };
240
+ return null;
241
+ }
242
+ for (const side of trimmed.split('??')) {
243
+ if (side.trim() === trimmed)
244
+ break;
245
+ const r = resolveKeyExpression(side, t);
246
+ if (r)
247
+ return r;
248
+ }
249
+ return null;
250
+ }
251
+ /** Parameter names of a `(a, b: string, c = 1)` list, positionally. Destructuring yields ''. */
252
+ function paramNames(list) {
253
+ return splitCallArgs(`(${list})`, 0, list.length + 2)
254
+ .map(p => /^([A-Za-z_$][\w$]*)/.exec(p.replace(/^\s*(?:readonly|public|private|protected)\s+/, ''))?.[1] ?? '');
255
+ }
256
+ /** The body of a block that opens at `open`, by brace matching. Strings are already comment-free. */
257
+ function blockBody(source, open, max = 4000) {
258
+ let depth = 0;
259
+ for (let i = open; i < source.length && i < open + max; i++) {
260
+ if (source[i] === '{')
261
+ depth++;
262
+ else if (source[i] === '}') {
263
+ depth--;
264
+ if (!depth)
265
+ return source.slice(open, i);
266
+ }
267
+ }
268
+ return source.slice(open, Math.min(source.length, open + max));
269
+ }
270
+ /**
271
+ * Functions whose own parameter is the key they read. Both the `function` and the arrow form; a
272
+ * class method is left out on purpose, because a method reaches its collaborators through `this` and
273
+ * the call site rarely spells the key either.
274
+ */
275
+ export function scanForwarders(source, exportedOnly = false) {
276
+ const byName = new Map();
277
+ const innerReads = new Set();
278
+ const lead = exportedOnly ? 'export\\s+' : '(?:export\\s+)?';
279
+ const heads = [
280
+ new RegExp(`${lead}(?:async\\s+)?function\\s+([A-Za-z_$][\\w$]*)\\s*\\(([^)]*)\\)[^{;]*\\{`, 'g'),
281
+ new RegExp(`${lead}const\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=\\n]*)?=\\s*(?:async\\s*)?\\(([^)]*)\\)[^={]*=>\\s*\\{`, 'g'),
282
+ ];
283
+ for (const re of heads) {
57
284
  let m;
58
285
  while ((m = re.exec(source))) {
59
- const [, identity, , key] = m;
60
- if (isReserved(key))
286
+ const [, name, params] = m;
287
+ const names = paramNames(params);
288
+ if (!names.length)
61
289
  continue;
62
- if (SYSTEM_IDENTITIES.some(s => identity.includes(s)))
290
+ const bodyStart = source.indexOf('{', m.index + m[0].length - 1);
291
+ if (bodyStart < 0)
63
292
  continue;
64
- const line = source.slice(0, m.index).split('\n').length;
65
- findings.push({ file: rel, line, key, identity: identity.trim().slice(0, 40) });
293
+ const body = blockBody(source, bodyStart);
294
+ const read = /\b(?:getMemory|getPublicMemory)\s*\(/g;
295
+ let r;
296
+ while ((r = read.exec(body))) {
297
+ const args = splitCallArgs(body, r.index + r[0].length - 1);
298
+ if (args.length < 2)
299
+ continue;
300
+ const keyIndex = names.indexOf(args[1].trim());
301
+ if (keyIndex < 0)
302
+ continue;
303
+ if (!byName.has(name))
304
+ byName.set(name, { keyIndex, identityIndex: names.indexOf(args[0].trim()) });
305
+ innerReads.add(bodyStart + r.index);
306
+ }
307
+ }
308
+ }
309
+ return { byName, innerReads };
310
+ }
311
+ export function collectKeyForwarders(source, exportedOnly = false) {
312
+ return scanForwarders(source, exportedOnly).byName;
313
+ }
314
+ /** Merges a name into a shared table, marking it null when two files disagree about its value. */
315
+ function share(table, from, same) {
316
+ for (const [name, value] of from) {
317
+ if (!table.has(name)) {
318
+ table.set(name, value);
319
+ continue;
66
320
  }
321
+ const seen = table.get(name);
322
+ if (seen === null || seen === undefined || !same(seen, value))
323
+ table.set(name, null);
67
324
  }
68
- return findings;
325
+ }
326
+ /**
327
+ * The scan proper, over sources rather than paths, so its failing cases can be proven against a
328
+ * fixture instead of the real tree.
329
+ */
330
+ export function scanSources(inputs) {
331
+ const prepared = inputs.map(i => {
332
+ const source = stripComments(i.source);
333
+ const fwd = scanForwarders(source);
334
+ return {
335
+ file: i.file,
336
+ source,
337
+ consts: collectKeyConstants(source),
338
+ builders: collectKeyBuilders(source),
339
+ forwarders: fwd.byName,
340
+ innerReads: fwd.innerReads,
341
+ };
342
+ });
343
+ // Only EXPORTED names cross a file boundary, so only those go in the shared tables. A file-local
344
+ // constant with a popular name (KEY, PREFIX) would otherwise answer for a read in a file that
345
+ // never imported it.
346
+ const sharedConsts = new Map();
347
+ const sharedBuilders = new Map();
348
+ const sharedForwarders = new Map();
349
+ const sameString = (a, b) => a === b;
350
+ for (const p of prepared) {
351
+ share(sharedConsts, collectKeyConstants(p.source, true), sameString);
352
+ share(sharedBuilders, collectKeyBuilders(p.source, true), sameString);
353
+ share(sharedForwarders, collectKeyForwarders(p.source, true), (a, b) => a.keyIndex === b.keyIndex && a.identityIndex === b.identityIndex);
354
+ }
355
+ const findings = [];
356
+ let unresolved = 0;
357
+ let reserved = 0;
358
+ let systemIdentity = 0;
359
+ for (const p of prepared) {
360
+ const t = {
361
+ consts: p.consts, builders: p.builders, forwarders: p.forwarders,
362
+ sharedConsts, sharedBuilders, sharedForwarders,
363
+ };
364
+ const at = (index) => p.source.slice(0, index).split('\n').length;
365
+ /** One judged read: reserved and system-identity reads leave nothing behind but silence. */
366
+ const record = (index, identity, keyExpr) => {
367
+ const resolved = resolveKeyExpression(keyExpr, t);
368
+ if (!resolved) {
369
+ unresolved++;
370
+ return;
371
+ }
372
+ if (isReserved(resolved.key)) {
373
+ reserved++;
374
+ return;
375
+ }
376
+ if (isSystemIdentity(identity, t)) {
377
+ systemIdentity++;
378
+ return;
379
+ }
380
+ findings.push({
381
+ file: p.file, line: at(index), key: resolved.key,
382
+ identity: identity.trim().slice(0, 40), via: resolved.via,
383
+ });
384
+ };
385
+ const direct = /\b(?:getMemory|getPublicMemory)\s*\(/g;
386
+ let m;
387
+ while ((m = direct.exec(p.source))) {
388
+ const args = splitCallArgs(p.source, m.index + m[0].length - 1);
389
+ // A forwarder's own storage call is judged at ITS call sites, where the key is spelled.
390
+ if (p.innerReads.has(m.index))
391
+ continue;
392
+ if (args.length < 2) {
393
+ unresolved++;
394
+ continue;
395
+ }
396
+ record(m.index, args[0], args[1]);
397
+ }
398
+ // A prefix scan is a read of every key under that prefix, and `listAllMemory` scans EVERY
399
+ // owner's namespace: `listAllMemory({ prefix: 'bensplit.' })` pays out on what it finds
400
+ // there. Whatever the server then acts on has to be as unwritable as a single key would be.
401
+ const perOwner = /\b(?:listMemory|listMemoryMeta|listMemoryForOwners|listMemoryMetaForOwners)\s*\(/g;
402
+ while ((m = perOwner.exec(p.source))) {
403
+ const args = splitCallArgs(p.source, m.index + m[0].length - 1);
404
+ const prefix = args.length > 1 ? prefixOption(args[1]) : null;
405
+ if (!prefix)
406
+ continue;
407
+ record(m.index, args[0], prefix);
408
+ }
409
+ const allOwners = /\blistAllMemory\s*\(/g;
410
+ while ((m = allOwners.exec(p.source))) {
411
+ const prefix = prefixOption(splitCallArgs(p.source, m.index + m[0].length - 1)[0] ?? '');
412
+ if (prefix)
413
+ record(m.index, '', prefix);
414
+ }
415
+ const byPrefix = /\blistMemoryKeysByPrefix\s*\(/g;
416
+ while ((m = byPrefix.exec(p.source))) {
417
+ const args = splitCallArgs(p.source, m.index + m[0].length - 1);
418
+ if (args.length)
419
+ record(m.index, '', args[0]);
420
+ }
421
+ // Calls to a key-forwarding helper: the frame where the constant is actually named.
422
+ for (const [name, fwd] of [...p.forwarders, ...sharedForwarders]) {
423
+ if (!fwd)
424
+ continue;
425
+ if (p.forwarders.has(name) && p.forwarders.get(name) !== fwd)
426
+ continue;
427
+ const re = new RegExp(`(?<![.\\w$])${name}\\s*\\(`, 'g');
428
+ let c;
429
+ while ((c = re.exec(p.source))) {
430
+ const args = splitCallArgs(p.source, c.index + c[0].length - 1);
431
+ if (args.length <= fwd.keyIndex)
432
+ continue;
433
+ if (isDefinitionSite(p.source, c.index))
434
+ continue;
435
+ record(c.index, fwd.identityIndex >= 0 ? (args[fwd.identityIndex] ?? '') : '', args[fwd.keyIndex]);
436
+ }
437
+ }
438
+ }
439
+ return { findings, unresolved, reserved, systemIdentity };
440
+ }
441
+ /**
442
+ * An identity no owner-scoped principal can address. The `__name__` convention is read as the rule
443
+ * rather than a fixed list: `__network_policy__`, `__genesis__` and `__federation_book__` all follow
444
+ * it, and the next one should be recognised on the day it is written rather than the day someone
445
+ * remembers to add it here.
446
+ */
447
+ function isSystemIdentity(expr, t) {
448
+ const raw = expr.trim();
449
+ const synthetic = (s) => /^__[A-Za-z0-9_]+__$/.test(s) || SYSTEM_IDENTITIES.some(k => s.includes(k));
450
+ if (synthetic(raw.replace(/^['"`]|['"`]$/g, '')))
451
+ return true;
452
+ // The identity can be behind a name too: `securityOwner(nodeId)` builds `security-system@<node>`,
453
+ // and reading the resolved value is the only way to see that.
454
+ const resolved = resolveKeyExpression(raw, t);
455
+ return !!resolved && synthetic(resolved.key);
456
+ }
457
+ /** The `{ prefix: 'x.' }` of a list call. Absent means "everything", which no denylist can help. */
458
+ function prefixOption(objectExpr) {
459
+ const m = /\bprefix\s*:\s*([^,}]+)/.exec(objectExpr);
460
+ return m ? m[1].trim() : null;
461
+ }
462
+ /** The `function foo(` of the definition itself is not a call to foo. */
463
+ function isDefinitionSite(source, index) {
464
+ return /(?:function|const|let|var)\s+$/.test(source.slice(Math.max(0, index - 30), index));
465
+ }
466
+ export function collectReads(files) {
467
+ return scanSources(files.map(f => ({
468
+ file: relative(ROOT, f).replace(/\\/g, '/'),
469
+ source: readFileSync(f, 'utf-8'),
470
+ }))).findings;
69
471
  }
70
472
  const softKey = (f) => `${f.file}:${f.key}`;
473
+ /**
474
+ * An exemption says the server does not act on this key. Empty prose says nothing at all, and that
475
+ * silence is what left `finance.accountants` and `commerce.psp` off the denylist for two months.
476
+ */
477
+ export function validateReasons(exempt) {
478
+ const reasonless = [];
479
+ const unreviewed = [];
480
+ for (const [key, reason] of Object.entries(exempt)) {
481
+ const text = (reason ?? '').trim();
482
+ if (text.length < MIN_REASON)
483
+ reasonless.push(key);
484
+ else if (text.startsWith(UNREVIEWED))
485
+ unreviewed.push(key);
486
+ }
487
+ return { reasonless, unreviewed };
488
+ }
489
+ function loadExemptions() {
490
+ if (!existsSync(EXEMPTIONS))
491
+ return { note: '', exempt: {} };
492
+ return JSON.parse(readFileSync(EXEMPTIONS, 'utf-8'));
493
+ }
494
+ const SEED_NOTE = `${UNREVIEWED}: seeded from the state on the day the gate learned to resolve this key. `
495
+ + 'Nobody has yet said whether the server ACTS on this value (a URL it fetches, a credential, a '
496
+ + 'policy, a budget, an authorization list) or merely hands it back as the user\'s own data. If it '
497
+ + 'acts on it, reserve the prefix in src/utils/reserved-keys.ts or move it under a system identity.';
498
+ /** Seeding MERGES: a reason someone wrote is never overwritten by a placeholder. */
499
+ function seed(findings) {
500
+ const previous = loadExemptions().exempt;
501
+ const exempt = {};
502
+ for (const f of findings.map(softKey).sort())
503
+ exempt[f] = previous[f] ?? SEED_NOTE;
504
+ const kept = Object.keys(exempt).filter(k => previous[k]).length;
505
+ writeFileSync(EXEMPTIONS, JSON.stringify({
506
+ note: 'Memory keys the server reads that are neither reserved nor under a system identity. A ratchet: '
507
+ + 'the list may shrink and never grow silently. Every entry carries prose saying why the server does '
508
+ + 'not act on this value; an empty reason fails the gate, and one that starts with UNREVIEWED counts '
509
+ + 'as backlog rather than as a claim anyone has made.',
510
+ exempt,
511
+ }, null, 2) + '\n');
512
+ console.log(`Seeded ${findings.length} reads as ${Object.keys(exempt).length} entries in `
513
+ + `${relative(ROOT, EXEMPTIONS)} (${kept} existing reasons kept word for word)`);
514
+ }
71
515
  function main() {
72
516
  const strict = process.argv.includes('--strict');
73
- const seed = process.argv.includes('--seed');
74
- const files = AREAS.flatMap(a => walk(a));
75
- const findings = collectReads(files);
76
- if (seed) {
77
- const exempt = {};
78
- for (const f of findings) {
79
- exempt[softKey(f)] = 'Seeded 2026-08-10 from the August audit. Not yet reviewed: decide whether the '
80
- + 'server ACTS on this value (a URL it fetches, a credential, a policy, a budget, a listing flag) '
81
- + 'or merely echoes it back as user data. If it acts on it, reserve the prefix or move it under a '
82
- + 'system identity.';
83
- }
84
- writeFileSync(EXEMPTIONS, JSON.stringify({
85
- note: 'Memory keys the server reads that are neither reserved nor under a system identity. Seeded '
86
- + 'from the state on 2026-08-10 so the gate can only ratchet down. Most are ordinary user data '
87
- + 'the server hands back untouched; the dangerous ones are those it acts on.',
88
- exempt,
89
- }, null, 2) + '\n');
90
- console.log(`Seeded ${findings.length} exemptions into ${relative(ROOT, EXEMPTIONS)}`);
517
+ const files = walk(SRC);
518
+ if (!files.length) {
519
+ console.error(`✖ scanned no files under ${SRC}. Run this from the aimeat package directory.`);
520
+ process.exit(1);
521
+ }
522
+ const { findings, unresolved, reserved, systemIdentity } = scanSources(files.map(f => ({
523
+ file: relative(ROOT, f).replace(/\\/g, '/'),
524
+ source: readFileSync(f, 'utf-8'),
525
+ })));
526
+ if (process.argv.includes('--seed')) {
527
+ seed(findings);
91
528
  return;
92
529
  }
93
- const exempt = existsSync(EXEMPTIONS)
94
- ? JSON.parse(readFileSync(EXEMPTIONS, 'utf-8')).exempt
95
- : {};
530
+ const { exempt } = loadExemptions();
96
531
  const known = new Set(Object.keys(exempt));
97
532
  const fresh = findings.filter(f => !known.has(softKey(f)));
533
+ const stale = [...known].filter(k => !findings.some(f => softKey(f) === k));
534
+ const { reasonless, unreviewed } = validateReasons(exempt);
98
535
  const distinct = new Set(findings.map(f => f.key));
536
+ const viaConstant = findings.filter(f => f.via !== 'literal').length;
99
537
  console.log('');
100
538
  console.log(' Server-trusted memory keys — Rule 10 invariant 2');
101
539
  console.log(' ' + '─'.repeat(62));
102
540
  console.log(` reads outside the guard ${String(findings.length).padStart(4)} (${distinct.size} distinct keys)`);
103
- console.log(` reserved prefixes ${String(RESERVED_OWNER_KEY_PREFIXES.length).padStart(4)} ${RESERVED_OWNER_KEY_PREFIXES.join(' ')}`);
541
+ console.log(` found via a constant ${String(viaConstant).padStart(4)} (invisible to a literal-only scan)`);
542
+ console.log(` covered by the denylist ${String(reserved).padStart(4)} ${RESERVED_OWNER_KEY_PREFIXES.join(' ')}`);
543
+ console.log(` under a system identity ${String(systemIdentity).padStart(4)} (out of reach of an owner-scoped token)`);
544
+ console.log(` key not resolvable ${String(unresolved).padStart(4)} (built from runtime values, not judged)`);
545
+ console.log(` exempt, reason written ${String(known.size - unreviewed.length - reasonless.length).padStart(4)}`);
546
+ console.log(` exempt, UNREVIEWED ${String(unreviewed.length).padStart(4)} (backlog, may only shrink)`);
104
547
  console.log(` NEW, not exempt ${String(fresh.length).padStart(4)}`);
105
548
  console.log('');
106
549
  if (fresh.length) {
@@ -109,14 +552,40 @@ function main() {
109
552
  console.log(' in security/trusted-key-exemptions.json why it is user data rather than configuration.');
110
553
  console.log('');
111
554
  for (const f of fresh)
112
- console.log(` ${f.file}:${f.line} ${f.key}`);
555
+ console.log(` ${f.file}:${f.line} ${f.key} (read via ${f.via})`);
556
+ console.log('');
557
+ }
558
+ if (reasonless.length) {
559
+ console.log(' These exemptions name a key and give no reason. A key name is a filing, not a claim:');
560
+ console.log(` write the sentence saying why the server does not act on it (at least ${MIN_REASON} characters),`);
561
+ console.log(` or prefix it with ${UNREVIEWED} so it counts as backlog rather than as an answer.`);
562
+ console.log('');
563
+ for (const k of reasonless)
564
+ console.log(` ${k}`);
565
+ console.log('');
566
+ }
567
+ if (stale.length) {
568
+ console.log(` ${stale.length} exemption(s) match no read any more — delete them, that is the ratchet turning:`);
569
+ for (const k of stale)
570
+ console.log(` ${k}`);
113
571
  console.log('');
114
572
  }
115
- if (strict && fresh.length) {
116
- console.error(`✖ ${fresh.length} new unguarded server-read key(s).`);
573
+ if (strict && (fresh.length || reasonless.length)) {
574
+ const parts = [
575
+ fresh.length ? `${fresh.length} new unguarded server-read key(s)` : '',
576
+ reasonless.length ? `${reasonless.length} exemption(s) without a reason` : '',
577
+ ].filter(Boolean);
578
+ console.error(`✖ ${parts.join(', ')}.`);
117
579
  process.exit(1);
118
580
  }
119
- console.log(fresh.length ? ' (report only — pass --strict to gate)' : ' ✓ no new unguarded server-read keys');
581
+ console.log(fresh.length || reasonless.length
582
+ ? ' (report only — pass --strict to gate)'
583
+ : ' ✓ no new unguarded server-read keys, and every exemption carries a reason');
120
584
  }
121
- main();
585
+ // Run only when invoked as the script. The unit test imports scanSources() to prove the failing
586
+ // cases against a fixture, and an import that gated the whole build as a side effect would be a
587
+ // surprise nobody expects from a function call.
588
+ const invokedDirectly = process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
589
+ if (invokedDirectly)
590
+ main();
122
591
  //# sourceMappingURL=check-trusted-keys.js.map