@elizaos/agent 2.0.3-beta.2 → 2.0.3-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/view-user-journeys.d.ts.map +1 -1
- package/__tests__/view-user-journeys.js +52 -41
- package/actions/context-signal.d.ts +2 -2
- package/actions/files.d.ts +9 -0
- package/actions/files.d.ts.map +1 -0
- package/actions/files.js +183 -0
- package/actions/index.d.ts +17 -17
- package/api/accounts-routes.d.ts +1 -1
- package/api/accounts-routes.js +1 -1
- package/api/agent-admin-routes.d.ts +1 -1
- package/api/agent-admin-routes.js +2 -2
- package/api/agent-model.d.ts +1 -1
- package/api/agent-status-routes.d.ts +1 -3
- package/api/agent-status-routes.d.ts.map +1 -1
- package/api/agent-status-routes.js +0 -2
- package/api/approval-routes.d.ts +38 -0
- package/api/approval-routes.d.ts.map +1 -0
- package/api/approval-routes.js +223 -0
- package/api/background-routes.d.ts +13 -0
- package/api/background-routes.d.ts.map +1 -0
- package/api/background-routes.js +91 -0
- package/api/binance-skill-helpers.d.ts +2 -2
- package/api/binance-skill-helpers.js +2 -2
- package/api/builtin-views.d.ts.map +1 -1
- package/api/builtin-views.js +44 -4
- package/api/character-routes.d.ts +1 -1
- package/api/chat-augmentation.d.ts.map +1 -1
- package/api/chat-augmentation.js +17 -0
- package/api/chat-routes.d.ts +29 -2
- package/api/chat-routes.d.ts.map +1 -1
- package/api/chat-routes.js +76 -1
- package/api/commands-routes.d.ts +10 -8
- package/api/commands-routes.d.ts.map +1 -1
- package/api/commands-routes.js +17 -59
- package/api/config-routes.d.ts +1 -1
- package/api/config-routes.d.ts.map +1 -1
- package/api/config-routes.js +0 -2
- package/api/connector-routes.d.ts +1 -1
- package/api/conversation-metadata.d.ts +1 -1
- package/api/conversation-metadata.d.ts.map +1 -1
- package/api/conversation-metadata.js +0 -1
- package/api/conversation-routes.d.ts +4 -3
- package/api/conversation-routes.d.ts.map +1 -1
- package/api/conversation-routes.js +34 -1
- package/api/documents-service-loader.d.ts +0 -4
- package/api/documents-service-loader.d.ts.map +1 -1
- package/api/documents-service-loader.js +0 -2
- package/api/files-routes.d.ts +14 -0
- package/api/files-routes.d.ts.map +1 -0
- package/api/files-routes.js +47 -0
- package/api/first-run-routes.d.ts +1 -1
- package/api/health-routes.d.ts +2 -2
- package/api/index.d.ts +40 -39
- package/api/index.d.ts.map +1 -1
- package/api/index.js +1 -0
- package/api/interactions-routes.d.ts +33 -0
- package/api/interactions-routes.d.ts.map +1 -0
- package/api/interactions-routes.js +63 -0
- package/api/media-runtime.d.ts +2 -1
- package/api/media-runtime.d.ts.map +1 -1
- package/api/media-runtime.js +64 -7
- package/api/media-store.d.ts +36 -0
- package/api/media-store.d.ts.map +1 -1
- package/api/media-store.js +141 -2
- package/api/memory-bounds.d.ts +0 -1
- package/api/memory-bounds.d.ts.map +1 -1
- package/api/memory-bounds.js +0 -1
- package/api/misc-routes.d.ts +1 -1
- package/api/model-provider-helpers.d.ts +2 -2
- package/api/model-provider-helpers.js +2 -2
- package/api/permissions-routes-extra.d.ts +1 -1
- package/api/permissions-routes.d.ts +1 -1
- package/api/permissions-routes.d.ts.map +1 -1
- package/api/permissions-routes.js +8 -7
- package/api/plugin-discovery-helpers.d.ts +5 -6
- package/api/plugin-discovery-helpers.d.ts.map +1 -1
- package/api/plugin-discovery-helpers.js +3 -4
- package/api/plugin-runtime-apply.d.ts +2 -2
- package/api/plugin-runtime-apply.d.ts.map +1 -1
- package/api/plugin-runtime-apply.js +74 -0
- package/api/provider-switch-config.d.ts +1 -1
- package/api/provider-switch-routes.d.ts +2 -2
- package/api/registry-routes.d.ts +1 -1
- package/api/registry-service.d.ts +1 -1
- package/api/remote-capability-routes.d.ts +2 -2
- package/api/remote-capability-routes.d.ts.map +1 -1
- package/api/remote-capability-routes.js +19 -0
- package/api/server-autonomy-helpers.d.ts +2 -2
- package/api/server-helpers-auth.d.ts +10 -0
- package/api/server-helpers-auth.d.ts.map +1 -1
- package/api/server-helpers-auth.js +16 -210
- package/api/server-helpers-config.d.ts +1 -1
- package/api/server-helpers-mcp.d.ts +2 -2
- package/api/server-helpers-plugin.d.ts +1 -1
- package/api/server-helpers-swarm.d.ts +3 -3
- package/api/server-helpers-swarm.d.ts.map +1 -1
- package/api/server-helpers-swarm.js +15 -5
- package/api/server-helpers-wallet.d.ts +1 -1
- package/api/server-helpers.d.ts +4 -4
- package/api/server-lazy-routes.d.ts +40 -38
- package/api/server-lazy-routes.d.ts.map +1 -1
- package/api/server-lazy-routes.js +7 -0
- package/api/server-route-dispatch.d.ts +2 -2
- package/api/server-route-dispatch.d.ts.map +1 -1
- package/api/server-route-dispatch.js +7 -0
- package/api/server-types.d.ts +9 -7
- package/api/server-types.d.ts.map +1 -1
- package/api/server.d.ts +19 -19
- package/api/server.d.ts.map +1 -1
- package/api/server.js +111 -17
- package/api/static-file-server.d.ts +2 -2
- package/api/static-file-server.js +2 -2
- package/api/subscription-routes.d.ts +4 -4
- package/api/subscription-routes.js +3 -4
- package/api/suggestions-routes.d.ts +1 -1
- package/api/suggestions-routes.d.ts.map +1 -1
- package/api/suggestions-routes.js +2 -3
- package/api/terminal-execution-routing.d.ts +1 -1
- package/api/training-service-like.d.ts +1 -1
- package/api/trajectory-fallback-routes.d.ts.map +1 -1
- package/api/trajectory-fallback-routes.js +21 -1
- package/api/update-routes.d.ts +1 -1
- package/api/view-registry-types.d.ts +1 -1
- package/api/views-registry.d.ts +14 -4
- package/api/views-registry.d.ts.map +1 -1
- package/api/views-registry.js +107 -72
- package/api/views-routes.d.ts +1 -1
- package/api/views-routes.d.ts.map +1 -1
- package/api/views-routes.js +131 -14
- package/api/views-search-index.d.ts +1 -1
- package/api/wallet-capability.d.ts +3 -3
- package/api/wallet-rpc.d.ts +1 -1
- package/api/wallet.d.ts +3 -3
- package/api/wallet.d.ts.map +1 -1
- package/api/wallet.js +4 -3
- package/api/workbench-context.d.ts +1 -1
- package/api/workbench-helpers.d.ts +3 -3
- package/api/workbench-helpers.js +3 -3
- package/api/workbench-routes.d.ts +2 -2
- package/api/workbench-vfs-routes.d.ts +1 -1
- package/api/ws-event-replay.d.ts +1 -2
- package/api/ws-event-replay.d.ts.map +1 -1
- package/api/ws-event-replay.js +1 -2
- package/api/x-relay-routes.d.ts +2 -2
- package/api/x402-route-validation.d.ts +4 -0
- package/api/x402-route-validation.d.ts.map +1 -0
- package/api/x402-route-validation.js +6 -0
- package/assets/view-heroes/background.png +0 -0
- package/auth/account-storage.d.ts +1 -1
- package/auth/anthropic.d.ts +1 -1
- package/auth/credentials.d.ts +2 -2
- package/auth/index.d.ts +7 -7
- package/auth/oauth-flow.d.ts +2 -2
- package/auth/openai-codex.d.ts +1 -1
- package/awareness/index.d.ts +1 -1
- package/config/config.js +0 -1
- package/config/env-vars.d.ts +1 -1
- package/config/env-vars.d.ts.map +1 -1
- package/config/env-vars.js +0 -1
- package/config/index.d.ts +10 -10
- package/config/model-metadata.d.ts +1 -1
- package/config/owner-contacts.d.ts +1 -1
- package/config/schema.d.ts +1 -1
- package/hooks/discovery.d.ts +1 -1
- package/hooks/eligibility.d.ts +2 -2
- package/hooks/index.d.ts +2 -2
- package/hooks/loader.d.ts +2 -2
- package/hooks/registry.d.ts +1 -1
- package/index.d.ts +87 -85
- package/index.d.ts.map +1 -1
- package/index.js +11 -3
- package/package.json +54 -44
- package/providers/media-provider.d.ts +1 -1
- package/providers/page-scoped-context.d.ts.map +1 -1
- package/providers/page-scoped-context.js +1 -70
- package/providers/relevant-conversations.d.ts.map +1 -1
- package/providers/relevant-conversations.js +8 -9
- package/providers/workspace.d.ts +1 -1
- package/runtime/actions/web-fetch.d.ts.map +1 -1
- package/runtime/actions/web-fetch.js +23 -3
- package/runtime/actions/web-search.d.ts +32 -0
- package/runtime/actions/web-search.d.ts.map +1 -0
- package/runtime/actions/web-search.js +245 -0
- package/runtime/advanced-capabilities-config.d.ts +1 -1
- package/runtime/boot-telemetry.d.ts +1 -1
- package/runtime/conversation-compactor-runtime.d.ts +1 -1
- package/runtime/conversation-compactor-runtime.js +1 -1
- package/runtime/conversation-compactor.d.ts +1 -1
- package/runtime/core-plugins.d.ts.map +1 -1
- package/runtime/core-plugins.js +9 -0
- package/runtime/custom-actions.d.ts +18 -9
- package/runtime/custom-actions.d.ts.map +1 -1
- package/runtime/custom-actions.js +85 -23
- package/runtime/eliza-plugin.d.ts.map +1 -1
- package/runtime/eliza-plugin.js +15 -1
- package/runtime/eliza.d.ts +9 -7
- package/runtime/eliza.d.ts.map +1 -1
- package/runtime/eliza.js +86 -23
- package/runtime/first-time-setup.d.ts +1 -3
- package/runtime/first-time-setup.d.ts.map +1 -1
- package/runtime/first-time-setup.js +0 -2
- package/runtime/index.d.ts +18 -18
- package/runtime/load-plugin-from-vfs.d.ts +2 -2
- package/runtime/mobile-dns.d.ts.map +1 -1
- package/runtime/mobile-dns.js +2 -5
- package/runtime/operations/classifier.d.ts +1 -1
- package/runtime/operations/cold-strategy.d.ts +1 -1
- package/runtime/operations/health-checks.d.ts +1 -1
- package/runtime/operations/health.d.ts +1 -1
- package/runtime/operations/index.d.ts +10 -10
- package/runtime/operations/manager.d.ts +3 -3
- package/runtime/operations/reload-hot.d.ts +1 -1
- package/runtime/operations/repository.d.ts +1 -1
- package/runtime/operations/vault-bridge.d.ts +1 -1
- package/runtime/plugin-collector.d.ts +6 -1
- package/runtime/plugin-collector.d.ts.map +1 -1
- package/runtime/plugin-collector.js +11 -28
- package/runtime/plugin-lifecycle.d.ts.map +1 -1
- package/runtime/plugin-lifecycle.js +1 -0
- package/runtime/plugin-resolver.d.ts +2 -2
- package/runtime/plugin-resolver.d.ts.map +1 -1
- package/runtime/plugin-resolver.js +113 -65
- package/runtime/plugin-types.d.ts +1 -1
- package/runtime/prompt-optimization.d.ts +4 -4
- package/runtime/remote-coding-runner-gate.d.ts +7 -0
- package/runtime/remote-coding-runner-gate.d.ts.map +1 -0
- package/runtime/remote-coding-runner-gate.js +36 -0
- package/runtime/roles/src/index.d.ts +4 -4
- package/runtime/roles.d.ts +2 -2
- package/runtime/sandbox-character.d.ts +1 -1
- package/runtime/tool-call-cache/cache.d.ts +1 -1
- package/runtime/tool-call-cache/disk-store.d.ts +1 -1
- package/runtime/tool-call-cache/index.d.ts +6 -6
- package/runtime/tool-call-cache/key.d.ts +1 -1
- package/runtime/tool-call-cache/redact.d.ts +1 -1
- package/runtime/tool-call-cache/registry.d.ts +1 -1
- package/runtime/tool-call-cache-wrapper.d.ts +7 -9
- package/runtime/tool-call-cache-wrapper.d.ts.map +1 -1
- package/runtime/tool-call-cache-wrapper.js +6 -11
- package/runtime/trajectory-export.d.ts +3 -3
- package/runtime/trajectory-internals.d.ts +2 -1
- package/runtime/trajectory-internals.d.ts.map +1 -1
- package/runtime/trajectory-persistence.d.ts +5 -5
- package/runtime/trajectory-steps-reader.d.ts +1 -1
- package/runtime/trajectory-steps-writer.d.ts +1 -1
- package/runtime/trajectory-storage.d.ts +4 -4
- package/runtime/view-action-affinity.d.ts +18 -15
- package/runtime/view-action-affinity.d.ts.map +1 -1
- package/runtime/view-action-affinity.js +26 -29
- package/runtime/web-search-tools.d.ts +4 -1
- package/runtime/web-search-tools.d.ts.map +1 -1
- package/runtime/web-search-tools.js +37 -9
- package/security/index.d.ts +3 -3
- package/services/approval/index.d.ts +9 -0
- package/services/approval/index.d.ts.map +1 -0
- package/services/approval/index.js +8 -0
- package/services/approval/service.d.ts +35 -0
- package/services/approval/service.d.ts.map +1 -0
- package/services/approval/service.js +40 -0
- package/services/approval/sql.d.ts +18 -0
- package/services/approval/sql.d.ts.map +1 -0
- package/services/approval/sql.js +104 -0
- package/services/approval/store.d.ts +39 -0
- package/services/approval/store.d.ts.map +1 -0
- package/services/approval/store.js +534 -0
- package/services/approval/types.d.ts +207 -0
- package/services/approval/types.d.ts.map +1 -0
- package/services/approval/types.js +34 -0
- package/services/character-persistence.d.ts +2 -2
- package/services/client-chat-sender.d.ts +1 -1
- package/services/config-plugin-manager.d.ts +2 -2
- package/services/connector-setup-service.d.ts +1 -1
- package/services/cove-quote-x509.d.ts +1 -1
- package/services/cove-quote.d.ts +2 -2
- package/services/dstack-tee-provider.d.ts +1 -1
- package/services/file-storage.d.ts +20 -0
- package/services/file-storage.d.ts.map +1 -0
- package/services/file-storage.js +70 -0
- package/services/global-pause/index.d.ts +8 -0
- package/services/global-pause/index.d.ts.map +1 -0
- package/services/global-pause/index.js +7 -0
- package/services/global-pause/service.d.ts +29 -0
- package/services/global-pause/service.d.ts.map +1 -0
- package/services/global-pause/service.js +34 -0
- package/services/global-pause/store.d.ts +31 -0
- package/services/global-pause/store.d.ts.map +1 -0
- package/services/global-pause/store.js +83 -0
- package/services/handoff/index.d.ts +8 -0
- package/services/handoff/index.d.ts.map +1 -0
- package/services/handoff/index.js +7 -0
- package/services/handoff/service.d.ts +29 -0
- package/services/handoff/service.d.ts.map +1 -0
- package/services/handoff/service.js +34 -0
- package/services/handoff/store.d.ts +76 -0
- package/services/handoff/store.d.ts.map +1 -0
- package/services/handoff/store.js +148 -0
- package/services/index.d.ts +30 -31
- package/services/index.d.ts.map +1 -1
- package/services/index.js +0 -6
- package/services/js-runtime-bridge.d.ts.map +1 -1
- package/services/js-runtime-bridge.js +8 -2
- package/services/knowledge-graph/index.d.ts +4 -4
- package/services/knowledge-graph/service.d.ts +2 -2
- package/services/pending-prompts/index.d.ts +8 -0
- package/services/pending-prompts/index.d.ts.map +1 -0
- package/services/pending-prompts/index.js +7 -0
- package/services/pending-prompts/service.d.ts +34 -0
- package/services/pending-prompts/service.d.ts.map +1 -0
- package/services/pending-prompts/service.js +68 -0
- package/services/pending-prompts/store.d.ts +70 -0
- package/services/pending-prompts/store.d.ts.map +1 -0
- package/services/pending-prompts/store.js +191 -0
- package/services/plugin-compiler.d.ts +1 -1
- package/services/plugin-installer.d.ts.map +1 -1
- package/services/plugin-installer.js +21 -11
- package/services/plugin-manager-types.d.ts +1 -1
- package/services/proactive-interaction-decider.d.ts +62 -11
- package/services/proactive-interaction-decider.d.ts.map +1 -1
- package/services/proactive-interaction-decider.js +223 -35
- package/services/push/apns-provider.d.ts +1 -1
- package/services/push/fcm-provider.d.ts +1 -1
- package/services/push/notification-push-service.d.ts +2 -2
- package/services/registry-client-app-meta.d.ts +1 -1
- package/services/registry-client-endpoints.d.ts +2 -2
- package/services/registry-client-local.d.ts +1 -1
- package/services/registry-client-network.d.ts +1 -1
- package/services/registry-client-queries.d.ts +1 -1
- package/services/registry-client.d.ts +3 -3
- package/services/relationships-graph.d.ts +1 -1
- package/services/remote-capability-cloud-sandbox.d.ts +3 -3
- package/services/remote-capability-endpoint-conformance.d.ts +1 -1
- package/services/remote-capability-endpoint-provider.d.ts +4 -4
- package/services/remote-capability-url-endpoint-providers.d.ts +1 -1
- package/services/remote-plugin-adapter.d.ts.map +1 -1
- package/services/remote-plugin-adapter.js +3 -0
- package/services/remote-plugin-bridge.d.ts.map +1 -1
- package/services/remote-plugin-bridge.js +97 -26
- package/services/remote-signing-service.d.ts +4 -4
- package/services/research-task-executor.d.ts +1 -1
- package/services/sandbox-manager.d.ts +1 -1
- package/services/self-updater.d.ts +1 -1
- package/services/self-updater.d.ts.map +1 -1
- package/services/self-updater.js +23 -9
- package/services/shell-execution-router.d.ts +1 -1
- package/services/shell-execution-router.d.ts.map +1 -1
- package/services/shell-execution-router.js +19 -2
- package/services/tee-boot-gate-state.d.ts +1 -1
- package/services/tee-boot-gate.d.ts +4 -4
- package/services/tee-confidential-inference.d.ts +3 -3
- package/services/tee-key-release.d.ts +2 -2
- package/services/tee-model-key-boot.d.ts +4 -4
- package/services/tee-policy.d.ts +1 -1
- package/services/tee-production-profile.d.ts +1 -1
- package/services/tee-release-policy.d.ts +1 -1
- package/services/tee-revocation.d.ts +2 -2
- package/services/tee-runtime-config.d.ts +1 -1
- package/services/tee-sealed-volume.d.ts +3 -3
- package/services/tee-signer-backend.d.ts +3 -3
- package/services/update-checker.d.ts +1 -1
- package/services/vault-signer-backend.d.ts +1 -1
- package/services/vfs-git.d.ts +1 -1
- package/test-support/index.d.ts +3 -3
- package/triggers/runtime.d.ts +1 -1
- package/triggers/scheduling.d.ts +3 -22
- package/triggers/scheduling.d.ts.map +1 -1
- package/triggers/scheduling.js +2 -214
- package/tui/agent-terminal-tui.d.ts.map +1 -1
- package/tui/agent-terminal-tui.js +174 -72
- package/types/index.d.ts +3 -3
- package/api/nfa-routes.d.ts +0 -6
- package/api/nfa-routes.d.ts.map +0 -1
- package/api/nfa-routes.js +0 -125
- package/api/server-auth.d.ts +0 -46
- package/api/server-auth.d.ts.map +0 -1
- package/api/server-auth.js +0 -504
- package/runtime/restart.d.ts +0 -9
- package/runtime/restart.d.ts.map +0 -1
- package/runtime/restart.js +0 -8
- package/test-utils/sqlite-compat.d.ts +0 -23
- package/test-utils/sqlite-compat.d.ts.map +0 -1
- package/test-utils/sqlite-compat.js +0 -214
package/api/chat-routes.js
CHANGED
|
@@ -27,8 +27,49 @@ import { isInsufficientCreditsError, isInsufficientCreditsMessage, } from "./cre
|
|
|
27
27
|
import { buildWalletActionNotExecutedReply, cloneWithoutBlockedObjectKeys, decodePathComponent, getErrorMessage, hasBlockedObjectKeyDeep, isWalletActionRequiredIntent, maybeAugmentChatMessageWithWalletContext, normalizeIncomingChatPrompt, resolveAppUserName, trimWalletProgressPrefix, validateChatImages, } from "./server-helpers.js";
|
|
28
28
|
const DEFAULT_CONVERSATION_TITLE_TIMEOUT_MS = 5_000;
|
|
29
29
|
let localInferenceChatApiPromise = null;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the plugin-local-inference chat API used to turn a local-inference
|
|
32
|
+
* failure into a user-facing status (download prompts, switch-model hints, …).
|
|
33
|
+
*
|
|
34
|
+
* An error-reporting path must NEVER throw. The mobile bundle can resolve the
|
|
35
|
+
* dynamic `import("@elizaos/plugin-local-inference")` to a namespace whose named
|
|
36
|
+
* export is `undefined` (tree-shake / circular-init artifact) — which previously
|
|
37
|
+
* made the catch blocks throw `getLocalInferenceChatStatus is not a function`
|
|
38
|
+
* and MASK the real error. So validate the import and fall back to a status
|
|
39
|
+
* derived from the raw error, guaranteeing the actual failure surfaces.
|
|
40
|
+
*/
|
|
30
41
|
function getLocalInferenceChatApi() {
|
|
31
|
-
localInferenceChatApiPromise ??=
|
|
42
|
+
localInferenceChatApiPromise ??=
|
|
43
|
+
(async () => {
|
|
44
|
+
const fallback = {
|
|
45
|
+
getLocalInferenceChatStatus: async (_intent, error) => ({
|
|
46
|
+
text: error instanceof Error
|
|
47
|
+
? error.message
|
|
48
|
+
: typeof error === "string" && error
|
|
49
|
+
? error
|
|
50
|
+
: "Local inference is unavailable.",
|
|
51
|
+
localInference: {},
|
|
52
|
+
}),
|
|
53
|
+
handleLocalInferenceChatCommand: async (_intent, prompt) => ({
|
|
54
|
+
text: prompt,
|
|
55
|
+
localInference: {},
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
try {
|
|
59
|
+
const mod = (await import("@elizaos/plugin-local-inference"));
|
|
60
|
+
return {
|
|
61
|
+
getLocalInferenceChatStatus: typeof mod.getLocalInferenceChatStatus === "function"
|
|
62
|
+
? mod.getLocalInferenceChatStatus
|
|
63
|
+
: fallback.getLocalInferenceChatStatus,
|
|
64
|
+
handleLocalInferenceChatCommand: typeof mod.handleLocalInferenceChatCommand === "function"
|
|
65
|
+
? mod.handleLocalInferenceChatCommand
|
|
66
|
+
: fallback.handleLocalInferenceChatCommand,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return fallback;
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
32
73
|
return localInferenceChatApiPromise;
|
|
33
74
|
}
|
|
34
75
|
const CHAT_MAX_BODY_BYTES = 20 * 1024 * 1024; // 20 MB (image-capable)
|
|
@@ -1016,6 +1057,9 @@ export function writeSse(res, payload) {
|
|
|
1016
1057
|
export function writeChatTokenSse(res, text, fullText) {
|
|
1017
1058
|
writeSse(res, { type: "token", text, fullText });
|
|
1018
1059
|
}
|
|
1060
|
+
export function writeChatStatusSse(res, status) {
|
|
1061
|
+
writeSse(res, { type: "status", ...status });
|
|
1062
|
+
}
|
|
1019
1063
|
export function writeSseData(res, data, event) {
|
|
1020
1064
|
if (res.writableEnded || res.destroyed)
|
|
1021
1065
|
return;
|
|
@@ -1321,6 +1365,22 @@ export async function generateChatResponse(runtime, message, agentName, opts) {
|
|
|
1321
1365
|
message.content.source.trim().length > 0
|
|
1322
1366
|
? message.content.source
|
|
1323
1367
|
: "api";
|
|
1368
|
+
// De-duped status emitter for the rich indicator. Coalesces repeats of the
|
|
1369
|
+
// same phase (an action firing many callbacks should emit one
|
|
1370
|
+
// `running_action`, not one per chunk) by tracking the last signature.
|
|
1371
|
+
let lastStatusSignature = "";
|
|
1372
|
+
const emitStatus = (status) => {
|
|
1373
|
+
if (!opts?.onStatus)
|
|
1374
|
+
return;
|
|
1375
|
+
const signature = `${status.kind}:${status.actionName ?? ""}:${status.toolName ?? ""}`;
|
|
1376
|
+
if (signature === lastStatusSignature)
|
|
1377
|
+
return;
|
|
1378
|
+
lastStatusSignature = signature;
|
|
1379
|
+
opts.onStatus(status);
|
|
1380
|
+
};
|
|
1381
|
+
// `thinking` is the opening phase: the turn started, the model is being
|
|
1382
|
+
// prompted, but no visible text has streamed yet.
|
|
1383
|
+
emitStatus({ kind: "thinking" });
|
|
1324
1384
|
const emitChunk = (chunk) => {
|
|
1325
1385
|
if (!chunk)
|
|
1326
1386
|
return;
|
|
@@ -1341,6 +1401,11 @@ export async function generateChatResponse(runtime, message, agentName, opts) {
|
|
|
1341
1401
|
const claimStreamSource = (source) => {
|
|
1342
1402
|
if (activeStreamSource === "unset") {
|
|
1343
1403
|
activeStreamSource = source;
|
|
1404
|
+
// The first claim is the thinking→producing transition. Raw LLM tokens
|
|
1405
|
+
// are `streaming`; an action handler producing the reply is
|
|
1406
|
+
// `running_action` (its name is stamped by recordActionCallback).
|
|
1407
|
+
if (source === "onStreamChunk")
|
|
1408
|
+
emitStatus({ kind: "streaming" });
|
|
1344
1409
|
return true;
|
|
1345
1410
|
}
|
|
1346
1411
|
return activeStreamSource === source;
|
|
@@ -1467,6 +1532,16 @@ export async function generateChatResponse(runtime, message, agentName, opts) {
|
|
|
1467
1532
|
if (normalizedActionTag) {
|
|
1468
1533
|
seenActionTags.add(normalizedActionTag);
|
|
1469
1534
|
}
|
|
1535
|
+
// The reply is now coming from an action handler, not raw LLM streaming —
|
|
1536
|
+
// surface it as `running_action`, carrying the concrete action name (when
|
|
1537
|
+
// it is a real action rather than the generic VISIBLE_CALLBACK tag) so the
|
|
1538
|
+
// status reads e.g. "Running SEND_MESSAGE" instead of generic "Working".
|
|
1539
|
+
emitStatus({
|
|
1540
|
+
kind: "running_action",
|
|
1541
|
+
...(normalizedActionTag && normalizedActionTag !== "VISIBLE_CALLBACK"
|
|
1542
|
+
? { actionName: normalizedActionTag }
|
|
1543
|
+
: {}),
|
|
1544
|
+
});
|
|
1470
1545
|
runtime.logger.info({
|
|
1471
1546
|
src: "eliza-api",
|
|
1472
1547
|
action: normalizedActionTag || actionTag,
|
package/api/commands-routes.d.ts
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Serves the connector-neutral command catalog in wire-safe form so client
|
|
5
5
|
* surfaces (the web chat composer, the TUI) discover and render one source of
|
|
6
|
-
* truth.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* truth. Scoped to a surface with `?surface=gui|tui|discord|telegram` — the
|
|
7
|
+
* surface actually filters the result (commands declare the `surfaces` they
|
|
8
|
+
* belong to) and is echoed in the response.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* This route is a *runtime-scoped projection*: it calls
|
|
11
|
+
* `getCatalogCommands(surface, { agentId })` from `@elizaos/plugin-commands`,
|
|
12
|
+
* which runs every enabled `CommandDefinition` through `serializeCommand`. The
|
|
13
|
+
* route fabricates nothing — `surfaces`, `requiresAuth`, `requiresElevated`,
|
|
14
|
+
* `category`, `dynamicChoices`, `icon`, and the full `textAliases` all come
|
|
15
|
+
* straight from the definitions (#8790).
|
|
14
16
|
*
|
|
15
|
-
* Response: `{ commands:
|
|
17
|
+
* Response: `{ commands: SerializedCommand[], surface, activeViewId, agentId, generatedAt }`.
|
|
16
18
|
*/
|
|
17
19
|
import type http from "node:http";
|
|
18
20
|
import type { AgentRuntime } from "@elizaos/core";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands-routes.d.ts","sourceRoot":"","sources":["../../src/api/commands-routes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"commands-routes.d.ts","sourceRoot":"","sources":["../../src/api/commands-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAalD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC;IAC1B,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,OAAO,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC;CAC1C;AAED,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,OAAO,CAAC,CAkClB"}
|
package/api/commands-routes.js
CHANGED
|
@@ -3,18 +3,20 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Serves the connector-neutral command catalog in wire-safe form so client
|
|
5
5
|
* surfaces (the web chat composer, the TUI) discover and render one source of
|
|
6
|
-
* truth.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* truth. Scoped to a surface with `?surface=gui|tui|discord|telegram` — the
|
|
7
|
+
* surface actually filters the result (commands declare the `surfaces` they
|
|
8
|
+
* belong to) and is echoed in the response.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* This route is a *runtime-scoped projection*: it calls
|
|
11
|
+
* `getCatalogCommands(surface, { agentId })` from `@elizaos/plugin-commands`,
|
|
12
|
+
* which runs every enabled `CommandDefinition` through `serializeCommand`. The
|
|
13
|
+
* route fabricates nothing — `surfaces`, `requiresAuth`, `requiresElevated`,
|
|
14
|
+
* `category`, `dynamicChoices`, `icon`, and the full `textAliases` all come
|
|
15
|
+
* straight from the definitions (#8790).
|
|
14
16
|
*
|
|
15
|
-
* Response: `{ commands:
|
|
17
|
+
* Response: `{ commands: SerializedCommand[], surface, activeViewId, agentId, generatedAt }`.
|
|
16
18
|
*/
|
|
17
|
-
import {
|
|
19
|
+
import { getCatalogCommands } from "@elizaos/plugin-commands";
|
|
18
20
|
import { getCurrentViewState } from "./views-routes.js";
|
|
19
21
|
const VALID_SURFACES = new Set([
|
|
20
22
|
"gui",
|
|
@@ -22,55 +24,6 @@ const VALID_SURFACES = new Set([
|
|
|
22
24
|
"discord",
|
|
23
25
|
"telegram",
|
|
24
26
|
]);
|
|
25
|
-
/** Map a catalog option onto a client arg, tagging known dynamic sources. */
|
|
26
|
-
function mapOption(option) {
|
|
27
|
-
const dynamicChoices = option.name === "section" ? "settings-sections" : undefined;
|
|
28
|
-
return {
|
|
29
|
-
name: option.name,
|
|
30
|
-
description: option.description,
|
|
31
|
-
required: option.required,
|
|
32
|
-
choices: option.choices,
|
|
33
|
-
...(dynamicChoices ? { dynamicChoices } : {}),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/** Map the connector-neutral target onto the client target shape. */
|
|
37
|
-
function mapTarget(target) {
|
|
38
|
-
if (target.kind === "navigate") {
|
|
39
|
-
// Pass the catalog's routing hints through verbatim: the GUI opens `tab`
|
|
40
|
-
// (or `viewId`) directly; `path` is the connector deep link; `section`
|
|
41
|
-
// focuses a settings sub-section.
|
|
42
|
-
return {
|
|
43
|
-
kind: "navigate",
|
|
44
|
-
path: target.path,
|
|
45
|
-
...(target.tab ? { tab: target.tab } : {}),
|
|
46
|
-
...(target.viewId ? { viewId: target.viewId } : {}),
|
|
47
|
-
...(target.section ? { section: target.section } : {}),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (target.kind === "client") {
|
|
51
|
-
return { kind: "client", clientAction: target.clientAction };
|
|
52
|
-
}
|
|
53
|
-
return { kind: "agent" };
|
|
54
|
-
}
|
|
55
|
-
/** Project a `ConnectorCommand` onto the wire-safe `SlashCommandCatalogItem`. */
|
|
56
|
-
function toCatalogItem(command) {
|
|
57
|
-
return {
|
|
58
|
-
key: command.name,
|
|
59
|
-
nativeName: command.name,
|
|
60
|
-
description: command.description,
|
|
61
|
-
textAliases: [`/${command.name}`],
|
|
62
|
-
scope: "both",
|
|
63
|
-
acceptsArgs: command.options.length > 0,
|
|
64
|
-
args: command.options.map(mapOption),
|
|
65
|
-
requiresAuth: false,
|
|
66
|
-
requiresElevated: false,
|
|
67
|
-
target: mapTarget(command.target),
|
|
68
|
-
source: "builtin",
|
|
69
|
-
...(command.views && command.views.length > 0
|
|
70
|
-
? { views: command.views }
|
|
71
|
-
: {}),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
27
|
export async function handleCommandsRoutes(ctx) {
|
|
75
28
|
const { res, method, pathname, url, json, error, runtime } = ctx;
|
|
76
29
|
if (pathname !== "/api/commands")
|
|
@@ -87,7 +40,12 @@ export async function handleCommandsRoutes(ctx) {
|
|
|
87
40
|
// Prefer an explicit ?view= (the client knows what it is rendering), else fall
|
|
88
41
|
// back to the agent's server-side current view.
|
|
89
42
|
const activeViewId = url.searchParams.get("view") ?? getCurrentViewState()?.viewId ?? null;
|
|
90
|
-
|
|
43
|
+
// Absent `?surface=` defaults to the web composer's surface (its historical
|
|
44
|
+
// consumer); an explicit surface filters to exactly that surface's commands.
|
|
45
|
+
const commands = getCatalogCommands(surface ?? "gui", {
|
|
46
|
+
activeViewId,
|
|
47
|
+
agentId: runtime?.agentId ?? null,
|
|
48
|
+
});
|
|
91
49
|
json(res, {
|
|
92
50
|
commands,
|
|
93
51
|
surface,
|
package/api/config-routes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type http from "node:http";
|
|
2
2
|
import { type AgentRuntime } from "@elizaos/core";
|
|
3
3
|
import type { ReadJsonBodyOptions } from "@elizaos/shared";
|
|
4
|
-
import type { ElizaConfig } from "../config/config.
|
|
4
|
+
import type { ElizaConfig } from "../config/config.js";
|
|
5
5
|
export interface ConfigRouteContext {
|
|
6
6
|
req: http.IncomingMessage;
|
|
7
7
|
res: http.ServerResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-routes.d.ts","sourceRoot":"","sources":["../../src/api/config-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAS3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AASvD,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC;IAC1B,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,WAAW,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OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEvB,mBAAmB,EAAE,CACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,kCAAkC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7D,6BAA6B,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IAC9E,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,6BAA6B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,0BAA0B,EAAE,CAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5B,wCAAwC,EAAE,CACxC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,IAAI,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,KAC7B;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAChD;AAqLD;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,OAAO,CAAC,CA2WlB"}
|
package/api/config-routes.js
CHANGED
|
@@ -272,7 +272,6 @@ export async function handleConfigRoutes(ctx) {
|
|
|
272
272
|
delete envPatch.ELIZA_API_TOKEN;
|
|
273
273
|
delete envPatch.ELIZA_WALLET_EXPORT_TOKEN;
|
|
274
274
|
delete envPatch.ELIZA_TERMINAL_RUN_TOKEN;
|
|
275
|
-
delete envPatch.HYPERSCAPE_AUTH_TOKEN;
|
|
276
275
|
delete envPatch.EVM_PRIVATE_KEY;
|
|
277
276
|
delete envPatch.SOLANA_PRIVATE_KEY;
|
|
278
277
|
delete envPatch.GITHUB_TOKEN;
|
|
@@ -283,7 +282,6 @@ export async function handleConfigRoutes(ctx) {
|
|
|
283
282
|
delete vars.ELIZA_API_TOKEN;
|
|
284
283
|
delete vars.ELIZA_WALLET_EXPORT_TOKEN;
|
|
285
284
|
delete vars.ELIZA_TERMINAL_RUN_TOKEN;
|
|
286
|
-
delete vars.HYPERSCAPE_AUTH_TOKEN;
|
|
287
285
|
delete vars.EVM_PRIVATE_KEY;
|
|
288
286
|
delete vars.SOLANA_PRIVATE_KEY;
|
|
289
287
|
delete vars.GITHUB_TOKEN;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type http from "node:http";
|
|
2
2
|
import type { IAgentRuntime, ReadJsonBodyOptions } from "@elizaos/core";
|
|
3
|
-
import type { ElizaConfig } from "../config/config.
|
|
3
|
+
import type { ElizaConfig } from "../config/config.js";
|
|
4
4
|
export interface ConnectorRouteContext {
|
|
5
5
|
req: http.IncomingMessage;
|
|
6
6
|
res: http.ServerResponse;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonValue, Room } from "@elizaos/core";
|
|
2
|
-
import type { ConversationMeta, ConversationMetadata } from "./server-types.
|
|
2
|
+
import type { ConversationMeta, ConversationMetadata } from "./server-types.js";
|
|
3
3
|
type RoomMetadataRecord = Record<string, JsonValue>;
|
|
4
4
|
export declare function sanitizeConversationMetadata(value: unknown): ConversationMetadata | undefined;
|
|
5
5
|
export declare function buildConversationRoomMetadata(conversation: Pick<ConversationMeta, "id" | "metadata">, ownerId: string, existingMetadata?: unknown): RoomMetadataRecord;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-metadata.d.ts","sourceRoot":"","sources":["../../src/api/conversation-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EAErB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation-metadata.d.ts","sourceRoot":"","sources":["../../src/api/conversation-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EAErB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AA2BpD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,oBAAoB,GAAG,SAAS,CAqElC;AAED,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,UAAU,CAAC,EACvD,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,OAAO,GACzB,kBAAkB,CAkBpB;AAED,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,SAAS,EAC/C,sBAAsB,CAAC,EAAE,MAAM,GAC9B,oBAAoB,GAAG,SAAS,CAkBlC;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,GAChD,OAAO,CAOT;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,GAChD,OAAO,CAGT"}
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { RouteRequestContext } from "@elizaos/core";
|
|
16
16
|
import { type AgentRuntime, type Content, type UUID } from "@elizaos/core";
|
|
17
|
-
import type { ElizaConfig } from "../config/config.
|
|
18
|
-
import type { ChatGenerationResult, LogEntry } from "./chat-routes.
|
|
19
|
-
import type { ConversationMeta } from "./server-types.
|
|
17
|
+
import type { ElizaConfig } from "../config/config.js";
|
|
18
|
+
import type { ChatGenerationResult, LogEntry } from "./chat-routes.js";
|
|
19
|
+
import type { ConversationMeta } from "./server-types.js";
|
|
20
20
|
export interface ConversationRouteState {
|
|
21
21
|
runtime: AgentRuntime | null;
|
|
22
22
|
/** Current agent lifecycle state (mirrors ServerState.agentState). */
|
|
@@ -33,6 +33,7 @@ export interface ConversationRouteState {
|
|
|
33
33
|
chatUserId: UUID | null;
|
|
34
34
|
logBuffer: LogEntry[];
|
|
35
35
|
conversations: Map<string, ConversationMeta>;
|
|
36
|
+
activeChatTurnCount: number;
|
|
36
37
|
conversationRestorePromise: Promise<void> | null;
|
|
37
38
|
deletedConversationIds: Set<string>;
|
|
38
39
|
broadcastWs: ((data: object) => void) | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-routes.d.ts","sourceRoot":"","sources":["../../src/api/conversation-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,OAAO,EAIZ,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation-routes.d.ts","sourceRoot":"","sources":["../../src/api/conversation-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,OAAO,EA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AG,MAAM,EAAE,CAqBvE;AASD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,qBAAqB,GAAE,SAAS,MAAM,EAAO,GAC5C,MAAM,CAYR;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EACF,IAAI,CACF,oBAAoB,EACpB,uBAAuB,GAAG,iBAAiB,GAAG,kBAAkB,CACjE,GACD,IAAI,GACJ,SAAS,GACZ,OAAO,CA8BT;AAED,wBAAsB,2CAA2C,CAC/D,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,IAAI,EACZ,qBAAqB,EAAE,SAAS,MAAM,EAAE,EACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAoElB;AAwBD,KAAK,2BAA2B,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAWF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC3C,2BAA2B,EAAE,GAAG,SAAS,CAwB3C;AA6KD,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,wBAAwB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAu3ClB"}
|
|
@@ -18,7 +18,7 @@ import path from "node:path";
|
|
|
18
18
|
import { ChannelType, createMessageMemory, logger, stringToUuid, } from "@elizaos/core";
|
|
19
19
|
import { PatchConversationRequestSchema, PostConversationCleanupEmptyRequestSchema, PostConversationRequestSchema, PostConversationTruncateRequestSchema, } from "@elizaos/shared";
|
|
20
20
|
import { resolveStateDir } from "../config/paths.js";
|
|
21
|
-
import { classifyChatFailure, generateChatResponse, generateConversationTitle, getChatFailureReply, hasRecentVisibleAssistantMemorySince, initSse, normalizeChatResponseText, persistAssistantConversationMemory, persistConversationMemory, readChatRequestPayload, resolveNoResponseFallback, writeChatTokenSse, writeSse, writeSseJson, } from "./chat-routes.js";
|
|
21
|
+
import { classifyChatFailure, generateChatResponse, generateConversationTitle, getChatFailureReply, hasRecentVisibleAssistantMemorySince, initSse, normalizeChatResponseText, persistAssistantConversationMemory, persistConversationMemory, readChatRequestPayload, resolveNoResponseFallback, writeChatStatusSse, writeChatTokenSse, writeSse, writeSseJson, } from "./chat-routes.js";
|
|
22
22
|
import { resolveClientChatAdminEntityId } from "./client-chat-admin.js";
|
|
23
23
|
import { buildConversationRoomMetadata, sanitizeConversationMetadata, } from "./conversation-metadata.js";
|
|
24
24
|
import { evictOldestConversation } from "./memory-bounds.js";
|
|
@@ -112,6 +112,16 @@ async function resolveRuntimeForChatTurn(state) {
|
|
|
112
112
|
}
|
|
113
113
|
return state.awaitRuntimeReady(WARMING_TURN_HOLD_MS);
|
|
114
114
|
}
|
|
115
|
+
function beginActiveChatTurn(state) {
|
|
116
|
+
state.activeChatTurnCount = Math.max(0, state.activeChatTurnCount) + 1;
|
|
117
|
+
let ended = false;
|
|
118
|
+
return () => {
|
|
119
|
+
if (ended)
|
|
120
|
+
return;
|
|
121
|
+
ended = true;
|
|
122
|
+
state.activeChatTurnCount = Math.max(0, state.activeChatTurnCount - 1);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
115
125
|
// ---------------------------------------------------------------------------
|
|
116
126
|
// Closure-lifted helpers
|
|
117
127
|
// ---------------------------------------------------------------------------
|
|
@@ -861,12 +871,16 @@ export async function handleConversationRoutes(ctx) {
|
|
|
861
871
|
? normalizeChatResponseText(rawText, state.logBuffer, runtime)
|
|
862
872
|
: rawText;
|
|
863
873
|
const attachments = serializeMessageAttachments(content);
|
|
874
|
+
const topics = Array.isArray(meta?.topics) && meta.topics.length > 0
|
|
875
|
+
? meta.topics.filter((topic) => typeof topic === "string")
|
|
876
|
+
: undefined;
|
|
864
877
|
return {
|
|
865
878
|
id: m.id ?? "",
|
|
866
879
|
role,
|
|
867
880
|
text,
|
|
868
881
|
timestamp: m.createdAt ?? 0,
|
|
869
882
|
...(attachments ? { attachments } : {}),
|
|
883
|
+
...(topics && topics.length > 0 ? { topics } : {}),
|
|
870
884
|
source: normalizedSource,
|
|
871
885
|
actionName,
|
|
872
886
|
actionCallbackHistory: actionCallbackHistory.length > 0
|
|
@@ -1236,6 +1250,7 @@ export async function handleConversationRoutes(ctx) {
|
|
|
1236
1250
|
}
|
|
1237
1251
|
const walletModeGuidance = resolveWalletModeGuidanceReply(state, prompt);
|
|
1238
1252
|
if (walletModeGuidance) {
|
|
1253
|
+
const endActiveChatTurn = beginActiveChatTurn(state);
|
|
1239
1254
|
initSse(res);
|
|
1240
1255
|
try {
|
|
1241
1256
|
if (!disconnectTracker.isAborted()) {
|
|
@@ -1260,10 +1275,12 @@ export async function handleConversationRoutes(ctx) {
|
|
|
1260
1275
|
}
|
|
1261
1276
|
finally {
|
|
1262
1277
|
finishStreamResponse();
|
|
1278
|
+
endActiveChatTurn();
|
|
1263
1279
|
}
|
|
1264
1280
|
return true;
|
|
1265
1281
|
}
|
|
1266
1282
|
// ── Local runtime path (streaming) ───────────────────────
|
|
1283
|
+
const endActiveChatTurn = beginActiveChatTurn(state);
|
|
1267
1284
|
initSse(res);
|
|
1268
1285
|
writeConversationStreamHeartbeat(res, disconnectTracker);
|
|
1269
1286
|
// SSE heartbeat to keep connection alive during long generation
|
|
@@ -1282,6 +1299,13 @@ export async function handleConversationRoutes(ctx) {
|
|
|
1282
1299
|
const result = await generateChatResponse(runtime, userMessage, state.agentName, {
|
|
1283
1300
|
isAborted: () => disconnectTracker.isAborted(),
|
|
1284
1301
|
abortSignal: disconnectTracker.signal,
|
|
1302
|
+
onStatus: (status) => {
|
|
1303
|
+
if (disconnectTracker.isAborted() ||
|
|
1304
|
+
disconnectTracker.checkConnectionClosed()) {
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
writeChatStatusSse(res, status);
|
|
1308
|
+
},
|
|
1285
1309
|
onChunk: (chunk) => {
|
|
1286
1310
|
if (!chunk)
|
|
1287
1311
|
return;
|
|
@@ -1439,6 +1463,7 @@ export async function handleConversationRoutes(ctx) {
|
|
|
1439
1463
|
finally {
|
|
1440
1464
|
clearInterval(heartbeatInterval);
|
|
1441
1465
|
finishStreamResponse();
|
|
1466
|
+
endActiveChatTurn();
|
|
1442
1467
|
// Persistence runs after the client has already received `done` + the
|
|
1443
1468
|
// socket is closed. Failures must still be observable — never swallow.
|
|
1444
1469
|
if (deferredPersistence !== null) {
|
|
@@ -1507,6 +1532,7 @@ export async function handleConversationRoutes(ctx) {
|
|
|
1507
1532
|
}
|
|
1508
1533
|
const walletModeGuidance = resolveWalletModeGuidanceReply(state, prompt);
|
|
1509
1534
|
if (walletModeGuidance) {
|
|
1535
|
+
const endActiveChatTurn = beginActiveChatTurn(state);
|
|
1510
1536
|
try {
|
|
1511
1537
|
await persistAssistantConversationMemory(runtime, conv.roomId, walletModeGuidance, channelType, turnStartedAt);
|
|
1512
1538
|
conv.updatedAt = new Date().toISOString();
|
|
@@ -1518,8 +1544,12 @@ export async function handleConversationRoutes(ctx) {
|
|
|
1518
1544
|
catch (persistErr) {
|
|
1519
1545
|
error(res, getErrorMessage(persistErr), 500);
|
|
1520
1546
|
}
|
|
1547
|
+
finally {
|
|
1548
|
+
endActiveChatTurn();
|
|
1549
|
+
}
|
|
1521
1550
|
return true;
|
|
1522
1551
|
}
|
|
1552
|
+
const endActiveChatTurn = beginActiveChatTurn(state);
|
|
1523
1553
|
try {
|
|
1524
1554
|
const result = await generateChatResponse(runtime, userMessage, state.agentName, {
|
|
1525
1555
|
resolveNoResponseText: () => resolveNoResponseFallback(state.logBuffer, runtime),
|
|
@@ -1574,6 +1604,9 @@ export async function handleConversationRoutes(ctx) {
|
|
|
1574
1604
|
error(res, getErrorMessage(persistErr), 500);
|
|
1575
1605
|
}
|
|
1576
1606
|
}
|
|
1607
|
+
finally {
|
|
1608
|
+
endActiveChatTurn();
|
|
1609
|
+
}
|
|
1577
1610
|
return true;
|
|
1578
1611
|
}
|
|
1579
1612
|
// ── POST /api/conversations/:id/greeting ───────────────────────────
|
|
@@ -62,15 +62,11 @@ export interface DocumentsServiceLike {
|
|
|
62
62
|
deleteDocument?(documentId: UUID, message?: Memory): Promise<void>;
|
|
63
63
|
deleteMemory(memoryId: UUID): Promise<void>;
|
|
64
64
|
}
|
|
65
|
-
/** Alias kept for backwards-compatible plugin imports. */
|
|
66
|
-
export type DocumentServiceLike = DocumentsServiceLike;
|
|
67
65
|
export type DocumentsLoadFailReason = "timeout" | "runtime_unavailable" | "not_registered";
|
|
68
66
|
export interface DocumentsServiceResult {
|
|
69
67
|
service: DocumentsServiceLike | null;
|
|
70
68
|
reason?: DocumentsLoadFailReason;
|
|
71
69
|
}
|
|
72
70
|
export declare function getDocumentsServiceTimeoutMs(): number;
|
|
73
|
-
/** Alias kept for backwards-compatible plugin imports. */
|
|
74
|
-
export declare const getDocumentsTimeoutMs: typeof getDocumentsServiceTimeoutMs;
|
|
75
71
|
export declare function getDocumentsService(runtime: AgentRuntime | null): Promise<DocumentsServiceResult>;
|
|
76
72
|
//# sourceMappingURL=documents-service-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents-service-loader.d.ts","sourceRoot":"","sources":["../../src/api/documents-service-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM,eAAe,CAAC;AAKzE,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,eAAe,GACf,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,OAAO,G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,CAAC;IACnE,YAAY,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,
|
|
1
|
+
{"version":3,"file":"documents-service-loader.d.ts","sourceRoot":"","sources":["../../src/api/documents-service-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM,eAAe,CAAC;AAKzE,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,eAAe,GACf,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,QAAQ,GACR,KAAK,GACL,MAAM,GACN,kBAAkB,GAClB,kBAAkB,GAClB,SAAS,GACT,cAAc,GACd,WAAW,CAAC;AAEhB,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,OAAO,EAAE;QACnB,OAAO,CAAC,EAAE,IAAI,CAAC;QACf,OAAO,EAAE,IAAI,CAAC;QACd,MAAM,EAAE,IAAI,CAAC;QACb,QAAQ,EAAE,IAAI,CAAC;QACf,gBAAgB,EAAE,IAAI,CAAC;QACvB,WAAW,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE,MAAM,CAAC;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,KAAK,CAAC,EAAE,uBAAuB,CAAC;QAChC,gBAAgB,CAAC,EAAE,IAAI,CAAC;QACxB,OAAO,CAAC,EAAE,IAAI,CAAC;QACf,WAAW,CAAC,EAAE,mBAAmB,CAAC;QAClC,SAAS,CAAC,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;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M,CAAC,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,cAAc,CAAC,OAAO,EAAE;QACtB,UAAU,EAAE,IAAI,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QACV,UAAU,EAAE,IAAI,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,cAAc,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,YAAY,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,qBAAqB,GACrB,gBAAgB,CAAC;AAErB,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAClC;AAKD,wBAAgB,4BAA4B,IAAI,MAAM,CAMrD;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,YAAY,GAAG,IAAI,GAC3B,OAAO,CAAC,sBAAsB,CAAC,CAwBjC"}
|
|
@@ -9,8 +9,6 @@ export function getDocumentsServiceTimeoutMs() {
|
|
|
9
9
|
return DEFAULT_TIMEOUT_MS;
|
|
10
10
|
return Math.min(parsed, MAX_TIMEOUT_MS);
|
|
11
11
|
}
|
|
12
|
-
/** Alias kept for backwards-compatible plugin imports. */
|
|
13
|
-
export const getDocumentsTimeoutMs = getDocumentsServiceTimeoutMs;
|
|
14
12
|
export async function getDocumentsService(runtime) {
|
|
15
13
|
if (!runtime) {
|
|
16
14
|
return { service: null, reason: "runtime_unavailable" };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authenticated Files API over the content-addressed media store: list and
|
|
3
|
+
* delete stored attachment bytes for the "Files" surface. Reads/writes go
|
|
4
|
+
* through the {@link IFileStorageService} (ServiceType.REMOTE_FILES), never the
|
|
5
|
+
* fs directly. Unlike the pre-auth media *serve* route (the sha256 is the
|
|
6
|
+
* capability), these privileged operations are auth-gated (PrivateRoute).
|
|
7
|
+
*/
|
|
8
|
+
import { type Route } from "@elizaos/core";
|
|
9
|
+
/** GET /api/files — list every stored file (newest first). */
|
|
10
|
+
export declare const filesListRoute: Route;
|
|
11
|
+
/** DELETE /api/files/:filename — delete one stored file (reference-unaware). */
|
|
12
|
+
export declare const fileDeleteRoute: Route;
|
|
13
|
+
export declare const filesRoutes: Route[];
|
|
14
|
+
//# sourceMappingURL=files-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-routes.d.ts","sourceRoot":"","sources":["../../src/api/files-routes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGL,KAAK,KAAK,EAEX,MAAM,eAAe,CAAC;AAQvB,8DAA8D;AAC9D,eAAO,MAAM,cAAc,EAAE,KAc5B,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,eAAe,EAAE,KAiB7B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,EAAsC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authenticated Files API over the content-addressed media store: list and
|
|
3
|
+
* delete stored attachment bytes for the "Files" surface. Reads/writes go
|
|
4
|
+
* through the {@link IFileStorageService} (ServiceType.REMOTE_FILES), never the
|
|
5
|
+
* fs directly. Unlike the pre-auth media *serve* route (the sha256 is the
|
|
6
|
+
* capability), these privileged operations are auth-gated (PrivateRoute).
|
|
7
|
+
*/
|
|
8
|
+
import { ServiceType, } from "@elizaos/core";
|
|
9
|
+
function getFileStorage(runtime) {
|
|
10
|
+
return (runtime.getService(ServiceType.REMOTE_FILES) ?? null);
|
|
11
|
+
}
|
|
12
|
+
/** GET /api/files — list every stored file (newest first). */
|
|
13
|
+
export const filesListRoute = {
|
|
14
|
+
type: "GET",
|
|
15
|
+
path: "/api/files",
|
|
16
|
+
rawPath: true,
|
|
17
|
+
name: "files-list",
|
|
18
|
+
routeHandler: async (ctx) => {
|
|
19
|
+
const storage = getFileStorage(ctx.runtime);
|
|
20
|
+
if (!storage) {
|
|
21
|
+
return { status: 503, body: { error: "file storage unavailable" } };
|
|
22
|
+
}
|
|
23
|
+
const files = await storage.list();
|
|
24
|
+
files.sort((a, b) => b.createdAt - a.createdAt);
|
|
25
|
+
return { status: 200, body: { files } };
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/** DELETE /api/files/:filename — delete one stored file (reference-unaware). */
|
|
29
|
+
export const fileDeleteRoute = {
|
|
30
|
+
type: "DELETE",
|
|
31
|
+
path: "/api/files/:filename",
|
|
32
|
+
rawPath: true,
|
|
33
|
+
name: "file-delete",
|
|
34
|
+
routeHandler: async (ctx) => {
|
|
35
|
+
const storage = getFileStorage(ctx.runtime);
|
|
36
|
+
if (!storage) {
|
|
37
|
+
return { status: 503, body: { error: "file storage unavailable" } };
|
|
38
|
+
}
|
|
39
|
+
const filename = ctx.params?.filename ?? "";
|
|
40
|
+
const deleted = await storage.delete(filename);
|
|
41
|
+
return {
|
|
42
|
+
status: deleted ? 200 : 404,
|
|
43
|
+
body: { deleted },
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
export const filesRoutes = [filesListRoute, fileDeleteRoute];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type http from "node:http";
|
|
2
2
|
import { type UUID } from "@elizaos/core";
|
|
3
3
|
import type { ReadJsonBodyOptions } from "@elizaos/shared";
|
|
4
|
-
import type { ElizaConfig } from "../config/config.
|
|
4
|
+
import type { ElizaConfig } from "../config/config.js";
|
|
5
5
|
export interface FirstRunRouteContext {
|
|
6
6
|
req: http.IncomingMessage;
|
|
7
7
|
res: http.ServerResponse;
|
package/api/health-routes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type http from "node:http";
|
|
2
2
|
import type { AgentRuntime } from "@elizaos/core";
|
|
3
|
-
import type { ElizaConfig } from "../config/config.
|
|
4
|
-
import type { ConnectorHealthMonitor } from "./connector-health.
|
|
3
|
+
import type { ElizaConfig } from "../config/config.js";
|
|
4
|
+
import type { ConnectorHealthMonitor } from "./connector-health.js";
|
|
5
5
|
interface PluginEntryLike {
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
configured: boolean;
|