@xopcai/xopc 0.0.82 → 0.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +2 -3
- package/dist/extensions/feishu/src/outbound/media-load.js.map +1 -1
- package/dist/extensions/feishu/src/schema/config-schema.d.ts +6 -6
- package/dist/extensions/telegram/src/config-schema.d.ts +6 -6
- package/dist/extensions/telegram/src/plugin.d.ts +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +3 -3
- package/dist/extensions/weixin/src/auth/accounts.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/config-schema.d.ts +3 -3
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
- package/dist/gateway/static/root/assets/agents-CrpYTHJS.js +222 -0
- package/dist/gateway/static/root/assets/{apps-page-pJ27dsqn.js → apps-page-1mcKh5Rh.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-zd6QNKPx.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-D1KYmOmi.js → channels-status-swr-uRAuhiUo.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-api-Y2wfSJVI.js → cron-api-O2Q_ruV6.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-B97KU_RG.js → cron-page-By09AQD-.js} +1 -1
- package/dist/gateway/static/root/assets/{dist-CboA_Css.js → dist-BpQxde0t.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DN_zNmpo.js → extension-debug-page-CY27wj_p.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BUXtOzv5.js → extension-page-C-Ed5ZmP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-C2dX4KCW.js → extension-settings-page-raLux7E7.js} +1 -1
- package/dist/gateway/static/root/assets/fetch-2iRFmd3n.js +3 -0
- package/dist/gateway/static/root/assets/{field-primitives-B9rOLqdm.js → field-primitives-fa_hiQcX.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-DvfiRVrc.js → heartbeat-config-api-BVl5VHvL.js} +1 -1
- package/dist/gateway/static/root/assets/index-BuFldCsB.css +1 -0
- package/dist/gateway/static/root/assets/{index-DQuaMye9.js → index-Y-iqo-gL.js} +94 -85
- package/dist/gateway/static/root/assets/{logs-page-BQuBpHcc.js → logs-page-BdH2n7ZW.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-Vpchzdp-.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-2Yu-FASs.js → settings-form-section-Kk1yAGBl.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-KBm0u6Dz.js +3 -0
- package/dist/gateway/static/root/assets/skills-page-BjeXXaOn.js +2 -0
- package/dist/gateway/static/root/assets/{theme-store-DnwYutiX.js → theme-store-D01dJt95.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-D2Gn2qod.js → utils-DpTxN4AF.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-CwO8Cf01.js +1 -0
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-instance-gateway.d.ts +50 -0
- package/dist/src/agent/agent-instance-gateway.js +1 -0
- package/dist/src/agent/agent-manager.d.ts +20 -14
- package/dist/src/agent/agent-manager.js +74 -186
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/background-review/coordinator.d.ts +61 -0
- package/dist/src/agent/background-review/coordinator.js +120 -0
- package/dist/src/agent/background-review/coordinator.js.map +1 -0
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
- package/dist/src/agent/child-agent-factory.d.ts +14 -0
- package/dist/src/agent/child-agent-factory.js +2 -8
- package/dist/src/agent/child-agent-factory.js.map +1 -1
- package/dist/src/agent/context/workspace-seed.js +3 -3
- package/dist/src/agent/embedded/index.d.ts +1 -2
- package/dist/src/agent/embedded/index.js +2 -3
- package/dist/src/agent/embedded/run-for-session.d.ts +2 -2
- package/dist/src/agent/embedded/run-for-session.js.map +1 -1
- package/dist/src/agent/embedded/runs.d.ts +32 -0
- package/dist/src/agent/embedded/runs.js +79 -19
- package/dist/src/agent/embedded/runs.js.map +1 -1
- package/dist/src/agent/embedded/session-manager-cache.d.ts +14 -0
- package/dist/src/agent/embedded/session-manager-cache.js +32 -11
- package/dist/src/agent/embedded/session-manager-cache.js.map +1 -1
- package/dist/src/agent/embedded/session-runner.d.ts +37 -7
- package/dist/src/agent/embedded/session-runner.js +184 -153
- package/dist/src/agent/embedded/session-runner.js.map +1 -1
- package/dist/src/agent/embedded/session-tool-result-guard.d.ts +57 -9
- package/dist/src/agent/embedded/session-tool-result-guard.js +159 -67
- package/dist/src/agent/embedded/session-tool-result-guard.js.map +1 -1
- package/dist/src/agent/goals/goal-run-store.js +4 -4
- package/dist/src/agent/goals/persistent-goal-service.d.ts +84 -0
- package/dist/src/agent/goals/persistent-goal-service.js +139 -0
- package/dist/src/agent/goals/persistent-goal-service.js.map +1 -0
- package/dist/src/agent/goals/post-turn.js +2 -2
- package/dist/src/agent/goals/state.d.ts +1 -1
- package/dist/src/agent/goals/state.js.map +1 -1
- package/dist/src/agent/image/load-image-media.js +1 -1
- package/dist/src/agent/inbound/inbound-loop.d.ts +77 -0
- package/dist/src/agent/inbound/inbound-loop.js +226 -0
- package/dist/src/agent/inbound/inbound-loop.js.map +1 -0
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +80 -0
- package/dist/src/agent/inbound/turn-dispatcher.js +138 -0
- package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -0
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/ipc/inbox.js +2 -2
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/lifecycle/handlers/compaction.d.ts +1 -1
- package/dist/src/agent/lifecycle/handlers/compaction.js.map +1 -1
- package/dist/src/agent/lifecycle/manager.d.ts +1 -1
- package/dist/src/agent/lifecycle/manager.js.map +1 -1
- package/dist/src/agent/lifecycle/types.d.ts +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
- package/dist/src/agent/memory/dreaming/events.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
- package/dist/src/agent/memory/dreaming/preview.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.d.ts +12 -2
- package/dist/src/agent/memory/dreaming/utils.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.js.map +1 -1
- package/dist/src/agent/memory/index.js +3 -3
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/memory/prefetch-coordinator.d.ts +37 -0
- package/dist/src/agent/memory/prefetch-coordinator.js +45 -0
- package/dist/src/agent/memory/prefetch-coordinator.js.map +1 -0
- package/dist/src/agent/messaging/command-handler.d.ts +5 -1
- package/dist/src/agent/messaging/command-handler.js +24 -96
- package/dist/src/agent/messaging/command-handler.js.map +1 -1
- package/dist/src/agent/messaging/index.d.ts +1 -0
- package/dist/src/agent/messaging/index.js +2 -1
- package/dist/src/agent/messaging/message-router.d.ts +1 -1
- package/dist/src/agent/messaging/message-router.js.map +1 -1
- package/dist/src/agent/messaging/outbound-coordinator.d.ts +82 -0
- package/dist/src/agent/messaging/outbound-coordinator.js +123 -0
- package/dist/src/agent/messaging/outbound-coordinator.js.map +1 -0
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/orchestration/agent-event-handler.d.ts +36 -33
- package/dist/src/agent/orchestration/agent-event-handler.js +212 -174
- package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +4 -4
- package/dist/src/agent/orchestration/agent-orchestrator.js +4 -8
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/orchestration/index.d.ts +1 -1
- package/dist/src/agent/orchestration/index.js +2 -2
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -4
- package/dist/src/agent/reply/post-compaction-context.js +1 -1
- package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
- package/dist/src/agent/sandbox/path-policy.js +1 -1
- package/dist/src/agent/service/async-queue.d.ts +20 -0
- package/dist/src/agent/service/async-queue.js +53 -0
- package/dist/src/agent/service/async-queue.js.map +1 -0
- package/dist/src/agent/service/build-direct-message-content.d.ts +2 -2
- package/dist/src/agent/service/build-direct-message-content.js.map +1 -1
- package/dist/src/agent/service/direct-turn-helpers.d.ts +70 -0
- package/dist/src/agent/service/direct-turn-helpers.js +90 -0
- package/dist/src/agent/service/direct-turn-helpers.js.map +1 -0
- package/dist/src/agent/service/process-direct-one-shot.d.ts +3 -3
- package/dist/src/agent/service/process-direct-one-shot.js +17 -34
- package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.d.ts +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +122 -168
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service/webchat-tts.d.ts +2 -2
- package/dist/src/agent/service/webchat-tts.js +1 -1
- package/dist/src/agent/service/webchat-tts.js.map +1 -1
- package/dist/src/agent/service.d.ts +62 -167
- package/dist/src/agent/service.js +177 -786
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/session/index.d.ts +4 -0
- package/dist/src/agent/session/index.js +5 -1
- package/dist/src/agent/session/session-config-service.d.ts +68 -0
- package/dist/src/agent/session/session-config-service.js +172 -0
- package/dist/src/agent/session/session-config-service.js.map +1 -0
- package/dist/src/agent/session/session-context.d.ts +27 -19
- package/dist/src/agent/session/session-context.js +39 -24
- package/dist/src/agent/session/session-context.js.map +1 -1
- package/dist/src/agent/session/session-hydrator.d.ts +42 -0
- package/dist/src/agent/session/session-hydrator.js +66 -0
- package/dist/src/agent/session/session-hydrator.js.map +1 -0
- package/dist/src/agent/session/session-inspector.d.ts +80 -0
- package/dist/src/agent/session/session-inspector.js +119 -0
- package/dist/src/agent/session/session-inspector.js.map +1 -0
- package/dist/src/agent/session/session-state-bag.d.ts +83 -0
- package/dist/src/agent/session/session-state-bag.js +192 -0
- package/dist/src/agent/session/session-state-bag.js.map +1 -0
- package/dist/src/agent/skills/config.js +1 -1
- package/dist/src/agent/skills/hub-hash.js +2 -2
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/index.d.ts +0 -2
- package/dist/src/agent/skills/index.js +3 -5
- package/dist/src/agent/skills/index.js.map +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js +11 -6
- package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js.map +1 -1
- package/dist/src/agent/skills/marketplace/adapters/skillhub/adapter.js +35 -7
- package/dist/src/agent/skills/marketplace/adapters/skillhub/adapter.js.map +1 -1
- package/dist/src/agent/skills/scanner.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +2 -2
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +7 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +37 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js.map +1 -1
- package/dist/src/agent/tools/delegate-tool.d.ts +7 -0
- package/dist/src/agent/tools/delegate-tool.js +2 -1
- package/dist/src/agent/tools/delegate-tool.js.map +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/executor.d.ts +34 -15
- package/dist/src/agent/tools/executor.js +44 -79
- package/dist/src/agent/tools/executor.js.map +1 -1
- package/dist/src/agent/tools/factory.d.ts +6 -0
- package/dist/src/agent/tools/factory.js +63 -4
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/skills-tools.js +1 -1
- package/dist/src/agent/tools/tts-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/workspace-runtime/registry.d.ts +48 -0
- package/dist/src/agent/workspace-runtime/registry.js +59 -0
- package/dist/src/agent/workspace-runtime/registry.js.map +1 -0
- package/dist/src/auth/credentials.js +3 -3
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/browser/cdp-local-launcher.js +4 -3
- package/dist/src/browser/cdp-local-launcher.js.map +1 -1
- package/dist/src/browser/index.d.ts +1 -0
- package/dist/src/browser/index.js +2 -1
- package/dist/src/browser/manager.js +3 -2
- package/dist/src/browser/manager.js.map +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +4 -4
- package/dist/src/browser/providers/browser-use.js +2 -1
- package/dist/src/browser/providers/browser-use.js.map +1 -1
- package/dist/src/browser/providers/browserbase.js +2 -1
- package/dist/src/browser/providers/browserbase.js.map +1 -1
- package/dist/src/browser/providers/cloakbrowser.js +7 -6
- package/dist/src/browser/providers/cloakbrowser.js.map +1 -1
- package/dist/src/browser/providers/playwright-doctor.d.ts +2 -0
- package/dist/src/browser/providers/playwright-doctor.js +7 -3
- package/dist/src/browser/providers/playwright-doctor.js.map +1 -1
- package/dist/src/browser/readiness.d.ts +33 -0
- package/dist/src/browser/readiness.js +138 -0
- package/dist/src/browser/readiness.js.map +1 -0
- package/dist/src/browser/stealth.js +2 -2
- package/dist/src/channels/attachments/inbound-persist.js +1 -1
- package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
- package/dist/src/channels/channel-domain.d.ts +1 -1
- package/dist/src/channels/config-helpers.d.ts +1 -1
- package/dist/src/channels/config-helpers.js.map +1 -1
- package/dist/src/channels/heartbeat-scheduler.d.ts +40 -0
- package/dist/src/channels/heartbeat-scheduler.js +94 -0
- package/dist/src/channels/heartbeat-scheduler.js.map +1 -0
- package/dist/src/channels/lifecycle-supervisor.d.ts +81 -0
- package/dist/src/channels/lifecycle-supervisor.js +263 -0
- package/dist/src/channels/lifecycle-supervisor.js.map +1 -0
- package/dist/src/channels/manager.d.ts +34 -68
- package/dist/src/channels/manager.js +107 -477
- package/dist/src/channels/manager.js.map +1 -1
- package/dist/src/channels/outbound/deliver.d.ts +1 -1
- package/dist/src/channels/outbound/deliver.js.map +1 -1
- package/dist/src/channels/outbound/persist-store.js +1 -1
- package/dist/src/channels/outbound-sender.d.ts +51 -0
- package/dist/src/channels/outbound-sender.js +125 -0
- package/dist/src/channels/outbound-sender.js.map +1 -0
- package/dist/src/channels/pairing/allow-from-file.js +1 -1
- package/dist/src/channels/pairing/pairing-service.d.ts +3 -10
- package/dist/src/channels/pairing/pairing-service.js.map +1 -1
- package/dist/src/channels/pairing/pairing-store.js +2 -2
- package/dist/src/channels/pairing/pairing-types.d.ts +15 -0
- package/dist/src/channels/pairing/pairing-types.js +1 -0
- package/dist/src/channels/plugin-registry.d.ts +22 -0
- package/dist/src/channels/plugin-registry.js +44 -0
- package/dist/src/channels/plugin-registry.js.map +1 -0
- package/dist/src/channels/plugin-types.d.ts +1 -1
- package/dist/src/channels/plugins/types.adapters.d.ts +2 -2
- package/dist/src/channels/security-helpers.d.ts +1 -1
- package/dist/src/channels/security-helpers.js.map +1 -1
- package/dist/src/channels/setup-wizard.d.ts +1 -1
- package/dist/src/chat-commands/builtins/config.js +2 -2
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/agent/stream-renderer.js +1 -1
- package/dist/src/cli/commands/agent/stream-renderer.js.map +1 -1
- package/dist/src/cli/commands/agent.js +4 -4
- package/dist/src/cli/commands/agent.js.map +1 -1
- package/dist/src/cli/commands/browser-cli-helpers.js +2 -1
- package/dist/src/cli/commands/browser-cli-helpers.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +2 -2
- package/dist/src/cli/commands/extension-dev.js.map +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension-marketplace.js.map +1 -1
- package/dist/src/cli/commands/extension-pack.js +1 -1
- package/dist/src/cli/commands/gateway/call.js +1 -1
- package/dist/src/cli/commands/gateway/call.js.map +1 -1
- package/dist/src/cli/commands/gateway/health.js +1 -1
- package/dist/src/cli/commands/gateway/health.js.map +1 -1
- package/dist/src/cli/commands/gateway/lifecycle-core.d.ts +31 -12
- package/dist/src/cli/commands/gateway/lifecycle-core.js +167 -116
- package/dist/src/cli/commands/gateway/lifecycle-core.js.map +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.d.ts +11 -0
- package/dist/src/cli/commands/gateway/lifecycle.js +102 -0
- package/dist/src/cli/commands/gateway/lifecycle.js.map +1 -0
- package/dist/src/cli/commands/gateway/logs.js +1 -1
- package/dist/src/cli/commands/gateway/logs.js.map +1 -1
- package/dist/src/cli/commands/gateway/probe.js +1 -1
- package/dist/src/cli/commands/gateway/probe.js.map +1 -1
- package/dist/src/cli/commands/gateway/restart-health.d.ts +12 -0
- package/dist/src/cli/commands/gateway/restart-health.js +45 -1
- package/dist/src/cli/commands/gateway/restart-health.js.map +1 -1
- package/dist/src/cli/commands/gateway/restart.js +3 -3
- package/dist/src/cli/commands/gateway/restart.js.map +1 -1
- package/dist/src/cli/commands/gateway/run-foreground.d.ts +0 -1
- package/dist/src/cli/commands/gateway/run-foreground.js +0 -35
- package/dist/src/cli/commands/gateway/run-foreground.js.map +1 -1
- package/dist/src/cli/commands/gateway/service.js +1 -1
- package/dist/src/cli/commands/gateway/service.js.map +1 -1
- package/dist/src/cli/commands/gateway/shared.d.ts +3 -0
- package/dist/src/cli/commands/gateway/shared.js +54 -0
- package/dist/src/cli/commands/gateway/shared.js.map +1 -0
- package/dist/src/cli/commands/gateway/status.js +1 -1
- package/dist/src/cli/commands/gateway/status.js.map +1 -1
- package/dist/src/cli/commands/gateway/stop.js +2 -2
- package/dist/src/cli/commands/gateway/stop.js.map +1 -1
- package/dist/src/cli/commands/gateway/token.js +1 -1
- package/dist/src/cli/commands/gateway/token.js.map +1 -1
- package/dist/src/cli/commands/gateway.js +5 -5
- package/dist/src/cli/commands/gateway.js.map +1 -1
- package/dist/src/cli/commands/image.js +2 -2
- package/dist/src/cli/commands/image.js.map +1 -1
- package/dist/src/cli/commands/init.js +4 -4
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/models.js.map +1 -1
- package/dist/src/cli/commands/onboard/gateway.d.ts +0 -8
- package/dist/src/cli/commands/onboard/gateway.js +48 -49
- package/dist/src/cli/commands/onboard/gateway.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +9 -64
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/cli/commands/session/utils.js +1 -1
- package/dist/src/cli/commands/session/utils.js.map +1 -1
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/commands/tailscale.js +1 -1
- package/dist/src/cli/commands/tailscale.js.map +1 -1
- package/dist/src/cli/context.d.ts +20 -0
- package/dist/src/cli/context.js +23 -0
- package/dist/src/cli/context.js.map +1 -0
- package/dist/src/cli/extension-cli-register.js +3 -3
- package/dist/src/cli/gateway-run-argv.js +1 -4
- package/dist/src/cli/gateway-run-argv.js.map +1 -1
- package/dist/src/cli/gateway-run-fast-path.js +1 -1
- package/dist/src/cli/gateway-run-fast-path.js.map +1 -1
- package/dist/src/cli/index.d.ts +1 -7
- package/dist/src/cli/index.js +4 -6
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -2
- package/dist/src/config/commands.flags.d.ts +3 -0
- package/dist/src/config/commands.flags.js +11 -0
- package/dist/src/config/commands.flags.js.map +1 -0
- package/dist/src/config/index.d.ts +1 -0
- package/dist/src/config/index.js +6 -5
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/profile.js +2 -2
- package/dist/src/config/schema.d.ts +11 -4
- package/dist/src/config/schema.js +13 -12
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/workspace-path-helpers.d.ts +15 -0
- package/dist/src/config/workspace-path-helpers.js +14 -0
- package/dist/src/config/workspace-path-helpers.js.map +1 -0
- package/dist/src/cron/executor.js +4 -4
- package/dist/src/cron/executor.js.map +1 -1
- package/dist/src/cron/persistence.js +1 -1
- package/dist/src/cron/run-log-store.js +1 -1
- package/dist/src/daemon/index.d.ts +0 -1
- package/dist/src/daemon/index.js +1 -2
- package/dist/src/daemon/install-plan.js +3 -2
- package/dist/src/daemon/install-plan.js.map +1 -1
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/daemon/types.d.ts +0 -6
- package/dist/src/extensions/api.d.ts +1 -1
- package/dist/src/extensions/api.js +2 -2
- package/dist/src/extensions/api.js.map +1 -1
- package/dist/src/extensions/bundle-mcp.js +1 -1
- package/dist/src/extensions/discover-extensions.js +1 -1
- package/dist/src/extensions/extension-registry-impl.d.ts +51 -0
- package/dist/src/extensions/extension-registry-impl.js +117 -0
- package/dist/src/extensions/extension-registry-impl.js.map +1 -0
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/index.js +3 -2
- package/dist/src/extensions/loader.d.ts +3 -43
- package/dist/src/extensions/loader.js +3 -110
- package/dist/src/extensions/loader.js.map +1 -1
- package/dist/src/extensions/lockfile.js +2 -2
- package/dist/src/extensions/sdk/index.js +2 -1
- package/dist/src/extensions/sdk/index.js.map +1 -1
- package/dist/src/extensions/types/events.d.ts +7 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +2 -2
- package/dist/src/gateway/heartbeat/service.js +2 -2
- package/dist/src/gateway/heartbeat/service.js.map +1 -1
- package/dist/src/gateway/hono/app.js +5 -53
- package/dist/src/gateway/hono/app.js.map +1 -1
- package/dist/src/gateway/hono/lib/extension-store.js +1 -1
- package/dist/src/gateway/hono/lib/static-ui.js +2 -2
- package/dist/src/gateway/hono/middleware/auth.d.ts +5 -14
- package/dist/src/gateway/hono/middleware/auth.js +89 -126
- package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
- package/dist/src/gateway/hono/middleware/logger.js +1 -1
- package/dist/src/gateway/hono/middleware/logger.js.map +1 -1
- package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +14 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +62 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js.map +1 -0
- package/dist/src/gateway/hono/oauth.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +4 -4
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js.map +1 -1
- package/dist/src/gateway/hono/routes/browser.d.ts +20 -0
- package/dist/src/gateway/hono/routes/browser.js +626 -0
- package/dist/src/gateway/hono/routes/browser.js.map +1 -0
- package/dist/src/gateway/hono/routes/commands-skills.js +13 -13
- package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/agents.d.ts +18 -0
- package/dist/src/gateway/hono/routes/config-patch/agents.js +418 -0
- package/dist/src/gateway/hono/routes/config-patch/agents.js.map +1 -0
- package/dist/src/gateway/hono/routes/config-patch/channels.d.ts +12 -0
- package/dist/src/gateway/hono/routes/config-patch/channels.js +186 -0
- package/dist/src/gateway/hono/routes/config-patch/channels.js.map +1 -0
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +18 -0
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +264 -0
- package/dist/src/gateway/hono/routes/config-patch/gateway.js.map +1 -0
- package/dist/src/gateway/hono/routes/config-patch/index.d.ts +9 -0
- package/dist/src/gateway/hono/routes/config-patch/index.js +6 -0
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +23 -0
- package/dist/src/gateway/hono/routes/config-patch/misc.js +139 -0
- package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -0
- package/dist/src/gateway/hono/routes/config-patch/result.d.ts +18 -0
- package/dist/src/gateway/hono/routes/config-patch/result.js +13 -0
- package/dist/src/gateway/hono/routes/config-patch/result.js.map +1 -0
- package/dist/src/gateway/hono/routes/config.js +20 -1764
- package/dist/src/gateway/hono/routes/config.js.map +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +2 -3
- package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
- package/dist/src/gateway/hono/routes/host-fs.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +10 -5
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +1 -2
- package/dist/src/gateway/hono/routes/mcp.js.map +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +32 -32
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/hono/routes/shares.js +4 -4
- package/dist/src/gateway/hono/routes/shares.js.map +1 -1
- package/dist/src/gateway/hono/routes/tunnel.js +1 -1
- package/dist/src/gateway/hono/routes/tunnel.js.map +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +6 -7
- package/dist/src/gateway/hono/routes/workspace.js.map +1 -1
- package/dist/src/gateway/hono/sse.js +2 -2
- package/dist/src/gateway/index.d.ts +1 -1
- package/dist/src/gateway/index.js +4 -2
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/rate-limit/auth-policy.d.ts +34 -0
- package/dist/src/gateway/rate-limit/auth-policy.js +49 -0
- package/dist/src/gateway/rate-limit/auth-policy.js.map +1 -0
- package/dist/src/gateway/rate-limit/buckets.d.ts +63 -0
- package/dist/src/gateway/rate-limit/buckets.js +143 -0
- package/dist/src/gateway/rate-limit/buckets.js.map +1 -0
- package/dist/src/gateway/rate-limit/env-flags.d.ts +13 -0
- package/dist/src/gateway/rate-limit/env-flags.js +16 -0
- package/dist/src/gateway/rate-limit/env-flags.js.map +1 -0
- package/dist/src/gateway/rate-limit/index.d.ts +3 -0
- package/dist/src/gateway/rate-limit/index.js +4 -0
- package/dist/src/gateway/run-loop.d.ts +1 -1
- package/dist/src/gateway/run-loop.js +24 -4
- package/dist/src/gateway/run-loop.js.map +1 -1
- package/dist/src/gateway/runtime-config.js +2 -1
- package/dist/src/gateway/runtime-config.js.map +1 -1
- package/dist/src/gateway/security/audit.js +2 -1
- package/dist/src/gateway/security/audit.js.map +1 -1
- package/dist/src/gateway/security/index.d.ts +0 -1
- package/dist/src/gateway/security/index.js +1 -2
- package/dist/src/gateway/security/loopback.d.ts +13 -0
- package/dist/src/gateway/security/loopback.js +45 -0
- package/dist/src/gateway/security/loopback.js.map +1 -0
- package/dist/src/gateway/service/agent-runner.d.ts +108 -0
- package/dist/src/gateway/service/agent-runner.js +184 -0
- package/dist/src/gateway/service/agent-runner.js.map +1 -0
- package/dist/src/gateway/service/config-coordinator.d.ts +119 -0
- package/dist/src/gateway/service/config-coordinator.js +351 -0
- package/dist/src/gateway/service/config-coordinator.js.map +1 -0
- package/dist/src/gateway/service/marketplace-service.d.ts +85 -0
- package/dist/src/gateway/service/marketplace-service.js +239 -0
- package/dist/src/gateway/service/marketplace-service.js.map +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +5 -5
- package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +125 -0
- package/dist/src/gateway/service/sessions-api.js +135 -0
- package/dist/src/gateway/service/sessions-api.js.map +1 -0
- package/dist/src/gateway/service.d.ts +30 -360
- package/dist/src/gateway/service.js +121 -903
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/gateway/workspace-heartbeat-path.js +1 -2
- package/dist/src/gateway/workspace-heartbeat-path.js.map +1 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/gateway-process-argv.d.ts +4 -0
- package/dist/src/infra/gateway-process-argv.js +26 -0
- package/dist/src/infra/gateway-process-argv.js.map +1 -0
- package/dist/src/infra/gateway-processes.d.ts +5 -0
- package/dist/src/infra/gateway-processes.js +65 -0
- package/dist/src/infra/gateway-processes.js.map +1 -0
- package/dist/src/infra/rate-limit/failure-limiter.d.ts +50 -0
- package/dist/src/infra/rate-limit/failure-limiter.js +100 -0
- package/dist/src/infra/rate-limit/failure-limiter.js.map +1 -0
- package/dist/src/infra/rate-limit/index.d.ts +5 -0
- package/dist/src/infra/rate-limit/index.js +3 -0
- package/dist/src/infra/rate-limit/keyed-store.d.ts +34 -0
- package/dist/src/infra/rate-limit/keyed-store.js +44 -0
- package/dist/src/infra/rate-limit/keyed-store.js.map +1 -0
- package/dist/src/infra/rate-limit/rate-limiter.d.ts +39 -0
- package/dist/src/infra/rate-limit/rate-limiter.js +65 -0
- package/dist/src/infra/rate-limit/rate-limiter.js.map +1 -0
- package/dist/src/infra/restart.d.ts +21 -0
- package/dist/src/infra/restart.js +122 -0
- package/dist/src/infra/restart.js.map +1 -0
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/infra/update-lock.js +3 -3
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +2 -2
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/mcp/channel-bridge.d.ts +0 -6
- package/dist/src/mcp/channel-bridge.js +1 -5
- package/dist/src/mcp/channel-bridge.js.map +1 -1
- package/dist/src/media-shared/http/ssrf-guard.js +1 -1
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/session/config-store.js +2 -2
- package/dist/src/session/parity/jsonl-transcript-io.js +2 -2
- package/dist/src/session/parity/sessions-json-file-read.d.ts +2 -1
- package/dist/src/session/parity/sessions-json-file-read.js.map +1 -1
- package/dist/src/session/parity/sessions-json-file.js +1 -1
- package/dist/src/session/parity/transcript-file-lock.js +2 -2
- package/dist/src/session/parity/transcript-paths.js +1 -1
- package/dist/src/session/search-index-cache.js +1 -1
- package/dist/src/session/search-index.js +1 -1
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.js +5 -5
- package/dist/src/share/share-rate-limit.d.ts +10 -2
- package/dist/src/share/share-rate-limit.js +33 -42
- package/dist/src/share/share-rate-limit.js.map +1 -1
- package/dist/src/share/share-store.js +3 -3
- package/dist/src/tui/backends/embedded-backend.js +16 -12
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/clipboard-image.js +2 -2
- package/dist/src/tui/extension-host/load-extensions.js +1 -1
- package/dist/src/tui/format-tui-hotkeys.js +1 -1
- package/dist/src/tui/theme-manager.js +1 -1
- package/dist/src/tui/tui-keybindings-file.js +1 -1
- package/dist/src/tui/tui-scoped-models.js +1 -1
- package/dist/src/tui/tui-settings.js +1 -1
- package/dist/src/tui/tui-skills-autocomplete.js +1 -1
- package/dist/src/tui/tui.js +1 -2
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/tui/xopc-tui-keybindings.d.ts +0 -1
- package/dist/src/tui/xopc-tui-keybindings.js +1 -2
- package/dist/src/tui/xopc-tui-keybindings.js.map +1 -1
- package/dist/src/tunnel/frpc-binary.js +2 -2
- package/dist/src/tunnel/frpc-config.js +1 -1
- package/dist/src/tunnel/frpc-extract.js +1 -1
- package/dist/src/tunnel/pairing-rate-limit.d.ts +10 -2
- package/dist/src/tunnel/pairing-rate-limit.js +19 -15
- package/dist/src/tunnel/pairing-rate-limit.js.map +1 -1
- package/dist/src/tunnel/tunnel-rate-limit.d.ts +6 -3
- package/dist/src/tunnel/tunnel-rate-limit.js +11 -22
- package/dist/src/tunnel/tunnel-rate-limit.js.map +1 -1
- package/dist/src/tunnel/tunnel-state.js +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/utils/logger/stats.d.ts +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/factory.js +1 -1
- package/dist/src/voice/tts/index.js +2 -2
- package/dist/src/voice/tts/merge-config.js +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +1 -1
- package/dist/src/voice/tts/service.js +1 -1
- package/dist/src/voice/tts/service.js.map +1 -1
- package/dist/src/voice/tts/speak-core.js +1 -1
- package/package.json +10 -5
- package/dist/gateway/static/root/assets/agents-Cqh1ts38.js +0 -222
- package/dist/gateway/static/root/assets/channels-settings-wTiWStg9.js +0 -1
- package/dist/gateway/static/root/assets/fetch-BAAh_kXG.js +0 -3
- package/dist/gateway/static/root/assets/index-C8yHX-AA.css +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BeiFm0Ms.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-RPAz_Wg_.js +0 -3
- package/dist/gateway/static/root/assets/skills-page-Wu4aNWDx.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-BxIGhhEL.js +0 -1
- package/dist/src/agent/embedded/session-raw-append-message.d.ts +0 -11
- package/dist/src/agent/embedded/session-raw-append-message.js +0 -15
- package/dist/src/agent/embedded/session-raw-append-message.js.map +0 -1
- package/dist/src/agent/embedded/session-tool-result-guard-wrapper.d.ts +0 -15
- package/dist/src/agent/embedded/session-tool-result-guard-wrapper.js +0 -24
- package/dist/src/agent/embedded/session-tool-result-guard-wrapper.js.map +0 -1
- package/dist/src/agent/embedded/session-tool-result-state.d.ts +0 -17
- package/dist/src/agent/embedded/session-tool-result-state.js +0 -26
- package/dist/src/agent/embedded/session-tool-result-state.js.map +0 -1
- package/dist/src/daemon/launchd-restart-handoff.d.ts +0 -25
- package/dist/src/daemon/launchd-restart-handoff.js +0 -132
- package/dist/src/daemon/launchd-restart-handoff.js.map +0 -1
- package/dist/src/gateway/auth-rate-limit.d.ts +0 -71
- package/dist/src/gateway/auth-rate-limit.js +0 -192
- package/dist/src/gateway/auth-rate-limit.js.map +0 -1
- package/dist/src/gateway/restart-handler.d.ts +0 -14
- package/dist/src/gateway/restart-handler.js +0 -64
- package/dist/src/gateway/restart-handler.js.map +0 -1
- package/dist/src/gateway/security/flood-guard.d.ts +0 -28
- package/dist/src/gateway/security/flood-guard.js +0 -42
- package/dist/src/gateway/security/flood-guard.js.map +0 -1
- package/dist/src/infra/rate-limit.d.ts +0 -38
- package/dist/src/infra/rate-limit.js +0 -60
- package/dist/src/infra/rate-limit.js.map +0 -1
- package/dist/src/infra/restart-intent.d.ts +0 -13
- package/dist/src/infra/restart-intent.js +0 -40
- package/dist/src/infra/restart-intent.js.map +0 -1
- package/dist/src/infra/restart-sentinel.d.ts +0 -23
- package/dist/src/infra/restart-sentinel.js +0 -75
- package/dist/src/infra/restart-sentinel.js.map +0 -1
- package/skills/creative/canvas-design/LICENSE.txt +0 -202
- package/skills/creative/canvas-design/SKILL-zh.md +0 -130
- package/skills/creative/canvas-design/SKILL.md +0 -130
- package/skills/creative/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/BigShoulders-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Boldonse-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/DMMono-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/EricaOne-OFL.txt +0 -94
- package/skills/creative/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/GeistMono-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Gloock-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Italiana-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Jura-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Lora-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/NationalPark-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Outfit-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/PixelifySans-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/PoiretOne-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/RedHatMono-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Silkscreen-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/SmoochSans-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/Tektur-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/WorkSans-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
- package/skills/creative/canvas-design/canvas-fonts/YoungSerif-OFL.txt +0 -93
- package/skills/creative/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
|
@@ -1,48 +1,35 @@
|
|
|
1
1
|
import { __toCommonJS } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { PACKAGE_VERSION, init_package_version } from "../package-version.js";
|
|
3
|
-
import { resolveStateDir } from "../config/paths-state.js";
|
|
4
|
-
import { getWorkspacePath, init_schema } from "../config/schema.js";
|
|
5
|
-
import { buildSessionKey, init_session_key, parseSessionKey } from "../routing/session-key.js";
|
|
6
|
-
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
7
3
|
import { getLogDir } from "../utils/logger/config.js";
|
|
8
4
|
import { getLogStats } from "../utils/logger/stats.js";
|
|
9
5
|
import { createLogger } from "../utils/logger/index.js";
|
|
10
6
|
import { init_logger } from "../utils/logger.js";
|
|
11
7
|
import { init_paths, resolveAgentDir, resolveConfigPath, resolveCronJobsPath, resolveExtensionsDir } from "../config/paths.js";
|
|
12
8
|
import { loadConfig, saveConfig } from "../config/loader.js";
|
|
13
|
-
import {
|
|
9
|
+
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
10
|
+
import { prewarmModelRegistry } from "../providers/model-registry.js";
|
|
14
11
|
import { init_providers, providers_exports } from "../providers/index.js";
|
|
15
|
-
import {
|
|
16
|
-
import { disposeAllSessionMcpRuntimes, retireSessionMcpRuntimeForSessionKey } from "../agent/mcp/bundle-mcp-runtime.js";
|
|
12
|
+
import { disposeAllSessionMcpRuntimes } from "../agent/mcp/bundle-mcp-runtime.js";
|
|
17
13
|
import "../agent/mcp/bundle-mcp-tools.js";
|
|
18
|
-
import { removeSkillsLockEntry } from "../agent/skills/hub-lock.js";
|
|
19
|
-
import { deleteManagedSkill, installSkillFromZip, listManagedSkillDirs } from "../agent/skills/managed-store.js";
|
|
20
|
-
import { MessageBus, MessageBusShutdownError } from "../infra/bus/queue.js";
|
|
21
|
-
import "../infra/bus/index.js";
|
|
22
14
|
import { SessionIndex } from "../session/manager.js";
|
|
23
15
|
import "../session/index.js";
|
|
24
16
|
import { areExtensionsGloballyDisabled } from "../extensions/discover-extensions.js";
|
|
25
17
|
import { registerClarifyBridge } from "./clarify-runtime.js";
|
|
26
18
|
import { setPairingBroadcastSink } from "../channels/pairing/pairing-events.js";
|
|
27
19
|
import { CHAT_CHANNEL_ORDER, getChatChannelMeta } from "../channels/registry.js";
|
|
20
|
+
import { getWorkspacePath } from "../config/workspace-path-helpers.js";
|
|
28
21
|
import { ExtensionLoader } from "../extensions/loader.js";
|
|
29
|
-
import { listRegisteredProviders } from "../agent/skills/marketplace/registry.js";
|
|
30
22
|
import { buildExtensionMetadataSnapshot } from "../extensions/extension-metadata-snapshot.js";
|
|
31
23
|
import "../extensions/index.js";
|
|
24
|
+
import { MessageBus, MessageBusShutdownError } from "../infra/bus/queue.js";
|
|
25
|
+
import "../infra/bus/index.js";
|
|
32
26
|
import { AgentService } from "../agent/service.js";
|
|
33
27
|
import { ChannelManager } from "../channels/manager.js";
|
|
34
|
-
import { ConfigHotReloader } from "../config/reload.js";
|
|
35
28
|
import "../config/index.js";
|
|
36
29
|
import { CronService } from "../cron/service.js";
|
|
37
30
|
import "../cron/index.js";
|
|
38
31
|
import { resolveEffectiveGatewayPort } from "./host.js";
|
|
39
|
-
import { computeBundledExtensionExtensionsPatch } from "../extensions/bundled-extension-activation.js";
|
|
40
|
-
import { getExtensionLockfileManager } from "../extensions/lockfile.js";
|
|
41
|
-
import { installExtensionFromStoreZip, peekExtensionIdFromStoreZip } from "../extensions/install.js";
|
|
42
|
-
import { AgentRunRelay } from "./agent-run-relay.js";
|
|
43
|
-
import { isGatewayStrictSecurityEnabled } from "./auth-rate-limit.js";
|
|
44
32
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
45
|
-
import { ClarifyBridge } from "./clarify-bridge.js";
|
|
46
33
|
import { HeartbeatService, heartbeatRunnerConfigFromConfig } from "./heartbeat/service.js";
|
|
47
34
|
import "./heartbeat/index.js";
|
|
48
35
|
import { wireTunnelEventsToGateway } from "../tunnel/gateway-lifecycle.js";
|
|
@@ -50,29 +37,27 @@ import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
|
|
|
50
37
|
import { getExposureManager } from "../remote-access/exposure-manager.js";
|
|
51
38
|
import { sanitizeTunnelConfig } from "../tunnel/tunnel-config.js";
|
|
52
39
|
import { assertGatewayAuthNotKnownWeak } from "./security/known-weak-secrets.js";
|
|
40
|
+
import { buckets } from "./rate-limit/buckets.js";
|
|
41
|
+
import { isGatewayStrictSecurityEnabled } from "./rate-limit/env-flags.js";
|
|
42
|
+
import "./rate-limit/index.js";
|
|
53
43
|
import { assertGatewayRuntimeConfig } from "./runtime-config.js";
|
|
54
44
|
import { auditGatewayConfig } from "./security/audit.js";
|
|
55
|
-
import { downloadExtensionStoreZipBuffer, fetchMarketplacePackageDetail, resolveExtensionZipDownloadUrl, resolveExtensionsStoreBaseUrl } from "../agent/skills/marketplace/adapters/store/store-api-client.js";
|
|
56
|
-
import { getMarketplaceProviderDisplayName, resolveSkillsMarketplaceProvider } from "../agent/skills/marketplace/resolve-adapter.js";
|
|
57
|
-
import { downloadFromMarketplace, getMarketplacePackageDetail, listMarketplaceCategories, listMarketplacePackages } from "../agent/skills/skills-marketplace.js";
|
|
58
45
|
import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
|
|
59
46
|
import { resolveChannelConnectDeferSet } from "./resolve-channel-connect-defer.js";
|
|
60
47
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
48
|
+
import { GatewaySessionsApi } from "./service/sessions-api.js";
|
|
49
|
+
import { GatewayMarketplaceService } from "./service/marketplace-service.js";
|
|
50
|
+
import { GatewayConfigCoordinator } from "./service/config-coordinator.js";
|
|
51
|
+
import { GatewayAgentRunner } from "./service/agent-runner.js";
|
|
63
52
|
import { GatewaySseHub } from "./service/sse-hub.js";
|
|
64
53
|
import { GatewayReadiness } from "./startup-readiness.js";
|
|
65
54
|
import { createGatewayStartupTrace } from "./startup-trace.js";
|
|
66
|
-
import { join } from "node:path";
|
|
67
|
-
import { existsSync, mkdirSync, rmSync } from "node:fs";
|
|
68
55
|
import crypto from "crypto";
|
|
69
56
|
//#region src/gateway/service.ts
|
|
70
|
-
init_schema();
|
|
71
57
|
init_providers();
|
|
72
58
|
init_logger();
|
|
73
59
|
init_paths();
|
|
74
60
|
init_package_version();
|
|
75
|
-
init_session_key();
|
|
76
61
|
init_resolve_route();
|
|
77
62
|
const log = createLogger("GatewayService");
|
|
78
63
|
var GatewayService = class {
|
|
@@ -91,17 +76,11 @@ var GatewayService = class {
|
|
|
91
76
|
heartbeatService = null;
|
|
92
77
|
sessionIndex;
|
|
93
78
|
running = false;
|
|
94
|
-
configReloader = null;
|
|
95
|
-
/** In-flight coalesced apply after PATCH/save (Telegram `getMe` must not block HTTP). */
|
|
96
|
-
channelReloadFlushPromise = null;
|
|
97
|
-
channelReloadPending = false;
|
|
98
79
|
startTime = Date.now();
|
|
99
80
|
workspacePath;
|
|
81
|
+
configCoordinator;
|
|
100
82
|
auth;
|
|
101
83
|
sse = new GatewaySseHub();
|
|
102
|
-
runRelay = new AgentRunRelay();
|
|
103
|
-
/** Per-run abort for webchat (POST /api/agent/abort or client disconnect). */
|
|
104
|
-
runAbortControllers = /* @__PURE__ */ new Map();
|
|
105
84
|
stopGatewayUpdateCheck = null;
|
|
106
85
|
/** When set (e.g. by `GatewayServer`), `triggerGatewayProcessRestart` can stop HTTP then exit. */
|
|
107
86
|
gatewayShutdownForRestart = null;
|
|
@@ -111,9 +90,27 @@ var GatewayService = class {
|
|
|
111
90
|
lastChannelConnectDeferSource = "off";
|
|
112
91
|
readiness = new GatewayReadiness();
|
|
113
92
|
startupTrace = null;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Webchat agent invocation surface (`runAgent`, `abortAgentRun`, `steer*`,
|
|
95
|
+
* `submitClarifyResponse`, clarify-bridge dispatch). Owns the
|
|
96
|
+
* `activeWebchatRunBySession` + `runAbortControllers` maps.
|
|
97
|
+
*/
|
|
98
|
+
agentRunner;
|
|
99
|
+
/** Read-only alias re-exported from `agentRunner.runRelay` for legacy callers. */
|
|
100
|
+
get runRelay() {
|
|
101
|
+
return this.agentRunner.runRelay;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Session CRUD / search / compaction / tag-archive-pin / stats — the gateway
|
|
105
|
+
* REST surface for sessions. Routes should depend on this narrow service
|
|
106
|
+
* rather than the full GatewayService composition root.
|
|
107
|
+
*/
|
|
108
|
+
sessions;
|
|
109
|
+
/**
|
|
110
|
+
* Skills + extensions marketplace surface (browse / install / uninstall) plus
|
|
111
|
+
* local-only managed-skill ops. Routes depend on this narrow service.
|
|
112
|
+
*/
|
|
113
|
+
marketplace;
|
|
117
114
|
constructor(serviceConfig = {}) {
|
|
118
115
|
this.serviceConfig = serviceConfig;
|
|
119
116
|
this.bus = new MessageBus();
|
|
@@ -166,6 +163,44 @@ var GatewayService = class {
|
|
|
166
163
|
this.initializeExtensionLoader();
|
|
167
164
|
this.sessionIndex = new SessionIndex({ config: this.config });
|
|
168
165
|
this.cronService = new CronService({ filePath: resolveCronJobsPath() });
|
|
166
|
+
this.agentRunner = new GatewayAgentRunner({
|
|
167
|
+
bus: this.bus,
|
|
168
|
+
sessionIndex: this.sessionIndex,
|
|
169
|
+
getAgentService: () => this.ensureAgentService(),
|
|
170
|
+
getChannelManager: () => this.channelManager,
|
|
171
|
+
getConfig: () => this.config,
|
|
172
|
+
emit: (type, payload) => this.sse.emit(type, payload)
|
|
173
|
+
});
|
|
174
|
+
this.sessions = new GatewaySessionsApi({
|
|
175
|
+
sessionIndex: this.sessionIndex,
|
|
176
|
+
getAgentService: () => this.ensureAgentService(),
|
|
177
|
+
getActiveWebchatRunId: (sk) => this.agentRunner.getActiveRunId(sk)
|
|
178
|
+
});
|
|
179
|
+
this.marketplace = new GatewayMarketplaceService({
|
|
180
|
+
getConfig: () => this.config,
|
|
181
|
+
getAgentService: () => this.ensureAgentService(),
|
|
182
|
+
getExtensionLoader: () => this.extensionLoader,
|
|
183
|
+
getChannelManager: () => this.channelManager,
|
|
184
|
+
saveConfig: (cfg) => this.saveConfig(cfg),
|
|
185
|
+
emit: (type, payload) => this.emit(type, payload)
|
|
186
|
+
});
|
|
187
|
+
this.configCoordinator = new GatewayConfigCoordinator({
|
|
188
|
+
configPath: this.configPath,
|
|
189
|
+
bus: this.bus,
|
|
190
|
+
enableHotReload: this.serviceConfig.enableHotReload !== false,
|
|
191
|
+
getConfig: () => this.config,
|
|
192
|
+
setConfig: (next) => {
|
|
193
|
+
this.config = next;
|
|
194
|
+
},
|
|
195
|
+
getAgentService: () => this.ensureAgentService(),
|
|
196
|
+
getChannelManager: () => this.channelManager,
|
|
197
|
+
getCronService: () => this.cronService,
|
|
198
|
+
getHeartbeatService: () => this.heartbeatService,
|
|
199
|
+
getExtensionLoader: () => this.extensionLoader,
|
|
200
|
+
reconcileBrowserExtensionServer: () => this.reconcileBrowserExtensionServer(),
|
|
201
|
+
getChannelsStatus: () => this.getChannelsStatus(),
|
|
202
|
+
emit: (type, payload) => this.emit(type, payload)
|
|
203
|
+
});
|
|
169
204
|
}
|
|
170
205
|
/** Lazy AgentService — constructed on first use or during `start()`. */
|
|
171
206
|
get agentService() {
|
|
@@ -188,24 +223,13 @@ var GatewayService = class {
|
|
|
188
223
|
},
|
|
189
224
|
extensionRegistry: this.extensionLoader?.getRegistry(),
|
|
190
225
|
getCronService: () => cronRef.service,
|
|
191
|
-
gatewayClarify: { requestClarification: (sessionKey, request) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
} : void 0;
|
|
199
|
-
if (!runId && !deliver) return Promise.reject(/* @__PURE__ */ new Error("Clarify is not available for this session (use webchat, Telegram, or CLI)"));
|
|
200
|
-
return this.clarifyBridge.startRequest({
|
|
201
|
-
sessionKey,
|
|
202
|
-
runId,
|
|
203
|
-
relay: this.runRelay,
|
|
204
|
-
publishSse,
|
|
205
|
-
request,
|
|
206
|
-
deliver
|
|
207
|
-
});
|
|
208
|
-
} }
|
|
226
|
+
gatewayClarify: { requestClarification: (sessionKey, request) => this.agentRunner.requestClarification({
|
|
227
|
+
sessionKey,
|
|
228
|
+
request,
|
|
229
|
+
publishSseFor: (_runId) => (e) => {
|
|
230
|
+
this._agentService.turnDispatcher.enqueueWebchatSseEvent(sessionKey, e);
|
|
231
|
+
}
|
|
232
|
+
}) }
|
|
209
233
|
});
|
|
210
234
|
this._agentService.setChannelManager(this.channelManager);
|
|
211
235
|
this.channelManager.setSessionModelHooks({
|
|
@@ -220,17 +244,17 @@ var GatewayService = class {
|
|
|
220
244
|
getDefaultCronAgentId: () => getDefaultAgentId(this.config)
|
|
221
245
|
});
|
|
222
246
|
cronRef.service = this.cronService;
|
|
223
|
-
this._agentService.
|
|
247
|
+
this._agentService.persistentGoals.setWebchatContinuationScheduler((sessionKey, message) => {
|
|
224
248
|
const scheduleWhenIdle = () => {
|
|
225
249
|
if (this._agentService.getInboundTurnDepth(sessionKey) > 0) {
|
|
226
250
|
setTimeout(scheduleWhenIdle, 50);
|
|
227
251
|
return;
|
|
228
252
|
}
|
|
229
|
-
if (this.
|
|
253
|
+
if (this.agentRunner.hasActiveRun(sessionKey)) {
|
|
230
254
|
setTimeout(scheduleWhenIdle, 50);
|
|
231
255
|
return;
|
|
232
256
|
}
|
|
233
|
-
this.drainScheduledWebchatContinuation(sessionKey, message);
|
|
257
|
+
this.agentRunner.drainScheduledWebchatContinuation(sessionKey, message);
|
|
234
258
|
};
|
|
235
259
|
queueMicrotask(scheduleWhenIdle);
|
|
236
260
|
});
|
|
@@ -247,11 +271,20 @@ var GatewayService = class {
|
|
|
247
271
|
});
|
|
248
272
|
return this.heartbeatService;
|
|
249
273
|
}
|
|
250
|
-
/** Hermes-style: after HTTP sets a goal, enqueue the goal text as the next user turn. */
|
|
251
274
|
enqueueWebchatPersistentGoalKickoff(sessionKey, goalText) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
275
|
+
this.agentRunner.enqueueWebchatPersistentGoalKickoff(sessionKey, goalText);
|
|
276
|
+
}
|
|
277
|
+
runAgent(...args) {
|
|
278
|
+
return this.agentRunner.runAgent(...args);
|
|
279
|
+
}
|
|
280
|
+
abortAgentRun(runId) {
|
|
281
|
+
return this.agentRunner.abortAgentRun(runId);
|
|
282
|
+
}
|
|
283
|
+
steerWebchatAgent(chatId, message) {
|
|
284
|
+
return this.agentRunner.steerWebchatAgent(chatId, message);
|
|
285
|
+
}
|
|
286
|
+
submitClarifyResponse(requestId, answer) {
|
|
287
|
+
return this.agentRunner.submitClarifyResponse(requestId, answer);
|
|
255
288
|
}
|
|
256
289
|
initializeExtensionLoader() {
|
|
257
290
|
try {
|
|
@@ -345,11 +378,11 @@ var GatewayService = class {
|
|
|
345
378
|
this.startupTrace = createGatewayStartupTrace();
|
|
346
379
|
this.readiness.markStarting(this.startTime);
|
|
347
380
|
const trace = this.startupTrace;
|
|
348
|
-
registerClarifyBridge(this.
|
|
381
|
+
registerClarifyBridge(this.agentRunner.getClarifyBridge());
|
|
349
382
|
this.ensureAgentService();
|
|
350
383
|
this.channelManager.setOutboundHooks({
|
|
351
|
-
runMessageSending: (to, content, channel) => this.agentService.invokeOutboundMessageSending(to, content, channel),
|
|
352
|
-
runMessageSent: (to, content, success, error, channel) => this.agentService.invokeOutboundMessageSent(to, content, success, error, channel)
|
|
384
|
+
runMessageSending: (to, content, channel) => this.agentService.outboundCoordinator.invokeOutboundMessageSending(to, content, channel),
|
|
385
|
+
runMessageSent: (to, content, success, error, channel) => this.agentService.outboundCoordinator.invokeOutboundMessageSent(to, content, success, error, channel)
|
|
353
386
|
});
|
|
354
387
|
this.channelManager.enableOutboundPersistence(resolveAgentDir(this.config, getDefaultAgentId(this.config)));
|
|
355
388
|
if (this.extensionLoader) this.extensionLoader.setRuntimeContext({
|
|
@@ -357,7 +390,7 @@ var GatewayService = class {
|
|
|
357
390
|
sessionManager: this.sessionIndex,
|
|
358
391
|
scheduleWebchatContinuation: (sessionKey, continuationMessage) => {
|
|
359
392
|
queueMicrotask(() => {
|
|
360
|
-
this.drainScheduledWebchatContinuation(sessionKey, continuationMessage);
|
|
393
|
+
this.agentRunner.drainScheduledWebchatContinuation(sessionKey, continuationMessage);
|
|
361
394
|
});
|
|
362
395
|
}
|
|
363
396
|
});
|
|
@@ -440,7 +473,7 @@ var GatewayService = class {
|
|
|
440
473
|
if (this.serviceConfig.deferChannelConnectUntilAfterHttp !== true) this.startOutboundProcessor().catch((err) => {
|
|
441
474
|
log.error({ err }, "Outbound processor error");
|
|
442
475
|
});
|
|
443
|
-
if (this.serviceConfig.enableHotReload !== false) this.
|
|
476
|
+
if (this.serviceConfig.enableHotReload !== false) this.configCoordinator.startHotReloader();
|
|
444
477
|
this.stopGatewayUpdateCheck = scheduleGatewayUpdateCheck({
|
|
445
478
|
config: this.config,
|
|
446
479
|
onUpdateAvailableChange: (update) => {
|
|
@@ -543,14 +576,7 @@ var GatewayService = class {
|
|
|
543
576
|
this.stopGatewayUpdateCheck();
|
|
544
577
|
this.stopGatewayUpdateCheck = null;
|
|
545
578
|
}
|
|
546
|
-
|
|
547
|
-
await this.configReloader.stop();
|
|
548
|
-
this.configReloader = null;
|
|
549
|
-
}
|
|
550
|
-
if (this.channelReloadFlushPromise) {
|
|
551
|
-
await this.channelReloadFlushPromise.catch(() => {});
|
|
552
|
-
this.channelReloadFlushPromise = null;
|
|
553
|
-
}
|
|
579
|
+
await this.configCoordinator.stopHotReloader();
|
|
554
580
|
this.heartbeatService?.stop();
|
|
555
581
|
if (this.browserExtensionRelease) {
|
|
556
582
|
await this.browserExtensionRelease();
|
|
@@ -559,7 +585,7 @@ var GatewayService = class {
|
|
|
559
585
|
this.browserExtensionProvider = null;
|
|
560
586
|
this.browserExtensionBindKey = null;
|
|
561
587
|
registerClarifyBridge(null);
|
|
562
|
-
this.
|
|
588
|
+
this.agentRunner.disposeClarifyBridge();
|
|
563
589
|
await disposeAllSessionMcpRuntimes().catch((err) => {
|
|
564
590
|
log.warn({ err }, "MCP runtime shutdown failed");
|
|
565
591
|
});
|
|
@@ -571,6 +597,7 @@ var GatewayService = class {
|
|
|
571
597
|
this.lastChannelConnectDeferSource = "off";
|
|
572
598
|
await this.channelManager.stop();
|
|
573
599
|
await this.cronService.stop();
|
|
600
|
+
buckets.destroyAll();
|
|
574
601
|
log.debug("Gateway service stopped");
|
|
575
602
|
}
|
|
576
603
|
/** Start the browser extension WS server when backend is 'extension'. */
|
|
@@ -664,457 +691,26 @@ var GatewayService = class {
|
|
|
664
691
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
665
692
|
}
|
|
666
693
|
}
|
|
667
|
-
/**
|
|
668
|
-
* Setup config hot reload using ConfigHotReloader
|
|
669
|
-
*/
|
|
670
|
-
setupConfigReloader() {
|
|
671
|
-
this.configReloader = new ConfigHotReloader(this.configPath, this.config, {
|
|
672
|
-
onModelsReload: (newConfig) => this.handleModelsReload(newConfig),
|
|
673
|
-
onAgentDefaultsReload: (newConfig) => this.handleAgentDefaultsReload(newConfig),
|
|
674
|
-
onChannelsReload: (newConfig) => this.handleChannelsReload(newConfig),
|
|
675
|
-
onCronReload: (newConfig) => this.handleCronReload(newConfig),
|
|
676
|
-
onHeartbeatReload: (newConfig) => this.handleHeartbeatReload(newConfig),
|
|
677
|
-
onToolsReload: (newConfig) => this.handleToolsReload(newConfig),
|
|
678
|
-
onMcpReload: (newConfig) => this.handleMcpReload(newConfig),
|
|
679
|
-
onExtensionsReload: async (newConfig, changedPaths) => {
|
|
680
|
-
await this.handleExtensionsReload(newConfig, changedPaths);
|
|
681
|
-
},
|
|
682
|
-
onFullRestart: (newConfig) => {
|
|
683
|
-
log.warn({
|
|
684
|
-
requiresProcessRestart: true,
|
|
685
|
-
hint: "Restart the gateway process (hot reload cannot apply this change)."
|
|
686
|
-
}, "Config reload: full gateway restart required — see prior \"restartPaths\" info log");
|
|
687
|
-
this.config = newConfig;
|
|
688
|
-
this.emit("config.reload", {
|
|
689
|
-
section: "full",
|
|
690
|
-
requiresRestart: true
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
}, {
|
|
694
|
-
debounceMs: 300,
|
|
695
|
-
enabled: this.serviceConfig.enableHotReload !== false
|
|
696
|
-
});
|
|
697
|
-
this.configReloader.start();
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Handle models config hot reload
|
|
701
|
-
*/
|
|
702
|
-
handleModelsReload(newConfig) {
|
|
703
|
-
log.debug("Reloading models config...");
|
|
704
|
-
this.config = newConfig;
|
|
705
|
-
getModelRegistry().refresh();
|
|
706
|
-
this.emit("config.reload", { section: "models" });
|
|
707
|
-
log.debug("Models config reloaded");
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Handle agent defaults config hot reload
|
|
711
|
-
*/
|
|
712
|
-
handleAgentDefaultsReload(newConfig) {
|
|
713
|
-
log.debug("Reloading agent defaults...");
|
|
714
|
-
this.config = newConfig;
|
|
715
|
-
this.agentService.applyAgentDefaultsFromConfig(newConfig);
|
|
716
|
-
this.reconcileBrowserExtensionServer();
|
|
717
|
-
this.emit("config.reload", { section: "agents" });
|
|
718
|
-
log.debug("Agent defaults reloaded");
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Apply `latest.channels` to every registered channel plugin (Telegram, Weixin, extensions).
|
|
722
|
-
* Single runtime path for: file watcher hot reload, API saves, and Weixin QR follow-up.
|
|
723
|
-
*/
|
|
724
|
-
async handleChannelsReload(newConfig) {
|
|
725
|
-
log.debug("Reloading channels config...");
|
|
726
|
-
this.config = newConfig;
|
|
727
|
-
await this.channelManager.updateConfig(newConfig);
|
|
728
|
-
this.emit("config.reload", { section: "channels" });
|
|
729
|
-
this.emit("channels.status", { channels: this.getChannelsStatus() });
|
|
730
|
-
log.debug("Channels config reloaded");
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Apply channel plugins for the latest persisted `this.config` without blocking `saveConfig` HTTP handlers.
|
|
734
|
-
* Coalesces rapid saves so Telegram/Weixin do not stop/start repeatedly.
|
|
735
|
-
*/
|
|
736
|
-
scheduleChannelPluginsAfterPersist() {
|
|
737
|
-
this.channelReloadPending = true;
|
|
738
|
-
if (this.channelReloadFlushPromise) return;
|
|
739
|
-
this.channelReloadFlushPromise = (async () => {
|
|
740
|
-
try {
|
|
741
|
-
while (this.channelReloadPending) {
|
|
742
|
-
this.channelReloadPending = false;
|
|
743
|
-
await this.handleChannelsReload(this.config);
|
|
744
|
-
}
|
|
745
|
-
} catch (err) {
|
|
746
|
-
const em = err instanceof Error ? err.message : String(err);
|
|
747
|
-
log.error({
|
|
748
|
-
err,
|
|
749
|
-
errorMessage: em
|
|
750
|
-
}, `Channel reload after persist failed: ${em}`);
|
|
751
|
-
} finally {
|
|
752
|
-
this.channelReloadFlushPromise = null;
|
|
753
|
-
if (this.channelReloadPending) this.scheduleChannelPluginsAfterPersist();
|
|
754
|
-
}
|
|
755
|
-
})();
|
|
756
|
-
}
|
|
757
|
-
/**
|
|
758
|
-
* Handle cron config hot reload
|
|
759
|
-
*/
|
|
760
|
-
handleCronReload(newConfig) {
|
|
761
|
-
log.debug("Reloading cron config...");
|
|
762
|
-
this.config = newConfig;
|
|
763
|
-
this.cronService.updateConfig(newConfig);
|
|
764
|
-
this.emit("config.reload", { section: "cron" });
|
|
765
|
-
log.debug("Cron config reloaded");
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* Handle heartbeat config hot reload
|
|
769
|
-
*/
|
|
770
|
-
handleHeartbeatReload(newConfig) {
|
|
771
|
-
log.debug("Reloading heartbeat config...");
|
|
772
|
-
this.config = newConfig;
|
|
773
|
-
this.heartbeatService?.updateConfig(newConfig);
|
|
774
|
-
this.emit("config.reload", { section: "heartbeat" });
|
|
775
|
-
log.debug("Heartbeat config reloaded");
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* Apply `gateway.heartbeat` from current config after PATCH /api/config (and when hot reload is off).
|
|
779
|
-
* File watcher uses `handleHeartbeatReload` with the same effect when paths match.
|
|
780
|
-
*/
|
|
781
694
|
reloadHeartbeatFromCurrentConfig() {
|
|
782
|
-
this.
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Handle tools config hot reload
|
|
786
|
-
*/
|
|
787
|
-
handleToolsReload(newConfig) {
|
|
788
|
-
log.debug("Reloading tools config...");
|
|
789
|
-
this.config = newConfig;
|
|
790
|
-
this.emit("config.reload", { section: "tools" });
|
|
791
|
-
log.debug("Tools config reloaded");
|
|
792
|
-
}
|
|
793
|
-
handleMcpReload(newConfig) {
|
|
794
|
-
log.debug("Reloading MCP config...");
|
|
795
|
-
this.config = newConfig;
|
|
796
|
-
disposeAllSessionMcpRuntimes().catch((err) => {
|
|
797
|
-
log.warn({ err }, "MCP runtime dispose on config reload failed");
|
|
798
|
-
});
|
|
799
|
-
this.emit("config.reload", { section: "mcp" });
|
|
800
|
-
log.debug("MCP config reloaded");
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Dispatch config hot reload to extensions that registered `registerReload`, matching changed paths.
|
|
804
|
-
*/
|
|
805
|
-
async handleExtensionsReload(newConfig, changedPaths) {
|
|
806
|
-
this.config = newConfig;
|
|
807
|
-
this.extensionLoader?.setConfig(this.config);
|
|
808
|
-
if (!this.extensionLoader) {
|
|
809
|
-
this.emit("config.reload", {
|
|
810
|
-
section: "extensions",
|
|
811
|
-
source: "extension-reload",
|
|
812
|
-
changedPaths
|
|
813
|
-
});
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
const matchingRegs = this.extensionLoader.getRegistry().getMatchingReloadRegistrations(changedPaths);
|
|
817
|
-
if (matchingRegs.length === 0) {
|
|
818
|
-
log.debug({ changedPaths }, "No extension reload handlers matched");
|
|
819
|
-
this.emit("config.reload", {
|
|
820
|
-
section: "extensions",
|
|
821
|
-
source: "extension-reload",
|
|
822
|
-
changedPaths
|
|
823
|
-
});
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
for (const reg of matchingRegs) {
|
|
827
|
-
const relevantPaths = changedPaths.filter((p) => reg.configPrefixes.length === 0 || reg.configPrefixes.some((prefix) => p === prefix || p.startsWith(`${prefix}.`)));
|
|
828
|
-
log.info({
|
|
829
|
-
extensionId: reg.extensionId,
|
|
830
|
-
relevantPaths
|
|
831
|
-
}, "Calling extension reload handler");
|
|
832
|
-
try {
|
|
833
|
-
const result = await reg.handler(newConfig, relevantPaths);
|
|
834
|
-
if (result.success) log.info({ extensionId: reg.extensionId }, "Extension reload succeeded");
|
|
835
|
-
else log.warn({
|
|
836
|
-
extensionId: reg.extensionId,
|
|
837
|
-
error: result.error
|
|
838
|
-
}, `Extension reload reported failure: ${result.error ?? "unknown"}`);
|
|
839
|
-
} catch (err) {
|
|
840
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
841
|
-
log.error({
|
|
842
|
-
err,
|
|
843
|
-
extensionId: reg.extensionId,
|
|
844
|
-
errorMessage
|
|
845
|
-
}, `Extension reload handler threw: ${errorMessage}`);
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
this.emit("config.reload", {
|
|
849
|
-
section: "extensions",
|
|
850
|
-
source: "extension-reload",
|
|
851
|
-
changedPaths
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Reload configuration from disk (manual trigger)
|
|
856
|
-
*/
|
|
857
|
-
async reloadConfig() {
|
|
858
|
-
if (!this.configReloader) return {
|
|
859
|
-
reloaded: false,
|
|
860
|
-
error: "Config reloader not initialized"
|
|
861
|
-
};
|
|
862
|
-
const result = await this.configReloader.triggerReload();
|
|
863
|
-
return {
|
|
864
|
-
reloaded: result.success,
|
|
865
|
-
error: result.error
|
|
866
|
-
};
|
|
695
|
+
this.configCoordinator.reloadHeartbeatFromCurrentConfig();
|
|
867
696
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
* channel apply as an API save, then force Weixin long-poll restart (see `reloadMonitorsWithConfig`).
|
|
871
|
-
*/
|
|
872
|
-
async afterWeixinCredentialsPersisted() {
|
|
873
|
-
const next = loadConfig(this.configPath);
|
|
874
|
-
this.config = next;
|
|
875
|
-
this.agentService.applyAgentDefaultsFromConfig(next);
|
|
876
|
-
this.configReloader?.syncCurrentConfig(next);
|
|
877
|
-
await this.handleChannelsReload(next);
|
|
878
|
-
const { weixinPlugin } = await import("../channels/weixin/index.js");
|
|
879
|
-
await weixinPlugin.reloadMonitorsWithConfig(this.config, this.bus);
|
|
880
|
-
log.info("Weixin monitors restarted after credential login");
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* After Feishu WebUI QR setup: `channels.feishu` was written directly to disk; reload into memory
|
|
884
|
-
* and apply channel plugins (same baseline as PATCH /api/config).
|
|
885
|
-
*/
|
|
886
|
-
async afterFeishuCredentialsPersisted() {
|
|
887
|
-
const next = loadConfig(this.configPath);
|
|
888
|
-
this.config = next;
|
|
889
|
-
this.agentService.applyAgentDefaultsFromConfig(next);
|
|
890
|
-
this.configReloader?.syncCurrentConfig(next);
|
|
891
|
-
await this.handleChannelsReload(next);
|
|
892
|
-
log.info("Feishu config applied after QR setup");
|
|
697
|
+
reloadConfig() {
|
|
698
|
+
return this.configCoordinator.reloadConfig();
|
|
893
699
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
* (PATCH merge objects can drift from Zod-normalized output).
|
|
897
|
-
*/
|
|
898
|
-
async writeConfigAndReloadFromDisk(configToWrite) {
|
|
899
|
-
await saveConfig(configToWrite, this.configPath);
|
|
900
|
-
this.config = loadConfig(this.configPath);
|
|
901
|
-
if (sanitizeTunnelConfig(this.config)) await saveConfig(this.config, this.configPath);
|
|
902
|
-
this.agentService.applyAgentDefaultsFromConfig(this.config);
|
|
903
|
-
await this.reconcileBrowserExtensionServer();
|
|
904
|
-
await this.agentService.reconcileDreamingNow().catch((err) => {
|
|
905
|
-
const em = err instanceof Error ? err.message : String(err);
|
|
906
|
-
log.warn({
|
|
907
|
-
err,
|
|
908
|
-
errorMessage: em
|
|
909
|
-
}, `Dreaming cron reconcile after save failed: ${em}`);
|
|
910
|
-
});
|
|
911
|
-
this.configReloader?.syncCurrentConfig(this.config);
|
|
912
|
-
}
|
|
913
|
-
async saveConfig(config) {
|
|
914
|
-
try {
|
|
915
|
-
await this.writeConfigAndReloadFromDisk(config);
|
|
916
|
-
this.scheduleChannelPluginsAfterPersist();
|
|
917
|
-
return { saved: true };
|
|
918
|
-
} catch (err) {
|
|
919
|
-
const error = err instanceof Error ? err.message : String(err);
|
|
920
|
-
log.error({ error }, "Failed to save config");
|
|
921
|
-
return {
|
|
922
|
-
saved: false,
|
|
923
|
-
error
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* App store (phase 1): persist `extensions.enabled` / `extensions.disabled` for a bundled extension.
|
|
929
|
-
* Marketplace-only extensions hot-load on enable; disable still needs a gateway restart to unload.
|
|
930
|
-
*/
|
|
931
|
-
async setBundledExtensionActivationTarget(extensionId, wanted) {
|
|
932
|
-
const loader = this.extensionLoader;
|
|
933
|
-
if (!loader) return {
|
|
934
|
-
ok: false,
|
|
935
|
-
error: "Extension loader unavailable",
|
|
936
|
-
requiresGatewayRestart: false
|
|
937
|
-
};
|
|
938
|
-
const id = extensionId.trim();
|
|
939
|
-
if (!id) return {
|
|
940
|
-
ok: false,
|
|
941
|
-
error: "Invalid extension id",
|
|
942
|
-
requiresGatewayRestart: false
|
|
943
|
-
};
|
|
944
|
-
const patch = computeBundledExtensionExtensionsPatch(loader, this.config, id, wanted);
|
|
945
|
-
if (patch.ok === false) return {
|
|
946
|
-
ok: false,
|
|
947
|
-
error: patch.error,
|
|
948
|
-
requiresGatewayRestart: false
|
|
949
|
-
};
|
|
950
|
-
const newConfig = {
|
|
951
|
-
...this.config,
|
|
952
|
-
extensions: patch.extensions
|
|
953
|
-
};
|
|
954
|
-
const saved = await this.saveConfig(newConfig);
|
|
955
|
-
if (!saved.saved) return {
|
|
956
|
-
ok: false,
|
|
957
|
-
error: saved.error ?? "Failed to save config",
|
|
958
|
-
requiresGatewayRestart: false
|
|
959
|
-
};
|
|
960
|
-
loader.setConfig(this.config);
|
|
961
|
-
let requiresGatewayRestart = true;
|
|
962
|
-
if (wanted) try {
|
|
963
|
-
loader.invalidateManifestCache();
|
|
964
|
-
await loader.loadByActivationPlan();
|
|
965
|
-
requiresGatewayRestart = false;
|
|
966
|
-
} catch (err) {
|
|
967
|
-
const em = err instanceof Error ? err.message : String(err);
|
|
968
|
-
log.warn({
|
|
969
|
-
err,
|
|
970
|
-
extensionId: id,
|
|
971
|
-
errorMessage: em
|
|
972
|
-
}, `Extension hot-load after bundled activation failed: ${em}`);
|
|
973
|
-
requiresGatewayRestart = true;
|
|
974
|
-
}
|
|
975
|
-
this.emit("config.reload", {
|
|
976
|
-
section: "extensions",
|
|
977
|
-
source: "bundled-activation"
|
|
978
|
-
});
|
|
979
|
-
return {
|
|
980
|
-
ok: true,
|
|
981
|
-
requiresGatewayRestart
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
|
-
/**
|
|
985
|
-
* Update configuration and persist to disk
|
|
986
|
-
*/
|
|
987
|
-
async updateConfig(updates) {
|
|
988
|
-
try {
|
|
989
|
-
log.debug("Updating configuration...");
|
|
990
|
-
this.config = {
|
|
991
|
-
...this.config,
|
|
992
|
-
...updates
|
|
993
|
-
};
|
|
994
|
-
await this.writeConfigAndReloadFromDisk(this.config);
|
|
995
|
-
this.scheduleChannelPluginsAfterPersist();
|
|
996
|
-
log.debug("Configuration updated successfully");
|
|
997
|
-
return { updated: true };
|
|
998
|
-
} catch (err) {
|
|
999
|
-
const error = err instanceof Error ? err.message : String(err);
|
|
1000
|
-
log.error({ error }, "Failed to update config");
|
|
1001
|
-
return {
|
|
1002
|
-
updated: false,
|
|
1003
|
-
error
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
/**
|
|
1008
|
-
* Run agent with a message and stream events.
|
|
1009
|
-
* `runOptions.signal` — When set (e.g. client disconnect), aborts in-flight generation and persists partial output.
|
|
1010
|
-
*/
|
|
1011
|
-
async *runAgent(message, channel, chatId, attachments, thinking, runOptions) {
|
|
1012
|
-
const iter = runGatewayAgent({
|
|
1013
|
-
config: this.config,
|
|
1014
|
-
agentService: this.agentService,
|
|
1015
|
-
bus: this.bus,
|
|
1016
|
-
runRelay: this.runRelay,
|
|
1017
|
-
runAbortControllers: this.runAbortControllers,
|
|
1018
|
-
activeWebchatRunBySession: this.activeWebchatRunBySession,
|
|
1019
|
-
sessionIndex: this.sessionIndex,
|
|
1020
|
-
emit: (type, payload) => this.sse.emit(type, payload)
|
|
1021
|
-
}, message, channel, chatId, attachments, thinking, runOptions);
|
|
1022
|
-
let step = await iter.next();
|
|
1023
|
-
while (!step.done) {
|
|
1024
|
-
yield step.value;
|
|
1025
|
-
step = await iter.next();
|
|
1026
|
-
}
|
|
1027
|
-
return step.value;
|
|
1028
|
-
}
|
|
1029
|
-
/** Abort an in-flight webchat agent run (matches `runId` from SSE `status`). */
|
|
1030
|
-
abortAgentRun(runId) {
|
|
1031
|
-
this.clarifyBridge.cancelForRun(runId);
|
|
1032
|
-
const keysToMark = [];
|
|
1033
|
-
for (const [sk, id] of this.activeWebchatRunBySession) if (id === runId) keysToMark.push(sk);
|
|
1034
|
-
for (const sk of keysToMark) this.activeWebchatRunBySession.delete(sk);
|
|
1035
|
-
const relaySk = this.runRelay.getSessionKey(runId);
|
|
1036
|
-
if (relaySk && !keysToMark.includes(relaySk)) keysToMark.push(relaySk);
|
|
1037
|
-
const c = this.runAbortControllers.get(runId);
|
|
1038
|
-
if (!c) return false;
|
|
1039
|
-
const cutoffTs = Date.now();
|
|
1040
|
-
for (const sk of keysToMark) {
|
|
1041
|
-
this.sessionIndex.updateSessionMetadata(sk, { abortCutoffTimestamp: cutoffTs }).catch(() => {});
|
|
1042
|
-
this.sessionIndex.appendTranscriptContextEntry(sk, {
|
|
1043
|
-
text: "Webchat agent run aborted",
|
|
1044
|
-
data: {
|
|
1045
|
-
runId,
|
|
1046
|
-
abortCutoffTimestamp: cutoffTs
|
|
1047
|
-
}
|
|
1048
|
-
}).catch(() => {});
|
|
1049
|
-
}
|
|
1050
|
-
c.abort();
|
|
1051
|
-
for (const sk of keysToMark) import("../agent/embedded/runs.js").then(({ abortEmbeddedRun }) => abortEmbeddedRun(sk));
|
|
1052
|
-
return true;
|
|
700
|
+
afterWeixinCredentialsPersisted() {
|
|
701
|
+
return this.configCoordinator.afterWeixinCredentialsPersisted();
|
|
1053
702
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
try {
|
|
1057
|
-
const gen = this.runAgent(message, "webchat", sessionKey, void 0, void 0, { clientCreatedAtMs: Date.now() });
|
|
1058
|
-
for await (const _ of gen);
|
|
1059
|
-
} catch (err) {
|
|
1060
|
-
log.warn({
|
|
1061
|
-
err,
|
|
1062
|
-
sessionKey
|
|
1063
|
-
}, "Scheduled webchat continuation failed");
|
|
1064
|
-
}
|
|
703
|
+
afterFeishuCredentialsPersisted() {
|
|
704
|
+
return this.configCoordinator.afterFeishuCredentialsPersisted();
|
|
1065
705
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
* `chatId` is the same as `POST /api/agent` body (`sessionKey` or legacy peer id).
|
|
1069
|
-
*/
|
|
1070
|
-
async steerWebchatAgent(chatId, message) {
|
|
1071
|
-
const trimmed = message.trim();
|
|
1072
|
-
if (!trimmed) return {
|
|
1073
|
-
ok: false,
|
|
1074
|
-
code: "BAD_REQUEST"
|
|
1075
|
-
};
|
|
1076
|
-
const sessionKey = parseSessionKey(chatId) ? chatId : buildSessionKey({
|
|
1077
|
-
agentId: getDefaultAgentId(this.config),
|
|
1078
|
-
source: "webchat",
|
|
1079
|
-
accountId: "default",
|
|
1080
|
-
peerKind: "direct",
|
|
1081
|
-
peerId: chatId
|
|
1082
|
-
});
|
|
1083
|
-
if (!this.activeWebchatRunBySession.has(sessionKey)) return {
|
|
1084
|
-
ok: false,
|
|
1085
|
-
code: "NO_ACTIVE_RUN"
|
|
1086
|
-
};
|
|
1087
|
-
if (!await this.agentService.steerWebchatSession(sessionKey, trimmed)) return {
|
|
1088
|
-
ok: false,
|
|
1089
|
-
code: "STEER_FAILED"
|
|
1090
|
-
};
|
|
1091
|
-
return { ok: true };
|
|
706
|
+
saveConfig(config) {
|
|
707
|
+
return this.configCoordinator.saveConfig(config);
|
|
1092
708
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
if (!parsed || parsed.source !== "telegram") return;
|
|
1096
|
-
let body = ctx.request.question;
|
|
1097
|
-
if (ctx.request.default) body += `\n\nDefault if unsure: ${ctx.request.default}`;
|
|
1098
|
-
const choices = ctx.request.choices;
|
|
1099
|
-
const buttonRows = choices && choices.length >= 2 ? choices.map((c, i) => [{
|
|
1100
|
-
text: c.length > 64 ? `${c.slice(0, 61)}…` : c,
|
|
1101
|
-
callback_data: `clarify:${ctx.requestId}:${i}`
|
|
1102
|
-
}]) : void 0;
|
|
1103
|
-
if (!buttonRows) body += "\n\nReply with your answer in this chat.";
|
|
1104
|
-
await this.channelManager.send({
|
|
1105
|
-
channel: "telegram",
|
|
1106
|
-
chat_id: parsed.peerId,
|
|
1107
|
-
content: body,
|
|
1108
|
-
metadata: {
|
|
1109
|
-
accountId: parsed.accountId,
|
|
1110
|
-
...parsed.threadId ? { threadId: parsed.threadId } : {}
|
|
1111
|
-
},
|
|
1112
|
-
buttons: buttonRows
|
|
1113
|
-
});
|
|
709
|
+
setBundledExtensionActivationTarget(extensionId, wanted) {
|
|
710
|
+
return this.configCoordinator.setBundledExtensionActivationTarget(extensionId, wanted);
|
|
1114
711
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
return this.clarifyBridge.handleResponse(requestId, answer);
|
|
712
|
+
updateConfig(updates) {
|
|
713
|
+
return this.configCoordinator.updateConfig(updates);
|
|
1118
714
|
}
|
|
1119
715
|
/**
|
|
1120
716
|
* Send message through a channel
|
|
@@ -1315,199 +911,6 @@ var GatewayService = class {
|
|
|
1315
911
|
get cronServiceInstance() {
|
|
1316
912
|
return this.cronService;
|
|
1317
913
|
}
|
|
1318
|
-
getSkillsApi(lang) {
|
|
1319
|
-
return {
|
|
1320
|
-
catalog: this.agentService.getSkillCatalog(lang),
|
|
1321
|
-
managed: listManagedSkillDirs()
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
|
-
getSkillMarkdownSource(skillName, lang) {
|
|
1325
|
-
return this.agentService.getSkillMarkdownSource(skillName, lang);
|
|
1326
|
-
}
|
|
1327
|
-
deleteManagedSkill(skillId) {
|
|
1328
|
-
removeSkillsLockEntry(skillId);
|
|
1329
|
-
deleteManagedSkill(skillId);
|
|
1330
|
-
this.agentService.refreshSkillsAfterDiskChange();
|
|
1331
|
-
}
|
|
1332
|
-
installManagedSkillZip(buffer, opts) {
|
|
1333
|
-
const result = installSkillFromZip(buffer, opts);
|
|
1334
|
-
removeSkillsLockEntry(result.skillId);
|
|
1335
|
-
this.agentService.refreshSkillsAfterDiskChange();
|
|
1336
|
-
return result;
|
|
1337
|
-
}
|
|
1338
|
-
async fetchSkillsMarketplaceCatalog(params, provider) {
|
|
1339
|
-
return listMarketplacePackages(this.config, params, provider);
|
|
1340
|
-
}
|
|
1341
|
-
async fetchSkillsMarketplaceCategories(provider) {
|
|
1342
|
-
return listMarketplaceCategories(this.config, provider);
|
|
1343
|
-
}
|
|
1344
|
-
async fetchSkillsMarketplacePackageDetail(packageName, provider) {
|
|
1345
|
-
return getMarketplacePackageDetail(this.config, packageName, provider);
|
|
1346
|
-
}
|
|
1347
|
-
async installSkillFromMarketplace(opts) {
|
|
1348
|
-
const { buffer, skillId } = await downloadFromMarketplace(this.config, opts.name, opts.version, opts.provider);
|
|
1349
|
-
return this.installManagedSkillZip(buffer, {
|
|
1350
|
-
skillId,
|
|
1351
|
-
overwrite: opts.overwrite ?? false
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* xopc-store extension package preview (type must be `extension`).
|
|
1356
|
-
*/
|
|
1357
|
-
async fetchExtensionMarketplacePackageDetail(packageName) {
|
|
1358
|
-
const detail = await fetchMarketplacePackageDetail(resolveExtensionsStoreBaseUrl(this.config), packageName.trim());
|
|
1359
|
-
if (detail.type !== "extension") throw new Error(`Package "${packageName}" is not an extension (store type: ${detail.type}).`);
|
|
1360
|
-
return detail;
|
|
1361
|
-
}
|
|
1362
|
-
mergeExtensionEnabledIntoConfig(extensionId) {
|
|
1363
|
-
const id = extensionId.trim();
|
|
1364
|
-
const prevExt = this.config.extensions;
|
|
1365
|
-
const baseExt = prevExt && typeof prevExt === "object" && !Array.isArray(prevExt) ? { ...prevExt } : {};
|
|
1366
|
-
const enabledRaw = baseExt.enabled;
|
|
1367
|
-
const enabled = Array.isArray(enabledRaw) ? [...enabledRaw.filter((x) => typeof x === "string")] : [];
|
|
1368
|
-
if (!enabled.includes(id)) enabled.push(id);
|
|
1369
|
-
const disabledRaw = baseExt.disabled;
|
|
1370
|
-
const nextExt = {
|
|
1371
|
-
...baseExt,
|
|
1372
|
-
enabled
|
|
1373
|
-
};
|
|
1374
|
-
if (Array.isArray(disabledRaw)) {
|
|
1375
|
-
const next = disabledRaw.filter((x) => typeof x === "string" && x !== id);
|
|
1376
|
-
if (next.length > 0) nextExt.disabled = next;
|
|
1377
|
-
else delete nextExt.disabled;
|
|
1378
|
-
}
|
|
1379
|
-
return {
|
|
1380
|
-
...this.config,
|
|
1381
|
-
extensions: nextExt
|
|
1382
|
-
};
|
|
1383
|
-
}
|
|
1384
|
-
mergeExtensionRemovedFromEnabledConfig(extensionId) {
|
|
1385
|
-
const id = extensionId.trim();
|
|
1386
|
-
const prevExt = this.config.extensions;
|
|
1387
|
-
const baseExt = prevExt && typeof prevExt === "object" && !Array.isArray(prevExt) ? { ...prevExt } : {};
|
|
1388
|
-
const enabledRaw = baseExt.enabled;
|
|
1389
|
-
const enabled = Array.isArray(enabledRaw) ? enabledRaw.filter((x) => typeof x === "string" && x !== id) : [];
|
|
1390
|
-
return {
|
|
1391
|
-
...this.config,
|
|
1392
|
-
extensions: {
|
|
1393
|
-
...baseExt,
|
|
1394
|
-
enabled
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
}
|
|
1398
|
-
/**
|
|
1399
|
-
* Install an extension from xopc-store into the global extensions directory (`~/.xopc/extensions`),
|
|
1400
|
-
* append its id to `extensions.enabled`, refresh the loader, and emit `config.reload`.
|
|
1401
|
-
*/
|
|
1402
|
-
async installExtensionFromMarketplace(opts) {
|
|
1403
|
-
const packageName = opts.name.trim();
|
|
1404
|
-
if (!packageName) throw new Error("Package name is required");
|
|
1405
|
-
const storeBase = resolveExtensionsStoreBaseUrl(this.config);
|
|
1406
|
-
const targetDir = resolveExtensionsDir();
|
|
1407
|
-
mkdirSync(targetDir, { recursive: true });
|
|
1408
|
-
const { downloadUrl, version } = await resolveExtensionZipDownloadUrl(storeBase, packageName, opts.version);
|
|
1409
|
-
const buf = await downloadExtensionStoreZipBuffer(storeBase, downloadUrl);
|
|
1410
|
-
if (opts.overwrite) {
|
|
1411
|
-
const peekId = peekExtensionIdFromStoreZip(buf);
|
|
1412
|
-
if (peekId && existsSync(join(targetDir, peekId))) rmSync(join(targetDir, peekId), {
|
|
1413
|
-
recursive: true,
|
|
1414
|
-
force: true
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
const result = await installExtensionFromStoreZip(buf, targetDir);
|
|
1418
|
-
if (!result.ok || !result.extensionId) throw new Error(result.error ?? "Extension install failed");
|
|
1419
|
-
await getExtensionLockfileManager().upsert(result.extensionId, {
|
|
1420
|
-
name: result.extensionId,
|
|
1421
|
-
version,
|
|
1422
|
-
resolved: packageName,
|
|
1423
|
-
source: "store"
|
|
1424
|
-
});
|
|
1425
|
-
const nextConfig = this.mergeExtensionEnabledIntoConfig(result.extensionId);
|
|
1426
|
-
const saved = await this.saveConfig(nextConfig);
|
|
1427
|
-
if (!saved.saved) throw new Error(saved.error ?? "Failed to save config after extension install");
|
|
1428
|
-
const channelIdsBefore = new Set(this.channelManager.getAllPlugins().map((p) => p.id));
|
|
1429
|
-
let requiresGatewayRestart = false;
|
|
1430
|
-
try {
|
|
1431
|
-
if (this.extensionLoader) {
|
|
1432
|
-
this.extensionLoader.invalidateManifestCache();
|
|
1433
|
-
await this.extensionLoader.loadByActivationPlan();
|
|
1434
|
-
const reg = this.extensionLoader.getRegistry();
|
|
1435
|
-
for (const p of reg.channelPlugins) if (!channelIdsBefore.has(p.id)) {
|
|
1436
|
-
requiresGatewayRestart = true;
|
|
1437
|
-
break;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
} catch (err) {
|
|
1441
|
-
const em = err instanceof Error ? err.message : String(err);
|
|
1442
|
-
log.warn({
|
|
1443
|
-
err,
|
|
1444
|
-
errorMessage: em
|
|
1445
|
-
}, `Extension loader refresh after marketplace install failed: ${em}`);
|
|
1446
|
-
requiresGatewayRestart = true;
|
|
1447
|
-
}
|
|
1448
|
-
this.emit("config.reload", {
|
|
1449
|
-
section: "extensions",
|
|
1450
|
-
source: "marketplace-install"
|
|
1451
|
-
});
|
|
1452
|
-
return {
|
|
1453
|
-
extensionId: result.extensionId,
|
|
1454
|
-
version,
|
|
1455
|
-
requiresGatewayRestart
|
|
1456
|
-
};
|
|
1457
|
-
}
|
|
1458
|
-
/**
|
|
1459
|
-
* Remove a user-installed (global or per-agent extensions dir) extension from disk and config.
|
|
1460
|
-
*/
|
|
1461
|
-
async uninstallUserExtension(extensionId) {
|
|
1462
|
-
const id = extensionId.trim();
|
|
1463
|
-
if (!id) throw new Error("extensionId is required");
|
|
1464
|
-
const loader = this.extensionLoader;
|
|
1465
|
-
if (!loader) throw new Error("Extensions unavailable");
|
|
1466
|
-
const ext = loader.discoverExtensions().find((e) => e.id === id);
|
|
1467
|
-
if (!ext) throw new Error(`Extension not found: ${id}`);
|
|
1468
|
-
if (ext.source === "bundled") throw new Error("Built-in extensions cannot be uninstalled from the marketplace UI");
|
|
1469
|
-
if (existsSync(ext.path)) rmSync(ext.path, {
|
|
1470
|
-
recursive: true,
|
|
1471
|
-
force: true
|
|
1472
|
-
});
|
|
1473
|
-
await getExtensionLockfileManager().remove(id);
|
|
1474
|
-
const nextConfig = this.mergeExtensionRemovedFromEnabledConfig(id);
|
|
1475
|
-
const saved = await this.saveConfig(nextConfig);
|
|
1476
|
-
if (!saved.saved) throw new Error(saved.error ?? "Failed to save config after extension uninstall");
|
|
1477
|
-
try {
|
|
1478
|
-
loader.invalidateManifestCache();
|
|
1479
|
-
await loader.loadByActivationPlan();
|
|
1480
|
-
} catch (err) {
|
|
1481
|
-
const em = err instanceof Error ? err.message : String(err);
|
|
1482
|
-
log.warn({
|
|
1483
|
-
err,
|
|
1484
|
-
errorMessage: em
|
|
1485
|
-
}, `Extension loader refresh after uninstall failed: ${em}`);
|
|
1486
|
-
}
|
|
1487
|
-
this.emit("config.reload", {
|
|
1488
|
-
section: "extensions",
|
|
1489
|
-
source: "marketplace-uninstall"
|
|
1490
|
-
});
|
|
1491
|
-
return { requiresGatewayRestart: true };
|
|
1492
|
-
}
|
|
1493
|
-
getSkillsMarketplaceProvider() {
|
|
1494
|
-
const provider = resolveSkillsMarketplaceProvider(this.config);
|
|
1495
|
-
return {
|
|
1496
|
-
provider,
|
|
1497
|
-
displayName: getMarketplaceProviderDisplayName(provider)
|
|
1498
|
-
};
|
|
1499
|
-
}
|
|
1500
|
-
/** All registered marketplace providers (built-in + extension-contributed). */
|
|
1501
|
-
getSkillsMarketplaceProviders() {
|
|
1502
|
-
return listRegisteredProviders();
|
|
1503
|
-
}
|
|
1504
|
-
reloadSkillsFromDisk() {
|
|
1505
|
-
this.agentService.refreshSkillsAfterDiskChange();
|
|
1506
|
-
}
|
|
1507
|
-
patchSkillEnabled(skillName, enabled) {
|
|
1508
|
-
createSkillConfigManager(resolveStateDir()).setSkillEnabled(skillName, enabled);
|
|
1509
|
-
this.agentService.refreshSkillsAfterSkillConfigChange();
|
|
1510
|
-
}
|
|
1511
914
|
get sessionIndexInstance() {
|
|
1512
915
|
return this.sessionIndex;
|
|
1513
916
|
}
|
|
@@ -1515,206 +918,21 @@ var GatewayService = class {
|
|
|
1515
918
|
get sessionManagerInstance() {
|
|
1516
919
|
return this.sessionIndex;
|
|
1517
920
|
}
|
|
1518
|
-
|
|
1519
|
-
return this.agentService.getSessionAgentConfig(sessionKey);
|
|
1520
|
-
}
|
|
1521
|
-
/** Resolved markdown workspace for a session (after hydration / mkdir). Used by workspace file API when `sessionKey` is passed. */
|
|
1522
|
-
async getEffectiveWorkspacePathForSession(sessionKey) {
|
|
1523
|
-
return this.agentService.getEffectiveWorkspacePathForSession(sessionKey);
|
|
1524
|
-
}
|
|
1525
|
-
async patchSessionAgentConfig(sessionKey, body) {
|
|
1526
|
-
return this.agentService.patchSessionAgentConfig(sessionKey, body);
|
|
1527
|
-
}
|
|
1528
|
-
/**
|
|
1529
|
-
* Process a message directly through the agent (for CLI mode)
|
|
1530
|
-
*/
|
|
921
|
+
/** Process a message directly through the agent (for CLI mode). */
|
|
1531
922
|
async processDirect(content, sessionKey = "cli:direct") {
|
|
1532
|
-
return this.agentService.processDirect(content, sessionKey);
|
|
923
|
+
return this.agentService.turnDispatcher.processDirect(content, sessionKey);
|
|
1533
924
|
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Subscribe to server-pushed events.
|
|
1536
|
-
* Returns a cleanup function to unsubscribe.
|
|
1537
|
-
*/
|
|
1538
925
|
subscribe(sessionId, listener) {
|
|
1539
926
|
return this.sse.subscribe(sessionId, listener);
|
|
1540
927
|
}
|
|
1541
|
-
/**
|
|
1542
|
-
* Emit an event to all subscribers.
|
|
1543
|
-
*/
|
|
1544
928
|
emit(type, payload) {
|
|
1545
929
|
this.sse.emit(type, payload);
|
|
1546
930
|
}
|
|
1547
|
-
/**
|
|
1548
|
-
* Get events since a given event id (for Last-Event-ID reconnection).
|
|
1549
|
-
*/
|
|
931
|
+
/** Replay events since `lastEventId` for SSE reconnection. */
|
|
1550
932
|
getEventsSince(sessionId, lastEventId) {
|
|
1551
933
|
return this.sse.getEventsSince(sessionId, lastEventId);
|
|
1552
934
|
}
|
|
1553
935
|
/**
|
|
1554
|
-
* List sessions with query filters
|
|
1555
|
-
*/
|
|
1556
|
-
async listSessions(query) {
|
|
1557
|
-
return this.sessionIndex.listSessions(query);
|
|
1558
|
-
}
|
|
1559
|
-
/**
|
|
1560
|
-
* List all subagent sessions.
|
|
1561
|
-
* Subagent sessions have keys starting with 'subagent:'.
|
|
1562
|
-
*/
|
|
1563
|
-
async listSubagents(query) {
|
|
1564
|
-
return this.sessionIndex.listSubagents(query);
|
|
1565
|
-
}
|
|
1566
|
-
/**
|
|
1567
|
-
* Get a single session by key
|
|
1568
|
-
*/
|
|
1569
|
-
async getSession(key, options) {
|
|
1570
|
-
return this.sessionIndex.getSession(key, options);
|
|
1571
|
-
}
|
|
1572
|
-
/** Read-only: in-flight webchat agent run for this session key, if any. */
|
|
1573
|
-
getSessionActiveRun(sessionKey) {
|
|
1574
|
-
const key = sessionKey.trim();
|
|
1575
|
-
if (!key) return { active: false };
|
|
1576
|
-
const runId = this.activeWebchatRunBySession.get(key)?.trim();
|
|
1577
|
-
if (!runId) return { active: false };
|
|
1578
|
-
return {
|
|
1579
|
-
active: true,
|
|
1580
|
-
runId
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
async getSessionMessagePage(key, options) {
|
|
1584
|
-
return this.sessionIndex.getSessionMessagePage(key, options);
|
|
1585
|
-
}
|
|
1586
|
-
/**
|
|
1587
|
-
* Partial session metadata update (OpenClaw-style sessions.patch subset).
|
|
1588
|
-
*/
|
|
1589
|
-
async patchSession(key, body) {
|
|
1590
|
-
return this.sessionIndex.patchSession(key, body);
|
|
1591
|
-
}
|
|
1592
|
-
async listSessionCompactionCheckpoints(key) {
|
|
1593
|
-
return this.sessionIndex.listCompactionCheckpoints(key);
|
|
1594
|
-
}
|
|
1595
|
-
async getSessionCompactionCheckpoint(key, checkpointId) {
|
|
1596
|
-
return this.sessionIndex.getCompactionCheckpointDetail(key, checkpointId);
|
|
1597
|
-
}
|
|
1598
|
-
async restoreSessionCompactionCheckpoint(key, checkpointId) {
|
|
1599
|
-
await this.sessionIndex.restoreCompactionCheckpoint(key, checkpointId);
|
|
1600
|
-
this.agentService.evictSessionAgent(key);
|
|
1601
|
-
}
|
|
1602
|
-
async runSessionCompaction(key, options) {
|
|
1603
|
-
const result = await this.agentService.compactSession(key, options);
|
|
1604
|
-
if (result.compacted) this.sessionIndex.appendTranscriptContextEntry(key, {
|
|
1605
|
-
text: "Session transcript compacted",
|
|
1606
|
-
data: {
|
|
1607
|
-
firstKeptIndex: result.firstKeptIndex,
|
|
1608
|
-
tokensBefore: result.tokensBefore,
|
|
1609
|
-
tokensAfter: result.tokensAfter,
|
|
1610
|
-
summaryPreview: result.summary.slice(0, 500)
|
|
1611
|
-
}
|
|
1612
|
-
}).catch(() => {});
|
|
1613
|
-
return result;
|
|
1614
|
-
}
|
|
1615
|
-
/**
|
|
1616
|
-
* Delete a session
|
|
1617
|
-
*/
|
|
1618
|
-
async deleteSession(key) {
|
|
1619
|
-
const result = await this.sessionIndex.deleteSession(key);
|
|
1620
|
-
if (result) {
|
|
1621
|
-
this.agentService.evictSessionAgent(key);
|
|
1622
|
-
await retireSessionMcpRuntimeForSessionKey({
|
|
1623
|
-
sessionKey: key,
|
|
1624
|
-
reason: "session-delete"
|
|
1625
|
-
});
|
|
1626
|
-
}
|
|
1627
|
-
return { deleted: result };
|
|
1628
|
-
}
|
|
1629
|
-
/**
|
|
1630
|
-
* Delete multiple sessions
|
|
1631
|
-
*/
|
|
1632
|
-
async deleteSessions(keys) {
|
|
1633
|
-
return this.sessionIndex.deleteSessions(keys);
|
|
1634
|
-
}
|
|
1635
|
-
/**
|
|
1636
|
-
* Rename a session
|
|
1637
|
-
*/
|
|
1638
|
-
async renameSession(key, name) {
|
|
1639
|
-
await this.sessionIndex.renameSession(key, name);
|
|
1640
|
-
return { renamed: true };
|
|
1641
|
-
}
|
|
1642
|
-
/**
|
|
1643
|
-
* Tag a session
|
|
1644
|
-
*/
|
|
1645
|
-
async tagSession(key, tags) {
|
|
1646
|
-
await this.sessionIndex.tagSession(key, tags);
|
|
1647
|
-
return { tagged: true };
|
|
1648
|
-
}
|
|
1649
|
-
/**
|
|
1650
|
-
* Remove tags from a session
|
|
1651
|
-
*/
|
|
1652
|
-
async untagSession(key, tags) {
|
|
1653
|
-
await this.sessionIndex.untagSession(key, tags);
|
|
1654
|
-
return { untagged: true };
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* Archive a session
|
|
1658
|
-
*/
|
|
1659
|
-
async archiveSession(key) {
|
|
1660
|
-
await this.sessionIndex.archiveSession(key);
|
|
1661
|
-
return { archived: true };
|
|
1662
|
-
}
|
|
1663
|
-
/**
|
|
1664
|
-
* Unarchive a session
|
|
1665
|
-
*/
|
|
1666
|
-
async unarchiveSession(key) {
|
|
1667
|
-
await this.sessionIndex.unarchiveSession(key);
|
|
1668
|
-
return { unarchived: true };
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* Pin a session
|
|
1672
|
-
*/
|
|
1673
|
-
async pinSession(key) {
|
|
1674
|
-
await this.sessionIndex.pinSession(key);
|
|
1675
|
-
return { pinned: true };
|
|
1676
|
-
}
|
|
1677
|
-
/**
|
|
1678
|
-
* Unpin a session
|
|
1679
|
-
*/
|
|
1680
|
-
async unpinSession(key) {
|
|
1681
|
-
await this.sessionIndex.unpinSession(key);
|
|
1682
|
-
return { unpinned: true };
|
|
1683
|
-
}
|
|
1684
|
-
/**
|
|
1685
|
-
* Search sessions
|
|
1686
|
-
*/
|
|
1687
|
-
async searchSessions(query) {
|
|
1688
|
-
return this.sessionIndex.searchSessions(query);
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* Search within a session
|
|
1692
|
-
*/
|
|
1693
|
-
async searchInSession(key, keyword) {
|
|
1694
|
-
return this.sessionIndex.searchInSession(key, keyword);
|
|
1695
|
-
}
|
|
1696
|
-
/**
|
|
1697
|
-
* Export a session
|
|
1698
|
-
*/
|
|
1699
|
-
async exportSession(key, format) {
|
|
1700
|
-
return { content: await this.sessionIndex.exportSession(key, format) };
|
|
1701
|
-
}
|
|
1702
|
-
/**
|
|
1703
|
-
* Get session statistics
|
|
1704
|
-
*/
|
|
1705
|
-
async getSessionStats() {
|
|
1706
|
-
return this.sessionIndex.getStats();
|
|
1707
|
-
}
|
|
1708
|
-
/**
|
|
1709
|
-
* Get unique chat IDs from sessions, grouped by channel
|
|
1710
|
-
* Returns a list of channel/chatId pairs for cron job configuration.
|
|
1711
|
-
* `chatId` is the session-store routing suffix (unique per bot account + peer).
|
|
1712
|
-
* When `routing` exists, `peerId` is the platform id (e.g. Telegram numeric chat id).
|
|
1713
|
-
*/
|
|
1714
|
-
async getSessionChatIds(channel) {
|
|
1715
|
-
return getDistinctSessionChatIds(this.sessionIndex, channel);
|
|
1716
|
-
}
|
|
1717
|
-
/**
|
|
1718
936
|
* Validate authentication token from request headers.
|
|
1719
937
|
* Returns true if auth is disabled (mode: 'none') or token is valid.
|
|
1720
938
|
*/
|
|
@@ -1758,7 +976,7 @@ var GatewayService = class {
|
|
|
1758
976
|
}
|
|
1759
977
|
}
|
|
1760
978
|
};
|
|
1761
|
-
await this.
|
|
979
|
+
await this.saveConfig(this.config);
|
|
1762
980
|
log.info({ tokenPreview: `${newToken.slice(0, 8)}...` }, "Gateway token refreshed");
|
|
1763
981
|
return newToken;
|
|
1764
982
|
}
|