aimeat 2.1.0 → 2.2.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/.env.example +9 -4
- package/dist/locales/en.json +28 -0
- package/dist/locales/fi.json +28 -0
- package/dist/public/cortex-bundled/aimeat-charts.js +158 -10
- package/dist/public/cortex-bundled/aimeat-charts.yaml +1 -1
- package/dist/public/cortex-bundled/aimeat-dag.js +515 -173
- package/dist/public/cortex-bundled/aimeat-dag.yaml +1 -1
- package/dist/public/cortex-bundled/aimeat-i18n.js +6 -1
- package/dist/public/cortex-bundled/aimeat-i18n.yaml +1 -1
- package/dist/public/cortex-bundled/aimeat-surface.js +577 -0
- package/dist/public/cortex-bundled/aimeat-surface.yaml +107 -0
- package/dist/public/cortex-bundled/aimeat-viewport.js +405 -0
- package/dist/public/cortex-bundled/aimeat-viewport.yaml +100 -0
- package/dist/public/css/views/inbox.css +1 -1
- package/dist/public/css/views/profile.css +9 -0
- package/dist/public/lib/VENDORED.md +6 -3
- package/dist/public/lib/aimeat-daisyui-bridge.css +39 -2
- package/dist/public/lib/aimeat-theme.css +538 -0
- package/dist/public/lib/fonts/LICENSE.md +11 -4
- package/dist/public/lib/fonts/fraunces-var-latin-ext.woff2 +0 -0
- package/dist/public/lib/fonts/fraunces-var-latin.woff2 +0 -0
- package/dist/public/lib/fonts/inter-var-latin-ext.woff2 +0 -0
- package/dist/public/lib/fonts/inter-var-latin.woff2 +0 -0
- package/dist/public/lib/fonts/jetbrains-mono-var-latin-ext.woff2 +0 -0
- package/dist/public/lib/fonts/jetbrains-mono-var-latin.woff2 +0 -0
- package/dist/public/lib/fonts/space-grotesk-var-latin-ext.woff2 +0 -0
- package/dist/public/lib/fonts/space-grotesk-var-latin.woff2 +0 -0
- package/dist/public/lib/samples/theme-check.html +92 -0
- package/dist/public/lib/samples/themes-boot.js +20 -0
- package/dist/public/lib/samples/themes.html +154 -0
- package/dist/public/lib/samples/themes.js +60 -0
- package/dist/public/views/profile/access-tab/connected-apps.js +81 -5
- package/dist/public/views/profile/extensions-tab.maturity.js +4 -1
- package/dist/public/views/profile/inbox-tab/components.js +17 -1
- package/dist/public/views/profile/inbox-tab/use-thread-ux.js +29 -2
- package/dist/public/views/profile/libraries-tab.js +10 -2
- package/dist/public/views/profile/wallet-tab.js +64 -0
- package/dist/scripts/check-openapi.d.ts +2 -0
- package/dist/scripts/check-openapi.d.ts.map +1 -0
- package/dist/scripts/check-openapi.js +139 -0
- package/dist/scripts/check-openapi.js.map +1 -0
- package/dist/scripts/embed-viewport.d.ts +23 -0
- package/dist/scripts/embed-viewport.d.ts.map +1 -0
- package/dist/scripts/embed-viewport.js +116 -0
- package/dist/scripts/embed-viewport.js.map +1 -0
- package/dist/src/auth/sse-domain-scopes.d.ts +50 -0
- package/dist/src/auth/sse-domain-scopes.d.ts.map +1 -0
- package/dist/src/auth/sse-domain-scopes.js +111 -0
- package/dist/src/auth/sse-domain-scopes.js.map +1 -0
- package/dist/src/cli/connect/mcp/tools/agent-tasks.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/tools/agent-tasks.js +4 -1
- package/dist/src/cli/connect/mcp/tools/agent-tasks.js.map +1 -1
- package/dist/src/cli/connect/mcp/tools/core.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/tools/core.js +14 -3
- package/dist/src/cli/connect/mcp/tools/core.js.map +1 -1
- package/dist/src/cli/connect/mcp/tools/workspaces.d.ts +3 -0
- package/dist/src/cli/connect/mcp/tools/workspaces.d.ts.map +1 -1
- package/dist/src/cli/connect/mcp/tools/workspaces.js +4 -2
- package/dist/src/cli/connect/mcp/tools/workspaces.js.map +1 -1
- package/dist/src/cli/connect/tool-call-defs-core.d.ts.map +1 -1
- package/dist/src/cli/connect/tool-call-defs-core.js +13 -1
- package/dist/src/cli/connect/tool-call-defs-core.js.map +1 -1
- package/dist/src/commerce/__tests__/x402-registry.test.d.ts +2 -0
- package/dist/src/commerce/__tests__/x402-registry.test.d.ts.map +1 -0
- package/dist/src/commerce/__tests__/x402-registry.test.js +105 -0
- package/dist/src/commerce/__tests__/x402-registry.test.js.map +1 -0
- package/dist/src/commerce/evm-address.d.ts +21 -0
- package/dist/src/commerce/evm-address.d.ts.map +1 -0
- package/dist/src/commerce/evm-address.js +94 -0
- package/dist/src/commerce/evm-address.js.map +1 -0
- package/dist/src/commerce/money.d.ts +18 -5
- package/dist/src/commerce/money.d.ts.map +1 -1
- package/dist/src/commerce/money.js +27 -6
- package/dist/src/commerce/money.js.map +1 -1
- package/dist/src/commerce/x402-facilitator.d.ts +64 -13
- package/dist/src/commerce/x402-facilitator.d.ts.map +1 -1
- package/dist/src/commerce/x402-facilitator.js +71 -19
- package/dist/src/commerce/x402-facilitator.js.map +1 -1
- package/dist/src/commerce/x402-handler.d.ts +13 -7
- package/dist/src/commerce/x402-handler.d.ts.map +1 -1
- package/dist/src/commerce/x402-handler.js +23 -10
- package/dist/src/commerce/x402-handler.js.map +1 -1
- package/dist/src/commerce/x402.d.ts +11 -6
- package/dist/src/commerce/x402.d.ts.map +1 -1
- package/dist/src/commerce/x402.js +10 -7
- package/dist/src/commerce/x402.js.map +1 -1
- package/dist/src/config-types.d.ts +12 -0
- package/dist/src/config-types.d.ts.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +8 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/data/app-templates/shells.d.ts +11 -3
- package/dist/src/data/app-templates/shells.d.ts.map +1 -1
- package/dist/src/data/app-templates/shells.js +87 -6
- package/dist/src/data/app-templates/shells.js.map +1 -1
- package/dist/src/data/app-templates.js +2 -2
- package/dist/src/data/app-templates.js.map +1 -1
- package/dist/src/data/library-packs/cortex.d.ts.map +1 -1
- package/dist/src/data/library-packs/cortex.js +108 -5
- package/dist/src/data/library-packs/cortex.js.map +1 -1
- package/dist/src/data/library-packs/sdk.d.ts.map +1 -1
- package/dist/src/data/library-packs/sdk.js +32 -8
- package/dist/src/data/library-packs/sdk.js.map +1 -1
- package/dist/src/data/library-packs/vendored.d.ts.map +1 -1
- package/dist/src/data/library-packs/vendored.js +83 -6
- package/dist/src/data/library-packs/vendored.js.map +1 -1
- package/dist/src/generated/api-types.d.ts +478 -19
- package/dist/src/generated/api-types.d.ts.map +1 -1
- package/dist/src/mcp/agent-tasks.d.ts +4 -0
- package/dist/src/mcp/agent-tasks.d.ts.map +1 -1
- package/dist/src/mcp/agent-tasks.js +20 -2
- package/dist/src/mcp/agent-tasks.js.map +1 -1
- package/dist/src/mcp/capabilities.d.ts +7 -1
- package/dist/src/mcp/capabilities.d.ts.map +1 -1
- package/dist/src/mcp/capabilities.js +5 -2
- package/dist/src/mcp/capabilities.js.map +1 -1
- package/dist/src/mcp/catalog/definitions/commerce.d.ts.map +1 -1
- package/dist/src/mcp/catalog/definitions/commerce.js +4 -2
- package/dist/src/mcp/catalog/definitions/commerce.js.map +1 -1
- package/dist/src/mcp/catalog/definitions/discovery-work-boards.d.ts.map +1 -1
- package/dist/src/mcp/catalog/definitions/discovery-work-boards.js +4 -3
- package/dist/src/mcp/catalog/definitions/discovery-work-boards.js.map +1 -1
- package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.js +1 -1
- package/dist/src/mcp/catalog/definitions/organisms-workspaces-apps.js.map +1 -1
- package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.d.ts.map +1 -1
- package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.js +3 -2
- package/dist/src/mcp/catalog/definitions/schedules-tasks-memory.js.map +1 -1
- package/dist/src/mcp/catalog/output-schemas.d.ts +6 -1
- package/dist/src/mcp/catalog/output-schemas.d.ts.map +1 -1
- package/dist/src/mcp/catalog/output-schemas.js +6 -1
- package/dist/src/mcp/catalog/output-schemas.js.map +1 -1
- package/dist/src/mcp/commerce.d.ts.map +1 -1
- package/dist/src/mcp/commerce.js +15 -3
- package/dist/src/mcp/commerce.js.map +1 -1
- package/dist/src/mcp/core-storage.d.ts +23 -0
- package/dist/src/mcp/core-storage.d.ts.map +1 -0
- package/dist/src/mcp/core-storage.js +157 -0
- package/dist/src/mcp/core-storage.js.map +1 -0
- package/dist/src/mcp/core.d.ts +16 -0
- package/dist/src/mcp/core.d.ts.map +1 -1
- package/dist/src/mcp/core.js +75 -119
- package/dist/src/mcp/core.js.map +1 -1
- package/dist/src/mcp/dm-messages.d.ts +4 -0
- package/dist/src/mcp/dm-messages.d.ts.map +1 -1
- package/dist/src/mcp/dm-messages.js +43 -2
- package/dist/src/mcp/dm-messages.js.map +1 -1
- package/dist/src/mcp/exchange.d.ts.map +1 -1
- package/dist/src/mcp/exchange.js +3 -2
- package/dist/src/mcp/exchange.js.map +1 -1
- package/dist/src/mcp/extensions.d.ts.map +1 -1
- package/dist/src/mcp/extensions.js +6 -2
- package/dist/src/mcp/extensions.js.map +1 -1
- package/dist/src/mcp/index.d.ts +5 -0
- package/dist/src/mcp/index.d.ts.map +1 -1
- package/dist/src/mcp/index.js +23 -4
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/memory-namespace-hints.d.ts +33 -0
- package/dist/src/mcp/memory-namespace-hints.d.ts.map +1 -0
- package/dist/src/mcp/memory-namespace-hints.js +60 -0
- package/dist/src/mcp/memory-namespace-hints.js.map +1 -0
- package/dist/src/mcp/workspaces.d.ts +5 -0
- package/dist/src/mcp/workspaces.d.ts.map +1 -1
- package/dist/src/mcp/workspaces.js +5 -3
- package/dist/src/mcp/workspaces.js.map +1 -1
- package/dist/src/models/agent-task-schemas.d.ts +25 -3
- package/dist/src/models/agent-task-schemas.d.ts.map +1 -1
- package/dist/src/models/agent-task-schemas.js +16 -0
- package/dist/src/models/agent-task-schemas.js.map +1 -1
- package/dist/src/models/app-tool-schemas.d.ts +518 -1
- package/dist/src/models/app-tool-schemas.d.ts.map +1 -1
- package/dist/src/models/app-tool-schemas.js +53 -1
- package/dist/src/models/app-tool-schemas.js.map +1 -1
- package/dist/src/models/odps-schemas.d.ts +305 -0
- package/dist/src/models/odps-schemas.d.ts.map +1 -0
- package/dist/src/models/odps-schemas.js +182 -0
- package/dist/src/models/odps-schemas.js.map +1 -0
- package/dist/src/models/offer-schemas.d.ts +357 -2
- package/dist/src/models/offer-schemas.d.ts.map +1 -1
- package/dist/src/models/offer-schemas.js +37 -0
- package/dist/src/models/offer-schemas.js.map +1 -1
- package/dist/src/models/schemas.d.ts +6 -3
- package/dist/src/models/schemas.d.ts.map +1 -1
- package/dist/src/models/schemas.js +10 -1
- package/dist/src/models/schemas.js.map +1 -1
- package/dist/src/models/webhook-schemas.d.ts +8 -8
- package/dist/src/routes/agent-tasks/create-read.d.ts +4 -0
- package/dist/src/routes/agent-tasks/create-read.d.ts.map +1 -1
- package/dist/src/routes/agent-tasks/create-read.js +20 -1
- package/dist/src/routes/agent-tasks/create-read.js.map +1 -1
- package/dist/src/routes/agent-tasks/lifecycle.d.ts.map +1 -1
- package/dist/src/routes/agent-tasks/lifecycle.js +10 -0
- package/dist/src/routes/agent-tasks/lifecycle.js.map +1 -1
- package/dist/src/routes/agents/offers.d.ts +2 -0
- package/dist/src/routes/agents/offers.d.ts.map +1 -1
- package/dist/src/routes/agents/offers.js +0 -0
- package/dist/src/routes/agents/offers.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 +55 -25
- package/dist/src/routes/app-grants.js.map +1 -1
- package/dist/src/routes/apps/drafts.d.ts +3 -0
- package/dist/src/routes/apps/drafts.d.ts.map +1 -1
- package/dist/src/routes/apps/drafts.js +63 -1
- package/dist/src/routes/apps/drafts.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 +17 -2
- package/dist/src/routes/apps/publish.js.map +1 -1
- package/dist/src/routes/commerce.d.ts.map +1 -1
- package/dist/src/routes/commerce.js +122 -2
- package/dist/src/routes/commerce.js.map +1 -1
- package/dist/src/routes/exchange-market.d.ts +6 -2
- package/dist/src/routes/exchange-market.d.ts.map +1 -1
- package/dist/src/routes/exchange-market.js +154 -28
- package/dist/src/routes/exchange-market.js.map +1 -1
- package/dist/src/routes/exchange.d.ts.map +1 -1
- package/dist/src/routes/exchange.js +5 -2
- package/dist/src/routes/exchange.js.map +1 -1
- package/dist/src/routes/extensions/actions.d.ts.map +1 -1
- package/dist/src/routes/extensions/actions.js +18 -0
- package/dist/src/routes/extensions/actions.js.map +1 -1
- package/dist/src/routes/extensions/crud.d.ts.map +1 -1
- package/dist/src/routes/extensions/crud.js +36 -3
- package/dist/src/routes/extensions/crud.js.map +1 -1
- package/dist/src/routes/extensions/entitlement-gate.d.ts.map +1 -1
- package/dist/src/routes/extensions/entitlement-gate.js +13 -0
- package/dist/src/routes/extensions/entitlement-gate.js.map +1 -1
- package/dist/src/routes/extensions/manifest.d.ts +6 -0
- package/dist/src/routes/extensions/manifest.d.ts.map +1 -1
- package/dist/src/routes/extensions/manifest.js +68 -1
- package/dist/src/routes/extensions/manifest.js.map +1 -1
- package/dist/src/routes/extensions/pacing.d.ts +31 -0
- package/dist/src/routes/extensions/pacing.d.ts.map +1 -0
- package/dist/src/routes/extensions/pacing.js +73 -0
- package/dist/src/routes/extensions/pacing.js.map +1 -0
- package/dist/src/routes/extensions/paywall.d.ts.map +1 -1
- package/dist/src/routes/extensions/paywall.js +17 -17
- package/dist/src/routes/extensions/paywall.js.map +1 -1
- package/dist/src/routes/memory/crud.d.ts.map +1 -1
- package/dist/src/routes/memory/crud.js +10 -0
- package/dist/src/routes/memory/crud.js.map +1 -1
- package/dist/src/routes/organisms/crud.d.ts +3 -0
- package/dist/src/routes/organisms/crud.d.ts.map +1 -1
- package/dist/src/routes/organisms/crud.js +5 -2
- package/dist/src/routes/organisms/crud.js.map +1 -1
- package/dist/src/routes/organisms/workspace-read.d.ts.map +1 -1
- package/dist/src/routes/organisms/workspace-read.js +7 -2
- package/dist/src/routes/organisms/workspace-read.js.map +1 -1
- package/dist/src/routes/public-stats.d.ts +7 -0
- package/dist/src/routes/public-stats.d.ts.map +1 -1
- package/dist/src/routes/public-stats.js +28 -7
- package/dist/src/routes/public-stats.js.map +1 -1
- package/dist/src/routes/sse.d.ts +7 -0
- package/dist/src/routes/sse.d.ts.map +1 -1
- package/dist/src/routes/sse.js +36 -6
- package/dist/src/routes/sse.js.map +1 -1
- package/dist/src/routes/storage-files.d.ts +11 -0
- package/dist/src/routes/storage-files.d.ts.map +1 -1
- package/dist/src/routes/storage-files.js +58 -51
- package/dist/src/routes/storage-files.js.map +1 -1
- package/dist/src/routes/subdomains.d.ts +4 -0
- package/dist/src/routes/subdomains.d.ts.map +1 -1
- package/dist/src/routes/subdomains.js +42 -5
- package/dist/src/routes/subdomains.js.map +1 -1
- package/dist/src/routes/upload.d.ts +11 -0
- package/dist/src/routes/upload.d.ts.map +1 -1
- package/dist/src/routes/upload.js +108 -28
- package/dist/src/routes/upload.js.map +1 -1
- package/dist/src/routes/webmcp.d.ts.map +1 -1
- package/dist/src/routes/webmcp.js +4 -0
- package/dist/src/routes/webmcp.js.map +1 -1
- package/dist/src/schemas/knowledge-package.d.ts +1 -1
- package/dist/src/server-bootstrap/static-files.d.ts +4 -0
- package/dist/src/server-bootstrap/static-files.d.ts.map +1 -1
- package/dist/src/server-bootstrap/static-files.js +11 -0
- package/dist/src/server-bootstrap/static-files.js.map +1 -1
- package/dist/src/services/build-app-prompt.d.ts +19 -0
- package/dist/src/services/build-app-prompt.d.ts.map +1 -1
- package/dist/src/services/build-app-prompt.js +97 -11
- package/dist/src/services/build-app-prompt.js.map +1 -1
- package/dist/src/services/call-timing.d.ts +51 -0
- package/dist/src/services/call-timing.d.ts.map +1 -0
- package/dist/src/services/call-timing.js +91 -0
- package/dist/src/services/call-timing.js.map +1 -0
- package/dist/src/services/capability-invoke.d.ts +2 -0
- package/dist/src/services/capability-invoke.d.ts.map +1 -1
- package/dist/src/services/capability-invoke.js +10 -0
- package/dist/src/services/capability-invoke.js.map +1 -1
- package/dist/src/services/config-schema.d.ts.map +1 -1
- package/dist/src/services/config-schema.js +6 -0
- package/dist/src/services/config-schema.js.map +1 -1
- package/dist/src/services/draft-token.d.ts +22 -2
- package/dist/src/services/draft-token.d.ts.map +1 -1
- package/dist/src/services/draft-token.js +52 -3
- package/dist/src/services/draft-token.js.map +1 -1
- package/dist/src/services/exchange-market.d.ts +41 -8
- package/dist/src/services/exchange-market.d.ts.map +1 -1
- package/dist/src/services/exchange-market.js +24 -2
- package/dist/src/services/exchange-market.js.map +1 -1
- package/dist/src/services/exchange-odps.d.ts +58 -0
- package/dist/src/services/exchange-odps.d.ts.map +1 -0
- package/dist/src/services/exchange-odps.js +400 -0
- package/dist/src/services/exchange-odps.js.map +1 -0
- package/dist/src/services/exchange-projection.d.ts +61 -0
- package/dist/src/services/exchange-projection.d.ts.map +1 -0
- package/dist/src/services/exchange-projection.js +504 -0
- package/dist/src/services/exchange-projection.js.map +1 -0
- package/dist/src/services/exchange-proposals.d.ts.map +1 -1
- package/dist/src/services/exchange-proposals.js +2 -0
- package/dist/src/services/exchange-proposals.js.map +1 -1
- package/dist/src/services/extension-files.d.ts +64 -0
- package/dist/src/services/extension-files.d.ts.map +1 -0
- package/dist/src/services/extension-files.js +88 -0
- package/dist/src/services/extension-files.js.map +1 -0
- package/dist/src/services/extension-runtime.d.ts +33 -0
- package/dist/src/services/extension-runtime.d.ts.map +1 -1
- package/dist/src/services/extension-runtime.js +52 -0
- package/dist/src/services/extension-runtime.js.map +1 -1
- package/dist/src/services/file-refs.d.ts +105 -0
- package/dist/src/services/file-refs.d.ts.map +1 -0
- package/dist/src/services/file-refs.js +106 -0
- package/dist/src/services/file-refs.js.map +1 -0
- package/dist/src/services/metered-entitlements.d.ts +7 -0
- package/dist/src/services/metered-entitlements.d.ts.map +1 -1
- package/dist/src/services/metered-entitlements.js +4 -0
- package/dist/src/services/metered-entitlements.js.map +1 -1
- package/dist/src/services/owner-memory.d.ts +14 -1
- package/dist/src/services/owner-memory.d.ts.map +1 -1
- package/dist/src/services/owner-memory.js +8 -14
- package/dist/src/services/owner-memory.js.map +1 -1
- package/dist/src/services/task-files.d.ts +51 -0
- package/dist/src/services/task-files.d.ts.map +1 -0
- package/dist/src/services/task-files.js +58 -0
- package/dist/src/services/task-files.js.map +1 -0
- package/dist/src/services/upload-token.d.ts +29 -0
- package/dist/src/services/upload-token.d.ts.map +1 -1
- package/dist/src/services/upload-token.js +37 -0
- package/dist/src/services/upload-token.js.map +1 -1
- package/dist/src/services/upload-zip.d.ts +2 -0
- package/dist/src/services/upload-zip.d.ts.map +1 -1
- package/dist/src/services/upload-zip.js +5 -1
- package/dist/src/services/upload-zip.js.map +1 -1
- package/dist/src/services/workspace-meta.d.ts +15 -0
- package/dist/src/services/workspace-meta.d.ts.map +1 -1
- package/dist/src/services/workspace-meta.js +17 -0
- package/dist/src/services/workspace-meta.js.map +1 -1
- package/dist/src/services/workspace-provision.d.ts +3 -0
- package/dist/src/services/workspace-provision.d.ts.map +1 -1
- package/dist/src/services/workspace-provision.js +5 -3
- package/dist/src/services/workspace-provision.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/app-grants.d.ts +1 -0
- package/dist/src/storage/providers/postgres-kysely/methods/app-grants.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/app-grants.js +10 -0
- package/dist/src/storage/providers/postgres-kysely/methods/app-grants.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/memory.d.ts +2 -0
- package/dist/src/storage/providers/postgres-kysely/methods/memory.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/memory.js +12 -1
- package/dist/src/storage/providers/postgres-kysely/methods/memory.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/organisms.d.ts.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/methods/organisms.js +5 -1
- package/dist/src/storage/providers/postgres-kysely/methods/organisms.js.map +1 -1
- package/dist/src/storage/providers/postgres-kysely/migrations/0012_unique_live_app_grant.sql +29 -0
- package/dist/src/storage/providers/sqlite/methods/apps.d.ts +3 -0
- package/dist/src/storage/providers/sqlite/methods/apps.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/apps.js +7 -0
- package/dist/src/storage/providers/sqlite/methods/apps.js.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/governance.d.ts +1 -0
- package/dist/src/storage/providers/sqlite/methods/governance.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/governance.js +4 -1
- package/dist/src/storage/providers/sqlite/methods/governance.js.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/owner.d.ts +5 -0
- package/dist/src/storage/providers/sqlite/methods/owner.d.ts.map +1 -1
- package/dist/src/storage/providers/sqlite/methods/owner.js +8 -0
- package/dist/src/storage/providers/sqlite/methods/owner.js.map +1 -1
- package/dist/src/storage/providers/sqlite/schema.d.ts +3 -0
- 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-grant.repository.d.ts +9 -1
- package/dist/src/storage/repositories/app-grant.repository.d.ts.map +1 -1
- package/dist/src/storage/repositories/memory.repository.d.ts +14 -0
- package/dist/src/storage/repositories/memory.repository.d.ts.map +1 -1
- package/dist/src/storage/repositories-impl/memory-repository.d.ts +8 -1
- package/dist/src/storage/repositories-impl/memory-repository.d.ts.map +1 -1
- package/dist/src/storage/repositories-impl/memory-repository.js +15 -4
- package/dist/src/storage/repositories-impl/memory-repository.js.map +1 -1
- package/dist/src/storage/types/agents-messaging.d.ts +19 -0
- package/dist/src/storage/types/agents-messaging.d.ts.map +1 -1
- package/dist/src/storage/types/agents-messaging.js.map +1 -1
- package/dist/src/storage/types/organisms-federation.d.ts +29 -0
- package/dist/src/storage/types/organisms-federation.d.ts.map +1 -1
- package/dist/src/utils/app-badge.d.ts.map +1 -1
- package/dist/src/utils/app-badge.js +7 -3
- package/dist/src/utils/app-badge.js.map +1 -1
- package/dist/static/app-catalog/_template.html +6 -5
- package/dist/static/app-catalog/js/cortex.js +3 -1
- package/dist/static/app-catalog/js/detail.js +411 -36
- package/dist/static/app-catalog/js/i18n-data.js +279 -3
- package/dist/static/app-catalog/js/main.js +28 -37
- package/dist/static/app-catalog/js/monetize.js +204 -16
- package/dist/static/app-catalog/js/odps.js +489 -0
- package/dist/static/app-catalog/js/render.js +3 -0
- package/dist/static/app-catalog/js/workcopy.js +198 -0
- package/dist/static/app-catalog/styles/app-catalog.css +60 -0
- package/dist/static/app-catalog.html +1450 -137
- package/dist/static/sdk-libs/agents/index.js +45 -7
- package/dist/static/sdk-libs/auth/cluster.js +97 -0
- package/dist/static/sdk-libs/auth/index.js +25 -1
- package/dist/static/sdk-libs/auth/locale.js +151 -0
- package/dist/static/sdk-libs/auth/modal.js +11 -2
- package/dist/static/sdk-libs/auth/palette.js +172 -0
- package/dist/static/sdk-libs/auth/pill.js +37 -6
- package/dist/static/sdk-libs/auth/theme.js +61 -20
- package/dist/static/sdk-libs/data/index.js +70 -8
- package/dist/static/sdk-libs/dist/aimeat-agents.js +41 -8
- package/dist/static/sdk-libs/dist/aimeat-auth.js +422 -21
- package/dist/static/sdk-libs/dist/aimeat-data.js +50 -8
- package/dist/static/sdk-libs/dist/aimeat-live.js +54 -2
- package/dist/static/sdk-libs/dist/aimeat-markdown.js +32 -1
- package/dist/static/sdk-libs/live/index.js +71 -4
- package/dist/static/sdk-libs/markdown/index.js +49 -1
- package/package.json +6 -2
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
15
|
var state = { keyBase: null, localeList: [], locale: 'en', dicts: {}, fallback: 'en' };
|
|
16
|
-
|
|
16
|
+
// THE platform locale key — same as the SPA (public/js/utils.js), the sign-in modal and the
|
|
17
|
+
// login pill's language control. A private 'aimeat-i18n-locale' was a third convention that
|
|
18
|
+
// silently disagreed with the other two.
|
|
19
|
+
var STORE_KEY = 'aimeat-lang';
|
|
17
20
|
var styled = false;
|
|
18
21
|
|
|
19
22
|
function injectStyles() {
|
|
@@ -80,6 +83,8 @@
|
|
|
80
83
|
return loadDict(locale).then(function () {
|
|
81
84
|
state.locale = locale;
|
|
82
85
|
try { window.localStorage.setItem(STORE_KEY, locale); } catch (e) { /* ignore */ }
|
|
86
|
+
try { document.cookie = 'aimeat-lang=' + locale + ';path=/;max-age=31536000;SameSite=Lax'; } catch (e) { /* ignore */ }
|
|
87
|
+
try { window.dispatchEvent(new CustomEvent('aimeat-lang-change', { detail: { lang: locale } })); } catch (e) { /* ignore */ }
|
|
83
88
|
try { window.dispatchEvent(new CustomEvent('aimeat-i18n-changed', { detail: { locale: locale } })); } catch (e) { /* ignore */ }
|
|
84
89
|
return locale;
|
|
85
90
|
});
|
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file aimeat-surface.js
|
|
3
|
+
* @description The panel-spec surface engine: turn a person's plain-language request into ONE
|
|
4
|
+
* panel spec, resolve that spec's data source into rows, and render the rows through the node's
|
|
5
|
+
* own UI packs. Extracted from the TILA app v0.2.6 (TARGET-051), where the same engine was
|
|
6
|
+
* already isolated behind {KINDS, resolve, renderBody, compose, reshape, writeBrief, refine,
|
|
7
|
+
* autoColumns} but closed over that app's PRH company source, its i18n and its app id.
|
|
8
|
+
*
|
|
9
|
+
* Here the DATA SOURCES ARE PLUGINS: `memory` and `inline` ship built in, and an app registers
|
|
10
|
+
* whatever else it can fetch — the registered sources assemble the composer's own prompt, so a
|
|
11
|
+
* source the app did not register is a source the model is never told about. That is what lets
|
|
12
|
+
* one engine serve both a single self-composing surface (TILA) and a spatial board of many
|
|
13
|
+
* frames (ORIGAMI) without either one owning the other's data.
|
|
14
|
+
*
|
|
15
|
+
* The engine renders the panel BODY only. Card, frame, chrome, drag handles and persistence
|
|
16
|
+
* belong to the host app, which is why the same spec can be a card in one product and a frame
|
|
17
|
+
* on a canvas in another.
|
|
18
|
+
* @structure
|
|
19
|
+
* - helpers: esc/uid/num/flatten/agg/fmtNum/autoColumns (pure, exposed for hosts)
|
|
20
|
+
* - BUILT_IN sources: memory (owner-scope prefix read), inline
|
|
21
|
+
* - create(opts) → engine: registerSource, resolve, renderBody, specHint, normalizeSpec,
|
|
22
|
+
* compose, reshape, refine, writeBrief
|
|
23
|
+
* @usage
|
|
24
|
+
* <script src="/v1/cortex/aimeat-surface/libs/aimeat-surface.js"></script>
|
|
25
|
+
* const surface = AIMEAT.surface.create({ appId: 'my-app', locale: 'fi' });
|
|
26
|
+
* surface.registerSource('companies', { hint: '{"type":"companies","names":["Nokia"]}', resolve: fetchCompanies });
|
|
27
|
+
* const spec = await surface.compose('show my AI spend per day', { prefixes });
|
|
28
|
+
* const rows = await surface.resolve(spec, { session });
|
|
29
|
+
* surface.renderBody(boxEl, spec, rows);
|
|
30
|
+
* @version-history
|
|
31
|
+
* v1.1.0 — 2026-07-25 — Charts are left uncoloured so aimeat-charts can theme them: the engine
|
|
32
|
+
* hardcoded four Tailwind colours over the chart lib's palette, which pinned every surface
|
|
33
|
+
* chart to indigo no matter which of the five palettes the reader had chosen, or whether they
|
|
34
|
+
* were in light or dark mode.
|
|
35
|
+
* v1.0.0 — 2026-07-25 — Initial (TARGET-051 Slice 1): engine lifted out of tila.html v0.2.6
|
|
36
|
+
* behaviour-for-behaviour, including every graceful fallback (statTiles → daisyUI stats,
|
|
37
|
+
* ChartBuilder → warning, Timeline → <ul>, markdown → escaped <br>, DataTable → <table>).
|
|
38
|
+
* New: pluggable sources, injected locale/strings/appId, and an onPick callback so a host no
|
|
39
|
+
* longer has to wire the options button by hand.
|
|
40
|
+
*/
|
|
41
|
+
(function (global) {
|
|
42
|
+
'use strict';
|
|
43
|
+
|
|
44
|
+
var AIMEAT = global.AIMEAT = global.AIMEAT || {};
|
|
45
|
+
if (AIMEAT.surface) return;
|
|
46
|
+
|
|
47
|
+
var KINDS = ['stats', 'table', 'chart', 'timeline', 'brief', 'options'];
|
|
48
|
+
|
|
49
|
+
var STRINGS = {
|
|
50
|
+
en: { no_data: 'No data', err: 'Could not render this', rows_n: 'Rows', picked: 'picked', pick: 'Pick' },
|
|
51
|
+
fi: { no_data: 'Ei dataa', err: 'Tätä ei voitu piirtää', rows_n: 'Rivejä', picked: 'valittu', pick: 'Valitse' },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var CSS = '.as-scroll { overflow-x: auto; max-width: 100%; }';
|
|
55
|
+
var cssInjected = false;
|
|
56
|
+
function injectCss() {
|
|
57
|
+
if (cssInjected) return;
|
|
58
|
+
var s = document.createElement('style');
|
|
59
|
+
s.setAttribute('data-aimeat-surface', '1');
|
|
60
|
+
s.textContent = CSS;
|
|
61
|
+
(document.head || document.documentElement).appendChild(s);
|
|
62
|
+
cssInjected = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function esc(s) {
|
|
66
|
+
var d = document.createElement('div');
|
|
67
|
+
d.textContent = String(s == null ? '' : s);
|
|
68
|
+
return d.innerHTML;
|
|
69
|
+
}
|
|
70
|
+
function uid(p) { return (p || 'pnl') + '-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 6); }
|
|
71
|
+
function num(v) {
|
|
72
|
+
if (typeof v === 'number') return v;
|
|
73
|
+
var n = parseFloat(String(v == null ? '' : v).replace(/[^0-9.,-]/g, '').replace(',', '.'));
|
|
74
|
+
return isFinite(n) ? n : 0;
|
|
75
|
+
}
|
|
76
|
+
function agentOf(gaii) { return (gaii && String(gaii).indexOf('#') > 0) ? String(gaii).split('#')[0] : null; }
|
|
77
|
+
async function unwrap(r) {
|
|
78
|
+
if (!r) return null;
|
|
79
|
+
if (typeof r.json === 'function') { try { return await r.json(); } catch (e) { return null; } }
|
|
80
|
+
return r;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Scalar view of a record so auto-picked columns show meaning (date, total_cost_usd, …)
|
|
85
|
+
* instead of plumbing. Nested objects contribute their scalar leaves one level deep.
|
|
86
|
+
*/
|
|
87
|
+
function flatten(v) {
|
|
88
|
+
var out = {};
|
|
89
|
+
Object.keys(v || {}).slice(0, 30).forEach(function (k) {
|
|
90
|
+
var val = v[k];
|
|
91
|
+
/* Float noise (0.07853924430000002) reads as broken data: keep it numeric, lose the tail. */
|
|
92
|
+
if (typeof val === 'number' && !Number.isInteger(val)) { out[k] = Math.round(val * 1e6) / 1e6; return; }
|
|
93
|
+
if (val === null || typeof val !== 'object') { out[k] = val; return; }
|
|
94
|
+
if (Array.isArray(val)) { out[k + '_n'] = val.length; return; }
|
|
95
|
+
Object.keys(val).slice(0, 6).forEach(function (ik) {
|
|
96
|
+
var iv = val[ik];
|
|
97
|
+
if (iv === null || typeof iv !== 'object') out[k + '_' + ik] = iv;
|
|
98
|
+
else Object.keys(iv).slice(0, 4).forEach(function (jk) {
|
|
99
|
+
if (iv[jk] === null || typeof iv[jk] !== 'object') out[ik + '_' + jk] = iv[jk];
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Columns worth showing: skip near-empty fields and plumbing, prettify the labels. */
|
|
107
|
+
function autoColumns(rows) {
|
|
108
|
+
if (!rows.length) return [];
|
|
109
|
+
var keys = Object.keys(rows[0]);
|
|
110
|
+
/* When the record carries its own date, the storage timestamps and the key tail are
|
|
111
|
+
duplicates of it: three columns saying the same thing is what makes a surface read
|
|
112
|
+
like a log instead of an answer. */
|
|
113
|
+
var hasDate = keys.indexOf('date') >= 0 || keys.indexOf('day') >= 0;
|
|
114
|
+
var PLUMBING = hasDate ? ['author', 'updated_at', 'saved', 'id', 'updatedAt'] : ['author'];
|
|
115
|
+
var scored = keys.filter(function (k) {
|
|
116
|
+
if (PLUMBING.indexOf(k) >= 0) return false;
|
|
117
|
+
var filled = 0, objish = false;
|
|
118
|
+
for (var i = 0; i < rows.length; i++) {
|
|
119
|
+
var v = rows[i][k];
|
|
120
|
+
if (v !== '' && v != null) filled++;
|
|
121
|
+
if (v != null && typeof v === 'object') objish = true;
|
|
122
|
+
}
|
|
123
|
+
/* An object or array value has no useful cell rendering — it reaches a table as
|
|
124
|
+
"[object Object]", which reads as broken data. Memory rows are flattened before they get
|
|
125
|
+
here so they never hit this; inline rows the model wrote can. */
|
|
126
|
+
if (objish) return false;
|
|
127
|
+
return filled / rows.length > 0.2;
|
|
128
|
+
});
|
|
129
|
+
return scored.slice(0, 6).map(function (k) {
|
|
130
|
+
return {
|
|
131
|
+
key: k,
|
|
132
|
+
label: k.replace(/_/g, ' ').replace(/\b\w/g, function (c) { return c.toUpperCase(); }),
|
|
133
|
+
type: typeof rows[0][k] === 'number' ? 'number' : 'string',
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function agg(rows, key, how) {
|
|
139
|
+
if (how === 'count' || !key) return rows.length;
|
|
140
|
+
var vals = rows.map(function (r) { return r[key]; });
|
|
141
|
+
if (how === 'sum') return vals.reduce(function (a, b) { return a + num(b); }, 0);
|
|
142
|
+
if (how === 'avg') return rows.length ? vals.reduce(function (a, b) { return a + num(b); }, 0) / rows.length : 0;
|
|
143
|
+
if (how === 'latest') {
|
|
144
|
+
var last = vals.filter(function (v) { return v != null && v !== ''; }).sort();
|
|
145
|
+
return last[last.length - 1] || '';
|
|
146
|
+
}
|
|
147
|
+
return rows.length;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function pickJson(v) {
|
|
151
|
+
if (!v) return null;
|
|
152
|
+
if (typeof v === 'object') return v;
|
|
153
|
+
var raw = String(v).replace(/^\s*```(?:json)?/i, '').replace(/```\s*$/, '').trim();
|
|
154
|
+
try { return JSON.parse(raw); } catch (e) { return null; }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Owner-scope memory read: also picks up what the owner's AGENTS wrote. */
|
|
158
|
+
async function resolveMemory(src, ctx) {
|
|
159
|
+
var session = ctx && ctx.session;
|
|
160
|
+
if (!session || typeof session.fetch !== 'function') return [];
|
|
161
|
+
var qs = '/v1/memory?owner_scope=true&prefix=' + encodeURIComponent(src.prefix || '');
|
|
162
|
+
var body = await unwrap(await session.fetch(qs));
|
|
163
|
+
var items = (body && (body.items || (body.data && body.data.items))) || [];
|
|
164
|
+
var rows = [];
|
|
165
|
+
items.forEach(function (it) {
|
|
166
|
+
/* Meta LAST: the long memory key is plumbing, so it must not win a column slot. */
|
|
167
|
+
var meta = {
|
|
168
|
+
id: String(it.key || '').split('.').pop(),
|
|
169
|
+
author: agentOf(it.owner_gaii) || '',
|
|
170
|
+
saved: (it.updated_at || '').slice(0, 10),
|
|
171
|
+
};
|
|
172
|
+
var v = it.value;
|
|
173
|
+
if (Array.isArray(v)) {
|
|
174
|
+
v.slice(0, 200).forEach(function (r) {
|
|
175
|
+
rows.push(Object.assign({}, (r && typeof r === 'object') ? flatten(r) : { value: r }, meta));
|
|
176
|
+
});
|
|
177
|
+
} else if (v && typeof v === 'object') {
|
|
178
|
+
rows.push(Object.assign(flatten(v), meta));
|
|
179
|
+
} else {
|
|
180
|
+
rows.push(Object.assign({ value: v }, meta));
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
/* Newest last for time series, so a chart reads left to right. */
|
|
184
|
+
var dk = rows.length ? ['date', 'day', 'ts', 'saved'].filter(function (k) { return rows[0][k] !== undefined; })[0] : null;
|
|
185
|
+
if (dk) rows.sort(function (a, b) { return String(a[dk]).localeCompare(String(b[dk])); });
|
|
186
|
+
return rows;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
var BUILT_IN = {
|
|
190
|
+
memory: {
|
|
191
|
+
resolve: resolveMemory,
|
|
192
|
+
hint: ' {"type":"memory","prefix":"ai-usage."} the owner\'s own stored data by key prefix',
|
|
193
|
+
normalize: function (src) { return { type: 'memory', prefix: src.prefix || src.key || '' }; },
|
|
194
|
+
claims: function (src) { return !!(src.prefix || src.key); },
|
|
195
|
+
},
|
|
196
|
+
inline: {
|
|
197
|
+
resolve: function (src) { return (src.rows || []).slice(0, 400); },
|
|
198
|
+
hint: ' {"type":"inline","rows":[{…}]} only when the user supplied the data themselves',
|
|
199
|
+
normalize: function (src) { return { type: 'inline', rows: src.rows || src.items || [] }; },
|
|
200
|
+
claims: function () { return false; }, // the fallback, never claimed by shape
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Create a surface engine.
|
|
206
|
+
* @param {Object} [opts]
|
|
207
|
+
* @param {string} [opts.appId] app id passed to AIMEAT.ai.complete (H-2 app grant)
|
|
208
|
+
* @param {string} [opts.locale='en'] 'fi' | 'en' — drives strings, number formatting and the
|
|
209
|
+
* language the composer is told to answer in
|
|
210
|
+
* @param {Object} [opts.strings] overrides for no_data / err / rows_n / picked / pick
|
|
211
|
+
* @param {Function} [opts.ai] (req) → completion; defaults to AIMEAT.ai.complete
|
|
212
|
+
* @param {string} [opts.scrollClass='as-scroll'] wrapper class for the table body
|
|
213
|
+
*/
|
|
214
|
+
function create(opts) {
|
|
215
|
+
opts = opts || {};
|
|
216
|
+
injectCss();
|
|
217
|
+
var appId = opts.appId;
|
|
218
|
+
var locale = opts.locale === 'fi' ? 'fi' : 'en';
|
|
219
|
+
var strings = Object.assign({}, STRINGS.en, STRINGS[locale], opts.strings || {});
|
|
220
|
+
var scrollClass = opts.scrollClass || 'as-scroll';
|
|
221
|
+
var sources = Object.assign({}, BUILT_IN);
|
|
222
|
+
var extraHints = [];
|
|
223
|
+
|
|
224
|
+
function t(k) { return strings[k] || k; }
|
|
225
|
+
function ai(req) {
|
|
226
|
+
if (opts.ai) return opts.ai(req);
|
|
227
|
+
return AIMEAT.ai.complete(Object.assign({ app_id: appId }, req));
|
|
228
|
+
}
|
|
229
|
+
function lang() { return locale === 'fi' ? 'Finnish' : 'English'; }
|
|
230
|
+
|
|
231
|
+
function fmtNum(n, format) {
|
|
232
|
+
if (typeof n !== 'number') return String(n == null ? '' : n);
|
|
233
|
+
if (format === 'usd') return '$' + n.toFixed(n < 1 ? 4 : 2);
|
|
234
|
+
if (format === 'eur') return n.toFixed(2) + ' EUR';
|
|
235
|
+
var s = Math.abs(n) >= 1000
|
|
236
|
+
? Math.round(n).toLocaleString(locale === 'fi' ? 'fi-FI' : 'en-GB')
|
|
237
|
+
: (Math.round(n * 100) / 100);
|
|
238
|
+
return String(s);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Teach the engine a data source. The registered sources assemble the composer prompt, so a
|
|
243
|
+
* source that is not registered is a source the model is never offered.
|
|
244
|
+
* @param {string} type
|
|
245
|
+
* @param {Object} def { resolve(src, ctx) → rows, hint, fields?, normalize?(src), claims?(src) }
|
|
246
|
+
*/
|
|
247
|
+
function registerSource(type, def) {
|
|
248
|
+
sources[type] = def;
|
|
249
|
+
if (def.hint) extraHints.push(def.hint);
|
|
250
|
+
if (def.fields) extraHints.push('A ' + type + ' row always has these fields, use them as column/tile keys:\n ' + def.fields);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async function resolve(spec, ctx) {
|
|
254
|
+
var src = (spec && spec.source) || { type: 'inline', rows: [] };
|
|
255
|
+
var def = sources[src.type] || sources.inline;
|
|
256
|
+
return await def.resolve(src, ctx || {});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* ------------------------------------------------------------ rendering --
|
|
260
|
+
Every kind renders through the node's own UI packs so a surface looks like one product
|
|
261
|
+
and we do not re-implement tables, charts or motion. Each pack call has a plain-DOM
|
|
262
|
+
fallback: a missing pack must degrade, never blank the panel. */
|
|
263
|
+
function renderBody(box, spec, rows, o) {
|
|
264
|
+
o = o || {};
|
|
265
|
+
var kind = KINDS.indexOf(spec.kind) >= 0 ? spec.kind : 'table';
|
|
266
|
+
var view = spec.view || {};
|
|
267
|
+
rows = rows || [];
|
|
268
|
+
|
|
269
|
+
if (!rows.length && kind !== 'options' && kind !== 'brief') {
|
|
270
|
+
box.innerHTML = '<div class="alert alert-warning text-sm">' + esc(t('no_data')) + '</div>';
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (kind === 'stats') {
|
|
275
|
+
var host = document.createElement('div');
|
|
276
|
+
box.appendChild(host);
|
|
277
|
+
var tiles = (view.tiles || []).slice(0, 4).map(function (ti) {
|
|
278
|
+
var v = agg(rows, ti.key, ti.agg || 'count');
|
|
279
|
+
return {
|
|
280
|
+
label: ti.label || ti.key || '',
|
|
281
|
+
value: typeof v === 'number' ? v : 0,
|
|
282
|
+
format: function (n) { return fmtNum(n, ti.format); },
|
|
283
|
+
spark: ti.sparkKey ? rows.slice(-12).map(function (r) { return num(r[ti.sparkKey]); }) : undefined,
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
if (!tiles.length) tiles = [{ label: t('rows_n'), value: rows.length }];
|
|
287
|
+
try { AIMEAT.ui.motion.statTiles(host, tiles); }
|
|
288
|
+
catch (e) {
|
|
289
|
+
host.className = 'stats stats-vertical sm:stats-horizontal w-full';
|
|
290
|
+
host.innerHTML = tiles.map(function (x) {
|
|
291
|
+
/* Apply the tile's own format here too. Printing the raw value made a documented
|
|
292
|
+
feature (format:'usd') silently do nothing whenever the motion pack was absent,
|
|
293
|
+
so a currency tile read as 4.4845678901 instead of $4.48. */
|
|
294
|
+
var shown = x.format ? x.format(x.value) : String(x.value);
|
|
295
|
+
return '<div class="stat"><div class="stat-title">' + esc(x.label) +
|
|
296
|
+
'</div><div class="stat-value text-2xl">' + esc(shown) + '</div></div>';
|
|
297
|
+
}).join('');
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (kind === 'chart') {
|
|
303
|
+
/* ChartBuilder wants a CONTAINER id and creates the <canvas> itself. Handing it a canvas
|
|
304
|
+
id nests a canvas inside a canvas: no error, no chart, just a blank box. */
|
|
305
|
+
var cid = 'cv-' + (spec.id || uid('c'));
|
|
306
|
+
var wrap = document.createElement('div');
|
|
307
|
+
wrap.id = cid;
|
|
308
|
+
box.appendChild(wrap);
|
|
309
|
+
var labelKey = view.labelKey || Object.keys(rows[0])[0];
|
|
310
|
+
var valueKeys = (view.valueKeys && view.valueKeys.length)
|
|
311
|
+
? view.valueKeys
|
|
312
|
+
: [Object.keys(rows[0]).filter(function (k) { return k !== labelKey; })[0]];
|
|
313
|
+
try {
|
|
314
|
+
AIMEAT.charts.ChartBuilder({
|
|
315
|
+
elementId: cid,
|
|
316
|
+
type: view.chartType || 'bar',
|
|
317
|
+
data: {
|
|
318
|
+
labels: rows.map(function (r) { return String(r[labelKey]); }),
|
|
319
|
+
/* No colours here on purpose: aimeat-charts resolves them from the theme tokens and
|
|
320
|
+
repaints when the palette or light/dark changes. Naming a colour here would pin
|
|
321
|
+
the series to it forever, which is exactly what used to happen. */
|
|
322
|
+
datasets: valueKeys.map(function (k) {
|
|
323
|
+
return { label: k, data: rows.map(function (r) { return num(r[k]); }) };
|
|
324
|
+
}),
|
|
325
|
+
},
|
|
326
|
+
/* The lib keeps the aspect ratio and pins canvas{height:auto!important}, so a fixed
|
|
327
|
+
container height is ignored and the chart spills out of the card. Give it a RATIO
|
|
328
|
+
instead and let the card grow to fit. */
|
|
329
|
+
options: { aspectRatio: rows.length > 10 ? 3.2 : 2.4 },
|
|
330
|
+
});
|
|
331
|
+
} catch (e) {
|
|
332
|
+
box.innerHTML = '<div class="alert alert-warning text-sm">' + esc(t('err')) + '</div>';
|
|
333
|
+
}
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (kind === 'timeline') {
|
|
338
|
+
var thost = document.createElement('div');
|
|
339
|
+
box.appendChild(thost);
|
|
340
|
+
var tsKey = view.tsKey || 'lastChange', txKey = view.textKey || 'name';
|
|
341
|
+
var events = rows.filter(function (r) { return r[tsKey]; })
|
|
342
|
+
.sort(function (a, b) { return String(b[tsKey]).localeCompare(String(a[tsKey])); })
|
|
343
|
+
.slice(0, 30)
|
|
344
|
+
.map(function (r) {
|
|
345
|
+
return {
|
|
346
|
+
date: String(r[tsKey]).slice(0, 10),
|
|
347
|
+
title: String(r[txKey] || ''),
|
|
348
|
+
description: String(r.lastChangeWhat || r.description || r.line || ''),
|
|
349
|
+
};
|
|
350
|
+
});
|
|
351
|
+
try { AIMEAT.ui.viewers.Timeline({ target: thost, events: events }); }
|
|
352
|
+
catch (e) {
|
|
353
|
+
thost.innerHTML = '<ul class="timeline timeline-vertical">' + events.map(function (ev) {
|
|
354
|
+
return '<li><div class="timeline-start text-xs opacity-60">' + esc(ev.date) + '</div><div class="timeline-middle">•</div>' +
|
|
355
|
+
'<div class="timeline-end timeline-box"><b>' + esc(ev.title) + '</b><br><span class="text-sm opacity-70">' + esc(ev.description) + '</span></div></li>';
|
|
356
|
+
}).join('') + '</ul>';
|
|
357
|
+
}
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (kind === 'brief') {
|
|
362
|
+
var md = view.markdown || '';
|
|
363
|
+
var bhost = document.createElement('div');
|
|
364
|
+
bhost.className = 'prose prose-sm max-w-none';
|
|
365
|
+
box.appendChild(bhost);
|
|
366
|
+
if (global.AIMEAT && AIMEAT.md && AIMEAT.md.render) { try { AIMEAT.md.render(md, bhost); return; } catch (e) { /* fall through */ } }
|
|
367
|
+
bhost.innerHTML = esc(md).replace(/\n\n/g, '<br><br>').replace(/\n/g, '<br>');
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (kind === 'options') {
|
|
372
|
+
var items = (view.items || []).slice(0, 4);
|
|
373
|
+
var ohost = document.createElement('div');
|
|
374
|
+
ohost.className = 'grid gap-3';
|
|
375
|
+
ohost.innerHTML = items.map(function (op, i) {
|
|
376
|
+
var isPicked = view.chosen && view.chosen.title === op.title;
|
|
377
|
+
return '<div class="card ' + (isPicked ? 'bg-success/10 border border-success' : 'bg-base-200') + '">' +
|
|
378
|
+
'<div class="card-body p-4 gap-2">' +
|
|
379
|
+
'<h4 class="font-semibold">' + esc(op.title) + (isPicked ? ' <span class="badge badge-success badge-sm">' + esc(t('picked')) + '</span>' : '') + '</h4>' +
|
|
380
|
+
'<p class="text-sm opacity-80 whitespace-pre-line">' + esc(op.body) + '</p>' +
|
|
381
|
+
(isPicked ? '' : '<div class="card-actions"><button class="btn btn-sm" data-pick="' + i + '">' + esc(t('pick')) + '</button></div>') +
|
|
382
|
+
'</div></div>';
|
|
383
|
+
}).join('');
|
|
384
|
+
box.appendChild(ohost);
|
|
385
|
+
/* Hosts used to wire this button themselves; onPick means one less thing to get wrong. */
|
|
386
|
+
if (o.onPick) {
|
|
387
|
+
ohost.addEventListener('click', function (ev) {
|
|
388
|
+
var b = ev.target.closest ? ev.target.closest('[data-pick]') : null;
|
|
389
|
+
if (b) o.onPick(Number(b.getAttribute('data-pick')), spec);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/* table (default) */
|
|
396
|
+
var cols = (view.columns && view.columns.length) ? view.columns : autoColumns(rows);
|
|
397
|
+
var thost2 = document.createElement('div');
|
|
398
|
+
thost2.className = scrollClass;
|
|
399
|
+
box.appendChild(thost2);
|
|
400
|
+
try {
|
|
401
|
+
AIMEAT.ui.viewers.DataTable({
|
|
402
|
+
target: thost2, columns: cols, rows: rows,
|
|
403
|
+
sortable: true, filterable: rows.length > 8, pageSize: o.pageSize || 25,
|
|
404
|
+
});
|
|
405
|
+
} catch (e) {
|
|
406
|
+
thost2.innerHTML = '<table class="table table-sm"><thead><tr>' +
|
|
407
|
+
cols.map(function (c) { return '<th>' + esc(c.label) + '</th>'; }).join('') + '</tr></thead><tbody>' +
|
|
408
|
+
rows.map(function (r) {
|
|
409
|
+
return '<tr>' + cols.map(function (c) { return '<td>' + esc(r[c.key]) + '</td>'; }).join('') + '</tr>';
|
|
410
|
+
}).join('') + '</tbody></table>';
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/* ------------------------------------------------------------ composing -- */
|
|
415
|
+
function specHint() {
|
|
416
|
+
var srcLines = Object.keys(sources)
|
|
417
|
+
.map(function (k) { return sources[k].hint; })
|
|
418
|
+
.filter(Boolean);
|
|
419
|
+
return [
|
|
420
|
+
'You turn a person\'s plain-language request into ONE panel spec (JSON) for a live surface.',
|
|
421
|
+
'',
|
|
422
|
+
'Return ONLY JSON: {"title":"…","kind":"…","source":{…},"view":{…}}',
|
|
423
|
+
'',
|
|
424
|
+
'kind is one of: ' + KINDS.join(' | '),
|
|
425
|
+
'source is one of:',
|
|
426
|
+
srcLines.join('\n'),
|
|
427
|
+
'',
|
|
428
|
+
extraHints.filter(function (h) { return h.indexOf('always has these fields') > 0; }).join('\n'),
|
|
429
|
+
'',
|
|
430
|
+
'view by kind:',
|
|
431
|
+
' table {"columns":[{"key":"name","label":"Name"},{"key":"form","label":"Form"}]}',
|
|
432
|
+
' chart {"chartType":"bar|line|pie|doughnut","labelKey":"name","valueKeys":["count"]}',
|
|
433
|
+
' stats {"tiles":[{"label":"Total","key":"name","agg":"count"}]} agg: count|sum|avg|latest',
|
|
434
|
+
' timeline {"tsKey":"lastChange","textKey":"name"}',
|
|
435
|
+
' brief {} (leave empty, the surface writes the prose afterwards)',
|
|
436
|
+
' options {"items":[{"title":"…","body":"…"}]}',
|
|
437
|
+
'',
|
|
438
|
+
'Rules: pick the kind that ANSWERS the request, not the fanciest one. A comparison is a table.',
|
|
439
|
+
'A trend over time is a chart. A count or total is stats. History of changes is a timeline.',
|
|
440
|
+
'An open question for the owner is options. Column labels in the user\'s language.',
|
|
441
|
+
'Never invent names the user did not mention. Never put made-up rows in inline.',
|
|
442
|
+
].join('\n');
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** Models ignore schema wrappers and rename keys, so normalise hard. */
|
|
446
|
+
function normalizeSpec(out, intent) {
|
|
447
|
+
var o = pickJson(out && out.parsed) || pickJson(out && out.data) ||
|
|
448
|
+
pickJson(out && (out.content || out.text)) || pickJson(out);
|
|
449
|
+
if (o && o.spec) o = o.spec;
|
|
450
|
+
if (o && o.panel) o = o.panel;
|
|
451
|
+
if (!o || typeof o !== 'object') return null;
|
|
452
|
+
|
|
453
|
+
var kind = String(o.kind || o.type || 'table').toLowerCase();
|
|
454
|
+
if (KINDS.indexOf(kind) < 0) kind = 'table';
|
|
455
|
+
|
|
456
|
+
var src = o.source || o.data || {};
|
|
457
|
+
if (Array.isArray(src)) src = { type: 'inline', rows: src };
|
|
458
|
+
var stype = String(src.type || '').toLowerCase();
|
|
459
|
+
if (!sources[stype]) {
|
|
460
|
+
/* The model renamed or dropped the type: let each registered source claim it by shape,
|
|
461
|
+
and fall back to inline. */
|
|
462
|
+
stype = Object.keys(sources).filter(function (k) {
|
|
463
|
+
return sources[k].claims && sources[k].claims(src);
|
|
464
|
+
})[0] || 'inline';
|
|
465
|
+
}
|
|
466
|
+
var norm = sources[stype].normalize;
|
|
467
|
+
var source = norm ? norm(src) : { type: stype };
|
|
468
|
+
source.type = stype;
|
|
469
|
+
|
|
470
|
+
var view = o.view || o.config || {};
|
|
471
|
+
if (kind === 'table' && !view.columns && o.columns) view.columns = o.columns;
|
|
472
|
+
if (kind === 'options' && !view.items) view.items = o.items || o.options || [];
|
|
473
|
+
|
|
474
|
+
return {
|
|
475
|
+
id: uid('pnl'),
|
|
476
|
+
title: String(o.title || intent || '').slice(0, 90) || intent,
|
|
477
|
+
kind: kind, intent: intent, source: source, view: view,
|
|
478
|
+
needsYou: null, updatedAt: new Date().toISOString(), author: 'you',
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
async function compose(text, ctx) {
|
|
483
|
+
var out = await ai({
|
|
484
|
+
prompt: specHint() +
|
|
485
|
+
'\n\nAvailable memory key prefixes on this owner\'s node (use one only if it fits):\n' +
|
|
486
|
+
(((ctx && ctx.prefixes) || []).slice(0, 40).join('\n')) +
|
|
487
|
+
'\n\nWrite the panel spec for this request, answering in ' + lang() + ':\n' + text,
|
|
488
|
+
});
|
|
489
|
+
return normalizeSpec(out, text);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
async function reshape(spec, text) {
|
|
493
|
+
var out = await ai({
|
|
494
|
+
prompt: specHint() + '\n\nHere is an EXISTING panel spec:\n' +
|
|
495
|
+
JSON.stringify({ title: spec.title, kind: spec.kind, source: spec.source, view: spec.view }) +
|
|
496
|
+
'\n\nThe owner asks you to change it: "' + text + '"\n' +
|
|
497
|
+
'Return the FULL updated spec, keeping everything they did not ask to change. ' +
|
|
498
|
+
'Keep the same source unless they clearly asked for different data. Answer in ' + lang() + '.',
|
|
499
|
+
});
|
|
500
|
+
var next = normalizeSpec(out, spec.intent || text);
|
|
501
|
+
if (!next) return null;
|
|
502
|
+
next.id = spec.id;
|
|
503
|
+
next.author = spec.author;
|
|
504
|
+
if (next.kind === 'options' && spec.view && spec.view.chosen) next.view.chosen = spec.view.chosen;
|
|
505
|
+
return next;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Prose for a brief panel is written AFTER the rows are known, so it can never be invented:
|
|
510
|
+
* the model only sees real fetched data.
|
|
511
|
+
*/
|
|
512
|
+
async function writeBrief(spec, rows) {
|
|
513
|
+
var out = await ai({
|
|
514
|
+
prompt: 'Write a short brief in ' + lang() +
|
|
515
|
+
' answering the request below. Use ONLY the data rows given, invent nothing. ' +
|
|
516
|
+
'3 to 6 sentences, plain language, no dashes as punctuation.\n\nREQUEST: ' +
|
|
517
|
+
(spec.intent || spec.title) + '\n\nDATA:\n' + JSON.stringify(rows).slice(0, 6000),
|
|
518
|
+
});
|
|
519
|
+
return (out && (out.content || out.text)) || '';
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* SECOND PASS: when the request hit data whose shape the composer had to guess blind, the
|
|
524
|
+
* real fields are only known once the rows arrive. Letting the model pick kind + view against
|
|
525
|
+
* them is what makes "show my AI spend per day" arrive as a chart of the right column instead
|
|
526
|
+
* of a table of plumbing.
|
|
527
|
+
*/
|
|
528
|
+
async function refine(spec, rows) {
|
|
529
|
+
if (!rows || !rows.length) return null;
|
|
530
|
+
var fields = Object.keys(rows[0]);
|
|
531
|
+
var out = await ai({
|
|
532
|
+
prompt: specHint() + '\n\nThe data is ALREADY FETCHED. These are the REAL fields:\n' +
|
|
533
|
+
fields.join(', ') + '\n\nTwo sample rows:\n' + JSON.stringify(rows.slice(0, 2)) +
|
|
534
|
+
'\n\nThe owner asked: "' + (spec.intent || spec.title) + '"\n' +
|
|
535
|
+
'Return the spec with source EXACTLY ' + JSON.stringify(spec.source) + ' ' +
|
|
536
|
+
'and a kind + view that answers the request using ONLY the field names above. ' +
|
|
537
|
+
'A per-day or per-period question is a chart (labelKey = the date field, valueKeys = the measure). ' +
|
|
538
|
+
'Labels in ' + lang() + '.',
|
|
539
|
+
});
|
|
540
|
+
var next = normalizeSpec(out, spec.intent);
|
|
541
|
+
if (!next) return null;
|
|
542
|
+
next.id = spec.id;
|
|
543
|
+
next.author = spec.author;
|
|
544
|
+
next.source = spec.source;
|
|
545
|
+
next.needsYou = spec.needsYou || null;
|
|
546
|
+
return next;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return {
|
|
550
|
+
KINDS: KINDS,
|
|
551
|
+
registerSource: registerSource,
|
|
552
|
+
resolve: resolve,
|
|
553
|
+
renderBody: renderBody,
|
|
554
|
+
specHint: specHint,
|
|
555
|
+
normalizeSpec: normalizeSpec,
|
|
556
|
+
compose: compose,
|
|
557
|
+
reshape: reshape,
|
|
558
|
+
writeBrief: writeBrief,
|
|
559
|
+
refine: refine,
|
|
560
|
+
autoColumns: autoColumns,
|
|
561
|
+
fmtNum: fmtNum,
|
|
562
|
+
t: t,
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
AIMEAT.surface = {
|
|
567
|
+
create: create,
|
|
568
|
+
KINDS: KINDS,
|
|
569
|
+
// Pure helpers a host may need outside an engine instance.
|
|
570
|
+
flatten: flatten,
|
|
571
|
+
autoColumns: autoColumns,
|
|
572
|
+
agg: agg,
|
|
573
|
+
num: num,
|
|
574
|
+
VERSION: '1.1.0',
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
})(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this);
|