aimeat 2.0.0 → 2.1.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 (412) hide show
  1. package/dist/locales/en.json +35 -1
  2. package/dist/locales/fi.json +35 -1
  3. package/dist/public/components/LinkPreview.js +101 -0
  4. package/dist/public/components/NotificationBell.js +18 -1
  5. package/dist/public/css/theme.css +57 -7
  6. package/dist/public/css/views/admin.css +8 -1
  7. package/dist/public/css/views/app-grant.css +18 -0
  8. package/dist/public/css/views/inbox.css +46 -0
  9. package/dist/public/css/views/portfolio.css +46 -0
  10. package/dist/public/css/views/profile.css +29 -4
  11. package/dist/public/js/services/apps.js +19 -3
  12. package/dist/public/js/services/messages-ai-prompts.js +38 -0
  13. package/dist/public/js/services/messages.js +26 -4
  14. package/dist/public/js/services/notebook.js +76 -0
  15. package/dist/public/js/services/unfurl.js +43 -0
  16. package/dist/public/lib/samples/LICENSE.md +11 -0
  17. package/dist/public/lib/samples/bass/A1.mp3 +0 -0
  18. package/dist/public/lib/samples/bass/B2.mp3 +0 -0
  19. package/dist/public/lib/samples/bass/D2.mp3 +0 -0
  20. package/dist/public/lib/samples/bass/E1.mp3 +0 -0
  21. package/dist/public/lib/samples/bass/E3.mp3 +0 -0
  22. package/dist/public/lib/samples/bass/G2.mp3 +0 -0
  23. package/dist/public/lib/samples/epiano/C2.mp3 +0 -0
  24. package/dist/public/lib/samples/epiano/C3.mp3 +0 -0
  25. package/dist/public/lib/samples/epiano/C4.mp3 +0 -0
  26. package/dist/public/lib/samples/epiano/C5.mp3 +0 -0
  27. package/dist/public/lib/samples/epiano/C6.mp3 +0 -0
  28. package/dist/public/lib/samples/epiano/G2.mp3 +0 -0
  29. package/dist/public/lib/samples/epiano/G3.mp3 +0 -0
  30. package/dist/public/lib/samples/epiano/G4.mp3 +0 -0
  31. package/dist/public/lib/samples/epiano/G5.mp3 +0 -0
  32. package/dist/public/lib/samples/guitar-steel/A2.mp3 +0 -0
  33. package/dist/public/lib/samples/guitar-steel/A4.mp3 +0 -0
  34. package/dist/public/lib/samples/guitar-steel/B3.mp3 +0 -0
  35. package/dist/public/lib/samples/guitar-steel/D3.mp3 +0 -0
  36. package/dist/public/lib/samples/guitar-steel/E2.mp3 +0 -0
  37. package/dist/public/lib/samples/guitar-steel/E4.mp3 +0 -0
  38. package/dist/public/lib/samples/guitar-steel/E5.mp3 +0 -0
  39. package/dist/public/lib/samples/guitar-steel/G3.mp3 +0 -0
  40. package/dist/public/lib/samples/organ/C2.mp3 +0 -0
  41. package/dist/public/lib/samples/organ/C3.mp3 +0 -0
  42. package/dist/public/lib/samples/organ/C4.mp3 +0 -0
  43. package/dist/public/lib/samples/organ/C5.mp3 +0 -0
  44. package/dist/public/lib/samples/organ/C6.mp3 +0 -0
  45. package/dist/public/lib/samples/organ/G2.mp3 +0 -0
  46. package/dist/public/lib/samples/organ/G3.mp3 +0 -0
  47. package/dist/public/lib/samples/organ/G4.mp3 +0 -0
  48. package/dist/public/lib/samples/organ/G5.mp3 +0 -0
  49. package/dist/public/lib/samples/strings/C2.mp3 +0 -0
  50. package/dist/public/lib/samples/strings/C3.mp3 +0 -0
  51. package/dist/public/lib/samples/strings/C4.mp3 +0 -0
  52. package/dist/public/lib/samples/strings/C5.mp3 +0 -0
  53. package/dist/public/lib/samples/strings/C6.mp3 +0 -0
  54. package/dist/public/lib/samples/strings/G2.mp3 +0 -0
  55. package/dist/public/lib/samples/strings/G3.mp3 +0 -0
  56. package/dist/public/lib/samples/strings/G4.mp3 +0 -0
  57. package/dist/public/lib/samples/strings/G5.mp3 +0 -0
  58. package/dist/public/lib/samples/trumpet/A3.mp3 +0 -0
  59. package/dist/public/lib/samples/trumpet/A4.mp3 +0 -0
  60. package/dist/public/lib/samples/trumpet/A5.mp3 +0 -0
  61. package/dist/public/lib/samples/trumpet/C4.mp3 +0 -0
  62. package/dist/public/lib/samples/trumpet/C5.mp3 +0 -0
  63. package/dist/public/lib/samples/trumpet/E3.mp3 +0 -0
  64. package/dist/public/lib/samples/trumpet/E4.mp3 +0 -0
  65. package/dist/public/lib/samples/trumpet/E5.mp3 +0 -0
  66. package/dist/public/spa.html +2 -0
  67. package/dist/public/views/app-grant.js +24 -4
  68. package/dist/public/views/portfolio.js +61 -6
  69. package/dist/public/views/profile/apps-tab.js +18 -1
  70. package/dist/public/views/profile/inbox-tab/ai-actions.js +86 -0
  71. package/dist/public/views/profile/inbox-tab/components.js +124 -9
  72. package/dist/public/views/profile/inbox-tab/helpers.js +26 -0
  73. package/dist/public/views/profile/inbox-tab/panels.js +18 -3
  74. package/dist/public/views/profile/inbox-tab/use-thread-ux.js +18 -1
  75. package/dist/public/views/profile/inbox-tab.js +46 -49
  76. package/dist/public/views/profile/landing-page.cards.js +7 -0
  77. package/dist/public/views/profile/landing-page.js +12 -1
  78. package/dist/public/views/profile/skills-tab.js +1 -1
  79. package/dist/public/views/public-workspace-viewer.js +1 -1
  80. package/dist/public/views/start.js +2 -1
  81. package/dist/scripts/build-sdk-libs.d.ts +16 -0
  82. package/dist/scripts/build-sdk-libs.d.ts.map +1 -0
  83. package/dist/scripts/build-sdk-libs.js +112 -0
  84. package/dist/scripts/build-sdk-libs.js.map +1 -0
  85. package/dist/src/cli/connect/auth.d.ts +15 -0
  86. package/dist/src/cli/connect/auth.d.ts.map +1 -1
  87. package/dist/src/cli/connect/auth.js +25 -6
  88. package/dist/src/cli/connect/auth.js.map +1 -1
  89. package/dist/src/cli/connect/keychain.d.ts +9 -0
  90. package/dist/src/cli/connect/keychain.d.ts.map +1 -1
  91. package/dist/src/cli/connect/keychain.js +21 -8
  92. package/dist/src/cli/connect/keychain.js.map +1 -1
  93. package/dist/src/cli/connect/mcp/tools/exchange.d.ts +18 -0
  94. package/dist/src/cli/connect/mcp/tools/exchange.d.ts.map +1 -0
  95. package/dist/src/cli/connect/mcp/tools/exchange.js +170 -0
  96. package/dist/src/cli/connect/mcp/tools/exchange.js.map +1 -0
  97. package/dist/src/cli/connect/mcp/tools/index.d.ts.map +1 -1
  98. package/dist/src/cli/connect/mcp/tools/index.js +2 -0
  99. package/dist/src/cli/connect/mcp/tools/index.js.map +1 -1
  100. package/dist/src/cli/connect/tool-call-defs-exchange.d.ts +3 -0
  101. package/dist/src/cli/connect/tool-call-defs-exchange.d.ts.map +1 -0
  102. package/dist/src/cli/connect/tool-call-defs-exchange.js +146 -0
  103. package/dist/src/cli/connect/tool-call-defs-exchange.js.map +1 -0
  104. package/dist/src/cli/connect/tool-call.d.ts.map +1 -1
  105. package/dist/src/cli/connect/tool-call.js +2 -0
  106. package/dist/src/cli/connect/tool-call.js.map +1 -1
  107. package/dist/src/commerce/session-service.d.ts +14 -0
  108. package/dist/src/commerce/session-service.d.ts.map +1 -1
  109. package/dist/src/commerce/session-service.js +1 -1
  110. package/dist/src/commerce/session-service.js.map +1 -1
  111. package/dist/src/data/app-templates/shells.d.ts +7 -3
  112. package/dist/src/data/app-templates/shells.d.ts.map +1 -1
  113. package/dist/src/data/app-templates/shells.js +10 -6
  114. package/dist/src/data/app-templates/shells.js.map +1 -1
  115. package/dist/src/data/appdev-pitfalls.d.ts +2 -0
  116. package/dist/src/data/appdev-pitfalls.d.ts.map +1 -1
  117. package/dist/src/data/appdev-pitfalls.js +24 -1
  118. package/dist/src/data/appdev-pitfalls.js.map +1 -1
  119. package/dist/src/generated/api-types.d.ts +1565 -9
  120. package/dist/src/generated/api-types.d.ts.map +1 -1
  121. package/dist/src/mcp/annotations.d.ts.map +1 -1
  122. package/dist/src/mcp/annotations.js +20 -0
  123. package/dist/src/mcp/annotations.js.map +1 -1
  124. package/dist/src/mcp/apps.d.ts.map +1 -1
  125. package/dist/src/mcp/apps.js +8 -4
  126. package/dist/src/mcp/apps.js.map +1 -1
  127. package/dist/src/mcp/catalog/definitions/exchange.d.ts +18 -0
  128. package/dist/src/mcp/catalog/definitions/exchange.d.ts.map +1 -0
  129. package/dist/src/mcp/catalog/definitions/exchange.js +182 -0
  130. package/dist/src/mcp/catalog/definitions/exchange.js.map +1 -0
  131. package/dist/src/mcp/catalog/definitions.d.ts.map +1 -1
  132. package/dist/src/mcp/catalog/definitions.js +2 -0
  133. package/dist/src/mcp/catalog/definitions.js.map +1 -1
  134. package/dist/src/mcp/catalog/scopes.d.ts.map +1 -1
  135. package/dist/src/mcp/catalog/scopes.js +22 -0
  136. package/dist/src/mcp/catalog/scopes.js.map +1 -1
  137. package/dist/src/mcp/catalog/surfaces.d.ts.map +1 -1
  138. package/dist/src/mcp/catalog/surfaces.js +14 -0
  139. package/dist/src/mcp/catalog/surfaces.js.map +1 -1
  140. package/dist/src/mcp/exchange-run.d.ts +5 -0
  141. package/dist/src/mcp/exchange-run.d.ts.map +1 -0
  142. package/dist/src/mcp/exchange-run.js +226 -0
  143. package/dist/src/mcp/exchange-run.js.map +1 -0
  144. package/dist/src/mcp/exchange.d.ts +5 -0
  145. package/dist/src/mcp/exchange.d.ts.map +1 -0
  146. package/dist/src/mcp/exchange.js +351 -0
  147. package/dist/src/mcp/exchange.js.map +1 -0
  148. package/dist/src/mcp/extensions.d.ts.map +1 -1
  149. package/dist/src/mcp/extensions.js +11 -0
  150. package/dist/src/mcp/extensions.js.map +1 -1
  151. package/dist/src/mcp/index.d.ts.map +1 -1
  152. package/dist/src/mcp/index.js +6 -2
  153. package/dist/src/mcp/index.js.map +1 -1
  154. package/dist/src/models/app-tool-schemas.d.ts +55 -1
  155. package/dist/src/models/app-tool-schemas.d.ts.map +1 -1
  156. package/dist/src/models/app-tool-schemas.js +20 -1
  157. package/dist/src/models/app-tool-schemas.js.map +1 -1
  158. package/dist/src/models/offer-schemas.d.ts +2 -2
  159. package/dist/src/models/schemas.d.ts +1 -0
  160. package/dist/src/models/schemas.d.ts.map +1 -1
  161. package/dist/src/models/schemas.js +3 -0
  162. package/dist/src/models/schemas.js.map +1 -1
  163. package/dist/src/routes/agents/device-auth.d.ts +4 -0
  164. package/dist/src/routes/agents/device-auth.d.ts.map +1 -1
  165. package/dist/src/routes/agents/device-auth.js +19 -4
  166. package/dist/src/routes/agents/device-auth.js.map +1 -1
  167. package/dist/src/routes/app-grants.d.ts +6 -0
  168. package/dist/src/routes/app-grants.d.ts.map +1 -1
  169. package/dist/src/routes/app-grants.js +35 -2
  170. package/dist/src/routes/app-grants.js.map +1 -1
  171. package/dist/src/routes/apps/fork-manage.d.ts.map +1 -1
  172. package/dist/src/routes/apps/fork-manage.js +24 -1
  173. package/dist/src/routes/apps/fork-manage.js.map +1 -1
  174. package/dist/src/routes/apps/publish.d.ts +2 -0
  175. package/dist/src/routes/apps/publish.d.ts.map +1 -1
  176. package/dist/src/routes/apps/publish.js +27 -1
  177. package/dist/src/routes/apps/publish.js.map +1 -1
  178. package/dist/src/routes/apps-cost.d.ts +25 -0
  179. package/dist/src/routes/apps-cost.d.ts.map +1 -0
  180. package/dist/src/routes/apps-cost.js +107 -0
  181. package/dist/src/routes/apps-cost.js.map +1 -0
  182. package/dist/src/routes/exchange-market.d.ts +28 -0
  183. package/dist/src/routes/exchange-market.d.ts.map +1 -0
  184. package/dist/src/routes/exchange-market.js +454 -0
  185. package/dist/src/routes/exchange-market.js.map +1 -0
  186. package/dist/src/routes/exchange.d.ts +33 -0
  187. package/dist/src/routes/exchange.d.ts.map +1 -0
  188. package/dist/src/routes/exchange.js +395 -0
  189. package/dist/src/routes/exchange.js.map +1 -0
  190. package/dist/src/routes/extensions/entitlement-gate.d.ts +33 -0
  191. package/dist/src/routes/extensions/entitlement-gate.d.ts.map +1 -0
  192. package/dist/src/routes/extensions/entitlement-gate.js +143 -0
  193. package/dist/src/routes/extensions/entitlement-gate.js.map +1 -0
  194. package/dist/src/routes/extensions/manifest.d.ts +9 -0
  195. package/dist/src/routes/extensions/manifest.d.ts.map +1 -1
  196. package/dist/src/routes/extensions/manifest.js +33 -1
  197. package/dist/src/routes/extensions/manifest.js.map +1 -1
  198. package/dist/src/routes/extensions/paywall.d.ts.map +1 -1
  199. package/dist/src/routes/extensions/paywall.js +9 -0
  200. package/dist/src/routes/extensions/paywall.js.map +1 -1
  201. package/dist/src/routes/federation-sync/messaging.d.ts.map +1 -1
  202. package/dist/src/routes/federation-sync/messaging.js +3 -1
  203. package/dist/src/routes/federation-sync/messaging.js.map +1 -1
  204. package/dist/src/routes/ghii/recovery.d.ts +2 -0
  205. package/dist/src/routes/ghii/recovery.d.ts.map +1 -1
  206. package/dist/src/routes/ghii/recovery.js +7 -0
  207. package/dist/src/routes/ghii/recovery.js.map +1 -1
  208. package/dist/src/routes/ghii/register-login.d.ts +4 -0
  209. package/dist/src/routes/ghii/register-login.d.ts.map +1 -1
  210. package/dist/src/routes/ghii/register-login.js +45 -22
  211. package/dist/src/routes/ghii/register-login.js.map +1 -1
  212. package/dist/src/routes/ghii/web-verify.d.ts +5 -0
  213. package/dist/src/routes/ghii/web-verify.d.ts.map +1 -1
  214. package/dist/src/routes/ghii/web-verify.js +24 -3
  215. package/dist/src/routes/ghii/web-verify.js.map +1 -1
  216. package/dist/src/routes/libs/sdk-serve.d.ts +11 -0
  217. package/dist/src/routes/libs/sdk-serve.d.ts.map +1 -0
  218. package/dist/src/routes/libs/sdk-serve.js +53 -0
  219. package/dist/src/routes/libs/sdk-serve.js.map +1 -0
  220. package/dist/src/routes/libs.d.ts +7 -1
  221. package/dist/src/routes/libs.d.ts.map +1 -1
  222. package/dist/src/routes/libs.js +65 -146
  223. package/dist/src/routes/libs.js.map +1 -1
  224. package/dist/src/routes/messages.d.ts +3 -0
  225. package/dist/src/routes/messages.d.ts.map +1 -1
  226. package/dist/src/routes/messages.js +9 -0
  227. package/dist/src/routes/messages.js.map +1 -1
  228. package/dist/src/routes/notifications.d.ts +6 -3
  229. package/dist/src/routes/notifications.d.ts.map +1 -1
  230. package/dist/src/routes/notifications.js +32 -3
  231. package/dist/src/routes/notifications.js.map +1 -1
  232. package/dist/src/routes/organisms/workspace-access.d.ts.map +1 -1
  233. package/dist/src/routes/organisms/workspace-access.js +38 -20
  234. package/dist/src/routes/organisms/workspace-access.js.map +1 -1
  235. package/dist/src/routes/unfurl.d.ts +27 -0
  236. package/dist/src/routes/unfurl.d.ts.map +1 -0
  237. package/dist/src/routes/unfurl.js +180 -0
  238. package/dist/src/routes/unfurl.js.map +1 -0
  239. package/dist/src/routes/upload.d.ts +2 -0
  240. package/dist/src/routes/upload.d.ts.map +1 -1
  241. package/dist/src/routes/upload.js +7 -0
  242. package/dist/src/routes/upload.js.map +1 -1
  243. package/dist/src/routes/webmcp.d.ts +3 -0
  244. package/dist/src/routes/webmcp.d.ts.map +1 -1
  245. package/dist/src/routes/webmcp.js +55 -0
  246. package/dist/src/routes/webmcp.js.map +1 -1
  247. package/dist/src/server-bootstrap/routes-loader.d.ts +1 -0
  248. package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
  249. package/dist/src/server-bootstrap/routes-loader.js +8 -0
  250. package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
  251. package/dist/src/services/agent-face.d.ts +10 -2
  252. package/dist/src/services/agent-face.d.ts.map +1 -1
  253. package/dist/src/services/agent-face.js +10 -4
  254. package/dist/src/services/agent-face.js.map +1 -1
  255. package/dist/src/services/app-tool-interfaces.d.ts +37 -0
  256. package/dist/src/services/app-tool-interfaces.d.ts.map +1 -0
  257. package/dist/src/services/app-tool-interfaces.js +101 -0
  258. package/dist/src/services/app-tool-interfaces.js.map +1 -0
  259. package/dist/src/services/build-app-prompt.d.ts +3 -0
  260. package/dist/src/services/build-app-prompt.d.ts.map +1 -1
  261. package/dist/src/services/build-app-prompt.js +12 -1
  262. package/dist/src/services/build-app-prompt.js.map +1 -1
  263. package/dist/src/services/contacts.d.ts +25 -1
  264. package/dist/src/services/contacts.d.ts.map +1 -1
  265. package/dist/src/services/contacts.js +30 -0
  266. package/dist/src/services/contacts.js.map +1 -1
  267. package/dist/src/services/entitlement-money.d.ts +55 -0
  268. package/dist/src/services/entitlement-money.d.ts.map +1 -0
  269. package/dist/src/services/entitlement-money.js +68 -0
  270. package/dist/src/services/entitlement-money.js.map +1 -0
  271. package/dist/src/services/exchange-market.d.ts +247 -0
  272. package/dist/src/services/exchange-market.d.ts.map +1 -0
  273. package/dist/src/services/exchange-market.js +254 -0
  274. package/dist/src/services/exchange-market.js.map +1 -0
  275. package/dist/src/services/exchange-proposals.d.ts +47 -0
  276. package/dist/src/services/exchange-proposals.d.ts.map +1 -0
  277. package/dist/src/services/exchange-proposals.js +71 -0
  278. package/dist/src/services/exchange-proposals.js.map +1 -0
  279. package/dist/src/services/exchange-work.d.ts +30 -0
  280. package/dist/src/services/exchange-work.d.ts.map +1 -0
  281. package/dist/src/services/exchange-work.js +43 -0
  282. package/dist/src/services/exchange-work.js.map +1 -0
  283. package/dist/src/services/message-send.d.ts.map +1 -1
  284. package/dist/src/services/message-send.js +4 -1
  285. package/dist/src/services/message-send.js.map +1 -1
  286. package/dist/src/services/metered-entitlements.d.ts +203 -0
  287. package/dist/src/services/metered-entitlements.d.ts.map +1 -0
  288. package/dist/src/services/metered-entitlements.js +264 -0
  289. package/dist/src/services/metered-entitlements.js.map +1 -0
  290. package/dist/src/services/notify.d.ts +7 -0
  291. package/dist/src/services/notify.d.ts.map +1 -1
  292. package/dist/src/services/notify.js +35 -0
  293. package/dist/src/services/notify.js.map +1 -1
  294. package/dist/src/services/owner-memory.d.ts +16 -0
  295. package/dist/src/services/owner-memory.d.ts.map +1 -1
  296. package/dist/src/services/owner-memory.js +23 -0
  297. package/dist/src/services/owner-memory.js.map +1 -1
  298. package/dist/src/services/owner-provisioning.d.ts +5 -0
  299. package/dist/src/services/owner-provisioning.d.ts.map +1 -1
  300. package/dist/src/services/owner-provisioning.js +20 -2
  301. package/dist/src/services/owner-provisioning.js.map +1 -1
  302. package/dist/src/storage/providers/postgres-kysely/methods/apps.d.ts +1 -0
  303. package/dist/src/storage/providers/postgres-kysely/methods/apps.d.ts.map +1 -1
  304. package/dist/src/storage/providers/postgres-kysely/methods/apps.js +2 -0
  305. package/dist/src/storage/providers/postgres-kysely/methods/apps.js.map +1 -1
  306. package/dist/src/storage/providers/postgres-kysely/methods/identity.d.ts +1 -0
  307. package/dist/src/storage/providers/postgres-kysely/methods/identity.d.ts.map +1 -1
  308. package/dist/src/storage/providers/postgres-kysely/methods/identity.js +4 -0
  309. package/dist/src/storage/providers/postgres-kysely/methods/identity.js.map +1 -1
  310. package/dist/src/storage/providers/postgres-kysely/migrations/0011_unique_verified_email.sql +25 -0
  311. package/dist/src/storage/providers/sqlite/methods/apps.d.ts +1 -0
  312. package/dist/src/storage/providers/sqlite/methods/apps.d.ts.map +1 -1
  313. package/dist/src/storage/providers/sqlite/methods/apps.js +2 -0
  314. package/dist/src/storage/providers/sqlite/methods/apps.js.map +1 -1
  315. package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts +1 -0
  316. package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts.map +1 -1
  317. package/dist/src/storage/providers/sqlite/methods/identity-nodes.js +4 -0
  318. package/dist/src/storage/providers/sqlite/methods/identity-nodes.js.map +1 -1
  319. package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
  320. package/dist/src/storage/providers/sqlite/schema.js +20 -0
  321. package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
  322. package/dist/src/storage/repositories/app.repository.d.ts +0 -0
  323. package/dist/src/storage/repositories/app.repository.d.ts.map +1 -1
  324. package/dist/src/storage/repositories/identity.repository.d.ts +6 -0
  325. package/dist/src/storage/repositories/identity.repository.d.ts.map +1 -1
  326. package/dist/src/storage/types/apps.d.ts +1 -0
  327. package/dist/src/storage/types/apps.d.ts.map +1 -1
  328. package/dist/src/storage/types/organisms-federation.d.ts +21 -0
  329. package/dist/src/storage/types/organisms-federation.d.ts.map +1 -1
  330. package/dist/src/utils/app-mobile-lint.d.ts +17 -0
  331. package/dist/src/utils/app-mobile-lint.d.ts.map +1 -0
  332. package/dist/src/utils/app-mobile-lint.js +40 -0
  333. package/dist/src/utils/app-mobile-lint.js.map +1 -0
  334. package/dist/static/app-catalog/_template.html +12 -77
  335. package/dist/static/app-catalog/js/apps-io.js +51 -165
  336. package/dist/static/app-catalog/js/cost.js +100 -0
  337. package/dist/static/app-catalog/js/db.js +23 -93
  338. package/dist/static/app-catalog/js/detail.js +158 -24
  339. package/dist/static/app-catalog/js/favorites.js +71 -0
  340. package/dist/static/app-catalog/js/i18n-data.js +90 -16
  341. package/dist/static/app-catalog/js/main.js +23 -103
  342. package/dist/static/app-catalog/js/migrate.js +88 -0
  343. package/dist/static/app-catalog/js/monetize.js +1 -1
  344. package/dist/static/app-catalog/js/promote.js +70 -0
  345. package/dist/static/app-catalog/js/render.js +26 -139
  346. package/dist/static/app-catalog/js/server-io.js +126 -223
  347. package/dist/static/app-catalog/js/settings.js +11 -204
  348. package/dist/static/app-catalog/styles/app-catalog.css +40 -0
  349. package/dist/static/app-catalog.html +790 -912
  350. package/dist/static/sdk-libs/_core/config.js +52 -0
  351. package/dist/static/sdk-libs/_core/http.js +52 -0
  352. package/dist/static/sdk-libs/_core/namespace.js +33 -0
  353. package/dist/static/sdk-libs/_core/sdk-globals.d.ts +50 -0
  354. package/dist/static/sdk-libs/_core/session.js +66 -0
  355. package/dist/static/sdk-libs/agentface/index.js +102 -0
  356. package/dist/static/sdk-libs/agents/index.js +267 -0
  357. package/dist/static/sdk-libs/ai/index.js +153 -0
  358. package/dist/static/sdk-libs/audio/core.js +111 -0
  359. package/dist/static/sdk-libs/audio/index.js +380 -0
  360. package/dist/static/sdk-libs/audio/instruments.js +369 -0
  361. package/dist/static/sdk-libs/auth/config.js +46 -0
  362. package/dist/static/sdk-libs/auth/crypto.js +166 -0
  363. package/dist/static/sdk-libs/auth/events.js +27 -0
  364. package/dist/static/sdk-libs/auth/i18n.js +64 -0
  365. package/dist/static/sdk-libs/auth/index.js +37 -0
  366. package/dist/static/sdk-libs/auth/modal.js +545 -0
  367. package/dist/static/sdk-libs/auth/pill.js +167 -0
  368. package/dist/static/sdk-libs/auth/session.js +792 -0
  369. package/dist/static/sdk-libs/auth/signup.js +232 -0
  370. package/dist/static/sdk-libs/auth/theme.js +96 -0
  371. package/dist/static/sdk-libs/capabilities/index.js +179 -0
  372. package/dist/static/sdk-libs/commerce/index.js +243 -0
  373. package/dist/static/sdk-libs/data/index.js +188 -0
  374. package/dist/static/sdk-libs/dist/aimeat-agentface.js +91 -0
  375. package/dist/static/sdk-libs/dist/aimeat-agents.js +315 -0
  376. package/dist/static/sdk-libs/dist/aimeat-ai.js +168 -0
  377. package/dist/static/sdk-libs/dist/aimeat-audio.js +979 -0
  378. package/dist/static/sdk-libs/dist/aimeat-auth.js +1831 -0
  379. package/dist/static/sdk-libs/dist/aimeat-capabilities.js +177 -0
  380. package/dist/static/sdk-libs/dist/aimeat-commerce.js +265 -0
  381. package/dist/static/sdk-libs/dist/aimeat-data.js +205 -0
  382. package/dist/static/sdk-libs/dist/aimeat-editor.js +299 -0
  383. package/dist/static/sdk-libs/dist/aimeat-header.js +270 -0
  384. package/dist/static/sdk-libs/dist/aimeat-intake.js +94 -0
  385. package/dist/static/sdk-libs/dist/aimeat-live.js +265 -0
  386. package/dist/static/sdk-libs/dist/aimeat-markdown.js +602 -0
  387. package/dist/static/sdk-libs/dist/aimeat-organism.js +394 -0
  388. package/dist/static/sdk-libs/dist/aimeat-portfolio-standalone.js +90 -0
  389. package/dist/static/sdk-libs/dist/aimeat-social.js +157 -0
  390. package/dist/static/sdk-libs/dist/aimeat-speech.js +300 -0
  391. package/dist/static/sdk-libs/dist/aimeat-storage.js +210 -0
  392. package/dist/static/sdk-libs/dist/aimeat-tunnel.js +383 -0
  393. package/dist/static/sdk-libs/dist/aimeat-wallet.js +118 -0
  394. package/dist/static/sdk-libs/dist/aimeat-webmcp.js +187 -0
  395. package/dist/static/sdk-libs/dist/aimeat-work.js +213 -0
  396. package/dist/static/sdk-libs/dist/aimeat-workflows.js +147 -0
  397. package/dist/static/sdk-libs/editor/index.js +229 -0
  398. package/dist/static/sdk-libs/header/index.js +249 -0
  399. package/dist/static/sdk-libs/intake/index.js +75 -0
  400. package/dist/static/sdk-libs/live/index.js +156 -0
  401. package/dist/static/sdk-libs/markdown/index.js +522 -0
  402. package/dist/static/sdk-libs/organism/index.js +381 -0
  403. package/dist/static/sdk-libs/portfolio-standalone/index.js +78 -0
  404. package/dist/static/sdk-libs/social/index.js +140 -0
  405. package/dist/static/sdk-libs/speech/index.js +321 -0
  406. package/dist/static/sdk-libs/storage/index.js +189 -0
  407. package/dist/static/sdk-libs/tunnel/index.js +428 -0
  408. package/dist/static/sdk-libs/wallet/index.js +115 -0
  409. package/dist/static/sdk-libs/webmcp/index.js +185 -0
  410. package/dist/static/sdk-libs/work/index.js +191 -0
  411. package/dist/static/sdk-libs/workflows/index.js +113 -0
  412. package/package.json +5 -2
