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