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,315 @@
|
|
|
1
|
+
// GENERATED FILE — do not edit directly. Source: src/static/sdk-libs/agents/ (+ _core/).
|
|
2
|
+
// Rebuild: pnpm build:sdk · Served at /v1/libs/aimeat-agents.js (with a per-node config prelude).
|
|
3
|
+
"use strict";
|
|
4
|
+
(() => {
|
|
5
|
+
// src/static/sdk-libs/_core/session.js
|
|
6
|
+
function getSession(libLabel) {
|
|
7
|
+
const auth = window.AIMEAT && window.AIMEAT.auth;
|
|
8
|
+
if (!auth) {
|
|
9
|
+
throw new Error("AIMEAT.auth is required. Include aimeat-auth.js before " + (libLabel || "this library"));
|
|
10
|
+
}
|
|
11
|
+
const s = auth.getSession();
|
|
12
|
+
if (!s) throw new Error("Not logged in. Call AIMEAT.auth.login() first.");
|
|
13
|
+
return s;
|
|
14
|
+
}
|
|
15
|
+
function authFetch(path, opts, libLabel) {
|
|
16
|
+
return getSession(libLabel).fetch(path, opts);
|
|
17
|
+
}
|
|
18
|
+
function makeSession(libLabel) {
|
|
19
|
+
return {
|
|
20
|
+
getSession: () => getSession(libLabel),
|
|
21
|
+
authFetch: (path, opts) => authFetch(path, opts, libLabel)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/static/sdk-libs/_core/namespace.js
|
|
26
|
+
function namespace() {
|
|
27
|
+
if (!window.AIMEAT) window.AIMEAT = {};
|
|
28
|
+
return window.AIMEAT;
|
|
29
|
+
}
|
|
30
|
+
function attach(key, value) {
|
|
31
|
+
const ns = namespace();
|
|
32
|
+
ns[key] = value;
|
|
33
|
+
return ns;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/static/sdk-libs/agents/index.js
|
|
37
|
+
var { authFetch: authFetch2 } = makeSession("aimeat-agents.js");
|
|
38
|
+
var enc = encodeURIComponent;
|
|
39
|
+
function unwrap(r, action) {
|
|
40
|
+
if (!r || !r.ok) {
|
|
41
|
+
var err = (
|
|
42
|
+
/** @type {Error & { code?: string }} */
|
|
43
|
+
new Error(r && r.error && r.error.message || action + " failed")
|
|
44
|
+
);
|
|
45
|
+
err.code = r && r.error && r.error.code || "UNKNOWN";
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
return r.data;
|
|
49
|
+
}
|
|
50
|
+
var _agentsCache = null;
|
|
51
|
+
var _cancelSetCache = null;
|
|
52
|
+
var agents = {
|
|
53
|
+
/** List the owner's agents. opts.activeOnly filters to ones seen recently.
|
|
54
|
+
* opts.fresh bypasses the 30s cache. */
|
|
55
|
+
async list(opts) {
|
|
56
|
+
var now = Date.now();
|
|
57
|
+
if (!(opts && opts.fresh) && _agentsCache && now - _agentsCache.t < 3e4) return _agentsCache.v;
|
|
58
|
+
var data = unwrap(await authFetch2("/v1/agents"), "list agents");
|
|
59
|
+
var v = data.agents || [];
|
|
60
|
+
_agentsCache = { v, t: now };
|
|
61
|
+
return opts && opts.activeOnly ? v.filter(function(a) {
|
|
62
|
+
return !!a.last_seen;
|
|
63
|
+
}) : v;
|
|
64
|
+
},
|
|
65
|
+
/** One agent by name (or GAII), or null. */
|
|
66
|
+
async get(name) {
|
|
67
|
+
var all = await agents.list();
|
|
68
|
+
return all.find(function(a) {
|
|
69
|
+
return a.name === name || a.gaii === name;
|
|
70
|
+
}) || null;
|
|
71
|
+
},
|
|
72
|
+
/** Commission a task for an agent. Returns the created task ({ id, status, ... }).
|
|
73
|
+
* Created 'queued' by default; task-runner agents auto-activate it. */
|
|
74
|
+
async createTask(name, task) {
|
|
75
|
+
if (!task || !task.description) throw new Error("createTask requires { description }");
|
|
76
|
+
var body = {
|
|
77
|
+
title: task.title || task.description.slice(0, 80),
|
|
78
|
+
description: task.description,
|
|
79
|
+
status: task.status || "queued"
|
|
80
|
+
};
|
|
81
|
+
var data = unwrap(await authFetch2("/v1/agents/" + enc(name) + "/tasks", {
|
|
82
|
+
method: "POST",
|
|
83
|
+
body: JSON.stringify(body)
|
|
84
|
+
}), "create task");
|
|
85
|
+
return data.task;
|
|
86
|
+
},
|
|
87
|
+
/** Get a single task. */
|
|
88
|
+
async getTask(name, id) {
|
|
89
|
+
return unwrap(await authFetch2("/v1/agents/" + enc(name) + "/tasks/" + enc(id)), "get task").task;
|
|
90
|
+
},
|
|
91
|
+
/** List an agent's tasks. opts.status filters (queued|active|done|failed|...). */
|
|
92
|
+
async tasks(name, opts) {
|
|
93
|
+
var q = "?per_page=100" + (opts && opts.status ? "&status=" + enc(opts.status) : "");
|
|
94
|
+
return unwrap(await authFetch2("/v1/agents/" + enc(name) + "/tasks" + q), "list tasks").tasks || [];
|
|
95
|
+
},
|
|
96
|
+
/** The task's event log (oldest-first). */
|
|
97
|
+
async events(name, id) {
|
|
98
|
+
return unwrap(await authFetch2("/v1/agents/" + enc(name) + "/tasks/" + enc(id) + "/events"), "list events").events || [];
|
|
99
|
+
},
|
|
100
|
+
/** Live-watch a task: calls onUpdate(task, events) on every server change
|
|
101
|
+
* (SSE) plus a periodic poll as a safety net. Returns an unsubscribe fn. */
|
|
102
|
+
watch(name, id, onUpdate, opts) {
|
|
103
|
+
var stopped = false, es = null, pollTimer = null, debTimer = null;
|
|
104
|
+
var pollMs = opts && opts.pollMs || 15e3;
|
|
105
|
+
async function refresh() {
|
|
106
|
+
if (stopped) return;
|
|
107
|
+
try {
|
|
108
|
+
var task = await agents.getTask(name, id);
|
|
109
|
+
var events = await agents.events(name, id);
|
|
110
|
+
if (!stopped && typeof onUpdate === "function") onUpdate(task, events);
|
|
111
|
+
} catch {
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function debounced() {
|
|
115
|
+
clearTimeout(debTimer);
|
|
116
|
+
debTimer = setTimeout(refresh, 400);
|
|
117
|
+
}
|
|
118
|
+
refresh();
|
|
119
|
+
pollTimer = setInterval(refresh, pollMs);
|
|
120
|
+
(async function() {
|
|
121
|
+
try {
|
|
122
|
+
var tk = unwrap(await authFetch2("/v1/events/ticket", { method: "POST" }), "open event stream");
|
|
123
|
+
if (stopped || !tk || !tk.ticket) return;
|
|
124
|
+
es = new EventSource("/v1/events?ticket=" + enc(tk.ticket));
|
|
125
|
+
es.onmessage = debounced;
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
})();
|
|
129
|
+
return function unsubscribe() {
|
|
130
|
+
stopped = true;
|
|
131
|
+
if (es) {
|
|
132
|
+
try {
|
|
133
|
+
es.close();
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
es = null;
|
|
137
|
+
}
|
|
138
|
+
clearInterval(pollTimer);
|
|
139
|
+
clearTimeout(debTimer);
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
/** Read the task's published deliverable (task.deliverableKey) from the
|
|
143
|
+
* agent's memory. Returns { key, value } | { key, gone:true } | null. */
|
|
144
|
+
async deliverable(name, id) {
|
|
145
|
+
var task = await agents.getTask(name, id);
|
|
146
|
+
var key = task && task.deliverableKey;
|
|
147
|
+
if (!key) return null;
|
|
148
|
+
var data = unwrap(await authFetch2("/v1/memory?agent=" + enc(task.agentGaii) + "&prefix=" + enc(key) + "&per_page=20"), "read deliverable");
|
|
149
|
+
var items = data.items || [];
|
|
150
|
+
var found = items.find(function(i) {
|
|
151
|
+
return i.key === key;
|
|
152
|
+
});
|
|
153
|
+
return found ? { key, value: found.value } : { key, gone: true };
|
|
154
|
+
},
|
|
155
|
+
/** Read a specific memory entry under an agent's namespace (or null). */
|
|
156
|
+
async memory(name, key) {
|
|
157
|
+
var a = await agents.get(name);
|
|
158
|
+
var gaii = a && a.gaii || name;
|
|
159
|
+
var data = unwrap(await authFetch2("/v1/memory?agent=" + enc(gaii) + "&prefix=" + enc(key) + "&per_page=20"), "read agent memory");
|
|
160
|
+
var items = data.items || [];
|
|
161
|
+
var found = items.find(function(i) {
|
|
162
|
+
return i.key === key;
|
|
163
|
+
});
|
|
164
|
+
return found ? found.value : null;
|
|
165
|
+
},
|
|
166
|
+
/** Agent questions awaiting an answer: outbound option-prompts with no reply
|
|
167
|
+
* yet. Each is { message_id, prompt_id, question, options, allow_other }. */
|
|
168
|
+
async pendingPrompts(name) {
|
|
169
|
+
var data = unwrap(await authFetch2("/v1/agents/" + enc(name) + "/messages?per_page=100"), "list messages");
|
|
170
|
+
var msgs = data.messages || [];
|
|
171
|
+
var answered = {};
|
|
172
|
+
msgs.forEach(function(m) {
|
|
173
|
+
var pa = m.metadata && (m.metadata.promptAnswer || m.metadata.prompt_answer);
|
|
174
|
+
var pid = pa && (pa.promptId || pa.prompt_id);
|
|
175
|
+
if (pid) answered[pid] = true;
|
|
176
|
+
});
|
|
177
|
+
var out = [];
|
|
178
|
+
msgs.forEach(function(m) {
|
|
179
|
+
if (m.direction !== "outbound") return;
|
|
180
|
+
var p = m.metadata && m.metadata.prompt;
|
|
181
|
+
if (!p) return;
|
|
182
|
+
var pid = p.promptId || p.prompt_id;
|
|
183
|
+
if (!pid || answered[pid]) return;
|
|
184
|
+
out.push({
|
|
185
|
+
message_id: m.id,
|
|
186
|
+
prompt_id: pid,
|
|
187
|
+
question: p.question,
|
|
188
|
+
options: p.options || [],
|
|
189
|
+
allow_other: (p.allowOther != null ? p.allowOther : p.allow_other) !== false
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
return out;
|
|
193
|
+
},
|
|
194
|
+
/** Answer an agent's option-prompt (owner -> agent). choice is the chosen
|
|
195
|
+
* option text, or free text when is_other is true. */
|
|
196
|
+
async answerPrompt(name, ans) {
|
|
197
|
+
if (!ans || !ans.prompt_id || !ans.choice) throw new Error("answerPrompt requires { prompt_id, choice }");
|
|
198
|
+
return unwrap(await authFetch2("/v1/agents/" + enc(name) + "/messages", {
|
|
199
|
+
method: "POST",
|
|
200
|
+
body: JSON.stringify({
|
|
201
|
+
content: ans.choice,
|
|
202
|
+
direction: "inbound",
|
|
203
|
+
metadata: { prompt_answer: { prompt_id: ans.prompt_id, choice: ans.choice, is_other: !!ans.is_other } }
|
|
204
|
+
})
|
|
205
|
+
}), "answer prompt");
|
|
206
|
+
},
|
|
207
|
+
/** Commission + watch until done/failed/stalled, then resolve
|
|
208
|
+
* { task, deliverable }. Best for task-runner agents (which auto-activate).
|
|
209
|
+
* opts: { onProgress(task, events), timeoutMs, pollMs }. */
|
|
210
|
+
async run(name, task, opts) {
|
|
211
|
+
var created = await agents.createTask(name, task);
|
|
212
|
+
var id = created.id;
|
|
213
|
+
return await new Promise(function(resolve, reject) {
|
|
214
|
+
var done = false, to = null;
|
|
215
|
+
var stop = agents.watch(name, id, async function(t, events) {
|
|
216
|
+
if (opts && opts.onProgress) {
|
|
217
|
+
try {
|
|
218
|
+
opts.onProgress(t, events);
|
|
219
|
+
} catch {
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (!done && (t.status === "done" || t.status === "failed" || t.status === "stalled")) {
|
|
223
|
+
done = true;
|
|
224
|
+
if (to) clearTimeout(to);
|
|
225
|
+
stop();
|
|
226
|
+
var deliverable = t.status === "done" ? await agents.deliverable(name, id).catch(function() {
|
|
227
|
+
return null;
|
|
228
|
+
}) : null;
|
|
229
|
+
resolve({ task: t, deliverable });
|
|
230
|
+
}
|
|
231
|
+
}, opts);
|
|
232
|
+
if (opts && opts.timeoutMs > 0) {
|
|
233
|
+
to = setTimeout(function() {
|
|
234
|
+
if (!done) {
|
|
235
|
+
done = true;
|
|
236
|
+
stop();
|
|
237
|
+
var e = (
|
|
238
|
+
/** @type {Error & { code?: string, taskId?: string }} */
|
|
239
|
+
new Error("run() timed out")
|
|
240
|
+
);
|
|
241
|
+
e.code = "TIMEOUT";
|
|
242
|
+
e.taskId = id;
|
|
243
|
+
reject(e);
|
|
244
|
+
}
|
|
245
|
+
}, opts.timeoutMs);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
/** Cooperative-cancel a task. Writes a cancel marker the worker daemon
|
|
250
|
+
* honours before its next kickoff (so abandoned/speculative subtasks never
|
|
251
|
+
* start), AND, for immediate effect, natively pauses an active task or
|
|
252
|
+
* deletes a queued one (owner-only ops; best-effort). Returns
|
|
253
|
+
* { marked:true, native:'paused'|'deleted'|null }. */
|
|
254
|
+
async cancelTask(name, taskId, opts) {
|
|
255
|
+
await authFetch2("/v1/memory", { method: "POST", body: JSON.stringify({
|
|
256
|
+
key: "agents.cancel.task." + taskId,
|
|
257
|
+
value: [taskId],
|
|
258
|
+
visibility: "owner"
|
|
259
|
+
}) });
|
|
260
|
+
var native = null;
|
|
261
|
+
try {
|
|
262
|
+
var t = await agents.getTask(name, taskId);
|
|
263
|
+
var st = t && t.status;
|
|
264
|
+
if (st === "active") {
|
|
265
|
+
var r = await authFetch2("/v1/agents/" + enc(name) + "/tasks/" + enc(taskId) + "/pause", { method: "POST" });
|
|
266
|
+
if (r && r.ok) native = "paused";
|
|
267
|
+
} else if (st === "queued" || st === "draft") {
|
|
268
|
+
var r2 = await authFetch2("/v1/agents/" + enc(name) + "/tasks/" + enc(taskId), { method: "DELETE" });
|
|
269
|
+
if (r2 && r2.ok) native = "deleted";
|
|
270
|
+
}
|
|
271
|
+
} catch {
|
|
272
|
+
}
|
|
273
|
+
if (opts && opts.invalidate !== false) _cancelSetCache = null;
|
|
274
|
+
return { marked: true, native };
|
|
275
|
+
},
|
|
276
|
+
/** Cancel a whole run/batch: write one marker listing many task ids
|
|
277
|
+
* (key agents.cancel.run.<run>). Workers union all agents.cancel.* markers. */
|
|
278
|
+
async cancelRun(run, taskIds) {
|
|
279
|
+
if (!run || !Array.isArray(taskIds)) throw new Error("cancelRun requires (run, taskIds[])");
|
|
280
|
+
await authFetch2("/v1/memory", { method: "POST", body: JSON.stringify({
|
|
281
|
+
key: "agents.cancel.run." + run,
|
|
282
|
+
value: taskIds.map(String),
|
|
283
|
+
visibility: "owner"
|
|
284
|
+
}) });
|
|
285
|
+
_cancelSetCache = null;
|
|
286
|
+
return { marked: true, count: taskIds.length };
|
|
287
|
+
},
|
|
288
|
+
/** The set (array) of task ids cancelled via any agents.cancel.* marker
|
|
289
|
+
* visible to the owner. 10s cache. */
|
|
290
|
+
async cancelledTaskIds(opts) {
|
|
291
|
+
var now = Date.now();
|
|
292
|
+
if (!(opts && opts.fresh) && _cancelSetCache && now - _cancelSetCache.t < 1e4) return _cancelSetCache.v;
|
|
293
|
+
var data = unwrap(await authFetch2("/v1/memory?owner_scope=true&prefix=" + enc("agents.cancel.") + "&per_page=100"), "read cancel markers");
|
|
294
|
+
var set = {};
|
|
295
|
+
(data.items || []).forEach(function(it) {
|
|
296
|
+
var v2 = it.value;
|
|
297
|
+
if (Array.isArray(v2)) v2.forEach(function(x) {
|
|
298
|
+
set[String(x)] = true;
|
|
299
|
+
});
|
|
300
|
+
else if (v2 && typeof v2 === "object") Object.keys(v2).forEach(function(k) {
|
|
301
|
+
set[k] = true;
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
var v = Object.keys(set);
|
|
305
|
+
_cancelSetCache = { v, t: now };
|
|
306
|
+
return v;
|
|
307
|
+
},
|
|
308
|
+
/** Clear the cached agent list (call after creating/deleting an agent). */
|
|
309
|
+
invalidateCache() {
|
|
310
|
+
_agentsCache = null;
|
|
311
|
+
_cancelSetCache = null;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
attach("agents", agents);
|
|
315
|
+
})();
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// GENERATED FILE — do not edit directly. Source: src/static/sdk-libs/ai/ (+ _core/).
|
|
2
|
+
// Rebuild: pnpm build:sdk · Served at /v1/libs/aimeat-ai.js (with a per-node config prelude).
|
|
3
|
+
"use strict";
|
|
4
|
+
(() => {
|
|
5
|
+
// src/static/sdk-libs/_core/session.js
|
|
6
|
+
function getSession(libLabel) {
|
|
7
|
+
const auth = window.AIMEAT && window.AIMEAT.auth;
|
|
8
|
+
if (!auth) {
|
|
9
|
+
throw new Error("AIMEAT.auth is required. Include aimeat-auth.js before " + (libLabel || "this library"));
|
|
10
|
+
}
|
|
11
|
+
const s = auth.getSession();
|
|
12
|
+
if (!s) throw new Error("Not logged in. Call AIMEAT.auth.login() first.");
|
|
13
|
+
return s;
|
|
14
|
+
}
|
|
15
|
+
function authFetch(path, opts, libLabel) {
|
|
16
|
+
return getSession(libLabel).fetch(path, opts);
|
|
17
|
+
}
|
|
18
|
+
function makeSession(libLabel) {
|
|
19
|
+
return {
|
|
20
|
+
getSession: () => getSession(libLabel),
|
|
21
|
+
authFetch: (path, opts) => authFetch(path, opts, libLabel)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/static/sdk-libs/_core/namespace.js
|
|
26
|
+
function namespace() {
|
|
27
|
+
if (!window.AIMEAT) window.AIMEAT = {};
|
|
28
|
+
return window.AIMEAT;
|
|
29
|
+
}
|
|
30
|
+
function attach(key, value) {
|
|
31
|
+
const ns = namespace();
|
|
32
|
+
ns[key] = value;
|
|
33
|
+
return ns;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/static/sdk-libs/ai/index.js
|
|
37
|
+
var { authFetch: authFetch2 } = makeSession("aimeat-ai.js");
|
|
38
|
+
var _availCache = null;
|
|
39
|
+
var _modelsCache = null;
|
|
40
|
+
var ai = {
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if the user has AI configured (an OpenRouter key, or a keyless
|
|
43
|
+
* self-hosted provider). Cached 60 seconds. Apps should call this before showing
|
|
44
|
+
* "Use AI" buttons. Uses GET /v1/ai/available, which an app-grant token (a sandboxed
|
|
45
|
+
* app on the isolated app origin) can call with the ai:use scope — unlike the
|
|
46
|
+
* owner-only /v1/openrouter/settings. Falls back to that settings probe on older nodes.
|
|
47
|
+
*/
|
|
48
|
+
async isAvailable() {
|
|
49
|
+
const now = Date.now();
|
|
50
|
+
if (_availCache && now - _availCache.t < 6e4) return _availCache.v;
|
|
51
|
+
try {
|
|
52
|
+
const r = await authFetch2("/v1/ai/available");
|
|
53
|
+
if (r && r.ok && r.data && typeof r.data.available === "boolean") {
|
|
54
|
+
_availCache = { v: r.data.available, t: now };
|
|
55
|
+
return r.data.available;
|
|
56
|
+
}
|
|
57
|
+
const s = await authFetch2("/v1/openrouter/settings");
|
|
58
|
+
const v = !!(s && s.ok && s.data && (s.data.hasApiKey || s.data.has_api_key));
|
|
59
|
+
_availCache = { v, t: now };
|
|
60
|
+
return v;
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Run a single completion. Returns { content, model, usage, budget }.
|
|
67
|
+
* Throws an Error with .code set on quota/permission/auth failures.
|
|
68
|
+
*
|
|
69
|
+
* Recognized error codes (see routes/ai.ts):
|
|
70
|
+
* NO_API_KEY — user hasn't set up a key yet
|
|
71
|
+
* QUOTA_EXHAUSTED — daily user budget hit
|
|
72
|
+
* APP_QUOTA_EXHAUSTED — per-app daily quota hit
|
|
73
|
+
* APP_NOT_ALLOWED — app_id not in user's allowlist
|
|
74
|
+
* APP_ID_REQUIRED — user has an allowlist; app must pass app_id
|
|
75
|
+
* INVALID_API_KEY — provider rejected the key
|
|
76
|
+
* RATE_LIMITED — provider rate limit
|
|
77
|
+
* PROVIDER_ERROR — upstream provider failed
|
|
78
|
+
*/
|
|
79
|
+
async complete(opts) {
|
|
80
|
+
if (!opts || typeof opts !== "object") throw new Error("opts object required");
|
|
81
|
+
if (!opts.prompt) throw new Error("opts.prompt required");
|
|
82
|
+
const body = {
|
|
83
|
+
prompt: opts.prompt,
|
|
84
|
+
systemPrompt: opts.systemPrompt,
|
|
85
|
+
model: opts.model,
|
|
86
|
+
modelRole: opts.modelRole,
|
|
87
|
+
temperature: opts.temperature,
|
|
88
|
+
top_p: opts.top_p,
|
|
89
|
+
max_tokens: opts.max_tokens,
|
|
90
|
+
app_id: opts.app_id
|
|
91
|
+
};
|
|
92
|
+
const r = await authFetch2("/v1/ai/complete", {
|
|
93
|
+
method: "POST",
|
|
94
|
+
body: JSON.stringify(body)
|
|
95
|
+
});
|
|
96
|
+
if (!r || !r.ok) {
|
|
97
|
+
const code = r && r.error && r.error.code || "UNKNOWN";
|
|
98
|
+
const msg = r && r.error && r.error.message || "AI call failed";
|
|
99
|
+
const err = (
|
|
100
|
+
/** @type {Error & { code?: string }} */
|
|
101
|
+
new Error(msg)
|
|
102
|
+
);
|
|
103
|
+
err.code = code;
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
return r.data;
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Convenience: complete + JSON.parse. Adds a "return ONLY valid JSON"
|
|
110
|
+
* suffix to systemPrompt. On parse failure, retries ONCE with a stronger
|
|
111
|
+
* instruction. Further failures throw — the user can retry by clicking.
|
|
112
|
+
*/
|
|
113
|
+
async completeJson(opts) {
|
|
114
|
+
const suffix = "\nReturn ONLY valid JSON, no prose, no markdown fences.";
|
|
115
|
+
const first = await ai.complete({
|
|
116
|
+
...opts,
|
|
117
|
+
systemPrompt: (opts.systemPrompt || "") + suffix
|
|
118
|
+
});
|
|
119
|
+
try {
|
|
120
|
+
return { ...first, parsed: JSON.parse(first.content) };
|
|
121
|
+
} catch {
|
|
122
|
+
const retry = await ai.complete({
|
|
123
|
+
...opts,
|
|
124
|
+
systemPrompt: (opts.systemPrompt || "") + suffix + "\nIMPORTANT: your previous attempt was not valid JSON. Output ONLY the JSON object, starting with { and ending with }. No other text.",
|
|
125
|
+
temperature: typeof opts.temperature === "number" ? Math.max(0, opts.temperature - 0.3) : 0.2
|
|
126
|
+
});
|
|
127
|
+
try {
|
|
128
|
+
return { ...retry, parsed: JSON.parse(retry.content) };
|
|
129
|
+
} catch {
|
|
130
|
+
const err = (
|
|
131
|
+
/** @type {Error & { code?: string }} */
|
|
132
|
+
new Error("AI returned invalid JSON twice. Original response: " + retry.content.slice(0, 200))
|
|
133
|
+
);
|
|
134
|
+
err.code = "JSON_PARSE_FAILED";
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
/**
|
|
140
|
+
* List the models the user's account can hit. Cached 1 hour.
|
|
141
|
+
*/
|
|
142
|
+
async models() {
|
|
143
|
+
const now = Date.now();
|
|
144
|
+
if (_modelsCache && now - _modelsCache.t < 36e5) return _modelsCache.v;
|
|
145
|
+
const r = await authFetch2("/v1/openrouter/models");
|
|
146
|
+
if (!r || !r.ok) throw new Error(r && r.error && r.error.message || "Failed to list models");
|
|
147
|
+
const v = r.data && r.data.models ? r.data.models : [];
|
|
148
|
+
_modelsCache = { v, t: now };
|
|
149
|
+
return v;
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* Today's spend snapshot (owner-only). Useful for "AI used: $0.04 / $1.00".
|
|
153
|
+
*/
|
|
154
|
+
async usage() {
|
|
155
|
+
const r = await authFetch2("/v1/ai/usage");
|
|
156
|
+
if (!r || !r.ok) throw new Error(r && r.error && r.error.message || "Failed to read usage");
|
|
157
|
+
return r.data;
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* Clear browser-side caches. Call after the user toggles their key/budget.
|
|
161
|
+
*/
|
|
162
|
+
invalidateCache() {
|
|
163
|
+
_availCache = null;
|
|
164
|
+
_modelsCache = null;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
attach("ai", ai);
|
|
168
|
+
})();
|