@@ -0,0 +1,381 @@
1
+ /**
2
+ * @file organism/index.js
3
+ * @description The aimeat-organism library (SDK-libs migration Phase 1). Organism/workspace content
4
+ * client for standalone published apps: wraps the workspace read contract (objects[] published +
5
+ * drafts[] as a separate map, merged by value.id with _meta handling) that apps otherwise
6
+ * re-derive and get wrong, plus organism/workspace CRUD, draft/publish/revert/delete (incl. the
7
+ * bulk publishRecords/deleteRecords bridge), readme, search, and a util namespace. Over the
8
+ * AIMEAT.auth session. Componentized ESM source esbuild bundles to the IIFE served, unchanged, at
9
+ * /v1/libs/aimeat-organism.js. Ported verbatim from lib-organism.ts; getSession/authFetch stay
10
+ * inline (authFetch keeps the defensive Response.json() reparse branch _core/session lacks).
11
+ * @structure imports attach (namespace); field/normalize helpers; the `organism` object + util;
12
+ * attach('organism', …).
13
+ * @usage <script src="/v1/libs/aimeat-auth.js"></script><script src="/v1/libs/aimeat-organism.js"></script>
14
+ * const ws = await AIMEAT.organism.read(orgId, wsId); ws.spaces[0].items[0].value
15
+ * @version-history
16
+ * v1.0.0 — 2026-07-19 — Migrated from src/routes/lib-organism.ts (SDK-libs migration Phase 1).
17
+ */
18
+ import { attach } from '../_core/namespace.js';
19
+
20
+ function getSession() {
21
+ if (!window.AIMEAT || !window.AIMEAT.auth) {
22
+ throw new Error('AIMEAT.auth is required. Include aimeat-auth.js before aimeat-organism.js');
23
+ }
24
+ var s = window.AIMEAT.auth.getSession();
25
+ if (!s) throw new Error('Not logged in. Call AIMEAT.auth.login() first.');
26
+ return s;
27
+ }
28
+ async function authFetch(path, opts) {
29
+ var res = await getSession().fetch(path, opts);
30
+ if (res && typeof res.json === 'function') res = await res.json();
31
+ return res;
32
+ }
33
+ function fail(res, fallback) {
34
+ var e = /** @type {Error & { code?: string, envelope?: unknown }} */ (new Error((res && res.error && (res.error.message || res.error.code)) || fallback));
35
+ e.code = res && res.error && res.error.code;
36
+ e.envelope = res;
37
+ return e;
38
+ }
39
+
40
+ // ── field conventions (mirror the SPA + AIMEAT Pages) ──
41
+ var TITLE_FIELDS = ['title', 'name', 'subject', 'label'];
42
+ var BODY_FIELDS = ['content', 'body', 'markdown', 'text', 'md', 'description', 'summary'];
43
+
44
+ function pickField(obj, names) {
45
+ if (!obj || typeof obj !== 'object') return null;
46
+ for (var i = 0; i < names.length; i++) if (typeof obj[names[i]] === 'string') return names[i];
47
+ return null;
48
+ }
49
+ function isMetaField(k) { return typeof k === 'string' && k.charAt(0) === '_'; }
50
+ // Read metadata (_createdAt/_updatedAt/_version) is merged into values by the workspace read;
51
+ // it must never be written back, so every write path strips it.
52
+ function stripMeta(v) {
53
+ if (!v || typeof v !== 'object' || Array.isArray(v)) return v;
54
+ var out = {};
55
+ Object.keys(v).forEach(function (k) { if (!isMetaField(k)) out[k] = v[k]; });
56
+ return out;
57
+ }
58
+ function slugify(s) {
59
+ return String(s || 'untitled').toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g, '')
60
+ .replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40) || 'untitled';
61
+ }
62
+ function titleOf(value, fallbackId) {
63
+ var v = value || {};
64
+ var f = pickField(v, TITLE_FIELDS);
65
+ if (f && v[f]) return v[f];
66
+ if (typeof v.id === 'string' && v.id) return v.id;
67
+ var bf = pickField(v, BODY_FIELDS);
68
+ if (bf && typeof v[bf] === 'string' && v[bf]) return String(v[bf]).replace(/\s+/g, ' ').slice(0, 48);
69
+ return fallbackId || 'Untitled';
70
+ }
71
+ function bodyFieldOf(value) { return pickField(value, BODY_FIELDS); }
72
+ function isDocLike(value) {
73
+ var bf = bodyFieldOf(value);
74
+ if (!bf || !value || typeof value[bf] !== 'string') return false;
75
+ return bf === 'markdown' || bf === 'content' || value[bf].length > 120 || /\n/.test(value[bf]);
76
+ }
77
+ function valueUpdatedAt(v) {
78
+ if (v && typeof v === 'object' && (v._updatedAt || v._createdAt)) {
79
+ var t = new Date(v._updatedAt || v._createdAt).getTime();
80
+ return isNaN(t) ? 0 : t;
81
+ }
82
+ return 0;
83
+ }
84
+
85
+ // ── key layout: one workspace lives under organism.{orgId}.w.{wsId} ──
86
+ function wsRoot(orgId, wsId) {
87
+ return 'organism.' + orgId + (wsId ? '.w.' + wsId : '');
88
+ }
89
+ function draftKey(orgId, wsId, namespace, id) {
90
+ return wsRoot(orgId, wsId) + '.' + namespace + '.' + id + '.draft';
91
+ }
92
+
93
+ // ── workspace read normalization ──
94
+ // data.objects[type] = published values, data.drafts[type] = draft values (separate map!).
95
+ // Both are bare values; the instance id lives in value.id. Items without one get a synthetic
96
+ // id and hasRealId:false — they cannot be saved or published (the real key id is unknown).
97
+ function normalizeWorkspace(data) {
98
+ var manifest = (data && data.manifest) || null;
99
+ var otList = (manifest && (manifest.objectTypes || manifest.object_types || manifest.types)) || [];
100
+ if (!Array.isArray(otList) && otList && typeof otList === 'object') {
101
+ otList = Object.keys(otList).map(function (k) {
102
+ var o = otList[k]; o = (o && typeof o === 'object') ? o : {};
103
+ if (!o.name) o.name = k;
104
+ return o;
105
+ });
106
+ }
107
+ var byName = {};
108
+ otList.forEach(function (ot) { var n = ot.name || ot.id || ot.type; if (n) byName[n] = ot; });
109
+
110
+ var objects = (data && data.objects) || {};
111
+ var draftsMap = (data && data.drafts) || {};
112
+ var typeNames = [];
113
+ otList.forEach(function (ot) { var n = ot.name || ot.id || ot.type; if (n && typeNames.indexOf(n) < 0) typeNames.push(n); });
114
+ Object.keys(objects).forEach(function (n) { if (typeNames.indexOf(n) < 0) typeNames.push(n); });
115
+ Object.keys(draftsMap).forEach(function (n) { if (typeNames.indexOf(n) < 0) typeNames.push(n); });
116
+
117
+ return typeNames.map(function (typeName) {
118
+ var ot = byName[typeName] || {};
119
+ var instances = {};
120
+ var order = [];
121
+ var seq = 0;
122
+ function instIdOf(v) {
123
+ if (v && typeof v === 'object' && typeof v.id === 'string' && v.id) return { id: v.id, real: true };
124
+ if (v && typeof v === 'object') {
125
+ var tf = pickField(v, TITLE_FIELDS);
126
+ if (tf && v[tf]) return { id: 't-' + slugify(v[tf]), real: false };
127
+ }
128
+ return { id: 'item-' + (seq++), real: false };
129
+ }
130
+ function add(v, slot) {
131
+ if (v == null) return;
132
+ var m = instIdOf(v);
133
+ if (!instances[m.id]) { instances[m.id] = { id: m.id, hasRealId: m.real, draft: null, latest: null }; order.push(m.id); }
134
+ if (slot === 'draft') instances[m.id].draft = v; else instances[m.id].latest = instances[m.id].latest || v;
135
+ }
136
+ var pub = objects[typeName] || []; if (!Array.isArray(pub)) pub = [pub];
137
+ pub.forEach(function (v) { add(v, 'latest'); });
138
+ var dr = draftsMap[typeName] || []; if (!Array.isArray(dr)) dr = [dr];
139
+ dr.forEach(function (v) { add(v, 'draft'); });
140
+
141
+ var items = order.map(function (id) {
142
+ var inst = instances[id];
143
+ var best = inst.draft || inst.latest;
144
+ inst.value = best;
145
+ inst.title = titleOf(best, id);
146
+ inst.updatedAt = Math.max(valueUpdatedAt(inst.draft), valueUpdatedAt(inst.latest));
147
+ inst.status = inst.draft && inst.latest ? 'draft+published' : (inst.draft ? 'draft' : 'published');
148
+ return inst;
149
+ });
150
+ return {
151
+ name: typeName,
152
+ namespace: ot.namespace || ot.ns || typeName,
153
+ kind: ot.kind || ot.type || null,
154
+ schemaRef: ot.schemaRef || null,
155
+ writeRole: ot.writeRole || null,
156
+ items: items,
157
+ };
158
+ });
159
+ }
160
+ function readmeText(readme) {
161
+ if (readme == null) return '';
162
+ if (typeof readme === 'string') return readme;
163
+ if (typeof readme === 'object') return readme.content || readme.text || readme.markdown || JSON.stringify(readme, null, 2);
164
+ return String(readme);
165
+ }
166
+
167
+ var organism = {
168
+ // List organisms the signed-in owner is a member of.
169
+ async list() {
170
+ var s = getSession();
171
+ var owner = s.owner || (s.user && s.user.owner) || '';
172
+ var res;
173
+ try { res = await authFetch('/v1/organisms?member=' + encodeURIComponent(owner) + '&per_page=100'); }
174
+ catch { res = null; }
175
+ if (!res || res.ok === false) res = await authFetch('/v1/organisms');
176
+ if (res.ok === false) throw fail(res, 'Failed to list organisms');
177
+ var d = res.data !== undefined ? res.data : res;
178
+ return (d && (d.organisms || d.items)) || (Array.isArray(d) ? d : []);
179
+ },
180
+
181
+ async get(orgId) {
182
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId));
183
+ if (res.ok === false) throw fail(res, 'Failed to load organism');
184
+ return res.data !== undefined ? res.data : res;
185
+ },
186
+
187
+ // Create a NEW organism (the signed-in owner becomes creator/member). Needs the organism:write app
188
+ // scope (declare it in <meta name="aimeat-scopes">). Returns { id, name, ... }. Use this + createWorkspace
189
+ // to let a multi-tenant app provision its own data space for each user on first use.
190
+ async create(name, opts) {
191
+ opts = opts || {};
192
+ var res = await authFetch('/v1/organisms', {
193
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
194
+ body: JSON.stringify({ name: name, type: opts.type || 'project', visibility: opts.visibility || 'private',
195
+ join_policy: opts.join_policy || 'invite_only', description: opts.description }),
196
+ });
197
+ if (res.ok === false) throw fail(res, 'Failed to create organism');
198
+ // The route envelope is { organism: record } — unwrap so this returns { id, name, ... }
199
+ // as documented (found by the PIPELINE flagship app: createWorkspace got orgId=undefined).
200
+ var d = res.data !== undefined ? res.data : res;
201
+ return (d && d.organism) ? d.organism : d;
202
+ },
203
+
204
+ // Create a NEW schema-locked workspace inside an organism from a manifest + per-namespace JSON schemas.
205
+ // manifest = { manifestVersion:'1', name, kind, objectTypes:[{ name, namespace, mode:'records',
206
+ // backing:'memory', writeRole:'member', schemaRef? }] }; schemas = { '<namespace>': <JSON Schema> }.
207
+ // Needs organism:write. Returns { ws, types, schemas_locked }.
208
+ async createWorkspace(orgId, name, manifest, schemas, readme) {
209
+ // The manifest meta-schema REQUIRES a schemaRef on every objectType, but this signature has
210
+ // always documented schemaRef as optional. Honour the documented contract: fill a schemaRef
211
+ // for any objectType missing one, and register a permissive schema for its namespace when the
212
+ // caller supplied none — so a records space provisions even without hand-authored schemas.
213
+ // (Both the PIPELINE flagship and the AEB A/B builders hit the required-schemaRef server rule.)
214
+ var m = manifest && typeof manifest === 'object' ? JSON.parse(JSON.stringify(manifest)) : manifest;
215
+ var sc = schemas && typeof schemas === 'object' ? Object.assign({}, schemas) : {};
216
+ if (m && Array.isArray(m.objectTypes)) {
217
+ for (var oi = 0; oi < m.objectTypes.length; oi++) {
218
+ var ot = m.objectTypes[oi];
219
+ if (ot && !ot.schemaRef) {
220
+ var slug = String(ot.name || ('type' + oi)).replace(/[^a-zA-Z0-9_-]/g, '-');
221
+ ot.schemaRef = 'schema:' + name + '-' + slug + '@1';
222
+ }
223
+ if (ot && ot.namespace && sc[ot.namespace] === undefined && (ot.mode || 'records') === 'records') {
224
+ sc[ot.namespace] = { type: 'object', additionalProperties: true };
225
+ }
226
+ }
227
+ }
228
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/workspaces', {
229
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
230
+ body: JSON.stringify({ name: name, manifest: m, schemas: sc, readme: readme }),
231
+ });
232
+ if (res.ok === false) throw fail(res, 'Failed to create workspace');
233
+ return res.data !== undefined ? res.data : res;
234
+ },
235
+
236
+ // List workspaces (access + enrichment counts included).
237
+ async workspaces(orgId) {
238
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/workspaces?include=enrichment');
239
+ if (res.ok === false) throw fail(res, 'Failed to list workspaces');
240
+ var d = res.data !== undefined ? res.data : res;
241
+ return (d && (d.workspaces || d.items)) || (Array.isArray(d) ? d : []);
242
+ },
243
+
244
+ // Read one workspace, normalized: { manifest, readme, readmeText, spaces, raw }.
245
+ // spaces[].items[]: { id, hasRealId, draft, latest, value, title, updatedAt, status }.
246
+ async read(orgId, wsId) {
247
+ var q = wsId ? ('?ws=' + encodeURIComponent(wsId)) : '';
248
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/workspace' + q);
249
+ if (res.ok === false) throw fail(res, 'Failed to read workspace');
250
+ var d = res.data !== undefined ? res.data : res;
251
+ return {
252
+ manifest: (d && d.manifest) || null,
253
+ readme: (d && d.readme) || null,
254
+ readmeText: readmeText(d && d.readme),
255
+ spaces: normalizeWorkspace(d),
256
+ raw: d,
257
+ };
258
+ },
259
+
260
+ // Write/overwrite an object's draft. Embeds the instance id into the value (SPA convention)
261
+ // unless opts.embedId === false (needed for locked schemas that reject an id property).
262
+ async writeDraft(orgId, wsId, namespace, id, value, opts) {
263
+ opts = opts || {};
264
+ var v = stripMeta(value);
265
+ if (opts.embedId !== false && v && typeof v === 'object' && !Array.isArray(v)) {
266
+ v = Object.assign({}, v, { id: id });
267
+ }
268
+ var body = /** @type {Record<string, any>} */ ({ key: draftKey(orgId, wsId, namespace, id), value: v, visibility: opts.visibility || 'private' });
269
+ if (opts.group_id) body.group_id = opts.group_id;
270
+ if (Array.isArray(opts.tags) && opts.tags.length) body.tags = opts.tags;
271
+ var res = await authFetch('/v1/memory', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
272
+ if (res.ok === false) throw fail(res, 'Failed to save draft');
273
+ return res.data !== undefined ? res.data : res;
274
+ },
275
+
276
+ // Publish a draft -> new .version.N + .latest (or a pending approval when the workspace gates publishes).
277
+ async publish(orgId, wsId, namespace, id) {
278
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/publish', {
279
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
280
+ body: JSON.stringify({ ws: wsId || undefined, namespace: namespace, id: id }),
281
+ });
282
+ if (res.ok === false) throw fail(res, 'Failed to publish');
283
+ return res.data !== undefined ? res.data : res;
284
+ },
285
+
286
+ // BULK publish MANY records in ONE request (data-access redesign). Two shapes:
287
+ // • ids: ['id', ...] → publish each record's existing DRAFT (the edit → publish flow)
288
+ // • records: [{ id, value }, ...] → DRAFT-LESS: publish the supplied values directly (imports —
289
+ // one request for a whole CSV migration, no per-record draft write). optional expectedVersions.
290
+ // Replaces a loop of publish() (each a server-side scan + 2 writes + draft delete). Returns
291
+ // { published, skipped, failed, results }. create_only 409s; a publish review gate refuses the batch.
292
+ async publishRecords(orgId, wsId, namespace, idsOrRecords, expectedVersions) {
293
+ var body = /** @type {Record<string, any>} */ ({ ws: wsId || undefined, namespace: namespace });
294
+ var arr = idsOrRecords || [];
295
+ if (arr.length && typeof arr[0] === 'object') body.records = arr; else body.instances = arr;
296
+ if (expectedVersions && typeof expectedVersions === 'object') body.expected_versions = expectedVersions;
297
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/workspace/records/publish', {
298
+ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body),
299
+ });
300
+ if (res.ok === false) throw fail(res, 'Failed to publish records');
301
+ return res.data !== undefined ? res.data : res;
302
+ },
303
+
304
+ // BULK delete MANY record families in ONE request (data-access redesign) — ids: [id,...]. Removes each
305
+ // record's bare/.draft/.latest/.version.N owned by the caller's own identity in one batched call
306
+ // (needs memory:delete scope). Replaces a loop of deleteObject() (a scan + per-key delete each).
307
+ // Returns { deleted:[{id,keys}], failed:[{id,reason}], rows_removed }.
308
+ async deleteRecords(orgId, wsId, namespace, ids) {
309
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/workspace/records/delete', {
310
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
311
+ body: JSON.stringify({ ws: wsId || undefined, namespace: namespace, ids: ids || [] }),
312
+ });
313
+ if (res.ok === false) throw fail(res, 'Failed to delete records');
314
+ return res.data !== undefined ? res.data : res;
315
+ },
316
+
317
+ // Reopen a published record for editing (server copies .latest -> .draft; 409 if a draft exists).
318
+ async revertToDraft(orgId, wsId, namespace, id) {
319
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/revert', {
320
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
321
+ body: JSON.stringify({ ws: wsId || undefined, namespace: namespace, id: id }),
322
+ });
323
+ if (res.ok === false) throw fail(res, 'Failed to revert to draft');
324
+ return res.data !== undefined ? res.data : res;
325
+ },
326
+
327
+ // Delete one object: bare key + .draft + .latest + all .version.N history (re-run for huge
328
+ // histories). NOTE: needs the memory:delete scope — app-grant tokens don't get it by default,
329
+ // declare it via <meta name="aimeat-scopes" content="memory:read memory:write memory:delete">.
330
+ async deleteObject(orgId, wsId, namespace, id) {
331
+ var base = wsRoot(orgId, wsId) + '.' + namespace + '.' + id;
332
+ var res = await authFetch('/v1/memory?prefix=' + encodeURIComponent(base) + '&limit=200');
333
+ if (res.ok === false) throw fail(res, 'Failed to list object keys');
334
+ var items = (res.data && res.data.items) || [];
335
+ var deleted = 0, attempted = 0, lastErr = null;
336
+ for (var i = 0; i < items.length; i++) {
337
+ var key = items[i].key;
338
+ // prefix match catches sibling ids (…my-doc2); keep only the exact instance's keys
339
+ if (key !== base && key.indexOf(base + '.') !== 0) continue;
340
+ attempted++;
341
+ var dres = await authFetch('/v1/memory/' + encodeURIComponent(key), { method: 'DELETE' });
342
+ if (dres.ok !== false) deleted++; else lastErr = dres;
343
+ }
344
+ if (attempted > 0 && deleted === 0 && lastErr) throw fail(lastErr, 'Failed to delete object keys');
345
+ return { deleted: deleted, attempted: attempted };
346
+ },
347
+
348
+ // Save the workspace README (creator/org-admin only — the server enforces it).
349
+ async saveReadme(orgId, wsId, readme) {
350
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/workspace?ws=' + encodeURIComponent(wsId), {
351
+ method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ readme: readme }),
352
+ });
353
+ if (res.ok === false) throw fail(res, 'Failed to save README');
354
+ return res.data !== undefined ? res.data : res;
355
+ },
356
+
357
+ // Organism-wide server-side search.
358
+ async search(orgId, q) {
359
+ var res = await authFetch('/v1/organisms/' + encodeURIComponent(orgId) + '/search?q=' + encodeURIComponent(q));
360
+ if (res.ok === false) throw fail(res, 'Search failed');
361
+ var d = res.data !== undefined ? res.data : res;
362
+ return (d && (d.results || d.hits || d.items)) || (Array.isArray(d) ? d : []);
363
+ },
364
+
365
+ util: {
366
+ stripMeta: stripMeta,
367
+ isMetaField: isMetaField,
368
+ titleOf: titleOf,
369
+ bodyFieldOf: bodyFieldOf,
370
+ isDocLike: isDocLike,
371
+ updatedAt: valueUpdatedAt,
372
+ wsRoot: wsRoot,
373
+ draftKey: draftKey,
374
+ normalizeWorkspace: normalizeWorkspace,
375
+ readmeText: readmeText,
376
+ TITLE_FIELDS: TITLE_FIELDS.slice(),
377
+ BODY_FIELDS: BODY_FIELDS.slice(),
378
+ },
379
+ };
380
+
381
+ attach('organism', organism);
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @file portfolio-standalone/index.js
3
+ * @description The portfolio-standalone bridge shim (SDK-libs migration Phase 1) — injected into
4
+ * portfolios served standalone on the portfolio origin (<username>.portfolio.<apex>). Recreates the
5
+ * viewer's postMessage bridge locally so the exact same portfolio HTML works at top level (where
6
+ * window.parent === window, so the portfolio's own parent.postMessage lands back here and this shim
7
+ * answers it). Auth comes from the aimeat-auth SDK's H-2 silent SSO (an app-grant token bound to
8
+ * THIS origin, scope memory:read). Componentized ESM source esbuild bundles to the IIFE served,
9
+ * unchanged, at /v1/libs/portfolio-standalone.js (note: NOT aimeat-prefixed, and does NOT attach to
10
+ * window.AIMEAT). Ported verbatim from lib-portfolio-standalone.ts; the baked ${config.baseUrl} apex
11
+ * is now APEX_URL from _core/config.
12
+ * @structure imports APEX_URL (config); post()/announce(); the message listener (aimeat-portfolio-fetch);
13
+ * boot() silent-SSO announce. No namespace attach — this is a standalone bridge, not an AIMEAT.* surface.
14
+ * @usage Served at GET /v1/libs/portfolio-standalone.js; injected (with aimeat-auth.js + a memory:read
15
+ * scopes meta) by the portfolio-origin serve route in subdomains.ts.
16
+ * @version-history
17
+ * v1.0.0 — 2026-07-19 — Migrated from src/routes/lib-portfolio-standalone.ts (SDK-libs migration Phase 1).
18
+ */
19
+ import { APEX_URL } from '../_core/config.js';
20
+
21
+ var APEX = APEX_URL;
22
+ var jwt = null;
23
+
24
+ function post(msg) {
25
+ try { window.postMessage(msg, window.location.origin); } catch { /* opaque origin — cannot happen here */ }
26
+ }
27
+ function announce(loggedIn) {
28
+ post({ type: 'aimeat-portfolio-auth', loggedIn: !!loggedIn });
29
+ }
30
+
31
+ // Answer the portfolio's bridge fetches with the visitor's grant token. At top
32
+ // level window.parent === window, so parent.postMessage lands on this window.
33
+ window.addEventListener('message', function (e) {
34
+ if (e.source !== window) return;
35
+ var d = e.data;
36
+ if (!d || d.type !== 'aimeat-portfolio-fetch') return;
37
+ var reply = function (ok, value) {
38
+ post({
39
+ type: 'aimeat-portfolio-fetch-result',
40
+ id: d.id == null ? null : d.id,
41
+ ok: !!ok,
42
+ gaii: typeof d.gaii === 'string' ? d.gaii : null,
43
+ key: typeof d.key === 'string' ? d.key : null,
44
+ value: value == null ? null : value,
45
+ });
46
+ };
47
+ if (typeof d.gaii !== 'string' || typeof d.key !== 'string') { reply(false, null); return; }
48
+ fetch(APEX + '/v1/memory/' + encodeURIComponent(d.gaii) + '/' + encodeURIComponent(d.key),
49
+ jwt ? { headers: { Authorization: 'Bearer ' + jwt } } : undefined)
50
+ .then(function (r) { return r.json().then(function (j) { return { r: r, j: j }; }); })
51
+ .then(function (x) {
52
+ var ok = !!(x.r.ok && x.j && x.j.ok !== false);
53
+ reply(ok, ok && x.j.data ? x.j.data.value : null);
54
+ })
55
+ .catch(function () { reply(false, null); });
56
+ });
57
+
58
+ // Silent SSO via the aimeat-auth SDK: on this foreign origin auth.login()
59
+ // resolves an H-2 app-grant (scope from the injected aimeat-scopes meta) when
60
+ // the visitor has an apex session AND has consented this origin; otherwise null.
61
+ function boot() {
62
+ var auth = window.AIMEAT && window.AIMEAT.auth;
63
+ if (!auth || typeof auth.login !== 'function') { announce(false); return; }
64
+ Promise.resolve(auth.login()).then(function (session) {
65
+ jwt = session && session.jwt ? session.jwt : null;
66
+ announce(!!jwt);
67
+ }).catch(function () { announce(false); });
68
+ if (typeof auth.on === 'function') {
69
+ auth.on('login', function () {
70
+ var s = typeof auth.getSession === 'function' ? auth.getSession() : null;
71
+ jwt = (s && s.jwt) || null;
72
+ announce(!!jwt);
73
+ });
74
+ auth.on('logout', function () { jwt = null; announce(false); });
75
+ }
76
+ }
77
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot);
78
+ else boot();
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @file social/index.js
3
+ * @description The aimeat-social library (SDK-libs migration Phase 2). Exposes AIMEAT.social — the
4
+ * boards & social feed client: createBoard/boards, post/posts/getPost, react/reply, subscribe/
5
+ * unsubscribe/subscriptions, and the public catalogue. Authenticated calls go through the
6
+ * AIMEAT.auth session; public reads go direct to NODE_URL. Componentized ESM source esbuild
7
+ * bundles to the IIFE served, unchanged, at /v1/libs/aimeat-social.js. Ported verbatim from
8
+ * lib-social.ts; NODE_URL now comes from _core/config.
9
+ * @structure imports NODE_URL (config) + authFetch (session) + attach (namespace); publicFetch();
10
+ * the `social` object; attach('social', …).
11
+ * @usage <script src="/v1/libs/aimeat-auth.js"></script><script src="/v1/libs/aimeat-social.js"></script>
12
+ * await AIMEAT.social.post('general', { title: 'Hi', body: 'Hello!' });
13
+ * @version-history
14
+ * v1.0.0 — 2026-07-19 — Migrated from src/routes/lib-social.ts (SDK-libs migration Phase 2).
15
+ */
16
+ import { NODE_URL } from '../_core/config.js';
17
+ import { makeSession } from '../_core/session.js';
18
+ const { authFetch } = makeSession('aimeat-social.js');
19
+ import { attach } from '../_core/namespace.js';
20
+
21
+ async function publicFetch(path) {
22
+ const r = await fetch(NODE_URL + path);
23
+ return r.json();
24
+ }
25
+
26
+ const social = {
27
+ // ── Boards ──
28
+
29
+ // Create a new board
30
+ async createBoard(name, opts) {
31
+ const body = { name, visibility: 'public', ...opts };
32
+ const res = await authFetch('/v1/boards', { method: 'POST', body: JSON.stringify(body) });
33
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to create board');
34
+ return res.data;
35
+ },
36
+
37
+ // List all visible boards (no auth needed for public boards)
38
+ async boards() {
39
+ const res = await publicFetch('/v1/boards');
40
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to list boards');
41
+ return res.data;
42
+ },
43
+
44
+ // ── Posts ──
45
+
46
+ // Post to a board
47
+ async post(boardId, content) {
48
+ const body = typeof content === 'string' ? { body: content } : content;
49
+ const res = await authFetch('/v1/boards/' + encodeURIComponent(boardId) + '/posts', {
50
+ method: 'POST', body: JSON.stringify(body),
51
+ });
52
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to post');
53
+ return res.data;
54
+ },
55
+
56
+ // List posts in a board (public, no auth needed)
57
+ async posts(boardId, opts) {
58
+ const params = new URLSearchParams();
59
+ if (opts?.category) params.set('category', opts.category);
60
+ if (opts?.cursor) params.set('cursor', opts.cursor);
61
+ if (opts?.limit) params.set('limit', String(opts.limit));
62
+ const qs = params.toString();
63
+ const res = await publicFetch('/v1/boards/' + encodeURIComponent(boardId) + '/posts' + (qs ? '?' + qs : ''));
64
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to list posts');
65
+ return res.data;
66
+ },
67
+
68
+ // Get a single post
69
+ async getPost(boardId, postId) {
70
+ const res = await publicFetch('/v1/boards/' + encodeURIComponent(boardId) + '/posts/' + encodeURIComponent(postId));
71
+ if (!res.ok) {
72
+ if (res.error?.code === 'NOT_FOUND') return null;
73
+ throw new Error(res.error?.message || 'Failed to get post');
74
+ }
75
+ return res.data;
76
+ },
77
+
78
+ // ── Reactions & Replies ──
79
+
80
+ // React to a post
81
+ async react(boardId, postId, reaction) {
82
+ const res = await authFetch(
83
+ '/v1/boards/' + encodeURIComponent(boardId) + '/posts/' + encodeURIComponent(postId) + '/react',
84
+ { method: 'POST', body: JSON.stringify({ reaction }) },
85
+ );
86
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to react');
87
+ return res.data;
88
+ },
89
+
90
+ // Reply to a post
91
+ async reply(boardId, postId, body) {
92
+ const content = typeof body === 'string' ? { body } : body;
93
+ const res = await authFetch(
94
+ '/v1/boards/' + encodeURIComponent(boardId) + '/posts/' + encodeURIComponent(postId) + '/replies',
95
+ { method: 'POST', body: JSON.stringify(content) },
96
+ );
97
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to reply');
98
+ return res.data;
99
+ },
100
+
101
+ // ── Subscriptions ──
102
+
103
+ // Subscribe to a board
104
+ async subscribe(boardId, opts) {
105
+ const body = { callback_url: opts?.callback_url, filters: opts?.filters };
106
+ const res = await authFetch('/v1/boards/' + encodeURIComponent(boardId) + '/subscribe', {
107
+ method: 'POST', body: JSON.stringify(body),
108
+ });
109
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to subscribe');
110
+ return res.data;
111
+ },
112
+
113
+ // Unsubscribe from a board
114
+ async unsubscribe(boardId) {
115
+ const res = await authFetch('/v1/boards/' + encodeURIComponent(boardId) + '/subscribe', {
116
+ method: 'DELETE',
117
+ });
118
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to unsubscribe');
119
+ return res.data;
120
+ },
121
+
122
+ // List own subscriptions
123
+ async subscriptions() {
124
+ const res = await authFetch('/v1/boards/subscriptions');
125
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to list subscriptions');
126
+ return res.data;
127
+ },
128
+
129
+ // ── Catalogue (public, no auth) ──
130
+
131
+ // Browse public boards from catalogue
132
+ async catalogue() {
133
+ const res = await publicFetch('/v1/catalogue/boards');
134
+ if (!res.ok) throw new Error(res.error?.message || 'Failed to browse catalogue boards');
135
+ return res.data;
136
+ },
137
+ };
138
+
139
+ // ── Expose globally ──
140
+ attach('social', social);