aimeat 3.2.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 (507) hide show
  1. package/dist/.env.example +58 -1
  2. package/dist/build-stamp.json +4 -4
  3. package/dist/locales/en.json +41 -1
  4. package/dist/locales/es.json +41 -1
  5. package/dist/locales/fi.json +43 -3
  6. package/dist/public/changelog.json +12 -0
  7. package/dist/public/css/views/chat.css +388 -0
  8. package/dist/public/js/services/chat.js +190 -0
  9. package/dist/public/js/services/speech-reader.js +26 -0
  10. package/dist/public/lib/VENDORED.md +1 -0
  11. package/dist/public/lib/duckdb-wasm@1.32.0/duckdb-browser-eh.worker.js +14 -0
  12. package/dist/public/lib/duckdb-wasm@1.32.0/duckdb-browser.js +23 -0
  13. package/dist/public/lib/duckdb-wasm@1.32.0/duckdb-eh.wasm +0 -0
  14. package/dist/public/lib/duckdb-wasm@1.32.0/extensions/v1.4.3/wasm_eh/parquet.duckdb_extension.wasm +0 -0
  15. package/dist/public/lib/vendored-assets.json +19 -0
  16. package/dist/public/llms-full-template.txt +2706 -0
  17. package/dist/public/llms-index-template.txt +60 -0
  18. package/dist/public/robots.node.txt +64 -23
  19. package/dist/public/spa.html +8 -1
  20. package/dist/public/views/chat/parts.js +257 -0
  21. package/dist/public/views/chat.js +327 -0
  22. package/dist/public/views/landing.js +24 -1
  23. package/dist/public/views/profile/agents/scope-model.js +320 -315
  24. package/dist/scripts/audit-mcp-schemas.js +41 -0
  25. package/dist/scripts/audit-mcp-schemas.js.map +1 -1
  26. package/dist/scripts/build-sdk-libs.d.ts.map +1 -1
  27. package/dist/scripts/build-sdk-libs.js +1 -0
  28. package/dist/scripts/build-sdk-libs.js.map +1 -1
  29. package/dist/scripts/check-ai-disclosure.js +11 -0
  30. package/dist/scripts/check-ai-disclosure.js.map +1 -1
  31. package/dist/scripts/check-denial-coverage.d.ts +29 -0
  32. package/dist/scripts/check-denial-coverage.d.ts.map +1 -0
  33. package/dist/scripts/check-denial-coverage.js +237 -0
  34. package/dist/scripts/check-denial-coverage.js.map +1 -0
  35. package/dist/scripts/check-ext-entrypoints.js +14 -2
  36. package/dist/scripts/check-ext-entrypoints.js.map +1 -1
  37. package/dist/scripts/check-outbound-fetch.d.ts.map +1 -1
  38. package/dist/scripts/check-outbound-fetch.js +16 -2
  39. package/dist/scripts/check-outbound-fetch.js.map +1 -1
  40. package/dist/scripts/check-sse-parity.js +14 -0
  41. package/dist/scripts/check-sse-parity.js.map +1 -1
  42. package/dist/scripts/indexnow.js +9 -7
  43. package/dist/scripts/indexnow.js.map +1 -1
  44. package/dist/src/auth/middleware.d.ts +7 -0
  45. package/dist/src/auth/middleware.d.ts.map +1 -1
  46. package/dist/src/auth/middleware.js +15 -21
  47. package/dist/src/auth/middleware.js.map +1 -1
  48. package/dist/src/cli/connect/mcp/tools/agent-tasks.d.ts +4 -0
  49. package/dist/src/cli/connect/mcp/tools/agent-tasks.d.ts.map +1 -1
  50. package/dist/src/cli/connect/mcp/tools/agent-tasks.js +11 -1
  51. package/dist/src/cli/connect/mcp/tools/agent-tasks.js.map +1 -1
  52. package/dist/src/cli/connect/mcp/tools/apps.d.ts.map +1 -1
  53. package/dist/src/cli/connect/mcp/tools/apps.js +88 -0
  54. package/dist/src/cli/connect/mcp/tools/apps.js.map +1 -1
  55. package/dist/src/cli/connect/mcp/tools/core.d.ts +7 -0
  56. package/dist/src/cli/connect/mcp/tools/core.d.ts.map +1 -1
  57. package/dist/src/cli/connect/mcp/tools/core.js +83 -4
  58. package/dist/src/cli/connect/mcp/tools/core.js.map +1 -1
  59. package/dist/src/cli/connect/onboarding-prompt.js +1 -1
  60. package/dist/src/cli/connect/skill-bundle.js +1 -1
  61. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.d.ts +21 -0
  62. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.d.ts.map +1 -0
  63. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.js +137 -0
  64. package/dist/src/cli/connect/tool-call-defs-app-draft-edit.js.map +1 -0
  65. package/dist/src/cli/connect/tool-call-defs-core.d.ts +1 -0
  66. package/dist/src/cli/connect/tool-call-defs-core.d.ts.map +1 -1
  67. package/dist/src/cli/connect/tool-call-defs-core.js +30 -0
  68. package/dist/src/cli/connect/tool-call-defs-core.js.map +1 -1
  69. package/dist/src/cli/connect/tool-call.d.ts.map +1 -1
  70. package/dist/src/cli/connect/tool-call.js +2 -0
  71. package/dist/src/cli/connect/tool-call.js.map +1 -1
  72. package/dist/src/config-types-ai.d.ts +76 -0
  73. package/dist/src/config-types-ai.d.ts.map +1 -0
  74. package/dist/src/config-types-ai.js +15 -0
  75. package/dist/src/config-types-ai.js.map +1 -0
  76. package/dist/src/config-types.d.ts +11 -2
  77. package/dist/src/config-types.d.ts.map +1 -1
  78. package/dist/src/config.d.ts.map +1 -1
  79. package/dist/src/config.js +25 -4
  80. package/dist/src/config.js.map +1 -1
  81. package/dist/src/data/builtin-skills.d.ts.map +1 -1
  82. package/dist/src/data/builtin-skills.js +3 -2
  83. package/dist/src/data/builtin-skills.js.map +1 -1
  84. package/dist/src/data/digital-signage-package.js +1 -1
  85. package/dist/src/data/library-packs/sdk.d.ts.map +1 -1
  86. package/dist/src/data/library-packs/sdk.js +76 -0
  87. package/dist/src/data/library-packs/sdk.js.map +1 -1
  88. package/dist/src/data/library-packs/vendored.d.ts.map +1 -1
  89. package/dist/src/data/library-packs/vendored.js +81 -0
  90. package/dist/src/data/library-packs/vendored.js.map +1 -1
  91. package/dist/src/data/library-packs.d.ts +2 -2
  92. package/dist/src/data/library-packs.js +2 -2
  93. package/dist/src/data/public-pages.d.ts +13 -0
  94. package/dist/src/data/public-pages.d.ts.map +1 -1
  95. package/dist/src/data/public-pages.js +153 -113
  96. package/dist/src/data/public-pages.js.map +1 -1
  97. package/dist/src/generated/api-types.d.ts +1652 -36
  98. package/dist/src/generated/api-types.d.ts.map +1 -1
  99. package/dist/src/index-start.d.ts.map +1 -1
  100. package/dist/src/index-start.js +3 -0
  101. package/dist/src/index-start.js.map +1 -1
  102. package/dist/src/mcp/agent-tasks.d.ts.map +1 -1
  103. package/dist/src/mcp/agent-tasks.js +5 -0
  104. package/dist/src/mcp/agent-tasks.js.map +1 -1
  105. package/dist/src/mcp/ai-image.d.ts +22 -0
  106. package/dist/src/mcp/ai-image.d.ts.map +1 -0
  107. package/dist/src/mcp/ai-image.js +60 -0
  108. package/dist/src/mcp/ai-image.js.map +1 -0
  109. package/dist/src/mcp/annotations.d.ts +5 -0
  110. package/dist/src/mcp/annotations.d.ts.map +1 -1
  111. package/dist/src/mcp/annotations.js +18 -0
  112. package/dist/src/mcp/annotations.js.map +1 -1
  113. package/dist/src/mcp/apps-draft-edit.d.ts +28 -0
  114. package/dist/src/mcp/apps-draft-edit.d.ts.map +1 -0
  115. package/dist/src/mcp/apps-draft-edit.js +164 -0
  116. package/dist/src/mcp/apps-draft-edit.js.map +1 -0
  117. package/dist/src/mcp/apps-screenshot.d.ts +26 -0
  118. package/dist/src/mcp/apps-screenshot.d.ts.map +1 -0
  119. package/dist/src/mcp/apps-screenshot.js +39 -0
  120. package/dist/src/mcp/apps-screenshot.js.map +1 -0
  121. package/dist/src/mcp/catalog/definitions/discovery-work-boards.d.ts +1 -0
  122. package/dist/src/mcp/catalog/definitions/discovery-work-boards.d.ts.map +1 -1
  123. package/dist/src/mcp/catalog/definitions/discovery-work-boards.js +40 -0
  124. package/dist/src/mcp/catalog/definitions/discovery-work-boards.js.map +1 -1
  125. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.d.ts +3 -0
  126. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.d.ts.map +1 -1
  127. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.js +74 -0
  128. package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.js.map +1 -1
  129. package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.d.ts.map +1 -1
  130. package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.js +1 -0
  131. package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.js.map +1 -1
  132. package/dist/src/mcp/catalog/scopes.d.ts.map +1 -1
  133. package/dist/src/mcp/catalog/scopes.js +19 -1
  134. package/dist/src/mcp/catalog/scopes.js.map +1 -1
  135. package/dist/src/mcp/catalog/surfaces.d.ts.map +1 -1
  136. package/dist/src/mcp/catalog/surfaces.js +18 -4
  137. package/dist/src/mcp/catalog/surfaces.js.map +1 -1
  138. package/dist/src/mcp/core-datapackage.d.ts +32 -0
  139. package/dist/src/mcp/core-datapackage.d.ts.map +1 -0
  140. package/dist/src/mcp/core-datapackage.js +188 -0
  141. package/dist/src/mcp/core-datapackage.js.map +1 -0
  142. package/dist/src/mcp/core-storage.d.ts +7 -3
  143. package/dist/src/mcp/core-storage.d.ts.map +1 -1
  144. package/dist/src/mcp/core-storage.js +27 -4
  145. package/dist/src/mcp/core-storage.js.map +1 -1
  146. package/dist/src/mcp/core.d.ts.map +1 -1
  147. package/dist/src/mcp/core.js +3 -0
  148. package/dist/src/mcp/core.js.map +1 -1
  149. package/dist/src/mcp/extensions.d.ts.map +1 -1
  150. package/dist/src/mcp/extensions.js +11 -1
  151. package/dist/src/mcp/extensions.js.map +1 -1
  152. package/dist/src/mcp/index.d.ts +9 -0
  153. package/dist/src/mcp/index.d.ts.map +1 -1
  154. package/dist/src/mcp/index.js +34 -0
  155. package/dist/src/mcp/index.js.map +1 -1
  156. package/dist/src/models/agent-task-schemas.d.ts.map +1 -1
  157. package/dist/src/models/agent-task-schemas.js +12 -1
  158. package/dist/src/models/agent-task-schemas.js.map +1 -1
  159. package/dist/src/models/workflow-schemas.d.ts +178 -1
  160. package/dist/src/models/workflow-schemas.d.ts.map +1 -1
  161. package/dist/src/models/workflow-schemas.js +75 -0
  162. package/dist/src/models/workflow-schemas.js.map +1 -1
  163. package/dist/src/routes/admin-extensions.d.ts +4 -0
  164. package/dist/src/routes/admin-extensions.d.ts.map +1 -1
  165. package/dist/src/routes/admin-extensions.js +135 -142
  166. package/dist/src/routes/admin-extensions.js.map +1 -1
  167. package/dist/src/routes/agent-conventions.d.ts.map +1 -1
  168. package/dist/src/routes/agent-conventions.js +4 -2
  169. package/dist/src/routes/agent-conventions.js.map +1 -1
  170. package/dist/src/routes/agent-docs.d.ts +4 -4
  171. package/dist/src/routes/agent-docs.js +145 -145
  172. package/dist/src/routes/agent-docs.js.map +1 -1
  173. package/dist/src/routes/agent-messages.d.ts +6 -0
  174. package/dist/src/routes/agent-messages.d.ts.map +1 -1
  175. package/dist/src/routes/agent-messages.js +23 -1
  176. package/dist/src/routes/agent-messages.js.map +1 -1
  177. package/dist/src/routes/agent-tasks/create-read.d.ts.map +1 -1
  178. package/dist/src/routes/agent-tasks/create-read.js +8 -1
  179. package/dist/src/routes/agent-tasks/create-read.js.map +1 -1
  180. package/dist/src/routes/agent-tasks/lifecycle.d.ts +4 -1
  181. package/dist/src/routes/agent-tasks/lifecycle.d.ts.map +1 -1
  182. package/dist/src/routes/agent-tasks/lifecycle.js +80 -2
  183. package/dist/src/routes/agent-tasks/lifecycle.js.map +1 -1
  184. package/dist/src/routes/ai.d.ts +5 -0
  185. package/dist/src/routes/ai.d.ts.map +1 -1
  186. package/dist/src/routes/ai.js +51 -1
  187. package/dist/src/routes/ai.js.map +1 -1
  188. package/dist/src/routes/app-grants.d.ts.map +1 -1
  189. package/dist/src/routes/app-grants.js +5 -0
  190. package/dist/src/routes/app-grants.js.map +1 -1
  191. package/dist/src/routes/apps/drafts.d.ts +6 -0
  192. package/dist/src/routes/apps/drafts.d.ts.map +1 -1
  193. package/dist/src/routes/apps/drafts.js +133 -1
  194. package/dist/src/routes/apps/drafts.js.map +1 -1
  195. package/dist/src/routes/apps/read.d.ts.map +1 -1
  196. package/dist/src/routes/apps/read.js +38 -1
  197. package/dist/src/routes/apps/read.js.map +1 -1
  198. package/dist/src/routes/auth-otk.d.ts +28 -0
  199. package/dist/src/routes/auth-otk.d.ts.map +1 -0
  200. package/dist/src/routes/auth-otk.js +190 -0
  201. package/dist/src/routes/auth-otk.js.map +1 -0
  202. package/dist/src/routes/auth.d.ts +17 -0
  203. package/dist/src/routes/auth.d.ts.map +1 -1
  204. package/dist/src/routes/auth.js +44 -153
  205. package/dist/src/routes/auth.js.map +1 -1
  206. package/dist/src/routes/bootstrap.d.ts +6 -0
  207. package/dist/src/routes/bootstrap.d.ts.map +1 -1
  208. package/dist/src/routes/bootstrap.js +47 -20
  209. package/dist/src/routes/bootstrap.js.map +1 -1
  210. package/dist/src/routes/chat.d.ts +23 -0
  211. package/dist/src/routes/chat.d.ts.map +1 -0
  212. package/dist/src/routes/chat.js +165 -0
  213. package/dist/src/routes/chat.js.map +1 -0
  214. package/dist/src/routes/commerce.js +4 -4
  215. package/dist/src/routes/commerce.js.map +1 -1
  216. package/dist/src/routes/datapackages.d.ts +35 -0
  217. package/dist/src/routes/datapackages.d.ts.map +1 -0
  218. package/dist/src/routes/datapackages.js +217 -0
  219. package/dist/src/routes/datapackages.js.map +1 -0
  220. package/dist/src/routes/disputes.d.ts +8 -0
  221. package/dist/src/routes/disputes.d.ts.map +1 -1
  222. package/dist/src/routes/disputes.js +52 -1
  223. package/dist/src/routes/disputes.js.map +1 -1
  224. package/dist/src/routes/ecosystem-apps-advisories.d.ts +16 -0
  225. package/dist/src/routes/ecosystem-apps-advisories.d.ts.map +1 -0
  226. package/dist/src/routes/ecosystem-apps-advisories.js +104 -0
  227. package/dist/src/routes/ecosystem-apps-advisories.js.map +1 -0
  228. package/dist/src/routes/ecosystem-apps.d.ts +6 -0
  229. package/dist/src/routes/ecosystem-apps.d.ts.map +1 -1
  230. package/dist/src/routes/ecosystem-apps.js +31 -99
  231. package/dist/src/routes/ecosystem-apps.js.map +1 -1
  232. package/dist/src/routes/extensions/actions.d.ts.map +1 -1
  233. package/dist/src/routes/extensions/actions.js +29 -1
  234. package/dist/src/routes/extensions/actions.js.map +1 -1
  235. package/dist/src/routes/federation-sync/routing.d.ts.map +1 -1
  236. package/dist/src/routes/federation-sync/routing.js +12 -3
  237. package/dist/src/routes/federation-sync/routing.js.map +1 -1
  238. package/dist/src/routes/glossary.js +1 -1
  239. package/dist/src/routes/glossary.js.map +1 -1
  240. package/dist/src/routes/home/track.d.ts +5 -1
  241. package/dist/src/routes/home/track.d.ts.map +1 -1
  242. package/dist/src/routes/home/track.js +20 -6
  243. package/dist/src/routes/home/track.js.map +1 -1
  244. package/dist/src/routes/instances/install.d.ts +3 -0
  245. package/dist/src/routes/instances/install.d.ts.map +1 -1
  246. package/dist/src/routes/instances/install.js +17 -24
  247. package/dist/src/routes/instances/install.js.map +1 -1
  248. package/dist/src/routes/libs.js +1 -1
  249. package/dist/src/routes/libs.js.map +1 -1
  250. package/dist/src/routes/markdown-mirrors.js +1 -1
  251. package/dist/src/routes/markdown-mirrors.js.map +1 -1
  252. package/dist/src/routes/odata.d.ts +36 -0
  253. package/dist/src/routes/odata.d.ts.map +1 -0
  254. package/dist/src/routes/odata.js +143 -0
  255. package/dist/src/routes/odata.js.map +1 -0
  256. package/dist/src/routes/openrouter.d.ts +4 -0
  257. package/dist/src/routes/openrouter.d.ts.map +1 -1
  258. package/dist/src/routes/openrouter.js +10 -1
  259. package/dist/src/routes/openrouter.js.map +1 -1
  260. package/dist/src/routes/organisms/gates.d.ts.map +1 -1
  261. package/dist/src/routes/organisms/gates.js +9 -2
  262. package/dist/src/routes/organisms/gates.js.map +1 -1
  263. package/dist/src/routes/portal.d.ts +1 -0
  264. package/dist/src/routes/portal.d.ts.map +1 -1
  265. package/dist/src/routes/portal.js +13 -0
  266. package/dist/src/routes/portal.js.map +1 -1
  267. package/dist/src/routes/schedules.d.ts +4 -0
  268. package/dist/src/routes/schedules.d.ts.map +1 -1
  269. package/dist/src/routes/schedules.js +9 -1
  270. package/dist/src/routes/schedules.js.map +1 -1
  271. package/dist/src/routes/storage-files.d.ts +23 -0
  272. package/dist/src/routes/storage-files.d.ts.map +1 -1
  273. package/dist/src/routes/storage-files.js +103 -82
  274. package/dist/src/routes/storage-files.js.map +1 -1
  275. package/dist/src/routes/workflows.d.ts.map +1 -1
  276. package/dist/src/routes/workflows.js +9 -1
  277. package/dist/src/routes/workflows.js.map +1 -1
  278. package/dist/src/server-bootstrap/routes-loader.d.ts +2 -0
  279. package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
  280. package/dist/src/server-bootstrap/routes-loader.js +20 -2
  281. package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
  282. package/dist/src/server-bootstrap/service-init.d.ts.map +1 -1
  283. package/dist/src/server-bootstrap/service-init.js +12 -7
  284. package/dist/src/server-bootstrap/service-init.js.map +1 -1
  285. package/dist/src/server-bootstrap/static-files.d.ts.map +1 -1
  286. package/dist/src/server-bootstrap/static-files.js +44 -10
  287. package/dist/src/server-bootstrap/static-files.js.map +1 -1
  288. package/dist/src/services/ai-allowance.d.ts +82 -0
  289. package/dist/src/services/ai-allowance.d.ts.map +1 -0
  290. package/dist/src/services/ai-allowance.js +117 -0
  291. package/dist/src/services/ai-allowance.js.map +1 -0
  292. package/dist/src/services/ai-completion.d.ts +26 -0
  293. package/dist/src/services/ai-completion.d.ts.map +1 -1
  294. package/dist/src/services/ai-completion.js +41 -13
  295. package/dist/src/services/ai-completion.js.map +1 -1
  296. package/dist/src/services/ai-image.d.ts +70 -0
  297. package/dist/src/services/ai-image.d.ts.map +1 -0
  298. package/dist/src/services/ai-image.js +104 -0
  299. package/dist/src/services/ai-image.js.map +1 -0
  300. package/dist/src/services/ai-model-defaults.d.ts +45 -0
  301. package/dist/src/services/ai-model-defaults.d.ts.map +1 -0
  302. package/dist/src/services/ai-model-defaults.js +42 -0
  303. package/dist/src/services/ai-model-defaults.js.map +1 -0
  304. package/dist/src/services/ai-tool-setup.d.ts +5 -1
  305. package/dist/src/services/ai-tool-setup.d.ts.map +1 -1
  306. package/dist/src/services/ai-tool-setup.js +36 -0
  307. package/dist/src/services/ai-tool-setup.js.map +1 -1
  308. package/dist/src/services/ai-transcription.d.ts +5 -0
  309. package/dist/src/services/ai-transcription.d.ts.map +1 -1
  310. package/dist/src/services/ai-transcription.js +5 -2
  311. package/dist/src/services/ai-transcription.js.map +1 -1
  312. package/dist/src/services/app-agent-surfaces.js +4 -4
  313. package/dist/src/services/app-agent-surfaces.js.map +1 -1
  314. package/dist/src/services/app-draft-edit.d.ts +144 -0
  315. package/dist/src/services/app-draft-edit.d.ts.map +1 -0
  316. package/dist/src/services/app-draft-edit.js +203 -0
  317. package/dist/src/services/app-draft-edit.js.map +1 -0
  318. package/dist/src/services/auth-md.js +2 -2
  319. package/dist/src/services/auth-md.js.map +1 -1
  320. package/dist/src/services/board-write.d.ts +11 -3
  321. package/dist/src/services/board-write.d.ts.map +1 -1
  322. package/dist/src/services/board-write.js +24 -3
  323. package/dist/src/services/board-write.js.map +1 -1
  324. package/dist/src/services/chat-agent.d.ts +36 -0
  325. package/dist/src/services/chat-agent.d.ts.map +1 -0
  326. package/dist/src/services/chat-agent.js +123 -0
  327. package/dist/src/services/chat-agent.js.map +1 -0
  328. package/dist/src/services/chat-session.d.ts +58 -0
  329. package/dist/src/services/chat-session.d.ts.map +1 -0
  330. package/dist/src/services/chat-session.js +151 -0
  331. package/dist/src/services/chat-session.js.map +1 -0
  332. package/dist/src/services/chat-threads.d.ts +61 -0
  333. package/dist/src/services/chat-threads.d.ts.map +1 -0
  334. package/dist/src/services/chat-threads.js +137 -0
  335. package/dist/src/services/chat-threads.js.map +1 -0
  336. package/dist/src/services/config-schema.d.ts.map +1 -1
  337. package/dist/src/services/config-schema.js +2 -1
  338. package/dist/src/services/config-schema.js.map +1 -1
  339. package/dist/src/services/datapackage/contract.d.ts +198 -0
  340. package/dist/src/services/datapackage/contract.d.ts.map +1 -0
  341. package/dist/src/services/datapackage/contract.js +140 -0
  342. package/dist/src/services/datapackage/contract.js.map +1 -0
  343. package/dist/src/services/datapackage/ext-capability.d.ts +85 -0
  344. package/dist/src/services/datapackage/ext-capability.d.ts.map +1 -0
  345. package/dist/src/services/datapackage/ext-capability.js +72 -0
  346. package/dist/src/services/datapackage/ext-capability.js.map +1 -0
  347. package/dist/src/services/datapackage/odata.d.ts +92 -0
  348. package/dist/src/services/datapackage/odata.d.ts.map +1 -0
  349. package/dist/src/services/datapackage/odata.js +256 -0
  350. package/dist/src/services/datapackage/odata.js.map +1 -0
  351. package/dist/src/services/datapackage/odps.d.ts +24 -0
  352. package/dist/src/services/datapackage/odps.d.ts.map +1 -0
  353. package/dist/src/services/datapackage/odps.js +183 -0
  354. package/dist/src/services/datapackage/odps.js.map +1 -0
  355. package/dist/src/services/datapackage/store.d.ts +143 -0
  356. package/dist/src/services/datapackage/store.d.ts.map +1 -0
  357. package/dist/src/services/datapackage/store.js +533 -0
  358. package/dist/src/services/datapackage/store.js.map +1 -0
  359. package/dist/src/services/datapackage/table.d.ts +67 -0
  360. package/dist/src/services/datapackage/table.d.ts.map +1 -0
  361. package/dist/src/services/datapackage/table.js +0 -0
  362. package/dist/src/services/datapackage/table.js.map +1 -0
  363. package/dist/src/services/extension-ctx.d.ts +1 -0
  364. package/dist/src/services/extension-ctx.d.ts.map +1 -1
  365. package/dist/src/services/extension-ctx.js +31 -6
  366. package/dist/src/services/extension-ctx.js.map +1 -1
  367. package/dist/src/services/extension-files.d.ts +20 -0
  368. package/dist/src/services/extension-files.d.ts.map +1 -1
  369. package/dist/src/services/extension-files.js +9 -2
  370. package/dist/src/services/extension-files.js.map +1 -1
  371. package/dist/src/services/extension-lifecycle.d.ts +3 -0
  372. package/dist/src/services/extension-lifecycle.d.ts.map +1 -1
  373. package/dist/src/services/extension-lifecycle.js +2 -26
  374. package/dist/src/services/extension-lifecycle.js.map +1 -1
  375. package/dist/src/services/extension-runtime.d.ts +28 -2
  376. package/dist/src/services/extension-runtime.d.ts.map +1 -1
  377. package/dist/src/services/extension-runtime.js +22 -0
  378. package/dist/src/services/extension-runtime.js.map +1 -1
  379. package/dist/src/services/extension-schedules.d.ts +90 -0
  380. package/dist/src/services/extension-schedules.d.ts.map +1 -0
  381. package/dist/src/services/extension-schedules.js +123 -0
  382. package/dist/src/services/extension-schedules.js.map +1 -0
  383. package/dist/src/services/extension-system-run.d.ts +91 -0
  384. package/dist/src/services/extension-system-run.d.ts.map +1 -0
  385. package/dist/src/services/extension-system-run.js +100 -0
  386. package/dist/src/services/extension-system-run.js.map +1 -0
  387. package/dist/src/services/extension-upsert.d.ts +2 -0
  388. package/dist/src/services/extension-upsert.d.ts.map +1 -1
  389. package/dist/src/services/extension-upsert.js +6 -24
  390. package/dist/src/services/extension-upsert.js.map +1 -1
  391. package/dist/src/services/goose-acp.d.ts +84 -0
  392. package/dist/src/services/goose-acp.d.ts.map +1 -0
  393. package/dist/src/services/goose-acp.js +304 -0
  394. package/dist/src/services/goose-acp.js.map +1 -0
  395. package/dist/src/services/markdown-negotiation.js +1 -1
  396. package/dist/src/services/markdown-negotiation.js.map +1 -1
  397. package/dist/src/services/openrouter.d.ts +20 -1
  398. package/dist/src/services/openrouter.d.ts.map +1 -1
  399. package/dist/src/services/openrouter.js +66 -0
  400. package/dist/src/services/openrouter.js.map +1 -1
  401. package/dist/src/services/prompt-defaults/tiers-core.js +4 -4
  402. package/dist/src/services/scheduler-extension-job.d.ts +29 -6
  403. package/dist/src/services/scheduler-extension-job.d.ts.map +1 -1
  404. package/dist/src/services/scheduler-extension-job.js +29 -75
  405. package/dist/src/services/scheduler-extension-job.js.map +1 -1
  406. package/dist/src/services/scope-vocabulary-migration.d.ts +34 -1
  407. package/dist/src/services/scope-vocabulary-migration.d.ts.map +1 -1
  408. package/dist/src/services/scope-vocabulary-migration.js +60 -0
  409. package/dist/src/services/scope-vocabulary-migration.js.map +1 -1
  410. package/dist/src/services/screenshot-capture.d.ts +40 -1
  411. package/dist/src/services/screenshot-capture.d.ts.map +1 -1
  412. package/dist/src/services/screenshot-capture.js +142 -60
  413. package/dist/src/services/screenshot-capture.js.map +1 -1
  414. package/dist/src/services/skill-bundle/generator.js +1 -1
  415. package/dist/src/services/skill-bundle/generic-adapter.js +1 -1
  416. package/dist/src/services/skill-bundle/hermes-adapter.js +1 -1
  417. package/dist/src/services/storage-file-write.d.ts +36 -1
  418. package/dist/src/services/storage-file-write.d.ts.map +1 -1
  419. package/dist/src/services/storage-file-write.js +49 -3
  420. package/dist/src/services/storage-file-write.js.map +1 -1
  421. package/dist/src/services/task-outcome.d.ts +53 -0
  422. package/dist/src/services/task-outcome.d.ts.map +1 -0
  423. package/dist/src/services/task-outcome.js +28 -0
  424. package/dist/src/services/task-outcome.js.map +1 -0
  425. package/dist/src/services/workflow/engine-human.d.ts +15 -0
  426. package/dist/src/services/workflow/engine-human.d.ts.map +1 -1
  427. package/dist/src/services/workflow/engine-human.js +10 -1
  428. package/dist/src/services/workflow/engine-human.js.map +1 -1
  429. package/dist/src/services/workflow/engine-steps.d.ts +48 -3
  430. package/dist/src/services/workflow/engine-steps.d.ts.map +1 -1
  431. package/dist/src/services/workflow/engine-steps.js +361 -0
  432. package/dist/src/services/workflow/engine-steps.js.map +1 -1
  433. package/dist/src/services/workflow/engine.d.ts +1 -0
  434. package/dist/src/services/workflow/engine.d.ts.map +1 -1
  435. package/dist/src/services/workflow/engine.js +2 -1
  436. package/dist/src/services/workflow/engine.js.map +1 -1
  437. package/dist/src/services/workflow/store.d.ts.map +1 -1
  438. package/dist/src/services/workflow/store.js +60 -4
  439. package/dist/src/services/workflow/store.js.map +1 -1
  440. package/dist/src/services/write-guards.d.ts +27 -1
  441. package/dist/src/services/write-guards.d.ts.map +1 -1
  442. package/dist/src/services/write-guards.js +39 -9
  443. package/dist/src/services/write-guards.js.map +1 -1
  444. package/dist/src/storage/providers/postgres-kysely/db-types.d.ts +1 -0
  445. package/dist/src/storage/providers/postgres-kysely/db-types.d.ts.map +1 -1
  446. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.d.ts +1 -0
  447. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.d.ts.map +1 -1
  448. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.js +3 -0
  449. package/dist/src/storage/providers/postgres-kysely/methods/app-grants.js.map +1 -1
  450. package/dist/src/storage/providers/postgres-kysely/methods/files.d.ts +2 -0
  451. package/dist/src/storage/providers/postgres-kysely/methods/files.d.ts.map +1 -1
  452. package/dist/src/storage/providers/postgres-kysely/methods/files.js +34 -2
  453. package/dist/src/storage/providers/postgres-kysely/methods/files.js.map +1 -1
  454. package/dist/src/storage/providers/postgres-kysely/migrations/0039_storage_file_utf8_verified.sql +19 -0
  455. package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -1
  456. package/dist/src/storage/providers/sqlite/index.js +2 -1
  457. package/dist/src/storage/providers/sqlite/index.js.map +1 -1
  458. package/dist/src/storage/providers/sqlite/methods/apps.d.ts +1 -0
  459. package/dist/src/storage/providers/sqlite/methods/apps.d.ts.map +1 -1
  460. package/dist/src/storage/providers/sqlite/methods/apps.js +33 -28
  461. package/dist/src/storage/providers/sqlite/methods/apps.js.map +1 -1
  462. package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts +1 -12
  463. package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts.map +1 -1
  464. package/dist/src/storage/providers/sqlite/methods/identity-nodes.js +28 -135
  465. package/dist/src/storage/providers/sqlite/methods/identity-nodes.js.map +1 -1
  466. package/dist/src/storage/providers/sqlite/methods/storage-files.d.ts +38 -0
  467. package/dist/src/storage/providers/sqlite/methods/storage-files.d.ts.map +1 -0
  468. package/dist/src/storage/providers/sqlite/methods/storage-files.js +109 -0
  469. package/dist/src/storage/providers/sqlite/methods/storage-files.js.map +1 -0
  470. package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
  471. package/dist/src/storage/providers/sqlite/schema.js +134 -130
  472. package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
  473. package/dist/src/storage/repositories/app-grant.repository.d.ts +11 -0
  474. package/dist/src/storage/repositories/app-grant.repository.d.ts.map +1 -1
  475. package/dist/src/storage/repositories/file.repository.d.ts +13 -0
  476. package/dist/src/storage/repositories/file.repository.d.ts.map +1 -1
  477. package/dist/src/storage/types/commerce.d.ts +6 -0
  478. package/dist/src/storage/types/commerce.d.ts.map +1 -1
  479. package/dist/src/utils/agent-footer.d.ts.map +1 -1
  480. package/dist/src/utils/agent-footer.js +1 -0
  481. package/dist/src/utils/agent-footer.js.map +1 -1
  482. package/dist/src/utils/app-content-type.d.ts +57 -3
  483. package/dist/src/utils/app-content-type.d.ts.map +1 -1
  484. package/dist/src/utils/app-content-type.js +81 -12
  485. package/dist/src/utils/app-content-type.js.map +1 -1
  486. package/dist/src/utils/env-config/sections-features.d.ts.map +1 -1
  487. package/dist/src/utils/env-config/sections-features.js +9 -3
  488. package/dist/src/utils/env-config/sections-features.js.map +1 -1
  489. package/dist/src/utils/file-download-headers.d.ts +5 -3
  490. package/dist/src/utils/file-download-headers.d.ts.map +1 -1
  491. package/dist/src/utils/file-download-headers.js +18 -5
  492. package/dist/src/utils/file-download-headers.js.map +1 -1
  493. package/dist/src/utils/http-range.d.ts +151 -0
  494. package/dist/src/utils/http-range.d.ts.map +1 -0
  495. package/dist/src/utils/http-range.js +190 -0
  496. package/dist/src/utils/http-range.js.map +1 -0
  497. package/dist/src/utils/page-head.d.ts +5 -0
  498. package/dist/src/utils/page-head.d.ts.map +1 -1
  499. package/dist/src/utils/page-head.js +10 -1
  500. package/dist/src/utils/page-head.js.map +1 -1
  501. package/dist/src/utils/reserved-keys.d.ts +4 -1
  502. package/dist/src/utils/reserved-keys.d.ts.map +1 -1
  503. package/dist/src/utils/reserved-keys.js +4 -1
  504. package/dist/src/utils/reserved-keys.js.map +1 -1
  505. package/dist/static/sdk-libs/datapackage/index.js +336 -0
  506. package/dist/static/sdk-libs/dist/aimeat-datapackage.js +305 -0
  507. package/package.json +10 -2
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @file chat-agent.ts
3
+ * @description The person's built-in chat agent: `chat#<owner>@<node>`, a real GAII principal like
4
+ * any other, and the short-lived MCP token one chat session hands to goose.
5
+ *
6
+ * It is a real agent on purpose. It appears in the owner's Agents tab beside the ones they
7
+ * connected themselves, its scopes are edited in the same place, and every tool call it makes is
8
+ * authorised against its own identity by the same MCP surface Claude Desktop talks to. A private
9
+ * side-channel would have been less code and a second permission model.
10
+ *
11
+ * The token is minted per chat session and kept out of storage. It is a bearer credential for the
12
+ * whole of the person's tool surface, and it needs to live exactly as long as the goose session
13
+ * that carries it — the session row makes it revocable, and deleting the agent ends it.
14
+ * @structure
15
+ * - CHAT_AGENT_NAME — the one place the name lives
16
+ * - ensureChatAgent() — find or create the agent, returning its GAII and granted scopes
17
+ * - mintChatAgentToken() — a session-scoped MCP credential for it
18
+ * @usage
19
+ * const agent = await ensureChatAgent(storage, config, ownerName);
20
+ * const { token } = await mintChatAgentToken(storage, config, agent);
21
+ * @version-history
22
+ * v1.0.1 — 2026-08-16 — Write every column the agents table requires. `morselBalance` and `mode`
23
+ * were left off a partial record, which the sqlite schema refuses with a NOT NULL error, so
24
+ * starting a conversation was a 500 on any node with the shipped schema. Found by the first E2E
25
+ * run of the chat routes, not by the developer's own database.
26
+ * v1.0.0 — 2026-08-16 — Initial.
27
+ */
28
+ import { randomBytes } from 'node:crypto';
29
+ import { buildGAII } from '../utils/gaii.js';
30
+ import { generateKeyPair } from '../auth/keypair.js';
31
+ import { issueJWT } from '../auth/jwt.js';
32
+ import { scopesForProfile } from '../mcp/catalog/scopes.js';
33
+ import { emitChange } from './event-bus.js';
34
+ import { logger } from '../utils/logger.js';
35
+ /** The agent's name component. One place, because it appears in a GAII, a UI and a log line. */
36
+ export const CHAT_AGENT_NAME = 'chat';
37
+ /**
38
+ * Find, or create, this owner's chat agent.
39
+ *
40
+ * The scopes come from the standard profile rather than from the owner's own roles. That is
41
+ * invariant 12: a role is granted, never inherited at mint time, and a mint that copied the owner's
42
+ * list would hand a scope-limited surface an unscoped credential. The owner can widen or narrow it
43
+ * afterwards in the Agents tab, which is the point of it being a real agent.
44
+ */
45
+ export async function ensureChatAgent(storage, config, ownerName) {
46
+ const gaii = buildGAII(CHAT_AGENT_NAME, ownerName, config.nodeId);
47
+ const existing = await storage.getAgent(gaii);
48
+ if (existing) {
49
+ return {
50
+ gaii,
51
+ ownerName,
52
+ scopes: existing.defaultScopes ?? [],
53
+ created: false,
54
+ };
55
+ }
56
+ const scopes = capScopes(config, scopesForProfile('agent'));
57
+ const keyPair = await generateKeyPair();
58
+ const now = new Date().toISOString();
59
+ // Every field the agents table requires, in the same shape the device-authorization path writes.
60
+ // `morselBalance` is zero and stays zero: the human pays, and an agent's balance resolves to the
61
+ // owner's GHII everywhere it is spent.
62
+ const record = {
63
+ name: CHAT_AGENT_NAME,
64
+ owner: ownerName,
65
+ gaii,
66
+ displayName: 'Chat',
67
+ description: 'The built-in chat agent. Talks to you in the browser and works through this node.',
68
+ capabilities: ['memory', 'apps'],
69
+ publicKey: keyPair.publicKey,
70
+ defaultScopes: scopes,
71
+ trustScore: 50,
72
+ morselBalance: 0,
73
+ mode: 'interactive',
74
+ createdAt: now,
75
+ lastSeen: now,
76
+ };
77
+ await storage.createAgent(record);
78
+ emitChange('agents', `${ownerName}@${config.nodeId}`);
79
+ logger.info(`[chat] created ${gaii} with ${scopes.length} scope(s)`);
80
+ return { gaii, ownerName, scopes, created: true };
81
+ }
82
+ /**
83
+ * Never grant more than the node allows, whatever the profile says. The profile is a convenience;
84
+ * `maxAgentScopes` is the operator's ceiling and it wins.
85
+ */
86
+ function capScopes(config, wanted) {
87
+ const max = config.maxAgentScopes;
88
+ if (!Array.isArray(max) || max.length === 0 || max.includes('*'))
89
+ return wanted;
90
+ return wanted.filter((s) => max.includes(s));
91
+ }
92
+ /**
93
+ * Mint an MCP credential for one chat session.
94
+ *
95
+ * The session row is what makes it revocable: requireAuth checks the token's `jti` against it, and a
96
+ * token whose session row never existed answers "not revoked" forever. That was a real hole on the
97
+ * device-authorization path once, and this is the same shape of credential.
98
+ *
99
+ * `mcp_client` marks where the session came from, which is what makes the chat show up in the
100
+ * owner's connected-clients list as itself rather than as an anonymous agent.
101
+ */
102
+ export async function mintChatAgentToken(storage, config, agent) {
103
+ const sessionId = `chat-${randomBytes(16).toString('hex')}`;
104
+ const now = new Date().toISOString();
105
+ const expiresAt = new Date(Date.now() + config.agentJwtTtlSeconds * 1000).toISOString();
106
+ const token = await issueJWT({
107
+ sub: agent.gaii,
108
+ owner: agent.ownerName,
109
+ node: config.nodeId,
110
+ roles: ['agent'],
111
+ scopes: agent.scopes,
112
+ mcp_client: 'aimeat-chat',
113
+ }, config.agentJwtTtlSeconds, sessionId);
114
+ await storage.createSession({
115
+ sessionId,
116
+ gaii: agent.gaii,
117
+ owner: agent.ownerName,
118
+ issuedAt: now,
119
+ expiresAt,
120
+ });
121
+ return { token, sessionId, expiresAt };
122
+ }
123
+ //# sourceMappingURL=chat-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-agent.js","sourceRoot":"","sources":["../../../src/services/chat-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,gGAAgG;AAChG,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAStC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACjC,OAAgB,EAAE,MAAoB,EAAE,SAAiB;IAEzD,MAAM,IAAI,GAAG,SAAS,CAAC,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAElE,MAAM,Q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AS,EAAE,SAAS,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @file chat-session.ts
3
+ * @description One turn of the chat, end to end: the person's identity, the agent process, the
4
+ * conversation record, and what came back.
5
+ *
6
+ * The node runs ONE agent process and gives each conversation a session inside it. That is the
7
+ * shape goose supports and the one that scales here: sessions are created on first use and each
8
+ * carries its own MCP server list, so a session speaks to this node as the person who owns it and
9
+ * the tool surface refuses everything they may not do. Fifty people with five talking at once is
10
+ * one process, not fifty.
11
+ *
12
+ * Session ids belong to a running process. When the agent restarts, every id it handed out means
13
+ * nothing, so they are stamped with the generation that issued them and a stale one is silently
14
+ * replaced rather than used. The conversation itself is unaffected: it lives in the person's
15
+ * memory, and goose's own store is a cache.
16
+ * @structure
17
+ * - chatEnabled() — whether this node has an agent at all
18
+ * - runChatTurn() — the whole turn, yielding updates as they happen and persisting both sides
19
+ * - shutdownChat() — stop the agent process
20
+ * @usage
21
+ * for await (const u of runChatTurn({ storage, config }, ownerName, threadId, text)) { … }
22
+ * @version-history
23
+ * v1.0.1 — 2026-08-16 — The work log keys tool calls by id rather than title. Only the opening
24
+ * event carries a title, so every call stayed at "starting" no matter how it ended. Seen in a
25
+ * browser against a real agent, where one completed call read as still running.
26
+ * v1.0.0 — 2026-08-16 — Initial.
27
+ */
28
+ import type { AimeatConfig } from '../config.js';
29
+ import type { Storage } from '../storage/interface.js';
30
+ import { type SessionUpdate } from './goose-acp.js';
31
+ export interface ChatDeps {
32
+ storage: Storage;
33
+ config: AimeatConfig;
34
+ }
35
+ /** Whether this node has a chat agent configured at all. */
36
+ export declare function chatEnabled(config: AimeatConfig): boolean;
37
+ /** Stop the agent. Called from the node's shutdown hook. */
38
+ export declare function shutdownChat(): void;
39
+ /**
40
+ * Run one turn.
41
+ *
42
+ * The person's own words are written down BEFORE the agent is asked anything: a turn that fails
43
+ * halfway should leave the conversation showing what was said, not an empty gap. The agent's side is
44
+ * written when the turn ends, with the tools it used and the model that answered — the model per
45
+ * turn, because a node that falls back to a free model when an allowance runs out has to be able to
46
+ * say which turn that was.
47
+ */
48
+ export declare function runChatTurn(deps: ChatDeps, ownerName: string, threadId: string, text: string): AsyncGenerator<SessionUpdate>;
49
+ /**
50
+ * Forget the goose session a conversation was on, so the next turn starts a fresh one.
51
+ *
52
+ * This is what a scope change needs: the session's MCP token carries the scopes it was minted with,
53
+ * so widening or narrowing them in the Agents tab has to reach the chat somehow. Dropping the
54
+ * session is that somehow, and it costs one handshake rather than a reconnect the person has to
55
+ * perform — which was the original complaint this whole feature answers.
56
+ */
57
+ export declare function resetChatSession(deps: ChatDeps, gaii: string, threadId: string): Promise<void>;
58
+ //# sourceMappingURL=chat-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-session.d.ts","sourceRoot":"","sources":["../../../src/services/chat-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAMrF,MAAM,WAAW,QAAQ;IAAG,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE;AAOpE,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAEzD;AAuBD,4DAA4D;AAC5D,wBAAgB,YAAY,IAAI,IAAI,CAGnC;AAsCD;;;;;;;;GAQG;AACH,wBAAuB,WAAW,CAC9B,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAClE,cAAc,CAAC,aAAa,CAAC,CAyD/B;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAClC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAC/C,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -0,0 +1,151 @@
1
+ import { GooseAcpClient, aimeatMcpServer } from './goose-acp.js';
2
+ import { ensureChatAgent, mintChatAgentToken } from './chat-agent.js';
3
+ import { appendTurn, readThread, setGooseSession } from './chat-threads.js';
4
+ import { resolveGhii } from '../utils/ghii-resolver.js';
5
+ import { logger } from '../utils/logger.js';
6
+ /** The single agent process, and which generation it is. */
7
+ let client = null;
8
+ let generation = 0;
9
+ let starting = null;
10
+ /** Whether this node has a chat agent configured at all. */
11
+ export function chatEnabled(config) {
12
+ return !!(config.gooseBin || '').trim();
13
+ }
14
+ /**
15
+ * The agent process, started on first use.
16
+ *
17
+ * Concurrent first turns share one start rather than racing into two processes, which is the same
18
+ * reason goose's own session manager holds a per-session creation lock.
19
+ */
20
+ async function agent(config) {
21
+ if (client)
22
+ return client;
23
+ if (starting)
24
+ return starting;
25
+ starting = GooseAcpClient.start(config)
26
+ .then((c) => {
27
+ client = c;
28
+ generation++;
29
+ logger.info(`[chat] agent process started (generation ${generation})`);
30
+ return c;
31
+ })
32
+ .finally(() => { starting = null; });
33
+ return starting;
34
+ }
35
+ /** Stop the agent. Called from the node's shutdown hook. */
36
+ export function shutdownChat() {
37
+ client?.close();
38
+ client = null;
39
+ }
40
+ /** A goose session id is only meaningful for the process that issued it. */
41
+ function stamp(sessionId) {
42
+ return `${generation}:${sessionId}`;
43
+ }
44
+ function unstamp(stamped) {
45
+ if (!stamped)
46
+ return null;
47
+ const [gen, ...rest] = stamped.split(':');
48
+ return Number(gen) === generation ? rest.join(':') : null;
49
+ }
50
+ /**
51
+ * Get, or create, the goose session this conversation runs on.
52
+ *
53
+ * The MCP token is minted per session and never stored: it is a bearer credential for the whole of
54
+ * the person's tool surface, and it should live exactly as long as the session that carries it.
55
+ */
56
+ async function sessionFor(deps, ownerName, gaii, threadId) {
57
+ const { storage, config } = deps;
58
+ const thread = await readThread(storage, gaii, threadId);
59
+ const existing = unstamp(thread?.gooseSessionId);
60
+ if (existing)
61
+ return existing;
62
+ const identity = await ensureChatAgent(storage, config, ownerName);
63
+ const { token } = await mintChatAgentToken(storage, config, identity);
64
+ const acp = await agent(config);
65
+ const sessionId = await acp.newSession({
66
+ mcpServers: [aimeatMcpServer(config.baseUrl, token)],
67
+ });
68
+ await setGooseSession(storage, gaii, threadId, stamp(sessionId));
69
+ logger.info(`[chat] ${identity.gaii} -> goose session ${sessionId} for thread ${threadId}`);
70
+ return sessionId;
71
+ }
72
+ /**
73
+ * Run one turn.
74
+ *
75
+ * The person's own words are written down BEFORE the agent is asked anything: a turn that fails
76
+ * halfway should leave the conversation showing what was said, not an empty gap. The agent's side is
77
+ * written when the turn ends, with the tools it used and the model that answered — the model per
78
+ * turn, because a node that falls back to a free model when an allowance runs out has to be able to
79
+ * say which turn that was.
80
+ */
81
+ export async function* runChatTurn(deps, ownerName, threadId, text) {
82
+ const { storage, config } = deps;
83
+ if (!chatEnabled(config)) {
84
+ yield { kind: 'error', message: 'This node has no chat agent configured.' };
85
+ return;
86
+ }
87
+ const gaii = await resolveGhii(storage, ownerName, `${ownerName}@${config.nodeId}`);
88
+ const now = new Date().toISOString();
89
+ await appendTurn(storage, gaii, threadId, { role: 'user', text, at: now });
90
+ let sessionId;
91
+ try {
92
+ sessionId = await sessionFor(deps, ownerName, gaii, threadId);
93
+ }
94
+ catch (err) {
95
+ const message = err.message;
96
+ logger.warn(`[chat] could not open a session for ${ownerName}: ${message}`);
97
+ yield { kind: 'error', message };
98
+ return;
99
+ }
100
+ const acp = await agent(config);
101
+ // Keyed by the call's OWN id, not its title. A tool call arrives twice — once as it starts and
102
+ // once as it finishes — and only the first carries a title, so matching on the title leaves
103
+ // every call in the log reading "starting" forever, whatever actually happened to it.
104
+ const tools = new Map();
105
+ let answer = '';
106
+ try {
107
+ for await (const update of acp.prompt(sessionId, text)) {
108
+ if (update.kind === 'text')
109
+ answer += update.text;
110
+ if (update.kind === 'tool_call') {
111
+ const key = update.id || update.title;
112
+ const seen = tools.get(key);
113
+ if (seen) {
114
+ seen.status = update.status;
115
+ if (update.title)
116
+ seen.title = update.title;
117
+ }
118
+ else {
119
+ tools.set(key, { title: update.title, status: update.status });
120
+ }
121
+ }
122
+ yield update;
123
+ }
124
+ }
125
+ finally {
126
+ // Written even when the turn ended badly: half an answer and the tools that ran is a truer
127
+ // record than nothing, and it is what the person saw on screen.
128
+ const turn = {
129
+ role: 'agent',
130
+ text: answer,
131
+ at: new Date().toISOString(),
132
+ ...(tools.size ? { tools: [...tools.values()] } : {}),
133
+ };
134
+ await appendTurn(storage, gaii, threadId, turn).catch((e) => {
135
+ logger.warn(`[chat] could not save the agent turn: ${e.message}`);
136
+ return null;
137
+ });
138
+ }
139
+ }
140
+ /**
141
+ * Forget the goose session a conversation was on, so the next turn starts a fresh one.
142
+ *
143
+ * This is what a scope change needs: the session's MCP token carries the scopes it was minted with,
144
+ * so widening or narrowing them in the Agents tab has to reach the chat somehow. Dropping the
145
+ * session is that somehow, and it costs one handshake rather than a reconnect the person has to
146
+ * perform — which was the original complaint this whole feature answers.
147
+ */
148
+ export async function resetChatSession(deps, gaii, threadId) {
149
+ await setGooseSession(deps.storage, gaii, threadId, undefined);
150
+ }
151
+ //# sourceMappingURL=chat-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-session.js","sourceRoot":"","sources":["../../../src/services/chat-session.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAsB,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAiB,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,4DAA4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AC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAClC,IAAc,EAAE,IAAY,EAAE,QAAgB;IAE9C,MAAM,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { AimeatConfig } from '../config.js';
2
+ import type { Storage } from '../storage/interface.js';
3
+ /** One thing said, by either side, with whatever the agent did while saying it. */
4
+ export interface ChatTurn {
5
+ role: 'user' | 'agent';
6
+ text: string;
7
+ at: string;
8
+ /** Compact record of the tool calls this turn made, for the work log. */
9
+ tools?: Array<{
10
+ title: string;
11
+ status: string;
12
+ }>;
13
+ /** Which model answered. Shown per turn, so "quality may vary" is checkable. */
14
+ model?: string;
15
+ }
16
+ export interface ChatThread {
17
+ id: string;
18
+ title: string;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ /** goose's own session id, if one is currently attached. A cache: the turns are the truth. */
22
+ gooseSessionId?: string;
23
+ turns: ChatTurn[];
24
+ }
25
+ declare const LIVE_PREFIX = "chat.thread.";
26
+ declare const ARCHIVE_PREFIX = "chat.archive.";
27
+ /** How many conversations stay open before the oldest rolls into the month's archive. */
28
+ declare const MAX_LIVE_THREADS = 50;
29
+ /**
30
+ * How much of one conversation is kept. A memory value tops out at 1024 kB, and a thread that grew
31
+ * past it would fail to save — losing the newest turn, which is the one that mattered. Trimming the
32
+ * oldest turns keeps the record writable and the recent context intact; goose does its own
33
+ * compaction for what the model sees.
34
+ */
35
+ declare const MAX_TURNS_PER_THREAD = 400;
36
+ /** Start a conversation. The title is a placeholder until the first turn gives it a better one. */
37
+ export declare function createThread(storage: Storage, config: AimeatConfig, gaii: string, title?: string): Promise<ChatThread>;
38
+ export declare function readThread(storage: Storage, gaii: string, id: string): Promise<ChatThread | null>;
39
+ /** Every live conversation, newest first. */
40
+ export declare function listThreads(storage: Storage, gaii: string): Promise<ChatThread[]>;
41
+ /** Attach (or forget) the goose session a conversation is currently running on. */
42
+ export declare function setGooseSession(storage: Storage, gaii: string, id: string, gooseSessionId: string | undefined): Promise<void>;
43
+ /**
44
+ * Add one turn. Returns the thread as stored.
45
+ *
46
+ * The first thing a person says becomes the title, because a list of conversations all called "New
47
+ * chat" is a list nobody can use.
48
+ */
49
+ export declare function appendTurn(storage: Storage, gaii: string, id: string, turn: ChatTurn): Promise<ChatThread | null>;
50
+ /** Throw a conversation away entirely. */
51
+ export declare function deleteThread(storage: Storage, gaii: string, id: string): Promise<void>;
52
+ /**
53
+ * Roll the oldest conversations into the month they belong to, once there are more open than the
54
+ * ceiling allows.
55
+ *
56
+ * Archived conversations stay readable — they are one record per month rather than one each — and
57
+ * the key count stops growing with use, which is the whole point.
58
+ */
59
+ export declare function archiveOverflow(storage: Storage, config: AimeatConfig, gaii: string): Promise<number>;
60
+ export { MAX_LIVE_THREADS, MAX_TURNS_PER_THREAD, LIVE_PREFIX, ARCHIVE_PREFIX };
61
+ //# sourceMappingURL=chat-threads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-threads.d.ts","sourceRoot":"","sources":["../../../src/services/chat-threads.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvD,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,yEAAyE;IACzE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACvB,EAAE,EA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AE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5F;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACjC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GACrD,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * @file chat-threads.ts
3
+ * @description Where a chat conversation lives: the person's own memory, under `chat.`.
4
+ *
5
+ * Goose keeps its own session store, and it is a cache. The conversation is the person's, so the
6
+ * record here is the truth: if the agent process is replaced, restarted or swapped for a different
7
+ * engine entirely, the conversation survives.
8
+ *
9
+ * The shape is chosen against a ceiling that is easy to walk into. A memory namespace holds 1000
10
+ * keys, and five conversations a day is 1825 keys a year, so one key per conversation forever is
11
+ * the wrong shape. Live conversations get a key each, because a person opens one at a time and
12
+ * expects to find it; older ones roll into one record per month. The same rule the node applies to
13
+ * anything that writes on a schedule: if keys per day times 365 exceeds 1000, the shape is wrong.
14
+ * @structure
15
+ * - ChatThread / ChatTurn — the record
16
+ * - createThread() · appendTurn() · readThread() · listThreads() · archiveOverflow()
17
+ * @usage
18
+ * const thread = await createThread(storage, config, gaii, 'Pong');
19
+ * await appendTurn(storage, config, gaii, thread.id, { role: 'user', text: 'build me pong' });
20
+ * @version-history
21
+ * v1.0.0 — 2026-08-16 — Initial.
22
+ */
23
+ import { randomBytes } from 'node:crypto';
24
+ import { logger } from '../utils/logger.js';
25
+ const LIVE_PREFIX = 'chat.thread.';
26
+ const ARCHIVE_PREFIX = 'chat.archive.';
27
+ /** How many conversations stay open before the oldest rolls into the month's archive. */
28
+ const MAX_LIVE_THREADS = 50;
29
+ /**
30
+ * How much of one conversation is kept. A memory value tops out at 1024 kB, and a thread that grew
31
+ * past it would fail to save — losing the newest turn, which is the one that mattered. Trimming the
32
+ * oldest turns keeps the record writable and the recent context intact; goose does its own
33
+ * compaction for what the model sees.
34
+ */
35
+ const MAX_TURNS_PER_THREAD = 400;
36
+ const liveKey = (id) => `${LIVE_PREFIX}${id}`;
37
+ const archiveKey = (month) => `${ARCHIVE_PREFIX}${month}`;
38
+ const monthOf = (iso) => iso.slice(0, 7);
39
+ async function writeRecord(storage, gaii, key, value, tags) {
40
+ const now = new Date().toISOString();
41
+ const existing = await storage.getMemory(gaii, key);
42
+ await storage.setMemory({
43
+ key, ownerGaii: gaii, value: value,
44
+ visibility: 'private', tags, ttlHours: null,
45
+ version: existing ? existing.version + 1 : 1,
46
+ createdAt: existing?.createdAt ?? now,
47
+ updatedAt: now,
48
+ });
49
+ }
50
+ /** Start a conversation. The title is a placeholder until the first turn gives it a better one. */
51
+ export async function createThread(storage, config, gaii, title = 'New chat') {
52
+ const now = new Date().toISOString();
53
+ const thread = {
54
+ id: randomBytes(9).toString('base64url'),
55
+ title, createdAt: now, updatedAt: now, turns: [],
56
+ };
57
+ await writeRecord(storage, gaii, liveKey(thread.id), thread, ['chat', 'thread']);
58
+ await archiveOverflow(storage, config, gaii);
59
+ return thread;
60
+ }
61
+ export async function readThread(storage, gaii, id) {
62
+ const rec = await storage.getMemory(gaii, liveKey(id));
63
+ return rec?.value ?? null;
64
+ }
65
+ /** Every live conversation, newest first. */
66
+ export async function listThreads(storage, gaii) {
67
+ const records = await storage.listMemory(gaii, { prefix: LIVE_PREFIX });
68
+ return records
69
+ .map((r) => r.value)
70
+ .filter((t) => !!t && typeof t.id === 'string')
71
+ .sort((a, b) => (b.updatedAt ?? '').localeCompare(a.updatedAt ?? ''));
72
+ }
73
+ /** Attach (or forget) the goose session a conversation is currently running on. */
74
+ export async function setGooseSession(storage, gaii, id, gooseSessionId) {
75
+ const thread = await readThread(storage, gaii, id);
76
+ if (!thread)
77
+ return;
78
+ thread.gooseSessionId = gooseSessionId;
79
+ thread.updatedAt = new Date().toISOString();
80
+ await writeRecord(storage, gaii, liveKey(id), thread, ['chat', 'thread']);
81
+ }
82
+ /**
83
+ * Add one turn. Returns the thread as stored.
84
+ *
85
+ * The first thing a person says becomes the title, because a list of conversations all called "New
86
+ * chat" is a list nobody can use.
87
+ */
88
+ export async function appendTurn(storage, gaii, id, turn) {
89
+ const thread = await readThread(storage, gaii, id);
90
+ if (!thread)
91
+ return null;
92
+ thread.turns.push(turn);
93
+ if (thread.turns.length > MAX_TURNS_PER_THREAD) {
94
+ const dropped = thread.turns.length - MAX_TURNS_PER_THREAD;
95
+ thread.turns = thread.turns.slice(dropped);
96
+ logger.info(`[chat] thread ${id}: dropped ${dropped} oldest turn(s) to stay under the value ceiling`);
97
+ }
98
+ if (thread.title === 'New chat' && turn.role === 'user' && turn.text.trim()) {
99
+ thread.title = turn.text.trim().slice(0, 60);
100
+ }
101
+ thread.updatedAt = turn.at;
102
+ await writeRecord(storage, gaii, liveKey(id), thread, ['chat', 'thread']);
103
+ return thread;
104
+ }
105
+ /** Throw a conversation away entirely. */
106
+ export async function deleteThread(storage, gaii, id) {
107
+ await storage.deleteMemory(gaii, liveKey(id));
108
+ }
109
+ /**
110
+ * Roll the oldest conversations into the month they belong to, once there are more open than the
111
+ * ceiling allows.
112
+ *
113
+ * Archived conversations stay readable — they are one record per month rather than one each — and
114
+ * the key count stops growing with use, which is the whole point.
115
+ */
116
+ export async function archiveOverflow(storage, config, gaii) {
117
+ const max = Math.max(1, config.chatMaxLiveThreads);
118
+ const threads = await listThreads(storage, gaii);
119
+ if (threads.length <= max)
120
+ return 0;
121
+ const overflow = threads.slice(max);
122
+ let archived = 0;
123
+ for (const thread of overflow) {
124
+ const month = monthOf(thread.updatedAt ?? thread.createdAt ?? new Date().toISOString());
125
+ const key = archiveKey(month);
126
+ const existing = (await storage.getMemory(gaii, key))?.value;
127
+ const bundle = { threads: [...(existing?.threads ?? []), thread] };
128
+ await writeRecord(storage, gaii, key, bundle, ['chat', 'archive']);
129
+ await storage.deleteMemory(gaii, liveKey(thread.id));
130
+ archived++;
131
+ }
132
+ if (archived > 0)
133
+ logger.info(`[chat] archived ${archived} conversation(s) for ${gaii}`);
134
+ return archived;
135
+ }
136
+ export { MAX_LIVE_THREADS, MAX_TURNS_PER_THREAD, LIVE_PREFIX, ARCHIVE_PREFIX };
137
+ //# sourceMappingURL=chat-threads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-threads.js","sourceRoot":"","sources":["../../../src/services/chat-threads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAuB5C,MAAM,WAAW,GAAG,cAAc,CAAC;AACnC,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC,yFAAyF;AACzF,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,MAAM,OAAO,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,GAAG,WAAW,GAAG,EAAE,EAAE,CAAC;AACtD,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,cAAc,GAAG,KAAK,EAAE,CAAC;AAClE,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjD,KAAK,UAAU,WAAW,CACtB,OAAgB,EAAE,IAAY,EAAE,GAAW,EAAE,KAAc,EAAE,IAAc;IAE3E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,OAAO,CAAC,SAAS,CAAC;QACpB,GAAG,EAAE,SAAS,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AAM,CAAM,CAAC;AAW1D,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAa5E;AAED,wDAAwD;AACxD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAG3D"}
@@ -107,7 +107,8 @@ export const CONFIG_FIELDS = [
107
107
  { key: 'commerceEnabled', dotPath: 'commerce.enabled', envVar: 'AIMEAT_COMMERCE_ENABLED', type: 'boolean', validate: v => typeof v === 'boolean', immutable: false, description: 'Checkout sessions (/v1/commerce) enabled' },
108
108
  { key: 'commerceSessionTtlMinutes', dotPath: 'commerce.session_ttl_minutes', envVar: 'AIMEAT_COMMERCE_SESSION_TTL_MINUTES', type: 'number', validate: v => typeof v === 'number' && Number.isInteger(v) && v >= 5 && v <= 10080, immutable: false, description: 'Open checkout-session lifetime in minutes', range: '5-10080' },
109
109
  { key: 'mcpCardCommerceTools', dotPath: 'commerce.mcp_card_tools', envVar: 'AIMEAT_MCP_CARD_COMMERCE_TOOLS', type: 'string', validate: v => v === 'inline' || v === 'pointer', immutable: false, description: 'MCP Server Card commerce_tools mode: inline (embed priced app-tool catalog) or pointer (link /v1/commerce/tools)' },
110
- { key: 'contentSignal', dotPath: 'site.content_signal', envVar: 'AIMEAT_CONTENT_SIGNAL', type: 'string', validate: v => typeof v === 'string' && /^(off|(search|ai-input|ai-train)=(yes|no)(\s*,\s*(search|ai-input|ai-train)=(yes|no)){0,2})$/i.test(v.trim()), immutable: false, description: 'robots.txt Content Signals Policy directive (contentsignals.org), e.g. "search=yes, ai-input=yes, ai-train=no"; "off" removes it' },
110
+ { key: 'contentSignal', dotPath: 'site.content_signal', envVar: 'AIMEAT_CONTENT_SIGNAL', type: 'string', validate: v => typeof v === 'string' && (v.trim() === '' || /^(off|(search|ai-input|ai-train)=(yes|no)(\s*,\s*(search|ai-input|ai-train)=(yes|no)){0,2})$/i.test(v.trim())), immutable: false, description: 'robots.txt Content Signals Policy directive (contentsignals.org), e.g. "search=yes, ai-input=yes, ai-train=no"; "off" removes it; empty pairs it to AIMEAT_AI_TRAINING' },
111
+ { key: 'aiTraining', dotPath: 'site.ai_training', envVar: 'AIMEAT_AI_TRAINING', type: 'string', validate: v => v === 'allow' || v === 'deny', immutable: false, description: 'Allow AI training crawlers in robots.txt ("allow" | "deny"). Search and retrieval bots are always allowed' },
111
112
  { key: 'webBotAuthSign', dotPath: 'federation.web_bot_auth_sign', envVar: 'AIMEAT_WEB_BOT_AUTH_SIGN', type: 'boolean', validate: v => typeof v === 'boolean', immutable: false, description: 'Sign outbound HTTP with the node Ed25519 key (RFC 9421 Web Bot Auth); the key directory is always served' },
112
113
  // ── Extensions (Phase 2.7, mutable) ──
113
114
  { key: 'extensionsEnabled', dotPath: 'extensions.enabled', envVar: 'AIMEAT_EXTENSIONS_ENABLED', type: 'boolean', validate: v => typeof v === 'boolean', immutable: false, description: 'Sandboxed extension system enabled' },