@elizaos/agent 2.0.0-beta.2 → 2.0.11-beta.6
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/__tests__/plugin-lifecycle-test-utils.d.ts +47 -0
- package/__tests__/plugin-lifecycle-test-utils.d.ts.map +1 -0
- package/__tests__/plugin-lifecycle-test-utils.js +81 -0
- package/__tests__/view-user-journeys.d.ts +55 -0
- package/__tests__/view-user-journeys.d.ts.map +1 -0
- package/__tests__/view-user-journeys.js +707 -0
- package/actions/compact-conversation.d.ts +3 -0
- package/actions/compact-conversation.d.ts.map +1 -0
- package/actions/compact-conversation.js +256 -0
- package/actions/connector-resolver.d.ts.map +1 -0
- package/actions/connector-resolver.js +250 -0
- package/actions/contact.d.ts.map +1 -0
- package/actions/contact.js +1700 -0
- package/actions/context-signal-lexicon.d.ts.map +1 -0
- package/actions/context-signal.d.ts.map +1 -0
- package/actions/context-signal.js +153 -0
- package/actions/database.d.ts.map +1 -0
- package/actions/database.js +674 -0
- package/actions/extract-params.d.ts +87 -0
- package/actions/extract-params.d.ts.map +1 -0
- package/actions/extract-params.js +204 -0
- package/actions/grounded-action-reply.d.ts.map +1 -0
- package/actions/grounded-action-reply.js +287 -0
- package/actions/index.d.ts +18 -0
- package/actions/index.d.ts.map +1 -0
- package/actions/index.js +17 -0
- package/actions/logs.d.ts.map +1 -0
- package/actions/memories.d.ts +3 -0
- package/actions/memories.d.ts.map +1 -0
- package/actions/memories.js +357 -0
- package/actions/notify.d.ts +14 -0
- package/actions/notify.d.ts.map +1 -0
- package/actions/notify.js +163 -0
- package/actions/page-action-groups.d.ts +9 -0
- package/actions/page-action-groups.d.ts.map +1 -0
- package/actions/page-action-groups.js +259 -0
- package/actions/plugin.d.ts +3 -0
- package/actions/plugin.d.ts.map +1 -0
- package/actions/plugin.js +755 -0
- package/actions/recent-conversation-texts.d.ts.map +1 -0
- package/actions/recent-conversation-texts.js +76 -0
- package/actions/runtime.d.ts.map +1 -0
- package/actions/runtime.js +517 -0
- package/actions/settings-actions.d.ts +19 -0
- package/actions/settings-actions.d.ts.map +1 -0
- package/actions/settings-actions.js +478 -0
- package/actions/terminal.d.ts.map +1 -0
- package/actions/terminal.js +327 -0
- package/actions/trigger.d.ts.map +1 -0
- package/actions/trigger.js +511 -0
- package/api/accounts-routes.d.ts +38 -0
- package/api/accounts-routes.d.ts.map +1 -0
- package/api/accounts-routes.js +932 -0
- package/api/agent-admin-routes.d.ts +36 -0
- package/api/agent-admin-routes.d.ts.map +1 -0
- package/api/agent-admin-routes.js +151 -0
- package/api/agent-lifecycle-routes.d.ts.map +1 -0
- package/api/agent-lifecycle-routes.js +104 -0
- package/api/agent-model.d.ts.map +1 -0
- package/api/agent-model.js +172 -0
- package/api/agent-status-routes.d.ts.map +1 -0
- package/api/agent-status-routes.js +280 -0
- package/api/agent-transfer-routes.d.ts.map +1 -0
- package/api/agent-transfer-routes.js +124 -0
- package/api/app-package-routes.d.ts +3 -0
- package/api/app-package-routes.d.ts.map +1 -0
- package/api/app-package-routes.js +59 -0
- package/api/auth-routes.d.ts.map +1 -0
- package/api/auth-routes.js +126 -0
- package/api/avatar-routes.d.ts.map +1 -0
- package/api/avatar-routes.js +210 -0
- package/api/background-tasks-routes.d.ts +18 -0
- package/api/background-tasks-routes.d.ts.map +1 -0
- package/api/background-tasks-routes.js +58 -0
- package/api/binance-skill-helpers.d.ts.map +1 -0
- package/api/binance-skill-helpers.js +859 -0
- package/api/bug-report-routes.d.ts +10 -0
- package/api/bug-report-routes.d.ts.map +1 -0
- package/api/bug-report-routes.js +276 -0
- package/api/builtin-views.d.ts +11 -0
- package/api/builtin-views.d.ts.map +1 -0
- package/api/builtin-views.js +164 -0
- package/api/character-routes.d.ts.map +1 -0
- package/api/character-routes.js +380 -0
- package/api/chat-augmentation.d.ts +22 -0
- package/api/chat-augmentation.d.ts.map +1 -0
- package/api/chat-augmentation.js +367 -0
- package/api/chat-routes.d.ts +150 -0
- package/api/chat-routes.d.ts.map +1 -0
- package/api/chat-routes.js +2581 -0
- package/api/chat-text-helpers.d.ts.map +1 -0
- package/api/client-chat-admin.d.ts.map +1 -0
- package/api/commands-routes.d.ts +30 -0
- package/api/commands-routes.d.ts.map +1 -0
- package/api/commands-routes.js +90 -0
- package/api/compat-utils.d.ts.map +1 -0
- package/api/config-env.d.ts.map +1 -0
- package/api/config-env.js +283 -0
- package/api/config-routes.d.ts.map +1 -0
- package/api/config-routes.js +433 -0
- package/api/connector-account-routes.d.ts.map +1 -0
- package/api/connector-account-routes.js +740 -0
- package/api/connector-health.d.ts.map +1 -0
- package/api/connector-oauth-callback-auth.d.ts.map +1 -0
- package/api/connector-routes.d.ts.map +1 -0
- package/api/connector-routes.js +198 -0
- package/api/conversation-metadata.d.ts.map +1 -0
- package/api/conversation-metadata.js +118 -0
- package/api/conversation-routes.d.ts +64 -0
- package/api/conversation-routes.d.ts.map +1 -0
- package/api/conversation-routes.js +1795 -0
- package/api/coordinator-wiring.d.ts.map +1 -0
- package/api/coordinator-wiring.js +108 -0
- package/api/credit-detection.d.ts.map +1 -0
- package/api/credit-detection.js +41 -0
- package/api/database.d.ts +33 -0
- package/api/database.d.ts.map +1 -0
- package/api/database.js +1026 -0
- package/api/diagnostics-routes.d.ts +51 -0
- package/api/diagnostics-routes.d.ts.map +1 -0
- package/api/diagnostics-routes.js +361 -0
- package/api/dispatch-route.d.ts +40 -0
- package/api/dispatch-route.d.ts.map +1 -0
- package/api/dispatch-route.js +387 -0
- package/api/documents-service-loader.d.ts.map +1 -0
- package/api/early-logs.d.ts +24 -0
- package/api/early-logs.d.ts.map +1 -0
- package/api/first-run-routes.d.ts +50 -0
- package/api/first-run-routes.d.ts.map +1 -0
- package/api/first-run-routes.js +570 -0
- package/api/health-routes.d.ts +58 -0
- package/api/health-routes.d.ts.map +1 -0
- package/api/health-routes.js +554 -0
- package/api/hono-adapter.d.ts +29 -0
- package/api/hono-adapter.d.ts.map +1 -0
- package/api/hono-adapter.js +170 -0
- package/api/hono-mount.d.ts +16 -0
- package/api/hono-mount.d.ts.map +1 -0
- package/api/hono-mount.js +121 -0
- package/api/inbox-routes.d.ts.map +1 -0
- package/api/inbox-routes.js +1587 -0
- package/api/index.d.ts +43 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +52 -0
- package/api/media-runtime.d.ts +36 -0
- package/api/media-runtime.d.ts.map +1 -0
- package/api/media-runtime.js +136 -0
- package/api/media-store.d.ts +86 -0
- package/api/media-store.d.ts.map +1 -0
- package/api/media-store.js +461 -0
- package/api/media-thumbnail.d.ts +22 -0
- package/api/media-thumbnail.d.ts.map +1 -0
- package/api/media-thumbnail.js +121 -0
- package/api/memory-bounds.d.ts.map +1 -0
- package/api/memory-routes.d.ts.map +1 -0
- package/api/memory-routes.js +480 -0
- package/api/misc-routes.d.ts.map +1 -0
- package/api/misc-routes.js +569 -0
- package/api/mobile-optional-routes.d.ts.map +1 -0
- package/api/mobile-optional-routes.js +258 -0
- package/api/model-provider-helpers.d.ts +70 -0
- package/api/model-provider-helpers.d.ts.map +1 -0
- package/api/model-provider-helpers.js +663 -0
- package/api/models-routes.d.ts.map +1 -0
- package/api/music-player-route-fallback.d.ts.map +1 -0
- package/api/nfa-routes.d.ts +6 -0
- package/api/nfa-routes.d.ts.map +1 -0
- package/api/nfa-routes.js +125 -0
- package/api/notification-routes.d.ts +38 -0
- package/api/notification-routes.d.ts.map +1 -0
- package/api/notification-routes.js +169 -0
- package/api/owner-contact-helpers.d.ts.map +1 -0
- package/api/parse-action-block.d.ts +53 -0
- package/api/parse-action-block.d.ts.map +1 -0
- package/api/pending-request-map.d.ts +30 -0
- package/api/pending-request-map.d.ts.map +1 -0
- package/api/pending-request-map.js +40 -0
- package/api/permission-request-prompt.d.ts +19 -0
- package/api/permission-request-prompt.d.ts.map +1 -0
- package/api/permission-request-prompt.js +55 -0
- package/api/permissions-routes-extra.d.ts +28 -0
- package/api/permissions-routes-extra.d.ts.map +1 -0
- package/api/permissions-routes.d.ts.map +1 -0
- package/api/permissions-routes.js +468 -0
- package/api/platform-detect.d.ts +26 -0
- package/api/platform-detect.d.ts.map +1 -0
- package/api/platform-detect.js +40 -0
- package/api/plugin-discovery-helpers.d.ts +118 -0
- package/api/plugin-discovery-helpers.d.ts.map +1 -0
- package/api/plugin-discovery-helpers.js +1159 -0
- package/api/plugin-runtime-apply.d.ts.map +1 -0
- package/api/plugin-runtime-apply.js +217 -0
- package/api/plugin-validation.d.ts.map +1 -0
- package/api/provider-switch-config.d.ts +59 -0
- package/api/provider-switch-config.d.ts.map +1 -0
- package/api/provider-switch-config.js +804 -0
- package/api/provider-switch-routes.d.ts.map +1 -0
- package/api/provider-switch-routes.js +133 -0
- package/api/push-token-routes.d.ts +30 -0
- package/api/push-token-routes.d.ts.map +1 -0
- package/api/push-token-routes.js +83 -0
- package/api/rate-limiter.d.ts.map +1 -0
- package/api/registry-routes.d.ts.map +1 -0
- package/api/registry-routes.js +98 -0
- package/api/registry-service.d.ts.map +1 -0
- package/api/registry-service.js +190 -0
- package/api/relationships-routes.d.ts.map +1 -0
- package/api/relationships-routes.js +286 -0
- package/api/remote-capability-routes.d.ts +26 -0
- package/api/remote-capability-routes.d.ts.map +1 -0
- package/api/remote-capability-routes.js +612 -0
- package/api/runtime-plugin-routes.d.ts.map +1 -0
- package/api/runtime-plugin-routes.js +251 -0
- package/api/runtime-ready-gate.d.ts +25 -0
- package/api/runtime-ready-gate.d.ts.map +1 -0
- package/api/runtime-ready-gate.js +35 -0
- package/api/server-auth.d.ts.map +1 -0
- package/api/server-auth.js +504 -0
- package/api/server-autonomy-helpers.d.ts.map +1 -0
- package/api/server-helpers-auth.d.ts +62 -0
- package/api/server-helpers-auth.d.ts.map +1 -0
- package/api/server-helpers-auth.js +889 -0
- package/api/server-helpers-config.d.ts +37 -0
- package/api/server-helpers-config.d.ts.map +1 -0
- package/api/server-helpers-config.js +289 -0
- package/api/server-helpers-fetch.d.ts.map +1 -0
- package/api/server-helpers-mcp.d.ts +17 -0
- package/api/server-helpers-mcp.d.ts.map +1 -0
- package/api/server-helpers-mcp.js +60 -0
- package/api/server-helpers-plugin.d.ts.map +1 -0
- package/api/server-helpers-swarm.d.ts +101 -0
- package/api/server-helpers-swarm.d.ts.map +1 -0
- package/api/server-helpers-swarm.js +646 -0
- package/api/server-helpers-wallet.d.ts.map +1 -0
- package/api/server-helpers.d.ts +85 -0
- package/api/server-helpers.d.ts.map +1 -0
- package/api/server-helpers.js +676 -0
- package/api/server-lazy-routes.d.ts +88 -0
- package/api/server-lazy-routes.d.ts.map +1 -0
- package/api/server-lazy-routes.js +446 -0
- package/api/server-route-dispatch.d.ts.map +1 -0
- package/api/server-route-dispatch.js +127 -0
- package/api/server-types.d.ts +197 -0
- package/api/server-types.d.ts.map +1 -0
- package/api/server.d.ts +61 -0
- package/api/server.d.ts.map +1 -0
- package/api/server.js +3684 -0
- package/api/static-file-server.d.ts.map +1 -0
- package/api/static-file-server.js +233 -0
- package/api/subscription-routes.d.ts.map +1 -0
- package/api/subscription-routes.js +294 -0
- package/api/suggestions-routes.d.ts +50 -0
- package/api/suggestions-routes.d.ts.map +1 -0
- package/api/suggestions-routes.js +301 -0
- package/api/task-agent-message-routing.d.ts.map +1 -0
- package/api/terminal-execution-routing.d.ts.map +1 -0
- package/api/terminal-run-limits.d.ts.map +1 -0
- package/api/terminal-run-limits.js +20 -0
- package/api/trade-safety.d.ts +35 -0
- package/api/trade-safety.d.ts.map +1 -0
- package/api/trade-safety.js +65 -0
- package/api/training-backend-check.d.ts.map +1 -0
- package/api/training-service-like.d.ts.map +1 -0
- package/api/tx-service.d.ts +53 -0
- package/api/tx-service.d.ts.map +1 -0
- package/api/tx-service.js +217 -0
- package/api/update-routes.d.ts.map +1 -0
- package/api/update-routes.js +69 -0
- package/api/view-registry-types.d.ts +52 -0
- package/api/view-registry-types.d.ts.map +1 -0
- package/api/view-registry-types.js +9 -0
- package/api/views-registry.d.ts +90 -0
- package/api/views-registry.d.ts.map +1 -0
- package/api/views-registry.js +471 -0
- package/api/views-routes.d.ts +50 -0
- package/api/views-routes.d.ts.map +1 -0
- package/api/views-routes.js +821 -0
- package/api/views-search-index.d.ts +56 -0
- package/api/views-search-index.d.ts.map +1 -0
- package/api/views-search-index.js +128 -0
- package/api/wallet-capability.d.ts +32 -0
- package/api/wallet-capability.d.ts.map +1 -0
- package/api/wallet-capability.js +192 -0
- package/api/wallet-dex-prices.d.ts.map +1 -0
- package/api/wallet-env-sync.d.ts +2 -0
- package/api/wallet-env-sync.d.ts.map +1 -0
- package/api/wallet-evm-balance.d.ts.map +1 -0
- package/api/wallet-keygen.d.ts +5 -0
- package/api/wallet-keygen.d.ts.map +1 -0
- package/api/wallet-keygen.js +67 -0
- package/api/wallet-rpc.d.ts.map +1 -0
- package/api/wallet-rpc.js +440 -0
- package/api/wallet-trading-profile.d.ts.map +1 -0
- package/api/wallet-trading-profile.js +544 -0
- package/api/wallet.d.ts.map +1 -0
- package/api/wallet.js +786 -0
- package/api/workbench-context.d.ts +48 -0
- package/api/workbench-context.d.ts.map +1 -0
- package/api/workbench-context.js +9 -0
- package/api/workbench-helpers.d.ts.map +1 -0
- package/api/workbench-routes.d.ts +5 -0
- package/api/workbench-routes.d.ts.map +1 -0
- package/api/workbench-routes.js +283 -0
- package/api/workbench-vfs-routes.d.ts +3 -0
- package/api/workbench-vfs-routes.d.ts.map +1 -0
- package/api/workbench-vfs-routes.js +396 -0
- package/api/ws-event-replay.d.ts +64 -0
- package/api/ws-event-replay.d.ts.map +1 -0
- package/api/ws-event-replay.js +84 -0
- package/api/x-relay-routes.d.ts.map +1 -0
- package/api/x-relay-routes.js +141 -0
- package/api/zip-utils.d.ts.map +1 -0
- package/assets/view-heroes/automations.png +0 -0
- package/assets/view-heroes/camera.png +0 -0
- package/assets/view-heroes/character.png +0 -0
- package/assets/view-heroes/chat.png +0 -0
- package/assets/view-heroes/database.png +0 -0
- package/assets/view-heroes/help.png +0 -0
- package/assets/view-heroes/logs.png +0 -0
- package/assets/view-heroes/memories.png +0 -0
- package/assets/view-heroes/plugins-page.png +0 -0
- package/assets/view-heroes/settings.png +0 -0
- package/assets/view-heroes/trajectories.png +0 -0
- package/assets/view-heroes/tutorial.png +0 -0
- package/auth/account-storage.d.ts +35 -0
- package/auth/account-storage.d.ts.map +1 -0
- package/auth/account-storage.js +135 -0
- package/auth/anthropic.d.ts.map +1 -0
- package/auth/claude-code-stealth.d.ts.map +1 -0
- package/auth/claude-code-stealth.js +114 -0
- package/auth/credentials.d.ts +131 -0
- package/auth/credentials.d.ts.map +1 -0
- package/auth/credentials.js +596 -0
- package/auth/index.d.ts.map +1 -0
- package/auth/oauth-flow.d.ts +106 -0
- package/auth/oauth-flow.d.ts.map +1 -0
- package/auth/oauth-flow.js +349 -0
- package/auth/openai-codex.d.ts.map +1 -0
- package/auth/openai-codex.js +84 -0
- package/auth/refresh-mutex.d.ts +24 -0
- package/auth/refresh-mutex.d.ts.map +1 -0
- package/auth/refresh-mutex.js +38 -0
- package/auth/types.d.ts +65 -0
- package/auth/types.d.ts.map +1 -0
- package/auth/types.js +157 -0
- package/auth/vendor/pi-oauth/anthropic-login.d.ts.map +1 -0
- package/auth/vendor/pi-oauth/anthropic-login.js +118 -0
- package/auth/vendor/pi-oauth/openai-codex-login.d.ts +28 -0
- package/auth/vendor/pi-oauth/openai-codex-login.d.ts.map +1 -0
- package/auth/vendor/pi-oauth/openai-codex-login.js +342 -0
- package/auth/vendor/pi-oauth/pkce.d.ts.map +1 -0
- package/awareness/index.d.ts.map +1 -0
- package/awareness/registry.d.ts.map +1 -0
- package/bin.d.ts.map +1 -0
- package/bin.js +120 -0
- package/cli/benchmark.d.ts.map +1 -0
- package/cli/benchmark.js +305 -0
- package/cli/index.d.ts.map +1 -0
- package/cli/index.js +174 -0
- package/config/character-schema.d.ts.map +1 -0
- package/config/config.d.ts.map +1 -0
- package/config/config.js +288 -0
- package/config/env-vars.d.ts.map +1 -0
- package/config/feature-flags.d.ts +26 -0
- package/config/feature-flags.d.ts.map +1 -0
- package/config/feature-flags.js +48 -0
- package/config/includes.d.ts +26 -0
- package/config/includes.d.ts.map +1 -0
- package/config/includes.js +151 -0
- package/config/index.d.ts.map +1 -0
- package/config/model-metadata.d.ts.map +1 -0
- package/config/model-metadata.js +133 -0
- package/config/owner-contacts.d.ts.map +1 -0
- package/config/owner-contacts.js +238 -0
- package/config/paths.d.ts +16 -0
- package/config/paths.d.ts.map +1 -0
- package/config/paths.js +61 -0
- package/config/plugin-auto-enable.d.ts.map +1 -0
- package/config/plugin-widgets.d.ts +26 -0
- package/config/plugin-widgets.d.ts.map +1 -0
- package/config/plugin-widgets.js +60 -0
- package/config/schema.d.ts.map +1 -0
- package/config/schema.js +928 -0
- package/config/telegram-custom-commands.d.ts.map +1 -0
- package/config/types.agent-defaults.d.ts.map +1 -0
- package/config/types.agents.d.ts.map +1 -0
- package/config/types.d.ts.map +1 -0
- package/config/types.eliza.d.ts.map +1 -0
- package/config/types.hooks.d.ts.map +1 -0
- package/config/types.messages.d.ts.map +1 -0
- package/config/zod-schema.agent-runtime.d.ts +1166 -0
- package/config/zod-schema.agent-runtime.d.ts.map +1 -0
- package/config/zod-schema.agent-runtime.js +810 -0
- package/config/zod-schema.core.d.ts +1279 -0
- package/config/zod-schema.core.d.ts.map +1 -0
- package/config/zod-schema.core.js +761 -0
- package/config/zod-schema.d.ts +3406 -0
- package/config/zod-schema.d.ts.map +1 -0
- package/config/zod-schema.hooks.d.ts.map +1 -0
- package/config/zod-schema.js +846 -0
- package/config/zod-schema.providers-core.d.ts +2752 -0
- package/config/zod-schema.providers-core.d.ts.map +1 -0
- package/config/zod-schema.providers-core.js +969 -0
- package/config/zod-schema.session.d.ts +183 -0
- package/config/zod-schema.session.d.ts.map +1 -0
- package/contracts/awareness.d.ts.map +1 -0
- package/diagnostics/integration-observability.d.ts.map +1 -0
- package/hooks/discovery.d.ts +13 -0
- package/hooks/discovery.d.ts.map +1 -0
- package/hooks/discovery.js +191 -0
- package/hooks/eligibility.d.ts.map +1 -0
- package/hooks/index.d.ts.map +1 -0
- package/hooks/loader.d.ts.map +1 -0
- package/hooks/loader.js +214 -0
- package/hooks/registry.d.ts.map +1 -0
- package/hooks/types.d.ts.map +1 -0
- package/index.d.ts +97 -0
- package/index.d.ts.map +1 -0
- package/index.js +128 -0
- package/package.json +272 -78
- package/providers/admin-panel.d.ts.map +1 -0
- package/providers/admin-trust.d.ts.map +1 -0
- package/providers/automation-terminal-bridge.d.ts.map +1 -0
- package/providers/automation-terminal-bridge.js +77 -0
- package/providers/conversation-proximity.d.ts.map +1 -0
- package/providers/escalation-trigger.d.ts.map +1 -0
- package/providers/media-provider.d.ts +234 -0
- package/providers/media-provider.d.ts.map +1 -0
- package/providers/media-provider.js +1511 -0
- package/providers/page-scoped-context.d.ts.map +1 -0
- package/providers/page-scoped-context.js +551 -0
- package/providers/pending-permissions-provider.d.ts +19 -0
- package/providers/pending-permissions-provider.d.ts.map +1 -0
- package/providers/pending-permissions-provider.js +110 -0
- package/providers/recent-conversations.d.ts.map +1 -0
- package/providers/recent-conversations.js +100 -0
- package/providers/relevant-conversations.d.ts.map +1 -0
- package/providers/relevant-conversations.js +99 -0
- package/providers/role-backfill.d.ts +18 -0
- package/providers/role-backfill.d.ts.map +1 -0
- package/providers/role-backfill.js +86 -0
- package/providers/rolodex.d.ts.map +1 -0
- package/providers/rolodex.js +90 -0
- package/providers/session-bridge.d.ts.map +1 -0
- package/providers/session-bridge.js +71 -0
- package/providers/session-utils.d.ts +14 -0
- package/providers/session-utils.d.ts.map +1 -0
- package/providers/session-utils.js +24 -0
- package/providers/skill-provider.d.ts.map +1 -0
- package/providers/tasks.d.ts.map +1 -0
- package/providers/ui-catalog.d.ts.map +1 -0
- package/providers/ui-catalog.js +132 -0
- package/providers/user-name.d.ts.map +1 -0
- package/providers/workspace-provider.d.ts.map +1 -0
- package/providers/workspace-provider.js +183 -0
- package/providers/workspace.d.ts +53 -0
- package/providers/workspace.d.ts.map +1 -0
- package/providers/workspace.js +419 -0
- package/runtime/actions/web-fetch.d.ts +28 -0
- package/runtime/actions/web-fetch.d.ts.map +1 -0
- package/runtime/actions/web-fetch.js +190 -0
- package/runtime/advanced-capabilities-config.d.ts.map +1 -0
- package/runtime/agent-event-service.d.ts.map +1 -0
- package/runtime/agent-wallets.d.ts +134 -0
- package/runtime/agent-wallets.d.ts.map +1 -0
- package/runtime/agent-wallets.js +317 -0
- package/runtime/android-app-plugins.d.ts +4 -0
- package/runtime/android-app-plugins.d.ts.map +1 -0
- package/runtime/android-app-plugins.js +40 -0
- package/runtime/boot-telemetry.d.ts +36 -0
- package/runtime/boot-telemetry.d.ts.map +1 -0
- package/runtime/boot-telemetry.js +198 -0
- package/runtime/boot-timer.d.ts +41 -0
- package/runtime/boot-timer.d.ts.map +1 -0
- package/runtime/boot-timer.js +42 -0
- package/runtime/build-character-config.d.ts.map +1 -0
- package/runtime/build-character-config.js +220 -0
- package/runtime/conversation-compactor-runtime.d.ts +164 -0
- package/runtime/conversation-compactor-runtime.d.ts.map +1 -0
- package/runtime/conversation-compactor-runtime.js +1114 -0
- package/runtime/conversation-compactor.d.ts +38 -0
- package/runtime/conversation-compactor.d.ts.map +1 -0
- package/runtime/conversation-compactor.js +1238 -0
- package/runtime/conversation-compactor.types.d.ts +102 -0
- package/runtime/conversation-compactor.types.d.ts.map +1 -0
- package/runtime/core-plugins.d.ts +142 -0
- package/runtime/core-plugins.d.ts.map +1 -0
- package/runtime/core-plugins.js +257 -0
- package/runtime/custom-actions.d.ts +71 -0
- package/runtime/custom-actions.d.ts.map +1 -0
- package/runtime/custom-actions.js +611 -0
- package/runtime/default-documents.d.ts +21 -0
- package/runtime/default-documents.d.ts.map +1 -0
- package/runtime/default-documents.js +283 -0
- package/runtime/eliza-plugin.d.ts.map +1 -0
- package/runtime/eliza-plugin.js +204 -0
- package/runtime/eliza.d.ts +136 -0
- package/runtime/eliza.d.ts.map +1 -0
- package/runtime/eliza.js +4331 -0
- package/runtime/first-run-names.d.ts +20 -0
- package/runtime/first-run-names.d.ts.map +1 -0
- package/runtime/first-run-names.js +104 -0
- package/runtime/first-time-setup.d.ts +51 -0
- package/runtime/first-time-setup.d.ts.map +1 -0
- package/runtime/first-time-setup.js +716 -0
- package/runtime/index.d.ts +19 -0
- package/runtime/index.d.ts.map +1 -0
- package/runtime/index.js +18 -0
- package/runtime/load-plugin-from-directory.d.ts +59 -0
- package/runtime/load-plugin-from-directory.d.ts.map +1 -0
- package/runtime/load-plugin-from-directory.js +143 -0
- package/runtime/load-plugin-from-vfs.d.ts +68 -0
- package/runtime/load-plugin-from-vfs.d.ts.map +1 -0
- package/runtime/load-plugin-from-vfs.js +100 -0
- package/runtime/local-execution-mode.d.ts +11 -0
- package/runtime/local-execution-mode.d.ts.map +1 -0
- package/runtime/mobile-dns.d.ts +18 -0
- package/runtime/mobile-dns.d.ts.map +1 -0
- package/runtime/mobile-dns.js +258 -0
- package/runtime/model-resolution.d.ts.map +1 -0
- package/runtime/model-resolution.js +55 -0
- package/runtime/native-runtime-features.d.ts.map +1 -0
- package/runtime/operations/classifier.d.ts.map +1 -0
- package/runtime/operations/classifier.js +72 -0
- package/runtime/operations/cold-strategy.d.ts.map +1 -0
- package/runtime/operations/health-checks.d.ts.map +1 -0
- package/runtime/operations/health.d.ts.map +1 -0
- package/runtime/operations/index.d.ts.map +1 -0
- package/runtime/operations/manager.d.ts +70 -0
- package/runtime/operations/manager.d.ts.map +1 -0
- package/runtime/operations/manager.js +210 -0
- package/runtime/operations/reload-hot.d.ts +43 -0
- package/runtime/operations/reload-hot.d.ts.map +1 -0
- package/runtime/operations/reload-hot.js +181 -0
- package/runtime/operations/repository.d.ts.map +1 -0
- package/runtime/operations/types.d.ts.map +1 -0
- package/runtime/operations/vault-bridge.d.ts +81 -0
- package/runtime/operations/vault-bridge.d.ts.map +1 -0
- package/runtime/owner-entity.d.ts.map +1 -0
- package/runtime/owner-entity.js +34 -0
- package/runtime/pglite-error-compat.d.ts +27 -0
- package/runtime/pglite-error-compat.d.ts.map +1 -0
- package/runtime/pglite-error-compat.js +53 -0
- package/runtime/plugin-collector.d.ts.map +1 -0
- package/runtime/plugin-collector.js +604 -0
- package/runtime/plugin-lifecycle.d.ts +16 -0
- package/runtime/plugin-lifecycle.d.ts.map +1 -0
- package/runtime/plugin-lifecycle.js +653 -0
- package/runtime/plugin-resolver.d.ts +59 -0
- package/runtime/plugin-resolver.d.ts.map +1 -0
- package/runtime/plugin-resolver.js +1549 -0
- package/runtime/plugin-role-gating.d.ts +23 -0
- package/runtime/plugin-role-gating.d.ts.map +1 -0
- package/runtime/plugin-role-gating.js +172 -0
- package/runtime/plugin-types.d.ts +64 -0
- package/runtime/plugin-types.d.ts.map +1 -0
- package/runtime/plugin-types.js +310 -0
- package/runtime/prompt-compaction.d.ts +100 -0
- package/runtime/prompt-compaction.d.ts.map +1 -0
- package/runtime/prompt-compaction.js +395 -0
- package/runtime/prompt-optimization.d.ts +50 -0
- package/runtime/prompt-optimization.d.ts.map +1 -0
- package/runtime/prompt-optimization.js +1243 -0
- package/runtime/release-plugin-policy.d.ts.map +1 -0
- package/runtime/release-plugin-policy.js +115 -0
- package/runtime/restart.d.ts +9 -0
- package/runtime/restart.d.ts.map +1 -0
- package/runtime/restart.js +8 -0
- package/runtime/roles/src/index.d.ts.map +1 -0
- package/runtime/roles/src/index.js +279 -0
- package/runtime/roles/src/provider.d.ts.map +1 -0
- package/runtime/roles/src/types.d.ts.map +1 -0
- package/runtime/roles/src/utils.d.ts.map +1 -0
- package/runtime/roles.d.ts.map +1 -0
- package/runtime/sandbox-character.d.ts +61 -0
- package/runtime/sandbox-character.d.ts.map +1 -0
- package/runtime/sandbox-character.js +193 -0
- package/runtime/sandbox-registry.d.ts +96 -0
- package/runtime/sandbox-registry.d.ts.map +1 -0
- package/runtime/sandbox-registry.js +346 -0
- package/runtime/tool-call-cache/cache.d.ts +62 -0
- package/runtime/tool-call-cache/cache.d.ts.map +1 -0
- package/runtime/tool-call-cache/cache.js +123 -0
- package/runtime/tool-call-cache/disk-store.d.ts.map +1 -0
- package/runtime/tool-call-cache/index.d.ts +7 -0
- package/runtime/tool-call-cache/index.d.ts.map +1 -0
- package/runtime/tool-call-cache/index.js +4 -0
- package/runtime/tool-call-cache/key.d.ts.map +1 -0
- package/runtime/tool-call-cache/key.js +31 -0
- package/runtime/tool-call-cache/lru.d.ts.map +1 -0
- package/runtime/tool-call-cache/redact.d.ts +17 -0
- package/runtime/tool-call-cache/redact.d.ts.map +1 -0
- package/runtime/tool-call-cache/redact.js +77 -0
- package/runtime/tool-call-cache/registry.d.ts +18 -0
- package/runtime/tool-call-cache/registry.d.ts.map +1 -0
- package/runtime/tool-call-cache/registry.js +66 -0
- package/runtime/tool-call-cache/types.d.ts.map +1 -0
- package/runtime/tool-call-cache-wrapper.d.ts.map +1 -0
- package/runtime/trajectory-export.d.ts.map +1 -0
- package/runtime/trajectory-export.js +132 -0
- package/runtime/trajectory-internals.d.ts +263 -0
- package/runtime/trajectory-internals.d.ts.map +1 -0
- package/runtime/trajectory-internals.js +1720 -0
- package/runtime/trajectory-persistence.d.ts +30 -0
- package/runtime/trajectory-persistence.d.ts.map +1 -0
- package/runtime/trajectory-persistence.js +47 -0
- package/runtime/trajectory-query.d.ts.map +1 -0
- package/runtime/trajectory-query.js +29 -0
- package/runtime/trajectory-steps-reader.d.ts +41 -0
- package/runtime/trajectory-steps-reader.d.ts.map +1 -0
- package/runtime/trajectory-steps-reader.js +129 -0
- package/runtime/trajectory-steps-writer.d.ts +35 -0
- package/runtime/trajectory-steps-writer.d.ts.map +1 -0
- package/runtime/trajectory-steps-writer.js +135 -0
- package/runtime/trajectory-storage.d.ts +103 -0
- package/runtime/trajectory-storage.d.ts.map +1 -0
- package/runtime/trajectory-storage.js +1174 -0
- package/runtime/vault-profile-resolver.d.ts +37 -0
- package/runtime/vault-profile-resolver.d.ts.map +1 -0
- package/runtime/vault-profile-resolver.js +79 -0
- package/runtime/version.d.ts.map +1 -0
- package/runtime/view-action-affinity.d.ts +129 -0
- package/runtime/view-action-affinity.d.ts.map +1 -0
- package/runtime/view-action-affinity.js +211 -0
- package/runtime/web-search-tools.d.ts +31 -0
- package/runtime/web-search-tools.d.ts.map +1 -0
- package/runtime/web-search-tools.js +170 -0
- package/security/access.d.ts.map +1 -0
- package/security/access.js +56 -0
- package/security/audit-log.d.ts.map +1 -0
- package/security/audit-log.js +165 -0
- package/security/index.d.ts.map +1 -0
- package/security/mcp-server-config.d.ts +6 -0
- package/security/mcp-server-config.d.ts.map +1 -0
- package/security/mcp-server-config.js +358 -0
- package/security/network-policy.d.ts.map +1 -0
- package/services/agent-export.d.ts +100 -0
- package/services/agent-export.d.ts.map +1 -0
- package/services/agent-export.js +767 -0
- package/services/app-manager-agents-list-guard.d.ts.map +1 -0
- package/services/app-package-modules.d.ts +26 -0
- package/services/app-package-modules.d.ts.map +1 -0
- package/services/app-package-modules.js +451 -0
- package/services/app-session-gate.d.ts.map +1 -0
- package/services/app-session-gate.js +71 -0
- package/services/capability-broker.d.ts.map +1 -0
- package/services/capability-broker.js +339 -0
- package/services/character-history.d.ts.map +1 -0
- package/services/character-persistence.d.ts.map +1 -0
- package/services/client-chat-sender.d.ts.map +1 -0
- package/services/client-chat-sender.js +88 -0
- package/services/config-plugin-manager.d.ts.map +1 -0
- package/services/connector-setup-service.d.ts.map +1 -0
- package/services/cove-quote-x509.d.ts +143 -0
- package/services/cove-quote-x509.d.ts.map +1 -0
- package/services/cove-quote-x509.js +424 -0
- package/services/cove-quote.d.ts +189 -0
- package/services/cove-quote.d.ts.map +1 -0
- package/services/cove-quote.js +455 -0
- package/services/dstack-tee-provider.d.ts +57 -0
- package/services/dstack-tee-provider.d.ts.map +1 -0
- package/services/dstack-tee-provider.js +180 -0
- package/services/e2b-capability-router.d.ts +139 -0
- package/services/e2b-capability-router.d.ts.map +1 -0
- package/services/e2b-capability-router.js +1239 -0
- package/services/escalation.d.ts.map +1 -0
- package/services/escalation.js +378 -0
- package/services/evm-signing-capability.d.ts +33 -0
- package/services/evm-signing-capability.d.ts.map +1 -0
- package/services/evm-signing-capability.js +52 -0
- package/services/external-bridge-state.d.ts +11 -0
- package/services/external-bridge-state.d.ts.map +1 -0
- package/services/external-bridge-state.js +15 -0
- package/services/hosted-tools.d.ts +77 -0
- package/services/hosted-tools.d.ts.map +1 -0
- package/services/hosted-tools.js +87 -0
- package/services/index.d.ts +32 -0
- package/services/index.d.ts.map +1 -0
- package/services/index.js +40 -0
- package/services/js-runtime-bridge.d.ts.map +1 -0
- package/services/js-runtime-bridge.js +216 -0
- package/services/knowledge-graph/entity-store.d.ts +94 -0
- package/services/knowledge-graph/entity-store.d.ts.map +1 -0
- package/services/knowledge-graph/entity-store.js +509 -0
- package/services/knowledge-graph/index.d.ts +12 -0
- package/services/knowledge-graph/index.d.ts.map +1 -0
- package/services/knowledge-graph/index.js +11 -0
- package/services/knowledge-graph/relationship-store.d.ts +58 -0
- package/services/knowledge-graph/relationship-store.d.ts.map +1 -0
- package/services/knowledge-graph/relationship-store.js +303 -0
- package/services/knowledge-graph/schema.d.ts +2070 -0
- package/services/knowledge-graph/schema.d.ts.map +1 -0
- package/services/knowledge-graph/schema.js +119 -0
- package/services/knowledge-graph/service.d.ts +35 -0
- package/services/knowledge-graph/service.d.ts.map +1 -0
- package/services/knowledge-graph/service.js +42 -0
- package/services/knowledge-graph/sql.d.ts +22 -0
- package/services/knowledge-graph/sql.d.ts.map +1 -0
- package/services/knowledge-graph/sql.js +142 -0
- package/services/mcp-marketplace.d.ts.map +1 -0
- package/services/mcp-marketplace.js +200 -0
- package/services/media-generation.d.ts +10 -0
- package/services/media-generation.d.ts.map +1 -0
- package/services/media-generation.js +102 -0
- package/services/overlay-app-presence.d.ts.map +1 -0
- package/services/owner-name.d.ts.map +1 -0
- package/services/permissions/contracts.d.ts +2 -0
- package/services/permissions/contracts.d.ts.map +1 -0
- package/services/permissions/contracts.js +1 -0
- package/services/permissions/probers/_bridge.d.ts +112 -0
- package/services/permissions/probers/_bridge.d.ts.map +1 -0
- package/services/permissions/probers/_bridge.js +313 -0
- package/services/permissions/probers/accessibility.d.ts.map +1 -0
- package/services/permissions/probers/automation.d.ts +17 -0
- package/services/permissions/probers/automation.d.ts.map +1 -0
- package/services/permissions/probers/automation.js +44 -0
- package/services/permissions/probers/calendar.d.ts +6 -0
- package/services/permissions/probers/calendar.d.ts.map +1 -0
- package/services/permissions/probers/calendar.js +42 -0
- package/services/permissions/probers/camera.d.ts.map +1 -0
- package/services/permissions/probers/contacts.d.ts +9 -0
- package/services/permissions/probers/contacts.d.ts.map +1 -0
- package/services/permissions/probers/contacts.js +44 -0
- package/services/permissions/probers/full-disk.d.ts.map +1 -0
- package/services/permissions/probers/health.d.ts +23 -0
- package/services/permissions/probers/health.d.ts.map +1 -0
- package/services/permissions/probers/health.js +60 -0
- package/services/permissions/probers/index.d.ts.map +1 -0
- package/services/permissions/probers/index.js +44 -0
- package/services/permissions/probers/location.d.ts +13 -0
- package/services/permissions/probers/location.d.ts.map +1 -0
- package/services/permissions/probers/location.js +54 -0
- package/services/permissions/probers/microphone.d.ts.map +1 -0
- package/services/permissions/probers/native-platform.d.ts +3 -0
- package/services/permissions/probers/native-platform.d.ts.map +1 -0
- package/services/permissions/probers/native-platform.js +27 -0
- package/services/permissions/probers/notes.d.ts +18 -0
- package/services/permissions/probers/notes.d.ts.map +1 -0
- package/services/permissions/probers/notes.js +44 -0
- package/services/permissions/probers/notifications.d.ts +18 -0
- package/services/permissions/probers/notifications.d.ts.map +1 -0
- package/services/permissions/probers/notifications.js +53 -0
- package/services/permissions/probers/reminders.d.ts +9 -0
- package/services/permissions/probers/reminders.d.ts.map +1 -0
- package/services/permissions/probers/reminders.js +44 -0
- package/services/permissions/probers/screen-recording.d.ts.map +1 -0
- package/services/permissions/probers/screentime.d.ts +21 -0
- package/services/permissions/probers/screentime.d.ts.map +1 -0
- package/services/permissions/probers/screentime.js +55 -0
- package/services/permissions/probers/shell.d.ts +16 -0
- package/services/permissions/probers/shell.d.ts.map +1 -0
- package/services/permissions/probers/shell.js +28 -0
- package/services/permissions/probers/website-blocking.d.ts.map +1 -0
- package/services/permissions/register-probers.d.ts +13 -0
- package/services/permissions/register-probers.d.ts.map +1 -0
- package/services/permissions/register-probers.js +15 -0
- package/services/permissions-registry.d.ts.map +1 -0
- package/services/permissions-registry.js +209 -0
- package/services/plugin-compiler.d.ts.map +1 -0
- package/services/plugin-compiler.js +168 -0
- package/services/plugin-installer.d.ts +93 -0
- package/services/plugin-installer.d.ts.map +1 -0
- package/services/plugin-installer.js +653 -0
- package/services/plugin-manager-types.d.ts.map +1 -0
- package/services/push/apns-provider.d.ts +58 -0
- package/services/push/apns-provider.d.ts.map +1 -0
- package/services/push/apns-provider.js +186 -0
- package/services/push/fcm-provider.d.ts +49 -0
- package/services/push/fcm-provider.d.ts.map +1 -0
- package/services/push/fcm-provider.js +206 -0
- package/services/push/notification-push-service.d.ts +58 -0
- package/services/push/notification-push-service.d.ts.map +1 -0
- package/services/push/notification-push-service.js +148 -0
- package/services/push/push-token-registry.d.ts +49 -0
- package/services/push/push-token-registry.d.ts.map +1 -0
- package/services/push/push-token-registry.js +91 -0
- package/services/push/push-types.d.ts +41 -0
- package/services/push/push-types.d.ts.map +1 -0
- package/services/push/push-types.js +16 -0
- package/services/registry-client-app-meta.d.ts.map +1 -0
- package/services/registry-client-app-meta.js +153 -0
- package/services/registry-client-endpoints.d.ts.map +1 -0
- package/services/registry-client-endpoints.js +199 -0
- package/services/registry-client-local.d.ts.map +1 -0
- package/services/registry-client-local.js +563 -0
- package/services/registry-client-network.d.ts +27 -0
- package/services/registry-client-network.d.ts.map +1 -0
- package/services/registry-client-network.js +211 -0
- package/services/registry-client-queries.d.ts.map +1 -0
- package/services/registry-client-queries.js +216 -0
- package/services/registry-client-types.d.ts +133 -0
- package/services/registry-client-types.d.ts.map +1 -0
- package/services/registry-client-types.js +1 -0
- package/services/registry-client.d.ts +39 -0
- package/services/registry-client.d.ts.map +1 -0
- package/services/registry-client.js +292 -0
- package/services/relationships-graph.d.ts +13 -0
- package/services/relationships-graph.d.ts.map +1 -0
- package/services/relationships-graph.js +48 -0
- package/services/remote-capability-cloud-sandbox.d.ts +45 -0
- package/services/remote-capability-cloud-sandbox.d.ts.map +1 -0
- package/services/remote-capability-cloud-sandbox.js +253 -0
- package/services/remote-capability-endpoint-conformance.d.ts +60 -0
- package/services/remote-capability-endpoint-conformance.d.ts.map +1 -0
- package/services/remote-capability-endpoint-conformance.js +819 -0
- package/services/remote-capability-endpoint-provider.d.ts +54 -0
- package/services/remote-capability-endpoint-provider.d.ts.map +1 -0
- package/services/remote-capability-endpoint-provider.js +255 -0
- package/services/remote-capability-live-report.d.ts +19 -0
- package/services/remote-capability-live-report.d.ts.map +1 -0
- package/services/remote-capability-live-report.js +147 -0
- package/services/remote-capability-router.d.ts +49 -0
- package/services/remote-capability-router.d.ts.map +1 -0
- package/services/remote-capability-router.js +784 -0
- package/services/remote-capability-url-endpoint-providers.d.ts +17 -0
- package/services/remote-capability-url-endpoint-providers.d.ts.map +1 -0
- package/services/remote-capability-url-endpoint-providers.js +69 -0
- package/services/remote-plugin-adapter.d.ts +42 -0
- package/services/remote-plugin-adapter.d.ts.map +1 -0
- package/services/remote-plugin-adapter.js +1731 -0
- package/services/remote-plugin-bridge.d.ts +81 -0
- package/services/remote-plugin-bridge.d.ts.map +1 -0
- package/services/remote-plugin-bridge.js +598 -0
- package/services/remote-signing-service.d.ts +110 -0
- package/services/remote-signing-service.d.ts.map +1 -0
- package/services/remote-signing-service.js +264 -0
- package/services/research-task-executor.d.ts.map +1 -0
- package/services/research-task-executor.js +133 -0
- package/services/sandbox-engine.d.ts.map +1 -0
- package/services/sandbox-manager.d.ts +132 -0
- package/services/sandbox-manager.d.ts.map +1 -0
- package/services/sandbox-manager.js +440 -0
- package/services/self-updater.d.ts +38 -0
- package/services/self-updater.d.ts.map +1 -0
- package/services/self-updater.js +248 -0
- package/services/send-handler-availability.d.ts.map +1 -0
- package/services/send-handler-availability.js +23 -0
- package/services/shell-execution-router.d.ts +69 -0
- package/services/shell-execution-router.d.ts.map +1 -0
- package/services/shell-execution-router.js +329 -0
- package/services/signing-policy.d.ts +46 -0
- package/services/signing-policy.d.ts.map +1 -0
- package/services/task-executor.d.ts.map +1 -0
- package/services/tee-boot-gate-state.d.ts +29 -0
- package/services/tee-boot-gate-state.d.ts.map +1 -0
- package/services/tee-boot-gate-state.js +38 -0
- package/services/tee-boot-gate.d.ts +45 -0
- package/services/tee-boot-gate.d.ts.map +1 -0
- package/services/tee-boot-gate.js +80 -0
- package/services/tee-confidential-inference.d.ts +177 -0
- package/services/tee-confidential-inference.d.ts.map +1 -0
- package/services/tee-confidential-inference.js +254 -0
- package/services/tee-evidence.d.ts +46 -0
- package/services/tee-evidence.d.ts.map +1 -0
- package/services/tee-evidence.js +149 -0
- package/services/tee-key-release.d.ts +100 -0
- package/services/tee-key-release.d.ts.map +1 -0
- package/services/tee-key-release.js +301 -0
- package/services/tee-model-key-boot.d.ts +82 -0
- package/services/tee-model-key-boot.d.ts.map +1 -0
- package/services/tee-model-key-boot.js +99 -0
- package/services/tee-policy.d.ts +31 -0
- package/services/tee-policy.d.ts.map +1 -0
- package/services/tee-policy.js +233 -0
- package/services/tee-production-profile.d.ts +35 -0
- package/services/tee-production-profile.d.ts.map +1 -0
- package/services/tee-production-profile.js +64 -0
- package/services/tee-release-policy.d.ts +18 -0
- package/services/tee-release-policy.d.ts.map +1 -0
- package/services/tee-release-policy.js +53 -0
- package/services/tee-revocation.d.ts +60 -0
- package/services/tee-revocation.d.ts.map +1 -0
- package/services/tee-revocation.js +150 -0
- package/services/tee-runtime-config.d.ts +9 -0
- package/services/tee-runtime-config.d.ts.map +1 -0
- package/services/tee-runtime-config.js +109 -0
- package/services/tee-sealed-volume.d.ts +114 -0
- package/services/tee-sealed-volume.d.ts.map +1 -0
- package/services/tee-sealed-volume.js +161 -0
- package/services/tee-signer-backend.d.ts +18 -0
- package/services/tee-signer-backend.d.ts.map +1 -0
- package/services/tee-signer-backend.js +26 -0
- package/services/update-checker.d.ts.map +1 -0
- package/services/vault-signer-backend.d.ts +32 -0
- package/services/vault-signer-backend.d.ts.map +1 -0
- package/services/vault-signer-backend.js +57 -0
- package/services/version-compat.d.ts.map +1 -0
- package/services/version-compat.js +212 -0
- package/services/vfs-builtin-shell.d.ts +17 -0
- package/services/vfs-builtin-shell.d.ts.map +1 -0
- package/services/vfs-builtin-shell.js +375 -0
- package/services/vfs-git.d.ts +18 -0
- package/services/vfs-git.d.ts.map +1 -0
- package/services/vfs-git.js +315 -0
- package/services/virtual-filesystem.d.ts +100 -0
- package/services/virtual-filesystem.d.ts.map +1 -0
- package/services/virtual-filesystem.js +482 -0
- package/shared/conversation-format.d.ts.map +1 -0
- package/shared/conversation-format.js +69 -0
- package/shared/ui-catalog-prompt.d.ts.map +1 -0
- package/shared/workspace-resolution.d.ts.map +1 -0
- package/shared/workspace-resolution.js +82 -0
- package/test-support/index.d.ts.map +1 -0
- package/test-support/process-helpers.d.ts.map +1 -0
- package/test-support/route-test-helpers.d.ts.map +1 -0
- package/test-support/test-helpers.d.ts.map +1 -0
- package/test-utils/sqlite-compat.d.ts.map +1 -0
- package/test-utils/sqlite-compat.js +214 -0
- package/triggers/runtime.d.ts.map +1 -0
- package/triggers/runtime.js +482 -0
- package/triggers/scheduling.d.ts +78 -0
- package/triggers/scheduling.d.ts.map +1 -0
- package/triggers/scheduling.js +420 -0
- package/triggers/types.d.ts +30 -0
- package/triggers/types.d.ts.map +1 -0
- package/tui/agent-terminal-tui.d.ts +14 -0
- package/tui/agent-terminal-tui.d.ts.map +1 -0
- package/tui/agent-terminal-tui.js +416 -0
- package/tui/slash-commands.d.ts +107 -0
- package/tui/slash-commands.d.ts.map +1 -0
- package/tui/slash-commands.js +108 -0
- package/tui/tui-enabled.d.ts +8 -0
- package/tui/tui-enabled.d.ts.map +1 -0
- package/tui/tui-enabled.js +17 -0
- package/types/agent-skills.d.ts.map +1 -0
- package/types/config-like.d.ts.map +1 -0
- package/types/index.d.ts.map +1 -0
- package/types/trajectory.d.ts +21 -0
- package/types/trajectory.d.ts.map +1 -0
- package/utils/atomic-json.d.ts.map +1 -0
- package/utils/terminal-command.d.ts +10 -0
- package/utils/terminal-command.d.ts.map +1 -0
- package/utils/terminal-command.js +19 -0
- package/version-resolver.d.ts.map +1 -0
- package/packages/agent/src/actions/connector-resolver.d.ts.map +0 -1
- package/packages/agent/src/actions/connector-resolver.js +0 -253
- package/packages/agent/src/actions/contact.d.ts.map +0 -1
- package/packages/agent/src/actions/contact.js +0 -1698
- package/packages/agent/src/actions/context-signal-lexicon.d.ts.map +0 -1
- package/packages/agent/src/actions/context-signal.d.ts.map +0 -1
- package/packages/agent/src/actions/context-signal.js +0 -153
- package/packages/agent/src/actions/database.d.ts.map +0 -1
- package/packages/agent/src/actions/database.js +0 -671
- package/packages/agent/src/actions/extract-page.d.ts +0 -3
- package/packages/agent/src/actions/extract-page.d.ts.map +0 -1
- package/packages/agent/src/actions/extract-page.js +0 -153
- package/packages/agent/src/actions/extract-params.d.ts +0 -87
- package/packages/agent/src/actions/extract-params.d.ts.map +0 -1
- package/packages/agent/src/actions/extract-params.js +0 -187
- package/packages/agent/src/actions/grounded-action-reply.d.ts.map +0 -1
- package/packages/agent/src/actions/grounded-action-reply.js +0 -287
- package/packages/agent/src/actions/index.d.ts +0 -22
- package/packages/agent/src/actions/index.d.ts.map +0 -1
- package/packages/agent/src/actions/index.js +0 -21
- package/packages/agent/src/actions/logs.d.ts.map +0 -1
- package/packages/agent/src/actions/media.d.ts +0 -9
- package/packages/agent/src/actions/media.d.ts.map +0 -1
- package/packages/agent/src/actions/media.js +0 -135
- package/packages/agent/src/actions/memories.d.ts +0 -9
- package/packages/agent/src/actions/memories.d.ts.map +0 -1
- package/packages/agent/src/actions/memories.js +0 -369
- package/packages/agent/src/actions/page-action-groups.d.ts +0 -17
- package/packages/agent/src/actions/page-action-groups.d.ts.map +0 -1
- package/packages/agent/src/actions/page-action-groups.js +0 -413
- package/packages/agent/src/actions/plugin.d.ts +0 -32
- package/packages/agent/src/actions/plugin.d.ts.map +0 -1
- package/packages/agent/src/actions/plugin.js +0 -780
- package/packages/agent/src/actions/recent-conversation-texts.d.ts.map +0 -1
- package/packages/agent/src/actions/recent-conversation-texts.js +0 -76
- package/packages/agent/src/actions/runtime.d.ts.map +0 -1
- package/packages/agent/src/actions/runtime.js +0 -517
- package/packages/agent/src/actions/settings-actions.d.ts +0 -19
- package/packages/agent/src/actions/settings-actions.d.ts.map +0 -1
- package/packages/agent/src/actions/settings-actions.js +0 -478
- package/packages/agent/src/actions/skill-command.d.ts +0 -20
- package/packages/agent/src/actions/skill-command.d.ts.map +0 -1
- package/packages/agent/src/actions/skill-command.js +0 -170
- package/packages/agent/src/actions/stream-control.d.ts +0 -20
- package/packages/agent/src/actions/stream-control.d.ts.map +0 -1
- package/packages/agent/src/actions/stream-control.js +0 -166
- package/packages/agent/src/actions/terminal.d.ts.map +0 -1
- package/packages/agent/src/actions/terminal.js +0 -305
- package/packages/agent/src/actions/trajectories.d.ts +0 -8
- package/packages/agent/src/actions/trajectories.d.ts.map +0 -1
- package/packages/agent/src/actions/trajectories.js +0 -135
- package/packages/agent/src/actions/trigger.d.ts.map +0 -1
- package/packages/agent/src/actions/trigger.js +0 -514
- package/packages/agent/src/api/accounts-routes.d.ts +0 -38
- package/packages/agent/src/api/accounts-routes.d.ts.map +0 -1
- package/packages/agent/src/api/accounts-routes.js +0 -927
- package/packages/agent/src/api/agent-admin-routes.d.ts +0 -39
- package/packages/agent/src/api/agent-admin-routes.d.ts.map +0 -1
- package/packages/agent/src/api/agent-admin-routes.js +0 -190
- package/packages/agent/src/api/agent-lifecycle-routes.d.ts.map +0 -1
- package/packages/agent/src/api/agent-lifecycle-routes.js +0 -101
- package/packages/agent/src/api/agent-model.d.ts.map +0 -1
- package/packages/agent/src/api/agent-model.js +0 -170
- package/packages/agent/src/api/agent-status-routes.d.ts.map +0 -1
- package/packages/agent/src/api/agent-status-routes.js +0 -264
- package/packages/agent/src/api/agent-transfer-routes.d.ts.map +0 -1
- package/packages/agent/src/api/agent-transfer-routes.js +0 -124
- package/packages/agent/src/api/app-package-routes.d.ts +0 -7
- package/packages/agent/src/api/app-package-routes.d.ts.map +0 -1
- package/packages/agent/src/api/app-package-routes.js +0 -59
- package/packages/agent/src/api/apps-routes.d.ts +0 -32
- package/packages/agent/src/api/apps-routes.d.ts.map +0 -1
- package/packages/agent/src/api/apps-routes.js +0 -998
- package/packages/agent/src/api/auth-routes.d.ts.map +0 -1
- package/packages/agent/src/api/auth-routes.js +0 -119
- package/packages/agent/src/api/avatar-routes.d.ts.map +0 -1
- package/packages/agent/src/api/avatar-routes.js +0 -205
- package/packages/agent/src/api/binance-skill-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/binance-skill-helpers.js +0 -745
- package/packages/agent/src/api/bug-report-routes.d.ts +0 -10
- package/packages/agent/src/api/bug-report-routes.d.ts.map +0 -1
- package/packages/agent/src/api/bug-report-routes.js +0 -271
- package/packages/agent/src/api/build-variant-routes.d.ts +0 -27
- package/packages/agent/src/api/build-variant-routes.d.ts.map +0 -1
- package/packages/agent/src/api/build-variant-routes.js +0 -27
- package/packages/agent/src/api/character-routes.d.ts.map +0 -1
- package/packages/agent/src/api/character-routes.js +0 -377
- package/packages/agent/src/api/chat-augmentation.d.ts +0 -70
- package/packages/agent/src/api/chat-augmentation.d.ts.map +0 -1
- package/packages/agent/src/api/chat-augmentation.js +0 -464
- package/packages/agent/src/api/chat-routes.d.ts +0 -124
- package/packages/agent/src/api/chat-routes.d.ts.map +0 -1
- package/packages/agent/src/api/chat-routes.js +0 -1841
- package/packages/agent/src/api/chat-text-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/client-chat-admin.d.ts.map +0 -1
- package/packages/agent/src/api/cloud-route-registry.d.ts +0 -22
- package/packages/agent/src/api/cloud-route-registry.d.ts.map +0 -1
- package/packages/agent/src/api/cloud-route-registry.js +0 -20
- package/packages/agent/src/api/compat-utils.d.ts.map +0 -1
- package/packages/agent/src/api/config-env.d.ts.map +0 -1
- package/packages/agent/src/api/config-env.js +0 -284
- package/packages/agent/src/api/config-routes.d.ts.map +0 -1
- package/packages/agent/src/api/config-routes.js +0 -429
- package/packages/agent/src/api/connector-account-routes.d.ts.map +0 -1
- package/packages/agent/src/api/connector-account-routes.js +0 -740
- package/packages/agent/src/api/connector-health.d.ts.map +0 -1
- package/packages/agent/src/api/connector-oauth-callback-auth.d.ts.map +0 -1
- package/packages/agent/src/api/connector-routes.d.ts.map +0 -1
- package/packages/agent/src/api/connector-routes.js +0 -184
- package/packages/agent/src/api/conversation-metadata.d.ts.map +0 -1
- package/packages/agent/src/api/conversation-metadata.js +0 -107
- package/packages/agent/src/api/conversation-routes.d.ts +0 -43
- package/packages/agent/src/api/conversation-routes.d.ts.map +0 -1
- package/packages/agent/src/api/conversation-routes.js +0 -1208
- package/packages/agent/src/api/coordinator-wiring.d.ts.map +0 -1
- package/packages/agent/src/api/coordinator-wiring.js +0 -108
- package/packages/agent/src/api/credit-detection.d.ts.map +0 -1
- package/packages/agent/src/api/credit-detection.js +0 -47
- package/packages/agent/src/api/curated-skills-routes.d.ts +0 -22
- package/packages/agent/src/api/curated-skills-routes.d.ts.map +0 -1
- package/packages/agent/src/api/curated-skills-routes.js +0 -295
- package/packages/agent/src/api/database.d.ts +0 -35
- package/packages/agent/src/api/database.d.ts.map +0 -1
- package/packages/agent/src/api/database.js +0 -1140
- package/packages/agent/src/api/diagnostics-routes.d.ts +0 -59
- package/packages/agent/src/api/diagnostics-routes.d.ts.map +0 -1
- package/packages/agent/src/api/diagnostics-routes.js +0 -365
- package/packages/agent/src/api/documents-routes.d.ts +0 -9
- package/packages/agent/src/api/documents-routes.d.ts.map +0 -1
- package/packages/agent/src/api/documents-routes.js +0 -26
- package/packages/agent/src/api/documents-service-loader.d.ts.map +0 -1
- package/packages/agent/src/api/early-logs.d.ts +0 -29
- package/packages/agent/src/api/early-logs.d.ts.map +0 -1
- package/packages/agent/src/api/health-routes.d.ts +0 -46
- package/packages/agent/src/api/health-routes.d.ts.map +0 -1
- package/packages/agent/src/api/health-routes.js +0 -450
- package/packages/agent/src/api/inbox-routes.d.ts.map +0 -1
- package/packages/agent/src/api/inbox-routes.js +0 -1579
- package/packages/agent/src/api/index.d.ts +0 -46
- package/packages/agent/src/api/index.d.ts.map +0 -1
- package/packages/agent/src/api/index.js +0 -49
- package/packages/agent/src/api/memory-bounds.d.ts.map +0 -1
- package/packages/agent/src/api/memory-routes.d.ts.map +0 -1
- package/packages/agent/src/api/memory-routes.js +0 -474
- package/packages/agent/src/api/misc-routes.d.ts.map +0 -1
- package/packages/agent/src/api/misc-routes.js +0 -569
- package/packages/agent/src/api/mobile-optional-routes.d.ts.map +0 -1
- package/packages/agent/src/api/mobile-optional-routes.js +0 -91
- package/packages/agent/src/api/model-provider-helpers.d.ts +0 -68
- package/packages/agent/src/api/model-provider-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/model-provider-helpers.js +0 -623
- package/packages/agent/src/api/models-routes.d.ts.map +0 -1
- package/packages/agent/src/api/music-player-route-fallback.d.ts.map +0 -1
- package/packages/agent/src/api/nfa-routes.d.ts +0 -6
- package/packages/agent/src/api/nfa-routes.d.ts.map +0 -1
- package/packages/agent/src/api/nfa-routes.js +0 -125
- package/packages/agent/src/api/onboarding-routes.d.ts +0 -50
- package/packages/agent/src/api/onboarding-routes.d.ts.map +0 -1
- package/packages/agent/src/api/onboarding-routes.js +0 -588
- package/packages/agent/src/api/owner-contact-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/parse-action-block.d.ts +0 -53
- package/packages/agent/src/api/parse-action-block.d.ts.map +0 -1
- package/packages/agent/src/api/permission-request-prompt.d.ts +0 -19
- package/packages/agent/src/api/permission-request-prompt.d.ts.map +0 -1
- package/packages/agent/src/api/permission-request-prompt.js +0 -53
- package/packages/agent/src/api/permissions-routes-extra.d.ts +0 -30
- package/packages/agent/src/api/permissions-routes-extra.d.ts.map +0 -1
- package/packages/agent/src/api/permissions-routes.d.ts.map +0 -1
- package/packages/agent/src/api/permissions-routes.js +0 -352
- package/packages/agent/src/api/plugin-discovery-helpers.d.ts +0 -147
- package/packages/agent/src/api/plugin-discovery-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/plugin-discovery-helpers.js +0 -1118
- package/packages/agent/src/api/plugin-routes.d.ts +0 -144
- package/packages/agent/src/api/plugin-routes.d.ts.map +0 -1
- package/packages/agent/src/api/plugin-routes.js +0 -1285
- package/packages/agent/src/api/plugin-runtime-apply.d.ts.map +0 -1
- package/packages/agent/src/api/plugin-runtime-apply.js +0 -217
- package/packages/agent/src/api/plugin-validation.d.ts.map +0 -1
- package/packages/agent/src/api/provider-switch-config.d.ts +0 -62
- package/packages/agent/src/api/provider-switch-config.d.ts.map +0 -1
- package/packages/agent/src/api/provider-switch-config.js +0 -719
- package/packages/agent/src/api/provider-switch-routes.d.ts.map +0 -1
- package/packages/agent/src/api/provider-switch-routes.js +0 -142
- package/packages/agent/src/api/rate-limiter.d.ts.map +0 -1
- package/packages/agent/src/api/registry-routes.d.ts.map +0 -1
- package/packages/agent/src/api/registry-routes.js +0 -98
- package/packages/agent/src/api/registry-service.d.ts.map +0 -1
- package/packages/agent/src/api/registry-service.js +0 -190
- package/packages/agent/src/api/relationships-routes.d.ts.map +0 -1
- package/packages/agent/src/api/relationships-routes.js +0 -287
- package/packages/agent/src/api/runtime-plugin-routes.d.ts.map +0 -1
- package/packages/agent/src/api/runtime-plugin-routes.js +0 -203
- package/packages/agent/src/api/server-auth.d.ts.map +0 -1
- package/packages/agent/src/api/server-auth.js +0 -507
- package/packages/agent/src/api/server-autonomy-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers-auth.d.ts +0 -41
- package/packages/agent/src/api/server-helpers-auth.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers-auth.js +0 -627
- package/packages/agent/src/api/server-helpers-config.d.ts +0 -37
- package/packages/agent/src/api/server-helpers-config.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers-config.js +0 -293
- package/packages/agent/src/api/server-helpers-fetch.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers-mcp.d.ts +0 -12
- package/packages/agent/src/api/server-helpers-mcp.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers-mcp.js +0 -315
- package/packages/agent/src/api/server-helpers-plugin.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers-swarm.d.ts +0 -101
- package/packages/agent/src/api/server-helpers-swarm.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers-swarm.js +0 -646
- package/packages/agent/src/api/server-helpers-wallet.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers.d.ts +0 -96
- package/packages/agent/src/api/server-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/server-helpers.js +0 -595
- package/packages/agent/src/api/server-route-dispatch.d.ts.map +0 -1
- package/packages/agent/src/api/server-route-dispatch.js +0 -103
- package/packages/agent/src/api/server-startup.d.ts +0 -16
- package/packages/agent/src/api/server-startup.d.ts.map +0 -1
- package/packages/agent/src/api/server-startup.js +0 -14
- package/packages/agent/src/api/server-types.d.ts +0 -232
- package/packages/agent/src/api/server-types.d.ts.map +0 -1
- package/packages/agent/src/api/server-types.js +0 -6
- package/packages/agent/src/api/server.d.ts +0 -61
- package/packages/agent/src/api/server.d.ts.map +0 -1
- package/packages/agent/src/api/server.js +0 -3215
- package/packages/agent/src/api/skill-discovery-helpers.d.ts +0 -80
- package/packages/agent/src/api/skill-discovery-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/skill-discovery-helpers.js +0 -385
- package/packages/agent/src/api/skills-routes.d.ts +0 -32
- package/packages/agent/src/api/skills-routes.d.ts.map +0 -1
- package/packages/agent/src/api/skills-routes.js +0 -978
- package/packages/agent/src/api/static-file-server.d.ts.map +0 -1
- package/packages/agent/src/api/static-file-server.js +0 -234
- package/packages/agent/src/api/subscription-routes.d.ts.map +0 -1
- package/packages/agent/src/api/subscription-routes.js +0 -261
- package/packages/agent/src/api/task-agent-message-routing.d.ts.map +0 -1
- package/packages/agent/src/api/terminal-execution-routing.d.ts.map +0 -1
- package/packages/agent/src/api/terminal-run-limits.d.ts.map +0 -1
- package/packages/agent/src/api/terminal-run-limits.js +0 -20
- package/packages/agent/src/api/trade-safety.d.ts +0 -35
- package/packages/agent/src/api/trade-safety.d.ts.map +0 -1
- package/packages/agent/src/api/trade-safety.js +0 -62
- package/packages/agent/src/api/training-backend-check.d.ts.map +0 -1
- package/packages/agent/src/api/training-service-like.d.ts.map +0 -1
- package/packages/agent/src/api/travel-provider-relay-routes.d.ts +0 -9
- package/packages/agent/src/api/travel-provider-relay-routes.d.ts.map +0 -1
- package/packages/agent/src/api/travel-provider-relay-routes.js +0 -143
- package/packages/agent/src/api/tx-service.d.ts +0 -53
- package/packages/agent/src/api/tx-service.d.ts.map +0 -1
- package/packages/agent/src/api/tx-service.js +0 -217
- package/packages/agent/src/api/update-routes.d.ts.map +0 -1
- package/packages/agent/src/api/update-routes.js +0 -54
- package/packages/agent/src/api/wallet-capability.d.ts +0 -33
- package/packages/agent/src/api/wallet-capability.d.ts.map +0 -1
- package/packages/agent/src/api/wallet-capability.js +0 -193
- package/packages/agent/src/api/wallet-dex-prices.d.ts.map +0 -1
- package/packages/agent/src/api/wallet-env-sync.d.ts +0 -2
- package/packages/agent/src/api/wallet-env-sync.d.ts.map +0 -1
- package/packages/agent/src/api/wallet-evm-balance.d.ts.map +0 -1
- package/packages/agent/src/api/wallet-routes.d.ts +0 -41
- package/packages/agent/src/api/wallet-routes.d.ts.map +0 -1
- package/packages/agent/src/api/wallet-routes.js +0 -848
- package/packages/agent/src/api/wallet-rpc.d.ts.map +0 -1
- package/packages/agent/src/api/wallet-rpc.js +0 -437
- package/packages/agent/src/api/wallet-trading-profile.d.ts.map +0 -1
- package/packages/agent/src/api/wallet-trading-profile.js +0 -544
- package/packages/agent/src/api/wallet.d.ts.map +0 -1
- package/packages/agent/src/api/wallet.js +0 -780
- package/packages/agent/src/api/workbench-helpers.d.ts.map +0 -1
- package/packages/agent/src/api/workbench-routes.d.ts +0 -43
- package/packages/agent/src/api/workbench-routes.d.ts.map +0 -1
- package/packages/agent/src/api/workbench-routes.js +0 -265
- package/packages/agent/src/api/x-relay-routes.d.ts.map +0 -1
- package/packages/agent/src/api/x-relay-routes.js +0 -134
- package/packages/agent/src/api/zip-utils.d.ts.map +0 -1
- package/packages/agent/src/auth/account-storage.d.ts +0 -48
- package/packages/agent/src/auth/account-storage.d.ts.map +0 -1
- package/packages/agent/src/auth/account-storage.js +0 -229
- package/packages/agent/src/auth/anthropic.d.ts.map +0 -1
- package/packages/agent/src/auth/claude-code-stealth-preload.d.ts +0 -2
- package/packages/agent/src/auth/claude-code-stealth-preload.d.ts.map +0 -1
- package/packages/agent/src/auth/claude-code-stealth-preload.js +0 -2
- package/packages/agent/src/auth/claude-code-stealth.d.ts.map +0 -1
- package/packages/agent/src/auth/claude-code-stealth.js +0 -116
- package/packages/agent/src/auth/credentials.d.ts +0 -100
- package/packages/agent/src/auth/credentials.d.ts.map +0 -1
- package/packages/agent/src/auth/credentials.js +0 -553
- package/packages/agent/src/auth/index.d.ts.map +0 -1
- package/packages/agent/src/auth/oauth-flow.d.ts +0 -106
- package/packages/agent/src/auth/oauth-flow.d.ts.map +0 -1
- package/packages/agent/src/auth/oauth-flow.js +0 -349
- package/packages/agent/src/auth/openai-codex.d.ts.map +0 -1
- package/packages/agent/src/auth/openai-codex.js +0 -76
- package/packages/agent/src/auth/refresh-mutex.d.ts +0 -19
- package/packages/agent/src/auth/refresh-mutex.d.ts.map +0 -1
- package/packages/agent/src/auth/refresh-mutex.js +0 -33
- package/packages/agent/src/auth/types.d.ts +0 -58
- package/packages/agent/src/auth/types.d.ts.map +0 -1
- package/packages/agent/src/auth/types.js +0 -149
- package/packages/agent/src/auth/vendor/pi-oauth/anthropic-login.d.ts.map +0 -1
- package/packages/agent/src/auth/vendor/pi-oauth/anthropic-login.js +0 -113
- package/packages/agent/src/auth/vendor/pi-oauth/openai-codex-login.d.ts +0 -26
- package/packages/agent/src/auth/vendor/pi-oauth/openai-codex-login.d.ts.map +0 -1
- package/packages/agent/src/auth/vendor/pi-oauth/openai-codex-login.js +0 -343
- package/packages/agent/src/auth/vendor/pi-oauth/pkce.d.ts.map +0 -1
- package/packages/agent/src/autonomy/index.d.ts +0 -48
- package/packages/agent/src/autonomy/index.d.ts.map +0 -1
- package/packages/agent/src/autonomy/index.js +0 -344
- package/packages/agent/src/awareness/index.d.ts.map +0 -1
- package/packages/agent/src/awareness/registry.d.ts.map +0 -1
- package/packages/agent/src/bin.d.ts.map +0 -1
- package/packages/agent/src/bin.js +0 -51
- package/packages/agent/src/cli/benchmark.d.ts.map +0 -1
- package/packages/agent/src/cli/benchmark.js +0 -293
- package/packages/agent/src/cli/index.d.ts.map +0 -1
- package/packages/agent/src/cli/index.js +0 -94
- package/packages/agent/src/cli/parse-duration.d.ts +0 -5
- package/packages/agent/src/cli/parse-duration.d.ts.map +0 -1
- package/packages/agent/src/cli/parse-duration.js +0 -27
- package/packages/agent/src/config/character-schema.d.ts.map +0 -1
- package/packages/agent/src/config/config.d.ts.map +0 -1
- package/packages/agent/src/config/config.js +0 -285
- package/packages/agent/src/config/env-vars.d.ts.map +0 -1
- package/packages/agent/src/config/feature-flags.d.ts +0 -17
- package/packages/agent/src/config/feature-flags.d.ts.map +0 -1
- package/packages/agent/src/config/feature-flags.js +0 -37
- package/packages/agent/src/config/includes.d.ts +0 -26
- package/packages/agent/src/config/includes.d.ts.map +0 -1
- package/packages/agent/src/config/includes.js +0 -149
- package/packages/agent/src/config/index.d.ts.map +0 -1
- package/packages/agent/src/config/model-metadata.d.ts.map +0 -1
- package/packages/agent/src/config/model-metadata.js +0 -133
- package/packages/agent/src/config/owner-contacts.d.ts.map +0 -1
- package/packages/agent/src/config/owner-contacts.js +0 -238
- package/packages/agent/src/config/paths.d.ts +0 -17
- package/packages/agent/src/config/paths.d.ts.map +0 -1
- package/packages/agent/src/config/paths.js +0 -65
- package/packages/agent/src/config/plugin-auto-enable.d.ts.map +0 -1
- package/packages/agent/src/config/plugin-widgets.d.ts +0 -29
- package/packages/agent/src/config/plugin-widgets.d.ts.map +0 -1
- package/packages/agent/src/config/plugin-widgets.js +0 -104
- package/packages/agent/src/config/schema.d.ts.map +0 -1
- package/packages/agent/src/config/schema.js +0 -928
- package/packages/agent/src/config/telegram-custom-commands.d.ts.map +0 -1
- package/packages/agent/src/config/types.agent-defaults.d.ts.map +0 -1
- package/packages/agent/src/config/types.agents.d.ts.map +0 -1
- package/packages/agent/src/config/types.d.ts.map +0 -1
- package/packages/agent/src/config/types.eliza.d.ts.map +0 -1
- package/packages/agent/src/config/types.gateway.d.ts +0 -2
- package/packages/agent/src/config/types.gateway.d.ts.map +0 -1
- package/packages/agent/src/config/types.gateway.js +0 -1
- package/packages/agent/src/config/types.hooks.d.ts.map +0 -1
- package/packages/agent/src/config/types.messages.d.ts.map +0 -1
- package/packages/agent/src/config/types.tools.d.ts +0 -2
- package/packages/agent/src/config/types.tools.d.ts.map +0 -1
- package/packages/agent/src/config/types.tools.js +0 -1
- package/packages/agent/src/config/zod-schema.agent-runtime.d.ts +0 -1164
- package/packages/agent/src/config/zod-schema.agent-runtime.d.ts.map +0 -1
- package/packages/agent/src/config/zod-schema.agent-runtime.js +0 -808
- package/packages/agent/src/config/zod-schema.core.d.ts +0 -1279
- package/packages/agent/src/config/zod-schema.core.d.ts.map +0 -1
- package/packages/agent/src/config/zod-schema.core.js +0 -761
- package/packages/agent/src/config/zod-schema.d.ts +0 -3404
- package/packages/agent/src/config/zod-schema.d.ts.map +0 -1
- package/packages/agent/src/config/zod-schema.hooks.d.ts.map +0 -1
- package/packages/agent/src/config/zod-schema.js +0 -846
- package/packages/agent/src/config/zod-schema.providers-core.d.ts +0 -2752
- package/packages/agent/src/config/zod-schema.providers-core.d.ts.map +0 -1
- package/packages/agent/src/config/zod-schema.providers-core.js +0 -969
- package/packages/agent/src/config/zod-schema.session.d.ts +0 -183
- package/packages/agent/src/config/zod-schema.session.d.ts.map +0 -1
- package/packages/agent/src/contracts/awareness.d.ts.map +0 -1
- package/packages/agent/src/contracts/index.d.ts +0 -2
- package/packages/agent/src/contracts/index.d.ts.map +0 -1
- package/packages/agent/src/contracts/index.js +0 -1
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts +0 -177
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts.map +0 -1
- package/packages/agent/src/contracts/onboarding-provider-defaults.js +0 -202
- package/packages/agent/src/diagnostics/index.d.ts +0 -2
- package/packages/agent/src/diagnostics/index.d.ts.map +0 -1
- package/packages/agent/src/diagnostics/index.js +0 -1
- package/packages/agent/src/diagnostics/integration-observability.d.ts.map +0 -1
- package/packages/agent/src/hooks/discovery.d.ts +0 -13
- package/packages/agent/src/hooks/discovery.d.ts.map +0 -1
- package/packages/agent/src/hooks/discovery.js +0 -191
- package/packages/agent/src/hooks/eligibility.d.ts.map +0 -1
- package/packages/agent/src/hooks/index.d.ts.map +0 -1
- package/packages/agent/src/hooks/loader.d.ts.map +0 -1
- package/packages/agent/src/hooks/loader.js +0 -214
- package/packages/agent/src/hooks/registry.d.ts.map +0 -1
- package/packages/agent/src/hooks/types.d.ts.map +0 -1
- package/packages/agent/src/index.d.ts +0 -73
- package/packages/agent/src/index.d.ts.map +0 -1
- package/packages/agent/src/index.js +0 -104
- package/packages/agent/src/providers/admin-panel.d.ts.map +0 -1
- package/packages/agent/src/providers/admin-trust.d.ts.map +0 -1
- package/packages/agent/src/providers/automation-terminal-bridge.d.ts.map +0 -1
- package/packages/agent/src/providers/automation-terminal-bridge.js +0 -77
- package/packages/agent/src/providers/conversation-proximity.d.ts.map +0 -1
- package/packages/agent/src/providers/escalation-trigger.d.ts.map +0 -1
- package/packages/agent/src/providers/index.d.ts +0 -19
- package/packages/agent/src/providers/index.d.ts.map +0 -1
- package/packages/agent/src/providers/index.js +0 -18
- package/packages/agent/src/providers/local-models.d.ts +0 -118
- package/packages/agent/src/providers/local-models.d.ts.map +0 -1
- package/packages/agent/src/providers/local-models.js +0 -418
- package/packages/agent/src/providers/media-provider.d.ts +0 -233
- package/packages/agent/src/providers/media-provider.d.ts.map +0 -1
- package/packages/agent/src/providers/media-provider.js +0 -1474
- package/packages/agent/src/providers/page-scoped-context.d.ts.map +0 -1
- package/packages/agent/src/providers/page-scoped-context.js +0 -551
- package/packages/agent/src/providers/pending-permissions-provider.d.ts +0 -19
- package/packages/agent/src/providers/pending-permissions-provider.d.ts.map +0 -1
- package/packages/agent/src/providers/pending-permissions-provider.js +0 -104
- package/packages/agent/src/providers/recent-conversations.d.ts.map +0 -1
- package/packages/agent/src/providers/recent-conversations.js +0 -100
- package/packages/agent/src/providers/relevant-conversations.d.ts.map +0 -1
- package/packages/agent/src/providers/relevant-conversations.js +0 -99
- package/packages/agent/src/providers/role-backfill.d.ts +0 -18
- package/packages/agent/src/providers/role-backfill.d.ts.map +0 -1
- package/packages/agent/src/providers/role-backfill.js +0 -86
- package/packages/agent/src/providers/rolodex.d.ts.map +0 -1
- package/packages/agent/src/providers/rolodex.js +0 -83
- package/packages/agent/src/providers/self-status.d.ts +0 -4
- package/packages/agent/src/providers/self-status.d.ts.map +0 -1
- package/packages/agent/src/providers/self-status.js +0 -22
- package/packages/agent/src/providers/session-bridge.d.ts.map +0 -1
- package/packages/agent/src/providers/session-bridge.js +0 -90
- package/packages/agent/src/providers/session-utils.d.ts +0 -20
- package/packages/agent/src/providers/session-utils.d.ts.map +0 -1
- package/packages/agent/src/providers/session-utils.js +0 -32
- package/packages/agent/src/providers/simple-mode.d.ts +0 -4
- package/packages/agent/src/providers/simple-mode.d.ts.map +0 -1
- package/packages/agent/src/providers/simple-mode.js +0 -49
- package/packages/agent/src/providers/skill-provider.d.ts.map +0 -1
- package/packages/agent/src/providers/tasks.d.ts.map +0 -1
- package/packages/agent/src/providers/ui-catalog.d.ts.map +0 -1
- package/packages/agent/src/providers/ui-catalog.js +0 -100
- package/packages/agent/src/providers/user-name.d.ts.map +0 -1
- package/packages/agent/src/providers/workspace-provider.d.ts.map +0 -1
- package/packages/agent/src/providers/workspace-provider.js +0 -183
- package/packages/agent/src/providers/workspace.d.ts +0 -53
- package/packages/agent/src/providers/workspace.d.ts.map +0 -1
- package/packages/agent/src/providers/workspace.js +0 -418
- package/packages/agent/src/runtime/advanced-capabilities-config.d.ts.map +0 -1
- package/packages/agent/src/runtime/agent-event-service.d.ts.map +0 -1
- package/packages/agent/src/runtime/agent-wallets.d.ts +0 -138
- package/packages/agent/src/runtime/agent-wallets.d.ts.map +0 -1
- package/packages/agent/src/runtime/agent-wallets.js +0 -308
- package/packages/agent/src/runtime/analysis-mode-flag.d.ts +0 -93
- package/packages/agent/src/runtime/analysis-mode-flag.d.ts.map +0 -1
- package/packages/agent/src/runtime/analysis-mode-flag.js +0 -131
- package/packages/agent/src/runtime/android-app-plugins.d.ts +0 -13
- package/packages/agent/src/runtime/android-app-plugins.d.ts.map +0 -1
- package/packages/agent/src/runtime/android-app-plugins.js +0 -48
- package/packages/agent/src/runtime/aosp-dflash-adapter.d.ts +0 -99
- package/packages/agent/src/runtime/aosp-dflash-adapter.d.ts.map +0 -1
- package/packages/agent/src/runtime/aosp-dflash-adapter.js +0 -332
- package/packages/agent/src/runtime/build-character-config.d.ts.map +0 -1
- package/packages/agent/src/runtime/build-character-config.js +0 -176
- package/packages/agent/src/runtime/conversation-compactor-runtime.d.ts +0 -141
- package/packages/agent/src/runtime/conversation-compactor-runtime.d.ts.map +0 -1
- package/packages/agent/src/runtime/conversation-compactor-runtime.js +0 -460
- package/packages/agent/src/runtime/conversation-compactor.d.ts +0 -38
- package/packages/agent/src/runtime/conversation-compactor.d.ts.map +0 -1
- package/packages/agent/src/runtime/conversation-compactor.js +0 -1121
- package/packages/agent/src/runtime/conversation-compactor.types.d.ts +0 -102
- package/packages/agent/src/runtime/conversation-compactor.types.d.ts.map +0 -1
- package/packages/agent/src/runtime/core-plugins.d.ts +0 -64
- package/packages/agent/src/runtime/core-plugins.d.ts.map +0 -1
- package/packages/agent/src/runtime/core-plugins.js +0 -120
- package/packages/agent/src/runtime/custom-actions.d.ts +0 -43
- package/packages/agent/src/runtime/custom-actions.d.ts.map +0 -1
- package/packages/agent/src/runtime/custom-actions.js +0 -533
- package/packages/agent/src/runtime/default-documents.d.ts +0 -21
- package/packages/agent/src/runtime/default-documents.d.ts.map +0 -1
- package/packages/agent/src/runtime/default-documents.js +0 -283
- package/packages/agent/src/runtime/eliza-plugin.d.ts.map +0 -1
- package/packages/agent/src/runtime/eliza-plugin.js +0 -180
- package/packages/agent/src/runtime/eliza.d.ts +0 -109
- package/packages/agent/src/runtime/eliza.d.ts.map +0 -1
- package/packages/agent/src/runtime/eliza.js +0 -3372
- package/packages/agent/src/runtime/embedding-presets.d.ts +0 -19
- package/packages/agent/src/runtime/embedding-presets.d.ts.map +0 -1
- package/packages/agent/src/runtime/embedding-presets.js +0 -60
- package/packages/agent/src/runtime/first-time-setup.d.ts +0 -47
- package/packages/agent/src/runtime/first-time-setup.d.ts.map +0 -1
- package/packages/agent/src/runtime/first-time-setup.js +0 -704
- package/packages/agent/src/runtime/index.d.ts +0 -20
- package/packages/agent/src/runtime/index.d.ts.map +0 -1
- package/packages/agent/src/runtime/index.js +0 -19
- package/packages/agent/src/runtime/load-plugin-from-vfs.d.ts +0 -54
- package/packages/agent/src/runtime/load-plugin-from-vfs.d.ts.map +0 -1
- package/packages/agent/src/runtime/load-plugin-from-vfs.js +0 -86
- package/packages/agent/src/runtime/local-execution-mode.d.ts +0 -11
- package/packages/agent/src/runtime/local-execution-mode.d.ts.map +0 -1
- package/packages/agent/src/runtime/model-resolution.d.ts.map +0 -1
- package/packages/agent/src/runtime/model-resolution.js +0 -55
- package/packages/agent/src/runtime/native-runtime-features.d.ts.map +0 -1
- package/packages/agent/src/runtime/onboarding-names.d.ts +0 -11
- package/packages/agent/src/runtime/onboarding-names.d.ts.map +0 -1
- package/packages/agent/src/runtime/onboarding-names.js +0 -81
- package/packages/agent/src/runtime/operations/classifier.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/classifier.js +0 -72
- package/packages/agent/src/runtime/operations/cold-strategy.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/health-checks.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/health.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/index.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/manager.d.ts +0 -70
- package/packages/agent/src/runtime/operations/manager.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/manager.js +0 -202
- package/packages/agent/src/runtime/operations/reload-hot.d.ts +0 -43
- package/packages/agent/src/runtime/operations/reload-hot.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/reload-hot.js +0 -181
- package/packages/agent/src/runtime/operations/repository.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/types.d.ts.map +0 -1
- package/packages/agent/src/runtime/operations/vault-bridge.d.ts +0 -81
- package/packages/agent/src/runtime/operations/vault-bridge.d.ts.map +0 -1
- package/packages/agent/src/runtime/owner-entity.d.ts.map +0 -1
- package/packages/agent/src/runtime/owner-entity.js +0 -30
- package/packages/agent/src/runtime/pglite-error-compat.d.ts +0 -28
- package/packages/agent/src/runtime/pglite-error-compat.d.ts.map +0 -1
- package/packages/agent/src/runtime/pglite-error-compat.js +0 -54
- package/packages/agent/src/runtime/plugin-collector.d.ts.map +0 -1
- package/packages/agent/src/runtime/plugin-collector.js +0 -503
- package/packages/agent/src/runtime/plugin-lifecycle.d.ts +0 -45
- package/packages/agent/src/runtime/plugin-lifecycle.d.ts.map +0 -1
- package/packages/agent/src/runtime/plugin-lifecycle.js +0 -602
- package/packages/agent/src/runtime/plugin-resolver.d.ts +0 -46
- package/packages/agent/src/runtime/plugin-resolver.d.ts.map +0 -1
- package/packages/agent/src/runtime/plugin-resolver.js +0 -1375
- package/packages/agent/src/runtime/plugin-role-gating.d.ts +0 -24
- package/packages/agent/src/runtime/plugin-role-gating.d.ts.map +0 -1
- package/packages/agent/src/runtime/plugin-role-gating.js +0 -106
- package/packages/agent/src/runtime/plugin-types.d.ts +0 -64
- package/packages/agent/src/runtime/plugin-types.d.ts.map +0 -1
- package/packages/agent/src/runtime/plugin-types.js +0 -306
- package/packages/agent/src/runtime/prompt-compaction.d.ts +0 -98
- package/packages/agent/src/runtime/prompt-compaction.d.ts.map +0 -1
- package/packages/agent/src/runtime/prompt-compaction.js +0 -362
- package/packages/agent/src/runtime/prompt-optimization.d.ts +0 -47
- package/packages/agent/src/runtime/prompt-optimization.d.ts.map +0 -1
- package/packages/agent/src/runtime/prompt-optimization.js +0 -1123
- package/packages/agent/src/runtime/release-plugin-policy.d.ts.map +0 -1
- package/packages/agent/src/runtime/release-plugin-policy.js +0 -85
- package/packages/agent/src/runtime/restart.d.ts +0 -9
- package/packages/agent/src/runtime/restart.d.ts.map +0 -1
- package/packages/agent/src/runtime/restart.js +0 -8
- package/packages/agent/src/runtime/roles/src/index.d.ts.map +0 -1
- package/packages/agent/src/runtime/roles/src/index.js +0 -255
- package/packages/agent/src/runtime/roles/src/provider.d.ts.map +0 -1
- package/packages/agent/src/runtime/roles/src/types.d.ts.map +0 -1
- package/packages/agent/src/runtime/roles/src/utils.d.ts.map +0 -1
- package/packages/agent/src/runtime/roles.d.ts.map +0 -1
- package/packages/agent/src/runtime/subagent-output.d.ts +0 -51
- package/packages/agent/src/runtime/subagent-output.d.ts.map +0 -1
- package/packages/agent/src/runtime/subagent-output.js +0 -173
- package/packages/agent/src/runtime/task-heartbeat.d.ts +0 -22
- package/packages/agent/src/runtime/task-heartbeat.d.ts.map +0 -1
- package/packages/agent/src/runtime/task-heartbeat.js +0 -84
- package/packages/agent/src/runtime/tool-call-cache/cache.d.ts +0 -62
- package/packages/agent/src/runtime/tool-call-cache/cache.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache/cache.js +0 -123
- package/packages/agent/src/runtime/tool-call-cache/disk-store.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache/index.d.ts +0 -7
- package/packages/agent/src/runtime/tool-call-cache/index.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache/index.js +0 -4
- package/packages/agent/src/runtime/tool-call-cache/key.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache/key.js +0 -31
- package/packages/agent/src/runtime/tool-call-cache/lru.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache/redact.d.ts +0 -17
- package/packages/agent/src/runtime/tool-call-cache/redact.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache/redact.js +0 -77
- package/packages/agent/src/runtime/tool-call-cache/registry.d.ts +0 -18
- package/packages/agent/src/runtime/tool-call-cache/registry.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache/registry.js +0 -66
- package/packages/agent/src/runtime/tool-call-cache/types.d.ts.map +0 -1
- package/packages/agent/src/runtime/tool-call-cache-wrapper.d.ts.map +0 -1
- package/packages/agent/src/runtime/trajectory-export.d.ts.map +0 -1
- package/packages/agent/src/runtime/trajectory-export.js +0 -109
- package/packages/agent/src/runtime/trajectory-internals.d.ts +0 -242
- package/packages/agent/src/runtime/trajectory-internals.d.ts.map +0 -1
- package/packages/agent/src/runtime/trajectory-internals.js +0 -1281
- package/packages/agent/src/runtime/trajectory-persistence.d.ts +0 -15
- package/packages/agent/src/runtime/trajectory-persistence.d.ts.map +0 -1
- package/packages/agent/src/runtime/trajectory-persistence.js +0 -29
- package/packages/agent/src/runtime/trajectory-query.d.ts.map +0 -1
- package/packages/agent/src/runtime/trajectory-query.js +0 -27
- package/packages/agent/src/runtime/trajectory-storage.d.ts +0 -91
- package/packages/agent/src/runtime/trajectory-storage.d.ts.map +0 -1
- package/packages/agent/src/runtime/trajectory-storage.js +0 -1093
- package/packages/agent/src/runtime/vault-profile-resolver.d.ts +0 -37
- package/packages/agent/src/runtime/vault-profile-resolver.d.ts.map +0 -1
- package/packages/agent/src/runtime/vault-profile-resolver.js +0 -79
- package/packages/agent/src/runtime/version.d.ts.map +0 -1
- package/packages/agent/src/runtime/web-search-tools.d.ts +0 -22
- package/packages/agent/src/runtime/web-search-tools.d.ts.map +0 -1
- package/packages/agent/src/runtime/web-search-tools.js +0 -151
- package/packages/agent/src/security/access.d.ts.map +0 -1
- package/packages/agent/src/security/access.js +0 -54
- package/packages/agent/src/security/audit-log.d.ts.map +0 -1
- package/packages/agent/src/security/audit-log.js +0 -161
- package/packages/agent/src/security/index.d.ts.map +0 -1
- package/packages/agent/src/security/network-policy.d.ts.map +0 -1
- package/packages/agent/src/services/agent-export.d.ts +0 -100
- package/packages/agent/src/services/agent-export.d.ts.map +0 -1
- package/packages/agent/src/services/agent-export.js +0 -764
- package/packages/agent/src/services/app-manager-agents-list-guard.d.ts.map +0 -1
- package/packages/agent/src/services/app-manager.d.ts +0 -108
- package/packages/agent/src/services/app-manager.d.ts.map +0 -1
- package/packages/agent/src/services/app-manager.js +0 -1678
- package/packages/agent/src/services/app-package-modules.d.ts +0 -22
- package/packages/agent/src/services/app-package-modules.d.ts.map +0 -1
- package/packages/agent/src/services/app-package-modules.js +0 -397
- package/packages/agent/src/services/app-run-store.d.ts +0 -6
- package/packages/agent/src/services/app-run-store.d.ts.map +0 -1
- package/packages/agent/src/services/app-run-store.js +0 -547
- package/packages/agent/src/services/app-session-gate.d.ts.map +0 -1
- package/packages/agent/src/services/app-session-gate.js +0 -71
- package/packages/agent/src/services/capability-broker.d.ts.map +0 -1
- package/packages/agent/src/services/capability-broker.js +0 -339
- package/packages/agent/src/services/character-history.d.ts.map +0 -1
- package/packages/agent/src/services/character-persistence.d.ts.map +0 -1
- package/packages/agent/src/services/client-chat-sender.d.ts.map +0 -1
- package/packages/agent/src/services/client-chat-sender.js +0 -88
- package/packages/agent/src/services/config-plugin-manager.d.ts.map +0 -1
- package/packages/agent/src/services/connector-setup-service.d.ts.map +0 -1
- package/packages/agent/src/services/escalation.d.ts.map +0 -1
- package/packages/agent/src/services/escalation.js +0 -376
- package/packages/agent/src/services/evm-signing-capability.d.ts +0 -33
- package/packages/agent/src/services/evm-signing-capability.d.ts.map +0 -1
- package/packages/agent/src/services/evm-signing-capability.js +0 -52
- package/packages/agent/src/services/external-bridge-state.d.ts +0 -10
- package/packages/agent/src/services/external-bridge-state.d.ts.map +0 -1
- package/packages/agent/src/services/external-bridge-state.js +0 -14
- package/packages/agent/src/services/hosted-tools.d.ts +0 -70
- package/packages/agent/src/services/hosted-tools.d.ts.map +0 -1
- package/packages/agent/src/services/hosted-tools.js +0 -87
- package/packages/agent/src/services/index.d.ts +0 -27
- package/packages/agent/src/services/index.d.ts.map +0 -1
- package/packages/agent/src/services/index.js +0 -32
- package/packages/agent/src/services/js-runtime-bridge.d.ts.map +0 -1
- package/packages/agent/src/services/js-runtime-bridge.js +0 -217
- package/packages/agent/src/services/mcp-marketplace.d.ts.map +0 -1
- package/packages/agent/src/services/mcp-marketplace.js +0 -200
- package/packages/agent/src/services/media-generation.d.ts +0 -10
- package/packages/agent/src/services/media-generation.d.ts.map +0 -1
- package/packages/agent/src/services/media-generation.js +0 -102
- package/packages/agent/src/services/overlay-app-presence.d.ts.map +0 -1
- package/packages/agent/src/services/owner-name.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/contracts.d.ts +0 -9
- package/packages/agent/src/services/permissions/contracts.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/contracts.js +0 -8
- package/packages/agent/src/services/permissions/probers/_bridge.d.ts +0 -77
- package/packages/agent/src/services/permissions/probers/_bridge.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/_bridge.js +0 -224
- package/packages/agent/src/services/permissions/probers/accessibility.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/automation.d.ts +0 -17
- package/packages/agent/src/services/permissions/probers/automation.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/automation.js +0 -46
- package/packages/agent/src/services/permissions/probers/calendar.d.ts +0 -14
- package/packages/agent/src/services/permissions/probers/calendar.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/calendar.js +0 -33
- package/packages/agent/src/services/permissions/probers/camera.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/contacts.d.ts +0 -13
- package/packages/agent/src/services/permissions/probers/contacts.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/contacts.js +0 -32
- package/packages/agent/src/services/permissions/probers/full-disk.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/health.d.ts +0 -23
- package/packages/agent/src/services/permissions/probers/health.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/health.js +0 -82
- package/packages/agent/src/services/permissions/probers/index.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/index.js +0 -42
- package/packages/agent/src/services/permissions/probers/location.d.ts +0 -21
- package/packages/agent/src/services/permissions/probers/location.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/location.js +0 -47
- package/packages/agent/src/services/permissions/probers/microphone.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/notes.d.ts +0 -19
- package/packages/agent/src/services/permissions/probers/notes.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/notes.js +0 -55
- package/packages/agent/src/services/permissions/probers/notifications.d.ts +0 -24
- package/packages/agent/src/services/permissions/probers/notifications.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/notifications.js +0 -47
- package/packages/agent/src/services/permissions/probers/reminders.d.ts +0 -22
- package/packages/agent/src/services/permissions/probers/reminders.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/reminders.js +0 -44
- package/packages/agent/src/services/permissions/probers/screen-recording.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/screentime.d.ts +0 -21
- package/packages/agent/src/services/permissions/probers/screentime.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/screentime.js +0 -67
- package/packages/agent/src/services/permissions/probers/shell.d.ts +0 -19
- package/packages/agent/src/services/permissions/probers/shell.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/probers/shell.js +0 -31
- package/packages/agent/src/services/permissions/probers/website-blocking.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/register-probers.d.ts +0 -29
- package/packages/agent/src/services/permissions/register-probers.d.ts.map +0 -1
- package/packages/agent/src/services/permissions/register-probers.js +0 -31
- package/packages/agent/src/services/permissions-registry.d.ts.map +0 -1
- package/packages/agent/src/services/permissions-registry.js +0 -213
- package/packages/agent/src/services/plugin-compiler.d.ts.map +0 -1
- package/packages/agent/src/services/plugin-compiler.js +0 -90
- package/packages/agent/src/services/plugin-installer.d.ts +0 -93
- package/packages/agent/src/services/plugin-installer.d.ts.map +0 -1
- package/packages/agent/src/services/plugin-installer.js +0 -623
- package/packages/agent/src/services/plugin-manager-types.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client-app-meta.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client-app-meta.js +0 -168
- package/packages/agent/src/services/registry-client-endpoints.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client-endpoints.js +0 -190
- package/packages/agent/src/services/registry-client-local.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client-local.js +0 -555
- package/packages/agent/src/services/registry-client-network.d.ts +0 -14
- package/packages/agent/src/services/registry-client-network.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client-network.js +0 -147
- package/packages/agent/src/services/registry-client-queries.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client-queries.js +0 -197
- package/packages/agent/src/services/registry-client-types.d.ts +0 -114
- package/packages/agent/src/services/registry-client-types.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client.d.ts +0 -39
- package/packages/agent/src/services/registry-client.d.ts.map +0 -1
- package/packages/agent/src/services/registry-client.js +0 -349
- package/packages/agent/src/services/relationships-graph.d.ts +0 -13
- package/packages/agent/src/services/relationships-graph.d.ts.map +0 -1
- package/packages/agent/src/services/relationships-graph.js +0 -38
- package/packages/agent/src/services/remote-signing-service.d.ts +0 -58
- package/packages/agent/src/services/remote-signing-service.d.ts.map +0 -1
- package/packages/agent/src/services/remote-signing-service.js +0 -185
- package/packages/agent/src/services/research-task-executor.d.ts.map +0 -1
- package/packages/agent/src/services/research-task-executor.js +0 -138
- package/packages/agent/src/services/sandbox-engine.d.ts.map +0 -1
- package/packages/agent/src/services/sandbox-manager.d.ts +0 -127
- package/packages/agent/src/services/sandbox-manager.d.ts.map +0 -1
- package/packages/agent/src/services/sandbox-manager.js +0 -418
- package/packages/agent/src/services/self-updater.d.ts +0 -21
- package/packages/agent/src/services/self-updater.d.ts.map +0 -1
- package/packages/agent/src/services/self-updater.js +0 -162
- package/packages/agent/src/services/send-handler-availability.d.ts.map +0 -1
- package/packages/agent/src/services/send-handler-availability.js +0 -20
- package/packages/agent/src/services/shell-execution-router.d.ts +0 -67
- package/packages/agent/src/services/shell-execution-router.d.ts.map +0 -1
- package/packages/agent/src/services/shell-execution-router.js +0 -201
- package/packages/agent/src/services/signing-policy.d.ts +0 -44
- package/packages/agent/src/services/signing-policy.d.ts.map +0 -1
- package/packages/agent/src/services/skill-catalog-client.d.ts +0 -47
- package/packages/agent/src/services/skill-catalog-client.d.ts.map +0 -1
- package/packages/agent/src/services/skill-catalog-client.js +0 -130
- package/packages/agent/src/services/skill-marketplace.d.ts +0 -42
- package/packages/agent/src/services/skill-marketplace.d.ts.map +0 -1
- package/packages/agent/src/services/skill-marketplace.js +0 -691
- package/packages/agent/src/services/task-executor.d.ts.map +0 -1
- package/packages/agent/src/services/update-checker.d.ts.map +0 -1
- package/packages/agent/src/services/version-compat.d.ts.map +0 -1
- package/packages/agent/src/services/version-compat.js +0 -211
- package/packages/agent/src/services/virtual-filesystem.d.ts +0 -88
- package/packages/agent/src/services/virtual-filesystem.d.ts.map +0 -1
- package/packages/agent/src/services/virtual-filesystem.js +0 -410
- package/packages/agent/src/shared/conversation-format.d.ts.map +0 -1
- package/packages/agent/src/shared/conversation-format.js +0 -69
- package/packages/agent/src/shared/index.d.ts +0 -4
- package/packages/agent/src/shared/index.d.ts.map +0 -1
- package/packages/agent/src/shared/index.js +0 -3
- package/packages/agent/src/shared/ui-catalog-prompt.d.ts.map +0 -1
- package/packages/agent/src/shared/workspace-resolution.d.ts.map +0 -1
- package/packages/agent/src/shared/workspace-resolution.js +0 -70
- package/packages/agent/src/templates/skill-scaffold.d.ts +0 -9
- package/packages/agent/src/templates/skill-scaffold.d.ts.map +0 -1
- package/packages/agent/src/templates/skill-scaffold.js +0 -26
- package/packages/agent/src/test-support/index.d.ts.map +0 -1
- package/packages/agent/src/test-support/process-helpers.d.ts.map +0 -1
- package/packages/agent/src/test-support/route-test-helpers.d.ts.map +0 -1
- package/packages/agent/src/test-support/test-helpers.d.ts.map +0 -1
- package/packages/agent/src/test-utils/sqlite-compat.d.ts.map +0 -1
- package/packages/agent/src/test-utils/sqlite-compat.js +0 -214
- package/packages/agent/src/testing/index.d.ts +0 -4
- package/packages/agent/src/testing/index.d.ts.map +0 -1
- package/packages/agent/src/testing/index.js +0 -3
- package/packages/agent/src/triggers/index.d.ts +0 -5
- package/packages/agent/src/triggers/index.d.ts.map +0 -1
- package/packages/agent/src/triggers/index.js +0 -4
- package/packages/agent/src/triggers/runtime.d.ts.map +0 -1
- package/packages/agent/src/triggers/runtime.js +0 -447
- package/packages/agent/src/triggers/scheduling.d.ts +0 -78
- package/packages/agent/src/triggers/scheduling.d.ts.map +0 -1
- package/packages/agent/src/triggers/scheduling.js +0 -436
- package/packages/agent/src/triggers/text-to-workflow.d.ts +0 -58
- package/packages/agent/src/triggers/text-to-workflow.d.ts.map +0 -1
- package/packages/agent/src/triggers/text-to-workflow.js +0 -44
- package/packages/agent/src/triggers/types.d.ts +0 -96
- package/packages/agent/src/triggers/types.d.ts.map +0 -1
- package/packages/agent/src/types/agent-skills.d.ts.map +0 -1
- package/packages/agent/src/types/config-like.d.ts.map +0 -1
- package/packages/agent/src/types/index.d.ts.map +0 -1
- package/packages/agent/src/types/trajectory.d.ts +0 -20
- package/packages/agent/src/types/trajectory.d.ts.map +0 -1
- package/packages/agent/src/utils/atomic-json.d.ts.map +0 -1
- package/packages/agent/src/utils/exec-safety.d.ts +0 -2
- package/packages/agent/src/utils/exec-safety.d.ts.map +0 -1
- package/packages/agent/src/utils/exec-safety.js +0 -21
- package/packages/agent/src/utils/index.d.ts +0 -2
- package/packages/agent/src/utils/index.d.ts.map +0 -1
- package/packages/agent/src/utils/index.js +0 -1
- package/packages/agent/src/utils/number-parsing.d.ts +0 -26
- package/packages/agent/src/utils/number-parsing.d.ts.map +0 -1
- package/packages/agent/src/utils/number-parsing.js +0 -51
- package/packages/agent/src/version-resolver.d.ts.map +0 -1
- /package/{packages/agent/src/actions → actions}/connector-resolver.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/contact.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/context-signal-lexicon.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/context-signal-lexicon.js +0 -0
- /package/{packages/agent/src/actions → actions}/context-signal.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/database.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/grounded-action-reply.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/logs.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/logs.js +0 -0
- /package/{packages/agent/src/actions → actions}/recent-conversation-texts.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/runtime.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/terminal.d.ts +0 -0
- /package/{packages/agent/src/actions → actions}/trigger.d.ts +0 -0
- /package/{packages/agent/src/api → api}/agent-lifecycle-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/agent-model.d.ts +0 -0
- /package/{packages/agent/src/api → api}/agent-status-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/agent-transfer-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/auth-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/avatar-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/binance-skill-helpers.d.ts +0 -0
- /package/{packages/agent/src/api → api}/character-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/chat-text-helpers.d.ts +0 -0
- /package/{packages/agent/src/api → api}/chat-text-helpers.js +0 -0
- /package/{packages/agent/src/api → api}/client-chat-admin.d.ts +0 -0
- /package/{packages/agent/src/api → api}/client-chat-admin.js +0 -0
- /package/{packages/agent/src/api → api}/compat-utils.d.ts +0 -0
- /package/{packages/agent/src/api → api}/compat-utils.js +0 -0
- /package/{packages/agent/src/api → api}/config-env.d.ts +0 -0
- /package/{packages/agent/src/api → api}/config-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/connector-account-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/connector-health.d.ts +0 -0
- /package/{packages/agent/src/api → api}/connector-health.js +0 -0
- /package/{packages/agent/src/api → api}/connector-oauth-callback-auth.d.ts +0 -0
- /package/{packages/agent/src/api → api}/connector-oauth-callback-auth.js +0 -0
- /package/{packages/agent/src/api → api}/connector-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/conversation-metadata.d.ts +0 -0
- /package/{packages/agent/src/api → api}/coordinator-wiring.d.ts +0 -0
- /package/{packages/agent/src/api → api}/credit-detection.d.ts +0 -0
- /package/{packages/agent/src/api → api}/documents-service-loader.d.ts +0 -0
- /package/{packages/agent/src/api → api}/documents-service-loader.js +0 -0
- /package/{packages/agent/src/api → api}/early-logs.js +0 -0
- /package/{packages/agent/src/api → api}/inbox-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/memory-bounds.d.ts +0 -0
- /package/{packages/agent/src/api → api}/memory-bounds.js +0 -0
- /package/{packages/agent/src/api → api}/memory-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/misc-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/mobile-optional-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/models-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/models-routes.js +0 -0
- /package/{packages/agent/src/api → api}/music-player-route-fallback.d.ts +0 -0
- /package/{packages/agent/src/api → api}/music-player-route-fallback.js +0 -0
- /package/{packages/agent/src/api → api}/owner-contact-helpers.d.ts +0 -0
- /package/{packages/agent/src/api → api}/owner-contact-helpers.js +0 -0
- /package/{packages/agent/src/api → api}/parse-action-block.js +0 -0
- /package/{packages/agent/src/api → api}/permissions-routes-extra.js +0 -0
- /package/{packages/agent/src/api → api}/permissions-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/plugin-runtime-apply.d.ts +0 -0
- /package/{packages/agent/src/api → api}/plugin-validation.d.ts +0 -0
- /package/{packages/agent/src/api → api}/plugin-validation.js +0 -0
- /package/{packages/agent/src/api → api}/provider-switch-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/rate-limiter.d.ts +0 -0
- /package/{packages/agent/src/api → api}/rate-limiter.js +0 -0
- /package/{packages/agent/src/api → api}/registry-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/registry-service.d.ts +0 -0
- /package/{packages/agent/src/api → api}/relationships-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/runtime-plugin-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/server-auth.d.ts +0 -0
- /package/{packages/agent/src/api → api}/server-autonomy-helpers.d.ts +0 -0
- /package/{packages/agent/src/api → api}/server-autonomy-helpers.js +0 -0
- /package/{packages/agent/src/api → api}/server-helpers-fetch.d.ts +0 -0
- /package/{packages/agent/src/api → api}/server-helpers-fetch.js +0 -0
- /package/{packages/agent/src/api → api}/server-helpers-plugin.d.ts +0 -0
- /package/{packages/agent/src/api → api}/server-helpers-plugin.js +0 -0
- /package/{packages/agent/src/api → api}/server-helpers-wallet.d.ts +0 -0
- /package/{packages/agent/src/api → api}/server-helpers-wallet.js +0 -0
- /package/{packages/agent/src/api → api}/server-route-dispatch.d.ts +0 -0
- /package/{packages/agent/src/api/training-service-like.js → api/server-types.js} +0 -0
- /package/{packages/agent/src/api → api}/static-file-server.d.ts +0 -0
- /package/{packages/agent/src/api → api}/subscription-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/task-agent-message-routing.d.ts +0 -0
- /package/{packages/agent/src/api → api}/task-agent-message-routing.js +0 -0
- /package/{packages/agent/src/api → api}/terminal-execution-routing.d.ts +0 -0
- /package/{packages/agent/src/api → api}/terminal-execution-routing.js +0 -0
- /package/{packages/agent/src/api → api}/terminal-run-limits.d.ts +0 -0
- /package/{packages/agent/src/api → api}/training-backend-check.d.ts +0 -0
- /package/{packages/agent/src/api → api}/training-backend-check.js +0 -0
- /package/{packages/agent/src/api → api}/training-service-like.d.ts +0 -0
- /package/{packages/agent/src/services/registry-client-types.js → api/training-service-like.js} +0 -0
- /package/{packages/agent/src/api → api}/update-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/wallet-dex-prices.d.ts +0 -0
- /package/{packages/agent/src/api → api}/wallet-dex-prices.js +0 -0
- /package/{packages/agent/src/api → api}/wallet-env-sync.js +0 -0
- /package/{packages/agent/src/api → api}/wallet-evm-balance.d.ts +0 -0
- /package/{packages/agent/src/api → api}/wallet-evm-balance.js +0 -0
- /package/{packages/agent/src/api → api}/wallet-rpc.d.ts +0 -0
- /package/{packages/agent/src/api → api}/wallet-trading-profile.d.ts +0 -0
- /package/{packages/agent/src/api → api}/wallet.d.ts +0 -0
- /package/{packages/agent/src/api → api}/workbench-helpers.d.ts +0 -0
- /package/{packages/agent/src/api → api}/workbench-helpers.js +0 -0
- /package/{packages/agent/src/api → api}/x-relay-routes.d.ts +0 -0
- /package/{packages/agent/src/api → api}/zip-utils.d.ts +0 -0
- /package/{packages/agent/src/api → api}/zip-utils.js +0 -0
- /package/{packages/agent/src/auth → auth}/anthropic.d.ts +0 -0
- /package/{packages/agent/src/auth → auth}/anthropic.js +0 -0
- /package/{packages/agent/src/auth → auth}/claude-code-stealth.d.ts +0 -0
- /package/{packages/agent/src/auth → auth}/index.d.ts +0 -0
- /package/{packages/agent/src/auth → auth}/index.js +0 -0
- /package/{packages/agent/src/auth → auth}/openai-codex.d.ts +0 -0
- /package/{packages/agent/src/auth → auth}/vendor/pi-oauth/anthropic-login.d.ts +0 -0
- /package/{packages/agent/src/auth → auth}/vendor/pi-oauth/pkce.d.ts +0 -0
- /package/{packages/agent/src/auth → auth}/vendor/pi-oauth/pkce.js +0 -0
- /package/{packages/agent/src/awareness → awareness}/index.d.ts +0 -0
- /package/{packages/agent/src/awareness → awareness}/index.js +0 -0
- /package/{packages/agent/src/awareness → awareness}/registry.d.ts +0 -0
- /package/{packages/agent/src/awareness → awareness}/registry.js +0 -0
- /package/{packages/agent/src/bin.d.ts → bin.d.ts} +0 -0
- /package/{packages/agent/src/cli → cli}/benchmark.d.ts +0 -0
- /package/{packages/agent/src/cli → cli}/index.d.ts +0 -0
- /package/{packages/agent/src/config → config}/character-schema.d.ts +0 -0
- /package/{packages/agent/src/config → config}/character-schema.js +0 -0
- /package/{packages/agent/src/config → config}/config.d.ts +0 -0
- /package/{packages/agent/src/config → config}/env-vars.d.ts +0 -0
- /package/{packages/agent/src/config → config}/env-vars.js +0 -0
- /package/{packages/agent/src/config → config}/index.d.ts +0 -0
- /package/{packages/agent/src/config → config}/index.js +0 -0
- /package/{packages/agent/src/config → config}/model-metadata.d.ts +0 -0
- /package/{packages/agent/src/config → config}/owner-contacts.d.ts +0 -0
- /package/{packages/agent/src/config → config}/plugin-auto-enable.d.ts +0 -0
- /package/{packages/agent/src/config → config}/plugin-auto-enable.js +0 -0
- /package/{packages/agent/src/config → config}/schema.d.ts +0 -0
- /package/{packages/agent/src/config → config}/telegram-custom-commands.d.ts +0 -0
- /package/{packages/agent/src/config → config}/telegram-custom-commands.js +0 -0
- /package/{packages/agent/src/config → config}/types.agent-defaults.d.ts +0 -0
- /package/{packages/agent/src/config → config}/types.agent-defaults.js +0 -0
- /package/{packages/agent/src/config → config}/types.agents.d.ts +0 -0
- /package/{packages/agent/src/config → config}/types.agents.js +0 -0
- /package/{packages/agent/src/config → config}/types.d.ts +0 -0
- /package/{packages/agent/src/config → config}/types.eliza.d.ts +0 -0
- /package/{packages/agent/src/config → config}/types.eliza.js +0 -0
- /package/{packages/agent/src/config → config}/types.hooks.d.ts +0 -0
- /package/{packages/agent/src/config → config}/types.hooks.js +0 -0
- /package/{packages/agent/src/config → config}/types.js +0 -0
- /package/{packages/agent/src/config → config}/types.messages.d.ts +0 -0
- /package/{packages/agent/src/config → config}/types.messages.js +0 -0
- /package/{packages/agent/src/config → config}/zod-schema.hooks.d.ts +0 -0
- /package/{packages/agent/src/config → config}/zod-schema.hooks.js +0 -0
- /package/{packages/agent/src/config → config}/zod-schema.session.js +0 -0
- /package/{packages/agent/src/contracts → contracts}/awareness.d.ts +0 -0
- /package/{packages/agent/src/contracts → contracts}/awareness.js +0 -0
- /package/{packages/agent/src/diagnostics → diagnostics}/integration-observability.d.ts +0 -0
- /package/{packages/agent/src/diagnostics → diagnostics}/integration-observability.js +0 -0
- /package/{packages/agent/src/hooks → hooks}/eligibility.d.ts +0 -0
- /package/{packages/agent/src/hooks → hooks}/eligibility.js +0 -0
- /package/{packages/agent/src/hooks → hooks}/index.d.ts +0 -0
- /package/{packages/agent/src/hooks → hooks}/index.js +0 -0
- /package/{packages/agent/src/hooks → hooks}/loader.d.ts +0 -0
- /package/{packages/agent/src/hooks → hooks}/registry.d.ts +0 -0
- /package/{packages/agent/src/hooks → hooks}/registry.js +0 -0
- /package/{packages/agent/src/hooks → hooks}/types.d.ts +0 -0
- /package/{packages/agent/src/hooks → hooks}/types.js +0 -0
- /package/{packages/agent/src/providers → providers}/admin-panel.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/admin-panel.js +0 -0
- /package/{packages/agent/src/providers → providers}/admin-trust.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/admin-trust.js +0 -0
- /package/{packages/agent/src/providers → providers}/automation-terminal-bridge.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/conversation-proximity.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/conversation-proximity.js +0 -0
- /package/{packages/agent/src/providers → providers}/escalation-trigger.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/escalation-trigger.js +0 -0
- /package/{packages/agent/src/providers → providers}/page-scoped-context.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/recent-conversations.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/relevant-conversations.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/rolodex.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/session-bridge.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/skill-provider.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/skill-provider.js +0 -0
- /package/{packages/agent/src/providers → providers}/tasks.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/tasks.js +0 -0
- /package/{packages/agent/src/providers → providers}/ui-catalog.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/user-name.d.ts +0 -0
- /package/{packages/agent/src/providers → providers}/user-name.js +0 -0
- /package/{packages/agent/src/providers → providers}/workspace-provider.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/advanced-capabilities-config.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/advanced-capabilities-config.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/agent-event-service.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/agent-event-service.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/build-character-config.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/conversation-compactor.types.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/eliza-plugin.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/local-execution-mode.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/model-resolution.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/native-runtime-features.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/native-runtime-features.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/classifier.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/cold-strategy.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/cold-strategy.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/health-checks.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/health-checks.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/health.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/health.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/index.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/index.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/repository.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/repository.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/types.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/types.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/operations/vault-bridge.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/owner-entity.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/plugin-collector.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/release-plugin-policy.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles/src/index.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles/src/provider.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles/src/provider.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles/src/types.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles/src/types.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles/src/utils.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles/src/utils.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/roles.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache/disk-store.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache/disk-store.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache/key.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache/lru.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache/lru.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache/types.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache/types.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache-wrapper.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/tool-call-cache-wrapper.js +0 -0
- /package/{packages/agent/src/runtime → runtime}/trajectory-export.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/trajectory-query.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/version.d.ts +0 -0
- /package/{packages/agent/src/runtime → runtime}/version.js +0 -0
- /package/{packages/agent/src/security → security}/access.d.ts +0 -0
- /package/{packages/agent/src/security → security}/audit-log.d.ts +0 -0
- /package/{packages/agent/src/security → security}/index.d.ts +0 -0
- /package/{packages/agent/src/security → security}/index.js +0 -0
- /package/{packages/agent/src/security → security}/network-policy.d.ts +0 -0
- /package/{packages/agent/src/security → security}/network-policy.js +0 -0
- /package/{packages/agent/src/services → services}/app-manager-agents-list-guard.d.ts +0 -0
- /package/{packages/agent/src/services → services}/app-manager-agents-list-guard.js +0 -0
- /package/{packages/agent/src/services → services}/app-session-gate.d.ts +0 -0
- /package/{packages/agent/src/services → services}/capability-broker.d.ts +0 -0
- /package/{packages/agent/src/services → services}/character-history.d.ts +0 -0
- /package/{packages/agent/src/services → services}/character-history.js +0 -0
- /package/{packages/agent/src/services → services}/character-persistence.d.ts +0 -0
- /package/{packages/agent/src/services → services}/character-persistence.js +0 -0
- /package/{packages/agent/src/services → services}/client-chat-sender.d.ts +0 -0
- /package/{packages/agent/src/services → services}/config-plugin-manager.d.ts +0 -0
- /package/{packages/agent/src/services → services}/config-plugin-manager.js +0 -0
- /package/{packages/agent/src/services → services}/connector-setup-service.d.ts +0 -0
- /package/{packages/agent/src/services → services}/connector-setup-service.js +0 -0
- /package/{packages/agent/src/services → services}/escalation.d.ts +0 -0
- /package/{packages/agent/src/services → services}/js-runtime-bridge.d.ts +0 -0
- /package/{packages/agent/src/services → services}/mcp-marketplace.d.ts +0 -0
- /package/{packages/agent/src/services → services}/overlay-app-presence.d.ts +0 -0
- /package/{packages/agent/src/services → services}/overlay-app-presence.js +0 -0
- /package/{packages/agent/src/services → services}/owner-name.d.ts +0 -0
- /package/{packages/agent/src/services → services}/owner-name.js +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/accessibility.d.ts +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/accessibility.js +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/camera.d.ts +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/camera.js +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/full-disk.d.ts +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/full-disk.js +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/index.d.ts +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/microphone.d.ts +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/microphone.js +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/screen-recording.d.ts +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/screen-recording.js +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/website-blocking.d.ts +0 -0
- /package/{packages/agent/src/services → services}/permissions/probers/website-blocking.js +0 -0
- /package/{packages/agent/src/services → services}/permissions-registry.d.ts +0 -0
- /package/{packages/agent/src/services → services}/plugin-compiler.d.ts +0 -0
- /package/{packages/agent/src/services → services}/plugin-manager-types.d.ts +0 -0
- /package/{packages/agent/src/services → services}/plugin-manager-types.js +0 -0
- /package/{packages/agent/src/services → services}/registry-client-app-meta.d.ts +0 -0
- /package/{packages/agent/src/services → services}/registry-client-endpoints.d.ts +0 -0
- /package/{packages/agent/src/services → services}/registry-client-local.d.ts +0 -0
- /package/{packages/agent/src/services → services}/registry-client-queries.d.ts +0 -0
- /package/{packages/agent/src/services → services}/research-task-executor.d.ts +0 -0
- /package/{packages/agent/src/services → services}/sandbox-engine.d.ts +0 -0
- /package/{packages/agent/src/services → services}/sandbox-engine.js +0 -0
- /package/{packages/agent/src/services → services}/send-handler-availability.d.ts +0 -0
- /package/{packages/agent/src/services → services}/signing-policy.js +0 -0
- /package/{packages/agent/src/services → services}/task-executor.d.ts +0 -0
- /package/{packages/agent/src/services → services}/task-executor.js +0 -0
- /package/{packages/agent/src/services → services}/update-checker.d.ts +0 -0
- /package/{packages/agent/src/services → services}/update-checker.js +0 -0
- /package/{packages/agent/src/services → services}/version-compat.d.ts +0 -0
- /package/{packages/agent/src/shared → shared}/conversation-format.d.ts +0 -0
- /package/{packages/agent/src/shared → shared}/ui-catalog-prompt.d.ts +0 -0
- /package/{packages/agent/src/shared → shared}/ui-catalog-prompt.js +0 -0
- /package/{packages/agent/src/shared → shared}/workspace-resolution.d.ts +0 -0
- /package/{packages/agent/src/test-support → test-support}/index.d.ts +0 -0
- /package/{packages/agent/src/test-support → test-support}/index.js +0 -0
- /package/{packages/agent/src/test-support → test-support}/process-helpers.d.ts +0 -0
- /package/{packages/agent/src/test-support → test-support}/process-helpers.js +0 -0
- /package/{packages/agent/src/test-support → test-support}/route-test-helpers.d.ts +0 -0
- /package/{packages/agent/src/test-support → test-support}/route-test-helpers.js +0 -0
- /package/{packages/agent/src/test-support → test-support}/test-helpers.d.ts +0 -0
- /package/{packages/agent/src/test-support → test-support}/test-helpers.js +0 -0
- /package/{packages/agent/src/test-utils → test-utils}/sqlite-compat.d.ts +0 -0
- /package/{packages/agent/src/triggers → triggers}/runtime.d.ts +0 -0
- /package/{packages/agent/src/triggers → triggers}/types.js +0 -0
- /package/{packages/agent/src/types → types}/agent-skills.d.ts +0 -0
- /package/{packages/agent/src/types → types}/agent-skills.js +0 -0
- /package/{packages/agent/src/types → types}/config-like.d.ts +0 -0
- /package/{packages/agent/src/types → types}/config-like.js +0 -0
- /package/{packages/agent/src/types → types}/index.d.ts +0 -0
- /package/{packages/agent/src/types → types}/index.js +0 -0
- /package/{packages/agent/src/types → types}/trajectory.js +0 -0
- /package/{packages/agent/src/utils → utils}/atomic-json.d.ts +0 -0
- /package/{packages/agent/src/utils → utils}/atomic-json.js +0 -0
- /package/{packages/agent/src/version-resolver.d.ts → version-resolver.d.ts} +0 -0
- /package/{packages/agent/src/version-resolver.js → version-resolver.js} +0 -0
package/api/server.js
ADDED
|
@@ -0,0 +1,3684 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST API server for the Eliza Control UI.
|
|
3
|
+
*
|
|
4
|
+
* Exposes HTTP endpoints that the UI frontend expects, backed by the
|
|
5
|
+
* elizaOS AgentRuntime. Default port: 2138. In dev mode, the Vite UI
|
|
6
|
+
* dev server proxies /api and /ws here (see eliza/packages/app-core/scripts/dev-ui.mjs).
|
|
7
|
+
*/
|
|
8
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
9
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
10
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
11
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return path;
|
|
15
|
+
};
|
|
16
|
+
import crypto from "node:crypto";
|
|
17
|
+
import fs from "node:fs";
|
|
18
|
+
import http from "node:http";
|
|
19
|
+
import { createRequire } from "node:module";
|
|
20
|
+
function tokenMatches(expected, provided) {
|
|
21
|
+
const expectedBuf = Buffer.from(expected);
|
|
22
|
+
const providedBuf = Buffer.from(provided);
|
|
23
|
+
return (expectedBuf.length === providedBuf.length &&
|
|
24
|
+
crypto.timingSafeEqual(expectedBuf, providedBuf));
|
|
25
|
+
}
|
|
26
|
+
const MAX_BODY_BYTES = 1024 * 1024; // 1 MB
|
|
27
|
+
import path from "node:path";
|
|
28
|
+
import { handleCloudPairRoute } from "@elizaos/app-core/api/cloud-pair-route";
|
|
29
|
+
import { isStreamingDestinationConfigured, logger, readJsonBody as parseJsonBody, readRequestBody, sendJson, sendJsonError, stringToUuid, } from "@elizaos/core";
|
|
30
|
+
import { getStylePresets, normalizeCharacterLanguage, resolveStylePresetByAvatarIndex, } from "@elizaos/shared/character-presets";
|
|
31
|
+
import { isMobilePlatform, resolveApiBindHost, resolveDesktopApiPort, resolveServerOnlyPort, } from "@elizaos/shared/runtime-env";
|
|
32
|
+
import { parseClampedInteger } from "@elizaos/shared/utils/number-parsing";
|
|
33
|
+
import { WebSocketServer } from "ws";
|
|
34
|
+
let browserPluginModule = null;
|
|
35
|
+
let x402PluginModule = null;
|
|
36
|
+
let browserPluginModulePromise = null;
|
|
37
|
+
let x402PluginModulePromise = null;
|
|
38
|
+
async function getBrowserPlugin() {
|
|
39
|
+
if (browserPluginModule)
|
|
40
|
+
return browserPluginModule;
|
|
41
|
+
browserPluginModulePromise ??= import(
|
|
42
|
+
/* @vite-ignore */ "@elizaos/plugin-browser").then((browser) => {
|
|
43
|
+
browserPluginModule = browser;
|
|
44
|
+
return browser;
|
|
45
|
+
});
|
|
46
|
+
return browserPluginModulePromise;
|
|
47
|
+
}
|
|
48
|
+
async function getX402Plugin() {
|
|
49
|
+
if (x402PluginModule)
|
|
50
|
+
return x402PluginModule;
|
|
51
|
+
x402PluginModulePromise ??= import(
|
|
52
|
+
/* @vite-ignore */ "@elizaos/plugin-x402").then((x402) => {
|
|
53
|
+
x402PluginModule = x402;
|
|
54
|
+
return x402;
|
|
55
|
+
});
|
|
56
|
+
return x402PluginModulePromise;
|
|
57
|
+
}
|
|
58
|
+
const optionalPluginImports = {
|
|
59
|
+
capacitor: () => import(/* @vite-ignore */ "@elizaos/plugin-capacitor-bridge"),
|
|
60
|
+
computerUse: () => import(/* @vite-ignore */ "@elizaos/plugin-computeruse"),
|
|
61
|
+
cloud: () => import(/* @vite-ignore */ "@elizaos/plugin-elizacloud"),
|
|
62
|
+
imessage: () => import(/* @vite-ignore */ "@elizaos/plugin-imessage"),
|
|
63
|
+
mcp: () => import(/* @vite-ignore */ "@elizaos/plugin-mcp"),
|
|
64
|
+
signal: () => import(/* @vite-ignore */ "@elizaos/plugin-signal"),
|
|
65
|
+
streaming: () => import(/* @vite-ignore */ "@elizaos/plugin-streaming"),
|
|
66
|
+
whatsapp: () => import(/* @vite-ignore */ "@elizaos/plugin-whatsapp"),
|
|
67
|
+
workflow: () => import(/* @vite-ignore */ "@elizaos/plugin-workflow"),
|
|
68
|
+
};
|
|
69
|
+
let localInferenceServerApiPromise = null;
|
|
70
|
+
function getLocalInferenceServerApi() {
|
|
71
|
+
// Import the route modules directly, NOT the package's bare entry: the mobile
|
|
72
|
+
// agent bundle stubs `@elizaos/plugin-local-inference` (the heavy Plugin entry)
|
|
73
|
+
// to a null module, so a bare import yields undefined handlers and every
|
|
74
|
+
// /api/local-inference/* route 404s on-device. The deep subpaths (the `./*`
|
|
75
|
+
// wildcard + `./routes` exports) aren't stubbed and carry the real impls on
|
|
76
|
+
// every platform.
|
|
77
|
+
localInferenceServerApiPromise ??=
|
|
78
|
+
(async () => {
|
|
79
|
+
const [routes, ttsRoutes] = await Promise.all([
|
|
80
|
+
import(
|
|
81
|
+
/* @vite-ignore */ "@elizaos/plugin-local-inference/local-inference-routes"),
|
|
82
|
+
import(
|
|
83
|
+
/* @vite-ignore */ "@elizaos/plugin-local-inference/routes"),
|
|
84
|
+
]);
|
|
85
|
+
return {
|
|
86
|
+
getLocalInferenceActiveModelId: routes.getLocalInferenceActiveModelId,
|
|
87
|
+
handleLocalInferenceRoutes: routes.handleLocalInferenceRoutes,
|
|
88
|
+
handleLocalInferenceTtsRoute: ttsRoutes.handleLocalInferenceTtsRoute,
|
|
89
|
+
handleLocalInferenceAsrRoute: ttsRoutes.handleLocalInferenceAsrRoute,
|
|
90
|
+
handleLiveDiarizationRoute: ttsRoutes.handleLiveDiarizationRoute,
|
|
91
|
+
};
|
|
92
|
+
})().catch((err) => {
|
|
93
|
+
// A cold-boot import failure must not poison the memoized promise: `??=`
|
|
94
|
+
// would otherwise cache the rejection and 404 EVERY /api/local-inference/*
|
|
95
|
+
// route for the lifetime of the process. Clear the memo so the next request
|
|
96
|
+
// retries once the deferred plugin closure is resolvable.
|
|
97
|
+
localInferenceServerApiPromise = null;
|
|
98
|
+
throw err;
|
|
99
|
+
});
|
|
100
|
+
return localInferenceServerApiPromise;
|
|
101
|
+
}
|
|
102
|
+
async function getOptionalPluginApi(key) {
|
|
103
|
+
return (await optionalPluginImports[key]());
|
|
104
|
+
}
|
|
105
|
+
let agentSkillsApiPromise;
|
|
106
|
+
function getAgentSkillsApi() {
|
|
107
|
+
agentSkillsApiPromise ??= import(
|
|
108
|
+
/* @vite-ignore */ "@elizaos/plugin-agent-skills");
|
|
109
|
+
return agentSkillsApiPromise;
|
|
110
|
+
}
|
|
111
|
+
let appManagerApiPromise;
|
|
112
|
+
function getAppManagerApi() {
|
|
113
|
+
appManagerApiPromise ??= import(
|
|
114
|
+
/* @vite-ignore */ "@elizaos/plugin-app-manager");
|
|
115
|
+
return appManagerApiPromise;
|
|
116
|
+
}
|
|
117
|
+
let walletApiPromise;
|
|
118
|
+
function getWalletApi() {
|
|
119
|
+
walletApiPromise ??= import(/* @vite-ignore */ "@elizaos/plugin-wallet");
|
|
120
|
+
return walletApiPromise;
|
|
121
|
+
}
|
|
122
|
+
let coreWalletApiPromise;
|
|
123
|
+
function getCoreWalletApi() {
|
|
124
|
+
coreWalletApiPromise ??= import("./wallet.js");
|
|
125
|
+
return coreWalletApiPromise;
|
|
126
|
+
}
|
|
127
|
+
let pluginRegistryApiPromise;
|
|
128
|
+
function getPluginRegistryApi() {
|
|
129
|
+
pluginRegistryApiPromise ??= import(
|
|
130
|
+
/* @vite-ignore */ "@elizaos/plugin-registry");
|
|
131
|
+
return pluginRegistryApiPromise;
|
|
132
|
+
}
|
|
133
|
+
import { getGlobalAwarenessRegistry } from "../awareness/registry.js";
|
|
134
|
+
import { loadElizaConfig, saveElizaConfig, } from "../config/config.js";
|
|
135
|
+
import { isCloudWalletEnabled } from "../config/feature-flags.js";
|
|
136
|
+
import { resolveModelsCacheDir, resolveStateDir } from "../config/paths.js";
|
|
137
|
+
import { CharacterSchema } from "../config/zod-schema.js";
|
|
138
|
+
import { createIntegrationTelemetrySpan } from "../diagnostics/integration-observability.js";
|
|
139
|
+
import { getAgentEventService, } from "../runtime/agent-event-service.js";
|
|
140
|
+
import { resolvePreferredProviderId, resolvePrimaryModel, } from "../runtime/model-resolution.js";
|
|
141
|
+
import { createColdStrategy, createHotStrategy, DefaultRuntimeOperationManager, defaultClassifier, getDefaultHealthChecker, getDefaultRepository, } from "../runtime/operations/index.js";
|
|
142
|
+
import { classifyRegistryPluginRelease } from "../runtime/release-plugin-policy.js";
|
|
143
|
+
import { AUDIT_EVENT_TYPES, AUDIT_SEVERITIES, getAuditFeedSize, queryAuditFeed, subscribeAuditFeed, } from "../security/audit-log.js";
|
|
144
|
+
import { AgentExportError, estimateExportSize, exportAgent, importAgent, } from "../services/agent-export.js";
|
|
145
|
+
import { registerClientChatSendHandler } from "../services/client-chat-sender.js";
|
|
146
|
+
import { createConfigPluginManager } from "../services/config-plugin-manager.js";
|
|
147
|
+
import { isCoreManagerLike, isPluginManagerLike, } from "../services/plugin-manager-types.js";
|
|
148
|
+
import { executeTriggerTask, getTriggerHealthSnapshot, getTriggerLimit, listTriggerTasks, readTriggerConfig, readTriggerRuns, TRIGGER_TASK_NAME, TRIGGER_TASK_TAGS, taskToTriggerSummary, triggersFeatureEnabled, } from "../triggers/runtime.js";
|
|
149
|
+
import { buildTriggerConfig, buildTriggerMetadata, DISABLED_TRIGGER_INTERVAL_MS, normalizeTriggerDraft, } from "../triggers/scheduling.js";
|
|
150
|
+
import { detectRuntimeModel, resolveProviderFromModel } from "./agent-model.js";
|
|
151
|
+
import { persistConfigEnv } from "./config-env.js";
|
|
152
|
+
import { wireCoordinatorBridgesWhenReady } from "./coordinator-wiring.js";
|
|
153
|
+
import { computeCanRespond } from "./health-routes.js";
|
|
154
|
+
import { pushWithBatchEvict } from "./memory-bounds.js";
|
|
155
|
+
import { createRuntimeReadyGate } from "./runtime-ready-gate.js";
|
|
156
|
+
import { cloneWithoutBlockedObjectKeys, decodePathComponent, hasPersistedFirstRunState, isUuidLike, patchTouchesProviderSelection, } from "./server-helpers.js";
|
|
157
|
+
import { createConnectorHealthMonitor, extractConversationMetadataFromRoom, handleAccountsRoutes, handleAgentAdminRoutes, handleAgentLifecycleRoutes, handleAgentStatusRoutes, handleAgentTransferRoutes, handleAppPackageRoutes, handleAuthRoutes, handleAvatarRoutes, handleBackgroundTasksRoute, handleBugReportRoutes, handleCharacterRoutes, handleCloudAndCoreRouteGroup, handleCommandsRoutes, handleConfigRoutes, handleConnectorRoutes, handleConversationRouteGroup, handleDatabaseRouteGroup, handleDiagnosticsRoutes, handleFirstRunRoutes, handleHealthRoutes, handleInboxAndCloudRelayRouteGroup, handleLifeOpsRuntimePluginRoute, handleMemoryRoutes, handleMiscRoutes, handleMobileOptionalRoutes, handleModelsRoutes, handlePermissionRoutes, handlePermissionsExtraRoutes, handleProviderSwitchRoutes, handleRegistryRoutes, handleRelationshipsRoutes, handleRemoteCapabilityRoutes, handleSandboxRouteGroup, handleSubscriptionRoutes, handleSuggestionsRoutes, handleUpdateRoutes, handleViewsRoutes, handleWorkbenchRoutes, isPublicRuntimePluginRoute, registerBuiltinViews, tryHandleHonoRuntimeRoute, tryHandleMusicPlayerStatusFallbackLazy, tryHandleRuntimePluginRoute, } from "./server-lazy-routes.js";
|
|
158
|
+
import { EVM_PLUGIN_PACKAGE, resolveWalletAutomationMode as resolveAgentAutomationModeFromConfig, resolveWalletCapabilityStatus, } from "./wallet-capability.js";
|
|
159
|
+
import { applyWalletRpcConfigUpdate, getStoredWalletRpcSelections, resolveWalletNetworkMode, resolveWalletRpcReadiness, } from "./wallet-rpc.js";
|
|
160
|
+
import { DEFAULT_REPLAY_LIMIT, parseEventCursor, selectReplayEvents, } from "./ws-event-replay.js";
|
|
161
|
+
export { executeFallbackParsedActions, inferBalanceChainFromText, isBalanceIntent, maybeHandleDirectBinanceSkillRequest, parseFallbackActionBlocks, shouldForceCheckBalanceFallback, } from "./binance-skill-helpers.js";
|
|
162
|
+
export { isClientVisibleNoResponse, isNoResponsePlaceholder, stripAssistantStageDirections, } from "./chat-text-helpers.js";
|
|
163
|
+
export { cloneWithoutBlockedObjectKeys, decodePathComponent, findOwnPackageRoot, getErrorMessage, isUuidLike, persistConversationRoomTitle, } from "./server-helpers.js";
|
|
164
|
+
import { getInventoryProviderOptions, getModelOptions, getOrFetchAllProviders, getOrFetchProvider, paramKeyToCategory, providerCachePath, readProviderCache, } from "./model-provider-helpers.js";
|
|
165
|
+
import { AGENT_EVENT_ALLOWED_STREAMS, aggregateSecrets, BLOCKED_ENV_KEYS, CONFIG_WRITE_ALLOWED_TOP_KEYS, discoverInstalledPlugins, discoverPluginsFromManifest, getReleaseBundledPluginIds, maskValue, } from "./plugin-discovery-helpers.js";
|
|
166
|
+
const _nodeRequire = createRequire(import.meta.url);
|
|
167
|
+
// Re-export for downstream consumers (e.g. @elizaos/app-core)
|
|
168
|
+
export { AGENT_EVENT_ALLOWED_STREAMS, CONFIG_WRITE_ALLOWED_TOP_KEYS, discoverInstalledPlugins, discoverPluginsFromManifest, findPrimaryEnvKey, readBundledPluginPackageMetadata, } from "./plugin-discovery-helpers.js";
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
// Types
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
function getAgentEventSvc(runtime) {
|
|
173
|
+
return getAgentEventService(runtime);
|
|
174
|
+
}
|
|
175
|
+
function requirePluginManager(runtime) {
|
|
176
|
+
const service = runtime?.getService("plugin_manager");
|
|
177
|
+
if (!isPluginManagerLike(service)) {
|
|
178
|
+
throw new Error("Plugin manager service not found");
|
|
179
|
+
}
|
|
180
|
+
return wrapPluginManagerWithLocalFallback(service);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The runtime plugin manager's registry client only fetches from GitHub and
|
|
184
|
+
* scans a `plugins/` dir for `elizaos.plugin.json`. Workspace-vendored plugins
|
|
185
|
+
* (under `packages/plugin-*`) are invisible to it. Wrap `installPlugin` so that
|
|
186
|
+
* when it returns "not found in the registry" we retry using our own
|
|
187
|
+
* registry-client (which discovers workspace packages and node_modules symlinks).
|
|
188
|
+
*/
|
|
189
|
+
function wrapPluginManagerWithLocalFallback(pm) {
|
|
190
|
+
const originalInstall = pm.installPlugin.bind(pm);
|
|
191
|
+
const wrapped = Object.create(pm);
|
|
192
|
+
wrapped.installPlugin = async (pluginName, onProgress) => {
|
|
193
|
+
const result = await originalInstall(pluginName, onProgress);
|
|
194
|
+
if (result.success ||
|
|
195
|
+
!result.error?.includes("not found in the registry")) {
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
// Upstream registry missed it — check Eliza's own local discovery.
|
|
199
|
+
const { getPluginInfo } = await import("../services/registry-client.js");
|
|
200
|
+
const localInfo = await getPluginInfo(pluginName);
|
|
201
|
+
if (!localInfo?.localPath) {
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
// The plugin is a workspace package — just return success pointing at it.
|
|
205
|
+
// The runtime already resolves it via NODE_PATH / bun workspace links so
|
|
206
|
+
// there is nothing to download; the caller only needs to enable it in
|
|
207
|
+
// config and restart.
|
|
208
|
+
return {
|
|
209
|
+
success: true,
|
|
210
|
+
pluginName: localInfo.name,
|
|
211
|
+
version: localInfo.npm.v2Version ?? localInfo.npm.v1Version ?? "workspace",
|
|
212
|
+
installPath: localInfo.localPath,
|
|
213
|
+
requiresRestart: true,
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
return wrapped;
|
|
217
|
+
}
|
|
218
|
+
function getPluginManagerForState(state) {
|
|
219
|
+
const service = state.runtime?.getService("plugin_manager");
|
|
220
|
+
if (isPluginManagerLike(service)) {
|
|
221
|
+
return service;
|
|
222
|
+
}
|
|
223
|
+
return createConfigPluginManager(() => state.config);
|
|
224
|
+
}
|
|
225
|
+
function requireCoreManager(runtime) {
|
|
226
|
+
const service = runtime?.getService("core_manager");
|
|
227
|
+
if (!isCoreManagerLike(service)) {
|
|
228
|
+
throw new Error("Core manager service not found");
|
|
229
|
+
}
|
|
230
|
+
return service;
|
|
231
|
+
}
|
|
232
|
+
const DELETED_CONVERSATIONS_FILENAME = "deleted-conversations.v1.json";
|
|
233
|
+
const MAX_DELETED_CONVERSATION_IDS = 5000;
|
|
234
|
+
function readDeletedConversationIdsFromState() {
|
|
235
|
+
const filePath = path.join(resolveStateDir(), DELETED_CONVERSATIONS_FILENAME);
|
|
236
|
+
if (!fs.existsSync(filePath))
|
|
237
|
+
return new Set();
|
|
238
|
+
try {
|
|
239
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
240
|
+
const parsed = JSON.parse(raw);
|
|
241
|
+
const ids = Array.isArray(parsed.ids) ? parsed.ids : [];
|
|
242
|
+
return new Set(ids
|
|
243
|
+
.map((id) => (typeof id === "string" ? id.trim() : ""))
|
|
244
|
+
.filter((id) => id.length > 0));
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
logger.warn(`[eliza-api] Failed to read deleted conversations state: ${err instanceof Error ? err.message : String(err)}`);
|
|
248
|
+
return new Set();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function _persistDeletedConversationIdsToState(ids) {
|
|
252
|
+
const dir = resolveStateDir();
|
|
253
|
+
if (!fs.existsSync(dir)) {
|
|
254
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
255
|
+
}
|
|
256
|
+
const normalized = Array.from(ids)
|
|
257
|
+
.map((id) => id.trim())
|
|
258
|
+
.filter((id) => id.length > 0)
|
|
259
|
+
.slice(-MAX_DELETED_CONVERSATION_IDS);
|
|
260
|
+
const filePath = path.join(dir, DELETED_CONVERSATIONS_FILENAME);
|
|
261
|
+
const tmpFilePath = `${filePath}.${process.pid}.tmp`;
|
|
262
|
+
const payload = {
|
|
263
|
+
version: 1,
|
|
264
|
+
updatedAt: new Date().toISOString(),
|
|
265
|
+
ids: normalized,
|
|
266
|
+
};
|
|
267
|
+
fs.writeFileSync(tmpFilePath, `${JSON.stringify(payload, null, 2)}\n`, {
|
|
268
|
+
encoding: "utf-8",
|
|
269
|
+
mode: 0o600,
|
|
270
|
+
});
|
|
271
|
+
fs.renameSync(tmpFilePath, filePath);
|
|
272
|
+
}
|
|
273
|
+
import { fetchWithTimeoutGuard as _fetchWithTimeoutGuard, streamResponseBodyWithByteLimit as _streamResponseBodyWithByteLimit, isAbortError, responseContentLength, } from "./server-helpers-fetch.js";
|
|
274
|
+
export { fetchWithTimeoutGuard, streamResponseBodyWithByteLimit, } from "./server-helpers-fetch.js";
|
|
275
|
+
const fetchWithTimeoutGuard = _fetchWithTimeoutGuard;
|
|
276
|
+
const streamResponseBodyWithByteLimit = _streamResponseBodyWithByteLimit;
|
|
277
|
+
const STREAMING_PLUGIN_MODULE_ID = ["@elizaos", "plugin-streaming"].join("/");
|
|
278
|
+
function isObjectRecord(value) {
|
|
279
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
280
|
+
}
|
|
281
|
+
function isStreamingPluginDestinationFactories(value) {
|
|
282
|
+
return (isObjectRecord(value) &&
|
|
283
|
+
typeof value.createCustomRtmpDestination === "function" &&
|
|
284
|
+
typeof value.createNamedRtmpDestination === "function" &&
|
|
285
|
+
typeof value.createTwitchDestination === "function" &&
|
|
286
|
+
typeof value.createYoutubeDestination === "function" &&
|
|
287
|
+
typeof value.createPumpfunDestination === "function" &&
|
|
288
|
+
typeof value.createXStreamDestination === "function");
|
|
289
|
+
}
|
|
290
|
+
async function loadStreamingPluginDestinationFactories() {
|
|
291
|
+
const moduleValue = await import(__rewriteRelativeImportExtension(STREAMING_PLUGIN_MODULE_ID));
|
|
292
|
+
if (!isStreamingPluginDestinationFactories(moduleValue)) {
|
|
293
|
+
throw new Error("missing destination factory exports");
|
|
294
|
+
}
|
|
295
|
+
return moduleValue;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Read and parse a JSON request body with size limits and error handling.
|
|
299
|
+
* Returns null (and sends a 4xx response) if reading or parsing fails.
|
|
300
|
+
*/
|
|
301
|
+
async function readJsonBody(req, res, options = {}) {
|
|
302
|
+
return parseJsonBody(req, res, {
|
|
303
|
+
maxBytes: MAX_BODY_BYTES,
|
|
304
|
+
...options,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const readBody = (req) => readRequestBody(req, { maxBytes: MAX_BODY_BYTES }).then((value) => value ?? "");
|
|
308
|
+
let activeTerminalRunCount = 0;
|
|
309
|
+
function json(res, data, status = 200) {
|
|
310
|
+
sendJson(res, data, status);
|
|
311
|
+
}
|
|
312
|
+
function error(res, message, status = 400) {
|
|
313
|
+
sendJsonError(res, message, status);
|
|
314
|
+
}
|
|
315
|
+
function emptyTrainingTaskCounters() {
|
|
316
|
+
return {
|
|
317
|
+
should_respond: 0,
|
|
318
|
+
context_routing: 0,
|
|
319
|
+
action_planner: 0,
|
|
320
|
+
response: 0,
|
|
321
|
+
media_description: 0,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
const TRAINING_CONFIG_MODULE = "@elizaos/plugin-training";
|
|
325
|
+
function defaultTrainingConfig() {
|
|
326
|
+
return {
|
|
327
|
+
autoTrain: true,
|
|
328
|
+
triggerThreshold: 100,
|
|
329
|
+
triggerCooldownHours: 12,
|
|
330
|
+
backends: ["native"],
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
async function loadOptionalTrainingConfigApi() {
|
|
334
|
+
try {
|
|
335
|
+
const loaded = (await import(__rewriteRelativeImportExtension(
|
|
336
|
+
/* @vite-ignore */ TRAINING_CONFIG_MODULE)));
|
|
337
|
+
if (typeof loaded.loadTrainingConfig === "function" &&
|
|
338
|
+
typeof loaded.normalizeTrainingConfig === "function" &&
|
|
339
|
+
typeof loaded.saveTrainingConfig === "function") {
|
|
340
|
+
return loaded;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
// app-training is optional in this server path.
|
|
345
|
+
}
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
async function readOptionalTrainingConfig() {
|
|
349
|
+
const api = await loadOptionalTrainingConfigApi();
|
|
350
|
+
return api?.loadTrainingConfig() ?? defaultTrainingConfig();
|
|
351
|
+
}
|
|
352
|
+
function parseBrowserBridgeKind(browserPlugin, value) {
|
|
353
|
+
if (!value)
|
|
354
|
+
return null;
|
|
355
|
+
const decoded = decodeURIComponent(value);
|
|
356
|
+
return browserPlugin.BROWSER_BRIDGE_KINDS.includes(decoded)
|
|
357
|
+
? decoded
|
|
358
|
+
: null;
|
|
359
|
+
}
|
|
360
|
+
function parseBrowserBridgePackageTarget(browserPlugin, value) {
|
|
361
|
+
return typeof value === "string" &&
|
|
362
|
+
browserPlugin.BROWSER_BRIDGE_PACKAGE_PATH_TARGETS.includes(value)
|
|
363
|
+
? value
|
|
364
|
+
: null;
|
|
365
|
+
}
|
|
366
|
+
async function handleBuiltinOptionalRoutes(req, res, pathname, method) {
|
|
367
|
+
if (method === "GET" && pathname === "/api/wallet/steward-status") {
|
|
368
|
+
const { getWalletAddresses } = await getCoreWalletApi();
|
|
369
|
+
const addresses = getWalletAddresses();
|
|
370
|
+
json(res, {
|
|
371
|
+
configured: false,
|
|
372
|
+
available: false,
|
|
373
|
+
connected: false,
|
|
374
|
+
error: "Steward wallet service is not loaded.",
|
|
375
|
+
walletAddresses: {
|
|
376
|
+
evm: addresses.evmAddress ?? null,
|
|
377
|
+
solana: addresses.solanaAddress ?? null,
|
|
378
|
+
},
|
|
379
|
+
evmAddress: addresses.evmAddress ?? undefined,
|
|
380
|
+
vaultHealth: "degraded",
|
|
381
|
+
});
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
if (method === "GET" && pathname === "/api/training/auto/config") {
|
|
385
|
+
json(res, { config: await readOptionalTrainingConfig() });
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
if (method === "POST" && pathname === "/api/training/auto/config") {
|
|
389
|
+
const body = (await readJsonBody(req, res)) ?? null;
|
|
390
|
+
if (!body)
|
|
391
|
+
return true;
|
|
392
|
+
const api = await loadOptionalTrainingConfigApi();
|
|
393
|
+
const currentConfig = api?.loadTrainingConfig() ?? defaultTrainingConfig();
|
|
394
|
+
const config = api
|
|
395
|
+
? api.normalizeTrainingConfig({
|
|
396
|
+
...currentConfig,
|
|
397
|
+
...body,
|
|
398
|
+
})
|
|
399
|
+
: currentConfig;
|
|
400
|
+
api?.saveTrainingConfig(config);
|
|
401
|
+
json(res, { config });
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
if (method === "GET" && pathname === "/api/training/auto/status") {
|
|
405
|
+
const config = await readOptionalTrainingConfig();
|
|
406
|
+
json(res, {
|
|
407
|
+
autoTrainEnabled: config.autoTrain,
|
|
408
|
+
triggerThreshold: config.triggerThreshold,
|
|
409
|
+
cooldownHours: config.triggerCooldownHours,
|
|
410
|
+
counters: emptyTrainingTaskCounters(),
|
|
411
|
+
lastTrain: {},
|
|
412
|
+
perTaskThresholds: emptyTrainingTaskCounters(),
|
|
413
|
+
perTaskCooldownMs: emptyTrainingTaskCounters(),
|
|
414
|
+
serviceRegistered: false,
|
|
415
|
+
});
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
if (pathname === "/api/lifeops/activity-signals") {
|
|
419
|
+
if (method === "GET") {
|
|
420
|
+
json(res, { signals: [] });
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
if (method === "POST") {
|
|
424
|
+
await readBody(req).catch(() => undefined);
|
|
425
|
+
json(res, {
|
|
426
|
+
ok: true,
|
|
427
|
+
stored: false,
|
|
428
|
+
reason: "lifeops_route_unavailable",
|
|
429
|
+
});
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (method === "GET" && pathname === "/api/voice/profiles") {
|
|
434
|
+
json(res, { profiles: [] });
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
if (method === "GET" && pathname === "/api/discord-local/status") {
|
|
438
|
+
json(res, {
|
|
439
|
+
available: false,
|
|
440
|
+
connected: false,
|
|
441
|
+
authenticated: false,
|
|
442
|
+
currentUser: null,
|
|
443
|
+
subscribedChannelIds: [],
|
|
444
|
+
configuredChannelIds: [],
|
|
445
|
+
scopes: [],
|
|
446
|
+
lastError: null,
|
|
447
|
+
ipcPath: null,
|
|
448
|
+
});
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
if (method === "GET" &&
|
|
452
|
+
pathname === "/api/lifeops/connectors/imessage/status") {
|
|
453
|
+
json(res, {
|
|
454
|
+
available: false,
|
|
455
|
+
connected: false,
|
|
456
|
+
bridgeType: "none",
|
|
457
|
+
hostPlatform: process.platform,
|
|
458
|
+
diagnostics: [],
|
|
459
|
+
error: null,
|
|
460
|
+
chatDbAvailable: false,
|
|
461
|
+
sendOnly: false,
|
|
462
|
+
reason: "lifeops_route_unavailable",
|
|
463
|
+
permissionAction: null,
|
|
464
|
+
});
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
if (method === "GET" && pathname === "/api/signal/status") {
|
|
468
|
+
const requestUrl = new URL(req.url ?? pathname, "http://localhost");
|
|
469
|
+
const accountId = requestUrl.searchParams.get("accountId") || "default";
|
|
470
|
+
json(res, {
|
|
471
|
+
accountId,
|
|
472
|
+
status: "idle",
|
|
473
|
+
authExists: false,
|
|
474
|
+
serviceConnected: false,
|
|
475
|
+
qrDataUrl: null,
|
|
476
|
+
phoneNumber: null,
|
|
477
|
+
error: null,
|
|
478
|
+
});
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
if (method === "GET" && pathname === "/api/setup/telegram-account/status") {
|
|
482
|
+
json(res, {
|
|
483
|
+
connector: "telegram-account",
|
|
484
|
+
state: "idle",
|
|
485
|
+
detail: {
|
|
486
|
+
status: "idle",
|
|
487
|
+
configured: false,
|
|
488
|
+
sessionExists: false,
|
|
489
|
+
serviceConnected: false,
|
|
490
|
+
restartRequired: false,
|
|
491
|
+
hasAppCredentials: false,
|
|
492
|
+
phone: null,
|
|
493
|
+
isCodeViaApp: false,
|
|
494
|
+
account: null,
|
|
495
|
+
error: null,
|
|
496
|
+
},
|
|
497
|
+
});
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
if (method === "GET" && pathname === "/api/whatsapp/status") {
|
|
501
|
+
const requestUrl = new URL(req.url ?? pathname, "http://localhost");
|
|
502
|
+
const accountId = requestUrl.searchParams.get("accountId") || "default";
|
|
503
|
+
const authScope = requestUrl.searchParams.get("authScope");
|
|
504
|
+
json(res, {
|
|
505
|
+
accountId,
|
|
506
|
+
...(authScope === "platform" || authScope === "lifeops"
|
|
507
|
+
? { authScope }
|
|
508
|
+
: {}),
|
|
509
|
+
status: "idle",
|
|
510
|
+
authExists: false,
|
|
511
|
+
serviceConnected: false,
|
|
512
|
+
servicePhone: null,
|
|
513
|
+
});
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
if (method === "GET" && pathname === "/api/coding-agents/preflight") {
|
|
517
|
+
json(res, { installed: [], available: false });
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
if (method === "GET" &&
|
|
521
|
+
pathname === "/api/coding-agents/coordinator/status") {
|
|
522
|
+
json(res, {
|
|
523
|
+
supervisionLevel: "unavailable",
|
|
524
|
+
taskCount: 0,
|
|
525
|
+
tasks: [],
|
|
526
|
+
pendingConfirmations: 0,
|
|
527
|
+
taskThreadCount: 0,
|
|
528
|
+
taskThreads: [],
|
|
529
|
+
frameworks: [],
|
|
530
|
+
});
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
if (method === "GET" && pathname === "/api/browser-bridge/companions") {
|
|
534
|
+
json(res, { companions: [] });
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
if (method === "GET" && pathname === "/api/browser-bridge/packages") {
|
|
538
|
+
const browserPlugin = await getBrowserPlugin();
|
|
539
|
+
json(res, {
|
|
540
|
+
status: browserPlugin.getBrowserBridgeCompanionPackageStatus(),
|
|
541
|
+
});
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
if (method === "POST" &&
|
|
545
|
+
pathname === "/api/browser-bridge/packages/open-path") {
|
|
546
|
+
const body = (await readJsonBody(req, res)) ?? null;
|
|
547
|
+
if (!body)
|
|
548
|
+
return true;
|
|
549
|
+
const browserPlugin = await getBrowserPlugin();
|
|
550
|
+
const target = parseBrowserBridgePackageTarget(browserPlugin, body.target);
|
|
551
|
+
if (!target) {
|
|
552
|
+
error(res, "Invalid browser bridge package target", 400);
|
|
553
|
+
return true;
|
|
554
|
+
}
|
|
555
|
+
json(res, await browserPlugin.openBrowserBridgeCompanionPackagePath(target, {
|
|
556
|
+
revealOnly: body.revealOnly === true,
|
|
557
|
+
}));
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
const packageBuildMatch = pathname.match(/^\/api\/browser-bridge\/packages\/([^/]+)\/build$/);
|
|
561
|
+
if (method === "POST" && packageBuildMatch) {
|
|
562
|
+
const browserPlugin = await getBrowserPlugin();
|
|
563
|
+
const browser = parseBrowserBridgeKind(browserPlugin, packageBuildMatch[1]);
|
|
564
|
+
if (!browser) {
|
|
565
|
+
error(res, "Invalid browser bridge package browser", 400);
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
568
|
+
json(res, {
|
|
569
|
+
status: await browserPlugin.buildBrowserBridgeCompanionPackage(browser),
|
|
570
|
+
});
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
573
|
+
const packageManagerMatch = pathname.match(/^\/api\/browser-bridge\/packages\/([^/]+)\/open-manager$/);
|
|
574
|
+
if (method === "POST" && packageManagerMatch) {
|
|
575
|
+
const browserPlugin = await getBrowserPlugin();
|
|
576
|
+
const browser = parseBrowserBridgeKind(browserPlugin, packageManagerMatch[1]);
|
|
577
|
+
if (!browser) {
|
|
578
|
+
error(res, "Invalid browser bridge package browser", 400);
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
json(res, await browserPlugin.openBrowserBridgeCompanionManager(browser));
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
if (pathname === "/api/browser-workspace" && method === "GET") {
|
|
585
|
+
const browserPlugin = await getBrowserPlugin();
|
|
586
|
+
json(res, await browserPlugin.getBrowserWorkspaceSnapshot());
|
|
587
|
+
return true;
|
|
588
|
+
}
|
|
589
|
+
if (pathname === "/api/browser-workspace/command" && method === "POST") {
|
|
590
|
+
const browserPlugin = await getBrowserPlugin();
|
|
591
|
+
const body = (await readJsonBody(req, res)) ?? null;
|
|
592
|
+
if (!body?.subaction) {
|
|
593
|
+
error(res, "subaction is required", 400);
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
json(res, await browserPlugin.executeBrowserWorkspaceCommand(body));
|
|
597
|
+
return true;
|
|
598
|
+
}
|
|
599
|
+
if (pathname === "/api/browser-workspace/tabs" && method === "GET") {
|
|
600
|
+
const browserPlugin = await getBrowserPlugin();
|
|
601
|
+
json(res, { tabs: await browserPlugin.listBrowserWorkspaceTabs() });
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
604
|
+
if (pathname === "/api/browser-workspace/tabs" && method === "POST") {
|
|
605
|
+
const browserPlugin = await getBrowserPlugin();
|
|
606
|
+
const body = (await readJsonBody(req, res)) ?? {};
|
|
607
|
+
json(res, { tab: await browserPlugin.openBrowserWorkspaceTab(body) });
|
|
608
|
+
return true;
|
|
609
|
+
}
|
|
610
|
+
const tabMatch = pathname.match(/^\/api\/browser-workspace\/tabs\/([^/]+)(?:\/(navigate|eval|show|hide|snapshot))?$/);
|
|
611
|
+
if (!tabMatch) {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
const tabId = decodeURIComponent(tabMatch[1]).trim();
|
|
615
|
+
const action = tabMatch[2] ?? null;
|
|
616
|
+
if (!action && method === "DELETE") {
|
|
617
|
+
const browserPlugin = await getBrowserPlugin();
|
|
618
|
+
const closed = await browserPlugin.closeBrowserWorkspaceTab(tabId);
|
|
619
|
+
json(res, { closed }, closed ? 200 : 404);
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
if (action === "show" && method === "POST") {
|
|
623
|
+
const browserPlugin = await getBrowserPlugin();
|
|
624
|
+
json(res, { tab: await browserPlugin.showBrowserWorkspaceTab(tabId) });
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
if (action === "hide" && method === "POST") {
|
|
628
|
+
const browserPlugin = await getBrowserPlugin();
|
|
629
|
+
json(res, { tab: await browserPlugin.hideBrowserWorkspaceTab(tabId) });
|
|
630
|
+
return true;
|
|
631
|
+
}
|
|
632
|
+
if (action === "snapshot" && method === "GET") {
|
|
633
|
+
const browserPlugin = await getBrowserPlugin();
|
|
634
|
+
json(res, await browserPlugin.snapshotBrowserWorkspaceTab(tabId));
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
if (action === "navigate" && method === "POST") {
|
|
638
|
+
const browserPlugin = await getBrowserPlugin();
|
|
639
|
+
const body = (await readJsonBody(req, res)) ??
|
|
640
|
+
null;
|
|
641
|
+
if (!body?.url) {
|
|
642
|
+
error(res, "url is required", 400);
|
|
643
|
+
return true;
|
|
644
|
+
}
|
|
645
|
+
json(res, {
|
|
646
|
+
tab: await browserPlugin.navigateBrowserWorkspaceTab({
|
|
647
|
+
id: tabId,
|
|
648
|
+
url: body.url,
|
|
649
|
+
}),
|
|
650
|
+
});
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
if (action === "eval" && method === "POST") {
|
|
654
|
+
const browserPlugin = await getBrowserPlugin();
|
|
655
|
+
const body = (await readJsonBody(req, res)) ??
|
|
656
|
+
null;
|
|
657
|
+
if (!body?.script) {
|
|
658
|
+
error(res, "script is required", 400);
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
json(res, {
|
|
662
|
+
value: await browserPlugin.evaluateBrowserWorkspaceTab({
|
|
663
|
+
id: tabId,
|
|
664
|
+
script: body.script,
|
|
665
|
+
}),
|
|
666
|
+
});
|
|
667
|
+
return true;
|
|
668
|
+
}
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
// ---------------------------------------------------------------------------
|
|
672
|
+
import { serveMediaFile } from "./media-store.js";
|
|
673
|
+
import { injectApiBaseIntoHtml, isAuthProtectedRoute, serveStaticUi, } from "./static-file-server.js";
|
|
674
|
+
export { injectApiBaseIntoHtml };
|
|
675
|
+
function coerce(value) {
|
|
676
|
+
return value;
|
|
677
|
+
}
|
|
678
|
+
function parseBoundedLimit(rawLimit, fallback = 15) {
|
|
679
|
+
return parseClampedInteger(rawLimit, {
|
|
680
|
+
min: 1,
|
|
681
|
+
max: 50,
|
|
682
|
+
fallback,
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function sanitizeFavoriteAppList(value) {
|
|
686
|
+
if (!Array.isArray(value))
|
|
687
|
+
return [];
|
|
688
|
+
const seen = new Set();
|
|
689
|
+
const apps = [];
|
|
690
|
+
for (const item of value) {
|
|
691
|
+
if (typeof item !== "string")
|
|
692
|
+
continue;
|
|
693
|
+
const trimmed = item.trim();
|
|
694
|
+
if (!trimmed || seen.has(trimmed))
|
|
695
|
+
continue;
|
|
696
|
+
seen.add(trimmed);
|
|
697
|
+
apps.push(trimmed);
|
|
698
|
+
}
|
|
699
|
+
return apps;
|
|
700
|
+
}
|
|
701
|
+
function readFavoriteAppsFromConfig(config) {
|
|
702
|
+
const ui = (config.ui ?? {});
|
|
703
|
+
return sanitizeFavoriteAppList(ui.favoriteApps);
|
|
704
|
+
}
|
|
705
|
+
function writeFavoriteAppsToConfig(config, apps) {
|
|
706
|
+
const sanitized = sanitizeFavoriteAppList(apps);
|
|
707
|
+
const ui = (config.ui ?? {});
|
|
708
|
+
ui.favoriteApps = sanitized;
|
|
709
|
+
config.ui = ui;
|
|
710
|
+
saveElizaConfig(config);
|
|
711
|
+
return sanitized;
|
|
712
|
+
}
|
|
713
|
+
const isBlockedObjectKey = isBlockedObjectKeyFromConfig;
|
|
714
|
+
import { resolveMcpServersRejection as _resolveMcpServersRejection, resolveMcpTerminalAuthorizationRejection as _resolveMcpTerminalAuthorizationRejection, } from "./server-helpers-mcp.js";
|
|
715
|
+
export { resolveMcpServersRejection, resolveMcpTerminalAuthorizationRejection, validateMcpServerConfig, } from "./server-helpers-mcp.js";
|
|
716
|
+
const resolveMcpServersRejection = _resolveMcpServersRejection;
|
|
717
|
+
import { pickRandomNames } from "../runtime/first-run-names.js";
|
|
718
|
+
import { resolveDefaultAgentWorkspaceDir } from "../shared/workspace-resolution.js";
|
|
719
|
+
import { applyFirstRunVoicePreset, ensureWalletKeysInEnvAndConfig, getCloudProviderOptions, getProviderOptions, isBlockedObjectKey as isBlockedObjectKeyFromConfig, isRedactedSecretValue, readUiLanguageHeader, redactConfigSecrets, redactDeep, resolveConfiguredCharacterLanguage, resolveDefaultAgentName, stripRedactedPlaceholderValuesDeep, } from "./server-helpers-config.js";
|
|
720
|
+
export { isSafeResetStateDir } from "./server-helpers-config.js";
|
|
721
|
+
// ---------------------------------------------------------------------------
|
|
722
|
+
// Trade permission helpers (exported for use by awareness contributors)
|
|
723
|
+
// ---------------------------------------------------------------------------
|
|
724
|
+
/**
|
|
725
|
+
* Resolve the active trade permission mode from config.
|
|
726
|
+
* Falls back to "user-sign-only" when not configured.
|
|
727
|
+
*/
|
|
728
|
+
export function resolveTradePermissionMode(config) {
|
|
729
|
+
const raw = config.features
|
|
730
|
+
?.tradePermissionMode;
|
|
731
|
+
if (raw === "user-sign-only" ||
|
|
732
|
+
raw === "manual-local-key" ||
|
|
733
|
+
raw === "agent-auto") {
|
|
734
|
+
return raw;
|
|
735
|
+
}
|
|
736
|
+
return "user-sign-only";
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Maximum number of autonomous agent trades allowed per calendar day.
|
|
740
|
+
* Acts as a safety rail when `agent-auto` mode is enabled.
|
|
741
|
+
*/
|
|
742
|
+
// Trade safety utilities (defined in trade-safety.ts for testability)
|
|
743
|
+
import { canUseLocalTradeExecution, } from "./trade-safety.js";
|
|
744
|
+
export { AGENT_AUTO_MAX_DAILY_TRADES, agentAutoDailyTrades, assertQuoteFresh, canUseLocalTradeExecution, getAgentAutoTradeDate, QUOTE_MAX_AGE_MS, recordAgentAutoTrade, } from "./trade-safety.js";
|
|
745
|
+
const AGENT_AUTOMATION_HEADER = "x-eliza-agent-action";
|
|
746
|
+
const AGENT_AUTOMATION_MODES = new Set([
|
|
747
|
+
"connectors-only",
|
|
748
|
+
"full",
|
|
749
|
+
]);
|
|
750
|
+
function parseAgentAutomationMode(value) {
|
|
751
|
+
if (typeof value !== "string")
|
|
752
|
+
return null;
|
|
753
|
+
const normalized = value.trim().toLowerCase();
|
|
754
|
+
if (!AGENT_AUTOMATION_MODES.has(normalized)) {
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
return normalized;
|
|
758
|
+
}
|
|
759
|
+
function _isAgentAutomationRequest(req) {
|
|
760
|
+
const raw = req.headers[AGENT_AUTOMATION_HEADER];
|
|
761
|
+
if (typeof raw !== "string")
|
|
762
|
+
return false;
|
|
763
|
+
return /^(1|true|yes|agent)$/i.test(raw.trim());
|
|
764
|
+
}
|
|
765
|
+
function persistAgentAutomationMode(state, mode) {
|
|
766
|
+
state.agentAutomationMode = mode;
|
|
767
|
+
if (!state.config.features) {
|
|
768
|
+
state.config.features = {};
|
|
769
|
+
}
|
|
770
|
+
const features = state.config.features;
|
|
771
|
+
const current = features.agentAutomation;
|
|
772
|
+
const currentObject = current && typeof current === "object" && !Array.isArray(current)
|
|
773
|
+
? current
|
|
774
|
+
: {};
|
|
775
|
+
features.agentAutomation = {
|
|
776
|
+
...currentObject,
|
|
777
|
+
enabled: true,
|
|
778
|
+
mode,
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
function buildPluginEvmDiagnosticEntry(state) {
|
|
782
|
+
const capability = resolveWalletCapabilityStatus(state);
|
|
783
|
+
const enabled = capability.pluginEvmLoaded ||
|
|
784
|
+
capability.pluginEvmRequired ||
|
|
785
|
+
(state.config.plugins?.allow ?? []).some((entry) => {
|
|
786
|
+
return (entry === EVM_PLUGIN_PACKAGE || entry === "evm" || entry === "wallet");
|
|
787
|
+
});
|
|
788
|
+
const capabilityStatus = capability.pluginEvmLoaded
|
|
789
|
+
? capability.pluginEvmRequired
|
|
790
|
+
? "loaded"
|
|
791
|
+
: "auto-enabled"
|
|
792
|
+
: enabled
|
|
793
|
+
? capability.evmAddress || capability.localSignerAvailable
|
|
794
|
+
? "blocked"
|
|
795
|
+
: "missing-prerequisites"
|
|
796
|
+
: "disabled";
|
|
797
|
+
return {
|
|
798
|
+
id: "evm",
|
|
799
|
+
name: "Plugin EVM",
|
|
800
|
+
description: "EVM wallet runtime for balance, transfer, and trade actions. Required for wallet execution in chat.",
|
|
801
|
+
tags: ["wallet", "evm", "bsc", "onchain"],
|
|
802
|
+
enabled,
|
|
803
|
+
configured: capability.pluginEvmRequired,
|
|
804
|
+
envKey: "EVM_PRIVATE_KEY",
|
|
805
|
+
category: "feature",
|
|
806
|
+
source: "bundled",
|
|
807
|
+
configKeys: [
|
|
808
|
+
"EVM_PRIVATE_KEY",
|
|
809
|
+
"BSC_RPC_URL",
|
|
810
|
+
"BSC_TESTNET_RPC_URL",
|
|
811
|
+
"ELIZA_WALLET_NETWORK",
|
|
812
|
+
],
|
|
813
|
+
parameters: [],
|
|
814
|
+
validationErrors: [],
|
|
815
|
+
validationWarnings: [],
|
|
816
|
+
npmName: EVM_PLUGIN_PACKAGE,
|
|
817
|
+
isActive: capability.pluginEvmLoaded,
|
|
818
|
+
autoEnabled: capability.pluginEvmRequired && !capability.pluginEvmLoaded,
|
|
819
|
+
managementMode: "core-optional",
|
|
820
|
+
capabilityStatus,
|
|
821
|
+
capabilityReason: capability.executionReady
|
|
822
|
+
? "Wallet execution is ready."
|
|
823
|
+
: capability.executionBlockedReason,
|
|
824
|
+
prerequisites: [
|
|
825
|
+
{ label: "wallet present", met: Boolean(capability.evmAddress) },
|
|
826
|
+
{ label: "rpc ready", met: capability.rpcReady },
|
|
827
|
+
{ label: "plugin loaded", met: capability.pluginEvmLoaded },
|
|
828
|
+
],
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
import { resolveWalletExportRejection as _resolveWalletExportRejection } from "./server-helpers-wallet.js";
|
|
832
|
+
export { hasUsableWalletFallbackParams, inferWalletExecutionFallback, resolveWalletExportRejection, } from "./server-helpers-wallet.js";
|
|
833
|
+
const resolveWalletExportRejection = _resolveWalletExportRejection;
|
|
834
|
+
import { resolvePluginConfigMutationRejections as _resolvePluginConfigMutationRejections } from "./server-helpers-plugin.js";
|
|
835
|
+
export { resolvePluginConfigMutationRejections, resolvePluginConfigReply, } from "./server-helpers-plugin.js";
|
|
836
|
+
const resolvePluginConfigMutationRejections = _resolvePluginConfigMutationRejections;
|
|
837
|
+
const TRAINING_SERVICE_REGISTRY_MODULE = "@elizaos/plugin-training";
|
|
838
|
+
async function resolveTrainingServiceCtor() {
|
|
839
|
+
if (isMobilePlatform()) {
|
|
840
|
+
logger.info("[eliza-api] Training service disabled on mobile platform");
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
const candidates = [
|
|
844
|
+
"../services/training-service",
|
|
845
|
+
"@elizaos/plugin-training",
|
|
846
|
+
"@elizaos/plugin-training",
|
|
847
|
+
];
|
|
848
|
+
for (const specifier of candidates) {
|
|
849
|
+
try {
|
|
850
|
+
const loaded = (await import(__rewriteRelativeImportExtension(/* @vite-ignore */ specifier)));
|
|
851
|
+
const ctor = loaded.TrainingService;
|
|
852
|
+
if (typeof ctor === "function") {
|
|
853
|
+
return ctor;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
catch {
|
|
857
|
+
// Keep trying fallbacks.
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
return null;
|
|
861
|
+
}
|
|
862
|
+
async function setActiveTrainingServiceIfAvailable(service) {
|
|
863
|
+
try {
|
|
864
|
+
const loaded = (await import(__rewriteRelativeImportExtension(
|
|
865
|
+
/* @vite-ignore */ TRAINING_SERVICE_REGISTRY_MODULE)));
|
|
866
|
+
loaded.setActiveTrainingService?.(service);
|
|
867
|
+
}
|
|
868
|
+
catch (err) {
|
|
869
|
+
logger.debug(`[eliza-api] Training service registry unavailable: ${err instanceof Error ? err.message : String(err)}`);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
const resolveMcpTerminalAuthorizationRejection = _resolveMcpTerminalAuthorizationRejection;
|
|
873
|
+
import { applyCors as _applyCors, clearPairing as _clearPairing, ensureApiTokenForBindHost as _ensureApiTokenForBindHost, ensurePairingCode as _ensurePairingCode, getConfiguredApiToken as _getConfiguredApiToken, getPairingExpiresAt as _getPairingExpiresAt, isAllowedHost as _isAllowedHost, isAuthorized as _isAuthorized, isSharedTerminalClientId as _isSharedTerminalClientId, isWaifuChatAuthorized as _isWaifuChatAuthorized, isWebSocketAuthorized as _isWebSocketAuthorized, normalizePairingCode as _normalizePairingCode, normalizeWsClientId as _normalizeWsClientId, pairingEnabled as _pairingEnabled, rateLimitPairing as _rateLimitPairing, rejectWebSocketUpgrade as _rejectWebSocketUpgrade, resolveTerminalRunClientId as _resolveTerminalRunClientId, resolveTerminalRunRejection as _resolveTerminalRunRejection, resolveWebSocketUpgradeRejection as _resolveWebSocketUpgradeRejection, } from "./server-helpers-auth.js";
|
|
874
|
+
export { ensureApiTokenForBindHost, extractAuthToken, isAllowedHost, isAuthorized, isWaifuChatAuthorized, normalizeWsClientId, resolveCorsOrigin, resolveTerminalRunClientId, resolveTerminalRunRejection, resolveWebSocketUpgradeRejection, } from "./server-helpers-auth.js";
|
|
875
|
+
const isAllowedHost = _isAllowedHost;
|
|
876
|
+
const applyCors = _applyCors;
|
|
877
|
+
const isAuthorized = _isAuthorized;
|
|
878
|
+
const isWaifuChatAuthorized = _isWaifuChatAuthorized;
|
|
879
|
+
const ensureApiTokenForBindHost = _ensureApiTokenForBindHost;
|
|
880
|
+
const normalizeWsClientId = _normalizeWsClientId;
|
|
881
|
+
const resolveTerminalRunClientId = _resolveTerminalRunClientId;
|
|
882
|
+
const isSharedTerminalClientId = _isSharedTerminalClientId;
|
|
883
|
+
const resolveTerminalRunRejection = _resolveTerminalRunRejection;
|
|
884
|
+
const resolveWebSocketUpgradeRejection = _resolveWebSocketUpgradeRejection;
|
|
885
|
+
const rejectWebSocketUpgrade = _rejectWebSocketUpgrade;
|
|
886
|
+
const isWebSocketAuthorized = _isWebSocketAuthorized;
|
|
887
|
+
const getConfiguredApiToken = _getConfiguredApiToken;
|
|
888
|
+
const pairingEnabled = _pairingEnabled;
|
|
889
|
+
const ensurePairingCode = _ensurePairingCode;
|
|
890
|
+
const normalizePairingCode = _normalizePairingCode;
|
|
891
|
+
const rateLimitPairing = _rateLimitPairing;
|
|
892
|
+
const getPairingExpiresAt = _getPairingExpiresAt;
|
|
893
|
+
const clearPairing = _clearPairing;
|
|
894
|
+
/**
|
|
895
|
+
* Lazy per-process runtime operation manager. Constructed on first
|
|
896
|
+
* request because it needs the per-server `state` reference + the
|
|
897
|
+
* `onRestart` closure. Cached so subsequent requests see the same
|
|
898
|
+
* active-op slot and execution chain.
|
|
899
|
+
*/
|
|
900
|
+
let cachedRuntimeOperationManager = null;
|
|
901
|
+
function getOrCreateRuntimeOperationManager(state, restartRuntime) {
|
|
902
|
+
if (cachedRuntimeOperationManager) {
|
|
903
|
+
return cachedRuntimeOperationManager;
|
|
904
|
+
}
|
|
905
|
+
const repository = getDefaultRepository();
|
|
906
|
+
const healthChecker = getDefaultHealthChecker();
|
|
907
|
+
const coldStrategy = createColdStrategy({
|
|
908
|
+
restartRuntime: async (reason) => {
|
|
909
|
+
const ok = await restartRuntime(reason);
|
|
910
|
+
if (!ok)
|
|
911
|
+
return null;
|
|
912
|
+
return state.runtime;
|
|
913
|
+
},
|
|
914
|
+
});
|
|
915
|
+
const hotStrategy = createHotStrategy({});
|
|
916
|
+
const classifyContext = () => ({
|
|
917
|
+
currentProvider: resolvePreferredProviderId(state.config),
|
|
918
|
+
currentPrimaryModel: resolvePrimaryModel(state.config),
|
|
919
|
+
});
|
|
920
|
+
cachedRuntimeOperationManager = new DefaultRuntimeOperationManager({
|
|
921
|
+
repository,
|
|
922
|
+
runtime: () => state.runtime,
|
|
923
|
+
classifyContext,
|
|
924
|
+
classifier: defaultClassifier,
|
|
925
|
+
healthChecker,
|
|
926
|
+
strategies: { cold: coldStrategy, hot: hotStrategy },
|
|
927
|
+
});
|
|
928
|
+
return cachedRuntimeOperationManager;
|
|
929
|
+
}
|
|
930
|
+
import { isLifeOpsCloudPluginRoute, maybeRouteAutonomyEventToConversation, } from "./server-autonomy-helpers.js";
|
|
931
|
+
import { getPtyConsoleBridge, wireCodingAgentChatBridge, wireCodingAgentSwarmSynthesis, wireCodingAgentWsBridge, wireCoordinatorEventRouting, } from "./server-helpers-swarm.js";
|
|
932
|
+
import { asObject, normalizeTags, parseNullableNumber, readTaskCompleted, readTaskMetadata, toWorkbenchTodo, } from "./workbench-helpers.js";
|
|
933
|
+
export { handleSwarmSynthesis, routeAutonomyTextToUser, } from "./server-helpers-swarm.js";
|
|
934
|
+
async function handleRequest(req, res, state, ctx) {
|
|
935
|
+
const method = req.method ?? "GET";
|
|
936
|
+
let url;
|
|
937
|
+
try {
|
|
938
|
+
url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
939
|
+
}
|
|
940
|
+
catch {
|
|
941
|
+
error(res, "Invalid request URL", 400);
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
const pathname = url.pathname;
|
|
945
|
+
const isAuthEndpoint = pathname.startsWith("/api/auth/");
|
|
946
|
+
const isHealthEndpoint = method === "GET" && pathname === "/api/health";
|
|
947
|
+
let isCloudProvisionedContainer = () => false;
|
|
948
|
+
let handleCloudStatusRoutes = async (_args) => false;
|
|
949
|
+
if (pathname === "/api/first-run/status" ||
|
|
950
|
+
pathname.startsWith("/api/cloud") ||
|
|
951
|
+
pathname.startsWith("/api/coding-agents")) {
|
|
952
|
+
const cloudApi = await getOptionalPluginApi("cloud");
|
|
953
|
+
isCloudProvisionedContainer = cloudApi.isCloudProvisionedContainer;
|
|
954
|
+
handleCloudStatusRoutes = cloudApi.handleCloudStatusRoutes;
|
|
955
|
+
}
|
|
956
|
+
const isCloudProvisioned = isCloudProvisionedContainer();
|
|
957
|
+
const isCloudFirstRunStatusEndpoint = method === "GET" &&
|
|
958
|
+
pathname === "/api/first-run/status" &&
|
|
959
|
+
isCloudProvisioned;
|
|
960
|
+
// Webhook exemptions: handlers MUST authenticate callers (see plugin handlers).
|
|
961
|
+
// WhatsApp: X-Hub-Signature-256 HMAC (WHATSAPP_APP_SECRET).
|
|
962
|
+
// BlueBubbles: X-BlueBubbles-Webhook-Secret (BLUEBUBBLES_WEBHOOK_SECRET).
|
|
963
|
+
const isWhatsAppWebhookEndpoint = pathname === "/api/whatsapp/webhook";
|
|
964
|
+
let blueBubblesWebhookPath = pathname === "/webhooks/bluebubbles" ? "/webhooks/bluebubbles" : null;
|
|
965
|
+
if (pathname.startsWith("/webhooks/")) {
|
|
966
|
+
const { resolveBlueBubblesWebhookPath } = await getOptionalPluginApi("imessage");
|
|
967
|
+
blueBubblesWebhookPath =
|
|
968
|
+
typeof resolveBlueBubblesWebhookPath === "function"
|
|
969
|
+
? resolveBlueBubblesWebhookPath({
|
|
970
|
+
runtime: state.runtime
|
|
971
|
+
? {
|
|
972
|
+
getService: (type) => state.runtime.getService(type),
|
|
973
|
+
}
|
|
974
|
+
: undefined,
|
|
975
|
+
})
|
|
976
|
+
: blueBubblesWebhookPath;
|
|
977
|
+
}
|
|
978
|
+
const isBlueBubblesWebhookEndpoint = blueBubblesWebhookPath != null && pathname === blueBubblesWebhookPath;
|
|
979
|
+
const isAuthProtectedPath = isAuthProtectedRoute(pathname);
|
|
980
|
+
const canonicalizeRestartReason = (reason) => {
|
|
981
|
+
if (reason === "primary-changed" ||
|
|
982
|
+
reason === "cloud-refreshed" ||
|
|
983
|
+
reason === "Wallet configuration updated") {
|
|
984
|
+
return "Wallet configuration updated";
|
|
985
|
+
}
|
|
986
|
+
return reason;
|
|
987
|
+
};
|
|
988
|
+
const scheduleRuntimeRestart = (reason) => {
|
|
989
|
+
const canonicalReason = canonicalizeRestartReason(reason);
|
|
990
|
+
if (state.pendingRestartReasons.length >= 50) {
|
|
991
|
+
// Prevent unbounded growth — keep only first entry + latest
|
|
992
|
+
state.pendingRestartReasons.splice(1, state.pendingRestartReasons.length - 1);
|
|
993
|
+
}
|
|
994
|
+
if (!state.pendingRestartReasons.includes(canonicalReason)) {
|
|
995
|
+
state.pendingRestartReasons.push(canonicalReason);
|
|
996
|
+
}
|
|
997
|
+
logger.info(`[eliza-api] Restart required: ${canonicalReason} (${state.pendingRestartReasons.length} pending)`);
|
|
998
|
+
state.broadcastWs?.({
|
|
999
|
+
type: "restart-required",
|
|
1000
|
+
reasons: [...state.pendingRestartReasons],
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
1003
|
+
const restartRuntime = async (reason) => {
|
|
1004
|
+
if (!ctx?.onRestart) {
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
if (state.agentState === "restarting") {
|
|
1008
|
+
return false;
|
|
1009
|
+
}
|
|
1010
|
+
const previousState = state.agentState;
|
|
1011
|
+
logger.info(`[eliza-api] Applying runtime reload: ${reason}`);
|
|
1012
|
+
state.agentState = "restarting";
|
|
1013
|
+
state.startup = { ...state.startup, phase: "restarting" };
|
|
1014
|
+
state.broadcastStatus?.();
|
|
1015
|
+
try {
|
|
1016
|
+
const newRuntime = await ctx.onRestart();
|
|
1017
|
+
if (!newRuntime) {
|
|
1018
|
+
state.agentState = previousState;
|
|
1019
|
+
state.broadcastStatus?.();
|
|
1020
|
+
return false;
|
|
1021
|
+
}
|
|
1022
|
+
state.runtime = newRuntime;
|
|
1023
|
+
state.chatConnectionReady = null;
|
|
1024
|
+
state.chatConnectionPromise = null;
|
|
1025
|
+
state.agentState = "running";
|
|
1026
|
+
state.agentName =
|
|
1027
|
+
newRuntime.character.name ?? resolveDefaultAgentName(state.config);
|
|
1028
|
+
state.model = detectRuntimeModel(newRuntime, state.config);
|
|
1029
|
+
state.startedAt = Date.now();
|
|
1030
|
+
state.pendingRestartReasons = [];
|
|
1031
|
+
ctx.onRuntimeSwapped?.();
|
|
1032
|
+
state.broadcastStatus?.();
|
|
1033
|
+
return true;
|
|
1034
|
+
}
|
|
1035
|
+
catch (err) {
|
|
1036
|
+
logger.warn(`[eliza-api] Runtime reload failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1037
|
+
state.agentState = previousState;
|
|
1038
|
+
state.broadcastStatus?.();
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
// ── DNS rebinding protection ──────────────────────────────────────────
|
|
1043
|
+
// Reject requests whose Host header doesn't match a known loopback
|
|
1044
|
+
// hostname. Without this check an attacker can rebind their domain's
|
|
1045
|
+
// DNS to 127.0.0.1 and read the unauthenticated localhost API from a
|
|
1046
|
+
// malicious page.
|
|
1047
|
+
if (!isAllowedHost(req)) {
|
|
1048
|
+
const incomingHost = req.headers.host ?? "your-hostname";
|
|
1049
|
+
json(res, {
|
|
1050
|
+
error: "Forbidden — invalid Host header",
|
|
1051
|
+
hint: `To allow this host, set ELIZA_ALLOWED_HOSTS=${incomingHost} in your environment, or access via http://localhost`,
|
|
1052
|
+
docs: "https://docs.eliza.ai/configuration#allowed-hosts",
|
|
1053
|
+
}, 403);
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (!applyCors(req, res, pathname)) {
|
|
1057
|
+
json(res, { error: "Origin not allowed" }, 403);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
// Cloud SSO popup handoff: GET /pair?token=X must short-circuit BEFORE the
|
|
1061
|
+
// static-UI catch-all, otherwise the SPA index.html is served and the user
|
|
1062
|
+
// ends up on the password screen.
|
|
1063
|
+
//
|
|
1064
|
+
// Guard the call: in the on-device mobile bundle this app-core export can
|
|
1065
|
+
// come through as `undefined` (circular re-export init order under Bun.build),
|
|
1066
|
+
// and an unguarded call throws on EVERY request — 500-ing /api/auth/status
|
|
1067
|
+
// and wedging the dashboard at "Connecting to backend…". The route is a
|
|
1068
|
+
// cloud-SSO handoff that a local on-device agent never legitimately serves,
|
|
1069
|
+
// so skipping it when unavailable is safe.
|
|
1070
|
+
if (typeof handleCloudPairRoute === "function" &&
|
|
1071
|
+
(await handleCloudPairRoute(req, res))) {
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
// Serve dashboard static assets before the auth gates. serveStaticUi already
|
|
1075
|
+
// refuses /api/, /v1/, and /ws paths, so API endpoints remain protected
|
|
1076
|
+
// while steward-managed containers can still reach the built-in dashboard.
|
|
1077
|
+
if (method === "GET" || method === "HEAD") {
|
|
1078
|
+
if (serveStaticUi(req, res, pathname))
|
|
1079
|
+
return;
|
|
1080
|
+
// Chat media (uploaded + generated). Content-addressed sha256 filenames act
|
|
1081
|
+
// as unguessable capabilities, so media loads from <img>/<audio> without an
|
|
1082
|
+
// auth header — same rationale as static assets above.
|
|
1083
|
+
if (serveMediaFile(req, res, pathname))
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (method !== "OPTIONS" &&
|
|
1087
|
+
isAuthProtectedPath &&
|
|
1088
|
+
!isAuthEndpoint &&
|
|
1089
|
+
!isHealthEndpoint &&
|
|
1090
|
+
!isCloudFirstRunStatusEndpoint &&
|
|
1091
|
+
!isWhatsAppWebhookEndpoint &&
|
|
1092
|
+
!isBlueBubblesWebhookEndpoint &&
|
|
1093
|
+
!isPublicRuntimePluginRoute({
|
|
1094
|
+
runtime: state.runtime,
|
|
1095
|
+
method,
|
|
1096
|
+
pathname,
|
|
1097
|
+
}) &&
|
|
1098
|
+
!isAuthorized(req) &&
|
|
1099
|
+
!isWaifuChatAuthorized(req, method, pathname)) {
|
|
1100
|
+
json(res, { error: "Unauthorized" }, 401);
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
// CORS preflight
|
|
1104
|
+
if (method === "OPTIONS") {
|
|
1105
|
+
res.statusCode = 204;
|
|
1106
|
+
res.end();
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
if ((pathname.startsWith("/api/local-inference") ||
|
|
1110
|
+
pathname === "/api/tts/local-inference" ||
|
|
1111
|
+
pathname.startsWith("/api/asr/local-inference") ||
|
|
1112
|
+
pathname.startsWith("/api/voice/audio-frames")) &&
|
|
1113
|
+
(await (async () => {
|
|
1114
|
+
const localInferenceServerApi = await getLocalInferenceServerApi();
|
|
1115
|
+
if (typeof localInferenceServerApi.handleLocalInferenceRoutes ===
|
|
1116
|
+
"function" &&
|
|
1117
|
+
(await localInferenceServerApi.handleLocalInferenceRoutes(req, res))) {
|
|
1118
|
+
return true;
|
|
1119
|
+
}
|
|
1120
|
+
// WebView → agent PCM transport for live on-device speaker diarization.
|
|
1121
|
+
if (localInferenceServerApi.handleLiveDiarizationRoute &&
|
|
1122
|
+
(await localInferenceServerApi.handleLiveDiarizationRoute(req, res, {
|
|
1123
|
+
current: state.runtime,
|
|
1124
|
+
}))) {
|
|
1125
|
+
return true;
|
|
1126
|
+
}
|
|
1127
|
+
if (localInferenceServerApi.handleLocalInferenceAsrRoute &&
|
|
1128
|
+
(await localInferenceServerApi.handleLocalInferenceAsrRoute(req, res, {
|
|
1129
|
+
current: state.runtime,
|
|
1130
|
+
}))) {
|
|
1131
|
+
return true;
|
|
1132
|
+
}
|
|
1133
|
+
return Boolean(localInferenceServerApi.handleLocalInferenceTtsRoute &&
|
|
1134
|
+
(await localInferenceServerApi.handleLocalInferenceTtsRoute(req, res, {
|
|
1135
|
+
current: state.runtime,
|
|
1136
|
+
})));
|
|
1137
|
+
})())) {
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
if (await handleBackgroundTasksRoute({
|
|
1141
|
+
req,
|
|
1142
|
+
res,
|
|
1143
|
+
method,
|
|
1144
|
+
pathname,
|
|
1145
|
+
state,
|
|
1146
|
+
json,
|
|
1147
|
+
})) {
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
if (pathname.startsWith("/api/computer-use/")) {
|
|
1151
|
+
const { handleComputerUseRoutes } = await getOptionalPluginApi("computerUse");
|
|
1152
|
+
if (await handleComputerUseRoutes(req, res, pathname, method))
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
// ── Provider inference helpers ────────────────────────────────────────
|
|
1156
|
+
const _disableCloudInference = () => {
|
|
1157
|
+
delete process.env.ANTHROPIC_BASE_URL;
|
|
1158
|
+
delete process.env.OPENAI_BASE_URL;
|
|
1159
|
+
delete process.env.ANTHROPIC_API_KEY;
|
|
1160
|
+
delete process.env.OPENAI_API_KEY;
|
|
1161
|
+
};
|
|
1162
|
+
const _enableCloudInference = (cloudApiKey, baseUrl) => {
|
|
1163
|
+
// Configure coding agent CLIs to proxy through ElizaCloud /api/v1
|
|
1164
|
+
process.env.ANTHROPIC_BASE_URL = `${baseUrl}/api/v1`;
|
|
1165
|
+
process.env.ANTHROPIC_API_KEY = cloudApiKey;
|
|
1166
|
+
process.env.OPENAI_BASE_URL = `${baseUrl}/api/v1`;
|
|
1167
|
+
process.env.OPENAI_API_KEY = cloudApiKey;
|
|
1168
|
+
// Gemini CLI and Aider — no proxy support via ElizaCloud inference
|
|
1169
|
+
};
|
|
1170
|
+
if (method === "POST" && pathname === "/api/provider/switch") {
|
|
1171
|
+
if (await handleProviderSwitchRoutes({
|
|
1172
|
+
req,
|
|
1173
|
+
res,
|
|
1174
|
+
method,
|
|
1175
|
+
pathname,
|
|
1176
|
+
state,
|
|
1177
|
+
json,
|
|
1178
|
+
error,
|
|
1179
|
+
readJsonBody,
|
|
1180
|
+
saveElizaConfig,
|
|
1181
|
+
scheduleRuntimeRestart,
|
|
1182
|
+
runtimeOperationManager: getOrCreateRuntimeOperationManager(state, restartRuntime),
|
|
1183
|
+
})) {
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
if (await handleAuthRoutes({
|
|
1188
|
+
req,
|
|
1189
|
+
res,
|
|
1190
|
+
method,
|
|
1191
|
+
pathname,
|
|
1192
|
+
readJsonBody,
|
|
1193
|
+
json,
|
|
1194
|
+
error,
|
|
1195
|
+
pairingEnabled,
|
|
1196
|
+
ensurePairingCode,
|
|
1197
|
+
normalizePairingCode,
|
|
1198
|
+
rateLimitPairing,
|
|
1199
|
+
getPairingExpiresAt,
|
|
1200
|
+
clearPairing,
|
|
1201
|
+
})) {
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (await handleSubscriptionRoutes({
|
|
1205
|
+
req,
|
|
1206
|
+
res,
|
|
1207
|
+
method,
|
|
1208
|
+
pathname,
|
|
1209
|
+
state,
|
|
1210
|
+
readJsonBody,
|
|
1211
|
+
json,
|
|
1212
|
+
error,
|
|
1213
|
+
saveConfig: saveElizaConfig,
|
|
1214
|
+
loadSubscriptionAuth: async () => (await import("../auth/index.js")),
|
|
1215
|
+
})) {
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
if (await handleAccountsRoutes({
|
|
1219
|
+
req,
|
|
1220
|
+
res,
|
|
1221
|
+
method,
|
|
1222
|
+
pathname,
|
|
1223
|
+
readJsonBody,
|
|
1224
|
+
json,
|
|
1225
|
+
error,
|
|
1226
|
+
state: { config: state.config },
|
|
1227
|
+
saveConfig: saveElizaConfig,
|
|
1228
|
+
})) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (await handleHealthRoutes({
|
|
1232
|
+
req,
|
|
1233
|
+
res,
|
|
1234
|
+
method,
|
|
1235
|
+
pathname,
|
|
1236
|
+
url,
|
|
1237
|
+
state,
|
|
1238
|
+
json,
|
|
1239
|
+
error,
|
|
1240
|
+
})) {
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
if (await handleFirstRunRoutes({
|
|
1244
|
+
req,
|
|
1245
|
+
res,
|
|
1246
|
+
method,
|
|
1247
|
+
pathname,
|
|
1248
|
+
url,
|
|
1249
|
+
state: coerce(state),
|
|
1250
|
+
json,
|
|
1251
|
+
error,
|
|
1252
|
+
readJsonBody,
|
|
1253
|
+
isCloudProvisionedContainer,
|
|
1254
|
+
hasPersistedFirstRunState,
|
|
1255
|
+
ensureWalletKeysInEnvAndConfig,
|
|
1256
|
+
getWalletAddresses: pathname === "/api/wallet/keys"
|
|
1257
|
+
? coerce((await getCoreWalletApi()).getWalletAddresses)
|
|
1258
|
+
: coerce(() => ({
|
|
1259
|
+
evmAddress: null,
|
|
1260
|
+
solanaAddress: null,
|
|
1261
|
+
})),
|
|
1262
|
+
pickRandomNames,
|
|
1263
|
+
getStylePresets: coerce(getStylePresets),
|
|
1264
|
+
getProviderOptions: coerce(getProviderOptions),
|
|
1265
|
+
getCloudProviderOptions: coerce(getCloudProviderOptions),
|
|
1266
|
+
getModelOptions: coerce(getModelOptions),
|
|
1267
|
+
getInventoryProviderOptions: coerce(getInventoryProviderOptions),
|
|
1268
|
+
resolveConfiguredCharacterLanguage: coerce(resolveConfiguredCharacterLanguage),
|
|
1269
|
+
normalizeCharacterLanguage: coerce(normalizeCharacterLanguage),
|
|
1270
|
+
readUiLanguageHeader: coerce(readUiLanguageHeader),
|
|
1271
|
+
applyFirstRunVoicePreset: coerce(applyFirstRunVoicePreset),
|
|
1272
|
+
saveElizaConfig,
|
|
1273
|
+
})) {
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
// POST /api/first-run is now handled by first-run-routes.ts above.
|
|
1277
|
+
if (await handleAgentLifecycleRoutes({
|
|
1278
|
+
req,
|
|
1279
|
+
res,
|
|
1280
|
+
method,
|
|
1281
|
+
pathname,
|
|
1282
|
+
state,
|
|
1283
|
+
error,
|
|
1284
|
+
json,
|
|
1285
|
+
readJsonBody,
|
|
1286
|
+
})) {
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
if (pathname.startsWith("/api/triggers") ||
|
|
1290
|
+
pathname.startsWith("/api/heartbeats")) {
|
|
1291
|
+
const { handleTriggerRoutes } = await getOptionalPluginApi("workflow");
|
|
1292
|
+
const triggerHandled = await handleTriggerRoutes({
|
|
1293
|
+
req,
|
|
1294
|
+
res,
|
|
1295
|
+
method,
|
|
1296
|
+
pathname,
|
|
1297
|
+
runtime: state.runtime,
|
|
1298
|
+
readJsonBody,
|
|
1299
|
+
json,
|
|
1300
|
+
error,
|
|
1301
|
+
executeTriggerTask,
|
|
1302
|
+
getTriggerHealthSnapshot,
|
|
1303
|
+
getTriggerLimit,
|
|
1304
|
+
listTriggerTasks,
|
|
1305
|
+
readTriggerConfig,
|
|
1306
|
+
readTriggerRuns,
|
|
1307
|
+
taskToTriggerSummary,
|
|
1308
|
+
triggersFeatureEnabled,
|
|
1309
|
+
buildTriggerConfig,
|
|
1310
|
+
buildTriggerMetadata,
|
|
1311
|
+
normalizeTriggerDraft,
|
|
1312
|
+
DISABLED_TRIGGER_INTERVAL_MS,
|
|
1313
|
+
TRIGGER_TASK_NAME,
|
|
1314
|
+
TRIGGER_TASK_TAGS: [...TRIGGER_TASK_TAGS],
|
|
1315
|
+
});
|
|
1316
|
+
if (triggerHandled) {
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
// Training routes (/api/training/*) and trajectory routes
|
|
1321
|
+
// (/api/trajectories/*) are now provided by the @elizaos/plugin-training
|
|
1322
|
+
// plugin via the runtime route registry.
|
|
1323
|
+
// Knowledge routes (/api/knowledge/*) are now provided by the
|
|
1324
|
+
// @elizaos/app-knowledge plugin via the runtime route registry.
|
|
1325
|
+
if (pathname.startsWith("/api/memory") ||
|
|
1326
|
+
pathname.startsWith("/api/memories") ||
|
|
1327
|
+
pathname === "/api/context/quick") {
|
|
1328
|
+
const memoryHandled = await handleMemoryRoutes({
|
|
1329
|
+
req,
|
|
1330
|
+
res,
|
|
1331
|
+
method,
|
|
1332
|
+
pathname,
|
|
1333
|
+
url,
|
|
1334
|
+
runtime: state.runtime,
|
|
1335
|
+
agentName: state.agentName,
|
|
1336
|
+
readJsonBody,
|
|
1337
|
+
json,
|
|
1338
|
+
error,
|
|
1339
|
+
});
|
|
1340
|
+
if (memoryHandled)
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
if (await handleAgentAdminRoutes({
|
|
1344
|
+
req,
|
|
1345
|
+
res,
|
|
1346
|
+
method,
|
|
1347
|
+
pathname,
|
|
1348
|
+
state,
|
|
1349
|
+
onRestart: ctx?.onRestart ?? undefined,
|
|
1350
|
+
onRuntimeSwapped: ctx?.onRuntimeSwapped,
|
|
1351
|
+
json,
|
|
1352
|
+
error,
|
|
1353
|
+
resolveStateDir,
|
|
1354
|
+
stateDirExists: fs.existsSync,
|
|
1355
|
+
removeStateDir: (resolvedState) => {
|
|
1356
|
+
fs.rmSync(resolvedState, { recursive: true, force: true });
|
|
1357
|
+
},
|
|
1358
|
+
logWarn: (message) => logger.warn(message),
|
|
1359
|
+
})) {
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
if (await handleAgentTransferRoutes({
|
|
1363
|
+
req,
|
|
1364
|
+
res,
|
|
1365
|
+
method,
|
|
1366
|
+
pathname,
|
|
1367
|
+
state,
|
|
1368
|
+
readJsonBody,
|
|
1369
|
+
json,
|
|
1370
|
+
error,
|
|
1371
|
+
exportAgent,
|
|
1372
|
+
estimateExportSize,
|
|
1373
|
+
importAgent,
|
|
1374
|
+
isAgentExportError: (err) => err instanceof AgentExportError,
|
|
1375
|
+
})) {
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
if (await handleCharacterRoutes({
|
|
1379
|
+
req,
|
|
1380
|
+
res,
|
|
1381
|
+
method,
|
|
1382
|
+
pathname,
|
|
1383
|
+
state,
|
|
1384
|
+
readJsonBody,
|
|
1385
|
+
json,
|
|
1386
|
+
error,
|
|
1387
|
+
pickRandomNames,
|
|
1388
|
+
saveConfig: saveElizaConfig,
|
|
1389
|
+
validateCharacter: (body) => CharacterSchema.safeParse(body),
|
|
1390
|
+
})) {
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
// Experience routes (/api/experiences/*, /api/character/experiences/*) are
|
|
1394
|
+
// served by the @elizaos/plugin-training plugin via Plugin.routes.
|
|
1395
|
+
// Compatibility route used by legacy health probes and desktop name lookup.
|
|
1396
|
+
if (method === "GET" && pathname === "/api/agents") {
|
|
1397
|
+
const runtimeAgentId = typeof state.runtime?.agentId === "string" &&
|
|
1398
|
+
state.runtime.agentId.trim().length > 0
|
|
1399
|
+
? state.runtime.agentId.trim()
|
|
1400
|
+
: null;
|
|
1401
|
+
const configuredAgentId = typeof state.config.agents?.list?.[0]?.id === "string" &&
|
|
1402
|
+
state.config.agents.list[0].id.trim().length > 0
|
|
1403
|
+
? state.config.agents.list[0].id.trim()
|
|
1404
|
+
: null;
|
|
1405
|
+
const agentName = state.runtime?.character.name?.trim() ||
|
|
1406
|
+
state.agentName.trim() ||
|
|
1407
|
+
"Eliza";
|
|
1408
|
+
json(res, {
|
|
1409
|
+
agents: [
|
|
1410
|
+
{
|
|
1411
|
+
id: runtimeAgentId ??
|
|
1412
|
+
configuredAgentId ??
|
|
1413
|
+
"00000000-0000-0000-0000-000000000000",
|
|
1414
|
+
name: agentName,
|
|
1415
|
+
status: state.agentState,
|
|
1416
|
+
},
|
|
1417
|
+
],
|
|
1418
|
+
});
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
if (await handleModelsRoutes({
|
|
1422
|
+
req,
|
|
1423
|
+
res,
|
|
1424
|
+
method,
|
|
1425
|
+
pathname,
|
|
1426
|
+
url,
|
|
1427
|
+
json,
|
|
1428
|
+
providerCachePath,
|
|
1429
|
+
getOrFetchProvider,
|
|
1430
|
+
getOrFetchAllProviders,
|
|
1431
|
+
resolveModelsCacheDir,
|
|
1432
|
+
pathExists: fs.existsSync,
|
|
1433
|
+
readDir: fs.readdirSync,
|
|
1434
|
+
unlinkFile: fs.unlinkSync,
|
|
1435
|
+
joinPath: path.join,
|
|
1436
|
+
})) {
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
if (await handleRegistryRoutes({
|
|
1440
|
+
req,
|
|
1441
|
+
res,
|
|
1442
|
+
method,
|
|
1443
|
+
pathname,
|
|
1444
|
+
url,
|
|
1445
|
+
json,
|
|
1446
|
+
error,
|
|
1447
|
+
getPluginManager: () => getPluginManagerForState(state),
|
|
1448
|
+
getLoadedPluginNames: () => state.runtime?.plugins.map((plugin) => plugin.name) ?? [],
|
|
1449
|
+
getBundledPluginIds: () => getReleaseBundledPluginIds(),
|
|
1450
|
+
classifyRegistryPluginRelease,
|
|
1451
|
+
})) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
if (await handleRemoteCapabilityRoutes({
|
|
1455
|
+
req,
|
|
1456
|
+
res,
|
|
1457
|
+
method,
|
|
1458
|
+
pathname,
|
|
1459
|
+
runtime: state.runtime,
|
|
1460
|
+
config: state.config,
|
|
1461
|
+
readJsonBody,
|
|
1462
|
+
saveConfig: (config) => saveElizaConfig(config),
|
|
1463
|
+
persistConfigEnv,
|
|
1464
|
+
json,
|
|
1465
|
+
error,
|
|
1466
|
+
})) {
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
// Live-load a plugin from an on-disk directory into the running runtime. This
|
|
1470
|
+
// is what makes a freshly scaffolded/edited local plugin (VIEWS/APP create)
|
|
1471
|
+
// actually appear without an agent restart — its views register via
|
|
1472
|
+
// runtime.registerPlugin. Must run BEFORE the generic /api/plugins/* handler.
|
|
1473
|
+
if (method === "POST" && pathname === "/api/plugins/load-from-directory") {
|
|
1474
|
+
const { isLocalCodeExecutionAllowed, buildStoreVariantBlockedMessage } = await import("@elizaos/core");
|
|
1475
|
+
if (!isLocalCodeExecutionAllowed()) {
|
|
1476
|
+
error(res, buildStoreVariantBlockedMessage("Local plugin loading"), 403);
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
if (!state.runtime) {
|
|
1480
|
+
error(res, "Agent runtime is not available", 503);
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
const body = await readJsonBody(req, res);
|
|
1484
|
+
if (body === null)
|
|
1485
|
+
return;
|
|
1486
|
+
const directory = typeof body.directory === "string" ? body.directory.trim() : "";
|
|
1487
|
+
if (!directory || !path.isAbsolute(directory)) {
|
|
1488
|
+
error(res, "'directory' must be an absolute path", 400);
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
const entry = typeof body.entry === "string" ? body.entry : undefined;
|
|
1492
|
+
try {
|
|
1493
|
+
const { loadPluginFromDirectory } = await import("../runtime/load-plugin-from-directory.js");
|
|
1494
|
+
const result = await loadPluginFromDirectory({
|
|
1495
|
+
runtime: state.runtime,
|
|
1496
|
+
directory,
|
|
1497
|
+
...(entry ? { entry } : {}),
|
|
1498
|
+
});
|
|
1499
|
+
json(res, { ok: true, ...result });
|
|
1500
|
+
}
|
|
1501
|
+
catch (err) {
|
|
1502
|
+
json(res, {
|
|
1503
|
+
ok: false,
|
|
1504
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1505
|
+
}, 422);
|
|
1506
|
+
}
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
// Unload a plugin previously live-loaded from a directory (the symmetric
|
|
1510
|
+
// counterpart to load-from-directory). Directly-registered plugins are not
|
|
1511
|
+
// known to the plugin-manager, so /api/plugins/uninstall can't remove them —
|
|
1512
|
+
// this delegates to runtime.unloadPlugin, which also deregisters its views.
|
|
1513
|
+
if (method === "POST" && pathname === "/api/plugins/unload-from-directory") {
|
|
1514
|
+
if (!state.runtime) {
|
|
1515
|
+
error(res, "Agent runtime is not available", 503);
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
const body = await readJsonBody(req, res);
|
|
1519
|
+
if (body === null)
|
|
1520
|
+
return;
|
|
1521
|
+
const pluginName = typeof body.pluginName === "string" ? body.pluginName.trim() : "";
|
|
1522
|
+
if (!pluginName) {
|
|
1523
|
+
error(res, "'pluginName' is required", 400);
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
try {
|
|
1527
|
+
const { unloadPluginFromDirectory } = await import("../runtime/load-plugin-from-directory.js");
|
|
1528
|
+
const result = await unloadPluginFromDirectory({
|
|
1529
|
+
runtime: state.runtime,
|
|
1530
|
+
pluginName,
|
|
1531
|
+
});
|
|
1532
|
+
json(res, { ok: result.unloaded, ...result });
|
|
1533
|
+
}
|
|
1534
|
+
catch (err) {
|
|
1535
|
+
json(res, { ok: false, error: err instanceof Error ? err.message : String(err) }, 422);
|
|
1536
|
+
}
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
if (pathname === "/api/plugins" ||
|
|
1540
|
+
pathname.startsWith("/api/plugins/") ||
|
|
1541
|
+
pathname === "/api/secrets" ||
|
|
1542
|
+
pathname === "/api/core/status") {
|
|
1543
|
+
const { handlePluginRoutes } = await getPluginRegistryApi();
|
|
1544
|
+
if (await handlePluginRoutes({
|
|
1545
|
+
req,
|
|
1546
|
+
res,
|
|
1547
|
+
method,
|
|
1548
|
+
pathname,
|
|
1549
|
+
url,
|
|
1550
|
+
state,
|
|
1551
|
+
json,
|
|
1552
|
+
error,
|
|
1553
|
+
readJsonBody,
|
|
1554
|
+
scheduleRuntimeRestart,
|
|
1555
|
+
restartRuntime,
|
|
1556
|
+
BLOCKED_ENV_KEYS,
|
|
1557
|
+
discoverInstalledPlugins,
|
|
1558
|
+
maskValue,
|
|
1559
|
+
aggregateSecrets,
|
|
1560
|
+
readProviderCache,
|
|
1561
|
+
paramKeyToCategory,
|
|
1562
|
+
buildPluginEvmDiagnosticEntry,
|
|
1563
|
+
EVM_PLUGIN_PACKAGE,
|
|
1564
|
+
applyWhatsAppQrOverride: (await getOptionalPluginApi("whatsapp")).applyWhatsAppQrOverride,
|
|
1565
|
+
applySignalQrOverride: (await getOptionalPluginApi("signal")).applySignalQrOverride,
|
|
1566
|
+
resolvePluginConfigMutationRejections,
|
|
1567
|
+
requirePluginManager,
|
|
1568
|
+
requireCoreManager,
|
|
1569
|
+
})) {
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
// Curated-skills routes must be dispatched before generic skills routes
|
|
1574
|
+
// (which reject "/" in skill IDs).
|
|
1575
|
+
if (pathname.startsWith("/api/skills/curated")) {
|
|
1576
|
+
const { handleCuratedSkillsRoutes } = await getAgentSkillsApi();
|
|
1577
|
+
if (await handleCuratedSkillsRoutes({
|
|
1578
|
+
req,
|
|
1579
|
+
res,
|
|
1580
|
+
method,
|
|
1581
|
+
pathname,
|
|
1582
|
+
url,
|
|
1583
|
+
json,
|
|
1584
|
+
error,
|
|
1585
|
+
readJsonBody,
|
|
1586
|
+
})) {
|
|
1587
|
+
return;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
if (pathname.startsWith("/api/skills")) {
|
|
1591
|
+
const { discoverSkills, handleSkillsRoutes } = await getAgentSkillsApi();
|
|
1592
|
+
if (await handleSkillsRoutes({
|
|
1593
|
+
req,
|
|
1594
|
+
res,
|
|
1595
|
+
method,
|
|
1596
|
+
pathname,
|
|
1597
|
+
url,
|
|
1598
|
+
state,
|
|
1599
|
+
json,
|
|
1600
|
+
error,
|
|
1601
|
+
readJsonBody,
|
|
1602
|
+
readBody,
|
|
1603
|
+
discoverSkills,
|
|
1604
|
+
})) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
if (await handleDiagnosticsRoutes({
|
|
1609
|
+
req,
|
|
1610
|
+
res,
|
|
1611
|
+
method,
|
|
1612
|
+
pathname,
|
|
1613
|
+
url,
|
|
1614
|
+
logBuffer: state.logBuffer,
|
|
1615
|
+
clearLogBuffer: () => {
|
|
1616
|
+
const previous = state.logBuffer.length;
|
|
1617
|
+
state.logBuffer.length = 0;
|
|
1618
|
+
return previous;
|
|
1619
|
+
},
|
|
1620
|
+
readJsonBody,
|
|
1621
|
+
error,
|
|
1622
|
+
eventBuffer: state.eventBuffer,
|
|
1623
|
+
json,
|
|
1624
|
+
auditEventTypes: AUDIT_EVENT_TYPES,
|
|
1625
|
+
auditSeverities: AUDIT_SEVERITIES,
|
|
1626
|
+
getAuditFeedSize,
|
|
1627
|
+
queryAuditFeed: (query) => queryAuditFeed({
|
|
1628
|
+
type: AUDIT_EVENT_TYPES.includes(query.type ?? "")
|
|
1629
|
+
? query.type
|
|
1630
|
+
: undefined,
|
|
1631
|
+
severity: AUDIT_SEVERITIES.includes(query.severity ?? "")
|
|
1632
|
+
? query.severity
|
|
1633
|
+
: undefined,
|
|
1634
|
+
sinceMs: query.sinceMs,
|
|
1635
|
+
limit: query.limit,
|
|
1636
|
+
}).map((entry) => ({
|
|
1637
|
+
timestamp: entry.timestamp,
|
|
1638
|
+
type: entry.type,
|
|
1639
|
+
summary: entry.summary,
|
|
1640
|
+
severity: entry.severity,
|
|
1641
|
+
metadata: entry.metadata,
|
|
1642
|
+
})),
|
|
1643
|
+
subscribeAuditFeed,
|
|
1644
|
+
})) {
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1648
|
+
// Bug report routes
|
|
1649
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1650
|
+
if (await handleBugReportRoutes({
|
|
1651
|
+
req,
|
|
1652
|
+
res,
|
|
1653
|
+
method,
|
|
1654
|
+
pathname,
|
|
1655
|
+
readJsonBody,
|
|
1656
|
+
json,
|
|
1657
|
+
error,
|
|
1658
|
+
})) {
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1662
|
+
// Wallet core routes (addresses, balances, generate, config, export)
|
|
1663
|
+
// Prefer the local wallet implementation during desktop startup. The
|
|
1664
|
+
// steward-app bridge can pull browser/UI-only dependencies into the agent
|
|
1665
|
+
// process and must not block local assistant boot.
|
|
1666
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1667
|
+
if (pathname.startsWith("/api/wallet/")) {
|
|
1668
|
+
const { handleWalletRoutes } = await getWalletApi();
|
|
1669
|
+
const { deriveSolanaAddress, fetchEvmBalances, fetchSolanaBalances, fetchSolanaNativeBalanceViaRpc, generateWalletForChain, getWalletAddresses, importWallet, setSolanaWalletEnv, validatePrivateKey, } = await getCoreWalletApi();
|
|
1670
|
+
if (await handleWalletRoutes({
|
|
1671
|
+
req,
|
|
1672
|
+
res,
|
|
1673
|
+
method,
|
|
1674
|
+
pathname,
|
|
1675
|
+
config: loadElizaConfig(),
|
|
1676
|
+
saveConfig: saveElizaConfig,
|
|
1677
|
+
ensureWalletKeysInEnvAndConfig,
|
|
1678
|
+
resolveWalletExportRejection,
|
|
1679
|
+
restartRuntime,
|
|
1680
|
+
scheduleRuntimeRestart,
|
|
1681
|
+
readJsonBody,
|
|
1682
|
+
json,
|
|
1683
|
+
error,
|
|
1684
|
+
deps: {
|
|
1685
|
+
fetchEvmBalances,
|
|
1686
|
+
fetchSolanaBalances,
|
|
1687
|
+
fetchSolanaNativeBalanceViaRpc,
|
|
1688
|
+
getWalletAddresses,
|
|
1689
|
+
validatePrivateKey,
|
|
1690
|
+
importWallet,
|
|
1691
|
+
generateWalletForChain,
|
|
1692
|
+
deriveSolanaAddress,
|
|
1693
|
+
setSolanaWalletEnv,
|
|
1694
|
+
resolveWalletRpcReadiness: coerce(resolveWalletRpcReadiness),
|
|
1695
|
+
resolveWalletNetworkMode: coerce(resolveWalletNetworkMode),
|
|
1696
|
+
getStoredWalletRpcSelections: coerce(getStoredWalletRpcSelections),
|
|
1697
|
+
applyWalletRpcConfigUpdate: coerce(applyWalletRpcConfigUpdate),
|
|
1698
|
+
resolveWalletCapabilityStatus: coerce((args) => resolveWalletCapabilityStatus({
|
|
1699
|
+
config: args.config,
|
|
1700
|
+
runtime: args.runtime,
|
|
1701
|
+
})),
|
|
1702
|
+
isCloudWalletEnabled,
|
|
1703
|
+
persistConfigEnv,
|
|
1704
|
+
createIntegrationTelemetrySpan: coerce(createIntegrationTelemetrySpan),
|
|
1705
|
+
},
|
|
1706
|
+
runtime: state.runtime ?? null,
|
|
1707
|
+
})) {
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1712
|
+
// ERC-8004 Registry, Agent self-status, Privy — delegated to agent-status-routes.ts
|
|
1713
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1714
|
+
if ((pathname === "/api/agent/self-status" ||
|
|
1715
|
+
pathname.startsWith("/api/registry")) &&
|
|
1716
|
+
(await (async () => {
|
|
1717
|
+
const { RegistryService } = await import("./registry-service.js");
|
|
1718
|
+
return handleAgentStatusRoutes({
|
|
1719
|
+
req,
|
|
1720
|
+
res,
|
|
1721
|
+
method,
|
|
1722
|
+
pathname,
|
|
1723
|
+
url,
|
|
1724
|
+
state: coerce(state),
|
|
1725
|
+
json,
|
|
1726
|
+
error,
|
|
1727
|
+
readJsonBody,
|
|
1728
|
+
deps: {
|
|
1729
|
+
getWalletAddresses: pathname === "/api/agent/self-status"
|
|
1730
|
+
? (await getCoreWalletApi()).getWalletAddresses
|
|
1731
|
+
: () => ({ evmAddress: null, solanaAddress: null }),
|
|
1732
|
+
resolveWalletCapabilityStatus: coerce(resolveWalletCapabilityStatus),
|
|
1733
|
+
resolveWalletRpcReadiness: coerce(resolveWalletRpcReadiness),
|
|
1734
|
+
resolveTradePermissionMode,
|
|
1735
|
+
canUseLocalTradeExecution: coerce(canUseLocalTradeExecution),
|
|
1736
|
+
detectRuntimeModel: coerce(detectRuntimeModel),
|
|
1737
|
+
resolveProviderFromModel,
|
|
1738
|
+
getGlobalAwarenessRegistry: coerce(getGlobalAwarenessRegistry),
|
|
1739
|
+
RegistryService,
|
|
1740
|
+
},
|
|
1741
|
+
});
|
|
1742
|
+
})())) {
|
|
1743
|
+
return;
|
|
1744
|
+
}
|
|
1745
|
+
if (await handleUpdateRoutes({
|
|
1746
|
+
req,
|
|
1747
|
+
res,
|
|
1748
|
+
method,
|
|
1749
|
+
pathname,
|
|
1750
|
+
url,
|
|
1751
|
+
state,
|
|
1752
|
+
json,
|
|
1753
|
+
error,
|
|
1754
|
+
readJsonBody,
|
|
1755
|
+
saveElizaConfig,
|
|
1756
|
+
})) {
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
if (await handleConnectorRoutes({
|
|
1760
|
+
req,
|
|
1761
|
+
res,
|
|
1762
|
+
method,
|
|
1763
|
+
pathname,
|
|
1764
|
+
state,
|
|
1765
|
+
json,
|
|
1766
|
+
error,
|
|
1767
|
+
readJsonBody,
|
|
1768
|
+
saveElizaConfig,
|
|
1769
|
+
redactConfigSecrets,
|
|
1770
|
+
isBlockedObjectKey,
|
|
1771
|
+
cloneWithoutBlockedObjectKeys,
|
|
1772
|
+
// Disconnect cascade is event-driven: connector-routes
|
|
1773
|
+
// emits `connector_disconnected` and WorkflowCredentialStore subscribes
|
|
1774
|
+
// to invalidate its own cache. No direct service lookup needed here.
|
|
1775
|
+
onConnectorDisconnect: async () => { },
|
|
1776
|
+
})) {
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
// ── WhatsApp routes (/api/whatsapp/*) ────────────────────────────────────
|
|
1780
|
+
// Moved to @elizaos/plugin-whatsapp setup-routes.ts (registered via Plugin.routes).
|
|
1781
|
+
// ── BlueBubbles routes (/api/bluebubbles/*, /webhooks/bluebubbles) ──
|
|
1782
|
+
// Extracted to @elizaos/plugin-bluebubbles setup-routes.ts (Plugin.routes).
|
|
1783
|
+
// ── Notification + inbox routes (/api/notifications/*, /api/inbox/*) ──
|
|
1784
|
+
// Notifications: the unified notification center backed by the runtime
|
|
1785
|
+
// NotificationService (see api/notification-routes.ts). Inbox: a
|
|
1786
|
+
// cross-channel read-only feed that merges connector messages (imessage,
|
|
1787
|
+
// telegram, discord, whatsapp, etc.) into a single time-ordered view.
|
|
1788
|
+
if (await handleInboxAndCloudRelayRouteGroup({
|
|
1789
|
+
req,
|
|
1790
|
+
res,
|
|
1791
|
+
method,
|
|
1792
|
+
pathname,
|
|
1793
|
+
url,
|
|
1794
|
+
state,
|
|
1795
|
+
json,
|
|
1796
|
+
error,
|
|
1797
|
+
readJsonBody,
|
|
1798
|
+
})) {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
// ── Restart ──────────────────────────────────────────────────────────
|
|
1802
|
+
if (method === "POST" && pathname === "/api/restart") {
|
|
1803
|
+
state.agentState = "restarting";
|
|
1804
|
+
state.startup = { ...state.startup, phase: "restarting" };
|
|
1805
|
+
state.broadcastStatus?.();
|
|
1806
|
+
json(res, { ok: true, message: "Restarting...", restarting: true });
|
|
1807
|
+
setTimeout(() => process.exit(0), 1000);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
if (pathname.startsWith("/api/tts/") &&
|
|
1811
|
+
(await (async () => {
|
|
1812
|
+
const { handleTtsRoutes } = await getOptionalPluginApi("streaming");
|
|
1813
|
+
return handleTtsRoutes({
|
|
1814
|
+
req,
|
|
1815
|
+
res,
|
|
1816
|
+
method,
|
|
1817
|
+
pathname,
|
|
1818
|
+
state,
|
|
1819
|
+
json,
|
|
1820
|
+
error,
|
|
1821
|
+
readJsonBody,
|
|
1822
|
+
isRedactedSecretValue,
|
|
1823
|
+
fetchWithTimeoutGuard,
|
|
1824
|
+
streamResponseBodyWithByteLimit: coerce(streamResponseBodyWithByteLimit),
|
|
1825
|
+
responseContentLength,
|
|
1826
|
+
isAbortError,
|
|
1827
|
+
ELEVENLABS_FETCH_TIMEOUT_MS: 30_000,
|
|
1828
|
+
ELEVENLABS_AUDIO_MAX_BYTES: 20 * 1_048_576,
|
|
1829
|
+
});
|
|
1830
|
+
})())) {
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
if (await handleAvatarRoutes({
|
|
1834
|
+
req,
|
|
1835
|
+
res,
|
|
1836
|
+
method,
|
|
1837
|
+
pathname,
|
|
1838
|
+
json,
|
|
1839
|
+
error,
|
|
1840
|
+
})) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
if (pathname === "/api/config" ||
|
|
1844
|
+
pathname === "/api/config/schema" ||
|
|
1845
|
+
pathname === "/api/config/reload") {
|
|
1846
|
+
if (await handleConfigRoutes({
|
|
1847
|
+
req,
|
|
1848
|
+
res,
|
|
1849
|
+
method,
|
|
1850
|
+
pathname,
|
|
1851
|
+
url,
|
|
1852
|
+
config: state.config,
|
|
1853
|
+
runtime: state.runtime,
|
|
1854
|
+
json,
|
|
1855
|
+
error,
|
|
1856
|
+
readJsonBody,
|
|
1857
|
+
redactConfigSecrets,
|
|
1858
|
+
isBlockedObjectKey,
|
|
1859
|
+
stripRedactedPlaceholderValuesDeep,
|
|
1860
|
+
patchTouchesProviderSelection,
|
|
1861
|
+
BLOCKED_ENV_KEYS,
|
|
1862
|
+
CONFIG_WRITE_ALLOWED_TOP_KEYS,
|
|
1863
|
+
resolveMcpServersRejection,
|
|
1864
|
+
resolveMcpTerminalAuthorizationRejection,
|
|
1865
|
+
})) {
|
|
1866
|
+
return;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
if (await handlePermissionsExtraRoutes({
|
|
1870
|
+
req,
|
|
1871
|
+
res,
|
|
1872
|
+
method,
|
|
1873
|
+
pathname,
|
|
1874
|
+
state: coerce(state),
|
|
1875
|
+
json,
|
|
1876
|
+
error,
|
|
1877
|
+
readJsonBody,
|
|
1878
|
+
saveElizaConfig,
|
|
1879
|
+
resolveTradePermissionMode: coerce(resolveTradePermissionMode),
|
|
1880
|
+
canUseLocalTradeExecution: coerce(canUseLocalTradeExecution),
|
|
1881
|
+
parseAgentAutomationMode,
|
|
1882
|
+
persistAgentAutomationMode: coerce(persistAgentAutomationMode),
|
|
1883
|
+
})) {
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
if (await handlePermissionRoutes({
|
|
1887
|
+
req,
|
|
1888
|
+
res,
|
|
1889
|
+
method,
|
|
1890
|
+
pathname,
|
|
1891
|
+
state,
|
|
1892
|
+
readJsonBody,
|
|
1893
|
+
json,
|
|
1894
|
+
error,
|
|
1895
|
+
saveConfig: (config) => {
|
|
1896
|
+
saveElizaConfig(config);
|
|
1897
|
+
},
|
|
1898
|
+
scheduleRuntimeRestart,
|
|
1899
|
+
})) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
if (await handleRelationshipsRoutes({
|
|
1903
|
+
req,
|
|
1904
|
+
res,
|
|
1905
|
+
method,
|
|
1906
|
+
pathname,
|
|
1907
|
+
runtime: state.runtime ?? undefined,
|
|
1908
|
+
readJsonBody,
|
|
1909
|
+
json,
|
|
1910
|
+
error,
|
|
1911
|
+
})) {
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
// Browser workspace routes (/api/browser-workspace/*) are served by the
|
|
1915
|
+
// @elizaos/app-browser plugin via Plugin.routes.
|
|
1916
|
+
// Agent self-status, Privy, and ERC-8004 registry routes are now handled
|
|
1917
|
+
// by handleAgentStatusRoutes above.
|
|
1918
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1919
|
+
// BSC trade routes and wallet trade execute — now handled by
|
|
1920
|
+
// @elizaos/plugin-steward-app plugin routes. See plugins/plugin-steward-app/src/plugin.ts.
|
|
1921
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
1922
|
+
if (isLifeOpsCloudPluginRoute(pathname) &&
|
|
1923
|
+
(await handleLifeOpsRuntimePluginRoute({
|
|
1924
|
+
req,
|
|
1925
|
+
res,
|
|
1926
|
+
method,
|
|
1927
|
+
pathname,
|
|
1928
|
+
url,
|
|
1929
|
+
state,
|
|
1930
|
+
isAuthorizedRequest: isAuthorized,
|
|
1931
|
+
}))) {
|
|
1932
|
+
return;
|
|
1933
|
+
}
|
|
1934
|
+
if (await handleCloudAndCoreRouteGroup({
|
|
1935
|
+
req,
|
|
1936
|
+
res,
|
|
1937
|
+
method,
|
|
1938
|
+
pathname,
|
|
1939
|
+
state,
|
|
1940
|
+
restartRuntime,
|
|
1941
|
+
saveConfig: saveElizaConfig,
|
|
1942
|
+
})) {
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1945
|
+
if (await handleSandboxRouteGroup({ req, res, method, pathname, state })) {
|
|
1946
|
+
return;
|
|
1947
|
+
}
|
|
1948
|
+
if (await handleConversationRouteGroup({
|
|
1949
|
+
req,
|
|
1950
|
+
res,
|
|
1951
|
+
method,
|
|
1952
|
+
pathname,
|
|
1953
|
+
url,
|
|
1954
|
+
state,
|
|
1955
|
+
json,
|
|
1956
|
+
error,
|
|
1957
|
+
readJsonBody,
|
|
1958
|
+
})) {
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
if (await handleDatabaseRouteGroup({ req, res, pathname, state })) {
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1964
|
+
// Trajectory routes (/api/trajectories/*) are now provided by the
|
|
1965
|
+
// @elizaos/plugin-training plugin via the runtime route registry.
|
|
1966
|
+
// Coding Agent API routes (/api/coding-agents/*, /api/workspace/*,
|
|
1967
|
+
// /api/issues/*) are now provided by the @elizaos/plugin-agent-orchestrator
|
|
1968
|
+
// plugin via the runtime route registry. Most of those paths genuinely need
|
|
1969
|
+
// the runtime, so a pre-runtime 503 is correct. The GET capability probes
|
|
1970
|
+
// below are the exception: they have graceful builtin probe handlers
|
|
1971
|
+
// (handleBuiltinOptionalRoutes → { available: false } / "unavailable"). The
|
|
1972
|
+
// dashboard polls /preflight the instant agentStatus flips to "running", which
|
|
1973
|
+
// can race ahead of state.runtime being assigned during a restart; serve those
|
|
1974
|
+
// from the builtin probe handler instead of a 503 the browser logs as a red console error.
|
|
1975
|
+
const isCodingAgentBuiltinProbe = pathname === "/api/coding-agents/preflight" ||
|
|
1976
|
+
pathname === "/api/coding-agents/coordinator/status";
|
|
1977
|
+
if (!state.runtime &&
|
|
1978
|
+
method === "GET" &&
|
|
1979
|
+
pathname.startsWith("/api/coding-agents") &&
|
|
1980
|
+
!isCodingAgentBuiltinProbe) {
|
|
1981
|
+
error(res, "Coding agent runtime unavailable", 503);
|
|
1982
|
+
return;
|
|
1983
|
+
}
|
|
1984
|
+
if (await handleCloudStatusRoutes({
|
|
1985
|
+
req,
|
|
1986
|
+
res,
|
|
1987
|
+
method,
|
|
1988
|
+
pathname,
|
|
1989
|
+
config: state.config,
|
|
1990
|
+
runtime: state.runtime,
|
|
1991
|
+
json,
|
|
1992
|
+
})) {
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1995
|
+
// ── App routes (/api/apps/*) ──────────────────────────────────────────
|
|
1996
|
+
if (pathname.startsWith("/api/apps")) {
|
|
1997
|
+
const { handleAppsRoutes } = await getAppManagerApi();
|
|
1998
|
+
const appManager = ctx?.getAppManager
|
|
1999
|
+
? await ctx.getAppManager()
|
|
2000
|
+
: state.appManager;
|
|
2001
|
+
if (await handleAppsRoutes({
|
|
2002
|
+
req,
|
|
2003
|
+
res,
|
|
2004
|
+
method,
|
|
2005
|
+
pathname,
|
|
2006
|
+
url,
|
|
2007
|
+
appManager: {
|
|
2008
|
+
listAvailable: (pluginManager) => appManager.listAvailable(pluginManager),
|
|
2009
|
+
search: (pluginManager, query, limit) => appManager.search(pluginManager, query, limit),
|
|
2010
|
+
listInstalled: (pluginManager) => appManager.listInstalled(pluginManager),
|
|
2011
|
+
listRuns: (runtime) => appManager.listRuns(runtime && typeof runtime === "object"
|
|
2012
|
+
? runtime
|
|
2013
|
+
: null),
|
|
2014
|
+
getRun: (runId, runtime) => appManager.getRun(runId, runtime && typeof runtime === "object"
|
|
2015
|
+
? runtime
|
|
2016
|
+
: null),
|
|
2017
|
+
attachRun: (runId, runtime) => appManager.attachRun(runId, runtime && typeof runtime === "object"
|
|
2018
|
+
? runtime
|
|
2019
|
+
: null),
|
|
2020
|
+
detachRun: (runId) => appManager.detachRun(runId),
|
|
2021
|
+
launch: (pluginManager, name, onProgress, runtime) => appManager.launch(pluginManager, name, onProgress, runtime && typeof runtime === "object"
|
|
2022
|
+
? runtime
|
|
2023
|
+
: null),
|
|
2024
|
+
stop: (pluginManager, name, runId, runtime) => appManager.stop(pluginManager, name, runId, runtime && typeof runtime === "object"
|
|
2025
|
+
? runtime
|
|
2026
|
+
: null),
|
|
2027
|
+
recordHeartbeat: (runId) => appManager.recordHeartbeat(runId),
|
|
2028
|
+
startStaleRunSweeper: (getRuntime) => appManager.startStaleRunSweeper(getRuntime),
|
|
2029
|
+
getInfo: (pluginManager, name) => appManager.getInfo(pluginManager, name),
|
|
2030
|
+
},
|
|
2031
|
+
getPluginManager: () => getPluginManagerForState(state),
|
|
2032
|
+
parseBoundedLimit,
|
|
2033
|
+
readJsonBody,
|
|
2034
|
+
json,
|
|
2035
|
+
error,
|
|
2036
|
+
runtime: state.runtime,
|
|
2037
|
+
favoriteApps: {
|
|
2038
|
+
read: () => readFavoriteAppsFromConfig(state.config),
|
|
2039
|
+
write: (apps) => writeFavoriteAppsToConfig(state.config, apps),
|
|
2040
|
+
},
|
|
2041
|
+
})) {
|
|
2042
|
+
return;
|
|
2043
|
+
}
|
|
2044
|
+
if (await handleAppPackageRoutes({
|
|
2045
|
+
req,
|
|
2046
|
+
res,
|
|
2047
|
+
method,
|
|
2048
|
+
pathname,
|
|
2049
|
+
url,
|
|
2050
|
+
readJsonBody,
|
|
2051
|
+
json,
|
|
2052
|
+
error,
|
|
2053
|
+
runtime: state.runtime,
|
|
2054
|
+
})) {
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
// ── Slash-command catalog (/api/commands) ─────────────────────────────────
|
|
2059
|
+
if (await handleCommandsRoutes({
|
|
2060
|
+
req,
|
|
2061
|
+
res,
|
|
2062
|
+
method,
|
|
2063
|
+
pathname,
|
|
2064
|
+
url,
|
|
2065
|
+
json,
|
|
2066
|
+
error,
|
|
2067
|
+
runtime: state.runtime,
|
|
2068
|
+
})) {
|
|
2069
|
+
return;
|
|
2070
|
+
}
|
|
2071
|
+
// ── Prompt suggestions (/api/suggestions) ─────────────────────────────────
|
|
2072
|
+
if (await handleSuggestionsRoutes({
|
|
2073
|
+
req,
|
|
2074
|
+
res,
|
|
2075
|
+
method,
|
|
2076
|
+
pathname,
|
|
2077
|
+
json,
|
|
2078
|
+
error,
|
|
2079
|
+
runtime: state.runtime,
|
|
2080
|
+
})) {
|
|
2081
|
+
return;
|
|
2082
|
+
}
|
|
2083
|
+
// ── View routes (/api/views/*) ────────────────────────────────────────────
|
|
2084
|
+
if (await handleViewsRoutes({
|
|
2085
|
+
req,
|
|
2086
|
+
res,
|
|
2087
|
+
method,
|
|
2088
|
+
pathname,
|
|
2089
|
+
url,
|
|
2090
|
+
json,
|
|
2091
|
+
error,
|
|
2092
|
+
broadcastWs: state.broadcastWs ?? undefined,
|
|
2093
|
+
runtime: state.runtime,
|
|
2094
|
+
})) {
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
if (pathname.startsWith("/api/workbench")) {
|
|
2098
|
+
if (await handleWorkbenchRoutes({
|
|
2099
|
+
req,
|
|
2100
|
+
res,
|
|
2101
|
+
method,
|
|
2102
|
+
pathname,
|
|
2103
|
+
url,
|
|
2104
|
+
state: coerce(state),
|
|
2105
|
+
json,
|
|
2106
|
+
error,
|
|
2107
|
+
readJsonBody,
|
|
2108
|
+
toWorkbenchTodo: coerce(toWorkbenchTodo),
|
|
2109
|
+
normalizeTags,
|
|
2110
|
+
readTaskMetadata,
|
|
2111
|
+
readTaskCompleted,
|
|
2112
|
+
parseNullableNumber,
|
|
2113
|
+
asObject,
|
|
2114
|
+
decodePathComponent,
|
|
2115
|
+
taskToTriggerSummary: coerce(taskToTriggerSummary),
|
|
2116
|
+
listTriggerTasks: coerce(listTriggerTasks),
|
|
2117
|
+
})) {
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
2122
|
+
// Life-ops routes: now served via lifeopsPlugin.routes (rawPath) on the
|
|
2123
|
+
// runtime plugin route system. See app-lifeops/src/routes/plugin.ts.
|
|
2124
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
2125
|
+
if (pathname.startsWith("/api/mcp")) {
|
|
2126
|
+
const { handleMcpRoutes } = await getOptionalPluginApi("mcp");
|
|
2127
|
+
if (await handleMcpRoutes({
|
|
2128
|
+
req,
|
|
2129
|
+
res,
|
|
2130
|
+
method,
|
|
2131
|
+
pathname,
|
|
2132
|
+
url,
|
|
2133
|
+
state,
|
|
2134
|
+
json,
|
|
2135
|
+
error,
|
|
2136
|
+
readJsonBody,
|
|
2137
|
+
saveElizaConfig,
|
|
2138
|
+
redactDeep,
|
|
2139
|
+
isBlockedObjectKey,
|
|
2140
|
+
cloneWithoutBlockedObjectKeys,
|
|
2141
|
+
resolveMcpServersRejection,
|
|
2142
|
+
resolveMcpTerminalAuthorizationRejection,
|
|
2143
|
+
decodePathComponent,
|
|
2144
|
+
})) {
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
if (await handleMiscRoutes({
|
|
2149
|
+
req,
|
|
2150
|
+
res,
|
|
2151
|
+
method,
|
|
2152
|
+
pathname,
|
|
2153
|
+
url,
|
|
2154
|
+
state: coerce(state),
|
|
2155
|
+
json,
|
|
2156
|
+
error,
|
|
2157
|
+
readJsonBody,
|
|
2158
|
+
AGENT_EVENT_ALLOWED_STREAMS,
|
|
2159
|
+
resolveTerminalRunRejection,
|
|
2160
|
+
resolveTerminalRunClientId,
|
|
2161
|
+
isSharedTerminalClientId,
|
|
2162
|
+
activeTerminalRunCount,
|
|
2163
|
+
setActiveTerminalRunCount: (delta) => {
|
|
2164
|
+
activeTerminalRunCount = Math.max(0, activeTerminalRunCount + delta);
|
|
2165
|
+
},
|
|
2166
|
+
})) {
|
|
2167
|
+
return;
|
|
2168
|
+
}
|
|
2169
|
+
// ── WhatsApp routes (/api/whatsapp/*) ────────────────────────────────────
|
|
2170
|
+
// Extracted to @elizaos/plugin-whatsapp setup-routes.ts (Plugin.routes).
|
|
2171
|
+
// ── elizaOS plugin HTTP routes (runtime.routes, e.g. /music-player/*) ───
|
|
2172
|
+
if (await tryHandleRuntimePluginRoute({
|
|
2173
|
+
req,
|
|
2174
|
+
res,
|
|
2175
|
+
method,
|
|
2176
|
+
pathname,
|
|
2177
|
+
url,
|
|
2178
|
+
runtime: state.runtime,
|
|
2179
|
+
isAuthorized: () => isAuthorized(req),
|
|
2180
|
+
hostContext: {
|
|
2181
|
+
config: state.config,
|
|
2182
|
+
saveConfig: (nextConfig) => {
|
|
2183
|
+
state.config = nextConfig;
|
|
2184
|
+
saveElizaConfig(state.config);
|
|
2185
|
+
},
|
|
2186
|
+
restartRuntime,
|
|
2187
|
+
},
|
|
2188
|
+
})) {
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
if (await handleBuiltinOptionalRoutes(req, res, pathname, method)) {
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
// ── Connector plugin routes (dynamically registered) ────────────────────
|
|
2195
|
+
for (const handler of state.connectorRouteHandlers) {
|
|
2196
|
+
const handled = await handler(req, res, pathname, method);
|
|
2197
|
+
if (handled)
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
if (await handleMobileOptionalRoutes(req, res, pathname, method)) {
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
// ── Music player compatibility fallback ─────────────────────────────────
|
|
2204
|
+
if (await tryHandleMusicPlayerStatusFallbackLazy({
|
|
2205
|
+
pathname,
|
|
2206
|
+
method,
|
|
2207
|
+
runtime: state.runtime,
|
|
2208
|
+
res,
|
|
2209
|
+
})) {
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
// ── Hono adapter for runtime.routes with `routeHandler` (new shape) ─────
|
|
2213
|
+
// Covers any plugin route registered via the new return-shape RouteHandler
|
|
2214
|
+
// contract. Legacy Express-shaped `handler` routes are still served by
|
|
2215
|
+
// `tryHandleRuntimePluginRoute` above.
|
|
2216
|
+
if (await tryHandleHonoRuntimeRoute({
|
|
2217
|
+
req,
|
|
2218
|
+
res,
|
|
2219
|
+
runtime: state.runtime,
|
|
2220
|
+
isAuthorized: () => isAuthorized(req),
|
|
2221
|
+
})) {
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2224
|
+
// ── Fallback ────────────────────────────────────────────────────────────
|
|
2225
|
+
error(res, "Not found", 404);
|
|
2226
|
+
}
|
|
2227
|
+
// ---------------------------------------------------------------------------
|
|
2228
|
+
// Early log capture — re-exported from the standalone module so existing
|
|
2229
|
+
// callers that `import { captureEarlyLogs } from "../../../../src/api/server"` keep
|
|
2230
|
+
// working. The implementation lives in `./early-logs.ts` to avoid pulling
|
|
2231
|
+
// the entire server dependency graph into lightweight consumers (e.g. the
|
|
2232
|
+
// headless `startEliza()` path).
|
|
2233
|
+
// ---------------------------------------------------------------------------
|
|
2234
|
+
import { flushEarlyLogs } from "./early-logs.js";
|
|
2235
|
+
// ---------------------------------------------------------------------------
|
|
2236
|
+
// Server start
|
|
2237
|
+
// ---------------------------------------------------------------------------
|
|
2238
|
+
function strictPortBindingEnabled() {
|
|
2239
|
+
const value = process.env.ELIZA_API_STRICT_PORT?.trim().toLowerCase();
|
|
2240
|
+
return value === "1" || value === "true" || value === "yes";
|
|
2241
|
+
}
|
|
2242
|
+
export async function startApiServer(opts) {
|
|
2243
|
+
const apiStartTime = Date.now();
|
|
2244
|
+
// Gated boot profiler (off unless ELIZA_BOOT_PROFILE=1) to time the API-bind
|
|
2245
|
+
// critical path. Stderr, since the structured logger level may suppress it.
|
|
2246
|
+
const apiLap = (label) => {
|
|
2247
|
+
if (process.env.ELIZA_BOOT_PROFILE === "1") {
|
|
2248
|
+
process.stderr.write(`[boot-profile] api:${label} +${Date.now() - apiStartTime}ms\n`);
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
logger.debug(`[eliza-api] startApiServer called`);
|
|
2252
|
+
// Honor ELIZA_API_PORT first (set by the desktop launcher → 31337) so
|
|
2253
|
+
// the renderer's hardcoded API base reaches this server. CLI-mode
|
|
2254
|
+
// (no ELIZA_API_PORT) keeps the legacy `resolveServerOnlyPort` default
|
|
2255
|
+
// of 2138, so this change is transparent for non-desktop users.
|
|
2256
|
+
const port = opts?.port ??
|
|
2257
|
+
(process.env.ELIZA_API_PORT
|
|
2258
|
+
? resolveDesktopApiPort(process.env)
|
|
2259
|
+
: resolveServerOnlyPort(process.env));
|
|
2260
|
+
const host = resolveApiBindHost(process.env);
|
|
2261
|
+
ensureApiTokenForBindHost(host);
|
|
2262
|
+
logger.debug(`[eliza-api] Token check done (${Date.now() - apiStartTime}ms)`);
|
|
2263
|
+
let config;
|
|
2264
|
+
try {
|
|
2265
|
+
config = loadElizaConfig();
|
|
2266
|
+
}
|
|
2267
|
+
catch (err) {
|
|
2268
|
+
logger.warn(`[eliza-api] Failed to load config, starting with defaults: ${err instanceof Error ? err.message : err}`);
|
|
2269
|
+
config = {};
|
|
2270
|
+
}
|
|
2271
|
+
logger.debug(`[eliza-api] Config loaded (${Date.now() - apiStartTime}ms)`);
|
|
2272
|
+
// Wallet/inventory routes read from process.env at request-time.
|
|
2273
|
+
// Hydrate persisted config.env values so addresses remain visible after restarts.
|
|
2274
|
+
const persistedEnv = config.env;
|
|
2275
|
+
const envKeysToHydrate = [
|
|
2276
|
+
"ELIZA_WALLET_OS_STORE",
|
|
2277
|
+
"EVM_PRIVATE_KEY",
|
|
2278
|
+
"SOLANA_PRIVATE_KEY",
|
|
2279
|
+
"ALCHEMY_API_KEY",
|
|
2280
|
+
"INFURA_API_KEY",
|
|
2281
|
+
"ANKR_API_KEY",
|
|
2282
|
+
"HELIUS_API_KEY",
|
|
2283
|
+
"BIRDEYE_API_KEY",
|
|
2284
|
+
"SOLANA_RPC_URL",
|
|
2285
|
+
];
|
|
2286
|
+
for (const key of envKeysToHydrate) {
|
|
2287
|
+
const value = persistedEnv?.[key];
|
|
2288
|
+
if (typeof value === "string" && value.trim() && !process.env[key]) {
|
|
2289
|
+
process.env[key] = value.trim();
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
// Optional auto-provision mode for legacy environments. Disabled by default
|
|
2293
|
+
// so startup does not silently create new wallets when keys are missing.
|
|
2294
|
+
const walletAutoProvisionRaw = process.env.ELIZA_WALLET_AUTO_PROVISION?.trim().toLowerCase();
|
|
2295
|
+
const walletAutoProvisionEnabled = walletAutoProvisionRaw === "1" ||
|
|
2296
|
+
walletAutoProvisionRaw === "true" ||
|
|
2297
|
+
walletAutoProvisionRaw === "on" ||
|
|
2298
|
+
walletAutoProvisionRaw === "yes";
|
|
2299
|
+
if (walletAutoProvisionEnabled && ensureWalletKeysInEnvAndConfig(config)) {
|
|
2300
|
+
try {
|
|
2301
|
+
saveElizaConfig(config);
|
|
2302
|
+
}
|
|
2303
|
+
catch (err) {
|
|
2304
|
+
logger.warn(`[eliza-api] Failed to persist generated wallet keys: ${err instanceof Error ? err.message : err}`);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
const blockOnStewardWalletCache = process.env.ELIZA_STEWARD_WALLET_CACHE_BLOCKING?.trim() === "1";
|
|
2308
|
+
if (blockOnStewardWalletCache) {
|
|
2309
|
+
// Cloud/provisioned environments can opt into strict startup semantics
|
|
2310
|
+
// when wallet addresses must be available before the first request.
|
|
2311
|
+
const { initStewardWalletCache } = await getCoreWalletApi();
|
|
2312
|
+
await initStewardWalletCache();
|
|
2313
|
+
}
|
|
2314
|
+
// Warn when wallet private keys live in plaintext config and the OS secure
|
|
2315
|
+
// store is not enabled. This nudges operators toward ELIZA_WALLET_OS_STORE=1.
|
|
2316
|
+
{
|
|
2317
|
+
const hasPlaintextKeys = (typeof persistedEnv?.EVM_PRIVATE_KEY === "string" &&
|
|
2318
|
+
persistedEnv.EVM_PRIVATE_KEY.trim()) ||
|
|
2319
|
+
(typeof persistedEnv?.SOLANA_PRIVATE_KEY === "string" &&
|
|
2320
|
+
persistedEnv.SOLANA_PRIVATE_KEY.trim());
|
|
2321
|
+
const osStoreRaw = process.env.ELIZA_WALLET_OS_STORE?.trim().toLowerCase();
|
|
2322
|
+
const osStoreEnabled = osStoreRaw === "1" ||
|
|
2323
|
+
osStoreRaw === "true" ||
|
|
2324
|
+
osStoreRaw === "on" ||
|
|
2325
|
+
osStoreRaw === "yes";
|
|
2326
|
+
if (hasPlaintextKeys && !osStoreEnabled) {
|
|
2327
|
+
logger.warn("[wallet] Private keys are stored in plaintext config. " +
|
|
2328
|
+
"Set ELIZA_WALLET_OS_STORE=1 to use the OS secure store instead.");
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
const plugins = discoverPluginsFromManifest();
|
|
2332
|
+
logger.debug(`[eliza-api] Plugins discovered (${Date.now() - apiStartTime}ms)`);
|
|
2333
|
+
const workspaceDir = config.agents?.defaults?.workspace ?? resolveDefaultAgentWorkspaceDir();
|
|
2334
|
+
const hasRuntime = opts?.runtime != null;
|
|
2335
|
+
const initialAgentState = hasRuntime
|
|
2336
|
+
? "running"
|
|
2337
|
+
: (opts?.initialAgentState ?? "not_started");
|
|
2338
|
+
const initialStartup = initialAgentState === "running"
|
|
2339
|
+
? { phase: "running", attempt: 0 }
|
|
2340
|
+
: initialAgentState === "starting"
|
|
2341
|
+
? { phase: "starting", attempt: 0 }
|
|
2342
|
+
: { phase: "idle", attempt: 0 };
|
|
2343
|
+
const agentName = hasRuntime
|
|
2344
|
+
? (opts.runtime?.character.name ?? resolveDefaultAgentName(config))
|
|
2345
|
+
: resolveDefaultAgentName(config);
|
|
2346
|
+
const deletedConversationIds = readDeletedConversationIdsFromState();
|
|
2347
|
+
const state = {
|
|
2348
|
+
runtime: opts?.runtime ?? null,
|
|
2349
|
+
config,
|
|
2350
|
+
agentState: initialAgentState,
|
|
2351
|
+
agentName,
|
|
2352
|
+
model: hasRuntime
|
|
2353
|
+
? detectRuntimeModel(opts.runtime ?? null, config)
|
|
2354
|
+
: undefined,
|
|
2355
|
+
startedAt: hasRuntime || initialAgentState === "starting" ? Date.now() : undefined,
|
|
2356
|
+
startup: initialStartup,
|
|
2357
|
+
plugins,
|
|
2358
|
+
// Filled asynchronously after server start to keep startup latency low.
|
|
2359
|
+
skills: [],
|
|
2360
|
+
logBuffer: [],
|
|
2361
|
+
eventBuffer: [],
|
|
2362
|
+
nextEventId: 1,
|
|
2363
|
+
chatRoomId: null,
|
|
2364
|
+
chatUserId: null,
|
|
2365
|
+
chatConnectionReady: null,
|
|
2366
|
+
chatConnectionPromise: null,
|
|
2367
|
+
adminEntityId: null,
|
|
2368
|
+
conversations: new Map(),
|
|
2369
|
+
conversationRestorePromise: null,
|
|
2370
|
+
deletedConversationIds,
|
|
2371
|
+
cloudManager: null,
|
|
2372
|
+
sandboxManager: null,
|
|
2373
|
+
appManager: null,
|
|
2374
|
+
trainingService: null,
|
|
2375
|
+
shareIngestQueue: [],
|
|
2376
|
+
broadcastStatus: null,
|
|
2377
|
+
awaitRuntimeReady: null,
|
|
2378
|
+
broadcastWs: null,
|
|
2379
|
+
broadcastWsToClientId: null,
|
|
2380
|
+
broadcastWsToConversation: null,
|
|
2381
|
+
activeConversationId: null,
|
|
2382
|
+
permissionStates: {},
|
|
2383
|
+
shellEnabled: config.features?.shellEnabled !== false,
|
|
2384
|
+
agentAutomationMode: resolveAgentAutomationModeFromConfig(config),
|
|
2385
|
+
tradePermissionMode: resolveTradePermissionMode(config),
|
|
2386
|
+
pendingRestartReasons: [],
|
|
2387
|
+
connectorRouteHandlers: [],
|
|
2388
|
+
connectorHealthMonitor: null,
|
|
2389
|
+
whatsappPairingSessions: new Map(),
|
|
2390
|
+
};
|
|
2391
|
+
// Lets chat handlers HOLD a turn through the warming window (early API bind →
|
|
2392
|
+
// runtime ready) instead of 503-dropping it — woken in updateRuntime when
|
|
2393
|
+
// first-turn capability comes online (see runtime-ready-gate.ts).
|
|
2394
|
+
const runtimeReadyGate = createRuntimeReadyGate(() => state.runtime);
|
|
2395
|
+
state.awaitRuntimeReady = (timeoutMs) => runtimeReadyGate.await(timeoutMs);
|
|
2396
|
+
const ensureAppManager = async () => {
|
|
2397
|
+
if (state.appManager) {
|
|
2398
|
+
return state.appManager;
|
|
2399
|
+
}
|
|
2400
|
+
const { AppManager } = await getAppManagerApi();
|
|
2401
|
+
const appManager = new AppManager();
|
|
2402
|
+
state.appManager = appManager;
|
|
2403
|
+
return appManager;
|
|
2404
|
+
};
|
|
2405
|
+
const trainingServiceOptions = {
|
|
2406
|
+
getRuntime: () => state.runtime,
|
|
2407
|
+
getConfig: () => state.config,
|
|
2408
|
+
setConfig: (nextConfig) => {
|
|
2409
|
+
state.config = nextConfig;
|
|
2410
|
+
saveElizaConfig(nextConfig);
|
|
2411
|
+
},
|
|
2412
|
+
};
|
|
2413
|
+
const blockOnTrainingService = process.env.ELIZA_API_TRAINING_BLOCKING?.trim() === "1";
|
|
2414
|
+
const attachTrainingService = async () => {
|
|
2415
|
+
if (state.trainingService)
|
|
2416
|
+
return;
|
|
2417
|
+
const trainingServiceCtor = await resolveTrainingServiceCtor();
|
|
2418
|
+
if (trainingServiceCtor) {
|
|
2419
|
+
state.trainingService = new trainingServiceCtor(trainingServiceOptions);
|
|
2420
|
+
await setActiveTrainingServiceIfAvailable(state.trainingService);
|
|
2421
|
+
}
|
|
2422
|
+
else {
|
|
2423
|
+
logger.info("[eliza-api] Training service package unavailable; training routes will be disabled");
|
|
2424
|
+
}
|
|
2425
|
+
};
|
|
2426
|
+
if (blockOnTrainingService) {
|
|
2427
|
+
await attachTrainingService();
|
|
2428
|
+
}
|
|
2429
|
+
const configuredAdminEntityId = config.agents?.defaults?.adminEntityId;
|
|
2430
|
+
if (configuredAdminEntityId && isUuidLike(configuredAdminEntityId)) {
|
|
2431
|
+
state.adminEntityId = configuredAdminEntityId;
|
|
2432
|
+
state.chatUserId = state.adminEntityId;
|
|
2433
|
+
}
|
|
2434
|
+
else if (configuredAdminEntityId) {
|
|
2435
|
+
logger.warn(`[eliza-api] Ignoring invalid agents.defaults.adminEntityId "${configuredAdminEntityId}"`);
|
|
2436
|
+
}
|
|
2437
|
+
const addLog = (level, message, source = "system", tags = []) => {
|
|
2438
|
+
let resolvedSource = source;
|
|
2439
|
+
if (source === "auto" || source === "system") {
|
|
2440
|
+
const bracketMatch = /^\[([^\]]+)\]\s*/.exec(message);
|
|
2441
|
+
if (bracketMatch)
|
|
2442
|
+
resolvedSource = bracketMatch[1];
|
|
2443
|
+
}
|
|
2444
|
+
// Auto-tag based on source when no explicit tags provided
|
|
2445
|
+
const resolvedTags = tags.length > 0
|
|
2446
|
+
? tags
|
|
2447
|
+
: resolvedSource === "runtime" || resolvedSource === "autonomy"
|
|
2448
|
+
? ["agent"]
|
|
2449
|
+
: resolvedSource === "api" || resolvedSource === "websocket"
|
|
2450
|
+
? ["server"]
|
|
2451
|
+
: resolvedSource === "cloud"
|
|
2452
|
+
? ["server", "cloud"]
|
|
2453
|
+
: ["system"];
|
|
2454
|
+
pushWithBatchEvict(state.logBuffer, {
|
|
2455
|
+
timestamp: Date.now(),
|
|
2456
|
+
level,
|
|
2457
|
+
message,
|
|
2458
|
+
source: resolvedSource,
|
|
2459
|
+
tags: resolvedTags,
|
|
2460
|
+
}, 1200, 200);
|
|
2461
|
+
};
|
|
2462
|
+
// ── Flush early-captured logs into the main buffer ────────────────────
|
|
2463
|
+
const earlyEntries = flushEarlyLogs();
|
|
2464
|
+
if (earlyEntries.length > 0) {
|
|
2465
|
+
for (const entry of earlyEntries) {
|
|
2466
|
+
state.logBuffer.push(entry);
|
|
2467
|
+
}
|
|
2468
|
+
if (state.logBuffer.length > 1000) {
|
|
2469
|
+
state.logBuffer.splice(0, state.logBuffer.length - 1000);
|
|
2470
|
+
}
|
|
2471
|
+
addLog("info", `Flushed ${earlyEntries.length} early startup log entries`, "system", ["system"]);
|
|
2472
|
+
}
|
|
2473
|
+
addLog("info", `Discovered ${plugins.length} plugins, loading skills in background`, "system", ["system", "plugins"]);
|
|
2474
|
+
// Warm per-provider model caches in background (non-blocking)
|
|
2475
|
+
void getOrFetchAllProviders().catch((err) => {
|
|
2476
|
+
logger.warn("[api] Provider cache warm-up failed:", err);
|
|
2477
|
+
});
|
|
2478
|
+
// ── Intercept loggers so ALL agent/plugin/service logs appear in the UI ──
|
|
2479
|
+
// We patch both the global `logger` singleton from @elizaos/core (used by
|
|
2480
|
+
// eliza.ts, services, plugins, etc.) AND the runtime instance logger.
|
|
2481
|
+
// A marker prevents double-patching on hot-restart and avoids stacking
|
|
2482
|
+
// wrapper functions that would leak memory.
|
|
2483
|
+
const PATCHED_MARKER = "__elizaLogPatched";
|
|
2484
|
+
const LEVELS = ["debug", "info", "warn", "error"];
|
|
2485
|
+
/**
|
|
2486
|
+
* Patch a logger object so every log call also feeds into the UI log buffer.
|
|
2487
|
+
* Returns true if patching was performed, false if already patched.
|
|
2488
|
+
*/
|
|
2489
|
+
const patchLogger = (target, defaultSource, defaultTags) => {
|
|
2490
|
+
const patchedTarget = target;
|
|
2491
|
+
if (patchedTarget[PATCHED_MARKER]) {
|
|
2492
|
+
return false;
|
|
2493
|
+
}
|
|
2494
|
+
for (const lvl of LEVELS) {
|
|
2495
|
+
const original = target[lvl].bind(target);
|
|
2496
|
+
// pino / adze signature: logger.info(obj, msg) or logger.info(msg)
|
|
2497
|
+
const patched = (...args) => {
|
|
2498
|
+
let msg = "";
|
|
2499
|
+
let source = defaultSource;
|
|
2500
|
+
let tags = [...defaultTags];
|
|
2501
|
+
if (typeof args[0] === "string") {
|
|
2502
|
+
msg = args[0];
|
|
2503
|
+
}
|
|
2504
|
+
else if (args[0] && typeof args[0] === "object") {
|
|
2505
|
+
const obj = args[0];
|
|
2506
|
+
if (typeof obj.src === "string")
|
|
2507
|
+
source = obj.src;
|
|
2508
|
+
// Extract tags from structured log objects
|
|
2509
|
+
if (Array.isArray(obj.tags)) {
|
|
2510
|
+
tags = [...tags, ...obj.tags];
|
|
2511
|
+
}
|
|
2512
|
+
msg = typeof args[1] === "string" ? args[1] : JSON.stringify(obj);
|
|
2513
|
+
}
|
|
2514
|
+
// Auto-extract source from [bracket] prefixes (e.g. "[eliza] ...")
|
|
2515
|
+
const bracketMatch = /^\[([^\]]+)\]\s*/.exec(msg);
|
|
2516
|
+
if (bracketMatch && source === defaultSource) {
|
|
2517
|
+
source = bracketMatch[1];
|
|
2518
|
+
}
|
|
2519
|
+
// Auto-tag based on source context
|
|
2520
|
+
if (source !== defaultSource && !tags.includes(source)) {
|
|
2521
|
+
tags.push(source);
|
|
2522
|
+
}
|
|
2523
|
+
if (msg)
|
|
2524
|
+
addLog(lvl, msg, source, tags);
|
|
2525
|
+
return original(...args);
|
|
2526
|
+
};
|
|
2527
|
+
target[lvl] = patched;
|
|
2528
|
+
}
|
|
2529
|
+
patchedTarget[PATCHED_MARKER] = true;
|
|
2530
|
+
return true;
|
|
2531
|
+
};
|
|
2532
|
+
// 1) Patch the global @elizaos/core logger — this captures ALL log calls
|
|
2533
|
+
// from eliza.ts, services, plugins, cloud, hooks, etc.
|
|
2534
|
+
if (patchLogger(logger, "agent", ["agent"])) {
|
|
2535
|
+
addLog("info", "Global logger connected — all agent logs will stream to the UI", "system", ["system", "agent"]);
|
|
2536
|
+
}
|
|
2537
|
+
// 2) Patch the runtime instance logger (if it's a different object)
|
|
2538
|
+
// This catches logs from runtime internals that use their own logger child.
|
|
2539
|
+
if (opts?.runtime?.logger && opts.runtime.logger !== logger) {
|
|
2540
|
+
if (patchLogger(opts.runtime.logger, "runtime", ["agent", "runtime"])) {
|
|
2541
|
+
addLog("info", "Runtime logger connected — runtime logs will stream to the UI", "system", ["system", "agent"]);
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
// Store the restart callback on the state so the route handler can access it.
|
|
2545
|
+
const onRestart = opts?.onRestart ?? null;
|
|
2546
|
+
logger.debug(`[eliza-api] Creating http server (${Date.now() - apiStartTime}ms)`);
|
|
2547
|
+
apiLap("pre-createServer (route imports + middleware setup done)");
|
|
2548
|
+
const server = http.createServer(async (req, res) => {
|
|
2549
|
+
try {
|
|
2550
|
+
await handleRequest(req, res, state, {
|
|
2551
|
+
onRestart,
|
|
2552
|
+
onRuntimeSwapped: () => {
|
|
2553
|
+
bindRuntimeStreams(state.runtime);
|
|
2554
|
+
void wireCoordinatorBridgesWhenReady(state, {
|
|
2555
|
+
wireChatBridge: wireCodingAgentChatBridge,
|
|
2556
|
+
wireWsBridge: wireCodingAgentWsBridge,
|
|
2557
|
+
wireEventRouting: wireCoordinatorEventRouting,
|
|
2558
|
+
wireSwarmSynthesis: wireCodingAgentSwarmSynthesis,
|
|
2559
|
+
context: "restart",
|
|
2560
|
+
logger,
|
|
2561
|
+
});
|
|
2562
|
+
},
|
|
2563
|
+
getAppManager: ensureAppManager,
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
catch (err) {
|
|
2567
|
+
const msg = err instanceof Error ? err.message : "internal error";
|
|
2568
|
+
logger.error({ err }, `[eliza-api] Request handler failed: ${msg}`);
|
|
2569
|
+
addLog("error", msg, "api", ["server", "api"]);
|
|
2570
|
+
error(res, msg, 500);
|
|
2571
|
+
}
|
|
2572
|
+
});
|
|
2573
|
+
if (isMobilePlatform() ||
|
|
2574
|
+
process.env.ELIZA_DEVICE_BRIDGE_ENABLED?.trim() === "1") {
|
|
2575
|
+
void getOptionalPluginApi("capacitor")
|
|
2576
|
+
.then(({ attachMobileDeviceBridgeToServer }) => attachMobileDeviceBridgeToServer(server))
|
|
2577
|
+
.catch((err) => {
|
|
2578
|
+
logger.warn("[eliza-api] Failed to attach mobile device bridge:", err instanceof Error ? err.message : String(err));
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
logger.debug(`[eliza-api] Server created (${Date.now() - apiStartTime}ms)`);
|
|
2582
|
+
// Node's `http.createServer` defaults are tuned for snappy web traffic:
|
|
2583
|
+
// - requestTimeout: 300_000 ms (5 min) — closes the socket if the
|
|
2584
|
+
// full request hasn't completed in 5 minutes.
|
|
2585
|
+
// - headersTimeout: 60_000 ms — closes the socket if headers
|
|
2586
|
+
// haven't arrived in 60 s.
|
|
2587
|
+
// - keepAliveTimeout: 5_000 ms — closes idle connections after 5 s.
|
|
2588
|
+
//
|
|
2589
|
+
// Local-inference chat completions on AOSP cuttlefish CPU routinely
|
|
2590
|
+
// run 5–25 minutes per turn (planner + action evaluator + reply,
|
|
2591
|
+
// each with a 9k-token prompt prefilled at ~20 tok/s). The 300 s
|
|
2592
|
+
// requestTimeout aborts the response mid-generation and the client
|
|
2593
|
+
// sees `fetch failed` while the agent's chat-routes timeout
|
|
2594
|
+
// (ELIZA_CHAT_GENERATION_TIMEOUT_MS, default 180 s, AOSP override
|
|
2595
|
+
// 1_800_000 ms = 30 min) is still ticking. The result: the device
|
|
2596
|
+
// does the work, the model produces a reply, but the HTTP socket
|
|
2597
|
+
// is already closed by the time the reply is ready.
|
|
2598
|
+
//
|
|
2599
|
+
// Read overrides from env so non-AOSP deploys keep tighter defaults,
|
|
2600
|
+
// and AOSP can pass a generous bound that matches the chat-routes
|
|
2601
|
+
// generation budget. ELIZA_HTTP_REQUEST_TIMEOUT_MS is the canonical
|
|
2602
|
+
// override; falls back to ELIZA_CHAT_GENERATION_TIMEOUT_MS + 60 s
|
|
2603
|
+
// slack so a single env var can drive the whole pipeline.
|
|
2604
|
+
const requestTimeoutEnvRaw = process.env.ELIZA_HTTP_REQUEST_TIMEOUT_MS?.trim() ?? "";
|
|
2605
|
+
const chatTimeoutEnvRaw = process.env.ELIZA_CHAT_GENERATION_TIMEOUT_MS?.trim() ?? "";
|
|
2606
|
+
const requestTimeoutMs = (() => {
|
|
2607
|
+
const explicit = Number.parseInt(requestTimeoutEnvRaw, 10);
|
|
2608
|
+
if (Number.isFinite(explicit) && explicit > 0)
|
|
2609
|
+
return explicit;
|
|
2610
|
+
const chatTimeout = Number.parseInt(chatTimeoutEnvRaw, 10);
|
|
2611
|
+
if (Number.isFinite(chatTimeout) && chatTimeout > 0) {
|
|
2612
|
+
// 60 s slack covers the round-trip overhead between chat-routes
|
|
2613
|
+
// resolving the generation promise and the response actually
|
|
2614
|
+
// landing on the wire.
|
|
2615
|
+
return chatTimeout + 60_000;
|
|
2616
|
+
}
|
|
2617
|
+
// No override and no chat-timeout hint — keep Node's default
|
|
2618
|
+
// (300_000 ms / 5 min) which matches the upstream behavior.
|
|
2619
|
+
return 300_000;
|
|
2620
|
+
})();
|
|
2621
|
+
// headersTimeout MUST be ≤ requestTimeout per Node docs. We give it
|
|
2622
|
+
// a 60 s lower bound so a slow client header upload doesn't cap the
|
|
2623
|
+
// long-tail decode budget.
|
|
2624
|
+
const headersTimeoutMs = Math.min(60_000, requestTimeoutMs);
|
|
2625
|
+
// keepAliveTimeout is for IDLE connections after a response. Bumping
|
|
2626
|
+
// it doesn't help long-running requests but keeps connections warm
|
|
2627
|
+
// for chat-completion clients that fire repeated turns.
|
|
2628
|
+
const keepAliveTimeoutMs = 60_000;
|
|
2629
|
+
server.requestTimeout = requestTimeoutMs;
|
|
2630
|
+
server.headersTimeout = headersTimeoutMs;
|
|
2631
|
+
server.keepAliveTimeout = keepAliveTimeoutMs;
|
|
2632
|
+
// server.timeout is the IDLE socket timeout (legacy). Setting to 0
|
|
2633
|
+
// disables it; we want long-running requests to ride on the
|
|
2634
|
+
// requestTimeout above instead. Default in Node 22 is 0 already, but
|
|
2635
|
+
// pin explicitly for clarity.
|
|
2636
|
+
server.timeout = 0;
|
|
2637
|
+
logger.debug(`[eliza-api] Server timeouts: requestTimeout=${requestTimeoutMs}ms, headersTimeout=${headersTimeoutMs}ms, keepAliveTimeout=${keepAliveTimeoutMs}ms`);
|
|
2638
|
+
const broadcastWs = (payload) => {
|
|
2639
|
+
const message = JSON.stringify(payload);
|
|
2640
|
+
for (const client of wsClients) {
|
|
2641
|
+
if (client.readyState === 1) {
|
|
2642
|
+
try {
|
|
2643
|
+
client.send(message);
|
|
2644
|
+
}
|
|
2645
|
+
catch (err) {
|
|
2646
|
+
logger.error(`[eliza-api] WebSocket broadcast error: ${err instanceof Error ? err.message : err}`);
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
};
|
|
2651
|
+
const pushEvent = (event) => {
|
|
2652
|
+
const seq = state.nextEventId;
|
|
2653
|
+
const envelope = {
|
|
2654
|
+
...event,
|
|
2655
|
+
eventId: `evt-${seq}`,
|
|
2656
|
+
bufferSeq: seq,
|
|
2657
|
+
version: 1,
|
|
2658
|
+
};
|
|
2659
|
+
state.nextEventId += 1;
|
|
2660
|
+
state.eventBuffer.push(envelope);
|
|
2661
|
+
if (state.eventBuffer.length > 1500) {
|
|
2662
|
+
state.eventBuffer.splice(0, state.eventBuffer.length - 1500);
|
|
2663
|
+
}
|
|
2664
|
+
broadcastWs(envelope);
|
|
2665
|
+
};
|
|
2666
|
+
let detachRuntimeStreams = null;
|
|
2667
|
+
let detachTrainingStream = null;
|
|
2668
|
+
const bindRuntimeStreams = (runtime) => {
|
|
2669
|
+
if (detachRuntimeStreams) {
|
|
2670
|
+
detachRuntimeStreams();
|
|
2671
|
+
detachRuntimeStreams = null;
|
|
2672
|
+
}
|
|
2673
|
+
const svc = getAgentEventSvc(runtime);
|
|
2674
|
+
if (!svc) {
|
|
2675
|
+
if (runtime) {
|
|
2676
|
+
logger.warn("[eliza-api] AGENT_EVENT service not found on runtime — event streaming will be unavailable");
|
|
2677
|
+
}
|
|
2678
|
+
return;
|
|
2679
|
+
}
|
|
2680
|
+
const unsubAgentEvents = svc.subscribe((event) => {
|
|
2681
|
+
pushEvent({
|
|
2682
|
+
type: "agent_event",
|
|
2683
|
+
ts: event.ts,
|
|
2684
|
+
runId: event.runId,
|
|
2685
|
+
seq: event.seq,
|
|
2686
|
+
stream: event.stream,
|
|
2687
|
+
sessionKey: event.sessionKey,
|
|
2688
|
+
agentId: event.agentId,
|
|
2689
|
+
roomId: event.roomId,
|
|
2690
|
+
payload: event.data,
|
|
2691
|
+
});
|
|
2692
|
+
void maybeRouteAutonomyEventToConversation(state, event).catch((err) => {
|
|
2693
|
+
logger.warn(`[autonomy-route] Failed to route proactive event: ${err instanceof Error ? err.message : String(err)}`);
|
|
2694
|
+
});
|
|
2695
|
+
});
|
|
2696
|
+
const unsubHeartbeat = svc.subscribeHeartbeat((event) => {
|
|
2697
|
+
pushEvent({
|
|
2698
|
+
type: "heartbeat_event",
|
|
2699
|
+
ts: event.ts,
|
|
2700
|
+
payload: event,
|
|
2701
|
+
});
|
|
2702
|
+
});
|
|
2703
|
+
detachRuntimeStreams = () => {
|
|
2704
|
+
unsubAgentEvents();
|
|
2705
|
+
unsubHeartbeat();
|
|
2706
|
+
};
|
|
2707
|
+
};
|
|
2708
|
+
const bindTrainingStream = () => {
|
|
2709
|
+
if (detachTrainingStream) {
|
|
2710
|
+
detachTrainingStream();
|
|
2711
|
+
detachTrainingStream = null;
|
|
2712
|
+
}
|
|
2713
|
+
if (!state.trainingService)
|
|
2714
|
+
return;
|
|
2715
|
+
detachTrainingStream = state.trainingService.subscribe((event) => {
|
|
2716
|
+
const payload = typeof event === "object" && event !== null ? event : { value: event };
|
|
2717
|
+
pushEvent({
|
|
2718
|
+
type: "training_event",
|
|
2719
|
+
ts: Date.now(),
|
|
2720
|
+
payload,
|
|
2721
|
+
});
|
|
2722
|
+
});
|
|
2723
|
+
};
|
|
2724
|
+
// ── Deferred startup work (non-blocking) ────────────────────────────────
|
|
2725
|
+
// Keep API startup fast: listen first, then warm optional subsystems.
|
|
2726
|
+
const startDeferredStartupWork = async () => {
|
|
2727
|
+
void registerBuiltinViews().catch((err) => {
|
|
2728
|
+
logger.warn(`[eliza-api] Built-in view registration failed after listen: ${err instanceof Error ? err.message : String(err)}`);
|
|
2729
|
+
});
|
|
2730
|
+
void ensureAppManager()
|
|
2731
|
+
.then((appManager) => {
|
|
2732
|
+
// Stop app runs whose UI heartbeat has gone silent.
|
|
2733
|
+
appManager.startStaleRunSweeper(() => state.runtime);
|
|
2734
|
+
})
|
|
2735
|
+
.catch((err) => {
|
|
2736
|
+
logger.warn(`[eliza-api] App manager startup work failed after listen: ${err instanceof Error ? err.message : String(err)}`);
|
|
2737
|
+
});
|
|
2738
|
+
if (!blockOnStewardWalletCache) {
|
|
2739
|
+
void getCoreWalletApi()
|
|
2740
|
+
.then(({ initStewardWalletCache }) => initStewardWalletCache())
|
|
2741
|
+
.catch((err) => {
|
|
2742
|
+
logger.debug(`[eliza-api] Steward wallet cache init failed after listen: ${err instanceof Error ? err.message : String(err)}`);
|
|
2743
|
+
});
|
|
2744
|
+
}
|
|
2745
|
+
void (async () => {
|
|
2746
|
+
try {
|
|
2747
|
+
const { discoverSkills } = await getAgentSkillsApi();
|
|
2748
|
+
const discoveredSkills = await discoverSkills(workspaceDir, state.config, state.runtime);
|
|
2749
|
+
state.skills = discoveredSkills;
|
|
2750
|
+
addLog("info", `Discovered ${discoveredSkills.length} skills`, "system", ["system", "plugins"]);
|
|
2751
|
+
}
|
|
2752
|
+
catch (err) {
|
|
2753
|
+
logger.warn(`[eliza-api] Skill discovery failed during startup: ${err instanceof Error ? err.message : String(err)}`);
|
|
2754
|
+
}
|
|
2755
|
+
})();
|
|
2756
|
+
void (async () => {
|
|
2757
|
+
await attachTrainingService();
|
|
2758
|
+
const trainingService = state.trainingService;
|
|
2759
|
+
if (!trainingService)
|
|
2760
|
+
return;
|
|
2761
|
+
try {
|
|
2762
|
+
await trainingService.initialize();
|
|
2763
|
+
bindTrainingStream();
|
|
2764
|
+
addLog("info", "Training service initialised", "system", [
|
|
2765
|
+
"system",
|
|
2766
|
+
"training",
|
|
2767
|
+
]);
|
|
2768
|
+
}
|
|
2769
|
+
catch (err) {
|
|
2770
|
+
logger.error(`[eliza-api] Training service init failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
2771
|
+
}
|
|
2772
|
+
})();
|
|
2773
|
+
// ERC-8004 RegistryService + DropService construction has moved into
|
|
2774
|
+
// elizaMakerPlugin.init() in @elizaos/plugin-elizamaker. The plugin reads
|
|
2775
|
+
// the live services via getElizaMakerRegistryService() /
|
|
2776
|
+
// getElizaMakerDropService() in this package.
|
|
2777
|
+
// ── Connector health monitoring ──────────────────────────────────────────
|
|
2778
|
+
if (state.runtime && state.config.connectors) {
|
|
2779
|
+
try {
|
|
2780
|
+
state.connectorHealthMonitor = await createConnectorHealthMonitor({
|
|
2781
|
+
runtime: state.runtime,
|
|
2782
|
+
config: state.config,
|
|
2783
|
+
broadcastWs,
|
|
2784
|
+
});
|
|
2785
|
+
state.connectorHealthMonitor.start();
|
|
2786
|
+
}
|
|
2787
|
+
catch (err) {
|
|
2788
|
+
logger.warn(`[eliza-api] Connector health monitor failed after listen: ${err instanceof Error ? err.message : String(err)}`);
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
// ── Dynamic streaming + connector route loading ────────────────────────
|
|
2792
|
+
// Always register generic stream routes. If a streaming destination is
|
|
2793
|
+
// configured, inject it so /api/stream/live can fetch credentials.
|
|
2794
|
+
void (async () => {
|
|
2795
|
+
if (isMobilePlatform() &&
|
|
2796
|
+
process.env.ELIZA_MOBILE_ENABLE_STREAMING_ROUTES !== "1") {
|
|
2797
|
+
logger.debug("[eliza-api] Desktop streaming routes disabled on mobile platform.");
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
try {
|
|
2801
|
+
const streamRoutes = await import(
|
|
2802
|
+
/* @vite-ignore */ "@elizaos/plugin-streaming");
|
|
2803
|
+
const handleStreamRoute = typeof streamRoutes.handleStreamRoute === "function"
|
|
2804
|
+
? streamRoutes.handleStreamRoute
|
|
2805
|
+
: null;
|
|
2806
|
+
if (!handleStreamRoute) {
|
|
2807
|
+
logger.debug("[eliza-api] @elizaos/plugin-streaming did not export handleStreamRoute; skipping streaming route registration.");
|
|
2808
|
+
}
|
|
2809
|
+
// Screen capture manager is injected by the desktop host via globalThis
|
|
2810
|
+
const screenCapture = globalThis
|
|
2811
|
+
.__elizaScreenCapture;
|
|
2812
|
+
// Build destination registry — all configured destinations
|
|
2813
|
+
const _connectors = state.config.connectors ?? {};
|
|
2814
|
+
const streaming = state.config.streaming;
|
|
2815
|
+
const destinations = new Map();
|
|
2816
|
+
try {
|
|
2817
|
+
const streamMod = await loadStreamingPluginDestinationFactories();
|
|
2818
|
+
if (isStreamingDestinationConfigured("customRtmp", streaming?.customRtmp)) {
|
|
2819
|
+
destinations.set("custom-rtmp", streamMod.createCustomRtmpDestination(streaming?.customRtmp));
|
|
2820
|
+
}
|
|
2821
|
+
const rawSources = streaming?.rtmpSources;
|
|
2822
|
+
if (Array.isArray(rawSources)) {
|
|
2823
|
+
for (const row of rawSources) {
|
|
2824
|
+
if (!row || typeof row !== "object")
|
|
2825
|
+
continue;
|
|
2826
|
+
const rec = row;
|
|
2827
|
+
const id = String(rec.id ?? "").trim();
|
|
2828
|
+
const name = String(rec.name ?? id).trim();
|
|
2829
|
+
const rtmpUrl = String(rec.rtmpUrl ?? "").trim();
|
|
2830
|
+
const rtmpKey = String(rec.rtmpKey ?? "").trim();
|
|
2831
|
+
if (!id || !rtmpUrl || !rtmpKey)
|
|
2832
|
+
continue;
|
|
2833
|
+
destinations.set(id, streamMod.createNamedRtmpDestination({
|
|
2834
|
+
id,
|
|
2835
|
+
name,
|
|
2836
|
+
rtmpUrl,
|
|
2837
|
+
rtmpKey,
|
|
2838
|
+
}));
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
if (isStreamingDestinationConfigured("twitch", streaming?.twitch)) {
|
|
2842
|
+
destinations.set("twitch", streamMod.createTwitchDestination(undefined, streaming?.twitch));
|
|
2843
|
+
}
|
|
2844
|
+
if (isStreamingDestinationConfigured("youtube", streaming?.youtube)) {
|
|
2845
|
+
destinations.set("youtube", streamMod.createYoutubeDestination(undefined, streaming?.youtube));
|
|
2846
|
+
}
|
|
2847
|
+
if (isStreamingDestinationConfigured("pumpfun", streaming?.pumpfun)) {
|
|
2848
|
+
destinations.set("pumpfun", streamMod.createPumpfunDestination(undefined, streaming?.pumpfun));
|
|
2849
|
+
}
|
|
2850
|
+
if (isStreamingDestinationConfigured("x", streaming?.x)) {
|
|
2851
|
+
destinations.set("x", streamMod.createXStreamDestination(undefined, streaming?.x));
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
catch (err) {
|
|
2855
|
+
logger.warn(`[eliza-api] Failed to load @elizaos/plugin-streaming destinations: ${err instanceof Error ? err.message : String(err)}`);
|
|
2856
|
+
}
|
|
2857
|
+
// Active destination: config preference → first available
|
|
2858
|
+
const activeDestinationId = streaming?.activeDestination ??
|
|
2859
|
+
(destinations.size > 0
|
|
2860
|
+
? destinations.keys().next().value
|
|
2861
|
+
: undefined);
|
|
2862
|
+
const { streamManager } = await getOptionalPluginApi("streaming");
|
|
2863
|
+
const streamState = {
|
|
2864
|
+
streamManager,
|
|
2865
|
+
port,
|
|
2866
|
+
screenCapture,
|
|
2867
|
+
captureUrl: undefined,
|
|
2868
|
+
destinations,
|
|
2869
|
+
activeDestinationId,
|
|
2870
|
+
activeStreamSource: { type: "stream-tab" },
|
|
2871
|
+
mirrorStreamAvatarToElizaConfig: (avatarIndex) => {
|
|
2872
|
+
try {
|
|
2873
|
+
if (!Number.isFinite(avatarIndex)) {
|
|
2874
|
+
return;
|
|
2875
|
+
}
|
|
2876
|
+
const diskCfg = loadElizaConfig();
|
|
2877
|
+
const lang = state.config.ui?.language ?? diskCfg.ui?.language;
|
|
2878
|
+
const preset = resolveStylePresetByAvatarIndex(avatarIndex, lang);
|
|
2879
|
+
const nextUi = {
|
|
2880
|
+
...(state.config.ui ?? {}),
|
|
2881
|
+
avatarIndex,
|
|
2882
|
+
...(preset?.id ? { presetId: preset.id } : {}),
|
|
2883
|
+
};
|
|
2884
|
+
state.config = {
|
|
2885
|
+
...state.config,
|
|
2886
|
+
ui: nextUi,
|
|
2887
|
+
};
|
|
2888
|
+
// Merge disk + live server config so we never persist a minimal
|
|
2889
|
+
// snapshot (e.g. ENOENT default) and clobber eliza.json during
|
|
2890
|
+
// first-run while state.config still holds the full boot payload.
|
|
2891
|
+
const toSave = {
|
|
2892
|
+
...diskCfg,
|
|
2893
|
+
...state.config,
|
|
2894
|
+
ui: {
|
|
2895
|
+
...(diskCfg.ui ?? {}),
|
|
2896
|
+
...(state.config.ui ?? {}),
|
|
2897
|
+
...nextUi,
|
|
2898
|
+
},
|
|
2899
|
+
};
|
|
2900
|
+
saveElizaConfig(toSave);
|
|
2901
|
+
state.config = {
|
|
2902
|
+
...state.config,
|
|
2903
|
+
ui: toSave.ui,
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2906
|
+
catch (err) {
|
|
2907
|
+
logger.warn(`[eliza-api] mirrorStreamAvatarToElizaConfig failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
2908
|
+
}
|
|
2909
|
+
},
|
|
2910
|
+
get config() {
|
|
2911
|
+
const cfg = state.config;
|
|
2912
|
+
const msgs = cfg?.messages;
|
|
2913
|
+
return msgs
|
|
2914
|
+
? {
|
|
2915
|
+
messages: {
|
|
2916
|
+
tts: msgs.tts,
|
|
2917
|
+
},
|
|
2918
|
+
}
|
|
2919
|
+
: undefined;
|
|
2920
|
+
},
|
|
2921
|
+
};
|
|
2922
|
+
// `handleStreamRoute` is exported by `@elizaos/plugin-streaming`,
|
|
2923
|
+
// which the mobile bundle replaces with a null-plugin proxy (see
|
|
2924
|
+
// `packages/agent/scripts/build-mobile-bundle.mjs` —
|
|
2925
|
+
// `@elizaos/plugin-streaming` is in the mobile replacement allowlist because the
|
|
2926
|
+
// TTS / SSE worker pool has zero mobile use). On mobile the
|
|
2927
|
+
// dynamic import resolves successfully but `handleStreamRoute` is
|
|
2928
|
+
// `undefined`, and the closure here gets pushed into
|
|
2929
|
+
// `connectorRouteHandlers` anyway — so every inbound HTTP request
|
|
2930
|
+
// (including `/api/local-inference/device-bridge/status`) errors
|
|
2931
|
+
// with `handleStreamRoute is not a function`. Skip the push when
|
|
2932
|
+
// the import returned a null-plugin proxy.
|
|
2933
|
+
if (typeof handleStreamRoute === "function") {
|
|
2934
|
+
state.connectorRouteHandlers.push((req, res, pathname, method) => handleStreamRoute(req, res, pathname, method, streamState));
|
|
2935
|
+
}
|
|
2936
|
+
const destNames = Array.from(destinations.values())
|
|
2937
|
+
.map((d) => d.name)
|
|
2938
|
+
.join(", ");
|
|
2939
|
+
const destLabel = destinations.size > 0
|
|
2940
|
+
? `destinations: ${destNames}`
|
|
2941
|
+
: "no destinations";
|
|
2942
|
+
addLog("info", `Stream routes registered (${destLabel})`, "system", [
|
|
2943
|
+
"system",
|
|
2944
|
+
"streaming",
|
|
2945
|
+
]);
|
|
2946
|
+
}
|
|
2947
|
+
catch (err) {
|
|
2948
|
+
logger.warn(`[eliza-api] Failed to load stream routes: ${err instanceof Error ? err.message : String(err)}`);
|
|
2949
|
+
}
|
|
2950
|
+
})();
|
|
2951
|
+
};
|
|
2952
|
+
// ── WebSocket Server ─────────────────────────────────────────────────────
|
|
2953
|
+
const wss = new WebSocketServer({ noServer: true, maxPayload: 64 * 1024 });
|
|
2954
|
+
const wsClients = new Set();
|
|
2955
|
+
const wsClientIds = new WeakMap();
|
|
2956
|
+
/**
|
|
2957
|
+
* Per-connection active conversation. Each browser window/client owns its own
|
|
2958
|
+
* active conversation, so two windows no longer fight over a single global.
|
|
2959
|
+
* `state.activeConversationId` is kept as the "most recent active conversation"
|
|
2960
|
+
* default for code paths that legitimately need *any* active conversation
|
|
2961
|
+
* (autonomy routing, swarm synthesis) and don't target a specific client.
|
|
2962
|
+
*/
|
|
2963
|
+
const wsActiveConversations = new WeakMap();
|
|
2964
|
+
/** Per-WS-client PTY output subscriptions: sessionId → unsubscribe */
|
|
2965
|
+
const wsClientPtySubscriptions = new WeakMap();
|
|
2966
|
+
/**
|
|
2967
|
+
* Short-window idempotency cache for client-tagged WS messages, keyed by
|
|
2968
|
+
* `${clientId}:${msgId}`. A message resent after a reconnect (same id) is
|
|
2969
|
+
* dropped if seen within the TTL. Entries expire so the map stays bounded.
|
|
2970
|
+
*/
|
|
2971
|
+
const wsSeenMessageIds = new Map();
|
|
2972
|
+
const WS_DEDUPE_TTL_MS = 30_000;
|
|
2973
|
+
let wsSeenLastSweepAt = 0;
|
|
2974
|
+
const isDuplicateWsMessage = (clientId, msgId) => {
|
|
2975
|
+
if (typeof msgId !== "string" || msgId.length === 0)
|
|
2976
|
+
return false;
|
|
2977
|
+
const key = `${clientId ?? "anon"}:${msgId}`;
|
|
2978
|
+
const now = Date.now();
|
|
2979
|
+
// O(1) TTL-aware dedupe: a still-fresh entry means this id was already seen
|
|
2980
|
+
// within the window. Correctness no longer depends on first scanning the
|
|
2981
|
+
// whole map — the previous full-scan-on-every-message was O(n) per message
|
|
2982
|
+
// (O(n^2) under a burst).
|
|
2983
|
+
const seenAt = wsSeenMessageIds.get(key);
|
|
2984
|
+
if (seenAt !== undefined && now - seenAt <= WS_DEDUPE_TTL_MS)
|
|
2985
|
+
return true;
|
|
2986
|
+
wsSeenMessageIds.set(key, now);
|
|
2987
|
+
// Amortized eviction: sweep expired entries at most once per TTL window
|
|
2988
|
+
// instead of on every message; keeps the map bounded without the per-
|
|
2989
|
+
// message scan.
|
|
2990
|
+
if (now - wsSeenLastSweepAt > WS_DEDUPE_TTL_MS) {
|
|
2991
|
+
wsSeenLastSweepAt = now;
|
|
2992
|
+
for (const [seenKey, ts] of wsSeenMessageIds) {
|
|
2993
|
+
if (now - ts > WS_DEDUPE_TTL_MS)
|
|
2994
|
+
wsSeenMessageIds.delete(seenKey);
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
return false;
|
|
2998
|
+
};
|
|
2999
|
+
bindRuntimeStreams(opts?.runtime ?? null);
|
|
3000
|
+
bindTrainingStream();
|
|
3001
|
+
// Wire coding-agent bridges at initial boot (event-driven via getServiceLoadPromise)
|
|
3002
|
+
if (opts?.runtime) {
|
|
3003
|
+
void wireCoordinatorBridgesWhenReady(state, {
|
|
3004
|
+
wireChatBridge: wireCodingAgentChatBridge,
|
|
3005
|
+
wireWsBridge: wireCodingAgentWsBridge,
|
|
3006
|
+
wireEventRouting: wireCoordinatorEventRouting,
|
|
3007
|
+
wireSwarmSynthesis: wireCodingAgentSwarmSynthesis,
|
|
3008
|
+
context: "boot",
|
|
3009
|
+
logger,
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
// Handle upgrade requests for WebSocket
|
|
3013
|
+
server.on("upgrade", (request, socket, head) => {
|
|
3014
|
+
try {
|
|
3015
|
+
const wsUrl = new URL(request.url ?? "/", `http://${request.headers.host ?? "localhost"}`);
|
|
3016
|
+
if (wsUrl.pathname === "/api/local-inference/device-bridge") {
|
|
3017
|
+
return;
|
|
3018
|
+
}
|
|
3019
|
+
const rejection = resolveWebSocketUpgradeRejection(request, wsUrl);
|
|
3020
|
+
if (rejection) {
|
|
3021
|
+
rejectWebSocketUpgrade(socket, rejection.status, rejection.reason);
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
3024
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
3025
|
+
wss.emit("connection", ws, request);
|
|
3026
|
+
});
|
|
3027
|
+
}
|
|
3028
|
+
catch (err) {
|
|
3029
|
+
logger.error(`[eliza-api] WebSocket upgrade error: ${err instanceof Error ? err.message : err}`);
|
|
3030
|
+
rejectWebSocketUpgrade(socket, 404, "Not found");
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
// Handle WebSocket connections
|
|
3034
|
+
wss.on("connection", (ws, request) => {
|
|
3035
|
+
let wsUrl;
|
|
3036
|
+
try {
|
|
3037
|
+
wsUrl = new URL(request.url ?? "/", `http://${request.headers.host ?? "localhost"}`);
|
|
3038
|
+
const clientId = normalizeWsClientId(wsUrl.searchParams.get("clientId"));
|
|
3039
|
+
if (clientId)
|
|
3040
|
+
wsClientIds.set(ws, clientId);
|
|
3041
|
+
}
|
|
3042
|
+
catch {
|
|
3043
|
+
// Ignore malformed WS URL metadata; auth/path were already validated.
|
|
3044
|
+
wsUrl = new URL("ws://localhost/ws");
|
|
3045
|
+
}
|
|
3046
|
+
let isAuthenticated = isWebSocketAuthorized(request, wsUrl);
|
|
3047
|
+
// Optional reconnect cursor: a client that tracks the highest buffered
|
|
3048
|
+
// event sequence it has applied can pass it back as `?lastEventId=` so the
|
|
3049
|
+
// server replays only the envelopes it is missing instead of re-flooding
|
|
3050
|
+
// the full tail on every (re)connect (loadperf research 05, Finding 4).
|
|
3051
|
+
// Absent/invalid => null => the historical slice(-DEFAULT_REPLAY_LIMIT)
|
|
3052
|
+
// behavior, so existing clients are unaffected.
|
|
3053
|
+
const replayCursor = parseEventCursor(wsUrl.searchParams.get("lastEventId") ?? wsUrl.searchParams.get("since"));
|
|
3054
|
+
const activateAuthenticatedConnection = () => {
|
|
3055
|
+
wsClients.add(ws);
|
|
3056
|
+
addLog("info", "WebSocket client connected", "websocket", [
|
|
3057
|
+
"server",
|
|
3058
|
+
"websocket",
|
|
3059
|
+
]);
|
|
3060
|
+
try {
|
|
3061
|
+
ws.send(JSON.stringify({
|
|
3062
|
+
type: "status",
|
|
3063
|
+
state: state.agentState,
|
|
3064
|
+
agentName: state.agentName,
|
|
3065
|
+
model: state.model,
|
|
3066
|
+
// Same server-authoritative readiness signal as broadcastStatus and
|
|
3067
|
+
// /api/status. Without it on the initial-connect status, every WS
|
|
3068
|
+
// (re)connect delivers canRespond: undefined and re-gates the chat
|
|
3069
|
+
// composer back to "waking up" until the next 5s broadcast.
|
|
3070
|
+
canRespond: computeCanRespond(state.runtime, state.agentState),
|
|
3071
|
+
startedAt: state.startedAt,
|
|
3072
|
+
startup: state.startup,
|
|
3073
|
+
pendingRestart: state.pendingRestartReasons.length > 0,
|
|
3074
|
+
pendingRestartReasons: state.pendingRestartReasons,
|
|
3075
|
+
}));
|
|
3076
|
+
const replay = selectReplayEvents(state.eventBuffer, replayCursor, DEFAULT_REPLAY_LIMIT);
|
|
3077
|
+
for (const event of replay) {
|
|
3078
|
+
ws.send(JSON.stringify(event));
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
catch (err) {
|
|
3082
|
+
logger.error(`[eliza-api] WebSocket send error: ${err instanceof Error ? err.message : err}`);
|
|
3083
|
+
}
|
|
3084
|
+
};
|
|
3085
|
+
if (isAuthenticated) {
|
|
3086
|
+
activateAuthenticatedConnection();
|
|
3087
|
+
}
|
|
3088
|
+
ws.on("message", async (data) => {
|
|
3089
|
+
try {
|
|
3090
|
+
const msg = JSON.parse(String(data));
|
|
3091
|
+
if (!isAuthenticated) {
|
|
3092
|
+
const expected = getConfiguredApiToken();
|
|
3093
|
+
if (expected &&
|
|
3094
|
+
msg.type === "auth" &&
|
|
3095
|
+
typeof msg.token === "string" &&
|
|
3096
|
+
tokenMatches(expected, msg.token.trim())) {
|
|
3097
|
+
isAuthenticated = true;
|
|
3098
|
+
ws.send(JSON.stringify({ type: "auth-ok" }));
|
|
3099
|
+
activateAuthenticatedConnection();
|
|
3100
|
+
}
|
|
3101
|
+
else {
|
|
3102
|
+
logger.warn("[eliza-api] WebSocket message rejected before auth");
|
|
3103
|
+
ws.close(1008, "Unauthorized");
|
|
3104
|
+
}
|
|
3105
|
+
return;
|
|
3106
|
+
}
|
|
3107
|
+
if (isDuplicateWsMessage(wsClientIds.get(ws), msg.msgId)) {
|
|
3108
|
+
return;
|
|
3109
|
+
}
|
|
3110
|
+
if (msg.type === "ping") {
|
|
3111
|
+
ws.send(JSON.stringify({ type: "pong" }));
|
|
3112
|
+
}
|
|
3113
|
+
else if (msg.type === "active-conversation") {
|
|
3114
|
+
// Per-connection: only this client's active conversation changes.
|
|
3115
|
+
const conversationId = typeof msg.conversationId === "string" ? msg.conversationId : null;
|
|
3116
|
+
if (conversationId) {
|
|
3117
|
+
wsActiveConversations.set(ws, conversationId);
|
|
3118
|
+
}
|
|
3119
|
+
else {
|
|
3120
|
+
wsActiveConversations.delete(ws);
|
|
3121
|
+
}
|
|
3122
|
+
// Keep the global as a sensible "any/most-recent active conversation"
|
|
3123
|
+
// default for non-client-targeted routing (autonomy, swarm synthesis).
|
|
3124
|
+
state.activeConversationId = conversationId;
|
|
3125
|
+
}
|
|
3126
|
+
else if (msg.type === "pty-subscribe" &&
|
|
3127
|
+
typeof msg.sessionId === "string") {
|
|
3128
|
+
const bridge = getPtyConsoleBridge(state);
|
|
3129
|
+
if (bridge) {
|
|
3130
|
+
let subs = wsClientPtySubscriptions.get(ws);
|
|
3131
|
+
if (!subs) {
|
|
3132
|
+
subs = new Map();
|
|
3133
|
+
wsClientPtySubscriptions.set(ws, subs);
|
|
3134
|
+
}
|
|
3135
|
+
// Don't double-subscribe
|
|
3136
|
+
if (!subs.has(msg.sessionId)) {
|
|
3137
|
+
const targetId = msg.sessionId;
|
|
3138
|
+
const listener = (evt) => {
|
|
3139
|
+
if (evt.sessionId !== targetId)
|
|
3140
|
+
return;
|
|
3141
|
+
if (ws.readyState === 1) {
|
|
3142
|
+
ws.send(JSON.stringify({
|
|
3143
|
+
type: "pty-output",
|
|
3144
|
+
sessionId: targetId,
|
|
3145
|
+
data: evt.data,
|
|
3146
|
+
}));
|
|
3147
|
+
}
|
|
3148
|
+
};
|
|
3149
|
+
bridge.on("session_output", listener);
|
|
3150
|
+
subs.set(targetId, () => bridge.off("session_output", listener));
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
else if (msg.type === "pty-unsubscribe" &&
|
|
3155
|
+
typeof msg.sessionId === "string") {
|
|
3156
|
+
const subs = wsClientPtySubscriptions.get(ws);
|
|
3157
|
+
const unsub = subs?.get(msg.sessionId);
|
|
3158
|
+
if (unsub) {
|
|
3159
|
+
unsub();
|
|
3160
|
+
subs?.delete(msg.sessionId);
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
else if (msg.type === "pty-input" &&
|
|
3164
|
+
typeof msg.sessionId === "string" &&
|
|
3165
|
+
typeof msg.data === "string") {
|
|
3166
|
+
// Only allow input to sessions this client has subscribed to
|
|
3167
|
+
const subs = wsClientPtySubscriptions.get(ws);
|
|
3168
|
+
if (!subs?.has(msg.sessionId)) {
|
|
3169
|
+
logger.warn(`[eliza-api] pty-input rejected: client not subscribed to session ${msg.sessionId}`);
|
|
3170
|
+
}
|
|
3171
|
+
else if (msg.data.length > 4096) {
|
|
3172
|
+
logger.warn(`[eliza-api] pty-input rejected: payload too large (${msg.data.length} bytes) for session ${msg.sessionId}`);
|
|
3173
|
+
}
|
|
3174
|
+
else {
|
|
3175
|
+
const bridge = getPtyConsoleBridge(state);
|
|
3176
|
+
if (bridge) {
|
|
3177
|
+
logger.debug(`[eliza-api] pty-input: session=${msg.sessionId} len=${msg.data.length}`);
|
|
3178
|
+
bridge.writeRaw(msg.sessionId, msg.data);
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
else if (msg.type === "pty-resize" &&
|
|
3183
|
+
typeof msg.sessionId === "string") {
|
|
3184
|
+
// Only allow resize for sessions this client has subscribed to
|
|
3185
|
+
const subs = wsClientPtySubscriptions.get(ws);
|
|
3186
|
+
if (!subs?.has(msg.sessionId)) {
|
|
3187
|
+
logger.warn(`[eliza-api] pty-resize rejected: client not subscribed to session ${msg.sessionId}`);
|
|
3188
|
+
}
|
|
3189
|
+
else {
|
|
3190
|
+
const bridge = getPtyConsoleBridge(state);
|
|
3191
|
+
if (bridge &&
|
|
3192
|
+
typeof msg.cols === "number" &&
|
|
3193
|
+
typeof msg.rows === "number" &&
|
|
3194
|
+
Number.isFinite(msg.cols) &&
|
|
3195
|
+
Number.isFinite(msg.rows) &&
|
|
3196
|
+
Number.isInteger(msg.cols) &&
|
|
3197
|
+
Number.isInteger(msg.rows) &&
|
|
3198
|
+
msg.cols >= 1 &&
|
|
3199
|
+
msg.cols <= 500 &&
|
|
3200
|
+
msg.rows >= 1 &&
|
|
3201
|
+
msg.rows <= 500) {
|
|
3202
|
+
bridge.resize(msg.sessionId, msg.cols, msg.rows);
|
|
3203
|
+
}
|
|
3204
|
+
else {
|
|
3205
|
+
logger.warn(`[eliza-api] pty-resize rejected: invalid dimensions cols=${msg.cols} rows=${msg.rows}`);
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
else if (msg.type === "view:interact:result" &&
|
|
3210
|
+
typeof msg.requestId === "string") {
|
|
3211
|
+
void import("./views-routes.js")
|
|
3212
|
+
.then(({ resolveViewInteractResult }) => {
|
|
3213
|
+
resolveViewInteractResult({
|
|
3214
|
+
requestId: msg.requestId,
|
|
3215
|
+
success: msg.success === true,
|
|
3216
|
+
result: msg.result,
|
|
3217
|
+
error: typeof msg.error === "string" ? msg.error : undefined,
|
|
3218
|
+
});
|
|
3219
|
+
})
|
|
3220
|
+
.catch((err) => {
|
|
3221
|
+
logger.error(`[eliza-api] view interaction result error: ${err instanceof Error ? err.message : err}`);
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
catch (err) {
|
|
3226
|
+
logger.error(`[eliza-api] WebSocket message error: ${err instanceof Error ? err.message : err}`);
|
|
3227
|
+
}
|
|
3228
|
+
});
|
|
3229
|
+
ws.on("close", () => {
|
|
3230
|
+
wsClients.delete(ws);
|
|
3231
|
+
wsActiveConversations.delete(ws);
|
|
3232
|
+
// Clean up any PTY output subscriptions for this client
|
|
3233
|
+
const subs = wsClientPtySubscriptions.get(ws);
|
|
3234
|
+
if (subs) {
|
|
3235
|
+
for (const unsub of subs.values())
|
|
3236
|
+
unsub();
|
|
3237
|
+
subs.clear();
|
|
3238
|
+
}
|
|
3239
|
+
addLog("info", "WebSocket client disconnected", "websocket", [
|
|
3240
|
+
"server",
|
|
3241
|
+
"websocket",
|
|
3242
|
+
]);
|
|
3243
|
+
});
|
|
3244
|
+
ws.on("error", (err) => {
|
|
3245
|
+
logger.error(`[eliza-api] WebSocket error: ${err instanceof Error ? err.message : err}`);
|
|
3246
|
+
wsClients.delete(ws);
|
|
3247
|
+
wsActiveConversations.delete(ws);
|
|
3248
|
+
// Clean up PTY subscriptions on error too
|
|
3249
|
+
const subs = wsClientPtySubscriptions.get(ws);
|
|
3250
|
+
if (subs) {
|
|
3251
|
+
for (const unsub of subs.values())
|
|
3252
|
+
unsub();
|
|
3253
|
+
subs.clear();
|
|
3254
|
+
}
|
|
3255
|
+
});
|
|
3256
|
+
});
|
|
3257
|
+
// Broadcast status to all connected WebSocket clients (flattened — PR #36 fix)
|
|
3258
|
+
const broadcastStatus = () => {
|
|
3259
|
+
broadcastWs({
|
|
3260
|
+
type: "status",
|
|
3261
|
+
state: state.agentState,
|
|
3262
|
+
agentName: state.agentName,
|
|
3263
|
+
model: state.model,
|
|
3264
|
+
// Carry the same server-authoritative readiness signal `/api/status`
|
|
3265
|
+
// returns. Without it, every 5s WS status broadcast resets the client's
|
|
3266
|
+
// `agentStatus.canRespond` to undefined, re-gating the chat composer back
|
|
3267
|
+
// to "waking up" even though the agent is fully ready and replying.
|
|
3268
|
+
canRespond: computeCanRespond(state.runtime, state.agentState),
|
|
3269
|
+
startedAt: state.startedAt,
|
|
3270
|
+
startup: state.startup,
|
|
3271
|
+
pendingRestart: state.pendingRestartReasons.length > 0,
|
|
3272
|
+
pendingRestartReasons: state.pendingRestartReasons,
|
|
3273
|
+
});
|
|
3274
|
+
};
|
|
3275
|
+
// Make broadcastStatus accessible to route handlers via state
|
|
3276
|
+
state.broadcastStatus = broadcastStatus;
|
|
3277
|
+
// Generic broadcast — sends an arbitrary JSON payload to all WS clients.
|
|
3278
|
+
state.broadcastWs = (data) => {
|
|
3279
|
+
const message = JSON.stringify(data);
|
|
3280
|
+
for (const client of wsClients) {
|
|
3281
|
+
if (client.readyState === 1) {
|
|
3282
|
+
try {
|
|
3283
|
+
client.send(message);
|
|
3284
|
+
}
|
|
3285
|
+
catch (err) {
|
|
3286
|
+
logger.error(`[eliza-api] WebSocket broadcast error: ${err instanceof Error ? err.message : err}`);
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
state.broadcastWsToClientId = (clientId, data) => {
|
|
3292
|
+
const message = JSON.stringify(data);
|
|
3293
|
+
let delivered = 0;
|
|
3294
|
+
for (const client of wsClients) {
|
|
3295
|
+
if (client.readyState !== 1)
|
|
3296
|
+
continue;
|
|
3297
|
+
if (wsClientIds.get(client) !== clientId)
|
|
3298
|
+
continue;
|
|
3299
|
+
try {
|
|
3300
|
+
client.send(message);
|
|
3301
|
+
delivered += 1;
|
|
3302
|
+
}
|
|
3303
|
+
catch (err) {
|
|
3304
|
+
logger.error(`[eliza-api] WebSocket targeted send error: ${err instanceof Error ? err.message : err}`);
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
return delivered;
|
|
3308
|
+
};
|
|
3309
|
+
// Conversation-scoped push: only clients with this conversation active.
|
|
3310
|
+
state.broadcastWsToConversation = (conversationId, data) => {
|
|
3311
|
+
const message = JSON.stringify(data);
|
|
3312
|
+
let delivered = 0;
|
|
3313
|
+
for (const client of wsClients) {
|
|
3314
|
+
if (client.readyState !== 1)
|
|
3315
|
+
continue;
|
|
3316
|
+
if (wsActiveConversations.get(client) !== conversationId)
|
|
3317
|
+
continue;
|
|
3318
|
+
try {
|
|
3319
|
+
client.send(message);
|
|
3320
|
+
delivered += 1;
|
|
3321
|
+
}
|
|
3322
|
+
catch (err) {
|
|
3323
|
+
logger.error(`[eliza-api] WebSocket conversation send error: ${err instanceof Error ? err.message : err}`);
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
return delivered;
|
|
3327
|
+
};
|
|
3328
|
+
// Wire up ConnectorSetupService broadcastWs so connector plugins
|
|
3329
|
+
// (Signal, WhatsApp) can broadcast pairing events via the service.
|
|
3330
|
+
if (state.runtime) {
|
|
3331
|
+
try {
|
|
3332
|
+
const setupSvc = state.runtime.getService("connector-setup");
|
|
3333
|
+
setupSvc?.setBroadcastWs?.(state.broadcastWs);
|
|
3334
|
+
}
|
|
3335
|
+
catch {
|
|
3336
|
+
// non-fatal — service may not be registered yet
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
// Broadcast status every 5 seconds
|
|
3340
|
+
const statusInterval = setInterval(broadcastStatus, 5000);
|
|
3341
|
+
/**
|
|
3342
|
+
* Restore the in-memory conversation list from the database.
|
|
3343
|
+
* Web-chat rooms live in a deterministic world; we scan it for rooms
|
|
3344
|
+
* whose channelId starts with "web-conv-" and reconstruct the metadata.
|
|
3345
|
+
*/
|
|
3346
|
+
const restoreConversationsFromDb = async (rt) => {
|
|
3347
|
+
try {
|
|
3348
|
+
const agentName = rt.character.name ?? "Eliza";
|
|
3349
|
+
const worldId = stringToUuid(`${agentName}-web-chat-world`);
|
|
3350
|
+
const rooms = await rt.getRoomsByWorld(worldId);
|
|
3351
|
+
if (!rooms.length)
|
|
3352
|
+
return;
|
|
3353
|
+
let restored = 0;
|
|
3354
|
+
for (const room of rooms) {
|
|
3355
|
+
// channelId is "web-conv-{uuid}" — extract the conversation id
|
|
3356
|
+
const channelId = typeof room.channelId === "string" ? room.channelId : "";
|
|
3357
|
+
if (!channelId.startsWith("web-conv-"))
|
|
3358
|
+
continue;
|
|
3359
|
+
const convId = channelId.replace("web-conv-", "");
|
|
3360
|
+
if (!convId || state.conversations.has(convId))
|
|
3361
|
+
continue;
|
|
3362
|
+
if (state.deletedConversationIds.has(convId))
|
|
3363
|
+
continue;
|
|
3364
|
+
// Peek at the latest message to get a timestamp
|
|
3365
|
+
let updatedAt = new Date().toISOString();
|
|
3366
|
+
try {
|
|
3367
|
+
const msgs = await rt.getMemories({
|
|
3368
|
+
roomId: room.id,
|
|
3369
|
+
tableName: "messages",
|
|
3370
|
+
limit: 1,
|
|
3371
|
+
});
|
|
3372
|
+
if (msgs.length > 0 && msgs[0].createdAt) {
|
|
3373
|
+
updatedAt = new Date(msgs[0].createdAt).toISOString();
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
catch {
|
|
3377
|
+
// non-fatal — use current time
|
|
3378
|
+
}
|
|
3379
|
+
const conversationMetadata = await extractConversationMetadataFromRoom(room, convId);
|
|
3380
|
+
state.conversations.set(convId, {
|
|
3381
|
+
id: convId,
|
|
3382
|
+
title: room.name || "Chat",
|
|
3383
|
+
roomId: room.id,
|
|
3384
|
+
...(conversationMetadata ? { metadata: conversationMetadata } : {}),
|
|
3385
|
+
createdAt: updatedAt,
|
|
3386
|
+
updatedAt,
|
|
3387
|
+
});
|
|
3388
|
+
restored++;
|
|
3389
|
+
}
|
|
3390
|
+
if (restored > 0) {
|
|
3391
|
+
addLog("info", `Restored ${restored} conversation(s) from database`, "system", ["system"]);
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
catch (err) {
|
|
3395
|
+
logger.warn(`[eliza-api] Failed to restore conversations from DB: ${err instanceof Error ? err.message : err}`);
|
|
3396
|
+
}
|
|
3397
|
+
};
|
|
3398
|
+
const beginConversationRestore = (rt) => {
|
|
3399
|
+
const restorePromise = restoreConversationsFromDb(rt).finally(() => {
|
|
3400
|
+
if (state.conversationRestorePromise === restorePromise) {
|
|
3401
|
+
state.conversationRestorePromise = null;
|
|
3402
|
+
}
|
|
3403
|
+
});
|
|
3404
|
+
state.conversationRestorePromise = restorePromise;
|
|
3405
|
+
return restorePromise;
|
|
3406
|
+
};
|
|
3407
|
+
/**
|
|
3408
|
+
* Load the agent's DB-persisted character data and overlay onto the
|
|
3409
|
+
* in-memory runtime.character. This ensures Character Editor edits
|
|
3410
|
+
* survive server restarts without depending on eliza.json persistence.
|
|
3411
|
+
*/
|
|
3412
|
+
const overlayDbCharacter = async (rt, st) => {
|
|
3413
|
+
try {
|
|
3414
|
+
const dbAgent = await rt.getAgent(rt.agentId);
|
|
3415
|
+
const agentRecord = dbAgent && typeof dbAgent === "object" && !Array.isArray(dbAgent)
|
|
3416
|
+
? Object.fromEntries(Object.entries(dbAgent))
|
|
3417
|
+
: null;
|
|
3418
|
+
const saved = agentRecord?.character;
|
|
3419
|
+
if (!saved || typeof saved !== "object")
|
|
3420
|
+
return;
|
|
3421
|
+
const c = rt.character;
|
|
3422
|
+
// Only overlay fields that were explicitly saved (non-empty)
|
|
3423
|
+
if (typeof saved.name === "string" && saved.name)
|
|
3424
|
+
c.name = saved.name;
|
|
3425
|
+
if (Array.isArray(saved.bio) && saved.bio.length > 0) {
|
|
3426
|
+
c.bio = saved.bio;
|
|
3427
|
+
}
|
|
3428
|
+
if (typeof saved.system === "string" && saved.system) {
|
|
3429
|
+
c.system = saved.system;
|
|
3430
|
+
}
|
|
3431
|
+
if (Array.isArray(saved.adjectives)) {
|
|
3432
|
+
c.adjectives = saved.adjectives;
|
|
3433
|
+
}
|
|
3434
|
+
if (Array.isArray(saved.topics)) {
|
|
3435
|
+
c.topics = saved.topics;
|
|
3436
|
+
}
|
|
3437
|
+
if (saved.style && typeof saved.style === "object") {
|
|
3438
|
+
c.style = saved.style;
|
|
3439
|
+
}
|
|
3440
|
+
if (Array.isArray(saved.messageExamples)) {
|
|
3441
|
+
c.messageExamples = saved.messageExamples;
|
|
3442
|
+
}
|
|
3443
|
+
if (Array.isArray(saved.postExamples) && saved.postExamples.length > 0) {
|
|
3444
|
+
c.postExamples = saved.postExamples;
|
|
3445
|
+
}
|
|
3446
|
+
// Update agent name on state
|
|
3447
|
+
st.agentName = c.name ?? st.agentName;
|
|
3448
|
+
logger.info(`[character-db] Overlaid DB-persisted character "${c.name}" onto runtime`);
|
|
3449
|
+
}
|
|
3450
|
+
catch (err) {
|
|
3451
|
+
logger.warn(`[character-db] Failed to load character from DB: ${err instanceof Error ? err.message : err}`);
|
|
3452
|
+
}
|
|
3453
|
+
};
|
|
3454
|
+
// Restore conversations from DB at initial boot (if runtime was passed in)
|
|
3455
|
+
if (opts?.runtime) {
|
|
3456
|
+
void beginConversationRestore(opts.runtime).catch((err) => {
|
|
3457
|
+
logger.warn("[api] Conversation restore failed:", err);
|
|
3458
|
+
});
|
|
3459
|
+
void overlayDbCharacter(opts.runtime, state).catch((err) => {
|
|
3460
|
+
logger.warn("[api] Character overlay restore failed:", err);
|
|
3461
|
+
});
|
|
3462
|
+
registerClientChatSendHandler(opts.runtime, state);
|
|
3463
|
+
}
|
|
3464
|
+
const assertX402RoutesValid = async (rt) => {
|
|
3465
|
+
if (!rt?.routes?.length)
|
|
3466
|
+
return;
|
|
3467
|
+
const agentId = rt.agentId != null && String(rt.agentId).length > 0
|
|
3468
|
+
? String(rt.agentId)
|
|
3469
|
+
: undefined;
|
|
3470
|
+
const { validateX402Startup } = await getX402Plugin();
|
|
3471
|
+
const result = validateX402Startup(rt.routes, rt.character, {
|
|
3472
|
+
agentId,
|
|
3473
|
+
});
|
|
3474
|
+
if (!result || typeof result !== "object") {
|
|
3475
|
+
logger.warn("[x402] startup validator returned no result; skipping x402 route validation");
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3478
|
+
if (!result.valid) {
|
|
3479
|
+
throw new Error(`x402 configuration invalid:\n${result.errors.map((e) => ` • ${e}`).join("\n")}`);
|
|
3480
|
+
}
|
|
3481
|
+
for (const w of result.warnings) {
|
|
3482
|
+
logger.warn(`[x402] ${w}`);
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
/** Hot-swap the runtime reference (used after an in-process restart). */
|
|
3486
|
+
const updateRuntime = (rt) => {
|
|
3487
|
+
void assertX402RoutesValid(rt).catch((err) => {
|
|
3488
|
+
logger.error(`[x402] runtime route validation failed after update: ${err instanceof Error ? err.message : String(err)}`);
|
|
3489
|
+
});
|
|
3490
|
+
state.runtime = rt;
|
|
3491
|
+
state.chatConnectionReady = null;
|
|
3492
|
+
state.chatConnectionPromise = null;
|
|
3493
|
+
bindRuntimeStreams(rt);
|
|
3494
|
+
// Wake any chat turns held through the warming window — first-turn
|
|
3495
|
+
// capability is now online, so they stream their response instead of 503.
|
|
3496
|
+
runtimeReadyGate.markReady(rt);
|
|
3497
|
+
// AppManager doesn't need a runtime reference
|
|
3498
|
+
state.agentState = "running";
|
|
3499
|
+
state.agentName =
|
|
3500
|
+
rt.character.name ?? resolveDefaultAgentName(state.config);
|
|
3501
|
+
state.model = detectRuntimeModel(rt, state.config);
|
|
3502
|
+
state.startedAt = Date.now();
|
|
3503
|
+
state.startup = {
|
|
3504
|
+
phase: "running",
|
|
3505
|
+
attempt: 0,
|
|
3506
|
+
};
|
|
3507
|
+
addLog("info", `Runtime restarted — agent: ${state.agentName}`, "system", [
|
|
3508
|
+
"system",
|
|
3509
|
+
"agent",
|
|
3510
|
+
]);
|
|
3511
|
+
// Restore conversations from DB so they survive restarts
|
|
3512
|
+
void beginConversationRestore(rt).catch((err) => {
|
|
3513
|
+
logger.warn("[api] Conversation restore failed on restart:", err);
|
|
3514
|
+
});
|
|
3515
|
+
// Overlay DB-persisted character data (from Character Editor saves)
|
|
3516
|
+
void overlayDbCharacter(rt, state).catch((err) => {
|
|
3517
|
+
logger.warn("[api] Character overlay restore failed on restart:", err);
|
|
3518
|
+
});
|
|
3519
|
+
// Broadcast status update immediately after restart
|
|
3520
|
+
broadcastStatus();
|
|
3521
|
+
// Re-register client_chat send handler on the new runtime
|
|
3522
|
+
registerClientChatSendHandler(rt, state);
|
|
3523
|
+
// Wire coding-agent bridges (event-driven via getServiceLoadPromise)
|
|
3524
|
+
void wireCoordinatorBridgesWhenReady(state, {
|
|
3525
|
+
wireChatBridge: wireCodingAgentChatBridge,
|
|
3526
|
+
wireWsBridge: wireCodingAgentWsBridge,
|
|
3527
|
+
wireEventRouting: wireCoordinatorEventRouting,
|
|
3528
|
+
wireSwarmSynthesis: wireCodingAgentSwarmSynthesis,
|
|
3529
|
+
context: "restart",
|
|
3530
|
+
logger,
|
|
3531
|
+
});
|
|
3532
|
+
};
|
|
3533
|
+
const updateStartup = (update) => {
|
|
3534
|
+
const { state: nextState, ...startupUpdate } = update;
|
|
3535
|
+
state.startup = {
|
|
3536
|
+
...state.startup,
|
|
3537
|
+
...startupUpdate,
|
|
3538
|
+
};
|
|
3539
|
+
if (nextState) {
|
|
3540
|
+
state.agentState = nextState;
|
|
3541
|
+
if (nextState === "error") {
|
|
3542
|
+
state.startedAt = undefined;
|
|
3543
|
+
}
|
|
3544
|
+
else if ((nextState === "starting" || nextState === "running") &&
|
|
3545
|
+
!state.startedAt) {
|
|
3546
|
+
state.startedAt = Date.now();
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3549
|
+
broadcastStatus();
|
|
3550
|
+
};
|
|
3551
|
+
logger.debug(`[eliza-api] Calling server.listen (${Date.now() - apiStartTime}ms)`);
|
|
3552
|
+
await assertX402RoutesValid(state.runtime);
|
|
3553
|
+
return new Promise((resolve, reject) => {
|
|
3554
|
+
let currentPort = port;
|
|
3555
|
+
const strictPortBinding = strictPortBindingEnabled();
|
|
3556
|
+
server.on("error", (err) => {
|
|
3557
|
+
if (err.code === "EADDRINUSE") {
|
|
3558
|
+
logger.warn(`[eliza-api] Port ${currentPort} is already in use. Checking fallback...`);
|
|
3559
|
+
if (currentPort !== 0 && !strictPortBinding) {
|
|
3560
|
+
logger.warn(`[eliza-api] Retrying with dynamic port (0)...`);
|
|
3561
|
+
currentPort = 0;
|
|
3562
|
+
server.listen(0, host);
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3565
|
+
if (strictPortBinding) {
|
|
3566
|
+
logger.error(`[eliza-api] Strict port binding is enabled; refusing dynamic fallback from ${currentPort}.`);
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
else {
|
|
3570
|
+
logger.error(`[eliza-api] Server error: ${err.message} (code: ${err.code})`);
|
|
3571
|
+
}
|
|
3572
|
+
reject(err);
|
|
3573
|
+
});
|
|
3574
|
+
apiLap("before server.listen");
|
|
3575
|
+
server.listen(port, host, () => {
|
|
3576
|
+
apiLap("LISTENING (API bound)");
|
|
3577
|
+
logger.debug(`[eliza-api] server.listen callback fired (${Date.now() - apiStartTime}ms)`);
|
|
3578
|
+
const addr = server.address();
|
|
3579
|
+
const actualPort = typeof addr === "object" && addr ? addr.port : currentPort;
|
|
3580
|
+
const displayHost = typeof addr === "object" && addr ? addr.address : host;
|
|
3581
|
+
addLog("info", `API server listening on http://${displayHost}:${actualPort}`, "system", ["server", "system"]);
|
|
3582
|
+
// Log to both stdout (for agent.ts port detection) and the in-memory
|
|
3583
|
+
// logger. agent.ts watches stdout for "Listening on http://host:PORT"
|
|
3584
|
+
// to detect dynamic port reassignment when the default port is in use.
|
|
3585
|
+
console.log(`[eliza-api] Listening on http://${displayHost}:${actualPort}`);
|
|
3586
|
+
logger.info(`[eliza-api] Listening on http://${displayHost}:${actualPort}`);
|
|
3587
|
+
if (!opts?.skipDeferredStartupWork) {
|
|
3588
|
+
void startDeferredStartupWork();
|
|
3589
|
+
}
|
|
3590
|
+
resolve({
|
|
3591
|
+
port: actualPort,
|
|
3592
|
+
close: () => new Promise((r) => {
|
|
3593
|
+
void Promise.resolve().then(() => {
|
|
3594
|
+
const closeAllConnections = server.closeAllConnections;
|
|
3595
|
+
const closeIdleConnections = server.closeIdleConnections;
|
|
3596
|
+
clearInterval(statusInterval);
|
|
3597
|
+
if (state.connectorHealthMonitor) {
|
|
3598
|
+
state.connectorHealthMonitor.stop();
|
|
3599
|
+
state.connectorHealthMonitor = null;
|
|
3600
|
+
}
|
|
3601
|
+
if (detachRuntimeStreams) {
|
|
3602
|
+
detachRuntimeStreams();
|
|
3603
|
+
detachRuntimeStreams = null;
|
|
3604
|
+
}
|
|
3605
|
+
if (detachTrainingStream) {
|
|
3606
|
+
detachTrainingStream();
|
|
3607
|
+
detachTrainingStream = null;
|
|
3608
|
+
}
|
|
3609
|
+
for (const ws of wsClients) {
|
|
3610
|
+
if (ws.readyState === 1 || ws.readyState === 0) {
|
|
3611
|
+
if ("terminate" in ws && typeof ws.terminate === "function") {
|
|
3612
|
+
ws.terminate();
|
|
3613
|
+
}
|
|
3614
|
+
else {
|
|
3615
|
+
ws.close();
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
wsClients.clear();
|
|
3620
|
+
// Clean up WhatsApp pairing sessions
|
|
3621
|
+
if (state.whatsappPairingSessions) {
|
|
3622
|
+
for (const s of state.whatsappPairingSessions.values()) {
|
|
3623
|
+
try {
|
|
3624
|
+
s.stop();
|
|
3625
|
+
}
|
|
3626
|
+
catch {
|
|
3627
|
+
/* non-fatal */
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
state.whatsappPairingSessions.clear();
|
|
3631
|
+
}
|
|
3632
|
+
// Clean up Signal pairing sessions
|
|
3633
|
+
if (state.signalPairingSessions) {
|
|
3634
|
+
for (const s of state.signalPairingSessions.values()) {
|
|
3635
|
+
try {
|
|
3636
|
+
s.stop();
|
|
3637
|
+
}
|
|
3638
|
+
catch {
|
|
3639
|
+
/* non-fatal */
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
state.signalPairingSessions.clear();
|
|
3643
|
+
}
|
|
3644
|
+
if (state.telegramAccountAuthSession) {
|
|
3645
|
+
void Promise.resolve(state.telegramAccountAuthSession.stop()).catch(() => {
|
|
3646
|
+
/* non-fatal */
|
|
3647
|
+
});
|
|
3648
|
+
state.telegramAccountAuthSession = null;
|
|
3649
|
+
}
|
|
3650
|
+
wss.close();
|
|
3651
|
+
const closeTimeout = setTimeout(() => r(), 5_000);
|
|
3652
|
+
const resolved = { done: false };
|
|
3653
|
+
const finalize = () => {
|
|
3654
|
+
if (!resolved.done) {
|
|
3655
|
+
resolved.done = true;
|
|
3656
|
+
clearTimeout(closeTimeout);
|
|
3657
|
+
r();
|
|
3658
|
+
}
|
|
3659
|
+
};
|
|
3660
|
+
if (typeof closeAllConnections === "function") {
|
|
3661
|
+
try {
|
|
3662
|
+
closeAllConnections();
|
|
3663
|
+
}
|
|
3664
|
+
catch {
|
|
3665
|
+
// Bun/Node server internals vary by runtime; non-fatal on shutdown.
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
if (typeof closeIdleConnections === "function") {
|
|
3669
|
+
try {
|
|
3670
|
+
closeIdleConnections();
|
|
3671
|
+
}
|
|
3672
|
+
catch {
|
|
3673
|
+
// Bun/Node server internals vary by runtime; non-fatal on shutdown.
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
server.close(finalize);
|
|
3677
|
+
});
|
|
3678
|
+
}),
|
|
3679
|
+
updateRuntime,
|
|
3680
|
+
updateStartup,
|
|
3681
|
+
});
|
|
3682
|
+
});
|
|
3683
|
+
});
|
|
3684
|
+
}
|