@xgjktech/xg_cwork_im 1.19.21 → 1.19.23
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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/src/connection/account-connection.d.ts +37 -0
- package/dist/src/connection/account-connection.d.ts.map +1 -0
- package/dist/src/connection/account-connection.js +548 -0
- package/dist/src/connection/account-connection.js.map +1 -0
- package/dist/src/connection/account-reconciler.d.ts +64 -0
- package/dist/src/connection/account-reconciler.d.ts.map +1 -0
- package/dist/src/connection/account-reconciler.js +314 -0
- package/dist/src/connection/account-reconciler.js.map +1 -0
- package/dist/src/connection/account-reconciler.test.d.ts +2 -0
- package/dist/src/connection/account-reconciler.test.d.ts.map +1 -0
- package/dist/src/connection/account-reconciler.test.js +166 -0
- package/dist/src/connection/account-reconciler.test.js.map +1 -0
- package/dist/src/connection/agent-stream-client-registry.d.ts +8 -0
- package/dist/src/connection/agent-stream-client-registry.d.ts.map +1 -0
- package/dist/src/connection/agent-stream-client-registry.js +19 -0
- package/dist/src/connection/agent-stream-client-registry.js.map +1 -0
- package/dist/src/connection/connection.d.ts +116 -0
- package/dist/src/connection/connection.d.ts.map +1 -0
- package/dist/src/connection/connection.js +469 -0
- package/dist/src/connection/connection.js.map +1 -0
- package/dist/src/connection/connection.test.d.ts +2 -0
- package/dist/src/connection/connection.test.d.ts.map +1 -0
- package/dist/src/connection/connection.test.js +126 -0
- package/dist/src/connection/connection.test.js.map +1 -0
- package/dist/src/connection/ws-inbound-schema.d.ts +14 -0
- package/dist/src/connection/ws-inbound-schema.d.ts.map +1 -0
- package/dist/src/connection/ws-inbound-schema.js +68 -0
- package/dist/src/connection/ws-inbound-schema.js.map +1 -0
- package/dist/src/connection/ws-inbound-schema.test.d.ts +2 -0
- package/dist/src/connection/ws-inbound-schema.test.d.ts.map +1 -0
- package/dist/src/connection/ws-inbound-schema.test.js +58 -0
- package/dist/src/connection/ws-inbound-schema.test.js.map +1 -0
- package/dist/src/delivery/assistant-item-delivery.d.ts +27 -0
- package/dist/src/delivery/assistant-item-delivery.d.ts.map +1 -0
- package/dist/src/delivery/assistant-item-delivery.js +134 -0
- package/dist/src/delivery/assistant-item-delivery.js.map +1 -0
- package/dist/src/delivery/assistant-item-delivery.test.d.ts +2 -0
- package/dist/src/delivery/assistant-item-delivery.test.d.ts.map +1 -0
- package/dist/src/delivery/assistant-item-delivery.test.js +116 -0
- package/dist/src/delivery/assistant-item-delivery.test.js.map +1 -0
- package/dist/src/delivery/assistant-item-sink.d.ts +17 -0
- package/dist/src/delivery/assistant-item-sink.d.ts.map +1 -0
- package/dist/src/delivery/assistant-item-sink.js +34 -0
- package/dist/src/delivery/assistant-item-sink.js.map +1 -0
- package/dist/src/delivery/block-streaming-config.test.d.ts +2 -0
- package/dist/src/delivery/block-streaming-config.test.d.ts.map +1 -0
- package/dist/src/delivery/block-streaming-config.test.js +91 -0
- package/dist/src/delivery/block-streaming-config.test.js.map +1 -0
- package/dist/src/delivery/deliver-text.d.ts +30 -0
- package/dist/src/delivery/deliver-text.d.ts.map +1 -0
- package/dist/src/delivery/deliver-text.js +88 -0
- package/dist/src/delivery/deliver-text.js.map +1 -0
- package/dist/src/delivery/deliver-text.test.d.ts +2 -0
- package/dist/src/delivery/deliver-text.test.d.ts.map +1 -0
- package/dist/src/delivery/deliver-text.test.js +117 -0
- package/dist/src/delivery/deliver-text.test.js.map +1 -0
- package/dist/src/delivery/im-tool-progress.d.ts +4 -0
- package/dist/src/delivery/im-tool-progress.d.ts.map +1 -0
- package/dist/src/delivery/im-tool-progress.js +87 -0
- package/dist/src/delivery/im-tool-progress.js.map +1 -0
- package/dist/src/delivery/inbound-terminal-delivery.d.ts +77 -0
- package/dist/src/delivery/inbound-terminal-delivery.d.ts.map +1 -0
- package/dist/src/delivery/inbound-terminal-delivery.js +251 -0
- package/dist/src/delivery/inbound-terminal-delivery.js.map +1 -0
- package/dist/src/delivery/inbound-terminal-state.d.ts +68 -0
- package/dist/src/delivery/inbound-terminal-state.d.ts.map +1 -0
- package/dist/src/delivery/inbound-terminal-state.js +185 -0
- package/dist/src/delivery/inbound-terminal-state.js.map +1 -0
- package/dist/src/delivery/inbound-terminal-state.test.d.ts +2 -0
- package/dist/src/delivery/inbound-terminal-state.test.d.ts.map +1 -0
- package/dist/src/delivery/inbound-terminal-state.test.js +224 -0
- package/dist/src/delivery/inbound-terminal-state.test.js.map +1 -0
- package/dist/src/delivery/send-file-event.d.ts +26 -0
- package/dist/src/delivery/send-file-event.d.ts.map +1 -0
- package/dist/src/delivery/send-file-event.js +33 -0
- package/dist/src/delivery/send-file-event.js.map +1 -0
- package/dist/src/delivery/send-file-event.test.d.ts +2 -0
- package/dist/src/delivery/send-file-event.test.d.ts.map +1 -0
- package/dist/src/delivery/send-file-event.test.js +86 -0
- package/dist/src/delivery/send-file-event.test.js.map +1 -0
- package/dist/src/delivery/send-service.d.ts +83 -0
- package/dist/src/delivery/send-service.d.ts.map +1 -0
- package/dist/src/delivery/send-service.js +324 -0
- package/dist/src/delivery/send-service.js.map +1 -0
- package/dist/src/delivery/send-service.test.d.ts +2 -0
- package/dist/src/delivery/send-service.test.d.ts.map +1 -0
- package/dist/src/delivery/send-service.test.js +40 -0
- package/dist/src/delivery/send-service.test.js.map +1 -0
- package/dist/src/delivery/thinking-ws-progress.d.ts +24 -0
- package/dist/src/delivery/thinking-ws-progress.d.ts.map +1 -0
- package/dist/src/delivery/thinking-ws-progress.js +45 -0
- package/dist/src/delivery/thinking-ws-progress.js.map +1 -0
- package/dist/src/delivery/thinking-ws-progress.test.d.ts +2 -0
- package/dist/src/delivery/thinking-ws-progress.test.d.ts.map +1 -0
- package/dist/src/delivery/thinking-ws-progress.test.js +38 -0
- package/dist/src/delivery/thinking-ws-progress.test.js.map +1 -0
- package/dist/src/delivery/turn-deliver-buffer.d.ts +60 -0
- package/dist/src/delivery/turn-deliver-buffer.d.ts.map +1 -0
- package/dist/src/delivery/turn-deliver-buffer.js +133 -0
- package/dist/src/delivery/turn-deliver-buffer.js.map +1 -0
- package/dist/src/delivery/turn-deliver-buffer.test.d.ts +2 -0
- package/dist/src/delivery/turn-deliver-buffer.test.d.ts.map +1 -0
- package/dist/src/delivery/turn-deliver-buffer.test.js +184 -0
- package/dist/src/delivery/turn-deliver-buffer.test.js.map +1 -0
- package/dist/src/delivery/user-facing-errors.d.ts +32 -0
- package/dist/src/delivery/user-facing-errors.d.ts.map +1 -0
- package/dist/src/delivery/user-facing-errors.js +120 -0
- package/dist/src/delivery/user-facing-errors.js.map +1 -0
- package/dist/src/delivery/user-facing-errors.test.d.ts +2 -0
- package/dist/src/delivery/user-facing-errors.test.d.ts.map +1 -0
- package/dist/src/delivery/user-facing-errors.test.js +102 -0
- package/dist/src/delivery/user-facing-errors.test.js.map +1 -0
- package/dist/src/inbound/dispatch-mentioned-reply.d.ts +47 -0
- package/dist/src/inbound/dispatch-mentioned-reply.d.ts.map +1 -0
- package/dist/src/inbound/dispatch-mentioned-reply.js +1014 -0
- package/dist/src/inbound/dispatch-mentioned-reply.js.map +1 -0
- package/dist/src/inbound/inbound-archive.d.ts +4 -0
- package/dist/src/inbound/inbound-archive.d.ts.map +1 -0
- package/dist/src/inbound/inbound-archive.js +105 -0
- package/dist/src/inbound/inbound-archive.js.map +1 -0
- package/dist/src/inbound/inbound-attachment-meta.d.ts +13 -0
- package/dist/src/inbound/inbound-attachment-meta.d.ts.map +1 -0
- package/dist/src/inbound/inbound-attachment-meta.js +39 -0
- package/dist/src/inbound/inbound-attachment-meta.js.map +1 -0
- package/dist/src/inbound/inbound-chat-type.d.ts +33 -0
- package/dist/src/inbound/inbound-chat-type.d.ts.map +1 -0
- package/dist/src/inbound/inbound-chat-type.js +52 -0
- package/dist/src/inbound/inbound-chat-type.js.map +1 -0
- package/dist/src/inbound/inbound-display.d.ts +41 -0
- package/dist/src/inbound/inbound-display.d.ts.map +1 -0
- package/dist/src/inbound/inbound-display.js +170 -0
- package/dist/src/inbound/inbound-display.js.map +1 -0
- package/dist/src/inbound/reply-dispatch-driver.d.ts +89 -0
- package/dist/src/inbound/reply-dispatch-driver.d.ts.map +1 -0
- package/dist/src/inbound/reply-dispatch-driver.js +294 -0
- package/dist/src/inbound/reply-dispatch-driver.js.map +1 -0
- package/dist/src/inbound/reply-dispatch-driver.test.d.ts +2 -0
- package/dist/src/inbound/reply-dispatch-driver.test.d.ts.map +1 -0
- package/dist/src/inbound/reply-dispatch-driver.test.js +363 -0
- package/dist/src/inbound/reply-dispatch-driver.test.js.map +1 -0
- package/dist/src/inbound/resolve-inbound-group-prompt.d.ts +37 -0
- package/dist/src/inbound/resolve-inbound-group-prompt.d.ts.map +1 -0
- package/dist/src/inbound/resolve-inbound-group-prompt.js +57 -0
- package/dist/src/inbound/resolve-inbound-group-prompt.js.map +1 -0
- package/dist/src/plan/action-run-event.d.ts +20 -0
- package/dist/src/plan/action-run-event.d.ts.map +1 -0
- package/dist/src/plan/action-run-event.js +62 -0
- package/dist/src/plan/action-run-event.js.map +1 -0
- package/dist/src/plan/action-run-event.test.d.ts +2 -0
- package/dist/src/plan/action-run-event.test.d.ts.map +1 -0
- package/dist/src/plan/action-run-event.test.js +83 -0
- package/dist/src/plan/action-run-event.test.js.map +1 -0
- package/dist/src/plan/action-store-access.d.ts +29 -0
- package/dist/src/plan/action-store-access.d.ts.map +1 -0
- package/dist/src/plan/action-store-access.js +81 -0
- package/dist/src/plan/action-store-access.js.map +1 -0
- package/dist/src/plan/action-store-lifecycle.test.d.ts +2 -0
- package/dist/src/plan/action-store-lifecycle.test.d.ts.map +1 -0
- package/dist/src/plan/action-store-lifecycle.test.js +195 -0
- package/dist/src/plan/action-store-lifecycle.test.js.map +1 -0
- package/dist/src/plan/plan-core-adapter.d.ts +54 -0
- package/dist/src/plan/plan-core-adapter.d.ts.map +1 -0
- package/dist/src/plan/plan-core-adapter.js +104 -0
- package/dist/src/plan/plan-core-adapter.js.map +1 -0
- package/dist/src/plan/plan-core-adapter.test.d.ts +2 -0
- package/dist/src/plan/plan-core-adapter.test.d.ts.map +1 -0
- package/dist/src/plan/plan-core-adapter.test.js +183 -0
- package/dist/src/plan/plan-core-adapter.test.js.map +1 -0
- package/dist/src/plan/plan-core-db.d.ts +22 -0
- package/dist/src/plan/plan-core-db.d.ts.map +1 -0
- package/dist/src/plan/plan-core-db.js +91 -0
- package/dist/src/plan/plan-core-db.js.map +1 -0
- package/dist/src/plan/plan-core-db.test.d.ts +2 -0
- package/dist/src/plan/plan-core-db.test.d.ts.map +1 -0
- package/dist/src/plan/plan-core-db.test.js +115 -0
- package/dist/src/plan/plan-core-db.test.js.map +1 -0
- package/dist/src/plan/plan-core-snapshot.d.ts +23 -0
- package/dist/src/plan/plan-core-snapshot.d.ts.map +1 -0
- package/dist/src/plan/plan-core-snapshot.js +66 -0
- package/dist/src/plan/plan-core-snapshot.js.map +1 -0
- package/dist/src/plan/plan-core-snapshot.test.d.ts +2 -0
- package/dist/src/plan/plan-core-snapshot.test.d.ts.map +1 -0
- package/dist/src/plan/plan-core-snapshot.test.js +157 -0
- package/dist/src/plan/plan-core-snapshot.test.js.map +1 -0
- package/dist/src/plan/plan-stat-event.d.ts +17 -0
- package/dist/src/plan/plan-stat-event.d.ts.map +1 -0
- package/dist/src/plan/plan-stat-event.js +41 -0
- package/dist/src/plan/plan-stat-event.js.map +1 -0
- package/dist/src/plan/plan-stat-event.test.d.ts +2 -0
- package/dist/src/plan/plan-stat-event.test.d.ts.map +1 -0
- package/dist/src/plan/plan-stat-event.test.js +131 -0
- package/dist/src/plan/plan-stat-event.test.js.map +1 -0
- package/dist/src/plan/plan-tool-middleware.d.ts +19 -0
- package/dist/src/plan/plan-tool-middleware.d.ts.map +1 -0
- package/dist/src/plan/plan-tool-middleware.js +63 -0
- package/dist/src/plan/plan-tool-middleware.js.map +1 -0
- package/dist/src/plan/plan-tool-middleware.test.d.ts +2 -0
- package/dist/src/plan/plan-tool-middleware.test.d.ts.map +1 -0
- package/dist/src/plan/plan-tool-middleware.test.js +103 -0
- package/dist/src/plan/plan-tool-middleware.test.js.map +1 -0
- package/dist/src/plan/plan-ws-registry.d.ts +15 -0
- package/dist/src/plan/plan-ws-registry.d.ts.map +1 -0
- package/dist/src/plan/plan-ws-registry.js +39 -0
- package/dist/src/plan/plan-ws-registry.js.map +1 -0
- package/dist/src/plan/plan-ws-registry.test.d.ts +2 -0
- package/dist/src/plan/plan-ws-registry.test.d.ts.map +1 -0
- package/dist/src/plan/plan-ws-registry.test.js +61 -0
- package/dist/src/plan/plan-ws-registry.test.js.map +1 -0
- package/dist/src/plan/tool-event-adapter.d.ts +31 -0
- package/dist/src/plan/tool-event-adapter.d.ts.map +1 -0
- package/dist/src/plan/tool-event-adapter.js +83 -0
- package/dist/src/plan/tool-event-adapter.js.map +1 -0
- package/dist/src/plan/tool-event-adapter.test.d.ts +2 -0
- package/dist/src/plan/tool-event-adapter.test.d.ts.map +1 -0
- package/dist/src/plan/tool-event-adapter.test.js +93 -0
- package/dist/src/plan/tool-event-adapter.test.js.map +1 -0
- package/dist/src/plugin/auth.d.ts +32 -0
- package/dist/src/plugin/auth.d.ts.map +1 -0
- package/dist/src/plugin/auth.js +70 -0
- package/dist/src/plugin/auth.js.map +1 -0
- package/dist/src/plugin/channel-config.d.ts +716 -0
- package/dist/src/plugin/channel-config.d.ts.map +1 -0
- package/dist/src/plugin/channel-config.js +405 -0
- package/dist/src/plugin/channel-config.js.map +1 -0
- package/dist/src/plugin/channel-config.test.d.ts +2 -0
- package/dist/src/plugin/channel-config.test.d.ts.map +1 -0
- package/dist/src/plugin/channel-config.test.js +113 -0
- package/dist/src/plugin/channel-config.test.js.map +1 -0
- package/dist/src/plugin/channel-disabled-account.test.d.ts +2 -0
- package/dist/src/plugin/channel-disabled-account.test.d.ts.map +1 -0
- package/dist/src/plugin/channel-disabled-account.test.js +44 -0
- package/dist/src/plugin/channel-disabled-account.test.js.map +1 -0
- package/dist/src/plugin/channel-log.d.ts +17 -0
- package/dist/src/plugin/channel-log.d.ts.map +1 -0
- package/dist/src/plugin/channel-log.js +45 -0
- package/dist/src/plugin/channel-log.js.map +1 -0
- package/dist/src/plugin/channel.d.ts +17 -0
- package/dist/src/plugin/channel.d.ts.map +1 -0
- package/dist/src/plugin/channel.js +272 -0
- package/dist/src/plugin/channel.js.map +1 -0
- package/dist/src/plugin/plugin-dispose.d.ts +22 -0
- package/dist/src/plugin/plugin-dispose.d.ts.map +1 -0
- package/dist/src/plugin/plugin-dispose.js +66 -0
- package/dist/src/plugin/plugin-dispose.js.map +1 -0
- package/dist/src/plugin/process-shared-store.d.ts +48 -0
- package/dist/src/plugin/process-shared-store.d.ts.map +1 -0
- package/dist/src/plugin/process-shared-store.js +89 -0
- package/dist/src/plugin/process-shared-store.js.map +1 -0
- package/dist/src/plugin/process-shared-store.test.d.ts +2 -0
- package/dist/src/plugin/process-shared-store.test.d.ts.map +1 -0
- package/dist/src/plugin/process-shared-store.test.js +60 -0
- package/dist/src/plugin/process-shared-store.test.js.map +1 -0
- package/dist/src/plugin/recommended-system-prompt.d.ts +3 -0
- package/dist/src/plugin/recommended-system-prompt.d.ts.map +1 -0
- package/dist/src/plugin/recommended-system-prompt.js +8 -0
- package/dist/src/plugin/recommended-system-prompt.js.map +1 -0
- package/dist/src/plugin/types.d.ts +433 -0
- package/dist/src/plugin/types.d.ts.map +1 -0
- package/dist/src/plugin/types.js +32 -0
- package/dist/src/plugin/types.js.map +1 -0
- package/dist/src/session/agent-context-types.d.ts +241 -0
- package/dist/src/session/agent-context-types.d.ts.map +1 -0
- package/dist/src/session/agent-context-types.js +142 -0
- package/dist/src/session/agent-context-types.js.map +1 -0
- package/dist/src/session/agent-context-types.test.d.ts +2 -0
- package/dist/src/session/agent-context-types.test.d.ts.map +1 -0
- package/dist/src/session/agent-context-types.test.js +140 -0
- package/dist/src/session/agent-context-types.test.js.map +1 -0
- package/dist/src/session/auto-model-router.d.ts +36 -0
- package/dist/src/session/auto-model-router.d.ts.map +1 -0
- package/dist/src/session/auto-model-router.js +60 -0
- package/dist/src/session/auto-model-router.js.map +1 -0
- package/dist/src/session/auto-model-router.test.d.ts +2 -0
- package/dist/src/session/auto-model-router.test.d.ts.map +1 -0
- package/dist/src/session/auto-model-router.test.js +99 -0
- package/dist/src/session/auto-model-router.test.js.map +1 -0
- package/dist/src/session/build-project-prompt.d.ts +40 -0
- package/dist/src/session/build-project-prompt.d.ts.map +1 -0
- package/dist/src/session/build-project-prompt.js +190 -0
- package/dist/src/session/build-project-prompt.js.map +1 -0
- package/dist/src/session/build-project-prompt.test.d.ts +2 -0
- package/dist/src/session/build-project-prompt.test.d.ts.map +1 -0
- package/dist/src/session/build-project-prompt.test.js +100 -0
- package/dist/src/session/build-project-prompt.test.js.map +1 -0
- package/dist/src/session/inbound-model.d.ts +39 -0
- package/dist/src/session/inbound-model.d.ts.map +1 -0
- package/dist/src/session/inbound-model.js +66 -0
- package/dist/src/session/inbound-model.js.map +1 -0
- package/dist/src/session/inbound-model.test.d.ts +2 -0
- package/dist/src/session/inbound-model.test.d.ts.map +1 -0
- package/dist/src/session/inbound-model.test.js +88 -0
- package/dist/src/session/inbound-model.test.js.map +1 -0
- package/dist/src/session/per-message-fallback-notice.d.ts +43 -0
- package/dist/src/session/per-message-fallback-notice.d.ts.map +1 -0
- package/dist/src/session/per-message-fallback-notice.js +93 -0
- package/dist/src/session/per-message-fallback-notice.js.map +1 -0
- package/dist/src/session/per-message-fallback-notice.test.d.ts +2 -0
- package/dist/src/session/per-message-fallback-notice.test.d.ts.map +1 -0
- package/dist/src/session/per-message-fallback-notice.test.js +47 -0
- package/dist/src/session/per-message-fallback-notice.test.js.map +1 -0
- package/dist/src/session/per-message-model-pending.d.ts +52 -0
- package/dist/src/session/per-message-model-pending.d.ts.map +1 -0
- package/dist/src/session/per-message-model-pending.js +134 -0
- package/dist/src/session/per-message-model-pending.js.map +1 -0
- package/dist/src/session/register-group-prompt-hook.d.ts +17 -0
- package/dist/src/session/register-group-prompt-hook.d.ts.map +1 -0
- package/dist/src/session/register-group-prompt-hook.js +45 -0
- package/dist/src/session/register-group-prompt-hook.js.map +1 -0
- package/dist/src/session/register-group-prompt-hook.test.d.ts +2 -0
- package/dist/src/session/register-group-prompt-hook.test.d.ts.map +1 -0
- package/dist/src/session/register-group-prompt-hook.test.js +60 -0
- package/dist/src/session/register-group-prompt-hook.test.js.map +1 -0
- package/dist/src/session/register-per-message-model-hook.d.ts +14 -0
- package/dist/src/session/register-per-message-model-hook.d.ts.map +1 -0
- package/dist/src/session/register-per-message-model-hook.js +48 -0
- package/dist/src/session/register-per-message-model-hook.js.map +1 -0
- package/dist/src/session/register-per-message-model-hook.test.d.ts +2 -0
- package/dist/src/session/register-per-message-model-hook.test.d.ts.map +1 -0
- package/dist/src/session/register-per-message-model-hook.test.js +208 -0
- package/dist/src/session/register-per-message-model-hook.test.js.map +1 -0
- package/dist/src/session/register-run-model-context-hook.d.ts +11 -0
- package/dist/src/session/register-run-model-context-hook.d.ts.map +1 -0
- package/dist/src/session/register-run-model-context-hook.js +23 -0
- package/dist/src/session/register-run-model-context-hook.js.map +1 -0
- package/dist/src/session/run-model-context.d.ts +45 -0
- package/dist/src/session/run-model-context.d.ts.map +1 -0
- package/dist/src/session/run-model-context.js +108 -0
- package/dist/src/session/run-model-context.js.map +1 -0
- package/dist/src/session/run-model-context.test.d.ts +2 -0
- package/dist/src/session/run-model-context.test.d.ts.map +1 -0
- package/dist/src/session/run-model-context.test.js +68 -0
- package/dist/src/session/run-model-context.test.js.map +1 -0
- package/dist/src/session/session-env-store.d.ts +55 -0
- package/dist/src/session/session-env-store.d.ts.map +1 -0
- package/dist/src/session/session-env-store.js +328 -0
- package/dist/src/session/session-env-store.js.map +1 -0
- package/dist/src/session/session-env-store.test.d.ts +2 -0
- package/dist/src/session/session-env-store.test.d.ts.map +1 -0
- package/dist/src/session/session-env-store.test.js +151 -0
- package/dist/src/session/session-env-store.test.js.map +1 -0
- package/dist/src/session/session-group-prompt.d.ts +34 -0
- package/dist/src/session/session-group-prompt.d.ts.map +1 -0
- package/dist/src/session/session-group-prompt.js +101 -0
- package/dist/src/session/session-group-prompt.js.map +1 -0
- package/dist/src/session/session-group-prompt.test.d.ts +2 -0
- package/dist/src/session/session-group-prompt.test.d.ts.map +1 -0
- package/dist/src/session/session-group-prompt.test.js +72 -0
- package/dist/src/session/session-group-prompt.test.js.map +1 -0
- package/dist/src/session/session-im-context.d.ts +15 -0
- package/dist/src/session/session-im-context.d.ts.map +1 -0
- package/dist/src/session/session-im-context.js +54 -0
- package/dist/src/session/session-im-context.js.map +1 -0
- package/dist/src/session/session-model-fallback.d.ts +13 -0
- package/dist/src/session/session-model-fallback.d.ts.map +1 -0
- package/dist/src/session/session-model-fallback.js +24 -0
- package/dist/src/session/session-model-fallback.js.map +1 -0
- package/dist/src/tools/active-cron-context-store.d.ts +20 -0
- package/dist/src/tools/active-cron-context-store.d.ts.map +1 -0
- package/dist/src/tools/active-cron-context-store.js +73 -0
- package/dist/src/tools/active-cron-context-store.js.map +1 -0
- package/dist/src/tools/cron-appkey-binding-store.d.ts +29 -0
- package/dist/src/tools/cron-appkey-binding-store.d.ts.map +1 -0
- package/dist/src/tools/cron-appkey-binding-store.js +239 -0
- package/dist/src/tools/cron-appkey-binding-store.js.map +1 -0
- package/dist/src/tools/cron-appkey-binding-store.test.d.ts +2 -0
- package/dist/src/tools/cron-appkey-binding-store.test.d.ts.map +1 -0
- package/dist/src/tools/cron-appkey-binding-store.test.js +387 -0
- package/dist/src/tools/cron-appkey-binding-store.test.js.map +1 -0
- package/dist/src/tools/group-history-tool.d.ts +31 -0
- package/dist/src/tools/group-history-tool.d.ts.map +1 -0
- package/dist/src/tools/group-history-tool.js +177 -0
- package/dist/src/tools/group-history-tool.js.map +1 -0
- package/dist/src/tools/register-exec-env-hook.d.ts +44 -0
- package/dist/src/tools/register-exec-env-hook.d.ts.map +1 -0
- package/dist/src/tools/register-exec-env-hook.js +473 -0
- package/dist/src/tools/register-exec-env-hook.js.map +1 -0
- package/dist/src/tools/register-exec-env-hook.test.d.ts +2 -0
- package/dist/src/tools/register-exec-env-hook.test.d.ts.map +1 -0
- package/dist/src/tools/register-exec-env-hook.test.js +189 -0
- package/dist/src/tools/register-exec-env-hook.test.js.map +1 -0
- package/dist/src/tools/send-file-tool.d.ts +81 -0
- package/dist/src/tools/send-file-tool.d.ts.map +1 -0
- package/dist/src/tools/send-file-tool.js +363 -0
- package/dist/src/tools/send-file-tool.js.map +1 -0
- package/dist/src/tools/send-file-tool.test.d.ts +2 -0
- package/dist/src/tools/send-file-tool.test.d.ts.map +1 -0
- package/dist/src/tools/send-file-tool.test.js +176 -0
- package/dist/src/tools/send-file-tool.test.js.map +1 -0
- package/dist/src/tools/send-group-message-tool.d.ts +17 -0
- package/dist/src/tools/send-group-message-tool.d.ts.map +1 -0
- package/dist/src/tools/send-group-message-tool.js +82 -0
- package/dist/src/tools/send-group-message-tool.js.map +1 -0
- package/dist/src/tools/tool-json-result.d.ts +14 -0
- package/dist/src/tools/tool-json-result.d.ts.map +1 -0
- package/dist/src/tools/tool-json-result.js +20 -0
- package/dist/src/tools/tool-json-result.js.map +1 -0
- package/dist/src/turn/active-round-registry.d.ts +35 -0
- package/dist/src/turn/active-round-registry.d.ts.map +1 -0
- package/dist/src/turn/active-round-registry.js +85 -0
- package/dist/src/turn/active-round-registry.js.map +1 -0
- package/dist/src/turn/active-round-registry.test.d.ts +2 -0
- package/dist/src/turn/active-round-registry.test.d.ts.map +1 -0
- package/dist/src/turn/active-round-registry.test.js +62 -0
- package/dist/src/turn/active-round-registry.test.js.map +1 -0
- package/dist/src/turn/interrupt-round.d.ts +9 -0
- package/dist/src/turn/interrupt-round.d.ts.map +1 -0
- package/dist/src/turn/interrupt-round.js +44 -0
- package/dist/src/turn/interrupt-round.js.map +1 -0
- package/dist/src/turn/interrupt-round.test.d.ts +2 -0
- package/dist/src/turn/interrupt-round.test.d.ts.map +1 -0
- package/dist/src/turn/interrupt-round.test.js +133 -0
- package/dist/src/turn/interrupt-round.test.js.map +1 -0
- package/dist/src/turn/item-event-guard.d.ts +28 -0
- package/dist/src/turn/item-event-guard.d.ts.map +1 -0
- package/dist/src/turn/item-event-guard.js +22 -0
- package/dist/src/turn/item-event-guard.js.map +1 -0
- package/dist/src/turn/item-event-guard.test.d.ts +2 -0
- package/dist/src/turn/item-event-guard.test.d.ts.map +1 -0
- package/dist/src/turn/item-event-guard.test.js +55 -0
- package/dist/src/turn/item-event-guard.test.js.map +1 -0
- package/dist/src/turn/run-usage-session.d.ts +13 -0
- package/dist/src/turn/run-usage-session.d.ts.map +1 -0
- package/dist/src/turn/run-usage-session.js +41 -0
- package/dist/src/turn/run-usage-session.js.map +1 -0
- package/dist/src/turn/run-usage.d.ts +67 -0
- package/dist/src/turn/run-usage.d.ts.map +1 -0
- package/dist/src/turn/run-usage.js +119 -0
- package/dist/src/turn/run-usage.js.map +1 -0
- package/dist/src/turn/run-usage.test.d.ts +2 -0
- package/dist/src/turn/run-usage.test.d.ts.map +1 -0
- package/dist/src/turn/run-usage.test.js +178 -0
- package/dist/src/turn/run-usage.test.js.map +1 -0
- package/dist/src/turn/subagent-monitor.d.ts +45 -0
- package/dist/src/turn/subagent-monitor.d.ts.map +1 -0
- package/dist/src/turn/subagent-monitor.js +498 -0
- package/dist/src/turn/subagent-monitor.js.map +1 -0
- package/dist/src/turn/subagent-monitor.test.d.ts +2 -0
- package/dist/src/turn/subagent-monitor.test.d.ts.map +1 -0
- package/dist/src/turn/subagent-monitor.test.js +335 -0
- package/dist/src/turn/subagent-monitor.test.js.map +1 -0
- package/dist/src/turn/turn-agent-event-subscription.d.ts +29 -0
- package/dist/src/turn/turn-agent-event-subscription.d.ts.map +1 -0
- package/dist/src/turn/turn-agent-event-subscription.js +350 -0
- package/dist/src/turn/turn-agent-event-subscription.js.map +1 -0
- package/dist/src/turn/turn-agent-event-subscription.test.d.ts +2 -0
- package/dist/src/turn/turn-agent-event-subscription.test.d.ts.map +1 -0
- package/dist/src/turn/turn-agent-event-subscription.test.js +257 -0
- package/dist/src/turn/turn-agent-event-subscription.test.js.map +1 -0
- package/dist/src/turn/turn-end-controller.d.ts +61 -0
- package/dist/src/turn/turn-end-controller.d.ts.map +1 -0
- package/dist/src/turn/turn-end-controller.js +239 -0
- package/dist/src/turn/turn-end-controller.js.map +1 -0
- package/dist/src/turn/turn-end-controller.test.d.ts +2 -0
- package/dist/src/turn/turn-end-controller.test.d.ts.map +1 -0
- package/dist/src/turn/turn-end-controller.test.js +97 -0
- package/dist/src/turn/turn-end-controller.test.js.map +1 -0
- package/dist/src/turn/ws-run-event-unmapped.d.ts +10 -0
- package/dist/src/turn/ws-run-event-unmapped.d.ts.map +1 -0
- package/dist/src/turn/ws-run-event-unmapped.js +16 -0
- package/dist/src/turn/ws-run-event-unmapped.js.map +1 -0
- package/dist/src/turn/ws-run-event-unmapped.test.d.ts +2 -0
- package/dist/src/turn/ws-run-event-unmapped.test.d.ts.map +1 -0
- package/dist/src/turn/ws-run-event-unmapped.test.js +15 -0
- package/dist/src/turn/ws-run-event-unmapped.test.js.map +1 -0
- package/dist/src/workspace/apply-sync-mapping.d.ts +15 -0
- package/dist/src/workspace/apply-sync-mapping.d.ts.map +1 -0
- package/dist/src/workspace/apply-sync-mapping.js +98 -0
- package/dist/src/workspace/apply-sync-mapping.js.map +1 -0
- package/dist/src/workspace/connection-workspace-event.test.d.ts +2 -0
- package/dist/src/workspace/connection-workspace-event.test.d.ts.map +1 -0
- package/dist/src/workspace/connection-workspace-event.test.js +74 -0
- package/dist/src/workspace/connection-workspace-event.test.js.map +1 -0
- package/dist/src/workspace/inbound-file-download.d.ts +15 -0
- package/dist/src/workspace/inbound-file-download.d.ts.map +1 -0
- package/dist/src/workspace/inbound-file-download.js +48 -0
- package/dist/src/workspace/inbound-file-download.js.map +1 -0
- package/dist/src/workspace/inbound-input-media.d.ts +43 -0
- package/dist/src/workspace/inbound-input-media.d.ts.map +1 -0
- package/dist/src/workspace/inbound-input-media.js +230 -0
- package/dist/src/workspace/inbound-input-media.js.map +1 -0
- package/dist/src/workspace/inbound-media-local.d.ts +49 -0
- package/dist/src/workspace/inbound-media-local.d.ts.map +1 -0
- package/dist/src/workspace/inbound-media-local.js +194 -0
- package/dist/src/workspace/inbound-media-local.js.map +1 -0
- package/dist/src/workspace/nas-site.d.ts +16 -0
- package/dist/src/workspace/nas-site.d.ts.map +1 -0
- package/dist/src/workspace/nas-site.js +17 -0
- package/dist/src/workspace/nas-site.js.map +1 -0
- package/dist/src/workspace/nas-volume-fs-sync.d.ts +37 -0
- package/dist/src/workspace/nas-volume-fs-sync.d.ts.map +1 -0
- package/dist/src/workspace/nas-volume-fs-sync.js +156 -0
- package/dist/src/workspace/nas-volume-fs-sync.js.map +1 -0
- package/dist/src/workspace/nas-volume-fs-sync.test.d.ts +2 -0
- package/dist/src/workspace/nas-volume-fs-sync.test.d.ts.map +1 -0
- package/dist/src/workspace/nas-volume-fs-sync.test.js +49 -0
- package/dist/src/workspace/nas-volume-fs-sync.test.js.map +1 -0
- package/dist/src/workspace/nas-volumes.d.ts +73 -0
- package/dist/src/workspace/nas-volumes.d.ts.map +1 -0
- package/dist/src/workspace/nas-volumes.js +546 -0
- package/dist/src/workspace/nas-volumes.js.map +1 -0
- package/dist/src/workspace/nas-volumes.test.d.ts +2 -0
- package/dist/src/workspace/nas-volumes.test.d.ts.map +1 -0
- package/dist/src/workspace/nas-volumes.test.js +386 -0
- package/dist/src/workspace/nas-volumes.test.js.map +1 -0
- package/dist/src/workspace/project-path-normalize.d.ts +30 -0
- package/dist/src/workspace/project-path-normalize.d.ts.map +1 -0
- package/dist/src/workspace/project-path-normalize.js +101 -0
- package/dist/src/workspace/project-path-normalize.js.map +1 -0
- package/dist/src/workspace/resource-file.d.ts +119 -0
- package/dist/src/workspace/resource-file.d.ts.map +1 -0
- package/dist/src/workspace/resource-file.js +533 -0
- package/dist/src/workspace/resource-file.js.map +1 -0
- package/dist/src/workspace/resource-file.test.d.ts +2 -0
- package/dist/src/workspace/resource-file.test.d.ts.map +1 -0
- package/dist/src/workspace/resource-file.test.js +64 -0
- package/dist/src/workspace/resource-file.test.js.map +1 -0
- package/dist/src/workspace/sync-mapping-types.d.ts +220 -0
- package/dist/src/workspace/sync-mapping-types.d.ts.map +1 -0
- package/dist/src/workspace/sync-mapping-types.js +55 -0
- package/dist/src/workspace/sync-mapping-types.js.map +1 -0
- package/dist/src/workspace/sync-service-client.d.ts +29 -0
- package/dist/src/workspace/sync-service-client.d.ts.map +1 -0
- package/dist/src/workspace/sync-service-client.js +72 -0
- package/dist/src/workspace/sync-service-client.js.map +1 -0
- package/dist/src/workspace/workspace-event-protocol.d.ts +3 -0
- package/dist/src/workspace/workspace-event-protocol.d.ts.map +1 -0
- package/dist/src/workspace/workspace-event-protocol.js +3 -0
- package/dist/src/workspace/workspace-event-protocol.js.map +1 -0
- package/dist/src/workspace/workspace-event-scheduler.d.ts +54 -0
- package/dist/src/workspace/workspace-event-scheduler.d.ts.map +1 -0
- package/dist/src/workspace/workspace-event-scheduler.js +131 -0
- package/dist/src/workspace/workspace-event-scheduler.js.map +1 -0
- package/dist/src/workspace/workspace-event-scheduler.test.d.ts +2 -0
- package/dist/src/workspace/workspace-event-scheduler.test.d.ts.map +1 -0
- package/dist/src/workspace/workspace-event-scheduler.test.js +157 -0
- package/dist/src/workspace/workspace-event-scheduler.test.js.map +1 -0
- package/dist/src/workspace/workspace-event.d.ts +28 -0
- package/dist/src/workspace/workspace-event.d.ts.map +1 -0
- package/dist/src/workspace/workspace-event.js +674 -0
- package/dist/src/workspace/workspace-event.js.map +1 -0
- package/dist/src/workspace/workspace-event.test.d.ts +2 -0
- package/dist/src/workspace/workspace-event.test.d.ts.map +1 -0
- package/dist/src/workspace/workspace-event.test.js +265 -0
- package/dist/src/workspace/workspace-event.test.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-log.d.ts","sourceRoot":"","sources":["../../../src/plugin/channel-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,qDAAqD;AACrD,wBAAgB,QAAQ,CACpB,IAAI,EACE;IAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAC5H,SAAS,GAChB,MAAM,CAyCR"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel 统一日志适配器:兼容 ChannelLogSink 与带 `log` 方法的 sink。
|
|
3
|
+
*/
|
|
4
|
+
/** ChannelLogSink 的 info/warn/error 方法接受单个 string */
|
|
5
|
+
export function toLogger(sink) {
|
|
6
|
+
const prefix = "[xg_cwork_im]";
|
|
7
|
+
const s = sink;
|
|
8
|
+
const emitInfo = (msg) => {
|
|
9
|
+
if (typeof s?.info === "function") {
|
|
10
|
+
s.info(msg);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (typeof s?.log === "function") {
|
|
14
|
+
s.log(msg);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.log(`${prefix} ${msg}`);
|
|
18
|
+
};
|
|
19
|
+
const emitWarn = (msg) => {
|
|
20
|
+
if (typeof sink?.warn === "function") {
|
|
21
|
+
sink.warn(msg);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.warn(`${prefix} ${msg}`);
|
|
25
|
+
};
|
|
26
|
+
const emitError = (msg) => {
|
|
27
|
+
if (typeof sink?.error === "function") {
|
|
28
|
+
sink.error(msg);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.error(`${prefix} ${msg}`);
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
info: emitInfo,
|
|
35
|
+
warn: emitWarn,
|
|
36
|
+
error: emitError,
|
|
37
|
+
debug: (msg) => {
|
|
38
|
+
if (typeof sink?.debug === "function")
|
|
39
|
+
sink.debug(msg);
|
|
40
|
+
else
|
|
41
|
+
emitInfo(msg);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=channel-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-log.js","sourceRoot":"","sources":["../../../src/plugin/channel-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,qDAAqD;AACrD,MAAM,UAAU,QAAQ,CACpB,IAEe;IAEf,MAAM,MAAM,GAAG,eAAe,CAAC;IAC/B,MAAM,CAAC,GAAG,IAAiF,CAAC;IAE5F,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAQ,EAAE;QACnC,IAAI,OAAO,CAAC,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;YAChC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACZ,OAAO;QACX,CAAC;QACD,IAAI,OAAO,CAAC,EAAE,GAAG,KAAK,UAAU,EAAE,CAAC;YAC/B,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACX,OAAO;QACX,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAQ,EAAE;QACnC,IAAI,OAAO,IAAI,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACf,OAAO;QACX,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,GAAW,EAAQ,EAAE;QACpC,IAAI,OAAO,IAAI,EAAE,KAAK,KAAK,UAAU,EAAE,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChB,OAAO;QACX,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,OAAO;QACH,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,OAAO,IAAI,EAAE,KAAK,KAAK,UAAU;gBAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;;gBAClD,QAAQ,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XG-IM Channel Plugin — 组装层
|
|
3
|
+
*
|
|
4
|
+
* 配置与解析见 channel-config.ts;入站正文见 inbound-display.ts;
|
|
5
|
+
* @ 后派发见 dispatch-mentioned-reply.ts(入站消息直投 OpenClaw,
|
|
6
|
+
* 忙碌排队/插话由 OpenClaw 原生 messages.queue 处理,见 docs/插件实现逻辑说明.md)。
|
|
7
|
+
* 单账号 WebSocket 连接运行见 account-connection.ts。
|
|
8
|
+
*
|
|
9
|
+
* 账号生命周期由 openclaw 8.1 框架驱动:注册本通道插件后,框架按账号调用
|
|
10
|
+
* gateway.startAccount(→ account-reconciler.startAccountLifecycle)并持有每账号
|
|
11
|
+
* AbortSignal;配置变更走 reload.configPrefixes + accountScopedRestart 做账号级
|
|
12
|
+
* stop→start。插件 register 不再自启连接,避免同账号重复 WebSocket。
|
|
13
|
+
*/
|
|
14
|
+
import type { PluginRuntime, XgImChannelPlugin } from "./types.js";
|
|
15
|
+
export declare function setXgImRuntime(rt: PluginRuntime): void;
|
|
16
|
+
export declare const xgCworkImChannelPlugin: XgImChannelPlugin;
|
|
17
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/plugin/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAYH,OAAO,KAAK,EAAuB,aAAa,EAAmB,iBAAiB,EAAc,MAAM,YAAY,CAAC;AAMrH,wBAAgB,cAAc,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,CAEtD;AAsSD,eAAO,MAAM,sBAAsB,EAGnB,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XG-IM Channel Plugin — 组装层
|
|
3
|
+
*
|
|
4
|
+
* 配置与解析见 channel-config.ts;入站正文见 inbound-display.ts;
|
|
5
|
+
* @ 后派发见 dispatch-mentioned-reply.ts(入站消息直投 OpenClaw,
|
|
6
|
+
* 忙碌排队/插话由 OpenClaw 原生 messages.queue 处理,见 docs/插件实现逻辑说明.md)。
|
|
7
|
+
* 单账号 WebSocket 连接运行见 account-connection.ts。
|
|
8
|
+
*
|
|
9
|
+
* 账号生命周期由 openclaw 8.1 框架驱动:注册本通道插件后,框架按账号调用
|
|
10
|
+
* gateway.startAccount(→ account-reconciler.startAccountLifecycle)并持有每账号
|
|
11
|
+
* AbortSignal;配置变更走 reload.configPrefixes + accountScopedRestart 做账号级
|
|
12
|
+
* stop→start。插件 register 不再自启连接,避免同账号重复 WebSocket。
|
|
13
|
+
*/
|
|
14
|
+
import { randomUUID } from "node:crypto";
|
|
15
|
+
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/core";
|
|
16
|
+
import { getToken } from "./auth.js";
|
|
17
|
+
import { getXgImConfig, isConfigured, XgImConfigSchema } from "./channel-config.js";
|
|
18
|
+
import { toLogger } from "./channel-log.js";
|
|
19
|
+
import { sendReplyDeliverBlock, sendTextMessage } from "../delivery/send-service.js";
|
|
20
|
+
import { toolJsonResult } from "../tools/tool-json-result.js";
|
|
21
|
+
import { accountReconciler } from "../connection/account-reconciler.js";
|
|
22
|
+
// ─── 全局 Runtime(在 index.ts 的 register 中注入)────────────────────────────
|
|
23
|
+
let xgImRuntime = null;
|
|
24
|
+
export function setXgImRuntime(rt) {
|
|
25
|
+
xgImRuntime = rt;
|
|
26
|
+
}
|
|
27
|
+
const MESSAGE_ACTION_CHANNEL_PREFIX = "xg_cwork_im:";
|
|
28
|
+
function actionFirstNonEmptyString(value) {
|
|
29
|
+
if (typeof value !== "string")
|
|
30
|
+
return undefined;
|
|
31
|
+
const trimmed = value.trim();
|
|
32
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
33
|
+
}
|
|
34
|
+
/** 从 message.action 参数中解析目标会话 ID(群/单聊共用 groupId)。 */
|
|
35
|
+
function resolveActionSendTarget(params) {
|
|
36
|
+
for (const key of ["to", "target", "groupId", "gid", "chatId", "channelId", "conversationId"]) {
|
|
37
|
+
const raw = params[key];
|
|
38
|
+
const direct = actionFirstNonEmptyString(raw);
|
|
39
|
+
if (direct) {
|
|
40
|
+
return direct.startsWith(MESSAGE_ACTION_CHANNEL_PREFIX)
|
|
41
|
+
? direct.slice(MESSAGE_ACTION_CHANNEL_PREFIX.length)
|
|
42
|
+
: direct;
|
|
43
|
+
}
|
|
44
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
45
|
+
const nested = raw;
|
|
46
|
+
const id = actionFirstNonEmptyString(nested.id ?? nested.groupId ?? nested.chatId ?? nested.conversationId);
|
|
47
|
+
if (id)
|
|
48
|
+
return id;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
/** 从 message.action 参数中解析发送正文;模型可能用 message/text/content/SendMessage 等别名。 */
|
|
54
|
+
function resolveActionSendText(params) {
|
|
55
|
+
for (const key of ["message", "text", "content", "body", "SendMessage"]) {
|
|
56
|
+
const value = actionFirstNonEmptyString(params[key]);
|
|
57
|
+
if (value)
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
function resolveActionSendAtUsers(params) {
|
|
63
|
+
for (const key of ["atUserIds", "atUsers"]) {
|
|
64
|
+
const raw = params[key];
|
|
65
|
+
if (!Array.isArray(raw))
|
|
66
|
+
continue;
|
|
67
|
+
const ids = raw
|
|
68
|
+
.map((entry) => (typeof entry === "string" ? entry.trim() : ""))
|
|
69
|
+
.filter((entry) => entry.length > 0);
|
|
70
|
+
if (ids.length > 0)
|
|
71
|
+
return ids;
|
|
72
|
+
}
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 处理网关 message.action:
|
|
77
|
+
* - action != "send" → 明确不支持(supportsAction 在支持该字段的宿主上会先行拦下)。
|
|
78
|
+
* - dryRun 只做参数校验,不真正发送。
|
|
79
|
+
* - 发送成功/失败通过抛错或 ok 结果让宿主得到确定语义;不写任何会话去重状态。
|
|
80
|
+
*/
|
|
81
|
+
async function handleChannelMessageAction(ctx) {
|
|
82
|
+
const channel = "xg_cwork_im";
|
|
83
|
+
const log = toLogger(undefined);
|
|
84
|
+
if (String(ctx?.action ?? "") !== "send") {
|
|
85
|
+
throw new Error(`xg_cwork_im does not support message action "${String(ctx?.action ?? "")}"`);
|
|
86
|
+
}
|
|
87
|
+
const params = ctx?.params && typeof ctx.params === "object" && !Array.isArray(ctx.params)
|
|
88
|
+
? ctx.params
|
|
89
|
+
: {};
|
|
90
|
+
const accountId = actionFirstNonEmptyString(ctx?.accountId ?? ctx?.requesterAccountId) ?? undefined;
|
|
91
|
+
const groupId = resolveActionSendTarget(params);
|
|
92
|
+
const text = resolveActionSendText(params);
|
|
93
|
+
const atUserIds = resolveActionSendAtUsers(params);
|
|
94
|
+
if (ctx?.dryRun === true) {
|
|
95
|
+
return toolJsonResult({
|
|
96
|
+
ok: true,
|
|
97
|
+
channel,
|
|
98
|
+
action: "send",
|
|
99
|
+
dryRun: true,
|
|
100
|
+
to: groupId ?? null,
|
|
101
|
+
textLen: text.length,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (!groupId) {
|
|
105
|
+
throw new Error("xg_cwork_im action send requires a target groupId (params.to/groupId/target/chatId)");
|
|
106
|
+
}
|
|
107
|
+
if (!text) {
|
|
108
|
+
throw new Error("xg_cwork_im action send requires text content (params.message/text/content)");
|
|
109
|
+
}
|
|
110
|
+
if (!ctx?.cfg) {
|
|
111
|
+
throw new Error("xg_cwork_im action send missing runtime cfg");
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const config = getXgImConfig(ctx.cfg, accountId);
|
|
115
|
+
const identity = await getToken(config, log);
|
|
116
|
+
log.info(`[action] send via message.action to=${groupId} accountId=${accountId ?? "default"} textLen=${text.length}`);
|
|
117
|
+
await sendTextMessage(config, identity.token, groupId, text, atUserIds, log);
|
|
118
|
+
return toolJsonResult({
|
|
119
|
+
ok: true,
|
|
120
|
+
channel,
|
|
121
|
+
action: "send",
|
|
122
|
+
to: groupId,
|
|
123
|
+
sentBy: identity.userId,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
log.error(`[action] send failed to=${groupId} accountId=${accountId ?? "default"} err=${String(err)}`);
|
|
128
|
+
throw err;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function buildChannelMessageActions() {
|
|
132
|
+
return {
|
|
133
|
+
supportsAction: ({ action }) => action === "send",
|
|
134
|
+
handleAction: (ctx) => handleChannelMessageAction(ctx),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// ─── Channel Plugin 定义 ─────────────────────────────────────────────────────
|
|
138
|
+
const xgCworkImChannelPluginBase = {
|
|
139
|
+
id: "xg_cwork_im",
|
|
140
|
+
meta: {
|
|
141
|
+
id: "xg_cwork_im",
|
|
142
|
+
label: "XG CWork IM",
|
|
143
|
+
selectionLabel: "XG CWork IM (工作说说)",
|
|
144
|
+
docsPath: "/channels/xg_cwork_im",
|
|
145
|
+
blurb: "工作说说 IM 机器人,通过 WebSocket 长连接接收 @ 消息。",
|
|
146
|
+
aliases: ["xg_cwork_im", "im"],
|
|
147
|
+
},
|
|
148
|
+
configSchema: buildChannelConfigSchema(XgImConfigSchema),
|
|
149
|
+
reload: {
|
|
150
|
+
configPrefixes: ["channels.xg_cwork_im"],
|
|
151
|
+
// openclaw 8.1+ 支持账号级 stop→start;SDK 类型尚未声明该字段,运行时属性存在即生效。
|
|
152
|
+
accountScopedRestart: true,
|
|
153
|
+
},
|
|
154
|
+
capabilities: {
|
|
155
|
+
chatTypes: ["direct", "group"],
|
|
156
|
+
reactions: false,
|
|
157
|
+
threads: false,
|
|
158
|
+
media: true,
|
|
159
|
+
nativeCommands: false,
|
|
160
|
+
blockStreaming: true,
|
|
161
|
+
},
|
|
162
|
+
config: {
|
|
163
|
+
listAccountIds: (cfg) => {
|
|
164
|
+
try {
|
|
165
|
+
const config = getXgImConfig(cfg);
|
|
166
|
+
const accounts = config.accounts;
|
|
167
|
+
if (accounts) {
|
|
168
|
+
if (!Array.isArray(accounts) && typeof accounts === "object") {
|
|
169
|
+
const keys = Object.keys(accounts).filter((k) => k !== "default");
|
|
170
|
+
return keys;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return isConfigured(cfg) ? ["default"] : [];
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
resolveAccount: (cfg, accountId) => {
|
|
180
|
+
const id = accountId || "default";
|
|
181
|
+
try {
|
|
182
|
+
const config = getXgImConfig(cfg, id);
|
|
183
|
+
return {
|
|
184
|
+
accountId: id,
|
|
185
|
+
config,
|
|
186
|
+
enabled: config.enabled !== false,
|
|
187
|
+
configured: Boolean((config.robotKey ?? config.appKey) && config.baseUrl),
|
|
188
|
+
name: config.name ?? null,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return {
|
|
193
|
+
accountId: id,
|
|
194
|
+
config: {},
|
|
195
|
+
enabled: false,
|
|
196
|
+
configured: false,
|
|
197
|
+
name: null,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
defaultAccountId: () => "default",
|
|
202
|
+
isConfigured: (account) => account.configured,
|
|
203
|
+
describeAccount: (account) => ({
|
|
204
|
+
accountId: account.accountId,
|
|
205
|
+
name: account.config?.name ?? "xg_cwork_im",
|
|
206
|
+
enabled: account.enabled,
|
|
207
|
+
configured: account.configured,
|
|
208
|
+
}),
|
|
209
|
+
},
|
|
210
|
+
groups: {
|
|
211
|
+
resolveRequireMention: (params) => {
|
|
212
|
+
try {
|
|
213
|
+
const config = getXgImConfig(params.cfg, params.accountId);
|
|
214
|
+
return config?.groupPolicy !== "open";
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
outbound: {
|
|
222
|
+
deliveryMode: "direct",
|
|
223
|
+
resolveTarget: (params) => {
|
|
224
|
+
const trimmed = params.to?.trim();
|
|
225
|
+
if (!trimmed) {
|
|
226
|
+
return {
|
|
227
|
+
ok: false,
|
|
228
|
+
error: new Error("XG-IM message requires --to <groupId>"),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
return { ok: true, to: trimmed };
|
|
232
|
+
},
|
|
233
|
+
sendText: async (ctx) => {
|
|
234
|
+
const { cfg, to, text, accountId, log: ctxLog } = ctx;
|
|
235
|
+
const log = toLogger(ctxLog);
|
|
236
|
+
const config = getXgImConfig(cfg, accountId);
|
|
237
|
+
const identity = await getToken(config, log);
|
|
238
|
+
await sendTextMessage(config, identity.token, to, text, [], log);
|
|
239
|
+
return {
|
|
240
|
+
channel: "xg_cwork_im",
|
|
241
|
+
messageId: randomUUID(),
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
sendMedia: async (ctx) => {
|
|
245
|
+
const { cfg, to, text, mediaUrl, accountId, log: ctxLog } = ctx;
|
|
246
|
+
const log = toLogger(ctxLog);
|
|
247
|
+
const config = getXgImConfig(cfg, accountId);
|
|
248
|
+
const identity = await getToken(config, log);
|
|
249
|
+
if (!mediaUrl?.trim()) {
|
|
250
|
+
await sendTextMessage(config, identity.token, to, text || "", [], log);
|
|
251
|
+
return { channel: "xg_cwork_im", messageId: randomUUID() };
|
|
252
|
+
}
|
|
253
|
+
await sendReplyDeliverBlock(config, identity.token, to, { text: text || "", mediaUrl: mediaUrl.trim() }, [], log, undefined, undefined);
|
|
254
|
+
return {
|
|
255
|
+
channel: "xg_cwork_im",
|
|
256
|
+
messageId: randomUUID(),
|
|
257
|
+
};
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
gateway: {
|
|
261
|
+
startAccount: async (ctx) => {
|
|
262
|
+
await accountReconciler.startAccountLifecycle(ctx);
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
// actions 属于 ChannelPlugin 的 message-action 面(宿主版本间字段/类型存在差异),
|
|
267
|
+
// 通过 base + spread 合并,既能保留 base 的字面量类型校验,又避免 actions 类型代际差异破坏构建。
|
|
268
|
+
export const xgCworkImChannelPlugin = {
|
|
269
|
+
...xgCworkImChannelPluginBase,
|
|
270
|
+
actions: buildChannelMessageActions(),
|
|
271
|
+
};
|
|
272
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":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iE;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG;IAClC,GAAG,0BAA0B;IAC7B,OAAO,EAAE,0BAA0B,EAAE;CACR,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件卸载/重载时的统一拆解入口。
|
|
3
|
+
*
|
|
4
|
+
* 语义(跨模块共享改造后):
|
|
5
|
+
* - 真卸载 / gateway_stop:`disposePluginModule()`(skipConnections=false)——连同进程级共享的
|
|
6
|
+
* account-reconciler 一起 stopAll,并清空全部共享内存态(连接/流客户端/会话上下文/轮次/去重/env/
|
|
7
|
+
* subagent 监控)。由 index.ts 的 gateway_stop 钩子触发,且用 once 闸门保证只执行一次。
|
|
8
|
+
* - 插件热重载 / registry 代际交替:cleanup 以 `disposePluginModule({ skipConnections: true,
|
|
9
|
+
* skipPlanResources: true })` 调用——只收尾可安全代际清理的句柄,保留动作读库与 plan-ws 路由,
|
|
10
|
+
* **绝不 stopAll、绝不清理共享连接/内存态**。连接只在 AccountReconciler(配置 diff,账号级)
|
|
11
|
+
* 与 gateway_stop(进程停机)处拆解,避免 OpenClaw runtime 代际交替误拆全部 WebSocket。
|
|
12
|
+
*/
|
|
13
|
+
export interface DisposePluginModuleOptions {
|
|
14
|
+
/** 注册表代际交替(热重载)场景:只收尾独占句柄,跳过共享连接与共享内存态。 */
|
|
15
|
+
skipConnections?: boolean;
|
|
16
|
+
/** 注册表代际交替时保留计划读库、动作读库句柄与计划 WS 路由——这些资源仍被代际交替后
|
|
17
|
+
* 可能继续调用的旧中间件读取路径使用,清空会令反查在打开数据库前即失败;gateway_stop 使用默认 false 完整清理。 */
|
|
18
|
+
skipPlanResources?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** skipConnections=false(gateway_stop)时停连接+清共享态;true(cleanup)只收尾独占句柄。 */
|
|
21
|
+
export declare function disposePluginModule(options?: DisposePluginModuleOptions): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=plugin-dispose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-dispose.d.ts","sourceRoot":"","sources":["../../../src/plugin/plugin-dispose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqBH,MAAM,WAAW,0BAA0B;IACvC,2CAA2C;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;2EACuE;IACvE,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,yEAAyE;AACzE,wBAAsB,mBAAmB,CACrC,OAAO,GAAE,0BAA+B,GACzC,OAAO,CAAC,IAAI,CAAC,CAkCf"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件卸载/重载时的统一拆解入口。
|
|
3
|
+
*
|
|
4
|
+
* 语义(跨模块共享改造后):
|
|
5
|
+
* - 真卸载 / gateway_stop:`disposePluginModule()`(skipConnections=false)——连同进程级共享的
|
|
6
|
+
* account-reconciler 一起 stopAll,并清空全部共享内存态(连接/流客户端/会话上下文/轮次/去重/env/
|
|
7
|
+
* subagent 监控)。由 index.ts 的 gateway_stop 钩子触发,且用 once 闸门保证只执行一次。
|
|
8
|
+
* - 插件热重载 / registry 代际交替:cleanup 以 `disposePluginModule({ skipConnections: true,
|
|
9
|
+
* skipPlanResources: true })` 调用——只收尾可安全代际清理的句柄,保留动作读库与 plan-ws 路由,
|
|
10
|
+
* **绝不 stopAll、绝不清理共享连接/内存态**。连接只在 AccountReconciler(配置 diff,账号级)
|
|
11
|
+
* 与 gateway_stop(进程停机)处拆解,避免 OpenClaw runtime 代际交替误拆全部 WebSocket。
|
|
12
|
+
*/
|
|
13
|
+
import { accountReconciler } from "../connection/account-reconciler.js";
|
|
14
|
+
import { disposeAssistantItemSinks } from "../delivery/assistant-item-sink.js";
|
|
15
|
+
import { disposeActiveCronContextStore } from "../tools/active-cron-context-store.js";
|
|
16
|
+
import { clearStreamClients } from "../connection/agent-stream-client-registry.js";
|
|
17
|
+
import { disposeActiveRoundRegistry } from "../turn/active-round-registry.js";
|
|
18
|
+
import { disposeActionStore } from "../plan/action-store-access.js";
|
|
19
|
+
import { clearAllTokenCache } from "./auth.js";
|
|
20
|
+
import { disposeCronAppKeyBindingStore } from "../tools/cron-appkey-binding-store.js";
|
|
21
|
+
import { disposeGlobalTerminalSent } from "../delivery/inbound-terminal-state.js";
|
|
22
|
+
import { clearSessionNasVolumeStates } from "../workspace/nas-volumes.js";
|
|
23
|
+
import { clearAllPendingPerMessageModel } from "../session/per-message-model-pending.js";
|
|
24
|
+
import { disposeSessionEnvStore } from "../session/session-env-store.js";
|
|
25
|
+
import { disposePlanWsRegistry } from "../plan/plan-ws-registry.js";
|
|
26
|
+
import { disposeSessionImContext } from "../session/session-im-context.js";
|
|
27
|
+
import { clearAllSessionGroupPrompts } from "../session/session-group-prompt.js";
|
|
28
|
+
import { disposeSubagentMonitor } from "../turn/subagent-monitor.js";
|
|
29
|
+
import { disposeTurnAgentEvents } from "../turn/turn-agent-event-subscription.js";
|
|
30
|
+
import { disposeTurnEndController } from "../turn/turn-end-controller.js";
|
|
31
|
+
/** skipConnections=false(gateway_stop)时停连接+清共享态;true(cleanup)只收尾独占句柄。 */
|
|
32
|
+
export async function disposePluginModule(options = {}) {
|
|
33
|
+
const { skipConnections = false } = options;
|
|
34
|
+
const { skipPlanResources = false } = options;
|
|
35
|
+
if (skipConnections) {
|
|
36
|
+
console.log(`[xg_cwork_im] [reload] disposePluginModule skipConnections=true ` +
|
|
37
|
+
`skipPlanResources=${skipPlanResources} (registry cycle)`);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// gateway_stop:停共享连接 + 清空共享热路径内存态(含 subagent 监控 maps/ticker)。
|
|
41
|
+
await accountReconciler.stopAll("gateway-stop");
|
|
42
|
+
disposeSubagentMonitor();
|
|
43
|
+
disposeTurnAgentEvents();
|
|
44
|
+
disposeAssistantItemSinks();
|
|
45
|
+
disposeTurnEndController();
|
|
46
|
+
clearStreamClients();
|
|
47
|
+
disposeSessionImContext();
|
|
48
|
+
clearAllSessionGroupPrompts();
|
|
49
|
+
disposeActiveRoundRegistry();
|
|
50
|
+
disposeGlobalTerminalSent();
|
|
51
|
+
clearAllPendingPerMessageModel();
|
|
52
|
+
clearSessionNasVolumeStates();
|
|
53
|
+
disposeSessionEnvStore();
|
|
54
|
+
disposeActiveCronContextStore();
|
|
55
|
+
disposeCronAppKeyBindingStore();
|
|
56
|
+
}
|
|
57
|
+
// 动作读库与 plan-ws 路由可能被代际交替后仍在调用的旧中间件/旧发送路径继续使用:旧 cleanup 绝不能清空
|
|
58
|
+
// 它们的配置/句柄——action 若被清空,getActionById 会在打开数据库之前就因 stateDir 缺失而失败,
|
|
59
|
+
// 表现为「反查不到 action,跳过 ACTION_DISPATCH 发送」;gateway_stop(skipPlanResources=false)仍完整释放。
|
|
60
|
+
if (!skipPlanResources) {
|
|
61
|
+
disposeActionStore();
|
|
62
|
+
disposePlanWsRegistry();
|
|
63
|
+
}
|
|
64
|
+
clearAllTokenCache();
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=plugin-dispose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-dispose.js","sourceRoot":"","sources":["../../../src/plugin/plugin-dispose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,6BAA6B,EAAE,M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C,2BAA2B,EAAE,CAAC;QAC9B,sBAAsB,EAAE,CAAC;QACzB,6BAA6B,EAAE,CAAC;QAChC,6BAA6B,EAAE,CAAC;IACpC,CAAC;IACD,8DAA8D;IAC9D,kEAAkE;IAClE,qFAAqF;IACrF,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACrB,kBAAkB,EAAE,CAAC;QACrB,qBAAqB,EAAE,CAAC;IAC5B,CAAC;IACD,kBAAkB,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 进程级共享存储(跨插件模块重载实例存活)。
|
|
3
|
+
*
|
|
4
|
+
* OpenClaw 热重载插件时会重新 import 插件模块 → 新模块作用域里的「模块级单例」与旧实例不互通,
|
|
5
|
+
* 旧模块由 registerRuntimeLifecycle cleanup 拆解。为了做到「WebSocket 连接与 runtime 不随模块
|
|
6
|
+
* 重建」,把必须在重载后仍存活的状态放到 globalThis(Symbol key),任何一代模块实例读写同一份。
|
|
7
|
+
*
|
|
8
|
+
* 用途:
|
|
9
|
+
* - 模块代际(epoch):模块每次(重)import 时取号,register() 后 cleanup 据此判断「是否已有更新的
|
|
10
|
+
* 模块实例接管」,接管时不再拆连接。
|
|
11
|
+
* - runtime 持有:每次 register() 把最新 PluginRuntime 写入,连接派发时按需现取,避免绑定旧代际。
|
|
12
|
+
* - 通用 namespace:后续状态迁移(reconciler 等)统一放这里。
|
|
13
|
+
*/
|
|
14
|
+
export interface ProcessSharedStore {
|
|
15
|
+
/** 模块代际计数:每个模块实例在顶层(重)import 时递增取号(仅用于观测重载)。 */
|
|
16
|
+
moduleEpoch: number;
|
|
17
|
+
/** register() 序列:每次 register() 自增(仅观测用,不再作为 teardown 判定依据)。 */
|
|
18
|
+
registerSeq: number;
|
|
19
|
+
/** 当前生效的插件 runtime(每次 register() 覆盖)。 */
|
|
20
|
+
runtime: unknown;
|
|
21
|
+
/** 进程级共享命名空间(连接/reconciler 等状态)。 */
|
|
22
|
+
namespace: Record<string, unknown>;
|
|
23
|
+
/** gateway_stop 全量 teardown 只执行一次的闸门。 */
|
|
24
|
+
fullTeardownDone: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** 模块实例顶层调用一次:领取一个全局单调递增的代际号(仅观测用)。 */
|
|
27
|
+
export declare function nextModuleEpoch(): number;
|
|
28
|
+
/** 读取当前最大的模块代际号。 */
|
|
29
|
+
export declare function currentModuleEpoch(): number;
|
|
30
|
+
/** register() 时调用:领取本次 register 的全局序列号。 */
|
|
31
|
+
export declare function nextRegisterSeq(): number;
|
|
32
|
+
/** 读取当前最大的 register 序列号。 */
|
|
33
|
+
export declare function currentRegisterSeq(): number;
|
|
34
|
+
/** 全量 teardown(gateway_stop)幂等闸门:首次调用返回 true,其后返回 false。 */
|
|
35
|
+
export declare function requestFullTeardownOnce(): boolean;
|
|
36
|
+
/** 出现新的 register() 时复位 teardown 闸门(允许下次停机再次 teardown)。 */
|
|
37
|
+
export declare function resetFullTeardownGate(): void;
|
|
38
|
+
/** register() 时写入最新 runtime(连接派发按需现取)。 */
|
|
39
|
+
export declare function setSharedRuntime(rt: unknown): void;
|
|
40
|
+
/** 读取当前最新 runtime。 */
|
|
41
|
+
export declare function getSharedRuntime<T = unknown>(): T | undefined;
|
|
42
|
+
/** 进程级 getOrCreate:跨模块重载共享单例(如 account-reconciler)。 */
|
|
43
|
+
export declare function getOrCreateShared<T>(key: string, factory: () => T): T;
|
|
44
|
+
/** 进程级共享 Map:跨模块重载共享状态(旧连接派发写入 / 新模块 hooks 读取同一份)。 */
|
|
45
|
+
export declare function getSharedMap<K, V>(key: string): Map<K, V>;
|
|
46
|
+
/** 仅供测试:整表重置(避免测试文件间串状态)。 */
|
|
47
|
+
export declare function __resetProcessSharedStoreForTests(): void;
|
|
48
|
+
//# sourceMappingURL=process-shared-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-shared-store.d.ts","sourceRoot":"","sources":["../../../src/plugin/process-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载实例存活)。
|
|
3
|
+
*
|
|
4
|
+
* OpenClaw 热重载插件时会重新 import 插件模块 → 新模块作用域里的「模块级单例」与旧实例不互通,
|
|
5
|
+
* 旧模块由 registerRuntimeLifecycle cleanup 拆解。为了做到「WebSocket 连接与 runtime 不随模块
|
|
6
|
+
* 重建」,把必须在重载后仍存活的状态放到 globalThis(Symbol key),任何一代模块实例读写同一份。
|
|
7
|
+
*
|
|
8
|
+
* 用途:
|
|
9
|
+
* - 模块代际(epoch):模块每次(重)import 时取号,register() 后 cleanup 据此判断「是否已有更新的
|
|
10
|
+
* 模块实例接管」,接管时不再拆连接。
|
|
11
|
+
* - runtime 持有:每次 register() 把最新 PluginRuntime 写入,连接派发时按需现取,避免绑定旧代际。
|
|
12
|
+
* - 通用 namespace:后续状态迁移(reconciler 等)统一放这里。
|
|
13
|
+
*/
|
|
14
|
+
const STORE_KEY = Symbol.for("xg.im.processSharedStore");
|
|
15
|
+
function ensureStore() {
|
|
16
|
+
const g = globalThis;
|
|
17
|
+
if (Object.hasOwn(g, STORE_KEY)) {
|
|
18
|
+
return g[STORE_KEY];
|
|
19
|
+
}
|
|
20
|
+
const created = {
|
|
21
|
+
moduleEpoch: 0,
|
|
22
|
+
registerSeq: 0,
|
|
23
|
+
runtime: undefined,
|
|
24
|
+
namespace: {},
|
|
25
|
+
fullTeardownDone: false,
|
|
26
|
+
};
|
|
27
|
+
g[STORE_KEY] = created;
|
|
28
|
+
return created;
|
|
29
|
+
}
|
|
30
|
+
/** 模块实例顶层调用一次:领取一个全局单调递增的代际号(仅观测用)。 */
|
|
31
|
+
export function nextModuleEpoch() {
|
|
32
|
+
const store = ensureStore();
|
|
33
|
+
store.moduleEpoch += 1;
|
|
34
|
+
return store.moduleEpoch;
|
|
35
|
+
}
|
|
36
|
+
/** 读取当前最大的模块代际号。 */
|
|
37
|
+
export function currentModuleEpoch() {
|
|
38
|
+
return ensureStore().moduleEpoch;
|
|
39
|
+
}
|
|
40
|
+
/** register() 时调用:领取本次 register 的全局序列号。 */
|
|
41
|
+
export function nextRegisterSeq() {
|
|
42
|
+
const store = ensureStore();
|
|
43
|
+
store.registerSeq += 1;
|
|
44
|
+
return store.registerSeq;
|
|
45
|
+
}
|
|
46
|
+
/** 读取当前最大的 register 序列号。 */
|
|
47
|
+
export function currentRegisterSeq() {
|
|
48
|
+
return ensureStore().registerSeq;
|
|
49
|
+
}
|
|
50
|
+
/** 全量 teardown(gateway_stop)幂等闸门:首次调用返回 true,其后返回 false。 */
|
|
51
|
+
export function requestFullTeardownOnce() {
|
|
52
|
+
const store = ensureStore();
|
|
53
|
+
if (store.fullTeardownDone)
|
|
54
|
+
return false;
|
|
55
|
+
store.fullTeardownDone = true;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
/** 出现新的 register() 时复位 teardown 闸门(允许下次停机再次 teardown)。 */
|
|
59
|
+
export function resetFullTeardownGate() {
|
|
60
|
+
ensureStore().fullTeardownDone = false;
|
|
61
|
+
}
|
|
62
|
+
/** register() 时写入最新 runtime(连接派发按需现取)。 */
|
|
63
|
+
export function setSharedRuntime(rt) {
|
|
64
|
+
ensureStore().runtime = rt;
|
|
65
|
+
}
|
|
66
|
+
/** 读取当前最新 runtime。 */
|
|
67
|
+
export function getSharedRuntime() {
|
|
68
|
+
return ensureStore().runtime;
|
|
69
|
+
}
|
|
70
|
+
/** 进程级 getOrCreate:跨模块重载共享单例(如 account-reconciler)。 */
|
|
71
|
+
export function getOrCreateShared(key, factory) {
|
|
72
|
+
const ns = ensureStore().namespace;
|
|
73
|
+
if (!Object.hasOwn(ns, key)) {
|
|
74
|
+
ns[key] = factory();
|
|
75
|
+
}
|
|
76
|
+
return ns[key];
|
|
77
|
+
}
|
|
78
|
+
/** 进程级共享 Map:跨模块重载共享状态(旧连接派发写入 / 新模块 hooks 读取同一份)。 */
|
|
79
|
+
export function getSharedMap(key) {
|
|
80
|
+
return getOrCreateShared(`map:${key}`, () => new Map());
|
|
81
|
+
}
|
|
82
|
+
/** 仅供测试:整表重置(避免测试文件间串状态)。 */
|
|
83
|
+
export function __resetProcessSharedStoreForTests() {
|
|
84
|
+
const g = globalThis;
|
|
85
|
+
if (Object.hasOwn(g, STORE_KEY)) {
|
|
86
|
+
delete g[STORE_KEY];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=process-shared-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-shared-store.js","sourceRoot":"","sources":["../../../src/plugin/process-shared-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAezD,SAAS,WAAW;IAChB,MAAM,CAAC,GAAG,UAA0C,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,CAAC,SAAS,CAAuB,CAAC;IAC9C,CAAC;IACD,MAAM,OAAO,GAAuB;QAChC,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,OAAO,EAAE,SAAS;QAClB,SAAS,EAAE,EAAE;QACb,gBAAgB,EAAE,KAAK;KAC1B,CAAC;IACF,CAAC,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;IACvB,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,eAAe;IAC3B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,KAAK,CAAC,WAAW,IAAI,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC,WAAW,CAAC;AAC7B,CAAC;AAED,oBAAoB;AACpB,MAAM,UAAU,kBAAkB;IAC9B,OAAO,WAAW,EAAE,CAAC,WAAW,CAAC;AACrC,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,eAAe;IAC3B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,KAAK,CAAC,WAAW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MAAM,CAAC,GAAG,UAA0C,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-shared-store.test.d.ts","sourceRoot":"","sources":["../../../src/plugin/process-shared-store.test.ts"],"names":[],"mappings":""}
|