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.
- package/dist/locales/en.json +35 -1
- package/dist/locales/fi.json +35 -1
- package/dist/public/components/LinkPreview.js +101 -0
- package/dist/public/components/NotificationBell.js +18 -1
- package/dist/public/css/theme.css +57 -7
- package/dist/public/css/views/admin.css +8 -1
- package/dist/public/css/views/app-grant.css +18 -0
- package/dist/public/css/views/inbox.css +46 -0
- package/dist/public/css/views/portfolio.css +46 -0
- package/dist/public/css/views/profile.css +29 -4
- package/dist/public/js/services/apps.js +19 -3
- package/dist/public/js/services/messages-ai-prompts.js +38 -0
- package/dist/public/js/services/messages.js +26 -4
- package/dist/public/js/services/notebook.js +76 -0
- package/dist/public/js/services/unfurl.js +43 -0
- package/dist/public/lib/samples/LICENSE.md +11 -0
- package/dist/public/lib/samples/bass/A1.mp3 +0 -0
- package/dist/public/lib/samples/bass/B2.mp3 +0 -0
- package/dist/public/lib/samples/bass/D2.mp3 +0 -0
- package/dist/public/lib/samples/bass/E1.mp3 +0 -0
- package/dist/public/lib/samples/bass/E3.mp3 +0 -0
- package/dist/public/lib/samples/bass/G2.mp3 +0 -0
- package/dist/public/lib/samples/epiano/C2.mp3 +0 -0
- package/dist/public/lib/samples/epiano/C3.mp3 +0 -0
- package/dist/public/lib/samples/epiano/C4.mp3 +0 -0
- package/dist/public/lib/samples/epiano/C5.mp3 +0 -0
- package/dist/public/lib/samples/epiano/C6.mp3 +0 -0
- package/dist/public/lib/samples/epiano/G2.mp3 +0 -0
- package/dist/public/lib/samples/epiano/G3.mp3 +0 -0
- package/dist/public/lib/samples/epiano/G4.mp3 +0 -0
- package/dist/public/lib/samples/epiano/G5.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/A2.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/A4.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/B3.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/D3.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/E2.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/E4.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/E5.mp3 +0 -0
- package/dist/public/lib/samples/guitar-steel/G3.mp3 +0 -0
- package/dist/public/lib/samples/organ/C2.mp3 +0 -0
- package/dist/public/lib/samples/organ/C3.mp3 +0 -0
- package/dist/public/lib/samples/organ/C4.mp3 +0 -0
- package/dist/public/lib/samples/organ/C5.mp3 +0 -0
- package/dist/public/lib/samples/organ/C6.mp3 +0 -0
- package/dist/public/lib/samples/organ/G2.mp3 +0 -0
- package/dist/public/lib/samples/organ/G3.mp3 +0 -0
- package/dist/public/lib/samples/organ/G4.mp3 +0 -0
- package/dist/public/lib/samples/organ/G5.mp3 +0 -0
- package/dist/public/lib/samples/strings/C2.mp3 +0 -0
- package/dist/public/lib/samples/strings/C3.mp3 +0 -0
- package/dist/public/lib/samples/strings/C4.mp3 +0 -0
- package/dist/public/lib/samples/strings/C5.mp3 +0 -0
- package/dist/public/lib/samples/strings/C6.mp3 +0 -0
- package/dist/public/lib/samples/strings/G2.mp3 +0 -0
- package/dist/public/lib/samples/strings/G3.mp3 +0 -0
- package/dist/public/lib/samples/strings/G4.mp3 +0 -0
- package/dist/public/lib/samples/strings/G5.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/A3.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/A4.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/A5.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/C4.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/C5.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/E3.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/E4.mp3 +0 -0
- package/dist/public/lib/samples/trumpet/E5.mp3 +0 -0
- package/dist/public/spa.html +2 -0
- package/dist/public/views/app-grant.js +24 -4
- package/dist/public/views/portfolio.js +61 -6
- package/dist/public/views/profile/apps-tab.js +18 -1
- package/dist/public/views/profile/inbox-tab/ai-actions.js +86 -0
- package/dist/public/views/profile/inbox-tab/components.js +124 -9
- package/dist/public/views/profile/inbox-tab/helpers.js +26 -0
- package/dist/public/views/profile/inbox-tab/panels.js +18 -3
- package/dist/public/views/profile/inbox-tab/use-thread-ux.js +18 -1
- package/dist/public/views/profile/inbox-tab.js +46 -49
- package/dist/public/views/profile/landing-page.cards.js +7 -0
- package/dist/public/views/profile/landing-page.js +12 -1
- package/dist/public/views/profile/skills-tab.js +1 -1
- package/dist/public/views/public-workspace-viewer.js +1 -1
- package/dist/public/views/start.js +2 -1
- package/dist/scripts/build-sdk-libs.d.ts +16 -0
- package/dist/scripts/build-sdk-libs.d.ts.map +1 -0
- package/dist/scripts/build-sdk-libs.js +112 -0
- package/dist/scripts/build-sdk-libs.js.map +1 -0
- package/dist/src/cli/connect/auth.d.ts +15 -0
- package/dist/src/cli/connect/auth.d.ts.map +1 -1
- package/dist/src/cli/connect/auth.js +25 -6
- package/dist/src/cli/connect/auth.js.map +1 -1
- package/dist/src/cli/connect/keychain.d.ts +9 -0
- package/dist/src/cli/connect/keychain.d.ts.map +1 -1
- package/dist/src/cli/connect/keychain.js +21 -8
- package/dist/src/cli/connect/keychain.js.map +1 -1
- package/dist/src/cli/connect/mcp/tools/exchange.d.ts +18 -0
- package/dist/src/cli/connect/mcp/tools/exchange.d.ts.map +1 -0
- package/dist/src/cli/connect/mcp/tools/exchange.js +170 -0
- package/dist/src/cli/connect/mcp/tools/exchange.js.map +1 -0
- package/dist/src/cli/connect/mcp/tools/index.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/tools/index.js +2 -0
- package/dist/src/cli/connect/mcp/tools/index.js.map +1 -1
- package/dist/src/cli/connect/tool-call-defs-exchange.d.ts +3 -0
- package/dist/src/cli/connect/tool-call-defs-exchange.d.ts.map +1 -0
- package/dist/src/cli/connect/tool-call-defs-exchange.js +146 -0
- package/dist/src/cli/connect/tool-call-defs-exchange.js.map +1 -0
- package/dist/src/cli/connect/tool-call.d.ts.map +1 -1
- package/dist/src/cli/connect/tool-call.js +2 -0
- package/dist/src/cli/connect/tool-call.js.map +1 -1
- package/dist/src/commerce/session-service.d.ts +14 -0
- package/dist/src/commerce/session-service.d.ts.map +1 -1
- package/dist/src/commerce/session-service.js +1 -1
- package/dist/src/commerce/session-service.js.map +1 -1
- package/dist/src/data/app-templates/shells.d.ts +7 -3
- package/dist/src/data/app-templates/shells.d.ts.map +1 -1
- package/dist/src/data/app-templates/shells.js +10 -6
- package/dist/src/data/app-templates/shells.js.map +1 -1
- package/dist/src/data/appdev-pitfalls.d.ts +2 -0
- package/dist/src/data/appdev-pitfalls.d.ts.map +1 -1
- package/dist/src/data/appdev-pitfalls.js +24 -1
- package/dist/src/data/appdev-pitfalls.js.map +1 -1
- package/dist/src/generated/api-types.d.ts +1565 -9
- package/dist/src/generated/api-types.d.ts.map +1 -1
- package/dist/src/mcp/annotations.d.ts.map +1 -1
- package/dist/src/mcp/annotations.js +20 -0
- package/dist/src/mcp/annotations.js.map +1 -1
- package/dist/src/mcp/apps.d.ts.map +1 -1
- package/dist/src/mcp/apps.js +8 -4
- package/dist/src/mcp/apps.js.map +1 -1
- package/dist/src/mcp/catalog/definitions/exchange.d.ts +18 -0
- package/dist/src/mcp/catalog/definitions/exchange.d.ts.map +1 -0
- package/dist/src/mcp/catalog/definitions/exchange.js +182 -0
- package/dist/src/mcp/catalog/definitions/exchange.js.map +1 -0
- package/dist/src/mcp/catalog/definitions.d.ts.map +1 -1
- package/dist/src/mcp/catalog/definitions.js +2 -0
- package/dist/src/mcp/catalog/definitions.js.map +1 -1
- package/dist/src/mcp/catalog/scopes.d.ts.map +1 -1
- package/dist/src/mcp/catalog/scopes.js +22 -0
- package/dist/src/mcp/catalog/scopes.js.map +1 -1
- package/dist/src/mcp/catalog/surfaces.d.ts.map +1 -1
- package/dist/src/mcp/catalog/surfaces.js +14 -0
- package/dist/src/mcp/catalog/surfaces.js.map +1 -1
- package/dist/src/mcp/exchange-run.d.ts +5 -0
- package/dist/src/mcp/exchange-run.d.ts.map +1 -0
- package/dist/src/mcp/exchange-run.js +226 -0
- package/dist/src/mcp/exchange-run.js.map +1 -0
- package/dist/src/mcp/exchange.d.ts +5 -0
- package/dist/src/mcp/exchange.d.ts.map +1 -0
- package/dist/src/mcp/exchange.js +351 -0
- package/dist/src/mcp/exchange.js.map +1 -0
- package/dist/src/mcp/extensions.d.ts.map +1 -1
- package/dist/src/mcp/extensions.js +11 -0
- package/dist/src/mcp/extensions.js.map +1 -1
- package/dist/src/mcp/index.d.ts.map +1 -1
- package/dist/src/mcp/index.js +6 -2
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/models/app-tool-schemas.d.ts +55 -1
- package/dist/src/models/app-tool-schemas.d.ts.map +1 -1
- package/dist/src/models/app-tool-schemas.js +20 -1
- package/dist/src/models/app-tool-schemas.js.map +1 -1
- package/dist/src/models/offer-schemas.d.ts +2 -2
- package/dist/src/models/schemas.d.ts +1 -0
- package/dist/src/models/schemas.d.ts.map +1 -1
- package/dist/src/models/schemas.js +3 -0
- package/dist/src/models/schemas.js.map +1 -1
- package/dist/src/routes/agents/device-auth.d.ts +4 -0
- package/dist/src/routes/agents/device-auth.d.ts.map +1 -1
- package/dist/src/routes/agents/device-auth.js +19 -4
- package/dist/src/routes/agents/device-auth.js.map +1 -1
- package/dist/src/routes/app-grants.d.ts +6 -0
- package/dist/src/routes/app-grants.d.ts.map +1 -1
- package/dist/src/routes/app-grants.js +35 -2
- package/dist/src/routes/app-grants.js.map +1 -1
- package/dist/src/routes/apps/fork-manage.d.ts.map +1 -1
- package/dist/src/routes/apps/fork-manage.js +24 -1
- package/dist/src/routes/apps/fork-manage.js.map +1 -1
- package/dist/src/routes/apps/publish.d.ts +2 -0
- package/dist/src/routes/apps/publish.d.ts.map +1 -1
- package/dist/src/routes/apps/publish.js +27 -1
- package/dist/src/routes/apps/publish.js.map +1 -1
- package/dist/src/routes/apps-cost.d.ts +25 -0
- package/dist/src/routes/apps-cost.d.ts.map +1 -0
- package/dist/src/routes/apps-cost.js +107 -0
- package/dist/src/routes/apps-cost.js.map +1 -0
- package/dist/src/routes/exchange-market.d.ts +28 -0
- package/dist/src/routes/exchange-market.d.ts.map +1 -0
- package/dist/src/routes/exchange-market.js +454 -0
- package/dist/src/routes/exchange-market.js.map +1 -0
- package/dist/src/routes/exchange.d.ts +33 -0
- package/dist/src/routes/exchange.d.ts.map +1 -0
- package/dist/src/routes/exchange.js +395 -0
- package/dist/src/routes/exchange.js.map +1 -0
- package/dist/src/routes/extensions/entitlement-gate.d.ts +33 -0
- package/dist/src/routes/extensions/entitlement-gate.d.ts.map +1 -0
- package/dist/src/routes/extensions/entitlement-gate.js +143 -0
- package/dist/src/routes/extensions/entitlement-gate.js.map +1 -0
- package/dist/src/routes/extensions/manifest.d.ts +9 -0
- package/dist/src/routes/extensions/manifest.d.ts.map +1 -1
- package/dist/src/routes/extensions/manifest.js +33 -1
- package/dist/src/routes/extensions/manifest.js.map +1 -1
- package/dist/src/routes/extensions/paywall.d.ts.map +1 -1
- package/dist/src/routes/extensions/paywall.js +9 -0
- package/dist/src/routes/extensions/paywall.js.map +1 -1
- package/dist/src/routes/federation-sync/messaging.d.ts.map +1 -1
- package/dist/src/routes/federation-sync/messaging.js +3 -1
- package/dist/src/routes/federation-sync/messaging.js.map +1 -1
- package/dist/src/routes/ghii/recovery.d.ts +2 -0
- package/dist/src/routes/ghii/recovery.d.ts.map +1 -1
- package/dist/src/routes/ghii/recovery.js +7 -0
- package/dist/src/routes/ghii/recovery.js.map +1 -1
- package/dist/src/routes/ghii/register-login.d.ts +4 -0
- package/dist/src/routes/ghii/register-login.d.ts.map +1 -1
- package/dist/src/routes/ghii/register-login.js +45 -22
- package/dist/src/routes/ghii/register-login.js.map +1 -1
- package/dist/src/routes/ghii/web-verify.d.ts +5 -0
- package/dist/src/routes/ghii/web-verify.d.ts.map +1 -1
- package/dist/src/routes/ghii/web-verify.js +24 -3
- package/dist/src/routes/ghii/web-verify.js.map +1 -1
- package/dist/src/routes/libs/sdk-serve.d.ts +11 -0
- package/dist/src/routes/libs/sdk-serve.d.ts.map +1 -0
- package/dist/src/routes/libs/sdk-serve.js +53 -0
- package/dist/src/routes/libs/sdk-serve.js.map +1 -0
- package/dist/src/routes/libs.d.ts +7 -1
- package/dist/src/routes/libs.d.ts.map +1 -1
- package/dist/src/routes/libs.js +65 -146
- package/dist/src/routes/libs.js.map +1 -1
- package/dist/src/routes/messages.d.ts +3 -0
- package/dist/src/routes/messages.d.ts.map +1 -1
- package/dist/src/routes/messages.js +9 -0
- package/dist/src/routes/messages.js.map +1 -1
- package/dist/src/routes/notifications.d.ts +6 -3
- package/dist/src/routes/notifications.d.ts.map +1 -1
- package/dist/src/routes/notifications.js +32 -3
- package/dist/src/routes/notifications.js.map +1 -1
- package/dist/src/routes/organisms/workspace-access.d.ts.map +1 -1
- package/dist/src/routes/organisms/workspace-access.js +38 -20
- package/dist/src/routes/organisms/workspace-access.js.map +1 -1
- package/dist/src/routes/unfurl.d.ts +27 -0
- package/dist/src/routes/unfurl.d.ts.map +1 -0
- package/dist/src/routes/unfurl.js +180 -0
- package/dist/src/routes/unfurl.js.map +1 -0
- package/dist/src/routes/upload.d.ts +2 -0
- package/dist/src/routes/upload.d.ts.map +1 -1
- package/dist/src/routes/upload.js +7 -0
- package/dist/src/routes/upload.js.map +1 -1
- package/dist/src/routes/webmcp.d.ts +3 -0
- package/dist/src/routes/webmcp.d.ts.map +1 -1
- package/dist/src/routes/webmcp.js +55 -0
- package/dist/src/routes/webmcp.js.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.d.ts +1 -0
- package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
- package/dist/src/server-bootstrap/routes-loader.js +8 -0
- package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
- package/dist/src/services/agent-face.d.ts +10 -2
- package/dist/src/services/agent-face.d.ts.map +1 -1
- package/dist/src/services/agent-face.js +10 -4
- package/dist/src/services/agent-face.js.map +1 -1
- package/dist/src/services/app-tool-interfaces.d.ts +37 -0
- package/dist/src/services/app-tool-interfaces.d.ts.map +1 -0
- package/dist/src/services/app-tool-interfaces.js +101 -0
- package/dist/src/services/app-tool-interfaces.js.map +1 -0
- package/dist/src/services/build-app-prompt.d.ts +3 -0
- package/dist/src/services/build-app-prompt.d.ts.map +1 -1
- package/dist/src/services/build-app-prompt.js +12 -1
- package/dist/src/services/build-app-prompt.js.map +1 -1
- package/dist/src/services/contacts.d.ts +25 -1
- package/dist/src/services/contacts.d.ts.map +1 -1
- package/dist/src/services/contacts.js +30 -0
- package/dist/src/services/contacts.js.map +1 -1
- package/dist/src/services/entitlement-money.d.ts +55 -0
- package/dist/src/services/entitlement-money.d.ts.map +1 -0
- package/dist/src/services/entitlement-money.js +68 -0
- package/dist/src/services/entitlement-money.js.map +1 -0
- package/dist/src/services/exchange-market.d.ts +247 -0
- package/dist/src/services/exchange-market.d.ts.map +1 -0
- package/dist/src/services/exchange-market.js +254 -0
- package/dist/src/services/exchange-market.js.map +1 -0
- package/dist/src/services/exchange-proposals.d.ts +47 -0
- package/dist/src/services/exchange-proposals.d.ts.map +1 -0
- package/dist/src/services/exchange-proposals.js +71 -0
- package/dist/src/services/exchange-proposals.js.map +1 -0
- package/dist/src/services/exchange-work.d.ts +30 -0
- package/dist/src/services/exchange-work.d.ts.map +1 -0
- package/dist/src/services/exchange-work.js +43 -0
- package/dist/src/services/exchange-work.js.map +1 -0
- package/dist/src/services/message-send.d.ts.map +1 -1
- package/dist/src/services/message-send.js +4 -1
- package/dist/src/services/message-send.js.map +1 -1
- package/dist/src/services/metered-entitlements.d.ts +203 -0
- package/dist/src/services/metered-entitlements.d.ts.map +1 -0
- package/dist/src/services/metered-entitlements.js +264 -0
- package/dist/src/services/metered-entitlements.js.map +1 -0
- package/dist/src/services/notify.d.ts +7 -0
- package/dist/src/services/notify.d.ts.map +1 -1
- package/dist/src/services/notify.js +35 -0
- package/dist/src/services/notify.js.map +1 -1
- package/dist/src/services/owner-memory.d.ts +16 -0
- package/dist/src/services/owner-memory.d.ts.map +1 -1
- package/dist/src/services/owner-memory.js +23 -0
- package/dist/src/services/owner-memory.js.map +1 -1
- package/dist/src/services/owner-provisioning.d.ts +5 -0
- package/dist/src/services/owner-provisioning.d.ts.map +1 -1
- package/dist/src/services/owner-provisioning.js +20 -2
- package/dist/src/services/owner-provisioning.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/apps.d.ts +1 -0
- package/dist/src/storage/providers/postgres-kysely/methods/apps.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/apps.js +2 -0
- package/dist/src/storage/providers/postgres-kysely/methods/apps.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/identity.d.ts +1 -0
- package/dist/src/storage/providers/postgres-kysely/methods/identity.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/identity.js +4 -0
- package/dist/src/storage/providers/postgres-kysely/methods/identity.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/migrations/0011_unique_verified_email.sql +25 -0
- package/dist/src/storage/providers/sqlite/methods/apps.d.ts +1 -0
- package/dist/src/storage/providers/sqlite/methods/apps.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/apps.js +2 -0
- package/dist/src/storage/providers/sqlite/methods/apps.js.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts +1 -0
- package/dist/src/storage/providers/sqlite/methods/identity-nodes.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/identity-nodes.js +4 -0
- package/dist/src/storage/providers/sqlite/methods/identity-nodes.js.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.js +20 -0
- package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
- package/dist/src/storage/repositories/app.repository.d.ts +0 -0
- package/dist/src/storage/repositories/app.repository.d.ts.map +1 -1
- package/dist/src/storage/repositories/identity.repository.d.ts +6 -0
- package/dist/src/storage/repositories/identity.repository.d.ts.map +1 -1
- package/dist/src/storage/types/apps.d.ts +1 -0
- package/dist/src/storage/types/apps.d.ts.map +1 -1
- package/dist/src/storage/types/organisms-federation.d.ts +21 -0
- package/dist/src/storage/types/organisms-federation.d.ts.map +1 -1
- package/dist/src/utils/app-mobile-lint.d.ts +17 -0
- package/dist/src/utils/app-mobile-lint.d.ts.map +1 -0
- package/dist/src/utils/app-mobile-lint.js +40 -0
- package/dist/src/utils/app-mobile-lint.js.map +1 -0
- package/dist/static/app-catalog/_template.html +12 -77
- package/dist/static/app-catalog/js/apps-io.js +51 -165
- package/dist/static/app-catalog/js/cost.js +100 -0
- package/dist/static/app-catalog/js/db.js +23 -93
- package/dist/static/app-catalog/js/detail.js +158 -24
- package/dist/static/app-catalog/js/favorites.js +71 -0
- package/dist/static/app-catalog/js/i18n-data.js +90 -16
- package/dist/static/app-catalog/js/main.js +23 -103
- package/dist/static/app-catalog/js/migrate.js +88 -0
- package/dist/static/app-catalog/js/monetize.js +1 -1
- package/dist/static/app-catalog/js/promote.js +70 -0
- package/dist/static/app-catalog/js/render.js +26 -139
- package/dist/static/app-catalog/js/server-io.js +126 -223
- package/dist/static/app-catalog/js/settings.js +11 -204
- package/dist/static/app-catalog/styles/app-catalog.css +40 -0
- package/dist/static/app-catalog.html +790 -912
- package/dist/static/sdk-libs/_core/config.js +52 -0
- package/dist/static/sdk-libs/_core/http.js +52 -0
- package/dist/static/sdk-libs/_core/namespace.js +33 -0
- package/dist/static/sdk-libs/_core/sdk-globals.d.ts +50 -0
- package/dist/static/sdk-libs/_core/session.js +66 -0
- package/dist/static/sdk-libs/agentface/index.js +102 -0
- package/dist/static/sdk-libs/agents/index.js +267 -0
- package/dist/static/sdk-libs/ai/index.js +153 -0
- package/dist/static/sdk-libs/audio/core.js +111 -0
- package/dist/static/sdk-libs/audio/index.js +380 -0
- package/dist/static/sdk-libs/audio/instruments.js +369 -0
- package/dist/static/sdk-libs/auth/config.js +46 -0
- package/dist/static/sdk-libs/auth/crypto.js +166 -0
- package/dist/static/sdk-libs/auth/events.js +27 -0
- package/dist/static/sdk-libs/auth/i18n.js +64 -0
- package/dist/static/sdk-libs/auth/index.js +37 -0
- package/dist/static/sdk-libs/auth/modal.js +545 -0
- package/dist/static/sdk-libs/auth/pill.js +167 -0
- package/dist/static/sdk-libs/auth/session.js +792 -0
- package/dist/static/sdk-libs/auth/signup.js +232 -0
- package/dist/static/sdk-libs/auth/theme.js +96 -0
- package/dist/static/sdk-libs/capabilities/index.js +179 -0
- package/dist/static/sdk-libs/commerce/index.js +243 -0
- package/dist/static/sdk-libs/data/index.js +188 -0
- package/dist/static/sdk-libs/dist/aimeat-agentface.js +91 -0
- package/dist/static/sdk-libs/dist/aimeat-agents.js +315 -0
- package/dist/static/sdk-libs/dist/aimeat-ai.js +168 -0
- package/dist/static/sdk-libs/dist/aimeat-audio.js +979 -0
- package/dist/static/sdk-libs/dist/aimeat-auth.js +1831 -0
- package/dist/static/sdk-libs/dist/aimeat-capabilities.js +177 -0
- package/dist/static/sdk-libs/dist/aimeat-commerce.js +265 -0
- package/dist/static/sdk-libs/dist/aimeat-data.js +205 -0
- package/dist/static/sdk-libs/dist/aimeat-editor.js +299 -0
- package/dist/static/sdk-libs/dist/aimeat-header.js +270 -0
- package/dist/static/sdk-libs/dist/aimeat-intake.js +94 -0
- package/dist/static/sdk-libs/dist/aimeat-live.js +265 -0
- package/dist/static/sdk-libs/dist/aimeat-markdown.js +602 -0
- package/dist/static/sdk-libs/dist/aimeat-organism.js +394 -0
- package/dist/static/sdk-libs/dist/aimeat-portfolio-standalone.js +90 -0
- package/dist/static/sdk-libs/dist/aimeat-social.js +157 -0
- package/dist/static/sdk-libs/dist/aimeat-speech.js +300 -0
- package/dist/static/sdk-libs/dist/aimeat-storage.js +210 -0
- package/dist/static/sdk-libs/dist/aimeat-tunnel.js +383 -0
- package/dist/static/sdk-libs/dist/aimeat-wallet.js +118 -0
- package/dist/static/sdk-libs/dist/aimeat-webmcp.js +187 -0
- package/dist/static/sdk-libs/dist/aimeat-work.js +213 -0
- package/dist/static/sdk-libs/dist/aimeat-workflows.js +147 -0
- package/dist/static/sdk-libs/editor/index.js +229 -0
- package/dist/static/sdk-libs/header/index.js +249 -0
- package/dist/static/sdk-libs/intake/index.js +75 -0
- package/dist/static/sdk-libs/live/index.js +156 -0
- package/dist/static/sdk-libs/markdown/index.js +522 -0
- package/dist/static/sdk-libs/organism/index.js +381 -0
- package/dist/static/sdk-libs/portfolio-standalone/index.js +78 -0
- package/dist/static/sdk-libs/social/index.js +140 -0
- package/dist/static/sdk-libs/speech/index.js +321 -0
- package/dist/static/sdk-libs/storage/index.js +189 -0
- package/dist/static/sdk-libs/tunnel/index.js +428 -0
- package/dist/static/sdk-libs/wallet/index.js +115 -0
- package/dist/static/sdk-libs/webmcp/index.js +185 -0
- package/dist/static/sdk-libs/work/index.js +191 -0
- package/dist/static/sdk-libs/workflows/index.js +113 -0
- package/package.json +5 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file config.js
|
|
3
|
+
* @description Shared SDK-libs core — resolves the node URL, apex URL, node id and heartbeat
|
|
4
|
+
* interval for every served AIMEAT browser helper library. Replaces the NODE_URL / APEX_URL /
|
|
5
|
+
* NODE_ID bootstrap that was copy-pasted (as JS-inside-a-template-string) into ~13 libs. The
|
|
6
|
+
* node-URL resolution order is preserved EXACTLY from the legacy libs:
|
|
7
|
+
* `<meta name="aimeat-node">` → `location.origin` (http/https) → the node-provided fallback,
|
|
8
|
+
* which is now injected as `window.__AIMEAT_SDK_CFG__` by a tiny prelude the route prepends at
|
|
9
|
+
* serve time (in place of the old build-time `${config.baseUrl}` interpolation).
|
|
10
|
+
* @structure resolveNodeUrl() · NODE_URL · APEX_URL · NODE_ID · HEARTBEAT_MS
|
|
11
|
+
* @usage import { NODE_URL, APEX_URL, NODE_ID } from '../_core/config.js';
|
|
12
|
+
* @version-history
|
|
13
|
+
* v1.0.0 — 2026-07-19 — Initial: extracted from the per-lib inline bootstrap (SDK-libs migration Phase 0).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} SdkConfig
|
|
18
|
+
* @property {string} nodeId Node id baked by the serving node.
|
|
19
|
+
* @property {string} baseUrl Apex base URL baked by the serving node.
|
|
20
|
+
* @property {number} [heartbeatMs] Personal-node heartbeat interval, in ms.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** @returns {SdkConfig} The serve-time config prelude, or empty defaults if absent. */
|
|
24
|
+
function cfg() {
|
|
25
|
+
return window.__AIMEAT_SDK_CFG__ || { nodeId: '', baseUrl: '' };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the node URL this library talks to. Order is unchanged from the legacy per-lib bootstrap:
|
|
30
|
+
* 1. `<meta name="aimeat-node" content="…">` (trailing slash trimmed)
|
|
31
|
+
* 2. `location.origin` on http/https
|
|
32
|
+
* 3. the node-provided baseUrl fallback (serve-time prelude)
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
export function resolveNodeUrl() {
|
|
36
|
+
const meta = document.querySelector('meta[name="aimeat-node"]');
|
|
37
|
+
if (meta) return (meta.getAttribute('content') || '').replace(/\/$/, '');
|
|
38
|
+
if (location.protocol === 'http:' || location.protocol === 'https:') return location.origin;
|
|
39
|
+
return cfg().baseUrl;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The resolved node URL, evaluated once at load — same timing as the legacy IIFE bootstrap. */
|
|
43
|
+
export const NODE_URL = resolveNodeUrl();
|
|
44
|
+
|
|
45
|
+
/** The apex base URL baked by the serving node (used for the H-2 app-origin bridge). */
|
|
46
|
+
export const APEX_URL = cfg().baseUrl;
|
|
47
|
+
|
|
48
|
+
/** The serving node's id. */
|
|
49
|
+
export const NODE_ID = cfg().nodeId;
|
|
50
|
+
|
|
51
|
+
/** Personal-node heartbeat interval in ms (default 30000 — matches lib-tunnel's legacy default). */
|
|
52
|
+
export const HEARTBEAT_MS = cfg().heartbeatMs || 30000;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file http.js
|
|
3
|
+
* @description Shared SDK-libs core — the envelope-aware fetch helpers every library rolled its
|
|
4
|
+
* own copy of. `api()` performs a JSON fetch against the resolved node URL, unwraps the AIMEAT
|
|
5
|
+
* response envelope, and — critically — preserves the machine-readable `err.code` / `err.details`
|
|
6
|
+
* on the thrown Error (the sign-in modal branches on `EMAIL_NOT_VERIFIED` etc. rather than
|
|
7
|
+
* matching on message text). `authApi()` adds a bearer token. Behavior is identical to the
|
|
8
|
+
* `api()` / `authApi()` that lived inline in auth-lib-part1.
|
|
9
|
+
* @structure api(path, opts) · authApi(path, jwt, opts)
|
|
10
|
+
* @usage import { api, authApi } from '../_core/http.js';
|
|
11
|
+
* @version-history
|
|
12
|
+
* v1.0.0 — 2026-07-19 — Initial: extracted from the per-lib inline fetch helpers (SDK-libs migration Phase 0).
|
|
13
|
+
*/
|
|
14
|
+
import { NODE_URL } from './config.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An Error carrying the envelope's machine-readable code + details.
|
|
18
|
+
* @typedef {Error & { code?: string, details?: unknown }} ApiError
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Fetch `path` on the node, parse the JSON envelope, throw on `!ok` (preserving code/details).
|
|
23
|
+
* @param {string} path Path beginning with `/` (joined onto NODE_URL).
|
|
24
|
+
* @param {RequestInit} [opts] Standard fetch options; JSON content-type is added.
|
|
25
|
+
* @returns {Promise<any>} The full parsed envelope (`{ ok, data, error, … }`).
|
|
26
|
+
*/
|
|
27
|
+
export async function api(path, opts = {}) {
|
|
28
|
+
const url = NODE_URL + path;
|
|
29
|
+
const headers = { 'Content-Type': 'application/json', ...opts.headers };
|
|
30
|
+
const resp = await fetch(url, { ...opts, headers });
|
|
31
|
+
const data = await resp.json();
|
|
32
|
+
if (!data.ok) {
|
|
33
|
+
// Preserve the machine-readable code + details on the thrown Error so callers can branch
|
|
34
|
+
// (e.g. EMAIL_NOT_VERIFIED → open the email-completion flow) instead of matching on text.
|
|
35
|
+
const err = /** @type {ApiError} */ (new Error(data.error?.message || 'API error'));
|
|
36
|
+
err.code = data.error?.code;
|
|
37
|
+
err.details = data.error?.details;
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* As {@link api}, with an `Authorization: Bearer <jwt>` header.
|
|
45
|
+
* @param {string} path
|
|
46
|
+
* @param {string} jwt
|
|
47
|
+
* @param {RequestInit} [opts]
|
|
48
|
+
* @returns {Promise<any>}
|
|
49
|
+
*/
|
|
50
|
+
export async function authApi(path, jwt, opts = {}) {
|
|
51
|
+
return api(path, { ...opts, headers: { ...opts.headers, 'Authorization': 'Bearer ' + jwt } });
|
|
52
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file namespace.js
|
|
3
|
+
* @description Shared SDK-libs core — the idempotent `window.AIMEAT` attach that ~21 libs each
|
|
4
|
+
* re-implemented as `if (!global.AIMEAT) global.AIMEAT = {}; global.AIMEAT.x = x;`. `namespace()`
|
|
5
|
+
* returns the (lazily created) global object; `attach(key, value)` mounts one library surface
|
|
6
|
+
* onto it. Serving each bundle as a self-contained IIFE means load order between libs never
|
|
7
|
+
* matters — whichever runs first creates `window.AIMEAT`, the rest extend it.
|
|
8
|
+
* @structure namespace() · attach(key, value)
|
|
9
|
+
* @usage import { attach } from '../_core/namespace.js'; attach('speech', speech);
|
|
10
|
+
* @version-history
|
|
11
|
+
* v1.0.0 — 2026-07-19 — Initial: extracted from the per-lib inline global attach (SDK-libs migration Phase 0).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The global `window.AIMEAT` object, created on first use.
|
|
16
|
+
* @returns {Record<string, any>}
|
|
17
|
+
*/
|
|
18
|
+
export function namespace() {
|
|
19
|
+
if (!window.AIMEAT) window.AIMEAT = {};
|
|
20
|
+
return window.AIMEAT;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Mount one library surface onto `window.AIMEAT` (idempotent — last writer wins, as before).
|
|
25
|
+
* @param {string} key The namespace key (e.g. `'speech'`, `'data'`).
|
|
26
|
+
* @param {any} value The library object to expose.
|
|
27
|
+
* @returns {Record<string, any>} The `window.AIMEAT` object.
|
|
28
|
+
*/
|
|
29
|
+
export function attach(key, value) {
|
|
30
|
+
const ns = namespace();
|
|
31
|
+
ns[key] = value;
|
|
32
|
+
return ns;
|
|
33
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file sdk-globals.d.ts
|
|
3
|
+
* @description Ambient declarations for the browser globals the served SDK libraries touch that
|
|
4
|
+
* are not on TypeScript's stock lib.dom `Window` — the webkit-prefixed / non-standard APIs
|
|
5
|
+
* (webkitAudioContext, SpeechRecognition, webkitSpeechRecognition) plus the serve-time config
|
|
6
|
+
* prelude (window.__AIMEAT_SDK_CFG__) and the window.AIMEAT namespace. Declaring them here keeps
|
|
7
|
+
* checkJs honest at those exact call sites instead of erasing type-safety with per-site `any`
|
|
8
|
+
* casts, and is shared by every lib (e.g. audio also needs webkitAudioContext).
|
|
9
|
+
* @usage Picked up by tsconfig.sdk.json (its include globs the sdk-libs .d.ts files). No runtime effect.
|
|
10
|
+
* @version-history
|
|
11
|
+
* v1.0.0 — 2026-07-19 — Initial: webkit audio/speech globals + SDK config prelude + AIMEAT namespace.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface Window {
|
|
15
|
+
// The AIMEAT namespace is assembled dynamically across ~21 libs (each attaches its own surface);
|
|
16
|
+
// there is no single static shape, so `any` is the honest type for cross-lib member access.
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
AIMEAT?: Record<string, any>;
|
|
19
|
+
/** aimeat-agentface also exposes its surface under the convention's spec name. */
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
AIMEATAgentFace?: Record<string, any>;
|
|
22
|
+
/** Serve-time config prelude prepended to each bundle (see _core/config.js + libs/sdk-serve.ts). */
|
|
23
|
+
__AIMEAT_SDK_CFG__?: { nodeId: string; baseUrl: string; heartbeatMs?: number };
|
|
24
|
+
/** aimeat-auth's extra serve-time prelude: the OIDC providers enabled on the node (server-computed). */
|
|
25
|
+
__AIMEAT_AUTH_CFG__?: { providers: Array<{ id: string; label: string; i18nKey: string }> };
|
|
26
|
+
/** aimeat-header's idempotency guard (mounts the canonical nav at most once). */
|
|
27
|
+
__AIMEAT_HEADER_MOUNTED__?: boolean;
|
|
28
|
+
/** aimeat-auth version marker exposed globally. */
|
|
29
|
+
version?: string;
|
|
30
|
+
/** aimeat-auth password-reset flow: the username carried from step 1 to step 2. */
|
|
31
|
+
__aimeatResetUser?: string;
|
|
32
|
+
// Rich-renderer CDN globals loaded on demand by aimeat-markdown (markdown-it + plugins, DOMPurify,
|
|
33
|
+
// highlight.js, mermaid) — untyped external libraries, hence `any`.
|
|
34
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
35
|
+
markdownit?: any;
|
|
36
|
+
markdownitTaskLists?: any;
|
|
37
|
+
markdownitFootnote?: any;
|
|
38
|
+
DOMPurify?: any;
|
|
39
|
+
hljs?: any;
|
|
40
|
+
mermaid?: any;
|
|
41
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
42
|
+
/** Safari's prefixed AudioContext. */
|
|
43
|
+
webkitAudioContext?: typeof AudioContext;
|
|
44
|
+
// SpeechRecognition / webkitSpeechRecognition have no lib.dom type; the instance API is accessed
|
|
45
|
+
// dynamically (lang/continuous/onresult/…), so the constructed value is intentionally `any`.
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
SpeechRecognition?: new () => any;
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
webkitSpeechRecognition?: new () => any;
|
|
50
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file session.js
|
|
3
|
+
* @description Shared SDK-libs core — the `AIMEAT.auth` session glue that data/storage/social/…
|
|
4
|
+
* each re-implemented. `getSession()` asserts aimeat-auth.js is loaded and the user is signed in,
|
|
5
|
+
* returning the live session object; `authFetch()` delegates to `session.fetch` (which injects the
|
|
6
|
+
* bearer token, refreshes on 401, and self-heals scope drift). Behavior matches the inline
|
|
7
|
+
* `getSession()` / `authFetch()` of the legacy libs.
|
|
8
|
+
* @structure getSession(libLabel?) · authFetch(path, opts, libLabel?) · makeSession(libLabel)
|
|
9
|
+
* @usage const { authFetch } = makeSession('aimeat-wallet.js'); // names the lib in the auth-missing error
|
|
10
|
+
* @version-history
|
|
11
|
+
* v1.0.0 — 2026-07-19 — Initial: extracted from the per-lib inline session glue (SDK-libs migration Phase 0).
|
|
12
|
+
* v1.1.0 — 2026-07-20 — makeSession(libLabel) restores each lib's specific "before aimeat-<name>.js" auth-guard error (agent-locatable), preserving DRY.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The live AIMEAT session object exposed by aimeat-auth.js. Only the members libs actually read
|
|
17
|
+
* are declared; it carries more (see aimeat-auth's createSession).
|
|
18
|
+
* @typedef {Object} AimeatSession
|
|
19
|
+
* @property {(path: string, opts?: RequestInit) => Promise<any>} fetch Authed fetch → parsed envelope.
|
|
20
|
+
* @property {string} [jwt]
|
|
21
|
+
* @property {string} [ghii] Full GHII/GAII of the signed-in principal.
|
|
22
|
+
* @property {string} [owner] Bare owner name.
|
|
23
|
+
* @property {string} [displayName]
|
|
24
|
+
* @property {string[]} [roles]
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Return the current signed-in session, or throw a descriptive error. `libLabel` (the served
|
|
29
|
+
* filename, e.g. 'aimeat-wallet.js') is named in the "include aimeat-auth.js first" error so the
|
|
30
|
+
* message points at the exact lib — the locator an agent/dev needs to fix the load order.
|
|
31
|
+
* @param {string} [libLabel]
|
|
32
|
+
* @returns {AimeatSession}
|
|
33
|
+
*/
|
|
34
|
+
export function getSession(libLabel) {
|
|
35
|
+
const auth = window.AIMEAT && window.AIMEAT.auth;
|
|
36
|
+
if (!auth) {
|
|
37
|
+
throw new Error('AIMEAT.auth is required. Include aimeat-auth.js before ' + (libLabel || 'this library'));
|
|
38
|
+
}
|
|
39
|
+
const s = auth.getSession();
|
|
40
|
+
if (!s) throw new Error('Not logged in. Call AIMEAT.auth.login() first.');
|
|
41
|
+
return s;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Authed fetch against the node — delegates to the session's own `fetch` (token + refresh + heal).
|
|
46
|
+
* @param {string} path
|
|
47
|
+
* @param {RequestInit} [opts]
|
|
48
|
+
* @param {string} [libLabel] The served filename, named in the auth-missing error.
|
|
49
|
+
* @returns {Promise<any>} The parsed response envelope.
|
|
50
|
+
*/
|
|
51
|
+
export function authFetch(path, opts, libLabel) {
|
|
52
|
+
return getSession(libLabel).fetch(path, opts);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Bind the per-lib served filename once so each lib's auth-guard error names the specific file
|
|
57
|
+
* (e.g. "…before aimeat-wallet.js") instead of a generic "this library". Call sites stay unchanged.
|
|
58
|
+
* @param {string} libLabel The served filename, e.g. 'aimeat-wallet.js'.
|
|
59
|
+
* @returns {{ getSession: () => AimeatSession, authFetch: (path: string, opts?: RequestInit) => Promise<any> }}
|
|
60
|
+
*/
|
|
61
|
+
export function makeSession(libLabel) {
|
|
62
|
+
return {
|
|
63
|
+
getSession: () => getSession(libLabel),
|
|
64
|
+
authFetch: (path, opts) => authFetch(path, opts, libLabel),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file agentface/index.js
|
|
3
|
+
* @description The aimeat-agentface library (SDK-libs migration Phase 1). Publishes an app's Agent
|
|
4
|
+
* Face — the markdown read-surface agents get on the app URL via Accept: text/markdown — in one
|
|
5
|
+
* call from inside the running app: publish() composes markdown (raw string or { title, sections }),
|
|
6
|
+
* infers the app filename (opts.app > <meta name="aimeat-app"> > the /v1/apps/{owner}/{file} path),
|
|
7
|
+
* and writes the public record apps.{filename}.agentface via the authenticated memory API. Exposed
|
|
8
|
+
* as BOTH AIMEAT.agentface (house convention) and AIMEATAgentFace (spec name). Componentized ESM
|
|
9
|
+
* source esbuild bundles to the IIFE served, unchanged, at /v1/libs/aimeat-agentface.js. Ported
|
|
10
|
+
* verbatim from lib-agentface.ts — the bespoke auth-guard messages are preserved (they teach the
|
|
11
|
+
* app-owner-only serving rule), so getSession stays inline rather than using _core/session.
|
|
12
|
+
* @structure imports attach (namespace); getSession/compose/inferFilename; the `agentface` object
|
|
13
|
+
* (key/compose/publish); attach('agentface', …) + window.AIMEATAgentFace.
|
|
14
|
+
* @usage <script src="/v1/libs/aimeat-auth.js"></script><script src="/v1/libs/aimeat-agentface.js"></script>
|
|
15
|
+
* await AIMEATAgentFace.publish('# My app\n\n…', { app: 'my-app.html' });
|
|
16
|
+
* @version-history
|
|
17
|
+
* v1.0.0 — 2026-07-19 — Migrated from src/routes/lib-agentface.ts (SDK-libs migration Phase 1).
|
|
18
|
+
*/
|
|
19
|
+
import { attach } from '../_core/namespace.js';
|
|
20
|
+
|
|
21
|
+
const MAX_BYTES = 256 * 1024; // the convention cap — the node treats an oversize face as absent
|
|
22
|
+
|
|
23
|
+
function getSession() {
|
|
24
|
+
const auth = window.AIMEAT && window.AIMEAT.auth;
|
|
25
|
+
if (!auth) {
|
|
26
|
+
throw new Error('AIMEAT.auth is required. Include aimeat-auth.js before aimeat-agentface.js');
|
|
27
|
+
}
|
|
28
|
+
const s = auth.getSession();
|
|
29
|
+
if (!s) {
|
|
30
|
+
throw new Error('Not signed in. AIMEATAgentFace.publish writes the face as the signed-in user — call AIMEAT.auth.login() first. Note: the node serves only the record written by the APP OWNER; another user\'s publish lands in their own namespace and is never served.');
|
|
31
|
+
}
|
|
32
|
+
return s;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Compose { title, sections: [{ heading, body }] } into a markdown document. */
|
|
36
|
+
function compose(doc) {
|
|
37
|
+
if (!doc || typeof doc !== 'object') {
|
|
38
|
+
throw new Error('compose expects { title, sections: [{ heading, body }] }');
|
|
39
|
+
}
|
|
40
|
+
const parts = [];
|
|
41
|
+
if (doc.title) parts.push('# ' + String(doc.title).trim());
|
|
42
|
+
const sections = Array.isArray(doc.sections) ? doc.sections : [];
|
|
43
|
+
for (const s of sections) {
|
|
44
|
+
if (!s || typeof s.heading !== 'string' || !s.heading.trim()) {
|
|
45
|
+
throw new Error('Every section needs a non-empty string heading');
|
|
46
|
+
}
|
|
47
|
+
parts.push('## ' + s.heading.trim() + '\n\n' + (typeof s.body === 'string' ? s.body.trim() : ''));
|
|
48
|
+
}
|
|
49
|
+
if (parts.length === 0) throw new Error('Nothing to compose — provide a title and/or sections');
|
|
50
|
+
return parts.join('\n\n') + '\n';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Derive this app's filename: <meta name="aimeat-app">, else the /v1/apps/{owner}/{file} path. */
|
|
54
|
+
function inferFilename() {
|
|
55
|
+
const meta = typeof document !== 'undefined' && document.querySelector('meta[name="aimeat-app"]');
|
|
56
|
+
const fromMeta = meta && meta.getAttribute('content');
|
|
57
|
+
if (fromMeta && fromMeta.trim()) return fromMeta.trim();
|
|
58
|
+
const m = typeof location !== 'undefined' && location.pathname.match(/\/v1\/apps\/[^/]+\/([^/?#]+\.html?)$/i);
|
|
59
|
+
if (m) return decodeURIComponent(m[1]);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const agentface = {
|
|
64
|
+
/** The convention memory key the face lives under. */
|
|
65
|
+
key(filename) { return 'apps.' + filename + '.agentface'; },
|
|
66
|
+
|
|
67
|
+
/** The markdown composer (exposed so an app can preview what publish() will write). */
|
|
68
|
+
compose: compose,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Publish this app's agent face: a markdown string, or { title, sections: [{ heading, body }] }.
|
|
72
|
+
* opts.app names the app filename explicitly (e.g. 'my-app.html') and overrides inference —
|
|
73
|
+
* pass it on per-app subdomain origins, where the filename is not derivable from the URL.
|
|
74
|
+
* Writes the public record apps.{filename}.agentface via the authenticated memory API.
|
|
75
|
+
*/
|
|
76
|
+
async publish(input, opts) {
|
|
77
|
+
opts = opts || {};
|
|
78
|
+
const markdown = typeof input === 'string' ? input : compose(input);
|
|
79
|
+
if (!markdown.trim()) throw new Error('AIMEATAgentFace.publish: the markdown content is empty');
|
|
80
|
+
if (new TextEncoder().encode(markdown).length > MAX_BYTES) {
|
|
81
|
+
throw new Error('Agent face exceeds the 256 KB cap — the node would treat it as absent. Publish a summary and link out to records instead.');
|
|
82
|
+
}
|
|
83
|
+
const filename = typeof opts.app === 'string' && opts.app.trim() ? opts.app.trim() : inferFilename();
|
|
84
|
+
if (!filename) {
|
|
85
|
+
throw new Error('Cannot derive the app filename on this origin — pass { app: "your-file.html" } or add <meta name="aimeat-app" content="your-file.html"> to the page');
|
|
86
|
+
}
|
|
87
|
+
const session = getSession();
|
|
88
|
+
const key = agentface.key(filename);
|
|
89
|
+
const res = await session.fetch('/v1/memory', {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
body: JSON.stringify({ key: key, value: markdown, visibility: 'public' }),
|
|
92
|
+
});
|
|
93
|
+
if (!res.ok) {
|
|
94
|
+
throw new Error((res.error && res.error.message) || 'Failed to publish the agent face');
|
|
95
|
+
}
|
|
96
|
+
return { key: key, app: filename, version: res.data && res.data.version, visibility: 'public' };
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// ── Expose globally: house convention + the convention's spec name ──
|
|
101
|
+
attach('agentface', agentface);
|
|
102
|
+
window.AIMEATAgentFace = agentface;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file agents/index.js
|
|
3
|
+
* @description The aimeat-agents library (SDK-libs migration Phase 1). Exposes AIMEAT.agents — the
|
|
4
|
+
* owner-side helper an AIMEAT app uses to commission and observe the owner's agents: list/get,
|
|
5
|
+
* createTask/run, getTask/tasks/events, watch (SSE + poll fallback), deliverable/memory,
|
|
6
|
+
* pendingPrompts/answerPrompt, and cooperative cancelTask/cancelRun/cancelledTaskIds. All over the
|
|
7
|
+
* AIMEAT.auth session. Componentized ESM source esbuild bundles to the IIFE served, unchanged, at
|
|
8
|
+
* /v1/libs/aimeat-agents.js. Ported verbatim from lib-agents.ts.
|
|
9
|
+
* @structure imports authFetch (session) + attach (namespace); unwrap() envelope helper; the
|
|
10
|
+
* `agents` object; attach('agents', …). Errors throw with a `.code` (NOT_FOUND/FORBIDDEN/UNKNOWN/TIMEOUT).
|
|
11
|
+
* @usage <script src="/v1/libs/aimeat-auth.js"></script><script src="/v1/libs/aimeat-agents.js"></script>
|
|
12
|
+
* const { task, deliverable } = await AIMEAT.agents.run('my-agent', { description: '…' });
|
|
13
|
+
* @version-history
|
|
14
|
+
* v1.0.0 — 2026-07-19 — Migrated from src/routes/lib-agents.ts (SDK-libs migration Phase 1).
|
|
15
|
+
*/
|
|
16
|
+
import { makeSession } from '../_core/session.js';
|
|
17
|
+
const { authFetch } = makeSession('aimeat-agents.js');
|
|
18
|
+
import { attach } from '../_core/namespace.js';
|
|
19
|
+
|
|
20
|
+
var enc = encodeURIComponent;
|
|
21
|
+
|
|
22
|
+
// session.fetch returns the parsed AIMEAT envelope { ok, data, error }.
|
|
23
|
+
function unwrap(r, action) {
|
|
24
|
+
if (!r || !r.ok) {
|
|
25
|
+
var err = /** @type {Error & { code?: string }} */ (new Error((r && r.error && r.error.message) || (action + ' failed')));
|
|
26
|
+
err.code = (r && r.error && r.error.code) || 'UNKNOWN';
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
return r.data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 30s cache for list() so apps can call it on every render cheaply.
|
|
33
|
+
var _agentsCache = null;
|
|
34
|
+
// 10s cache for the cancelled-task-id set.
|
|
35
|
+
var _cancelSetCache = null;
|
|
36
|
+
|
|
37
|
+
var agents = {
|
|
38
|
+
/** List the owner's agents. opts.activeOnly filters to ones seen recently.
|
|
39
|
+
* opts.fresh bypasses the 30s cache. */
|
|
40
|
+
async list(opts) {
|
|
41
|
+
var now = Date.now();
|
|
42
|
+
if (!(opts && opts.fresh) && _agentsCache && (now - _agentsCache.t) < 30000) return _agentsCache.v;
|
|
43
|
+
var data = unwrap(await authFetch('/v1/agents'), 'list agents');
|
|
44
|
+
var v = data.agents || [];
|
|
45
|
+
_agentsCache = { v: v, t: now };
|
|
46
|
+
return (opts && opts.activeOnly) ? v.filter(function (a) { return !!a.last_seen; }) : v;
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/** One agent by name (or GAII), or null. */
|
|
50
|
+
async get(name) {
|
|
51
|
+
var all = await agents.list();
|
|
52
|
+
return all.find(function (a) { return a.name === name || a.gaii === name; }) || null;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/** Commission a task for an agent. Returns the created task ({ id, status, ... }).
|
|
56
|
+
* Created 'queued' by default; task-runner agents auto-activate it. */
|
|
57
|
+
async createTask(name, task) {
|
|
58
|
+
if (!task || !task.description) throw new Error('createTask requires { description }');
|
|
59
|
+
var body = {
|
|
60
|
+
title: task.title || task.description.slice(0, 80),
|
|
61
|
+
description: task.description,
|
|
62
|
+
status: task.status || 'queued',
|
|
63
|
+
};
|
|
64
|
+
var data = unwrap(await authFetch('/v1/agents/' + enc(name) + '/tasks', {
|
|
65
|
+
method: 'POST', body: JSON.stringify(body),
|
|
66
|
+
}), 'create task');
|
|
67
|
+
return data.task;
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
/** Get a single task. */
|
|
71
|
+
async getTask(name, id) {
|
|
72
|
+
return unwrap(await authFetch('/v1/agents/' + enc(name) + '/tasks/' + enc(id)), 'get task').task;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/** List an agent's tasks. opts.status filters (queued|active|done|failed|...). */
|
|
76
|
+
async tasks(name, opts) {
|
|
77
|
+
var q = '?per_page=100' + (opts && opts.status ? ('&status=' + enc(opts.status)) : '');
|
|
78
|
+
return unwrap(await authFetch('/v1/agents/' + enc(name) + '/tasks' + q), 'list tasks').tasks || [];
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
/** The task's event log (oldest-first). */
|
|
82
|
+
async events(name, id) {
|
|
83
|
+
return unwrap(await authFetch('/v1/agents/' + enc(name) + '/tasks/' + enc(id) + '/events'), 'list events').events || [];
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/** Live-watch a task: calls onUpdate(task, events) on every server change
|
|
87
|
+
* (SSE) plus a periodic poll as a safety net. Returns an unsubscribe fn. */
|
|
88
|
+
watch(name, id, onUpdate, opts) {
|
|
89
|
+
var stopped = false, es = null, pollTimer = null, debTimer = null;
|
|
90
|
+
var pollMs = (opts && opts.pollMs) || 15000;
|
|
91
|
+
async function refresh() {
|
|
92
|
+
if (stopped) return;
|
|
93
|
+
try {
|
|
94
|
+
var task = await agents.getTask(name, id);
|
|
95
|
+
var events = await agents.events(name, id);
|
|
96
|
+
if (!stopped && typeof onUpdate === 'function') onUpdate(task, events);
|
|
97
|
+
} catch { /* transient; the poll/next tick retries */ }
|
|
98
|
+
}
|
|
99
|
+
function debounced() { clearTimeout(debTimer); debTimer = setTimeout(refresh, 400); }
|
|
100
|
+
refresh();
|
|
101
|
+
pollTimer = setInterval(refresh, pollMs);
|
|
102
|
+
(async function () {
|
|
103
|
+
try {
|
|
104
|
+
var tk = unwrap(await authFetch('/v1/events/ticket', { method: 'POST' }), 'open event stream');
|
|
105
|
+
if (stopped || !tk || !tk.ticket) return;
|
|
106
|
+
es = new EventSource('/v1/events?ticket=' + enc(tk.ticket));
|
|
107
|
+
es.onmessage = debounced;
|
|
108
|
+
} catch { /* SSE unavailable — poll fallback already running */ }
|
|
109
|
+
})();
|
|
110
|
+
return function unsubscribe() {
|
|
111
|
+
stopped = true;
|
|
112
|
+
if (es) { try { es.close(); } catch { /* already closed */ } es = null; }
|
|
113
|
+
clearInterval(pollTimer); clearTimeout(debTimer);
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
/** Read the task's published deliverable (task.deliverableKey) from the
|
|
118
|
+
* agent's memory. Returns { key, value } | { key, gone:true } | null. */
|
|
119
|
+
async deliverable(name, id) {
|
|
120
|
+
var task = await agents.getTask(name, id);
|
|
121
|
+
var key = task && task.deliverableKey;
|
|
122
|
+
if (!key) return null;
|
|
123
|
+
var data = unwrap(await authFetch('/v1/memory?agent=' + enc(task.agentGaii) + '&prefix=' + enc(key) + '&per_page=20'), 'read deliverable');
|
|
124
|
+
var items = data.items || [];
|
|
125
|
+
var found = items.find(function (i) { return i.key === key; });
|
|
126
|
+
return found ? { key: key, value: found.value } : { key: key, gone: true };
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
/** Read a specific memory entry under an agent's namespace (or null). */
|
|
130
|
+
async memory(name, key) {
|
|
131
|
+
var a = await agents.get(name);
|
|
132
|
+
var gaii = (a && a.gaii) || name;
|
|
133
|
+
var data = unwrap(await authFetch('/v1/memory?agent=' + enc(gaii) + '&prefix=' + enc(key) + '&per_page=20'), 'read agent memory');
|
|
134
|
+
var items = data.items || [];
|
|
135
|
+
var found = items.find(function (i) { return i.key === key; });
|
|
136
|
+
return found ? found.value : null;
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
/** Agent questions awaiting an answer: outbound option-prompts with no reply
|
|
140
|
+
* yet. Each is { message_id, prompt_id, question, options, allow_other }. */
|
|
141
|
+
async pendingPrompts(name) {
|
|
142
|
+
var data = unwrap(await authFetch('/v1/agents/' + enc(name) + '/messages?per_page=100'), 'list messages');
|
|
143
|
+
var msgs = data.messages || [];
|
|
144
|
+
var answered = {};
|
|
145
|
+
msgs.forEach(function (m) {
|
|
146
|
+
var pa = m.metadata && (m.metadata.promptAnswer || m.metadata.prompt_answer);
|
|
147
|
+
var pid = pa && (pa.promptId || pa.prompt_id);
|
|
148
|
+
if (pid) answered[pid] = true;
|
|
149
|
+
});
|
|
150
|
+
var out = [];
|
|
151
|
+
msgs.forEach(function (m) {
|
|
152
|
+
if (m.direction !== 'outbound') return;
|
|
153
|
+
var p = m.metadata && m.metadata.prompt;
|
|
154
|
+
if (!p) return;
|
|
155
|
+
var pid = p.promptId || p.prompt_id;
|
|
156
|
+
if (!pid || answered[pid]) return;
|
|
157
|
+
out.push({
|
|
158
|
+
message_id: m.id,
|
|
159
|
+
prompt_id: pid,
|
|
160
|
+
question: p.question,
|
|
161
|
+
options: p.options || [],
|
|
162
|
+
allow_other: (p.allowOther != null ? p.allowOther : p.allow_other) !== false,
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
return out;
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
/** Answer an agent's option-prompt (owner -> agent). choice is the chosen
|
|
169
|
+
* option text, or free text when is_other is true. */
|
|
170
|
+
async answerPrompt(name, ans) {
|
|
171
|
+
if (!ans || !ans.prompt_id || !ans.choice) throw new Error('answerPrompt requires { prompt_id, choice }');
|
|
172
|
+
return unwrap(await authFetch('/v1/agents/' + enc(name) + '/messages', {
|
|
173
|
+
method: 'POST',
|
|
174
|
+
body: JSON.stringify({
|
|
175
|
+
content: ans.choice,
|
|
176
|
+
direction: 'inbound',
|
|
177
|
+
metadata: { prompt_answer: { prompt_id: ans.prompt_id, choice: ans.choice, is_other: !!ans.is_other } },
|
|
178
|
+
}),
|
|
179
|
+
}), 'answer prompt');
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
/** Commission + watch until done/failed/stalled, then resolve
|
|
183
|
+
* { task, deliverable }. Best for task-runner agents (which auto-activate).
|
|
184
|
+
* opts: { onProgress(task, events), timeoutMs, pollMs }. */
|
|
185
|
+
async run(name, task, opts) {
|
|
186
|
+
var created = await agents.createTask(name, task);
|
|
187
|
+
var id = created.id;
|
|
188
|
+
return await new Promise(function (resolve, reject) {
|
|
189
|
+
var done = false, to = null;
|
|
190
|
+
var stop = agents.watch(name, id, async function (t, events) {
|
|
191
|
+
if (opts && opts.onProgress) { try { opts.onProgress(t, events); } catch { /* progress callback errors are non-fatal */ } }
|
|
192
|
+
if (!done && (t.status === 'done' || t.status === 'failed' || t.status === 'stalled')) {
|
|
193
|
+
done = true; if (to) clearTimeout(to); stop();
|
|
194
|
+
var deliverable = t.status === 'done' ? await agents.deliverable(name, id).catch(function () { return null; }) : null;
|
|
195
|
+
resolve({ task: t, deliverable: deliverable });
|
|
196
|
+
}
|
|
197
|
+
}, opts);
|
|
198
|
+
if (opts && opts.timeoutMs > 0) {
|
|
199
|
+
to = setTimeout(function () {
|
|
200
|
+
if (!done) { done = true; stop(); var e = /** @type {Error & { code?: string, taskId?: string }} */ (new Error('run() timed out')); e.code = 'TIMEOUT'; e.taskId = id; reject(e); }
|
|
201
|
+
}, opts.timeoutMs);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
/** Cooperative-cancel a task. Writes a cancel marker the worker daemon
|
|
207
|
+
* honours before its next kickoff (so abandoned/speculative subtasks never
|
|
208
|
+
* start), AND, for immediate effect, natively pauses an active task or
|
|
209
|
+
* deletes a queued one (owner-only ops; best-effort). Returns
|
|
210
|
+
* { marked:true, native:'paused'|'deleted'|null }. */
|
|
211
|
+
async cancelTask(name, taskId, opts) {
|
|
212
|
+
await authFetch('/v1/memory', { method: 'POST', body: JSON.stringify({
|
|
213
|
+
key: 'agents.cancel.task.' + taskId,
|
|
214
|
+
value: [taskId],
|
|
215
|
+
visibility: 'owner',
|
|
216
|
+
}) });
|
|
217
|
+
var native = null;
|
|
218
|
+
try {
|
|
219
|
+
var t = await agents.getTask(name, taskId);
|
|
220
|
+
var st = t && t.status;
|
|
221
|
+
if (st === 'active') {
|
|
222
|
+
var r = await authFetch('/v1/agents/' + enc(name) + '/tasks/' + enc(taskId) + '/pause', { method: 'POST' });
|
|
223
|
+
if (r && r.ok) native = 'paused';
|
|
224
|
+
} else if (st === 'queued' || st === 'draft') {
|
|
225
|
+
var r2 = await authFetch('/v1/agents/' + enc(name) + '/tasks/' + enc(taskId), { method: 'DELETE' });
|
|
226
|
+
if (r2 && r2.ok) native = 'deleted';
|
|
227
|
+
}
|
|
228
|
+
} catch { /* native stop is best-effort; the marker still applies */ }
|
|
229
|
+
if (opts && opts.invalidate !== false) _cancelSetCache = null;
|
|
230
|
+
return { marked: true, native: native };
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
/** Cancel a whole run/batch: write one marker listing many task ids
|
|
234
|
+
* (key agents.cancel.run.<run>). Workers union all agents.cancel.* markers. */
|
|
235
|
+
async cancelRun(run, taskIds) {
|
|
236
|
+
if (!run || !Array.isArray(taskIds)) throw new Error('cancelRun requires (run, taskIds[])');
|
|
237
|
+
await authFetch('/v1/memory', { method: 'POST', body: JSON.stringify({
|
|
238
|
+
key: 'agents.cancel.run.' + run,
|
|
239
|
+
value: taskIds.map(String),
|
|
240
|
+
visibility: 'owner',
|
|
241
|
+
}) });
|
|
242
|
+
_cancelSetCache = null;
|
|
243
|
+
return { marked: true, count: taskIds.length };
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
/** The set (array) of task ids cancelled via any agents.cancel.* marker
|
|
247
|
+
* visible to the owner. 10s cache. */
|
|
248
|
+
async cancelledTaskIds(opts) {
|
|
249
|
+
var now = Date.now();
|
|
250
|
+
if (!(opts && opts.fresh) && _cancelSetCache && (now - _cancelSetCache.t) < 10000) return _cancelSetCache.v;
|
|
251
|
+
var data = unwrap(await authFetch('/v1/memory?owner_scope=true&prefix=' + enc('agents.cancel.') + '&per_page=100'), 'read cancel markers');
|
|
252
|
+
var set = {};
|
|
253
|
+
(data.items || []).forEach(function (it) {
|
|
254
|
+
var v = it.value;
|
|
255
|
+
if (Array.isArray(v)) v.forEach(function (x) { set[String(x)] = true; });
|
|
256
|
+
else if (v && typeof v === 'object') Object.keys(v).forEach(function (k) { set[k] = true; });
|
|
257
|
+
});
|
|
258
|
+
var v = Object.keys(set);
|
|
259
|
+
_cancelSetCache = { v: v, t: now };
|
|
260
|
+
return v;
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
/** Clear the cached agent list (call after creating/deleting an agent). */
|
|
264
|
+
invalidateCache() { _agentsCache = null; _cancelSetCache = null; },
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
attach('agents', agents);
|