@elizaos/agent 2.0.0-alpha.98 → 2.0.0-beta.2
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/package.json +78 -923
- package/packages/agent/src/actions/connector-resolver.d.ts +74 -0
- package/packages/agent/src/actions/connector-resolver.d.ts.map +1 -0
- package/packages/agent/src/actions/connector-resolver.js +253 -0
- package/packages/agent/src/actions/contact.d.ts +35 -0
- package/packages/agent/src/actions/contact.d.ts.map +1 -0
- package/packages/agent/src/actions/contact.js +1698 -0
- package/packages/agent/src/actions/context-signal-lexicon.d.ts +17 -0
- package/packages/agent/src/actions/context-signal-lexicon.d.ts.map +1 -0
- package/packages/agent/src/actions/context-signal-lexicon.js +206 -0
- package/packages/agent/src/actions/context-signal.d.ts +48 -0
- package/packages/agent/src/actions/context-signal.d.ts.map +1 -0
- package/packages/agent/src/actions/context-signal.js +153 -0
- package/packages/agent/src/actions/database.d.ts +20 -0
- package/packages/agent/src/actions/database.d.ts.map +1 -0
- package/packages/agent/src/actions/database.js +671 -0
- package/packages/agent/src/actions/extract-page.d.ts +3 -0
- package/packages/agent/src/actions/extract-page.d.ts.map +1 -0
- package/packages/agent/src/actions/extract-page.js +153 -0
- package/packages/agent/src/actions/extract-params.d.ts +87 -0
- package/packages/agent/src/actions/extract-params.d.ts.map +1 -0
- package/packages/agent/src/actions/extract-params.js +187 -0
- package/packages/agent/src/actions/grounded-action-reply.d.ts +22 -0
- package/packages/agent/src/actions/grounded-action-reply.d.ts.map +1 -0
- package/packages/agent/src/actions/grounded-action-reply.js +287 -0
- package/packages/agent/src/actions/index.d.ts +22 -0
- package/packages/agent/src/actions/index.d.ts.map +1 -0
- package/packages/agent/src/actions/index.js +21 -0
- package/packages/agent/src/actions/logs.d.ts +11 -0
- package/packages/agent/src/actions/logs.d.ts.map +1 -0
- package/packages/agent/src/actions/logs.js +300 -0
- package/packages/agent/src/actions/media.d.ts +9 -0
- package/packages/agent/src/actions/media.d.ts.map +1 -0
- package/packages/agent/src/actions/media.js +135 -0
- package/packages/agent/src/actions/memories.d.ts +9 -0
- package/packages/agent/src/actions/memories.d.ts.map +1 -0
- package/packages/agent/src/actions/memories.js +369 -0
- package/packages/agent/src/actions/page-action-groups.d.ts +17 -0
- package/packages/agent/src/actions/page-action-groups.d.ts.map +1 -0
- package/packages/agent/src/actions/page-action-groups.js +413 -0
- package/packages/agent/src/actions/plugin.d.ts +32 -0
- package/packages/agent/src/actions/plugin.d.ts.map +1 -0
- package/packages/agent/src/actions/plugin.js +780 -0
- package/packages/agent/src/actions/recent-conversation-texts.d.ts +9 -0
- package/packages/agent/src/actions/recent-conversation-texts.d.ts.map +1 -0
- package/packages/agent/src/actions/recent-conversation-texts.js +76 -0
- package/packages/agent/src/actions/runtime.d.ts +19 -0
- package/packages/agent/src/actions/runtime.d.ts.map +1 -0
- package/packages/agent/src/actions/runtime.js +517 -0
- package/packages/agent/src/actions/settings-actions.d.ts +19 -0
- package/packages/agent/src/actions/settings-actions.d.ts.map +1 -0
- package/packages/agent/src/actions/settings-actions.js +478 -0
- package/packages/agent/src/actions/skill-command.d.ts +20 -0
- package/packages/agent/src/actions/skill-command.d.ts.map +1 -0
- package/packages/agent/src/actions/skill-command.js +170 -0
- package/packages/agent/src/actions/stream-control.d.ts +13 -8
- package/packages/agent/src/actions/stream-control.d.ts.map +1 -1
- package/packages/agent/src/actions/stream-control.js +127 -318
- package/packages/agent/src/actions/terminal.d.ts +4 -3
- package/packages/agent/src/actions/terminal.d.ts.map +1 -1
- package/packages/agent/src/actions/terminal.js +247 -96
- package/packages/agent/src/actions/trajectories.d.ts +8 -0
- package/packages/agent/src/actions/trajectories.d.ts.map +1 -0
- package/packages/agent/src/actions/trajectories.js +135 -0
- package/packages/agent/src/actions/trigger.d.ts +5 -0
- package/packages/agent/src/actions/trigger.d.ts.map +1 -0
- package/packages/agent/src/actions/trigger.js +514 -0
- package/packages/agent/src/api/accounts-routes.d.ts +38 -0
- package/packages/agent/src/api/accounts-routes.d.ts.map +1 -0
- package/packages/agent/src/api/accounts-routes.js +927 -0
- package/packages/agent/src/api/agent-admin-routes.d.ts +6 -5
- package/packages/agent/src/api/agent-admin-routes.d.ts.map +1 -1
- package/packages/agent/src/api/agent-admin-routes.js +106 -9
- package/packages/agent/src/api/agent-lifecycle-routes.d.ts +2 -2
- package/packages/agent/src/api/agent-lifecycle-routes.d.ts.map +1 -1
- package/packages/agent/src/api/agent-lifecycle-routes.js +22 -1
- package/packages/agent/src/api/agent-model.d.ts +2 -9
- package/packages/agent/src/api/agent-model.d.ts.map +1 -1
- package/packages/agent/src/api/agent-model.js +50 -3
- package/packages/agent/src/api/agent-status-routes.d.ts +75 -0
- package/packages/agent/src/api/agent-status-routes.d.ts.map +1 -0
- package/packages/agent/src/api/agent-status-routes.js +264 -0
- package/packages/agent/src/api/agent-transfer-routes.d.ts +1 -1
- package/packages/agent/src/api/agent-transfer-routes.js +1 -1
- package/packages/agent/src/api/app-package-routes.d.ts +7 -0
- package/packages/agent/src/api/app-package-routes.d.ts.map +1 -0
- package/packages/agent/src/api/app-package-routes.js +59 -0
- package/packages/agent/src/api/apps-routes.d.ts +16 -3
- package/packages/agent/src/api/apps-routes.d.ts.map +1 -1
- package/packages/agent/src/api/apps-routes.js +885 -15
- package/packages/agent/src/api/auth-routes.d.ts +1 -1
- package/packages/agent/src/api/auth-routes.d.ts.map +1 -1
- package/packages/agent/src/api/auth-routes.js +67 -2
- package/packages/agent/src/api/avatar-routes.d.ts +11 -0
- package/packages/agent/src/api/avatar-routes.d.ts.map +1 -0
- package/packages/agent/src/api/avatar-routes.js +205 -0
- package/packages/agent/src/api/binance-skill-helpers.d.ts +21 -0
- package/packages/agent/src/api/binance-skill-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/binance-skill-helpers.js +745 -0
- package/packages/agent/src/api/bug-report-routes.d.ts +5 -2
- package/packages/agent/src/api/bug-report-routes.d.ts.map +1 -1
- package/packages/agent/src/api/bug-report-routes.js +155 -8
- package/packages/agent/src/api/build-variant-routes.d.ts +27 -0
- package/packages/agent/src/api/build-variant-routes.d.ts.map +1 -0
- package/packages/agent/src/api/build-variant-routes.js +27 -0
- package/packages/agent/src/api/character-routes.d.ts +7 -5
- package/packages/agent/src/api/character-routes.d.ts.map +1 -1
- package/packages/agent/src/api/character-routes.js +100 -49
- package/packages/agent/src/api/chat-augmentation.d.ts +70 -0
- package/packages/agent/src/api/chat-augmentation.d.ts.map +1 -0
- package/packages/agent/src/api/chat-augmentation.js +464 -0
- package/packages/agent/src/api/chat-routes.d.ts +124 -0
- package/packages/agent/src/api/chat-routes.d.ts.map +1 -0
- package/packages/agent/src/api/chat-routes.js +1841 -0
- package/packages/agent/src/api/chat-text-helpers.d.ts +11 -0
- package/packages/agent/src/api/chat-text-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/chat-text-helpers.js +184 -0
- package/packages/agent/src/api/client-chat-admin.d.ts +19 -0
- package/packages/agent/src/api/client-chat-admin.d.ts.map +1 -0
- package/packages/agent/src/api/client-chat-admin.js +27 -0
- package/packages/agent/src/api/cloud-route-registry.d.ts +22 -0
- package/packages/agent/src/api/cloud-route-registry.d.ts.map +1 -0
- package/packages/agent/src/api/cloud-route-registry.js +20 -0
- package/packages/agent/src/api/compat-utils.d.ts.map +1 -1
- package/packages/agent/src/api/compat-utils.js +1 -5
- package/packages/agent/src/api/config-env.d.ts +43 -0
- package/packages/agent/src/api/config-env.d.ts.map +1 -0
- package/packages/agent/src/api/config-env.js +284 -0
- package/packages/agent/src/api/config-routes.d.ts +40 -0
- package/packages/agent/src/api/config-routes.d.ts.map +1 -0
- package/packages/agent/src/api/config-routes.js +429 -0
- package/packages/agent/src/api/connector-account-routes.d.ts +25 -0
- package/packages/agent/src/api/connector-account-routes.d.ts.map +1 -0
- package/packages/agent/src/api/connector-account-routes.js +740 -0
- package/packages/agent/src/api/connector-health.d.ts +9 -1
- package/packages/agent/src/api/connector-health.d.ts.map +1 -1
- package/packages/agent/src/api/connector-health.js +33 -10
- package/packages/agent/src/api/connector-oauth-callback-auth.d.ts +2 -0
- package/packages/agent/src/api/connector-oauth-callback-auth.d.ts.map +1 -0
- package/packages/agent/src/api/connector-oauth-callback-auth.js +4 -0
- package/packages/agent/src/api/connector-routes.d.ts +36 -0
- package/packages/agent/src/api/connector-routes.d.ts.map +1 -0
- package/packages/agent/src/api/connector-routes.js +184 -0
- package/packages/agent/src/api/conversation-metadata.d.ts +10 -0
- package/packages/agent/src/api/conversation-metadata.d.ts.map +1 -0
- package/packages/agent/src/api/conversation-metadata.js +107 -0
- package/packages/agent/src/api/conversation-routes.d.ts +43 -0
- package/packages/agent/src/api/conversation-routes.d.ts.map +1 -0
- package/packages/agent/src/api/conversation-routes.js +1208 -0
- package/packages/agent/src/api/coordinator-wiring.d.ts +4 -4
- package/packages/agent/src/api/coordinator-wiring.d.ts.map +1 -1
- package/packages/agent/src/api/coordinator-wiring.js +13 -6
- package/packages/agent/src/api/credit-detection.d.ts.map +1 -1
- package/packages/agent/src/api/credit-detection.js +12 -6
- package/packages/agent/src/api/curated-skills-routes.d.ts +22 -0
- package/packages/agent/src/api/curated-skills-routes.d.ts.map +1 -0
- package/packages/agent/src/api/curated-skills-routes.js +295 -0
- package/packages/agent/src/api/database.d.ts +2 -0
- package/packages/agent/src/api/database.d.ts.map +1 -1
- package/packages/agent/src/api/database.js +129 -8
- package/packages/agent/src/api/diagnostics-routes.d.ts +15 -2
- package/packages/agent/src/api/diagnostics-routes.d.ts.map +1 -1
- package/packages/agent/src/api/diagnostics-routes.js +145 -21
- package/packages/agent/src/api/documents-routes.d.ts +9 -0
- package/packages/agent/src/api/documents-routes.d.ts.map +1 -0
- package/packages/agent/src/api/documents-routes.js +26 -0
- package/packages/agent/src/api/documents-service-loader.d.ts +76 -0
- package/packages/agent/src/api/documents-service-loader.d.ts.map +1 -0
- package/packages/agent/src/api/{knowledge-service-loader.js → documents-service-loader.js} +10 -8
- package/packages/agent/src/api/health-routes.d.ts +46 -0
- package/packages/agent/src/api/health-routes.d.ts.map +1 -0
- package/packages/agent/src/api/health-routes.js +450 -0
- package/packages/agent/src/api/inbox-routes.d.ts +47 -0
- package/packages/agent/src/api/inbox-routes.d.ts.map +1 -0
- package/packages/agent/src/api/inbox-routes.js +1579 -0
- package/packages/agent/src/api/index.d.ts +45 -60
- package/packages/agent/src/api/index.d.ts.map +1 -1
- package/packages/agent/src/api/index.js +49 -59
- package/packages/agent/src/api/memory-routes.d.ts +1 -1
- package/packages/agent/src/api/memory-routes.d.ts.map +1 -1
- package/packages/agent/src/api/memory-routes.js +274 -41
- package/packages/agent/src/api/misc-routes.d.ts +64 -0
- package/packages/agent/src/api/misc-routes.d.ts.map +1 -0
- package/packages/agent/src/api/misc-routes.js +569 -0
- package/packages/agent/src/api/mobile-optional-routes.d.ts +3 -0
- package/packages/agent/src/api/mobile-optional-routes.d.ts.map +1 -0
- package/packages/agent/src/api/mobile-optional-routes.js +91 -0
- package/packages/agent/src/api/model-provider-helpers.d.ts +68 -0
- package/packages/agent/src/api/model-provider-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/model-provider-helpers.js +623 -0
- package/packages/agent/src/api/models-routes.d.ts +1 -1
- package/packages/agent/src/api/models-routes.d.ts.map +1 -1
- package/packages/agent/src/api/music-player-route-fallback.d.ts +16 -0
- package/packages/agent/src/api/music-player-route-fallback.d.ts.map +1 -0
- package/packages/agent/src/api/music-player-route-fallback.js +65 -0
- package/packages/agent/src/api/nfa-routes.d.ts +2 -1
- package/packages/agent/src/api/nfa-routes.d.ts.map +1 -1
- package/packages/agent/src/api/nfa-routes.js +10 -10
- package/packages/agent/src/api/onboarding-routes.d.ts +50 -0
- package/packages/agent/src/api/onboarding-routes.d.ts.map +1 -0
- package/packages/agent/src/api/onboarding-routes.js +588 -0
- package/packages/agent/src/api/owner-contact-helpers.d.ts +39 -0
- package/packages/agent/src/api/owner-contact-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/owner-contact-helpers.js +47 -0
- package/packages/agent/src/api/parse-action-block.d.ts +20 -3
- package/packages/agent/src/api/parse-action-block.d.ts.map +1 -1
- package/packages/agent/src/api/parse-action-block.js +77 -6
- package/packages/agent/src/api/permission-request-prompt.d.ts +19 -0
- package/packages/agent/src/api/permission-request-prompt.d.ts.map +1 -0
- package/packages/agent/src/api/permission-request-prompt.js +53 -0
- package/packages/agent/src/api/permissions-routes-extra.d.ts +30 -0
- package/packages/agent/src/api/permissions-routes-extra.d.ts.map +1 -0
- package/packages/agent/src/api/permissions-routes-extra.js +78 -0
- package/packages/agent/src/api/permissions-routes.d.ts +6 -11
- package/packages/agent/src/api/permissions-routes.d.ts.map +1 -1
- package/packages/agent/src/api/permissions-routes.js +230 -27
- package/packages/agent/src/api/plugin-discovery-helpers.d.ts +147 -0
- package/packages/agent/src/api/plugin-discovery-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/plugin-discovery-helpers.js +1118 -0
- package/packages/agent/src/api/plugin-routes.d.ts +144 -0
- package/packages/agent/src/api/plugin-routes.d.ts.map +1 -0
- package/packages/agent/src/api/plugin-routes.js +1285 -0
- package/packages/agent/src/api/plugin-runtime-apply.d.ts +31 -0
- package/packages/agent/src/api/plugin-runtime-apply.d.ts.map +1 -0
- package/packages/agent/src/api/plugin-runtime-apply.js +217 -0
- package/packages/agent/src/api/plugin-validation.d.ts.map +1 -1
- package/packages/agent/src/api/plugin-validation.js +4 -2
- package/packages/agent/src/api/provider-switch-config.d.ts +32 -7
- package/packages/agent/src/api/provider-switch-config.d.ts.map +1 -1
- package/packages/agent/src/api/provider-switch-config.js +627 -225
- package/packages/agent/src/api/provider-switch-routes.d.ts +29 -0
- package/packages/agent/src/api/provider-switch-routes.d.ts.map +1 -0
- package/packages/agent/src/api/provider-switch-routes.js +142 -0
- package/packages/agent/src/api/rate-limiter.d.ts +29 -0
- package/packages/agent/src/api/rate-limiter.d.ts.map +1 -0
- package/packages/agent/src/api/rate-limiter.js +57 -0
- package/packages/agent/src/api/registry-routes.d.ts +5 -2
- package/packages/agent/src/api/registry-routes.d.ts.map +1 -1
- package/packages/agent/src/api/registry-routes.js +13 -5
- package/packages/agent/src/api/registry-service.d.ts +1 -1
- package/packages/agent/src/api/registry-service.d.ts.map +1 -1
- package/packages/agent/src/api/relationships-routes.d.ts +7 -0
- package/packages/agent/src/api/relationships-routes.d.ts.map +1 -0
- package/packages/agent/src/api/relationships-routes.js +287 -0
- package/packages/agent/src/api/runtime-plugin-routes.d.ts +27 -0
- package/packages/agent/src/api/runtime-plugin-routes.d.ts.map +1 -0
- package/packages/agent/src/api/runtime-plugin-routes.js +203 -0
- package/packages/agent/src/api/server-auth.d.ts +46 -0
- package/packages/agent/src/api/server-auth.d.ts.map +1 -0
- package/packages/agent/src/api/server-auth.js +507 -0
- package/packages/agent/src/api/server-autonomy-helpers.d.ts +5 -0
- package/packages/agent/src/api/server-autonomy-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/server-autonomy-helpers.js +28 -0
- package/packages/agent/src/api/server-helpers-auth.d.ts +41 -0
- package/packages/agent/src/api/server-helpers-auth.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-auth.js +627 -0
- package/packages/agent/src/api/server-helpers-config.d.ts +37 -0
- package/packages/agent/src/api/server-helpers-config.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-config.js +293 -0
- package/packages/agent/src/api/server-helpers-fetch.d.ts +15 -0
- package/packages/agent/src/api/server-helpers-fetch.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-fetch.js +149 -0
- package/packages/agent/src/api/server-helpers-mcp.d.ts +12 -0
- package/packages/agent/src/api/server-helpers-mcp.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-mcp.js +315 -0
- package/packages/agent/src/api/server-helpers-plugin.d.ts +13 -0
- package/packages/agent/src/api/server-helpers-plugin.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-plugin.js +160 -0
- package/packages/agent/src/api/server-helpers-swarm.d.ts +101 -0
- package/packages/agent/src/api/server-helpers-swarm.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-swarm.js +646 -0
- package/packages/agent/src/api/server-helpers-wallet.d.ts +18 -0
- package/packages/agent/src/api/server-helpers-wallet.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-wallet.js +177 -0
- package/packages/agent/src/api/server-helpers.d.ts +96 -0
- package/packages/agent/src/api/server-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers.js +595 -0
- package/packages/agent/src/api/server-route-dispatch.d.ts +30 -0
- package/packages/agent/src/api/server-route-dispatch.d.ts.map +1 -0
- package/packages/agent/src/api/server-route-dispatch.js +103 -0
- package/packages/agent/src/api/server-startup.d.ts +16 -0
- package/packages/agent/src/api/server-startup.d.ts.map +1 -0
- package/packages/agent/src/api/server-startup.js +14 -0
- package/packages/agent/src/api/server-types.d.ts +232 -0
- package/packages/agent/src/api/server-types.d.ts.map +1 -0
- package/packages/agent/src/api/server-types.js +6 -0
- package/packages/agent/src/api/server.d.ts +26 -383
- package/packages/agent/src/api/server.d.ts.map +1 -1
- package/packages/agent/src/api/server.js +2022 -12484
- package/packages/agent/src/api/skill-discovery-helpers.d.ts +80 -0
- package/packages/agent/src/api/skill-discovery-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/skill-discovery-helpers.js +385 -0
- package/packages/agent/src/api/skills-routes.d.ts +32 -0
- package/packages/agent/src/api/skills-routes.d.ts.map +1 -0
- package/packages/agent/src/api/skills-routes.js +978 -0
- package/packages/agent/src/api/static-file-server.d.ts +19 -0
- package/packages/agent/src/api/static-file-server.d.ts.map +1 -0
- package/packages/agent/src/api/static-file-server.js +234 -0
- package/packages/agent/src/api/subscription-routes.d.ts +6 -6
- package/packages/agent/src/api/subscription-routes.d.ts.map +1 -1
- package/packages/agent/src/api/subscription-routes.js +84 -14
- package/packages/agent/src/api/task-agent-message-routing.d.ts +10 -0
- package/packages/agent/src/api/task-agent-message-routing.d.ts.map +1 -0
- package/packages/agent/src/api/task-agent-message-routing.js +62 -0
- package/packages/agent/src/api/terminal-execution-routing.d.ts +14 -0
- package/packages/agent/src/api/terminal-execution-routing.d.ts.map +1 -0
- package/packages/agent/src/api/terminal-execution-routing.js +23 -0
- package/packages/agent/src/api/terminal-run-limits.d.ts.map +1 -1
- package/packages/agent/src/api/terminal-run-limits.js +3 -5
- package/packages/agent/src/api/trade-safety.d.ts +35 -0
- package/packages/agent/src/api/trade-safety.d.ts.map +1 -0
- package/packages/agent/src/api/trade-safety.js +62 -0
- package/packages/agent/src/api/training-service-like.d.ts +3 -2
- package/packages/agent/src/api/training-service-like.d.ts.map +1 -1
- package/packages/agent/src/api/travel-provider-relay-routes.d.ts +9 -0
- package/packages/agent/src/api/travel-provider-relay-routes.d.ts.map +1 -0
- package/packages/agent/src/api/travel-provider-relay-routes.js +143 -0
- package/packages/agent/src/api/tx-service.d.ts +6 -0
- package/packages/agent/src/api/tx-service.d.ts.map +1 -1
- package/packages/agent/src/api/tx-service.js +64 -3
- package/packages/agent/src/api/update-routes.d.ts +19 -0
- package/packages/agent/src/api/update-routes.d.ts.map +1 -0
- package/packages/agent/src/api/update-routes.js +54 -0
- package/packages/agent/src/api/wallet-capability.d.ts +33 -0
- package/packages/agent/src/api/wallet-capability.d.ts.map +1 -0
- package/packages/agent/src/api/wallet-capability.js +193 -0
- package/packages/agent/src/api/wallet-dex-prices.d.ts +0 -18
- package/packages/agent/src/api/wallet-dex-prices.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-dex-prices.js +14 -38
- package/packages/agent/src/api/wallet-env-sync.d.ts +2 -0
- package/packages/agent/src/api/wallet-env-sync.d.ts.map +1 -0
- package/packages/agent/src/api/wallet-env-sync.js +108 -0
- package/packages/agent/src/api/wallet-evm-balance.d.ts +8 -1
- package/packages/agent/src/api/wallet-evm-balance.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-evm-balance.js +5 -5
- package/packages/agent/src/api/wallet-routes.d.ts +20 -12
- package/packages/agent/src/api/wallet-routes.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-routes.js +593 -37
- package/packages/agent/src/api/wallet-rpc.d.ts +14 -11
- package/packages/agent/src/api/wallet-rpc.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-rpc.js +108 -38
- package/packages/agent/src/api/wallet-trading-profile.d.ts +2 -22
- package/packages/agent/src/api/wallet-trading-profile.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-trading-profile.js +27 -30
- package/packages/agent/src/api/wallet.d.ts +38 -5
- package/packages/agent/src/api/wallet.d.ts.map +1 -1
- package/packages/agent/src/api/wallet.js +469 -202
- package/packages/agent/src/api/workbench-helpers.d.ts +39 -0
- package/packages/agent/src/api/workbench-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/workbench-helpers.js +137 -0
- package/packages/agent/src/api/workbench-routes.d.ts +43 -0
- package/packages/agent/src/api/workbench-routes.d.ts.map +1 -0
- package/packages/agent/src/api/workbench-routes.js +265 -0
- package/packages/agent/src/api/x-relay-routes.d.ts +27 -0
- package/packages/agent/src/api/x-relay-routes.d.ts.map +1 -0
- package/packages/agent/src/api/x-relay-routes.js +134 -0
- package/packages/agent/src/auth/account-storage.d.ts +48 -0
- package/packages/agent/src/auth/account-storage.d.ts.map +1 -0
- package/packages/agent/src/auth/account-storage.js +229 -0
- package/packages/agent/src/auth/anthropic.d.ts +3 -4
- package/packages/agent/src/auth/anthropic.d.ts.map +1 -1
- package/packages/agent/src/auth/anthropic.js +5 -7
- package/packages/agent/src/auth/claude-code-stealth-preload.d.ts +2 -0
- package/packages/agent/src/auth/claude-code-stealth-preload.d.ts.map +1 -0
- package/packages/agent/src/auth/claude-code-stealth-preload.js +2 -0
- package/packages/agent/src/auth/claude-code-stealth.d.ts.map +1 -1
- package/packages/agent/src/auth/claude-code-stealth.js +21 -9
- package/packages/agent/src/auth/credentials.d.ts +62 -17
- package/packages/agent/src/auth/credentials.d.ts.map +1 -1
- package/packages/agent/src/auth/credentials.js +492 -121
- package/packages/agent/src/auth/index.d.ts +7 -6
- package/packages/agent/src/auth/index.d.ts.map +1 -1
- package/packages/agent/src/auth/index.js +7 -3
- package/packages/agent/src/auth/oauth-flow.d.ts +106 -0
- package/packages/agent/src/auth/oauth-flow.d.ts.map +1 -0
- package/packages/agent/src/auth/oauth-flow.js +349 -0
- package/packages/agent/src/auth/openai-codex.d.ts +2 -2
- package/packages/agent/src/auth/openai-codex.d.ts.map +1 -1
- package/packages/agent/src/auth/openai-codex.js +17 -13
- package/packages/agent/src/auth/refresh-mutex.d.ts +19 -0
- package/packages/agent/src/auth/refresh-mutex.d.ts.map +1 -0
- package/packages/agent/src/auth/refresh-mutex.js +33 -0
- package/packages/agent/src/auth/types.d.ts +42 -2
- package/packages/agent/src/auth/types.d.ts.map +1 -1
- package/packages/agent/src/auth/types.js +142 -1
- package/packages/agent/src/auth/vendor/pi-oauth/anthropic-login.d.ts +48 -0
- package/packages/agent/src/auth/vendor/pi-oauth/anthropic-login.d.ts.map +1 -0
- package/packages/agent/src/auth/vendor/pi-oauth/anthropic-login.js +113 -0
- package/packages/agent/src/auth/vendor/pi-oauth/openai-codex-login.d.ts +26 -0
- package/packages/agent/src/auth/vendor/pi-oauth/openai-codex-login.d.ts.map +1 -0
- package/packages/agent/src/auth/vendor/pi-oauth/openai-codex-login.js +343 -0
- package/packages/agent/src/auth/vendor/pi-oauth/pkce.d.ts +9 -0
- package/packages/agent/src/auth/vendor/pi-oauth/pkce.d.ts.map +1 -0
- package/packages/agent/src/auth/vendor/pi-oauth/pkce.js +21 -0
- package/packages/agent/src/autonomy/index.d.ts +48 -0
- package/packages/agent/src/autonomy/index.d.ts.map +1 -0
- package/packages/agent/src/autonomy/index.js +344 -0
- package/packages/agent/src/awareness/index.d.ts +2 -0
- package/packages/agent/src/awareness/index.d.ts.map +1 -0
- package/packages/agent/src/awareness/index.js +1 -0
- package/packages/agent/src/awareness/registry.d.ts +1 -26
- package/packages/agent/src/awareness/registry.d.ts.map +1 -1
- package/packages/agent/src/awareness/registry.js +1 -161
- package/packages/agent/src/bin.js +46 -1
- package/packages/agent/src/cli/benchmark.d.ts +10 -0
- package/packages/agent/src/cli/benchmark.d.ts.map +1 -0
- package/packages/agent/src/cli/benchmark.js +293 -0
- package/packages/agent/src/cli/index.d.ts.map +1 -1
- package/packages/agent/src/cli/index.js +58 -4
- package/packages/agent/src/config/config.d.ts +2 -2
- package/packages/agent/src/config/config.d.ts.map +1 -1
- package/packages/agent/src/config/config.js +185 -18
- package/packages/agent/src/config/env-vars.d.ts +7 -1
- package/packages/agent/src/config/env-vars.d.ts.map +1 -1
- package/packages/agent/src/config/env-vars.js +205 -0
- package/packages/agent/src/config/feature-flags.d.ts +17 -0
- package/packages/agent/src/config/feature-flags.d.ts.map +1 -0
- package/packages/agent/src/config/feature-flags.js +37 -0
- package/packages/agent/src/config/includes.d.ts.map +1 -1
- package/packages/agent/src/config/includes.js +6 -5
- package/packages/agent/src/config/index.d.ts +10 -15
- package/packages/agent/src/config/index.d.ts.map +1 -1
- package/packages/agent/src/config/index.js +9 -15
- package/packages/agent/src/config/model-metadata.d.ts +20 -0
- package/packages/agent/src/config/model-metadata.d.ts.map +1 -0
- package/packages/agent/src/config/model-metadata.js +133 -0
- package/packages/agent/src/config/owner-contacts.d.ts +42 -0
- package/packages/agent/src/config/owner-contacts.d.ts.map +1 -0
- package/packages/agent/src/config/owner-contacts.js +238 -0
- package/packages/agent/src/config/paths.d.ts +10 -6
- package/packages/agent/src/config/paths.d.ts.map +1 -1
- package/packages/agent/src/config/paths.js +43 -45
- package/packages/agent/src/config/plugin-auto-enable.d.ts +12 -15
- package/packages/agent/src/config/plugin-auto-enable.d.ts.map +1 -1
- package/packages/agent/src/config/plugin-auto-enable.js +12 -384
- package/packages/agent/src/config/plugin-widgets.d.ts +29 -0
- package/packages/agent/src/config/plugin-widgets.d.ts.map +1 -0
- package/packages/agent/src/config/plugin-widgets.js +104 -0
- package/packages/agent/src/config/schema.d.ts +2 -2
- package/packages/agent/src/config/schema.d.ts.map +1 -1
- package/packages/agent/src/config/schema.js +24 -24
- package/packages/agent/src/config/types.agent-defaults.d.ts +1 -330
- package/packages/agent/src/config/types.agent-defaults.d.ts.map +1 -1
- package/packages/agent/src/config/types.agent-defaults.js +1 -1
- package/packages/agent/src/config/types.agents.d.ts +1 -109
- package/packages/agent/src/config/types.agents.d.ts.map +1 -1
- package/packages/agent/src/config/types.agents.js +1 -1
- package/packages/agent/src/config/types.d.ts +1 -7
- package/packages/agent/src/config/types.d.ts.map +1 -1
- package/packages/agent/src/config/types.eliza.d.ts +1 -635
- package/packages/agent/src/config/types.eliza.d.ts.map +1 -1
- package/packages/agent/src/config/types.eliza.js +1 -1
- package/packages/agent/src/config/types.gateway.d.ts +1 -215
- package/packages/agent/src/config/types.gateway.d.ts.map +1 -1
- package/packages/agent/src/config/types.gateway.js +1 -1
- package/packages/agent/src/config/types.hooks.d.ts +1 -106
- package/packages/agent/src/config/types.hooks.d.ts.map +1 -1
- package/packages/agent/src/config/types.hooks.js +1 -1
- package/packages/agent/src/config/types.js +1 -7
- package/packages/agent/src/config/types.messages.d.ts +1 -175
- package/packages/agent/src/config/types.messages.d.ts.map +1 -1
- package/packages/agent/src/config/types.messages.js +1 -1
- package/packages/agent/src/config/types.tools.d.ts +1 -399
- package/packages/agent/src/config/types.tools.d.ts.map +1 -1
- package/packages/agent/src/config/types.tools.js +1 -1
- package/packages/agent/src/config/zod-schema.agent-runtime.d.ts +111 -9
- package/packages/agent/src/config/zod-schema.agent-runtime.d.ts.map +1 -1
- package/packages/agent/src/config/zod-schema.agent-runtime.js +89 -2
- package/packages/agent/src/config/zod-schema.core.d.ts +308 -50
- package/packages/agent/src/config/zod-schema.core.d.ts.map +1 -1
- package/packages/agent/src/config/zod-schema.core.js +81 -14
- package/packages/agent/src/config/zod-schema.d.ts +500 -1913
- package/packages/agent/src/config/zod-schema.d.ts.map +1 -1
- package/packages/agent/src/config/zod-schema.js +84 -16
- package/packages/agent/src/config/zod-schema.providers-core.d.ts +135 -359
- package/packages/agent/src/config/zod-schema.providers-core.d.ts.map +1 -1
- package/packages/agent/src/config/zod-schema.providers-core.js +51 -88
- package/packages/agent/src/config/zod-schema.session.d.ts +1 -1
- package/packages/agent/src/config/zod-schema.session.js +1 -1
- package/packages/agent/src/contracts/awareness.d.ts +1 -1
- package/packages/agent/src/contracts/index.d.ts +1 -8
- package/packages/agent/src/contracts/index.d.ts.map +1 -1
- package/packages/agent/src/contracts/index.js +1 -8
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts +177 -0
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts.map +1 -0
- package/packages/agent/src/contracts/{onboarding.js → onboarding-provider-defaults.js} +21 -109
- package/packages/agent/src/diagnostics/index.d.ts +2 -0
- package/packages/agent/src/diagnostics/index.d.ts.map +1 -0
- package/packages/agent/src/diagnostics/index.js +1 -0
- package/packages/agent/src/diagnostics/integration-observability.d.ts +1 -1
- package/packages/agent/src/diagnostics/integration-observability.d.ts.map +1 -1
- package/packages/agent/src/diagnostics/integration-observability.js +13 -3
- package/packages/agent/src/hooks/discovery.d.ts +1 -1
- package/packages/agent/src/hooks/discovery.d.ts.map +1 -1
- package/packages/agent/src/hooks/discovery.js +10 -3
- package/packages/agent/src/hooks/eligibility.d.ts +2 -2
- package/packages/agent/src/hooks/eligibility.d.ts.map +1 -1
- package/packages/agent/src/hooks/eligibility.js +7 -2
- package/packages/agent/src/hooks/index.d.ts +2 -2
- package/packages/agent/src/hooks/index.d.ts.map +1 -1
- package/packages/agent/src/hooks/index.js +2 -2
- package/packages/agent/src/hooks/loader.d.ts +2 -2
- package/packages/agent/src/hooks/loader.d.ts.map +1 -1
- package/packages/agent/src/hooks/loader.js +50 -12
- package/packages/agent/src/hooks/registry.d.ts +1 -1
- package/packages/agent/src/hooks/registry.d.ts.map +1 -1
- package/packages/agent/src/index.d.ts +72 -19
- package/packages/agent/src/index.d.ts.map +1 -1
- package/packages/agent/src/index.js +104 -19
- package/packages/agent/src/providers/admin-panel.d.ts +4 -0
- package/packages/agent/src/providers/admin-panel.d.ts.map +1 -0
- package/packages/agent/src/providers/admin-panel.js +89 -0
- package/packages/agent/src/providers/admin-trust.d.ts.map +1 -1
- package/packages/agent/src/providers/admin-trust.js +20 -33
- package/packages/agent/src/providers/automation-terminal-bridge.d.ts +3 -0
- package/packages/agent/src/providers/automation-terminal-bridge.d.ts.map +1 -0
- package/packages/agent/src/providers/automation-terminal-bridge.js +77 -0
- package/packages/agent/src/providers/conversation-proximity.d.ts +3 -0
- package/packages/agent/src/providers/conversation-proximity.d.ts.map +1 -0
- package/packages/agent/src/providers/conversation-proximity.js +62 -0
- package/packages/agent/src/providers/escalation-trigger.d.ts +15 -0
- package/packages/agent/src/providers/escalation-trigger.d.ts.map +1 -0
- package/packages/agent/src/providers/escalation-trigger.js +171 -0
- package/packages/agent/src/providers/index.d.ts +19 -0
- package/packages/agent/src/providers/index.d.ts.map +1 -0
- package/packages/agent/src/providers/index.js +18 -0
- package/packages/agent/src/providers/local-models.d.ts +118 -0
- package/packages/agent/src/providers/local-models.d.ts.map +1 -0
- package/packages/agent/src/providers/local-models.js +418 -0
- package/packages/agent/src/providers/media-provider.d.ts +233 -0
- package/packages/agent/src/providers/media-provider.d.ts.map +1 -0
- package/packages/agent/src/providers/media-provider.js +1474 -0
- package/packages/agent/src/providers/page-scoped-context.d.ts +3 -0
- package/packages/agent/src/providers/page-scoped-context.d.ts.map +1 -0
- package/packages/agent/src/providers/page-scoped-context.js +551 -0
- package/packages/agent/src/providers/pending-permissions-provider.d.ts +19 -0
- package/packages/agent/src/providers/pending-permissions-provider.d.ts.map +1 -0
- package/packages/agent/src/providers/pending-permissions-provider.js +104 -0
- package/packages/agent/src/providers/recent-conversations.d.ts +3 -0
- package/packages/agent/src/providers/recent-conversations.d.ts.map +1 -0
- package/packages/agent/src/providers/recent-conversations.js +100 -0
- package/packages/agent/src/providers/relevant-conversations.d.ts +3 -0
- package/packages/agent/src/providers/relevant-conversations.d.ts.map +1 -0
- package/packages/agent/src/providers/relevant-conversations.js +99 -0
- package/packages/agent/src/providers/role-backfill.d.ts +18 -0
- package/packages/agent/src/providers/role-backfill.d.ts.map +1 -0
- package/packages/agent/src/providers/role-backfill.js +86 -0
- package/packages/agent/src/providers/rolodex.d.ts +3 -0
- package/packages/agent/src/providers/rolodex.d.ts.map +1 -0
- package/packages/agent/src/providers/rolodex.js +83 -0
- package/packages/agent/src/providers/self-status.d.ts +4 -0
- package/packages/agent/src/providers/self-status.d.ts.map +1 -0
- package/packages/agent/src/providers/self-status.js +22 -0
- package/packages/agent/src/providers/session-bridge.d.ts.map +1 -1
- package/packages/agent/src/providers/session-bridge.js +6 -1
- package/packages/agent/src/providers/session-utils.d.ts +1 -1
- package/packages/agent/src/providers/session-utils.d.ts.map +1 -1
- package/packages/agent/src/providers/session-utils.js +2 -3
- package/packages/agent/src/providers/simple-mode.d.ts.map +1 -1
- package/packages/agent/src/providers/simple-mode.js +18 -54
- package/packages/agent/src/providers/skill-provider.d.ts +16 -0
- package/packages/agent/src/providers/skill-provider.d.ts.map +1 -0
- package/packages/agent/src/providers/skill-provider.js +353 -0
- package/packages/agent/src/providers/tasks.d.ts +9 -0
- package/packages/agent/src/providers/tasks.d.ts.map +1 -0
- package/packages/agent/src/providers/tasks.js +118 -0
- package/packages/agent/src/providers/ui-catalog.d.ts.map +1 -1
- package/packages/agent/src/providers/ui-catalog.js +15 -38
- package/packages/agent/src/providers/user-name.d.ts +11 -0
- package/packages/agent/src/providers/user-name.d.ts.map +1 -0
- package/packages/agent/src/providers/user-name.js +46 -0
- package/packages/agent/src/providers/workspace-provider.d.ts +3 -11
- package/packages/agent/src/providers/workspace-provider.d.ts.map +1 -1
- package/packages/agent/src/providers/workspace-provider.js +27 -11
- package/packages/agent/src/providers/workspace.d.ts +2 -3
- package/packages/agent/src/providers/workspace.d.ts.map +1 -1
- package/packages/agent/src/providers/workspace.js +81 -68
- package/packages/agent/src/runtime/advanced-capabilities-config.d.ts +8 -0
- package/packages/agent/src/runtime/advanced-capabilities-config.d.ts.map +1 -0
- package/packages/agent/src/runtime/advanced-capabilities-config.js +41 -0
- package/packages/agent/src/runtime/agent-wallets.d.ts +138 -0
- package/packages/agent/src/runtime/agent-wallets.d.ts.map +1 -0
- package/packages/agent/src/runtime/agent-wallets.js +308 -0
- package/packages/agent/src/runtime/analysis-mode-flag.d.ts +93 -0
- package/packages/agent/src/runtime/analysis-mode-flag.d.ts.map +1 -0
- package/packages/agent/src/runtime/analysis-mode-flag.js +131 -0
- package/packages/agent/src/runtime/android-app-plugins.d.ts +13 -0
- package/packages/agent/src/runtime/android-app-plugins.d.ts.map +1 -0
- package/packages/agent/src/runtime/android-app-plugins.js +48 -0
- package/packages/agent/src/runtime/aosp-dflash-adapter.d.ts +99 -0
- package/packages/agent/src/runtime/aosp-dflash-adapter.d.ts.map +1 -0
- package/packages/agent/src/runtime/aosp-dflash-adapter.js +332 -0
- package/packages/agent/src/runtime/build-character-config.d.ts +2 -0
- package/packages/agent/src/runtime/build-character-config.d.ts.map +1 -0
- package/packages/agent/src/runtime/build-character-config.js +176 -0
- package/packages/agent/src/runtime/conversation-compactor-runtime.d.ts +141 -0
- package/packages/agent/src/runtime/conversation-compactor-runtime.d.ts.map +1 -0
- package/packages/agent/src/runtime/conversation-compactor-runtime.js +460 -0
- package/packages/agent/src/runtime/conversation-compactor.d.ts +38 -0
- package/packages/agent/src/runtime/conversation-compactor.d.ts.map +1 -0
- package/packages/agent/src/runtime/conversation-compactor.js +1121 -0
- package/packages/agent/src/runtime/conversation-compactor.types.d.ts +102 -0
- package/packages/agent/src/runtime/conversation-compactor.types.d.ts.map +1 -0
- package/packages/agent/src/runtime/conversation-compactor.types.js +30 -0
- package/packages/agent/src/runtime/core-plugins.d.ts +50 -0
- package/packages/agent/src/runtime/core-plugins.d.ts.map +1 -1
- package/packages/agent/src/runtime/core-plugins.js +85 -16
- package/packages/agent/src/runtime/custom-actions.d.ts +5 -2
- package/packages/agent/src/runtime/custom-actions.d.ts.map +1 -1
- package/packages/agent/src/runtime/custom-actions.js +93 -14
- package/packages/agent/src/runtime/default-documents.d.ts +21 -0
- package/packages/agent/src/runtime/default-documents.d.ts.map +1 -0
- package/packages/agent/src/runtime/default-documents.js +283 -0
- package/packages/agent/src/runtime/eliza-plugin.d.ts +1 -1
- package/packages/agent/src/runtime/eliza-plugin.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza-plugin.js +142 -67
- package/packages/agent/src/runtime/eliza.d.ts +23 -119
- package/packages/agent/src/runtime/eliza.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza.js +1512 -2085
- package/packages/agent/src/runtime/embedding-presets.d.ts.map +1 -1
- package/packages/agent/src/runtime/embedding-presets.js +27 -20
- package/packages/agent/src/runtime/first-time-setup.d.ts +47 -0
- package/packages/agent/src/runtime/first-time-setup.d.ts.map +1 -0
- package/packages/agent/src/runtime/first-time-setup.js +704 -0
- package/packages/agent/src/runtime/index.d.ts +19 -8
- package/packages/agent/src/runtime/index.d.ts.map +1 -1
- package/packages/agent/src/runtime/index.js +19 -8
- package/packages/agent/src/runtime/load-plugin-from-vfs.d.ts +54 -0
- package/packages/agent/src/runtime/load-plugin-from-vfs.d.ts.map +1 -0
- package/packages/agent/src/runtime/load-plugin-from-vfs.js +86 -0
- package/packages/agent/src/runtime/local-execution-mode.d.ts +11 -0
- package/packages/agent/src/runtime/local-execution-mode.d.ts.map +1 -0
- package/packages/agent/src/runtime/local-execution-mode.js +10 -0
- package/packages/agent/src/runtime/model-resolution.d.ts +2 -0
- package/packages/agent/src/runtime/model-resolution.d.ts.map +1 -0
- package/packages/agent/src/runtime/model-resolution.js +55 -0
- package/packages/agent/src/runtime/native-runtime-features.d.ts +4 -0
- package/packages/agent/src/runtime/native-runtime-features.d.ts.map +1 -0
- package/packages/agent/src/runtime/native-runtime-features.js +10 -0
- package/packages/agent/src/runtime/onboarding-names.d.ts +3 -3
- package/packages/agent/src/runtime/onboarding-names.d.ts.map +1 -1
- package/packages/agent/src/runtime/onboarding-names.js +14 -7
- package/packages/agent/src/runtime/operations/classifier.d.ts +36 -0
- package/packages/agent/src/runtime/operations/classifier.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/classifier.js +72 -0
- package/packages/agent/src/runtime/operations/cold-strategy.d.ts +19 -0
- package/packages/agent/src/runtime/operations/cold-strategy.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/cold-strategy.js +50 -0
- package/packages/agent/src/runtime/operations/health-checks.d.ts +25 -0
- package/packages/agent/src/runtime/operations/health-checks.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/health-checks.js +186 -0
- package/packages/agent/src/runtime/operations/health.d.ts +32 -0
- package/packages/agent/src/runtime/operations/health.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/health.js +139 -0
- package/packages/agent/src/runtime/operations/index.d.ts +17 -0
- package/packages/agent/src/runtime/operations/index.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/index.js +15 -0
- package/packages/agent/src/runtime/operations/manager.d.ts +70 -0
- package/packages/agent/src/runtime/operations/manager.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/manager.js +202 -0
- package/packages/agent/src/runtime/operations/reload-hot.d.ts +43 -0
- package/packages/agent/src/runtime/operations/reload-hot.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/reload-hot.js +181 -0
- package/packages/agent/src/runtime/operations/repository.d.ts +66 -0
- package/packages/agent/src/runtime/operations/repository.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/repository.js +319 -0
- package/packages/agent/src/runtime/operations/types.d.ts +203 -0
- package/packages/agent/src/runtime/operations/types.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/types.js +18 -0
- package/packages/agent/src/runtime/operations/vault-bridge.d.ts +81 -0
- package/packages/agent/src/runtime/operations/vault-bridge.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/vault-bridge.js +133 -0
- package/packages/agent/src/runtime/owner-entity.d.ts +4 -0
- package/packages/agent/src/runtime/owner-entity.d.ts.map +1 -0
- package/packages/agent/src/runtime/owner-entity.js +30 -0
- package/packages/agent/src/runtime/pglite-error-compat.d.ts +28 -0
- package/packages/agent/src/runtime/pglite-error-compat.d.ts.map +1 -0
- package/packages/agent/src/runtime/pglite-error-compat.js +54 -0
- package/packages/agent/src/runtime/plugin-collector.d.ts +22 -0
- package/packages/agent/src/runtime/plugin-collector.d.ts.map +1 -0
- package/packages/agent/src/runtime/plugin-collector.js +503 -0
- package/packages/agent/src/runtime/plugin-lifecycle.d.ts +45 -0
- package/packages/agent/src/runtime/plugin-lifecycle.d.ts.map +1 -0
- package/packages/agent/src/runtime/plugin-lifecycle.js +602 -0
- package/packages/agent/src/runtime/plugin-resolver.d.ts +46 -0
- package/packages/agent/src/runtime/plugin-resolver.d.ts.map +1 -0
- package/packages/agent/src/runtime/plugin-resolver.js +1375 -0
- package/packages/agent/src/runtime/plugin-role-gating.d.ts +24 -0
- package/packages/agent/src/runtime/plugin-role-gating.d.ts.map +1 -0
- package/packages/agent/src/runtime/plugin-role-gating.js +106 -0
- package/packages/agent/src/runtime/plugin-types.d.ts +64 -0
- package/packages/agent/src/runtime/plugin-types.d.ts.map +1 -0
- package/packages/agent/src/runtime/plugin-types.js +306 -0
- package/packages/agent/src/runtime/prompt-compaction.d.ts +98 -0
- package/packages/agent/src/runtime/prompt-compaction.d.ts.map +1 -0
- package/packages/agent/src/runtime/prompt-compaction.js +362 -0
- package/packages/agent/src/runtime/prompt-optimization.d.ts +47 -0
- package/packages/agent/src/runtime/prompt-optimization.d.ts.map +1 -0
- package/packages/agent/src/runtime/prompt-optimization.js +1123 -0
- package/packages/agent/src/runtime/release-plugin-policy.d.ts.map +1 -1
- package/packages/agent/src/runtime/release-plugin-policy.js +2 -4
- package/packages/agent/src/runtime/restart.d.ts +5 -41
- package/packages/agent/src/runtime/restart.d.ts.map +1 -1
- package/packages/agent/src/runtime/restart.js +5 -42
- package/packages/agent/src/runtime/roles/src/index.d.ts +24 -0
- package/packages/agent/src/runtime/roles/src/index.d.ts.map +1 -0
- package/packages/agent/src/runtime/roles/src/index.js +255 -0
- package/packages/agent/src/runtime/roles/src/provider.d.ts +7 -0
- package/packages/agent/src/runtime/roles/src/provider.d.ts.map +1 -0
- package/packages/agent/src/runtime/roles/src/provider.js +138 -0
- package/packages/agent/src/runtime/roles/src/types.d.ts +3 -0
- package/packages/agent/src/runtime/roles/src/types.d.ts.map +1 -0
- package/packages/agent/src/runtime/roles/src/types.js +1 -0
- package/packages/agent/src/runtime/roles/src/utils.d.ts +2 -0
- package/packages/agent/src/runtime/roles/src/utils.d.ts.map +1 -0
- package/packages/agent/src/runtime/roles/src/utils.js +1 -0
- package/packages/agent/src/runtime/roles.d.ts +3 -0
- package/packages/agent/src/runtime/roles.d.ts.map +1 -0
- package/packages/agent/src/runtime/roles.js +5 -0
- package/packages/agent/src/runtime/subagent-output.d.ts +51 -0
- package/packages/agent/src/runtime/subagent-output.d.ts.map +1 -0
- package/packages/agent/src/runtime/subagent-output.js +173 -0
- package/packages/agent/src/runtime/task-heartbeat.d.ts +22 -0
- package/packages/agent/src/runtime/task-heartbeat.d.ts.map +1 -0
- package/packages/agent/src/runtime/task-heartbeat.js +84 -0
- package/packages/agent/src/runtime/tool-call-cache/cache.d.ts +62 -0
- package/packages/agent/src/runtime/tool-call-cache/cache.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/cache.js +123 -0
- package/packages/agent/src/runtime/tool-call-cache/disk-store.d.ts +23 -0
- package/packages/agent/src/runtime/tool-call-cache/disk-store.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/disk-store.js +55 -0
- package/packages/agent/src/runtime/tool-call-cache/index.d.ts +7 -0
- package/packages/agent/src/runtime/tool-call-cache/index.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/index.js +4 -0
- package/packages/agent/src/runtime/tool-call-cache/key.d.ts +11 -0
- package/packages/agent/src/runtime/tool-call-cache/key.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/key.js +31 -0
- package/packages/agent/src/runtime/tool-call-cache/lru.d.ts +17 -0
- package/packages/agent/src/runtime/tool-call-cache/lru.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/lru.js +46 -0
- package/packages/agent/src/runtime/tool-call-cache/redact.d.ts +17 -0
- package/packages/agent/src/runtime/tool-call-cache/redact.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/redact.js +77 -0
- package/packages/agent/src/runtime/tool-call-cache/registry.d.ts +18 -0
- package/packages/agent/src/runtime/tool-call-cache/registry.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/registry.js +66 -0
- package/packages/agent/src/runtime/tool-call-cache/types.d.ts +50 -0
- package/packages/agent/src/runtime/tool-call-cache/types.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache/types.js +10 -0
- package/packages/agent/src/runtime/tool-call-cache-wrapper.d.ts +39 -0
- package/packages/agent/src/runtime/tool-call-cache-wrapper.d.ts.map +1 -0
- package/packages/agent/src/runtime/tool-call-cache-wrapper.js +72 -0
- package/packages/agent/src/runtime/trajectory-export.d.ts +18 -0
- package/packages/agent/src/runtime/trajectory-export.d.ts.map +1 -0
- package/packages/agent/src/runtime/trajectory-export.js +109 -0
- package/packages/agent/src/runtime/trajectory-internals.d.ts +242 -0
- package/packages/agent/src/runtime/trajectory-internals.d.ts.map +1 -0
- package/packages/agent/src/runtime/trajectory-internals.js +1281 -0
- package/packages/agent/src/runtime/trajectory-persistence.d.ts +13 -212
- package/packages/agent/src/runtime/trajectory-persistence.d.ts.map +1 -1
- package/packages/agent/src/runtime/trajectory-persistence.js +25 -1952
- package/packages/agent/src/runtime/trajectory-query.d.ts +8 -0
- package/packages/agent/src/runtime/trajectory-query.d.ts.map +1 -0
- package/packages/agent/src/runtime/trajectory-query.js +27 -0
- package/packages/agent/src/runtime/trajectory-storage.d.ts +91 -0
- package/packages/agent/src/runtime/trajectory-storage.d.ts.map +1 -0
- package/packages/agent/src/runtime/trajectory-storage.js +1093 -0
- package/packages/agent/src/runtime/vault-profile-resolver.d.ts +37 -0
- package/packages/agent/src/runtime/vault-profile-resolver.d.ts.map +1 -0
- package/packages/agent/src/runtime/vault-profile-resolver.js +79 -0
- package/packages/agent/src/runtime/version.js +1 -1
- package/packages/agent/src/runtime/web-search-tools.d.ts +22 -0
- package/packages/agent/src/runtime/web-search-tools.d.ts.map +1 -0
- package/packages/agent/src/runtime/web-search-tools.js +151 -0
- package/packages/agent/src/security/access.d.ts +17 -0
- package/packages/agent/src/security/access.d.ts.map +1 -0
- package/packages/agent/src/security/access.js +54 -0
- package/packages/agent/src/security/audit-log.d.ts +0 -2
- package/packages/agent/src/security/audit-log.d.ts.map +1 -1
- package/packages/agent/src/security/index.d.ts +4 -0
- package/packages/agent/src/security/index.d.ts.map +1 -0
- package/packages/agent/src/security/index.js +3 -0
- package/packages/agent/src/services/agent-export.d.ts.map +1 -1
- package/packages/agent/src/services/agent-export.js +58 -23
- package/packages/agent/src/services/app-manager-agents-list-guard.d.ts +4 -0
- package/packages/agent/src/services/app-manager-agents-list-guard.d.ts.map +1 -0
- package/packages/agent/src/services/app-manager-agents-list-guard.js +15 -0
- package/packages/agent/src/services/app-manager.d.ts +78 -4
- package/packages/agent/src/services/app-manager.d.ts.map +1 -1
- package/packages/agent/src/services/app-manager.js +1429 -176
- package/packages/agent/src/services/app-package-modules.d.ts +22 -0
- package/packages/agent/src/services/app-package-modules.d.ts.map +1 -0
- package/packages/agent/src/services/app-package-modules.js +397 -0
- package/packages/agent/src/services/app-run-store.d.ts +6 -0
- package/packages/agent/src/services/app-run-store.d.ts.map +1 -0
- package/packages/agent/src/services/app-run-store.js +547 -0
- package/packages/agent/src/services/app-session-gate.d.ts +15 -0
- package/packages/agent/src/services/app-session-gate.d.ts.map +1 -0
- package/packages/agent/src/services/app-session-gate.js +71 -0
- package/packages/agent/src/services/capability-broker.d.ts +89 -0
- package/packages/agent/src/services/capability-broker.d.ts.map +1 -0
- package/packages/agent/src/services/capability-broker.js +339 -0
- package/packages/agent/src/services/character-history.d.ts +69 -0
- package/packages/agent/src/services/character-history.d.ts.map +1 -0
- package/packages/agent/src/services/character-history.js +280 -0
- package/packages/agent/src/services/character-persistence.d.ts +25 -0
- package/packages/agent/src/services/character-persistence.d.ts.map +1 -0
- package/packages/agent/src/services/character-persistence.js +167 -0
- package/packages/agent/src/services/client-chat-sender.d.ts +19 -0
- package/packages/agent/src/services/client-chat-sender.d.ts.map +1 -0
- package/packages/agent/src/services/client-chat-sender.js +88 -0
- package/packages/agent/src/services/config-plugin-manager.d.ts +6 -0
- package/packages/agent/src/services/config-plugin-manager.d.ts.map +1 -0
- package/packages/agent/src/services/config-plugin-manager.js +53 -0
- package/packages/agent/src/services/connector-setup-service.d.ts +48 -0
- package/packages/agent/src/services/connector-setup-service.d.ts.map +1 -0
- package/packages/agent/src/services/connector-setup-service.js +60 -0
- package/packages/agent/src/services/escalation.d.ts +35 -0
- package/packages/agent/src/services/escalation.d.ts.map +1 -0
- package/packages/agent/src/services/escalation.js +376 -0
- package/packages/agent/src/services/evm-signing-capability.d.ts +33 -0
- package/packages/agent/src/services/evm-signing-capability.d.ts.map +1 -0
- package/packages/agent/src/services/evm-signing-capability.js +52 -0
- package/packages/agent/src/services/external-bridge-state.d.ts +10 -0
- package/packages/agent/src/services/external-bridge-state.d.ts.map +1 -0
- package/packages/agent/src/services/external-bridge-state.js +14 -0
- package/packages/agent/src/services/hosted-tools.d.ts +70 -0
- package/packages/agent/src/services/hosted-tools.d.ts.map +1 -0
- package/packages/agent/src/services/hosted-tools.js +87 -0
- package/packages/agent/src/services/index.d.ts +26 -17
- package/packages/agent/src/services/index.d.ts.map +1 -1
- package/packages/agent/src/services/index.js +32 -17
- package/packages/agent/src/services/js-runtime-bridge.d.ts +105 -0
- package/packages/agent/src/services/js-runtime-bridge.d.ts.map +1 -0
- package/packages/agent/src/services/js-runtime-bridge.js +217 -0
- package/packages/agent/src/services/mcp-marketplace.js +1 -1
- package/packages/agent/src/services/media-generation.d.ts +10 -0
- package/packages/agent/src/services/media-generation.d.ts.map +1 -0
- package/packages/agent/src/services/media-generation.js +102 -0
- package/packages/agent/src/services/overlay-app-presence.d.ts +9 -0
- package/packages/agent/src/services/overlay-app-presence.d.ts.map +1 -0
- package/packages/agent/src/services/overlay-app-presence.js +18 -0
- package/packages/agent/src/services/owner-name.d.ts +4 -0
- package/packages/agent/src/services/owner-name.d.ts.map +1 -0
- package/packages/agent/src/services/owner-name.js +46 -0
- package/packages/agent/src/services/permissions/contracts.d.ts +9 -0
- package/packages/agent/src/services/permissions/contracts.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/contracts.js +8 -0
- package/packages/agent/src/services/permissions/probers/_bridge.d.ts +77 -0
- package/packages/agent/src/services/permissions/probers/_bridge.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/_bridge.js +224 -0
- package/packages/agent/src/services/permissions/probers/accessibility.d.ts +16 -0
- package/packages/agent/src/services/permissions/probers/accessibility.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/accessibility.js +45 -0
- package/packages/agent/src/services/permissions/probers/automation.d.ts +17 -0
- package/packages/agent/src/services/permissions/probers/automation.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/automation.js +46 -0
- package/packages/agent/src/services/permissions/probers/calendar.d.ts +14 -0
- package/packages/agent/src/services/permissions/probers/calendar.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/calendar.js +33 -0
- package/packages/agent/src/services/permissions/probers/camera.d.ts +14 -0
- package/packages/agent/src/services/permissions/probers/camera.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/camera.js +39 -0
- package/packages/agent/src/services/permissions/probers/contacts.d.ts +13 -0
- package/packages/agent/src/services/permissions/probers/contacts.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/contacts.js +32 -0
- package/packages/agent/src/services/permissions/probers/full-disk.d.ts +22 -0
- package/packages/agent/src/services/permissions/probers/full-disk.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/full-disk.js +78 -0
- package/packages/agent/src/services/permissions/probers/health.d.ts +23 -0
- package/packages/agent/src/services/permissions/probers/health.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/health.js +82 -0
- package/packages/agent/src/services/permissions/probers/index.d.ts +27 -0
- package/packages/agent/src/services/permissions/probers/index.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/index.js +42 -0
- package/packages/agent/src/services/permissions/probers/location.d.ts +21 -0
- package/packages/agent/src/services/permissions/probers/location.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/location.js +47 -0
- package/packages/agent/src/services/permissions/probers/microphone.d.ts +14 -0
- package/packages/agent/src/services/permissions/probers/microphone.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/microphone.js +41 -0
- package/packages/agent/src/services/permissions/probers/notes.d.ts +19 -0
- package/packages/agent/src/services/permissions/probers/notes.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/notes.js +55 -0
- package/packages/agent/src/services/permissions/probers/notifications.d.ts +24 -0
- package/packages/agent/src/services/permissions/probers/notifications.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/notifications.js +47 -0
- package/packages/agent/src/services/permissions/probers/reminders.d.ts +22 -0
- package/packages/agent/src/services/permissions/probers/reminders.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/reminders.js +44 -0
- package/packages/agent/src/services/permissions/probers/screen-recording.d.ts +15 -0
- package/packages/agent/src/services/permissions/probers/screen-recording.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/screen-recording.js +39 -0
- package/packages/agent/src/services/permissions/probers/screentime.d.ts +21 -0
- package/packages/agent/src/services/permissions/probers/screentime.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/screentime.js +67 -0
- package/packages/agent/src/services/permissions/probers/shell.d.ts +19 -0
- package/packages/agent/src/services/permissions/probers/shell.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/shell.js +31 -0
- package/packages/agent/src/services/permissions/probers/website-blocking.d.ts +16 -0
- package/packages/agent/src/services/permissions/probers/website-blocking.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/probers/website-blocking.js +27 -0
- package/packages/agent/src/services/permissions/register-probers.d.ts +29 -0
- package/packages/agent/src/services/permissions/register-probers.d.ts.map +1 -0
- package/packages/agent/src/services/permissions/register-probers.js +31 -0
- package/packages/agent/src/services/permissions-registry.d.ts +62 -0
- package/packages/agent/src/services/permissions-registry.d.ts.map +1 -0
- package/packages/agent/src/services/permissions-registry.js +213 -0
- package/packages/agent/src/services/plugin-compiler.d.ts +51 -0
- package/packages/agent/src/services/plugin-compiler.d.ts.map +1 -0
- package/packages/agent/src/services/plugin-compiler.js +90 -0
- package/packages/agent/src/services/plugin-installer.d.ts +93 -0
- package/packages/agent/src/services/plugin-installer.d.ts.map +1 -0
- package/packages/agent/src/services/plugin-installer.js +623 -0
- package/packages/agent/src/services/plugin-manager-types.d.ts +30 -55
- package/packages/agent/src/services/plugin-manager-types.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-app-meta.d.ts +1 -1
- package/packages/agent/src/services/registry-client-app-meta.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-app-meta.js +53 -32
- package/packages/agent/src/services/registry-client-endpoints.d.ts +2 -2
- package/packages/agent/src/services/registry-client-endpoints.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-endpoints.js +11 -4
- package/packages/agent/src/services/registry-client-local.d.ts +1 -1
- package/packages/agent/src/services/registry-client-local.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-local.js +239 -61
- package/packages/agent/src/services/registry-client-network.d.ts +6 -1
- package/packages/agent/src/services/registry-client-network.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-network.js +43 -5
- package/packages/agent/src/services/registry-client-queries.d.ts +16 -5
- package/packages/agent/src/services/registry-client-queries.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-queries.js +50 -3
- package/packages/agent/src/services/registry-client-types.d.ts +39 -40
- package/packages/agent/src/services/registry-client-types.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client.d.ts +3 -3
- package/packages/agent/src/services/registry-client.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client.js +116 -16
- package/packages/agent/src/services/relationships-graph.d.ts +13 -0
- package/packages/agent/src/services/relationships-graph.d.ts.map +1 -0
- package/packages/agent/src/services/relationships-graph.js +38 -0
- package/packages/agent/src/services/remote-signing-service.d.ts +2 -2
- package/packages/agent/src/services/remote-signing-service.d.ts.map +1 -1
- package/packages/agent/src/services/remote-signing-service.js +2 -2
- package/packages/agent/src/services/research-task-executor.d.ts +14 -0
- package/packages/agent/src/services/research-task-executor.d.ts.map +1 -0
- package/packages/agent/src/services/research-task-executor.js +138 -0
- package/packages/agent/src/services/sandbox-manager.d.ts +24 -1
- package/packages/agent/src/services/sandbox-manager.d.ts.map +1 -1
- package/packages/agent/src/services/sandbox-manager.js +174 -109
- package/packages/agent/src/services/self-updater.d.ts +1 -1
- package/packages/agent/src/services/self-updater.d.ts.map +1 -1
- package/packages/agent/src/services/self-updater.js +1 -1
- package/packages/agent/src/services/send-handler-availability.d.ts +5 -0
- package/packages/agent/src/services/send-handler-availability.d.ts.map +1 -0
- package/packages/agent/src/services/send-handler-availability.js +20 -0
- package/packages/agent/src/services/shell-execution-router.d.ts +67 -0
- package/packages/agent/src/services/shell-execution-router.d.ts.map +1 -0
- package/packages/agent/src/services/shell-execution-router.js +201 -0
- package/packages/agent/src/services/skill-marketplace.d.ts.map +1 -1
- package/packages/agent/src/services/skill-marketplace.js +36 -25
- package/packages/agent/src/services/task-executor.d.ts +47 -0
- package/packages/agent/src/services/task-executor.d.ts.map +1 -0
- package/packages/agent/src/services/task-executor.js +31 -0
- package/packages/agent/src/services/update-checker.d.ts +1 -1
- package/packages/agent/src/services/update-checker.d.ts.map +1 -1
- package/packages/agent/src/services/update-checker.js +4 -4
- package/packages/agent/src/services/version-compat.d.ts +4 -4
- package/packages/agent/src/services/version-compat.d.ts.map +1 -1
- package/packages/agent/src/services/version-compat.js +23 -7
- package/packages/agent/src/services/virtual-filesystem.d.ts +88 -0
- package/packages/agent/src/services/virtual-filesystem.d.ts.map +1 -0
- package/packages/agent/src/services/virtual-filesystem.js +410 -0
- package/packages/agent/src/shared/conversation-format.d.ts +11 -0
- package/packages/agent/src/shared/conversation-format.d.ts.map +1 -0
- package/packages/agent/src/shared/conversation-format.js +69 -0
- package/packages/agent/src/shared/index.d.ts +4 -0
- package/packages/agent/src/shared/index.d.ts.map +1 -0
- package/packages/agent/src/shared/index.js +3 -0
- package/packages/agent/src/shared/ui-catalog-prompt.d.ts +60 -18
- package/packages/agent/src/shared/ui-catalog-prompt.d.ts.map +1 -1
- package/packages/agent/src/shared/ui-catalog-prompt.js +116 -99
- package/packages/agent/src/shared/workspace-resolution.d.ts +5 -0
- package/packages/agent/src/shared/workspace-resolution.d.ts.map +1 -0
- package/packages/agent/src/shared/workspace-resolution.js +70 -0
- package/packages/agent/src/templates/skill-scaffold.d.ts +9 -0
- package/packages/agent/src/templates/skill-scaffold.d.ts.map +1 -0
- package/packages/agent/src/templates/skill-scaffold.js +26 -0
- package/packages/agent/src/test-support/index.d.ts +4 -0
- package/packages/agent/src/test-support/index.d.ts.map +1 -0
- package/packages/agent/src/test-support/index.js +3 -0
- package/packages/agent/src/test-support/route-test-helpers.d.ts +2 -2
- package/packages/agent/src/test-support/route-test-helpers.d.ts.map +1 -1
- package/packages/agent/src/test-support/route-test-helpers.js +1 -1
- package/packages/agent/src/test-support/test-helpers.d.ts +3 -3
- package/packages/agent/src/test-support/test-helpers.d.ts.map +1 -1
- package/packages/agent/src/test-support/test-helpers.js +35 -24
- package/packages/agent/src/test-utils/sqlite-compat.d.ts +23 -0
- package/packages/agent/src/test-utils/sqlite-compat.d.ts.map +1 -0
- package/packages/agent/src/test-utils/sqlite-compat.js +214 -0
- package/packages/agent/src/testing/index.d.ts +3 -3
- package/packages/agent/src/testing/index.d.ts.map +1 -1
- package/packages/agent/src/testing/index.js +3 -3
- package/packages/agent/src/triggers/index.d.ts +5 -0
- package/packages/agent/src/triggers/index.d.ts.map +1 -0
- package/packages/agent/src/triggers/index.js +4 -0
- package/packages/agent/src/triggers/runtime.d.ts +8 -2
- package/packages/agent/src/triggers/runtime.d.ts.map +1 -1
- package/packages/agent/src/triggers/runtime.js +197 -72
- package/packages/agent/src/triggers/scheduling.d.ts +9 -1
- package/packages/agent/src/triggers/scheduling.d.ts.map +1 -1
- package/packages/agent/src/triggers/scheduling.js +103 -22
- package/packages/agent/src/triggers/text-to-workflow.d.ts +58 -0
- package/packages/agent/src/triggers/text-to-workflow.d.ts.map +1 -0
- package/packages/agent/src/triggers/text-to-workflow.js +44 -0
- package/packages/agent/src/triggers/types.d.ts +18 -37
- package/packages/agent/src/triggers/types.d.ts.map +1 -1
- package/packages/agent/src/triggers/types.js +1 -1
- package/packages/agent/src/types/agent-skills.d.ts +19 -0
- package/packages/agent/src/types/agent-skills.d.ts.map +1 -0
- package/packages/agent/src/types/agent-skills.js +7 -0
- package/packages/agent/src/types/config-like.d.ts +17 -0
- package/packages/agent/src/types/config-like.d.ts.map +1 -0
- package/packages/agent/src/types/config-like.js +7 -0
- package/packages/agent/src/types/index.d.ts +4 -0
- package/packages/agent/src/types/index.d.ts.map +1 -0
- package/packages/agent/src/types/index.js +3 -0
- package/packages/agent/src/types/trajectory.d.ts +20 -0
- package/packages/agent/src/types/trajectory.d.ts.map +1 -0
- package/packages/agent/src/types/trajectory.js +2 -0
- package/packages/agent/src/utils/atomic-json.d.ts +37 -0
- package/packages/agent/src/utils/atomic-json.d.ts.map +1 -0
- package/packages/agent/src/utils/atomic-json.js +98 -0
- package/packages/agent/src/utils/index.d.ts +2 -0
- package/packages/agent/src/utils/index.d.ts.map +1 -0
- package/packages/agent/src/utils/index.js +1 -0
- package/packages/agent/src/utils/number-parsing.d.ts.map +1 -1
- package/packages/agent/src/utils/number-parsing.js +1 -2
- package/packages/agent/src/version-resolver.d.ts +0 -1
- package/packages/agent/src/version-resolver.d.ts.map +1 -1
- package/packages/agent/src/version-resolver.js +0 -1
- 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/onboarding.d.ts +0 -384
- package/packages/agent/src/contracts/onboarding.d.ts.map +0 -1
- 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/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/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/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/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/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/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/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/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/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/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/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
|
@@ -8,21 +8,281 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module services/app-manager
|
|
10
10
|
*/
|
|
11
|
+
import crypto from "node:crypto";
|
|
11
12
|
import * as fs from "node:fs";
|
|
12
13
|
import * as path from "node:path";
|
|
13
14
|
import { logger } from "@elizaos/core";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
15
|
+
import { getElizaCuratedAppCatalogOrder, getElizaCuratedAppLookupNames, hasAppInterface, normalizeElizaCuratedAppName, packageNameToAppDisplayName, packageNameToAppRouteSlug, } from "@elizaos/shared";
|
|
16
|
+
import { loadElizaConfig, saveElizaConfig } from "../config/config.js";
|
|
17
|
+
import { shouldRestoreAgentsListAfterAppLaunch } from "./app-manager-agents-list-guard.js";
|
|
18
|
+
import { importAppPlugin, importAppRouteModule, } from "./app-package-modules.js";
|
|
19
|
+
import { readAppRunStore, writeAppRunStore } from "./app-run-store.js";
|
|
20
|
+
import { getPluginInfo, getRegistryPlugins } from "./registry-client.js";
|
|
21
|
+
import { mergeAppMeta as mergeRegistryAppMeta, resolveAppOverride, } from "./registry-client-app-meta.js";
|
|
22
|
+
import { resolveAppHeroImage, scoreEntries, toSearchResults, } from "./registry-client-queries.js";
|
|
16
23
|
const LOCAL_PLUGINS_DIR = "plugins";
|
|
17
24
|
const DEFAULT_VIEWER_SANDBOX = "allow-scripts allow-same-origin allow-popups";
|
|
18
|
-
const
|
|
19
|
-
const
|
|
25
|
+
const DEFAULT_RS_SDK_SERVER_URL = "https://rs-sdk-demo.fly.dev";
|
|
26
|
+
const HYPERSCAPE_APP_ROUTE_SLUG = "hyperscape";
|
|
27
|
+
const LOCAL_DEV_HYPERSCAPE_CLIENT_URL = "http://localhost:3333";
|
|
28
|
+
const PRODUCTION_HYPERSCAPE_CLIENT_URL = "https://hyperscape.gg";
|
|
20
29
|
const SAFE_APP_URL_PROTOCOLS = new Set(["http:", "https:"]);
|
|
21
|
-
const
|
|
22
|
-
// Public display identity only.
|
|
30
|
+
const SAFE_APP_TEMPLATE_ENV_KEYS = new Set([
|
|
23
31
|
"BOT_NAME",
|
|
32
|
+
"HYPERSCAPE_CHARACTER_ID",
|
|
33
|
+
"HYPERSCAPE_CLIENT_URL",
|
|
24
34
|
"RS_SDK_BOT_NAME",
|
|
35
|
+
"RS_SDK_BOT_PASSWORD",
|
|
36
|
+
"RS_SDK_SERVER_URL",
|
|
25
37
|
]);
|
|
38
|
+
const RUN_REFRESH_MIN_INTERVAL_MS = 5_000;
|
|
39
|
+
const MAX_RUN_EVENTS = 20;
|
|
40
|
+
/**
|
|
41
|
+
* How long a run can go without a heartbeat (UI ping or session refresh)
|
|
42
|
+
* before the sweeper considers it abandoned and stops it. Tuned to comfortably
|
|
43
|
+
* tolerate the 3s session-refresh poll + a few missed ticks on a slow tab,
|
|
44
|
+
* while still reaping a closed/crashed browser within ~1.5 minutes.
|
|
45
|
+
*/
|
|
46
|
+
const RUN_HEARTBEAT_TIMEOUT_MS = 90_000;
|
|
47
|
+
/** How often the sweeper wakes to look for stale runs. */
|
|
48
|
+
const RUN_HEARTBEAT_SWEEP_INTERVAL_MS = 30_000;
|
|
49
|
+
const DEFAULT_REGISTRY_REFRESH_TIMEOUT_MS = 5_000;
|
|
50
|
+
function cloneJsonValue(value) {
|
|
51
|
+
return JSON.parse(JSON.stringify(value));
|
|
52
|
+
}
|
|
53
|
+
function readAgentsListSnapshot() {
|
|
54
|
+
const list = loadElizaConfig().agents?.list;
|
|
55
|
+
return Array.isArray(list) ? cloneJsonValue(list) : undefined;
|
|
56
|
+
}
|
|
57
|
+
function restoreAgentsListAfterAppLaunchIfNeeded(before, appName, phase) {
|
|
58
|
+
const config = loadElizaConfig();
|
|
59
|
+
const current = config.agents?.list;
|
|
60
|
+
if (!shouldRestoreAgentsListAfterAppLaunch(before, current)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
config.agents ??= {};
|
|
64
|
+
if (!before) {
|
|
65
|
+
delete config.agents.list;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
config.agents.list = cloneJsonValue(before);
|
|
69
|
+
}
|
|
70
|
+
saveElizaConfig(config);
|
|
71
|
+
logger.warn(`[app-manager] Restored agents.list after ${appName} ${phase}; app launch must not replace the user's active character config.`);
|
|
72
|
+
}
|
|
73
|
+
function isProductionRuntime() {
|
|
74
|
+
return process.env.NODE_ENV === "production";
|
|
75
|
+
}
|
|
76
|
+
function resolveRegistryRefreshTimeoutMs() {
|
|
77
|
+
const raw = process.env.ELIZA_APPS_REGISTRY_REFRESH_TIMEOUT_MS?.trim();
|
|
78
|
+
if (!raw)
|
|
79
|
+
return DEFAULT_REGISTRY_REFRESH_TIMEOUT_MS;
|
|
80
|
+
const parsed = Number.parseInt(raw, 10);
|
|
81
|
+
return Number.isFinite(parsed) && parsed >= 250
|
|
82
|
+
? parsed
|
|
83
|
+
: DEFAULT_REGISTRY_REFRESH_TIMEOUT_MS;
|
|
84
|
+
}
|
|
85
|
+
async function withTimeout(promise, timeoutMs, label) {
|
|
86
|
+
let timeout;
|
|
87
|
+
try {
|
|
88
|
+
return await Promise.race([
|
|
89
|
+
promise,
|
|
90
|
+
new Promise((_, reject) => {
|
|
91
|
+
timeout = setTimeout(() => {
|
|
92
|
+
reject(new Error(`${label} timed out after ${timeoutMs}ms`));
|
|
93
|
+
}, timeoutMs);
|
|
94
|
+
}),
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
if (timeout)
|
|
99
|
+
clearTimeout(timeout);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function isAppRegistryPlugin(plugin) {
|
|
103
|
+
return hasAppInterface(plugin);
|
|
104
|
+
}
|
|
105
|
+
function isHyperscapeAppName(appName) {
|
|
106
|
+
return packageNameToAppRouteSlug(appName) === HYPERSCAPE_APP_ROUTE_SLUG;
|
|
107
|
+
}
|
|
108
|
+
function resolveDisplayViewerInfo(viewer) {
|
|
109
|
+
if (!viewer)
|
|
110
|
+
return viewer;
|
|
111
|
+
const embedParams = viewer.embedParams
|
|
112
|
+
? Object.fromEntries(Object.entries(viewer.embedParams)
|
|
113
|
+
.map(([key, value]) => [key, substituteTemplateVars(value).trim()])
|
|
114
|
+
.filter(([, value]) => value.length > 0))
|
|
115
|
+
: undefined;
|
|
116
|
+
return {
|
|
117
|
+
...viewer,
|
|
118
|
+
url: substituteTemplateVars(viewer.url),
|
|
119
|
+
embedParams,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function flattenAppInfo(appInfo) {
|
|
123
|
+
const meta = appInfo.appMeta;
|
|
124
|
+
if (!meta)
|
|
125
|
+
return appInfo;
|
|
126
|
+
return {
|
|
127
|
+
...appInfo,
|
|
128
|
+
displayName: meta.displayName ?? appInfo.displayName,
|
|
129
|
+
launchType: meta.launchType ?? appInfo.launchType,
|
|
130
|
+
launchUrl: substituteTemplateVars(meta.launchUrl ?? appInfo.launchUrl ?? "") || null,
|
|
131
|
+
icon: meta.icon ?? appInfo.icon,
|
|
132
|
+
heroImage: resolveAppHeroImage(appInfo.name, meta.heroImage ?? null),
|
|
133
|
+
category: meta.category ?? appInfo.category,
|
|
134
|
+
capabilities: meta.capabilities ?? appInfo.capabilities,
|
|
135
|
+
uiExtension: meta.uiExtension ?? appInfo.uiExtension,
|
|
136
|
+
viewer: resolveDisplayViewerInfo(meta.viewer ?? appInfo.viewer),
|
|
137
|
+
session: meta.session ?? appInfo.session,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function cloneRegistryPluginInfo(appInfo) {
|
|
141
|
+
return {
|
|
142
|
+
...appInfo,
|
|
143
|
+
topics: [...appInfo.topics],
|
|
144
|
+
npm: { ...appInfo.npm },
|
|
145
|
+
git: { ...appInfo.git },
|
|
146
|
+
supports: { ...appInfo.supports },
|
|
147
|
+
appMeta: appInfo.appMeta
|
|
148
|
+
? {
|
|
149
|
+
...appInfo.appMeta,
|
|
150
|
+
capabilities: [...appInfo.appMeta.capabilities],
|
|
151
|
+
viewer: appInfo.appMeta.viewer
|
|
152
|
+
? {
|
|
153
|
+
...appInfo.appMeta.viewer,
|
|
154
|
+
embedParams: appInfo.appMeta.viewer.embedParams
|
|
155
|
+
? { ...appInfo.appMeta.viewer.embedParams }
|
|
156
|
+
: undefined,
|
|
157
|
+
}
|
|
158
|
+
: undefined,
|
|
159
|
+
session: appInfo.appMeta.session
|
|
160
|
+
? {
|
|
161
|
+
...appInfo.appMeta.session,
|
|
162
|
+
features: appInfo.appMeta.session.features
|
|
163
|
+
? [...appInfo.appMeta.session.features]
|
|
164
|
+
: undefined,
|
|
165
|
+
}
|
|
166
|
+
: undefined,
|
|
167
|
+
}
|
|
168
|
+
: undefined,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function canonicalizeCuratedRegistryPlugin(appInfo, canonicalName) {
|
|
172
|
+
if (appInfo.name === canonicalName && appInfo.npm.package === canonicalName) {
|
|
173
|
+
return cloneRegistryPluginInfo(appInfo);
|
|
174
|
+
}
|
|
175
|
+
const next = cloneRegistryPluginInfo(appInfo);
|
|
176
|
+
next.name = canonicalName;
|
|
177
|
+
// Only rewrite npm.package if it was derived from the name (no separate
|
|
178
|
+
// runtime plugin). When npm.package differs from name (e.g. Hyperscape:
|
|
179
|
+
// app=@hyperscape/plugin-hyperscape, plugin=@elizaos/plugin-hyperscape),
|
|
180
|
+
// preserve the original so resolvePluginPackageName stays correct.
|
|
181
|
+
if (!next.npm.package || next.npm.package === appInfo.name) {
|
|
182
|
+
next.npm = {
|
|
183
|
+
...next.npm,
|
|
184
|
+
package: canonicalName,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return next;
|
|
188
|
+
}
|
|
189
|
+
function mergeCatalogVariant(target, candidate) {
|
|
190
|
+
mergeLocalRegistryInfo(target, candidate);
|
|
191
|
+
target.stars = Math.max(target.stars, candidate.stars);
|
|
192
|
+
return target;
|
|
193
|
+
}
|
|
194
|
+
function compareCuratedCatalogCandidates(left, right) {
|
|
195
|
+
const orderDiff = getElizaCuratedAppCatalogOrder(left.name) -
|
|
196
|
+
getElizaCuratedAppCatalogOrder(right.name);
|
|
197
|
+
if (orderDiff !== 0) {
|
|
198
|
+
return orderDiff;
|
|
199
|
+
}
|
|
200
|
+
const leftCanonicalName = normalizeElizaCuratedAppName(left.name);
|
|
201
|
+
const rightCanonicalName = normalizeElizaCuratedAppName(right.name);
|
|
202
|
+
const leftCanonicalPenalty = left.name === leftCanonicalName ? 0 : 1;
|
|
203
|
+
const rightCanonicalPenalty = right.name === rightCanonicalName ? 0 : 1;
|
|
204
|
+
if (leftCanonicalPenalty !== rightCanonicalPenalty) {
|
|
205
|
+
return leftCanonicalPenalty - rightCanonicalPenalty;
|
|
206
|
+
}
|
|
207
|
+
const leftLocalPenalty = left.localPath ? 0 : 1;
|
|
208
|
+
const rightLocalPenalty = right.localPath ? 0 : 1;
|
|
209
|
+
if (leftLocalPenalty !== rightLocalPenalty) {
|
|
210
|
+
return leftLocalPenalty - rightLocalPenalty;
|
|
211
|
+
}
|
|
212
|
+
return right.stars - left.stars || left.name.localeCompare(right.name);
|
|
213
|
+
}
|
|
214
|
+
function curateCatalogApps(apps) {
|
|
215
|
+
const curated = new Map();
|
|
216
|
+
const candidates = Array.from(apps).sort(compareCuratedCatalogCandidates);
|
|
217
|
+
for (const app of candidates) {
|
|
218
|
+
const canonicalName = normalizeElizaCuratedAppName(app.name);
|
|
219
|
+
if (!canonicalName) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const normalized = canonicalizeCuratedRegistryPlugin(app, canonicalName);
|
|
223
|
+
const existing = curated.get(canonicalName);
|
|
224
|
+
if (!existing) {
|
|
225
|
+
curated.set(canonicalName, normalized);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
mergeCatalogVariant(existing, normalized);
|
|
229
|
+
}
|
|
230
|
+
return Array.from(curated.values()).sort(compareCuratedCatalogCandidates);
|
|
231
|
+
}
|
|
232
|
+
async function resolveCuratedAppInfo(pluginManager, name) {
|
|
233
|
+
const canonicalName = normalizeElizaCuratedAppName(name);
|
|
234
|
+
if (!canonicalName) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const lookupNames = getElizaCuratedAppLookupNames(name);
|
|
238
|
+
let appInfo = null;
|
|
239
|
+
for (const candidateName of lookupNames) {
|
|
240
|
+
const remote = (await pluginManager.getRegistryPlugin(candidateName));
|
|
241
|
+
if (!remote) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const normalized = canonicalizeCuratedRegistryPlugin(remote, canonicalName);
|
|
245
|
+
if (!appInfo) {
|
|
246
|
+
appInfo = normalized;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
mergeCatalogVariant(appInfo, normalized);
|
|
250
|
+
}
|
|
251
|
+
for (const candidateName of lookupNames) {
|
|
252
|
+
const localPluginInfo = await getPluginInfo(candidateName).catch(() => null);
|
|
253
|
+
if (!localPluginInfo) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const normalized = canonicalizeCuratedRegistryPlugin(localPluginInfo, canonicalName);
|
|
257
|
+
if (!appInfo) {
|
|
258
|
+
appInfo = mergeLocalRegistryInfo(normalized, normalized);
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
mergeCatalogVariant(appInfo, normalized);
|
|
262
|
+
}
|
|
263
|
+
if (!appInfo) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
appInfo.appMeta = resolveEffectiveAppMeta(canonicalName, appInfo);
|
|
267
|
+
return flattenAppInfo(appInfo);
|
|
268
|
+
}
|
|
269
|
+
async function resolveNamedAppInfo(pluginManager, name) {
|
|
270
|
+
let appInfo = (await pluginManager.getRegistryPlugin(name));
|
|
271
|
+
const localPluginInfo = await getPluginInfo(name).catch(() => null);
|
|
272
|
+
if (localPluginInfo) {
|
|
273
|
+
if (!appInfo) {
|
|
274
|
+
appInfo = mergeLocalRegistryInfo(cloneRegistryPluginInfo(localPluginInfo), localPluginInfo);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
mergeLocalRegistryInfo(appInfo, localPluginInfo);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (!appInfo) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
appInfo.appMeta = resolveEffectiveAppMeta(name, appInfo);
|
|
284
|
+
return flattenAppInfo(appInfo);
|
|
285
|
+
}
|
|
26
286
|
function resolvePluginPackageName(appInfo) {
|
|
27
287
|
const npmPackage = appInfo.npm.package.trim();
|
|
28
288
|
return npmPackage && npmPackage.length > 0 ? npmPackage : appInfo.name;
|
|
@@ -37,6 +297,60 @@ function mergeAppMeta(appInfo, meta) {
|
|
|
37
297
|
appInfo.category = meta.category ?? appInfo.category;
|
|
38
298
|
appInfo.capabilities = meta.capabilities ?? appInfo.capabilities;
|
|
39
299
|
appInfo.icon = meta.icon ?? appInfo.icon;
|
|
300
|
+
appInfo.runtimePlugin = meta.runtimePlugin ?? appInfo.runtimePlugin;
|
|
301
|
+
appInfo.session = meta.session ?? appInfo.session;
|
|
302
|
+
}
|
|
303
|
+
function mergeLocalRegistryInfo(appInfo, localInfo) {
|
|
304
|
+
appInfo.localPath = localInfo.localPath ?? appInfo.localPath;
|
|
305
|
+
appInfo.kind = localInfo.kind ?? appInfo.kind;
|
|
306
|
+
appInfo.appMeta = localInfo.appMeta ?? appInfo.appMeta;
|
|
307
|
+
if (!appInfo.description && localInfo.description) {
|
|
308
|
+
appInfo.description = localInfo.description;
|
|
309
|
+
}
|
|
310
|
+
if (!appInfo.homepage && localInfo.homepage) {
|
|
311
|
+
appInfo.homepage = localInfo.homepage;
|
|
312
|
+
}
|
|
313
|
+
mergeAppMeta(appInfo, localInfo.appMeta);
|
|
314
|
+
return appInfo;
|
|
315
|
+
}
|
|
316
|
+
function deriveAppMetaFromPluginInfo(appInfo) {
|
|
317
|
+
const hasTopLevelAppMeta = appInfo.displayName !== undefined ||
|
|
318
|
+
appInfo.category !== undefined ||
|
|
319
|
+
appInfo.launchType !== undefined ||
|
|
320
|
+
appInfo.launchUrl !== undefined ||
|
|
321
|
+
appInfo.icon !== undefined ||
|
|
322
|
+
appInfo.heroImage !== undefined ||
|
|
323
|
+
appInfo.capabilities !== undefined ||
|
|
324
|
+
appInfo.runtimePlugin !== undefined ||
|
|
325
|
+
appInfo.uiExtension !== undefined ||
|
|
326
|
+
appInfo.viewer !== undefined ||
|
|
327
|
+
appInfo.session !== undefined;
|
|
328
|
+
if (!hasTopLevelAppMeta) {
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
displayName: appInfo.displayName ?? packageNameToAppDisplayName(appInfo.name),
|
|
333
|
+
category: appInfo.category ?? "game",
|
|
334
|
+
launchType: appInfo.launchType ?? "url",
|
|
335
|
+
launchUrl: appInfo.launchUrl ?? null,
|
|
336
|
+
icon: appInfo.icon ?? null,
|
|
337
|
+
heroImage: appInfo.heroImage ?? null,
|
|
338
|
+
capabilities: appInfo.capabilities ?? [],
|
|
339
|
+
minPlayers: null,
|
|
340
|
+
maxPlayers: null,
|
|
341
|
+
runtimePlugin: appInfo.runtimePlugin,
|
|
342
|
+
uiExtension: appInfo.uiExtension,
|
|
343
|
+
viewer: appInfo.viewer,
|
|
344
|
+
session: appInfo.session,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function resolveEffectiveAppMeta(packageName, appInfo) {
|
|
348
|
+
const derivedAppMeta = deriveAppMetaFromPluginInfo(appInfo);
|
|
349
|
+
const baseAppMeta = mergeRegistryAppMeta(derivedAppMeta, appInfo.appMeta);
|
|
350
|
+
if (baseAppMeta) {
|
|
351
|
+
return resolveAppOverride(packageName, baseAppMeta) ?? baseAppMeta;
|
|
352
|
+
}
|
|
353
|
+
return resolveAppOverride(packageName, undefined);
|
|
40
354
|
}
|
|
41
355
|
function isAutoInstallable(appInfo) {
|
|
42
356
|
const supportsRuntime = appInfo.supports.v0 || appInfo.supports.v1 || appInfo.supports.v2;
|
|
@@ -71,37 +385,107 @@ function getTemplateFallbackValue(key) {
|
|
|
71
385
|
if (runtimeBotName && runtimeBotName.length > 0) {
|
|
72
386
|
return runtimeBotName;
|
|
73
387
|
}
|
|
74
|
-
return
|
|
388
|
+
return undefined;
|
|
389
|
+
}
|
|
390
|
+
if (key === "RS_SDK_BOT_PASSWORD") {
|
|
391
|
+
const runtimeBotPassword = process.env.BOT_PASSWORD?.trim();
|
|
392
|
+
if (runtimeBotPassword && runtimeBotPassword.length > 0) {
|
|
393
|
+
return runtimeBotPassword;
|
|
394
|
+
}
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
397
|
+
if (key === "RS_SDK_SERVER_URL") {
|
|
398
|
+
return DEFAULT_RS_SDK_SERVER_URL;
|
|
399
|
+
}
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
function resolveSettingLike(runtime, key) {
|
|
403
|
+
const fromRuntime = runtime?.getSetting?.(key);
|
|
404
|
+
if (typeof fromRuntime === "string" && fromRuntime.trim().length > 0) {
|
|
405
|
+
return fromRuntime.trim();
|
|
406
|
+
}
|
|
407
|
+
const fromEnv = process.env[key];
|
|
408
|
+
if (typeof fromEnv === "string" && fromEnv.trim().length > 0) {
|
|
409
|
+
return fromEnv.trim();
|
|
75
410
|
}
|
|
76
411
|
return undefined;
|
|
77
412
|
}
|
|
78
|
-
function
|
|
413
|
+
function readSafeTemplateEnv(key) {
|
|
414
|
+
if (!SAFE_APP_TEMPLATE_ENV_KEYS.has(key)) {
|
|
415
|
+
return undefined;
|
|
416
|
+
}
|
|
417
|
+
const value = process.env[key];
|
|
418
|
+
return typeof value === "string" && value.trim().length > 0
|
|
419
|
+
? value.trim()
|
|
420
|
+
: undefined;
|
|
421
|
+
}
|
|
422
|
+
function substituteTemplateVars(raw, options) {
|
|
423
|
+
const preserveUnknown = options?.preserveUnknown ?? true;
|
|
424
|
+
const hyperscapeClientDefault = options?.hyperscapeClientDefault === true;
|
|
79
425
|
return raw.replace(/\{([A-Z0-9_]+)\}/g, (_full, key) => {
|
|
80
|
-
|
|
81
|
-
|
|
426
|
+
const value = (SAFE_APP_TEMPLATE_ENV_KEYS.has(key)
|
|
427
|
+
? resolveSettingLike(options?.runtime, key)
|
|
428
|
+
: undefined) ??
|
|
429
|
+
readSafeTemplateEnv(key) ??
|
|
430
|
+
(hyperscapeClientDefault && key === "HYPERSCAPE_CLIENT_URL"
|
|
431
|
+
? isProductionRuntime()
|
|
432
|
+
? PRODUCTION_HYPERSCAPE_CLIENT_URL
|
|
433
|
+
: LOCAL_DEV_HYPERSCAPE_CLIENT_URL
|
|
434
|
+
: undefined) ??
|
|
435
|
+
getTemplateFallbackValue(key);
|
|
436
|
+
if (value !== undefined) {
|
|
437
|
+
return value;
|
|
82
438
|
}
|
|
83
|
-
|
|
84
|
-
if (value && value.trim().length > 0) {
|
|
85
|
-
return value.trim();
|
|
86
|
-
}
|
|
87
|
-
return getTemplateFallbackValue(key) ?? "";
|
|
439
|
+
return preserveUnknown ? `{${key}}` : "";
|
|
88
440
|
});
|
|
89
441
|
}
|
|
90
|
-
function buildViewerUrl(baseUrl, embedParams) {
|
|
442
|
+
function buildViewerUrl(baseUrl, embedParams, runtime) {
|
|
91
443
|
if (!embedParams || Object.keys(embedParams).length === 0) {
|
|
92
|
-
return substituteTemplateVars(baseUrl
|
|
444
|
+
return substituteTemplateVars(baseUrl, {
|
|
445
|
+
preserveUnknown: false,
|
|
446
|
+
hyperscapeClientDefault: true,
|
|
447
|
+
runtime,
|
|
448
|
+
});
|
|
93
449
|
}
|
|
94
|
-
const resolvedBaseUrl = substituteTemplateVars(baseUrl
|
|
450
|
+
const resolvedBaseUrl = substituteTemplateVars(baseUrl, {
|
|
451
|
+
preserveUnknown: false,
|
|
452
|
+
hyperscapeClientDefault: true,
|
|
453
|
+
runtime,
|
|
454
|
+
});
|
|
95
455
|
const [beforeHash, hashPartRaw] = resolvedBaseUrl.split("#", 2);
|
|
96
456
|
const [pathPart, queryPartRaw] = beforeHash.split("?", 2);
|
|
97
457
|
const queryParams = new URLSearchParams(queryPartRaw ?? "");
|
|
98
458
|
for (const [key, rawValue] of Object.entries(embedParams)) {
|
|
99
|
-
|
|
459
|
+
const nextValue = substituteTemplateVars(rawValue, {
|
|
460
|
+
preserveUnknown: false,
|
|
461
|
+
hyperscapeClientDefault: true,
|
|
462
|
+
runtime,
|
|
463
|
+
}).trim();
|
|
464
|
+
if (!nextValue) {
|
|
465
|
+
queryParams.delete(key);
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
queryParams.set(key, nextValue);
|
|
100
469
|
}
|
|
101
470
|
const query = queryParams.toString();
|
|
102
471
|
const hash = hashPartRaw ? `#${hashPartRaw}` : "";
|
|
103
472
|
return `${pathPart}${query.length > 0 ? `?${query}` : ""}${hash}`;
|
|
104
473
|
}
|
|
474
|
+
function resolveViewerEmbedParams(embedParams, runtime) {
|
|
475
|
+
if (!embedParams)
|
|
476
|
+
return undefined;
|
|
477
|
+
const resolved = Object.fromEntries(Object.entries(embedParams)
|
|
478
|
+
.map(([key, value]) => [
|
|
479
|
+
key,
|
|
480
|
+
substituteTemplateVars(value, {
|
|
481
|
+
preserveUnknown: false,
|
|
482
|
+
hyperscapeClientDefault: true,
|
|
483
|
+
runtime,
|
|
484
|
+
}).trim(),
|
|
485
|
+
])
|
|
486
|
+
.filter(([, value]) => value.length > 0));
|
|
487
|
+
return Object.keys(resolved).length > 0 ? resolved : undefined;
|
|
488
|
+
}
|
|
105
489
|
function normalizeSafeAppUrl(url) {
|
|
106
490
|
const trimmed = url.trim();
|
|
107
491
|
if (!trimmed)
|
|
@@ -121,43 +505,46 @@ function normalizeSafeAppUrl(url) {
|
|
|
121
505
|
return null;
|
|
122
506
|
}
|
|
123
507
|
}
|
|
124
|
-
function buildViewerAuthMessage(
|
|
508
|
+
async function buildViewerAuthMessage(appInfo, launchUrl, runtime) {
|
|
509
|
+
const postMessageAuth = appInfo.viewer?.postMessageAuth;
|
|
125
510
|
if (!postMessageAuth)
|
|
126
511
|
return undefined;
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
process.env.BOT_PASSWORD?.trim() ||
|
|
136
|
-
"";
|
|
137
|
-
return {
|
|
138
|
-
type: RS_2004SCAPE_AUTH_MESSAGE_TYPE,
|
|
139
|
-
authToken: username, // Using authToken field for username
|
|
140
|
-
sessionToken: password, // Using sessionToken field for password
|
|
141
|
-
};
|
|
512
|
+
const routeModule = await importAppRouteModule(appInfo.name);
|
|
513
|
+
if (typeof routeModule?.resolveViewerAuthMessage === "function") {
|
|
514
|
+
return ((await routeModule.resolveViewerAuthMessage({
|
|
515
|
+
appName: appInfo.name,
|
|
516
|
+
launchUrl,
|
|
517
|
+
runtime: runtime ?? null,
|
|
518
|
+
viewer: null,
|
|
519
|
+
})) ?? undefined);
|
|
142
520
|
}
|
|
143
521
|
return undefined;
|
|
144
522
|
}
|
|
145
|
-
function buildViewerConfig(appInfo, launchUrl) {
|
|
523
|
+
async function buildViewerConfig(appInfo, launchUrl, runtime) {
|
|
146
524
|
const viewerInfo = appInfo.viewer;
|
|
147
525
|
if (viewerInfo) {
|
|
148
526
|
const requestedPostMessageAuth = Boolean(viewerInfo.postMessageAuth);
|
|
149
|
-
const authMessage = buildViewerAuthMessage(appInfo
|
|
527
|
+
const authMessage = await buildViewerAuthMessage(appInfo, launchUrl, runtime);
|
|
150
528
|
const postMessageAuth = requestedPostMessageAuth && Boolean(authMessage);
|
|
151
529
|
if (requestedPostMessageAuth && !authMessage) {
|
|
152
530
|
logger.warn(`[app-manager] ${appInfo.name} requires postMessage auth but no auth payload was generated.`);
|
|
153
531
|
}
|
|
154
|
-
const
|
|
532
|
+
const resolvedEmbedParams = {
|
|
533
|
+
...(resolveViewerEmbedParams(viewerInfo.embedParams, runtime) ?? {}),
|
|
534
|
+
};
|
|
535
|
+
if (authMessage?.followEntity && !resolvedEmbedParams.followEntity) {
|
|
536
|
+
resolvedEmbedParams.followEntity = authMessage.followEntity;
|
|
537
|
+
}
|
|
538
|
+
const finalEmbedParams = Object.keys(resolvedEmbedParams).length > 0
|
|
539
|
+
? resolvedEmbedParams
|
|
540
|
+
: undefined;
|
|
541
|
+
const viewerUrl = normalizeSafeAppUrl(buildViewerUrl(viewerInfo.url, finalEmbedParams, runtime));
|
|
155
542
|
if (!viewerUrl) {
|
|
156
543
|
throw new Error(`Refusing to launch app "${appInfo.name}": unsafe viewer URL`);
|
|
157
544
|
}
|
|
158
545
|
return {
|
|
159
546
|
url: viewerUrl,
|
|
160
|
-
embedParams:
|
|
547
|
+
embedParams: finalEmbedParams,
|
|
161
548
|
postMessageAuth,
|
|
162
549
|
sandbox: viewerInfo.sandbox ?? DEFAULT_VIEWER_SANDBOX,
|
|
163
550
|
authMessage,
|
|
@@ -176,91 +563,831 @@ function buildViewerConfig(appInfo, launchUrl) {
|
|
|
176
563
|
}
|
|
177
564
|
return null;
|
|
178
565
|
}
|
|
566
|
+
function buildAppSession(appInfo, authMessage, runtime) {
|
|
567
|
+
if (!appInfo.session)
|
|
568
|
+
return null;
|
|
569
|
+
const runtimeAgentId = typeof runtime?.agentId === "string" && runtime.agentId.trim().length > 0
|
|
570
|
+
? runtime.agentId
|
|
571
|
+
: undefined;
|
|
572
|
+
const sessionId = authMessage?.agentId || authMessage?.characterId || runtimeAgentId;
|
|
573
|
+
if (!sessionId)
|
|
574
|
+
return null;
|
|
575
|
+
const features = new Set(appInfo.session.features ?? []);
|
|
576
|
+
const controls = [];
|
|
577
|
+
if (features.has("pause")) {
|
|
578
|
+
controls.push("pause");
|
|
579
|
+
}
|
|
580
|
+
if (features.has("resume")) {
|
|
581
|
+
controls.push("resume");
|
|
582
|
+
}
|
|
583
|
+
const canSendCommands = features.has("commands") || features.has("suggestions");
|
|
584
|
+
const characterId = authMessage?.characterId ??
|
|
585
|
+
(isHyperscapeAppName(appInfo.name)
|
|
586
|
+
? resolveSettingLike(runtime, "HYPERSCAPE_CHARACTER_ID")
|
|
587
|
+
: undefined);
|
|
588
|
+
const followEntity = authMessage?.followEntity ?? characterId ?? undefined;
|
|
589
|
+
return {
|
|
590
|
+
sessionId,
|
|
591
|
+
appName: appInfo.name,
|
|
592
|
+
mode: appInfo.session.mode,
|
|
593
|
+
status: "connecting",
|
|
594
|
+
displayName: appInfo.displayName ?? appInfo.name,
|
|
595
|
+
agentId: authMessage?.agentId ?? runtimeAgentId,
|
|
596
|
+
characterId,
|
|
597
|
+
followEntity,
|
|
598
|
+
canSendCommands,
|
|
599
|
+
controls,
|
|
600
|
+
summary: "Connecting session...",
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function buildUnavailableSession(run, status, summary) {
|
|
604
|
+
if (!run.session)
|
|
605
|
+
return null;
|
|
606
|
+
return {
|
|
607
|
+
...run.session,
|
|
608
|
+
status,
|
|
609
|
+
canSendCommands: false,
|
|
610
|
+
controls: [],
|
|
611
|
+
goalLabel: null,
|
|
612
|
+
suggestedPrompts: [],
|
|
613
|
+
telemetry: null,
|
|
614
|
+
summary,
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
async function resolveLaunchSession(appInfo, viewer, launchUrl, runtime) {
|
|
618
|
+
const routeModule = await importAppRouteModule(appInfo.name);
|
|
619
|
+
if (typeof routeModule?.resolveLaunchSession === "function") {
|
|
620
|
+
return routeModule.resolveLaunchSession({
|
|
621
|
+
appName: appInfo.name,
|
|
622
|
+
launchUrl,
|
|
623
|
+
runtime,
|
|
624
|
+
viewer,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
return buildAppSession(appInfo, viewer?.authMessage, runtime);
|
|
628
|
+
}
|
|
179
629
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
630
|
+
* Invoke the plugin's `stopRun` bridge hook (if defined) when an app run is
|
|
631
|
+
* removed. Plugins use this to tear down per-run resources (WebSocket
|
|
632
|
+
* connections, game-loop timers, bot sessions, embedded servers).
|
|
633
|
+
*
|
|
634
|
+
* Errors are logged but never re-thrown — removal from the app-manager
|
|
635
|
+
* registry is authoritative.
|
|
182
636
|
*/
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
637
|
+
async function invokeAppStopRunHook(run, runtime) {
|
|
638
|
+
try {
|
|
639
|
+
const routeModule = await importAppRouteModule(run.appName);
|
|
640
|
+
if (typeof routeModule?.stopRun !== "function") {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
await routeModule.stopRun({
|
|
644
|
+
appName: run.appName,
|
|
645
|
+
launchUrl: run.launchUrl,
|
|
646
|
+
runtime,
|
|
647
|
+
viewer: run.viewer,
|
|
648
|
+
runId: run.runId,
|
|
649
|
+
session: run.session,
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
catch (err) {
|
|
653
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
654
|
+
logger.warn(`[app-manager] stopRun hook for "${run.appName}" (runId=${run.runId}) failed: ${message}`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
async function prepareLaunch(appInfo, launchUrl, runtime) {
|
|
658
|
+
const routeModule = await importAppRouteModule(appInfo.name);
|
|
659
|
+
if (typeof routeModule?.prepareLaunch === "function") {
|
|
660
|
+
return ((await routeModule.prepareLaunch({
|
|
661
|
+
appName: appInfo.name,
|
|
662
|
+
launchUrl,
|
|
663
|
+
runtime,
|
|
664
|
+
viewer: null,
|
|
665
|
+
})) ?? {});
|
|
666
|
+
}
|
|
667
|
+
return {};
|
|
668
|
+
}
|
|
669
|
+
function mergePreparedViewer(base, override) {
|
|
670
|
+
return {
|
|
671
|
+
...(base ?? {}),
|
|
672
|
+
...override,
|
|
673
|
+
embedParams: {
|
|
674
|
+
...(base?.embedParams ?? {}),
|
|
675
|
+
...(override.embedParams ?? {}),
|
|
676
|
+
},
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function applyLaunchPreparation(appInfo, preparation) {
|
|
680
|
+
const launchUrl = preparation.launchUrl !== undefined
|
|
681
|
+
? (preparation.launchUrl ?? undefined)
|
|
682
|
+
: appInfo.launchUrl;
|
|
683
|
+
const viewer = preparation.viewer === undefined
|
|
684
|
+
? appInfo.viewer
|
|
685
|
+
: preparation.viewer === null
|
|
686
|
+
? undefined
|
|
687
|
+
: mergePreparedViewer(appInfo.viewer, preparation.viewer);
|
|
688
|
+
return {
|
|
689
|
+
...appInfo,
|
|
690
|
+
launchUrl,
|
|
691
|
+
viewer,
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function isRuntimePluginActive(appInfo, runtime) {
|
|
695
|
+
if (!runtime || !Array.isArray(runtime.plugins)) {
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
const pluginNames = new Set([
|
|
699
|
+
appInfo.name,
|
|
700
|
+
appInfo.runtimePlugin ?? resolvePluginPackageName(appInfo),
|
|
701
|
+
]);
|
|
702
|
+
return runtime.plugins.some((plugin) => typeof plugin?.name === "string" && pluginNames.has(plugin.name));
|
|
703
|
+
}
|
|
704
|
+
function isRuntimePluginReady(appInfo, runtime) {
|
|
705
|
+
if (!isRuntimePluginActive(appInfo, runtime)) {
|
|
706
|
+
return false;
|
|
707
|
+
}
|
|
708
|
+
if (isHyperscapeAppName(appInfo.name)) {
|
|
709
|
+
return Boolean(runtime?.hasService?.("hyperscapeService") ||
|
|
710
|
+
runtime?.getService?.("hyperscapeService"));
|
|
711
|
+
}
|
|
712
|
+
return true;
|
|
713
|
+
}
|
|
714
|
+
function getRuntimePluginCandidates(appInfo) {
|
|
715
|
+
const candidates = [
|
|
716
|
+
appInfo.runtimePlugin,
|
|
717
|
+
appInfo.name,
|
|
718
|
+
resolvePluginPackageName(appInfo),
|
|
719
|
+
];
|
|
720
|
+
return Array.from(new Set(candidates.filter((candidate) => typeof candidate === "string" && candidate.trim().length > 0)));
|
|
721
|
+
}
|
|
722
|
+
async function collectLaunchDiagnostics(appInfo, viewer, session, launchUrl, runtime) {
|
|
723
|
+
const routeModule = await importAppRouteModule(appInfo.name);
|
|
724
|
+
const diagnosticViewer = viewer && appInfo.viewer?.postMessageAuth && !viewer.authMessage
|
|
725
|
+
? { ...viewer, postMessageAuth: true }
|
|
726
|
+
: viewer;
|
|
727
|
+
if (typeof routeModule?.collectLaunchDiagnostics === "function") {
|
|
728
|
+
return routeModule.collectLaunchDiagnostics({
|
|
729
|
+
appName: appInfo.name,
|
|
730
|
+
launchUrl,
|
|
731
|
+
runtime,
|
|
732
|
+
viewer: diagnosticViewer,
|
|
733
|
+
session,
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
return [];
|
|
737
|
+
}
|
|
738
|
+
async function ensureRuntimePluginRegistered(appInfo, runtime, isLocal) {
|
|
739
|
+
if (!runtime) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
if (isRuntimePluginReady(appInfo, runtime)) {
|
|
743
|
+
return true;
|
|
744
|
+
}
|
|
745
|
+
const pluginNames = getRuntimePluginCandidates(appInfo);
|
|
746
|
+
for (const pluginPackageName of pluginNames) {
|
|
747
|
+
let plugin = null;
|
|
191
748
|
try {
|
|
192
|
-
|
|
749
|
+
plugin = await importAppPlugin(pluginPackageName);
|
|
193
750
|
}
|
|
194
|
-
catch (
|
|
195
|
-
logger.warn(`[app-manager]
|
|
751
|
+
catch (err) {
|
|
752
|
+
logger.warn(`[app-manager] importAppPlugin(${pluginPackageName}) threw: ${err instanceof Error ? err.message : String(err)}`);
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
if (!plugin) {
|
|
756
|
+
continue;
|
|
196
757
|
}
|
|
197
|
-
}
|
|
198
|
-
const solKey = runtime?.getSetting?.("SOLANA_PRIVATE_KEY")?.trim() || process.env.SOLANA_PRIVATE_KEY?.trim();
|
|
199
|
-
if (solKey && !PLACEHOLDER_RE.test(solKey)) {
|
|
200
758
|
try {
|
|
201
|
-
|
|
759
|
+
await runtime.registerPlugin(plugin);
|
|
202
760
|
}
|
|
203
|
-
catch (
|
|
204
|
-
logger.warn(`[app-manager]
|
|
761
|
+
catch (err) {
|
|
762
|
+
logger.warn(`[app-manager] registerPlugin(${plugin.name}) threw: ${err instanceof Error ? err.message : String(err)}`);
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
if (isRuntimePluginReady(appInfo, runtime)) {
|
|
766
|
+
return true;
|
|
205
767
|
}
|
|
206
768
|
}
|
|
207
|
-
|
|
769
|
+
if (!isLocal) {
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
throw new Error(`Local runtime plugin for "${appInfo.name}" could not be loaded.`);
|
|
773
|
+
}
|
|
774
|
+
async function ensureRuntimeReady(appInfo, viewer, launchUrl, runtime) {
|
|
775
|
+
if (!runtime) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const routeModule = await importAppRouteModule(appInfo.name);
|
|
779
|
+
if (typeof routeModule?.ensureRuntimeReady !== "function") {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
const ctx = {
|
|
783
|
+
appName: appInfo.name,
|
|
784
|
+
launchUrl,
|
|
785
|
+
runtime,
|
|
786
|
+
viewer,
|
|
787
|
+
};
|
|
788
|
+
try {
|
|
789
|
+
await routeModule.ensureRuntimeReady(ctx);
|
|
790
|
+
}
|
|
791
|
+
catch (error) {
|
|
792
|
+
const pluginNames = getRuntimePluginCandidates(appInfo);
|
|
793
|
+
let recovered = false;
|
|
794
|
+
for (const pluginPackageName of pluginNames) {
|
|
795
|
+
const plugin = await importAppPlugin(pluginPackageName);
|
|
796
|
+
if (!plugin) {
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
799
|
+
await runtime.registerPlugin(plugin);
|
|
800
|
+
recovered = true;
|
|
801
|
+
}
|
|
802
|
+
if (!recovered) {
|
|
803
|
+
throw error;
|
|
804
|
+
}
|
|
805
|
+
await routeModule.ensureRuntimeReady(ctx);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function deriveRunHealth(status, summary) {
|
|
809
|
+
const normalized = status.trim().toLowerCase();
|
|
810
|
+
if (normalized === "running" ||
|
|
811
|
+
normalized === "connected" ||
|
|
812
|
+
normalized === "active") {
|
|
813
|
+
return {
|
|
814
|
+
state: "healthy",
|
|
815
|
+
message: summary,
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
if (normalized === "stopped" ||
|
|
819
|
+
normalized === "offline" ||
|
|
820
|
+
normalized === "error" ||
|
|
821
|
+
normalized === "failed") {
|
|
822
|
+
return {
|
|
823
|
+
state: "offline",
|
|
824
|
+
message: summary,
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
state: "degraded",
|
|
829
|
+
message: summary,
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
function buildRunEvent(input) {
|
|
833
|
+
return {
|
|
834
|
+
eventId: crypto.randomUUID(),
|
|
835
|
+
kind: input.kind,
|
|
836
|
+
severity: input.severity ?? "info",
|
|
837
|
+
message: input.message,
|
|
838
|
+
createdAt: input.createdAt ?? new Date().toISOString(),
|
|
839
|
+
status: input.status ?? null,
|
|
840
|
+
details: input.details ?? null,
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function normalizeRunEvents(events) {
|
|
844
|
+
return [...events]
|
|
845
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
|
846
|
+
.slice(0, MAX_RUN_EVENTS);
|
|
847
|
+
}
|
|
848
|
+
function deriveChatAvailability(session) {
|
|
849
|
+
if (!session) {
|
|
850
|
+
return "unknown";
|
|
851
|
+
}
|
|
852
|
+
return session.canSendCommands ? "available" : "unavailable";
|
|
853
|
+
}
|
|
854
|
+
function deriveControlAvailability(session) {
|
|
855
|
+
if (!session) {
|
|
856
|
+
return "unknown";
|
|
857
|
+
}
|
|
858
|
+
return session.canSendCommands || (session.controls?.length ?? 0) > 0
|
|
859
|
+
? "available"
|
|
860
|
+
: "unavailable";
|
|
861
|
+
}
|
|
862
|
+
function deriveHealthFacetState(availability) {
|
|
863
|
+
if (availability === "available") {
|
|
864
|
+
return "healthy";
|
|
865
|
+
}
|
|
866
|
+
if (availability === "unavailable") {
|
|
867
|
+
return "degraded";
|
|
868
|
+
}
|
|
869
|
+
return "unknown";
|
|
870
|
+
}
|
|
871
|
+
function deriveRunHealthDetails(run) {
|
|
872
|
+
const viewerState = !run.viewer
|
|
873
|
+
? "unknown"
|
|
874
|
+
: run.viewerAttachment === "attached"
|
|
875
|
+
? "healthy"
|
|
876
|
+
: run.viewerAttachment === "detached"
|
|
877
|
+
? "degraded"
|
|
878
|
+
: "offline";
|
|
879
|
+
const authState = run.session
|
|
880
|
+
? run.viewerAttachment === "attached" || run.viewer == null
|
|
881
|
+
? "healthy"
|
|
882
|
+
: "degraded"
|
|
883
|
+
: "unknown";
|
|
884
|
+
return {
|
|
885
|
+
checkedAt: run.updatedAt,
|
|
886
|
+
auth: {
|
|
887
|
+
state: authState,
|
|
888
|
+
message: run.session?.summary ?? run.summary,
|
|
889
|
+
},
|
|
890
|
+
runtime: {
|
|
891
|
+
state: run.health.state,
|
|
892
|
+
message: run.health.message,
|
|
893
|
+
},
|
|
894
|
+
viewer: {
|
|
895
|
+
state: viewerState,
|
|
896
|
+
message: run.viewerAttachment === "attached"
|
|
897
|
+
? "Viewer attached."
|
|
898
|
+
: run.viewerAttachment === "detached"
|
|
899
|
+
? "Viewer detached."
|
|
900
|
+
: "Viewer unavailable.",
|
|
901
|
+
},
|
|
902
|
+
chat: {
|
|
903
|
+
state: deriveHealthFacetState(run.chatAvailability),
|
|
904
|
+
message: run.chatAvailability === "available"
|
|
905
|
+
? "Operator chat is available."
|
|
906
|
+
: run.chatAvailability === "unavailable"
|
|
907
|
+
? "Operator chat is unavailable."
|
|
908
|
+
: "Operator chat availability is unknown.",
|
|
909
|
+
},
|
|
910
|
+
control: {
|
|
911
|
+
state: deriveHealthFacetState(run.controlAvailability),
|
|
912
|
+
message: run.controlAvailability === "available"
|
|
913
|
+
? "Control actions are available."
|
|
914
|
+
: run.controlAvailability === "unavailable"
|
|
915
|
+
? "Control actions are unavailable."
|
|
916
|
+
: "Control availability is unknown.",
|
|
917
|
+
},
|
|
918
|
+
message: run.health.message,
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
function deriveAwaySummary(run) {
|
|
922
|
+
const recent = run.recentEvents.slice(0, 3).map((event) => event.message);
|
|
923
|
+
return {
|
|
924
|
+
generatedAt: run.updatedAt,
|
|
925
|
+
message: recent.length > 0
|
|
926
|
+
? recent.join(" ")
|
|
927
|
+
: (run.summary ?? `${run.displayName} is ${run.status}.`),
|
|
928
|
+
eventCount: run.recentEvents.length,
|
|
929
|
+
since: run.recentEvents.at(-1)?.createdAt ?? run.startedAt,
|
|
930
|
+
until: run.recentEvents[0]?.createdAt ?? run.updatedAt,
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
function normalizeRunSummary(run) {
|
|
934
|
+
const status = run.session?.status ?? run.status;
|
|
935
|
+
const summary = run.session?.summary ?? run.summary;
|
|
936
|
+
const next = {
|
|
937
|
+
...run,
|
|
938
|
+
characterId: run.characterId ?? run.session?.characterId ?? null,
|
|
939
|
+
agentId: run.agentId ?? run.session?.agentId ?? null,
|
|
940
|
+
chatAvailability: deriveChatAvailability(run.session),
|
|
941
|
+
controlAvailability: deriveControlAvailability(run.session),
|
|
942
|
+
supportsViewerDetach: typeof run.supportsViewerDetach === "boolean"
|
|
943
|
+
? run.supportsViewerDetach
|
|
944
|
+
: Boolean(run.supportsBackground),
|
|
945
|
+
recentEvents: normalizeRunEvents(run.recentEvents),
|
|
946
|
+
status,
|
|
947
|
+
summary,
|
|
948
|
+
lastHeartbeatAt: run.session ? run.updatedAt : run.lastHeartbeatAt,
|
|
949
|
+
health: deriveRunHealth(status, summary),
|
|
950
|
+
};
|
|
951
|
+
return {
|
|
952
|
+
...next,
|
|
953
|
+
awaySummary: deriveAwaySummary(next),
|
|
954
|
+
healthDetails: deriveRunHealthDetails(next),
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function buildRunSummary(input) {
|
|
958
|
+
const now = new Date().toISOString();
|
|
959
|
+
const status = input.session?.status ?? (input.viewer ? "running" : "launching");
|
|
960
|
+
const summary = input.session?.summary ?? null;
|
|
961
|
+
const health = deriveRunHealth(status, summary);
|
|
962
|
+
return normalizeRunSummary({
|
|
963
|
+
runId: input.runId,
|
|
964
|
+
appName: input.appName,
|
|
965
|
+
displayName: input.displayName,
|
|
966
|
+
pluginName: input.pluginName,
|
|
967
|
+
launchType: input.launchType,
|
|
968
|
+
launchUrl: input.launchUrl,
|
|
969
|
+
viewer: input.viewer,
|
|
970
|
+
session: input.session,
|
|
971
|
+
characterId: input.session?.characterId ?? null,
|
|
972
|
+
agentId: input.session?.agentId ?? null,
|
|
973
|
+
status,
|
|
974
|
+
summary,
|
|
975
|
+
startedAt: input.startedAt ?? now,
|
|
976
|
+
updatedAt: now,
|
|
977
|
+
lastHeartbeatAt: input.session ? now : null,
|
|
978
|
+
supportsBackground: true,
|
|
979
|
+
viewerAttachment: input.viewerAttachment ?? (input.viewer ? "attached" : "unavailable"),
|
|
980
|
+
chatAvailability: deriveChatAvailability(input.session),
|
|
981
|
+
controlAvailability: deriveControlAvailability(input.session),
|
|
982
|
+
supportsViewerDetach: true,
|
|
983
|
+
recentEvents: [
|
|
984
|
+
buildRunEvent({
|
|
985
|
+
kind: "launch",
|
|
986
|
+
message: summary ??
|
|
987
|
+
`${input.displayName} launched with ${input.viewer ? "a viewer" : "no viewer"}.`,
|
|
988
|
+
status,
|
|
989
|
+
details: {
|
|
990
|
+
runId: input.runId,
|
|
991
|
+
appName: input.appName,
|
|
992
|
+
viewerAttachment: input.viewerAttachment ??
|
|
993
|
+
(input.viewer ? "attached" : "unavailable"),
|
|
994
|
+
characterId: input.session?.characterId ?? null,
|
|
995
|
+
agentId: input.session?.agentId ?? null,
|
|
996
|
+
},
|
|
997
|
+
}),
|
|
998
|
+
],
|
|
999
|
+
awaySummary: null,
|
|
1000
|
+
health,
|
|
1001
|
+
healthDetails: {
|
|
1002
|
+
checkedAt: now,
|
|
1003
|
+
auth: {
|
|
1004
|
+
state: "unknown",
|
|
1005
|
+
message: summary,
|
|
1006
|
+
},
|
|
1007
|
+
runtime: {
|
|
1008
|
+
state: health.state,
|
|
1009
|
+
message: summary,
|
|
1010
|
+
},
|
|
1011
|
+
viewer: {
|
|
1012
|
+
state: "unknown",
|
|
1013
|
+
message: null,
|
|
1014
|
+
},
|
|
1015
|
+
chat: {
|
|
1016
|
+
state: "unknown",
|
|
1017
|
+
message: null,
|
|
1018
|
+
},
|
|
1019
|
+
control: {
|
|
1020
|
+
state: "unknown",
|
|
1021
|
+
message: null,
|
|
1022
|
+
},
|
|
1023
|
+
message: summary,
|
|
1024
|
+
},
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
function updateRunSummary(run, patch, event) {
|
|
1028
|
+
const updatedAt = new Date().toISOString();
|
|
1029
|
+
const next = normalizeRunSummary({
|
|
1030
|
+
...run,
|
|
1031
|
+
...patch,
|
|
1032
|
+
updatedAt,
|
|
1033
|
+
lastHeartbeatAt: patch.session ? updatedAt : run.lastHeartbeatAt,
|
|
1034
|
+
recentEvents: event
|
|
1035
|
+
? normalizeRunEvents([
|
|
1036
|
+
buildRunEvent({
|
|
1037
|
+
...event,
|
|
1038
|
+
createdAt: updatedAt,
|
|
1039
|
+
}),
|
|
1040
|
+
...run.recentEvents,
|
|
1041
|
+
])
|
|
1042
|
+
: run.recentEvents,
|
|
1043
|
+
});
|
|
1044
|
+
return next;
|
|
1045
|
+
}
|
|
1046
|
+
function sameRunIdentity(run, appName, session, viewer) {
|
|
1047
|
+
if (run.appName !== appName)
|
|
1048
|
+
return false;
|
|
1049
|
+
if (session?.sessionId && run.session?.sessionId === session.sessionId) {
|
|
1050
|
+
return true;
|
|
1051
|
+
}
|
|
1052
|
+
return Boolean(viewer?.url && run.viewer?.url === viewer.url);
|
|
208
1053
|
}
|
|
209
1054
|
export class AppManager {
|
|
210
1055
|
activeSessions = new Map();
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
1056
|
+
knownAppNames = new Set();
|
|
1057
|
+
runRefreshAt = new Map();
|
|
1058
|
+
runRefreshInFlight = new Map();
|
|
1059
|
+
stateDir;
|
|
1060
|
+
heartbeatTimeoutMs;
|
|
1061
|
+
heartbeatSweepIntervalMs;
|
|
1062
|
+
appRuns = new Map();
|
|
1063
|
+
sweeperTimer = null;
|
|
1064
|
+
sweeperRuntimeFn = null;
|
|
1065
|
+
sweeperReapInFlight = false;
|
|
1066
|
+
constructor(options = {}) {
|
|
1067
|
+
this.stateDir = options.stateDir;
|
|
1068
|
+
this.heartbeatTimeoutMs =
|
|
1069
|
+
options.heartbeatTimeoutMs ?? RUN_HEARTBEAT_TIMEOUT_MS;
|
|
1070
|
+
this.heartbeatSweepIntervalMs =
|
|
1071
|
+
options.heartbeatSweepIntervalMs ?? RUN_HEARTBEAT_SWEEP_INTERVAL_MS;
|
|
1072
|
+
for (const run of readAppRunStore(this.stateDir)) {
|
|
1073
|
+
this.appRuns.set(run.runId, run);
|
|
1074
|
+
this.knownAppNames.add(run.appName);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Bump a run's `lastHeartbeatAt` to "now" without invoking any plugin
|
|
1079
|
+
* routes. Returns the updated run, or `null` if the runId is unknown.
|
|
1080
|
+
*
|
|
1081
|
+
* The UI calls this on a short interval while the GameView is mounted so
|
|
1082
|
+
* the sweeper knows the tab is still alive. When the tab goes away the
|
|
1083
|
+
* heartbeat stops and {@link reapStaleRuns} reclaims the run after
|
|
1084
|
+
* `heartbeatTimeoutMs`.
|
|
1085
|
+
*/
|
|
1086
|
+
recordHeartbeat(runId) {
|
|
1087
|
+
const run = this.appRuns.get(runId);
|
|
1088
|
+
if (!run)
|
|
1089
|
+
return null;
|
|
1090
|
+
const now = new Date().toISOString();
|
|
1091
|
+
const next = {
|
|
1092
|
+
...run,
|
|
1093
|
+
lastHeartbeatAt: now,
|
|
1094
|
+
};
|
|
1095
|
+
this.appRuns.set(runId, next);
|
|
1096
|
+
this.persistRuns();
|
|
1097
|
+
return next;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Stop and remove every run whose last heartbeat is older than
|
|
1101
|
+
* `heartbeatTimeoutMs`. Runs that never received a heartbeat (no UI ever
|
|
1102
|
+
* attached) are reaped only once they are also older than the timeout to
|
|
1103
|
+
* avoid racing with the launch -> first-poll window.
|
|
1104
|
+
*
|
|
1105
|
+
* For each reaped run the route module's `stopRun` hook is invoked the
|
|
1106
|
+
* same way the explicit Stop button does — so plugins get a single,
|
|
1107
|
+
* uniform shutdown path regardless of why a run is going away.
|
|
1108
|
+
*/
|
|
1109
|
+
async reapStaleRuns(runtime, nowMs = Date.now()) {
|
|
1110
|
+
const reaped = [];
|
|
1111
|
+
for (const run of [...this.appRuns.values()]) {
|
|
1112
|
+
const heartbeat = run.lastHeartbeatAt
|
|
1113
|
+
? Date.parse(run.lastHeartbeatAt)
|
|
1114
|
+
: null;
|
|
1115
|
+
const startedAt = Date.parse(run.startedAt);
|
|
1116
|
+
const reference = heartbeat ?? startedAt;
|
|
1117
|
+
if (!Number.isFinite(reference))
|
|
1118
|
+
continue;
|
|
1119
|
+
if (nowMs - reference < this.heartbeatTimeoutMs)
|
|
1120
|
+
continue;
|
|
1121
|
+
const removed = this.removeRun(run.runId);
|
|
1122
|
+
if (!removed)
|
|
1123
|
+
continue;
|
|
1124
|
+
reaped.push(removed);
|
|
1125
|
+
await invokeAppStopRunHook(removed, runtime);
|
|
1126
|
+
logger.info(`[app-manager] Reaped stale app run "${removed.runId}" (${removed.appName}); ` +
|
|
1127
|
+
`last heartbeat ${run.lastHeartbeatAt ?? "never"}`);
|
|
1128
|
+
}
|
|
1129
|
+
return reaped;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Start the periodic stale-run sweeper. Idempotent — calling twice does
|
|
1133
|
+
* not start two timers. The runtime is resolved lazily via `getRuntime`
|
|
1134
|
+
* so the sweeper picks up runtime changes (e.g. agent restart) without
|
|
1135
|
+
* needing to be re-wired.
|
|
1136
|
+
*
|
|
1137
|
+
* The interval is wrapped in `unref()` so a stuck sweeper never keeps a
|
|
1138
|
+
* Node process alive on shutdown.
|
|
1139
|
+
*/
|
|
1140
|
+
startStaleRunSweeper(getRuntime) {
|
|
1141
|
+
this.sweeperRuntimeFn = getRuntime;
|
|
1142
|
+
if (this.sweeperTimer)
|
|
1143
|
+
return;
|
|
1144
|
+
this.sweeperTimer = setInterval(() => {
|
|
1145
|
+
void this.runSweeperTick();
|
|
1146
|
+
}, this.heartbeatSweepIntervalMs);
|
|
1147
|
+
if (typeof this.sweeperTimer.unref === "function") {
|
|
1148
|
+
this.sweeperTimer.unref();
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
/** Stop the periodic stale-run sweeper. Safe to call multiple times. */
|
|
1152
|
+
stopStaleRunSweeper() {
|
|
1153
|
+
if (!this.sweeperTimer)
|
|
1154
|
+
return;
|
|
1155
|
+
clearInterval(this.sweeperTimer);
|
|
1156
|
+
this.sweeperTimer = null;
|
|
1157
|
+
}
|
|
1158
|
+
async runSweeperTick() {
|
|
1159
|
+
if (this.sweeperReapInFlight)
|
|
1160
|
+
return;
|
|
1161
|
+
this.sweeperReapInFlight = true;
|
|
216
1162
|
try {
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
1163
|
+
const runtime = this.sweeperRuntimeFn?.() ?? null;
|
|
1164
|
+
await this.reapStaleRuns(runtime);
|
|
1165
|
+
}
|
|
1166
|
+
catch (err) {
|
|
1167
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1168
|
+
logger.warn(`[app-manager] Stale-run sweeper failed: ${message}`);
|
|
1169
|
+
}
|
|
1170
|
+
finally {
|
|
1171
|
+
this.sweeperReapInFlight = false;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
persistRuns() {
|
|
1175
|
+
writeAppRunStore(Array.from(this.appRuns.values()), this.stateDir);
|
|
1176
|
+
}
|
|
1177
|
+
listRunsSorted() {
|
|
1178
|
+
return [...this.appRuns.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
1179
|
+
}
|
|
1180
|
+
storeRun(run) {
|
|
1181
|
+
this.knownAppNames.add(run.appName);
|
|
1182
|
+
this.appRuns.set(run.runId, run);
|
|
1183
|
+
this.persistRuns();
|
|
1184
|
+
return run;
|
|
1185
|
+
}
|
|
1186
|
+
removeRun(runId) {
|
|
1187
|
+
const run = this.appRuns.get(runId) ?? null;
|
|
1188
|
+
if (!run)
|
|
1189
|
+
return null;
|
|
1190
|
+
this.appRuns.delete(runId);
|
|
1191
|
+
this.activeSessions.delete(runId);
|
|
1192
|
+
this.runRefreshAt.delete(runId);
|
|
1193
|
+
this.runRefreshInFlight.delete(runId);
|
|
1194
|
+
this.persistRuns();
|
|
1195
|
+
return run;
|
|
1196
|
+
}
|
|
1197
|
+
findRun(runId) {
|
|
1198
|
+
return this.appRuns.get(runId) ?? null;
|
|
1199
|
+
}
|
|
1200
|
+
findMatchingRun(appName, session, viewer) {
|
|
1201
|
+
for (const run of this.listRunsSorted()) {
|
|
1202
|
+
if (sameRunIdentity(run, appName, session, viewer)) {
|
|
1203
|
+
return run;
|
|
222
1204
|
}
|
|
223
1205
|
}
|
|
224
|
-
|
|
225
|
-
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1208
|
+
shouldSkipRunRefresh(run, force) {
|
|
1209
|
+
if (force)
|
|
1210
|
+
return false;
|
|
1211
|
+
const lastRefreshAt = this.runRefreshAt.get(run.runId) ?? 0;
|
|
1212
|
+
return Date.now() - lastRefreshAt < RUN_REFRESH_MIN_INTERVAL_MS;
|
|
1213
|
+
}
|
|
1214
|
+
async refreshRunSession(run, runtime) {
|
|
1215
|
+
const routeModule = await importAppRouteModule(run.appName);
|
|
1216
|
+
if (typeof routeModule?.refreshRunSession !== "function") {
|
|
1217
|
+
return run;
|
|
226
1218
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
1219
|
+
try {
|
|
1220
|
+
const nextSession = await routeModule.refreshRunSession({
|
|
1221
|
+
appName: run.appName,
|
|
1222
|
+
launchUrl: run.launchUrl,
|
|
1223
|
+
runtime,
|
|
1224
|
+
viewer: run.viewer,
|
|
1225
|
+
runId: run.runId,
|
|
1226
|
+
session: run.session,
|
|
1227
|
+
});
|
|
1228
|
+
if (!nextSession) {
|
|
1229
|
+
const summary = "Run session is no longer available.";
|
|
1230
|
+
const nextRun = this.storeRun(updateRunSummary(run, {
|
|
1231
|
+
session: buildUnavailableSession(run, "offline", summary),
|
|
1232
|
+
status: "offline",
|
|
1233
|
+
summary,
|
|
1234
|
+
}, {
|
|
1235
|
+
kind: "health",
|
|
1236
|
+
severity: "warning",
|
|
1237
|
+
message: summary,
|
|
1238
|
+
status: "offline",
|
|
1239
|
+
details: {
|
|
1240
|
+
runId: run.runId,
|
|
1241
|
+
appName: run.appName,
|
|
1242
|
+
},
|
|
1243
|
+
}));
|
|
1244
|
+
return nextRun;
|
|
1245
|
+
}
|
|
1246
|
+
const nextRun = this.storeRun(updateRunSummary(run, {
|
|
1247
|
+
session: nextSession,
|
|
1248
|
+
status: nextSession.status,
|
|
1249
|
+
summary: nextSession.summary ?? run.summary,
|
|
1250
|
+
}, {
|
|
1251
|
+
kind: "refresh",
|
|
1252
|
+
severity: nextSession.status === "running" ? "info" : "warning",
|
|
1253
|
+
message: nextSession.summary ?? `${run.displayName} session refreshed.`,
|
|
1254
|
+
status: nextSession.status,
|
|
1255
|
+
details: {
|
|
1256
|
+
runId: run.runId,
|
|
1257
|
+
appName: run.appName,
|
|
1258
|
+
sessionId: nextSession.sessionId,
|
|
1259
|
+
},
|
|
1260
|
+
}));
|
|
1261
|
+
return nextRun;
|
|
1262
|
+
}
|
|
1263
|
+
catch (error) {
|
|
1264
|
+
const message = error instanceof Error
|
|
1265
|
+
? `Run verification failed: ${error.message}`
|
|
1266
|
+
: "Run verification failed.";
|
|
1267
|
+
const nextStatus = run.session ? "disconnected" : "offline";
|
|
1268
|
+
const nextRun = this.storeRun(updateRunSummary(run, {
|
|
1269
|
+
session: buildUnavailableSession(run, nextStatus, message),
|
|
1270
|
+
status: nextStatus,
|
|
1271
|
+
summary: message,
|
|
1272
|
+
}, {
|
|
1273
|
+
kind: "health",
|
|
1274
|
+
severity: "error",
|
|
1275
|
+
message,
|
|
1276
|
+
status: nextStatus,
|
|
1277
|
+
details: {
|
|
1278
|
+
runId: run.runId,
|
|
1279
|
+
appName: run.appName,
|
|
1280
|
+
},
|
|
1281
|
+
}));
|
|
1282
|
+
return nextRun;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
async refreshRun(run, runtime, options = {}) {
|
|
1286
|
+
const force = options.force === true;
|
|
1287
|
+
if (this.shouldSkipRunRefresh(run, force)) {
|
|
1288
|
+
return this.findRun(run.runId) ?? run;
|
|
1289
|
+
}
|
|
1290
|
+
const inFlight = this.runRefreshInFlight.get(run.runId);
|
|
1291
|
+
if (inFlight) {
|
|
1292
|
+
return inFlight;
|
|
1293
|
+
}
|
|
1294
|
+
this.runRefreshAt.set(run.runId, Date.now());
|
|
1295
|
+
const refreshPromise = this.refreshRunSession(run, runtime).finally(() => {
|
|
1296
|
+
this.runRefreshInFlight.delete(run.runId);
|
|
251
1297
|
});
|
|
1298
|
+
this.runRefreshInFlight.set(run.runId, refreshPromise);
|
|
1299
|
+
return refreshPromise;
|
|
1300
|
+
}
|
|
1301
|
+
async listAvailable(pluginManager) {
|
|
1302
|
+
void pluginManager;
|
|
1303
|
+
const registry = await getRegistryPlugins();
|
|
1304
|
+
const apps = curateCatalogApps(Array.from(registry.values()).filter(isAppRegistryPlugin));
|
|
1305
|
+
return apps.map(flattenAppInfo);
|
|
252
1306
|
}
|
|
253
1307
|
async search(pluginManager, query, limit = 15) {
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
1308
|
+
const appEntries = (await this.listAvailable(pluginManager)).map(flattenAppInfo);
|
|
1309
|
+
const results = scoreEntries(appEntries, query, limit, (p) => [
|
|
1310
|
+
p.appMeta?.displayName?.toLowerCase() ??
|
|
1311
|
+
p.displayName?.toLowerCase() ??
|
|
1312
|
+
"",
|
|
1313
|
+
], (p) => p.appMeta?.capabilities ?? p.capabilities ?? []);
|
|
1314
|
+
return toSearchResults(results);
|
|
261
1315
|
}
|
|
262
1316
|
async getInfo(pluginManager, name) {
|
|
263
|
-
return pluginManager
|
|
1317
|
+
return ((await resolveCuratedAppInfo(pluginManager, name)) ??
|
|
1318
|
+
(await resolveNamedAppInfo(pluginManager, name)));
|
|
1319
|
+
}
|
|
1320
|
+
async listRuns(runtime = null) {
|
|
1321
|
+
const runs = this.listRunsSorted();
|
|
1322
|
+
if (runs.length === 0) {
|
|
1323
|
+
return runs;
|
|
1324
|
+
}
|
|
1325
|
+
const refreshed = await Promise.all(runs.map((run) => this.refreshRun(run, runtime)));
|
|
1326
|
+
return refreshed.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
1327
|
+
}
|
|
1328
|
+
async getRun(runId, runtime = null) {
|
|
1329
|
+
const run = this.findRun(runId);
|
|
1330
|
+
if (!run) {
|
|
1331
|
+
return null;
|
|
1332
|
+
}
|
|
1333
|
+
return this.refreshRun(run, runtime, { force: true });
|
|
1334
|
+
}
|
|
1335
|
+
async attachRun(runId, runtime = null) {
|
|
1336
|
+
const existingRun = this.findRun(runId);
|
|
1337
|
+
const run = existingRun
|
|
1338
|
+
? await this.refreshRun(existingRun, runtime, { force: true })
|
|
1339
|
+
: null;
|
|
1340
|
+
if (!run) {
|
|
1341
|
+
return {
|
|
1342
|
+
success: false,
|
|
1343
|
+
message: `App run "${runId}" was not found.`,
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
const updated = this.storeRun(updateRunSummary(run, {
|
|
1347
|
+
viewerAttachment: run.viewer ? "attached" : "unavailable",
|
|
1348
|
+
}, {
|
|
1349
|
+
kind: "attach",
|
|
1350
|
+
message: run.viewer
|
|
1351
|
+
? `${run.displayName} viewer attached.`
|
|
1352
|
+
: `${run.displayName} viewer is unavailable.`,
|
|
1353
|
+
status: run.session?.status ?? run.status,
|
|
1354
|
+
details: {
|
|
1355
|
+
runId: run.runId,
|
|
1356
|
+
appName: run.appName,
|
|
1357
|
+
},
|
|
1358
|
+
}));
|
|
1359
|
+
return {
|
|
1360
|
+
success: true,
|
|
1361
|
+
message: `${updated.displayName} attached.`,
|
|
1362
|
+
run: updated,
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
async detachRun(runId) {
|
|
1366
|
+
const run = this.findRun(runId);
|
|
1367
|
+
if (!run) {
|
|
1368
|
+
return {
|
|
1369
|
+
success: false,
|
|
1370
|
+
message: `App run "${runId}" was not found.`,
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
const updated = this.storeRun(updateRunSummary(run, {
|
|
1374
|
+
viewerAttachment: run.viewer ? "detached" : "unavailable",
|
|
1375
|
+
}, {
|
|
1376
|
+
kind: "detach",
|
|
1377
|
+
message: run.viewer
|
|
1378
|
+
? `${run.displayName} viewer detached.`
|
|
1379
|
+
: `${run.displayName} viewer is unavailable.`,
|
|
1380
|
+
status: run.session?.status ?? run.status,
|
|
1381
|
+
details: {
|
|
1382
|
+
runId: run.runId,
|
|
1383
|
+
appName: run.appName,
|
|
1384
|
+
},
|
|
1385
|
+
}));
|
|
1386
|
+
return {
|
|
1387
|
+
success: true,
|
|
1388
|
+
message: `${updated.displayName} detached.`,
|
|
1389
|
+
run: updated,
|
|
1390
|
+
};
|
|
264
1391
|
}
|
|
265
1392
|
/**
|
|
266
1393
|
* Launch an app: install its plugin (if needed) and return the viewer URL.
|
|
@@ -272,35 +1399,17 @@ export class AppManager {
|
|
|
272
1399
|
* handle this by showing "connecting..." while the runtime restarts.
|
|
273
1400
|
*/
|
|
274
1401
|
async launch(pluginManager, name, onProgress, _runtime) {
|
|
275
|
-
let appInfo = (await pluginManager
|
|
276
|
-
|
|
277
|
-
// service doesn't include our local workspace app discovery.
|
|
278
|
-
try {
|
|
279
|
-
const localInfo = await getPluginInfo(name);
|
|
280
|
-
if (localInfo) {
|
|
281
|
-
const meta = localInfo.appMeta;
|
|
282
|
-
if (!appInfo) {
|
|
283
|
-
appInfo = { ...localInfo };
|
|
284
|
-
mergeAppMeta(appInfo, meta);
|
|
285
|
-
}
|
|
286
|
-
else if (meta && !appInfo.viewer) {
|
|
287
|
-
// Merge local metadata into existing registry entry
|
|
288
|
-
mergeAppMeta(appInfo, meta);
|
|
289
|
-
appInfo.kind = localInfo.kind ?? appInfo.kind;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
catch {
|
|
294
|
-
// local lookup is best-effort
|
|
295
|
-
}
|
|
1402
|
+
let appInfo = (await resolveCuratedAppInfo(pluginManager, name)) ??
|
|
1403
|
+
(await resolveNamedAppInfo(pluginManager, name));
|
|
296
1404
|
if (!appInfo) {
|
|
297
1405
|
throw new Error(`App "${name}" not found in the registry.`);
|
|
298
1406
|
}
|
|
1407
|
+
const agentsListBeforeLaunch = readAgentsListSnapshot();
|
|
299
1408
|
// The app's plugin is what the agent needs to play the game.
|
|
300
1409
|
// It's the same npm package name as the app, or a separate plugin ref.
|
|
301
|
-
const pluginName = resolvePluginPackageName(appInfo);
|
|
1410
|
+
const pluginName = appInfo.runtimePlugin ?? resolvePluginPackageName(appInfo);
|
|
302
1411
|
// Check if this is a local plugin (already present in plugins/ directory)
|
|
303
|
-
const isLocal = isLocalPlugin(appInfo);
|
|
1412
|
+
const isLocal = Boolean(appInfo.localPath) || isLocalPlugin(appInfo);
|
|
304
1413
|
// Check if the plugin is already installed
|
|
305
1414
|
const installed = await pluginManager.listInstalledPlugins();
|
|
306
1415
|
const alreadyInstalled = installed.some((p) => p.name === pluginName);
|
|
@@ -313,10 +1422,30 @@ export class AppManager {
|
|
|
313
1422
|
else if (!alreadyInstalled) {
|
|
314
1423
|
if (isAutoInstallable(appInfo)) {
|
|
315
1424
|
logger.info(`[app-manager] Installing plugin for app: ${pluginName}`);
|
|
316
|
-
|
|
1425
|
+
let result = await pluginManager
|
|
1426
|
+
.installPlugin(pluginName, onProgress)
|
|
1427
|
+
.catch((err) => ({
|
|
1428
|
+
success: false,
|
|
1429
|
+
pluginName,
|
|
1430
|
+
version: "",
|
|
1431
|
+
installPath: "",
|
|
1432
|
+
requiresRestart: false,
|
|
1433
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1434
|
+
}));
|
|
1435
|
+
if (!result.success &&
|
|
1436
|
+
(result.error?.includes("requires a running agent runtime") ||
|
|
1437
|
+
!_runtime)) {
|
|
1438
|
+
// Runtime plugin manager unavailable — fall back to the direct
|
|
1439
|
+
// installer which writes to ~/.eliza/plugins/installed and can be
|
|
1440
|
+
// picked up by the app-package-modules resolver without restart.
|
|
1441
|
+
const { installPlugin: installPluginDirect } = await import(
|
|
1442
|
+
/* webpackIgnore: true */ "./plugin-installer.js");
|
|
1443
|
+
result = await installPluginDirect(pluginName, onProgress);
|
|
1444
|
+
}
|
|
317
1445
|
if (!result.success) {
|
|
318
1446
|
throw new Error(`Failed to install plugin "${pluginName}": ${result.error}`);
|
|
319
1447
|
}
|
|
1448
|
+
restoreAgentsListAfterAppLaunchIfNeeded(agentsListBeforeLaunch, name, "plugin install");
|
|
320
1449
|
pluginInstalled = true;
|
|
321
1450
|
needsRestart = result.requiresRestart;
|
|
322
1451
|
logger.info(`[app-manager] Plugin installed: ${pluginName} v${result.version}`);
|
|
@@ -328,9 +1457,21 @@ export class AppManager {
|
|
|
328
1457
|
else {
|
|
329
1458
|
logger.info(`[app-manager] Plugin already installed: ${pluginName}`);
|
|
330
1459
|
}
|
|
331
|
-
|
|
1460
|
+
const initialLaunchUrl = appInfo.launchUrl
|
|
1461
|
+
? normalizeSafeAppUrl(substituteTemplateVars(appInfo.launchUrl, {
|
|
1462
|
+
preserveUnknown: false,
|
|
1463
|
+
hyperscapeClientDefault: true,
|
|
1464
|
+
}))
|
|
1465
|
+
: null;
|
|
1466
|
+
const launchPreparation = await prepareLaunch(appInfo, initialLaunchUrl, _runtime ?? null);
|
|
1467
|
+
restoreAgentsListAfterAppLaunchIfNeeded(agentsListBeforeLaunch, name, "launch preparation");
|
|
1468
|
+
const launchPreparationDiagnostics = launchPreparation.diagnostics ?? [];
|
|
1469
|
+
appInfo = applyLaunchPreparation(appInfo, launchPreparation);
|
|
332
1470
|
const resolvedLaunchUrl = appInfo.launchUrl
|
|
333
|
-
? substituteTemplateVars(appInfo.launchUrl
|
|
1471
|
+
? substituteTemplateVars(appInfo.launchUrl, {
|
|
1472
|
+
preserveUnknown: false,
|
|
1473
|
+
hyperscapeClientDefault: true,
|
|
1474
|
+
})
|
|
334
1475
|
: null;
|
|
335
1476
|
const launchUrl = resolvedLaunchUrl
|
|
336
1477
|
? normalizeSafeAppUrl(resolvedLaunchUrl)
|
|
@@ -338,15 +1479,94 @@ export class AppManager {
|
|
|
338
1479
|
if (resolvedLaunchUrl && !launchUrl) {
|
|
339
1480
|
throw new Error(`Refusing to launch app "${appInfo.name}": unsafe launch URL`);
|
|
340
1481
|
}
|
|
341
|
-
const
|
|
342
|
-
|
|
1482
|
+
const skipPluginRegistration = launchPreparation.skipRuntimePluginRegistration === true;
|
|
1483
|
+
let runtimePluginRegistered = false;
|
|
1484
|
+
if (!skipPluginRegistration) {
|
|
1485
|
+
runtimePluginRegistered = await ensureRuntimePluginRegistered(appInfo, _runtime ?? null, isLocal);
|
|
1486
|
+
restoreAgentsListAfterAppLaunchIfNeeded(agentsListBeforeLaunch, name, "runtime plugin registration");
|
|
1487
|
+
}
|
|
1488
|
+
if (runtimePluginRegistered) {
|
|
1489
|
+
pluginInstalled = true;
|
|
1490
|
+
}
|
|
1491
|
+
const viewer = await buildViewerConfig(appInfo, launchUrl, _runtime);
|
|
1492
|
+
const runtimeReadyDiagnostics = [];
|
|
1493
|
+
try {
|
|
1494
|
+
await ensureRuntimeReady(appInfo, viewer, launchUrl, _runtime ?? null);
|
|
1495
|
+
}
|
|
1496
|
+
catch (readyError) {
|
|
1497
|
+
const message = readyError instanceof Error ? readyError.message : String(readyError);
|
|
1498
|
+
logger.warn(`[app-manager] ensureRuntimeReady(${appInfo.name}) failed: ${message}`);
|
|
1499
|
+
runtimeReadyDiagnostics.push({
|
|
1500
|
+
code: "runtime-service-unavailable",
|
|
1501
|
+
severity: "warning",
|
|
1502
|
+
message: `${appInfo.displayName ?? appInfo.name} runtime service could not initialize: ${message}. The viewer will open but live agent control may be unavailable until the underlying service is reachable.`,
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
// Build viewer config from registry app metadata
|
|
1506
|
+
let session;
|
|
1507
|
+
try {
|
|
1508
|
+
session = viewer
|
|
1509
|
+
? await resolveLaunchSession(appInfo, viewer, launchUrl, _runtime ?? null)
|
|
1510
|
+
: buildAppSession(appInfo, undefined, _runtime);
|
|
1511
|
+
}
|
|
1512
|
+
catch (sessionError) {
|
|
1513
|
+
const message = sessionError instanceof Error
|
|
1514
|
+
? sessionError.message
|
|
1515
|
+
: String(sessionError);
|
|
1516
|
+
logger.warn(`[app-manager] resolveLaunchSession(${appInfo.name}) failed: ${message}`);
|
|
1517
|
+
runtimeReadyDiagnostics.push({
|
|
1518
|
+
code: "session-resolve-failed",
|
|
1519
|
+
severity: "warning",
|
|
1520
|
+
message: `Could not resolve launch session for ${appInfo.displayName ?? appInfo.name}: ${message}.`,
|
|
1521
|
+
});
|
|
1522
|
+
session = buildAppSession(appInfo, undefined, _runtime);
|
|
1523
|
+
}
|
|
1524
|
+
const diagnostics = [
|
|
1525
|
+
...launchPreparationDiagnostics,
|
|
1526
|
+
...runtimeReadyDiagnostics,
|
|
1527
|
+
...(await collectLaunchDiagnostics(appInfo, viewer, session, launchUrl, _runtime ?? null)),
|
|
1528
|
+
];
|
|
1529
|
+
const existingRun = this.findMatchingRun(name, session, viewer);
|
|
1530
|
+
const run = this.storeRun(existingRun
|
|
1531
|
+
? updateRunSummary(existingRun, {
|
|
1532
|
+
displayName: appInfo.displayName ?? appInfo.name,
|
|
1533
|
+
pluginName,
|
|
1534
|
+
launchType: appInfo.launchType ?? "connect",
|
|
1535
|
+
launchUrl,
|
|
1536
|
+
viewer,
|
|
1537
|
+
session,
|
|
1538
|
+
viewerAttachment: viewer ? "attached" : "unavailable",
|
|
1539
|
+
}, {
|
|
1540
|
+
kind: "refresh",
|
|
1541
|
+
message: session?.summary ??
|
|
1542
|
+
`${appInfo.displayName ?? appInfo.name} launch state refreshed.`,
|
|
1543
|
+
status: session?.status ?? (viewer ? "running" : "launching"),
|
|
1544
|
+
details: {
|
|
1545
|
+
runId: existingRun.runId,
|
|
1546
|
+
appName: name,
|
|
1547
|
+
sessionId: session?.sessionId ?? null,
|
|
1548
|
+
},
|
|
1549
|
+
})
|
|
1550
|
+
: buildRunSummary({
|
|
1551
|
+
runId: crypto.randomUUID(),
|
|
1552
|
+
appName: name,
|
|
1553
|
+
displayName: appInfo.displayName ?? appInfo.name,
|
|
1554
|
+
pluginName,
|
|
1555
|
+
launchType: appInfo.launchType ?? "connect",
|
|
1556
|
+
launchUrl,
|
|
1557
|
+
viewer,
|
|
1558
|
+
session,
|
|
1559
|
+
}));
|
|
1560
|
+
this.activeSessions.set(run.runId, {
|
|
1561
|
+
runId: run.runId,
|
|
343
1562
|
appName: name,
|
|
344
1563
|
pluginName,
|
|
345
1564
|
launchType: appInfo.launchType ?? "connect",
|
|
346
1565
|
launchUrl,
|
|
347
1566
|
viewerUrl: viewer?.url ?? null,
|
|
348
|
-
startedAt:
|
|
1567
|
+
startedAt: run.startedAt,
|
|
349
1568
|
});
|
|
1569
|
+
restoreAgentsListAfterAppLaunchIfNeeded(agentsListBeforeLaunch, name, "launch");
|
|
350
1570
|
return {
|
|
351
1571
|
pluginInstalled,
|
|
352
1572
|
needsRestart,
|
|
@@ -354,72 +1574,105 @@ export class AppManager {
|
|
|
354
1574
|
launchType: appInfo.launchType ?? "connect",
|
|
355
1575
|
launchUrl,
|
|
356
1576
|
viewer,
|
|
1577
|
+
session,
|
|
1578
|
+
run,
|
|
1579
|
+
diagnostics,
|
|
357
1580
|
};
|
|
358
1581
|
}
|
|
359
|
-
async stop(pluginManager, name) {
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
1582
|
+
async stop(pluginManager, name, runId, runtime) {
|
|
1583
|
+
const stoppedAt = new Date().toISOString();
|
|
1584
|
+
if (runId) {
|
|
1585
|
+
const removedRun = this.removeRun(runId);
|
|
1586
|
+
if (!removedRun) {
|
|
1587
|
+
return {
|
|
1588
|
+
success: false,
|
|
1589
|
+
appName: name,
|
|
1590
|
+
runId,
|
|
1591
|
+
stoppedAt,
|
|
1592
|
+
pluginUninstalled: false,
|
|
1593
|
+
needsRestart: false,
|
|
1594
|
+
stopScope: "no-op",
|
|
1595
|
+
message: `App run "${runId}" was not found.`,
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
await invokeAppStopRunHook(removedRun, runtime ?? null);
|
|
369
1599
|
return {
|
|
370
|
-
success:
|
|
371
|
-
appName:
|
|
372
|
-
|
|
1600
|
+
success: true,
|
|
1601
|
+
appName: removedRun.appName,
|
|
1602
|
+
runId: removedRun.runId,
|
|
1603
|
+
stoppedAt,
|
|
373
1604
|
pluginUninstalled: false,
|
|
374
1605
|
needsRestart: false,
|
|
375
|
-
stopScope: "
|
|
376
|
-
message:
|
|
1606
|
+
stopScope: "viewer-session",
|
|
1607
|
+
message: `${removedRun.displayName} stopped.`,
|
|
377
1608
|
};
|
|
378
1609
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (!
|
|
382
|
-
|
|
1610
|
+
const runsForApp = this.listRunsSorted().filter((run) => run.appName === name);
|
|
1611
|
+
if (runsForApp.length === 0) {
|
|
1612
|
+
if (!this.knownAppNames.has(name)) {
|
|
1613
|
+
const appInfo = (await pluginManager.getRegistryPlugin(name));
|
|
1614
|
+
if (!appInfo) {
|
|
1615
|
+
throw new Error(`App "${name}" not found in the registry.`);
|
|
1616
|
+
}
|
|
1617
|
+
this.knownAppNames.add(name);
|
|
383
1618
|
}
|
|
384
1619
|
return {
|
|
385
|
-
success:
|
|
1620
|
+
success: false,
|
|
386
1621
|
appName: name,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
: `${name} disconnected and plugin uninstalled.`,
|
|
1622
|
+
runId: null,
|
|
1623
|
+
stoppedAt,
|
|
1624
|
+
pluginUninstalled: false,
|
|
1625
|
+
needsRestart: false,
|
|
1626
|
+
stopScope: "no-op",
|
|
1627
|
+
message: `No active app run found for "${name}".`,
|
|
394
1628
|
};
|
|
395
1629
|
}
|
|
1630
|
+
for (const run of runsForApp) {
|
|
1631
|
+
this.removeRun(run.runId);
|
|
1632
|
+
await invokeAppStopRunHook(run, runtime ?? null);
|
|
1633
|
+
}
|
|
396
1634
|
return {
|
|
397
1635
|
success: true,
|
|
398
1636
|
appName: name,
|
|
399
|
-
|
|
1637
|
+
runId: null,
|
|
1638
|
+
stoppedAt,
|
|
400
1639
|
pluginUninstalled: false,
|
|
401
1640
|
needsRestart: false,
|
|
402
1641
|
stopScope: "viewer-session",
|
|
403
|
-
message:
|
|
1642
|
+
message: runsForApp.length === 1
|
|
1643
|
+
? `${runsForApp[0]?.displayName ?? name} stopped.`
|
|
1644
|
+
: `${runsForApp.length} app runs stopped for "${name}".`,
|
|
404
1645
|
};
|
|
405
1646
|
}
|
|
406
1647
|
/** List apps whose plugins are currently installed on the agent. */
|
|
407
1648
|
async listInstalled(pluginManager) {
|
|
408
1649
|
const installed = await pluginManager.listInstalledPlugins();
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
1650
|
+
const registry = await getRegistryPlugins();
|
|
1651
|
+
const refreshedRegistry = await withTimeout(pluginManager.refreshRegistry(), resolveRegistryRefreshTimeoutMs(), "app registry refresh").catch(() => new Map());
|
|
1652
|
+
const mergedRegistry = new Map(registry);
|
|
1653
|
+
for (const [name, info] of refreshedRegistry.entries()) {
|
|
1654
|
+
if (!mergedRegistry.has(name)) {
|
|
1655
|
+
mergedRegistry.set(name, info);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
const installedByName = new Map(installed.map((plugin) => [plugin.name, plugin]));
|
|
1659
|
+
const appEntries = Array.from(mergedRegistry.values())
|
|
1660
|
+
.filter(isAppRegistryPlugin)
|
|
1661
|
+
.map(flattenAppInfo);
|
|
1662
|
+
return appEntries
|
|
1663
|
+
.map((appInfo) => {
|
|
1664
|
+
const pluginName = appInfo.runtimePlugin ?? resolvePluginPackageName(appInfo);
|
|
1665
|
+
const installedPlugin = installedByName.get(pluginName) ?? installedByName.get(appInfo.name);
|
|
1666
|
+
if (!installedPlugin)
|
|
1667
|
+
return null;
|
|
1668
|
+
return {
|
|
1669
|
+
name: appInfo.name,
|
|
1670
|
+
displayName: appInfo.displayName ?? packageNameToAppDisplayName(appInfo.name),
|
|
1671
|
+
pluginName,
|
|
1672
|
+
version: installedPlugin.version ?? "unknown",
|
|
1673
|
+
installedAt: installedPlugin.installedAt ?? "",
|
|
1674
|
+
};
|
|
1675
|
+
})
|
|
1676
|
+
.filter((app) => app !== null);
|
|
424
1677
|
}
|
|
425
1678
|
}
|