lightclawbot 1.1.2 → 1.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/index.js +38 -31
- package/dist/setup-entry.js +32 -0
- package/dist/src/channel.js +166 -253
- package/dist/src/channel.setup.js +16 -0
- package/dist/src/config.js +31 -124
- package/dist/src/dedup.js +0 -1
- package/dist/src/download-tool.js +0 -1
- package/dist/src/file-storage.js +2 -2
- package/dist/src/gateway.js +224 -178
- package/dist/src/history/cron-utils.js +0 -1
- package/dist/src/history/index.js +0 -1
- package/dist/src/history/message-parser.js +0 -1
- package/dist/src/history/session-reader.js +3 -1
- package/dist/src/history/session-store.js +0 -1
- package/dist/src/history/text-processing.js +0 -1
- package/dist/src/history/types.js +0 -1
- package/dist/src/inbound.js +165 -234
- package/dist/src/media.js +0 -1
- package/dist/src/messaging.js +65 -0
- package/dist/src/outbound.js +129 -45
- package/dist/src/runtime.js +9 -11
- package/dist/src/setup-core.js +27 -0
- package/dist/src/shared.js +141 -0
- package/dist/src/socket/handlers.js +72 -49
- package/dist/src/socket/index.js +0 -1
- package/dist/src/socket/native-socket.js +385 -0
- package/dist/src/socket/registry.js +0 -1
- package/dist/src/socket/reliable-emitter.js +188 -50
- package/dist/src/streaming/delta-tracker.js +140 -0
- package/dist/src/streaming/index.js +12 -0
- package/dist/src/streaming/stream-reply-sink.js +387 -0
- package/dist/src/streaming/types.js +4 -0
- package/dist/src/tools.js +13 -0
- package/dist/src/types.js +22 -2
- package/dist/src/upload-tool.js +0 -1
- package/dist/src/utils/account.js +73 -0
- package/dist/src/utils/common.js +48 -0
- package/dist/src/utils/index.js +2 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/constants.js +1 -0
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/permessage-deflate.js +6 -6
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/websocket-server.js +10 -6
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/websocket.js +19 -14
- package/node_modules/{engine.io-client/node_modules/ws → ws}/package.json +4 -3
- package/node_modules/ws/wrapper.mjs +21 -0
- package/openclaw.plugin.json +0 -7
- package/package.json +8 -5
- package/dist/index.d.ts +0 -24
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/public/data/scripts/manifest.json +0 -11
- package/dist/public/data/scripts/preflight.9af62b39.sh +0 -191
- package/dist/public/data/scripts/preflight.sh +0 -191
- package/dist/src/channel.d.ts +0 -11
- package/dist/src/channel.d.ts.map +0 -1
- package/dist/src/channel.js.map +0 -1
- package/dist/src/config.d.ts +0 -129
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js.map +0 -1
- package/dist/src/dedup.d.ts +0 -12
- package/dist/src/dedup.d.ts.map +0 -1
- package/dist/src/dedup.js.map +0 -1
- package/dist/src/download-tool.d.ts +0 -32
- package/dist/src/download-tool.d.ts.map +0 -1
- package/dist/src/download-tool.js.map +0 -1
- package/dist/src/file-storage.d.ts +0 -74
- package/dist/src/file-storage.d.ts.map +0 -1
- package/dist/src/file-storage.js.map +0 -1
- package/dist/src/format-urls.d.ts +0 -26
- package/dist/src/format-urls.d.ts.map +0 -1
- package/dist/src/format-urls.js +0 -53
- package/dist/src/format-urls.js.map +0 -1
- package/dist/src/gateway.d.ts +0 -16
- package/dist/src/gateway.d.ts.map +0 -1
- package/dist/src/gateway.js.map +0 -1
- package/dist/src/history/cron-utils.d.ts +0 -76
- package/dist/src/history/cron-utils.d.ts.map +0 -1
- package/dist/src/history/cron-utils.js.map +0 -1
- package/dist/src/history/index.d.ts +0 -20
- package/dist/src/history/index.d.ts.map +0 -1
- package/dist/src/history/index.js.map +0 -1
- package/dist/src/history/message-parser.d.ts +0 -52
- package/dist/src/history/message-parser.d.ts.map +0 -1
- package/dist/src/history/message-parser.js.map +0 -1
- package/dist/src/history/session-reader.d.ts +0 -58
- package/dist/src/history/session-reader.d.ts.map +0 -1
- package/dist/src/history/session-reader.js.map +0 -1
- package/dist/src/history/session-store.d.ts +0 -42
- package/dist/src/history/session-store.d.ts.map +0 -1
- package/dist/src/history/session-store.js.map +0 -1
- package/dist/src/history/text-processing.d.ts +0 -41
- package/dist/src/history/text-processing.d.ts.map +0 -1
- package/dist/src/history/text-processing.js.map +0 -1
- package/dist/src/history/types.d.ts +0 -134
- package/dist/src/history/types.d.ts.map +0 -1
- package/dist/src/history/types.js.map +0 -1
- package/dist/src/inbound.d.ts +0 -18
- package/dist/src/inbound.d.ts.map +0 -1
- package/dist/src/inbound.js.map +0 -1
- package/dist/src/media.d.ts +0 -12
- package/dist/src/media.d.ts.map +0 -1
- package/dist/src/media.js.map +0 -1
- package/dist/src/outbound.d.ts +0 -28
- package/dist/src/outbound.d.ts.map +0 -1
- package/dist/src/outbound.js.map +0 -1
- package/dist/src/runtime.d.ts +0 -4
- package/dist/src/runtime.d.ts.map +0 -1
- package/dist/src/runtime.js.map +0 -1
- package/dist/src/socket/handlers.d.ts +0 -26
- package/dist/src/socket/handlers.d.ts.map +0 -1
- package/dist/src/socket/handlers.js.map +0 -1
- package/dist/src/socket/index.d.ts +0 -11
- package/dist/src/socket/index.d.ts.map +0 -1
- package/dist/src/socket/index.js.map +0 -1
- package/dist/src/socket/registry.d.ts +0 -59
- package/dist/src/socket/registry.d.ts.map +0 -1
- package/dist/src/socket/registry.js.map +0 -1
- package/dist/src/socket/reliable-emitter.d.ts +0 -79
- package/dist/src/socket/reliable-emitter.d.ts.map +0 -1
- package/dist/src/socket/reliable-emitter.js.map +0 -1
- package/dist/src/types.d.ts +0 -112
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js.map +0 -1
- package/dist/src/upload-tool.d.ts +0 -27
- package/dist/src/upload-tool.d.ts.map +0 -1
- package/dist/src/upload-tool.js.map +0 -1
- package/node_modules/@socket.io/component-emitter/LICENSE +0 -24
- package/node_modules/@socket.io/component-emitter/Readme.md +0 -79
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +0 -179
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +0 -176
- package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +0 -4
- package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +0 -179
- package/node_modules/@socket.io/component-emitter/lib/esm/index.js +0 -169
- package/node_modules/@socket.io/component-emitter/lib/esm/package.json +0 -4
- package/node_modules/@socket.io/component-emitter/package.json +0 -28
- package/node_modules/debug/LICENSE +0 -20
- package/node_modules/debug/README.md +0 -481
- package/node_modules/debug/package.json +0 -64
- package/node_modules/debug/src/browser.js +0 -272
- package/node_modules/debug/src/common.js +0 -292
- package/node_modules/debug/src/index.js +0 -10
- package/node_modules/debug/src/node.js +0 -263
- package/node_modules/engine.io-client/LICENSE +0 -22
- package/node_modules/engine.io-client/README.md +0 -331
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +0 -3
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +0 -4
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +0 -1
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +0 -14
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +0 -15
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +0 -38
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +0 -1
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +0 -67
- package/node_modules/engine.io-client/build/cjs/globals.d.ts +0 -4
- package/node_modules/engine.io-client/build/cjs/globals.js +0 -26
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +0 -21
- package/node_modules/engine.io-client/build/cjs/globals.node.js +0 -97
- package/node_modules/engine.io-client/build/cjs/index.d.ts +0 -15
- package/node_modules/engine.io-client/build/cjs/index.js +0 -32
- package/node_modules/engine.io-client/build/cjs/package.json +0 -10
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +0 -482
- package/node_modules/engine.io-client/build/cjs/socket.js +0 -765
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +0 -106
- package/node_modules/engine.io-client/build/cjs/transport.js +0 -153
- package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +0 -8
- package/node_modules/engine.io-client/build/cjs/transports/index.js +0 -11
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +0 -15
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +0 -60
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +0 -108
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +0 -285
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +0 -11
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +0 -44
- package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +0 -52
- package/node_modules/engine.io-client/build/cjs/transports/polling.js +0 -165
- package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +0 -36
- package/node_modules/engine.io-client/build/cjs/transports/websocket.js +0 -136
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +0 -14
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +0 -68
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +0 -18
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +0 -94
- package/node_modules/engine.io-client/build/cjs/util.d.ts +0 -7
- package/node_modules/engine.io-client/build/cjs/util.js +0 -65
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +0 -3
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +0 -2
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +0 -11
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +0 -34
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +0 -64
- package/node_modules/engine.io-client/build/esm/globals.d.ts +0 -4
- package/node_modules/engine.io-client/build/esm/globals.js +0 -22
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +0 -21
- package/node_modules/engine.io-client/build/esm/globals.node.js +0 -91
- package/node_modules/engine.io-client/build/esm/index.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm/index.js +0 -15
- package/node_modules/engine.io-client/build/esm/package.json +0 -10
- package/node_modules/engine.io-client/build/esm/socket.d.ts +0 -482
- package/node_modules/engine.io-client/build/esm/socket.js +0 -727
- package/node_modules/engine.io-client/build/esm/transport.d.ts +0 -106
- package/node_modules/engine.io-client/build/esm/transport.js +0 -142
- package/node_modules/engine.io-client/build/esm/transports/index.d.ts +0 -8
- package/node_modules/engine.io-client/build/esm/transports/index.js +0 -8
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +0 -56
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +0 -108
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +0 -271
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +0 -11
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +0 -17
- package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +0 -52
- package/node_modules/engine.io-client/build/esm/transports/polling.js +0 -145
- package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +0 -36
- package/node_modules/engine.io-client/build/esm/transports/websocket.js +0 -125
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +0 -14
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +0 -41
- package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +0 -18
- package/node_modules/engine.io-client/build/esm/transports/webtransport.js +0 -80
- package/node_modules/engine.io-client/build/esm/util.d.ts +0 -7
- package/node_modules/engine.io-client/build/esm/util.js +0 -59
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +0 -3
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +0 -2
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +0 -11
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +0 -34
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +0 -64
- package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +0 -4
- package/node_modules/engine.io-client/build/esm-debug/globals.js +0 -22
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +0 -21
- package/node_modules/engine.io-client/build/esm-debug/globals.node.js +0 -91
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm-debug/index.js +0 -15
- package/node_modules/engine.io-client/build/esm-debug/package.json +0 -10
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +0 -482
- package/node_modules/engine.io-client/build/esm-debug/socket.js +0 -756
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +0 -106
- package/node_modules/engine.io-client/build/esm-debug/transport.js +0 -145
- package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +0 -8
- package/node_modules/engine.io-client/build/esm-debug/transports/index.js +0 -8
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +0 -56
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +0 -108
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +0 -276
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +0 -11
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +0 -17
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +0 -52
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +0 -158
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +0 -36
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +0 -128
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +0 -14
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +0 -41
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +0 -18
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +0 -87
- package/node_modules/engine.io-client/build/esm-debug/util.d.ts +0 -7
- package/node_modules/engine.io-client/build/esm-debug/util.js +0 -59
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +0 -7
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +0 -1
- package/node_modules/engine.io-client/dist/engine.io.js +0 -3064
- package/node_modules/engine.io-client/dist/engine.io.js.map +0 -1
- package/node_modules/engine.io-client/dist/engine.io.min.js +0 -7
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +0 -1
- package/node_modules/engine.io-client/node_modules/ws/index.js +0 -13
- package/node_modules/engine.io-client/node_modules/ws/wrapper.mjs +0 -8
- package/node_modules/engine.io-client/package.json +0 -95
- package/node_modules/engine.io-parser/LICENSE +0 -22
- package/node_modules/engine.io-parser/Readme.md +0 -158
- package/node_modules/engine.io-parser/build/cjs/commons.d.ts +0 -14
- package/node_modules/engine.io-parser/build/cjs/commons.js +0 -19
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +0 -2
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +0 -48
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +0 -2
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +0 -66
- package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +0 -2
- package/node_modules/engine.io-parser/build/cjs/decodePacket.js +0 -59
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +0 -4
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +0 -72
- package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +0 -3
- package/node_modules/engine.io-parser/build/cjs/encodePacket.js +0 -38
- package/node_modules/engine.io-parser/build/cjs/index.d.ts +0 -9
- package/node_modules/engine.io-parser/build/cjs/index.js +0 -164
- package/node_modules/engine.io-parser/build/cjs/package.json +0 -8
- package/node_modules/engine.io-parser/build/esm/commons.d.ts +0 -14
- package/node_modules/engine.io-parser/build/esm/commons.js +0 -14
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +0 -2
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +0 -43
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +0 -2
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +0 -62
- package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +0 -2
- package/node_modules/engine.io-parser/build/esm/decodePacket.js +0 -55
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +0 -4
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +0 -68
- package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +0 -3
- package/node_modules/engine.io-parser/build/esm/encodePacket.js +0 -33
- package/node_modules/engine.io-parser/build/esm/index.d.ts +0 -9
- package/node_modules/engine.io-parser/build/esm/index.js +0 -156
- package/node_modules/engine.io-parser/build/esm/package.json +0 -8
- package/node_modules/engine.io-parser/package.json +0 -46
- package/node_modules/ms/index.js +0 -162
- package/node_modules/ms/license.md +0 -21
- package/node_modules/ms/package.json +0 -38
- package/node_modules/ms/readme.md +0 -59
- package/node_modules/socket.io-client/LICENSE +0 -21
- package/node_modules/socket.io-client/README.md +0 -29
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +0 -2
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +0 -4
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +0 -12
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +0 -69
- package/node_modules/socket.io-client/build/cjs/index.d.ts +0 -29
- package/node_modules/socket.io-client/build/cjs/index.js +0 -76
- package/node_modules/socket.io-client/build/cjs/manager.d.ts +0 -295
- package/node_modules/socket.io-client/build/cjs/manager.js +0 -416
- package/node_modules/socket.io-client/build/cjs/on.d.ts +0 -2
- package/node_modules/socket.io-client/build/cjs/on.js +0 -9
- package/node_modules/socket.io-client/build/cjs/socket.d.ts +0 -593
- package/node_modules/socket.io-client/build/cjs/socket.js +0 -909
- package/node_modules/socket.io-client/build/cjs/url.d.ts +0 -33
- package/node_modules/socket.io-client/build/cjs/url.js +0 -69
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +0 -2
- package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +0 -12
- package/node_modules/socket.io-client/build/esm/contrib/backo2.js +0 -66
- package/node_modules/socket.io-client/build/esm/index.d.ts +0 -29
- package/node_modules/socket.io-client/build/esm/index.js +0 -58
- package/node_modules/socket.io-client/build/esm/manager.d.ts +0 -295
- package/node_modules/socket.io-client/build/esm/manager.js +0 -367
- package/node_modules/socket.io-client/build/esm/on.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm/on.js +0 -6
- package/node_modules/socket.io-client/build/esm/package.json +0 -5
- package/node_modules/socket.io-client/build/esm/socket.d.ts +0 -593
- package/node_modules/socket.io-client/build/esm/socket.js +0 -880
- package/node_modules/socket.io-client/build/esm/url.d.ts +0 -33
- package/node_modules/socket.io-client/build/esm/url.js +0 -59
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +0 -2
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +0 -12
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +0 -66
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +0 -29
- package/node_modules/socket.io-client/build/esm-debug/index.js +0 -62
- package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +0 -295
- package/node_modules/socket.io-client/build/esm-debug/manager.js +0 -386
- package/node_modules/socket.io-client/build/esm-debug/on.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm-debug/on.js +0 -6
- package/node_modules/socket.io-client/build/esm-debug/package.json +0 -5
- package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +0 -593
- package/node_modules/socket.io-client/build/esm-debug/socket.js +0 -902
- package/node_modules/socket.io-client/build/esm-debug/url.d.ts +0 -33
- package/node_modules/socket.io-client/build/esm-debug/url.js +0 -63
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +0 -7
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +0 -1
- package/node_modules/socket.io-client/dist/socket.io.js +0 -4955
- package/node_modules/socket.io-client/dist/socket.io.js.map +0 -1
- package/node_modules/socket.io-client/dist/socket.io.min.js +0 -7
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +0 -1
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +0 -7
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +0 -1
- package/node_modules/socket.io-client/package.json +0 -101
- package/node_modules/socket.io-parser/LICENSE +0 -20
- package/node_modules/socket.io-parser/Readme.md +0 -81
- package/node_modules/socket.io-parser/build/cjs/binary.d.ts +0 -20
- package/node_modules/socket.io-parser/build/cjs/binary.js +0 -87
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +0 -101
- package/node_modules/socket.io-parser/build/cjs/index.js +0 -367
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +0 -7
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +0 -54
- package/node_modules/socket.io-parser/build/cjs/package.json +0 -3
- package/node_modules/socket.io-parser/build/esm/binary.d.ts +0 -20
- package/node_modules/socket.io-parser/build/esm/binary.js +0 -83
- package/node_modules/socket.io-parser/build/esm/index.d.ts +0 -101
- package/node_modules/socket.io-parser/build/esm/index.js +0 -356
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +0 -7
- package/node_modules/socket.io-parser/build/esm/is-binary.js +0 -50
- package/node_modules/socket.io-parser/build/esm/package.json +0 -3
- package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +0 -20
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +0 -83
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +0 -101
- package/node_modules/socket.io-parser/build/esm-debug/index.js +0 -361
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +0 -7
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +0 -50
- package/node_modules/socket.io-parser/build/esm-debug/package.json +0 -3
- package/node_modules/socket.io-parser/package.json +0 -44
- package/node_modules/xmlhttprequest-ssl/LICENSE +0 -22
- package/node_modules/xmlhttprequest-ssl/README.md +0 -67
- package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +0 -689
- package/node_modules/xmlhttprequest-ssl/package.json +0 -40
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/LICENSE +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/README.md +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/browser.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/buffer-util.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/event-target.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/extension.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/limiter.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/receiver.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/sender.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/stream.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/subprotocol.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/validation.js +0 -0
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* LightClaw — 主入口文件
|
|
3
|
+
*
|
|
4
|
+
* 使用 OpenClaw SDK 标准的 defineChannelPluginEntry 工厂函数替代手动创建 plugin 对象,
|
|
5
|
+
* 遵循 Discord/Slack 等官方 channel 插件的标准 index.ts 模式。
|
|
6
|
+
*
|
|
7
|
+
* 该文件定义了 LightClawBot channel plugin 的入口配置,包括插件ID、名称、描述、
|
|
8
|
+
* 核心插件实现、运行时设置和工具注册等功能。
|
|
9
|
+
*/
|
|
10
|
+
// 导入 OpenClaw SDK 的核心功能
|
|
11
|
+
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
|
|
12
|
+
// 导入本地模块
|
|
13
|
+
import { lightclawPlugin } from "./src/channel.js"; // 核心插件实现
|
|
14
|
+
import { setLightclawRuntime } from "./src/runtime.js"; // 运行时配置设置函数
|
|
15
|
+
import { registerLightclawTools } from "./src/tools.js"; // 工具注册函数
|
|
16
|
+
// 导出运行时设置函数,供外部使用
|
|
17
|
+
export { setLightclawRuntime } from "./src/runtime.js";
|
|
18
|
+
/**
|
|
19
|
+
* 创建并配置 LightClawBot channel plugin 入口
|
|
20
|
+
*
|
|
21
|
+
* 使用 defineChannelPluginEntry 工厂函数创建插件配置对象,
|
|
22
|
+
* 该函数返回一个类型安全的插件入口配置。
|
|
23
|
+
*
|
|
24
|
+
* @type {ReturnType<typeof defineChannelPluginEntry<ChannelPlugin>>}
|
|
25
|
+
*/
|
|
26
|
+
const entry = defineChannelPluginEntry({
|
|
27
|
+
// 插件唯一标识符,用于在系统中识别该插件
|
|
7
28
|
id: "lightclawbot",
|
|
29
|
+
// 插件显示名称,在UI中展示给用户
|
|
8
30
|
name: "LightClawBot",
|
|
31
|
+
// 插件功能描述,说明插件的主要用途
|
|
9
32
|
description: "Channel plugin for LightClawBot",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export default plugin;
|
|
20
|
-
export { myAssistantPlugin } from "./src/channel.js";
|
|
21
|
-
export { setAssistantRuntime, getAssistantRuntime } from "./src/runtime.js";
|
|
22
|
-
export * from "./src/types.js";
|
|
23
|
-
export * from "./src/config.js";
|
|
24
|
-
export * from "./src/gateway.js";
|
|
25
|
-
export * from "./src/dedup.js";
|
|
26
|
-
export * from "./src/media.js";
|
|
27
|
-
export * from "./src/inbound.js";
|
|
28
|
-
export * from "./src/socket/index.js";
|
|
29
|
-
export * from "./src/outbound.js";
|
|
30
|
-
export * from "./src/history/index.js";
|
|
31
|
-
export * from "./src/file-storage.js";
|
|
32
|
-
export * from "./src/upload-tool.js";
|
|
33
|
-
export * from "./src/download-tool.js";
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
33
|
+
// 核心插件实现,包含消息处理、事件响应等核心逻辑
|
|
34
|
+
plugin: lightclawPlugin,
|
|
35
|
+
// 运行时设置函数,用于配置插件运行时的环境和参数
|
|
36
|
+
setRuntime: setLightclawRuntime,
|
|
37
|
+
// 完整工具注册函数,用于向系统注册插件提供的所有工具和能力
|
|
38
|
+
registerFull: registerLightclawTools,
|
|
39
|
+
});
|
|
40
|
+
// 导出默认入口配置,供 OpenClaw SDK 加载和使用
|
|
41
|
+
export default entry;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LightClaw — Setup 入口文件
|
|
3
|
+
*
|
|
4
|
+
* 使用 OpenClaw SDK 提供的 defineSetupPluginEntry 工厂函数导出轻量级的 setup 插件配置。
|
|
5
|
+
*
|
|
6
|
+
* 该入口文件的主要作用是:
|
|
7
|
+
* - 当插件未配置或未启用时,OpenClaw 系统只会加载此轻量级入口
|
|
8
|
+
* - 避免拉起 ws 等运行时重依赖,减少系统启动开销
|
|
9
|
+
* - 提供插件的基本信息和配置能力,但不包含完整的运行时逻辑
|
|
10
|
+
*
|
|
11
|
+
* 这种设计模式有助于:
|
|
12
|
+
* - 降低系统启动时的内存占用
|
|
13
|
+
* - 提高插件加载性能
|
|
14
|
+
* - 支持按需加载插件功能
|
|
15
|
+
*/
|
|
16
|
+
// 导入 OpenClaw SDK 的 setup 插件入口定义函数
|
|
17
|
+
import { defineSetupPluginEntry } from "openclaw/plugin-sdk/core";
|
|
18
|
+
// 导入本地的 setup 插件实现
|
|
19
|
+
import { lightclawSetupPlugin } from "./src/channel.setup.js";
|
|
20
|
+
// 导出 setup 插件实现,供外部模块使用或测试
|
|
21
|
+
export { lightclawSetupPlugin } from "./src/channel.setup.js";
|
|
22
|
+
/**
|
|
23
|
+
* 默认导出 setup 插件入口配置
|
|
24
|
+
*
|
|
25
|
+
* 使用 defineSetupPluginEntry 工厂函数创建并配置 setup 插件:
|
|
26
|
+
* - 包装 lightclawSetupPlugin 实例
|
|
27
|
+
* - 提供标准的插件入口接口
|
|
28
|
+
* - 确保插件符合 OpenClaw SDK 的规范要求
|
|
29
|
+
*
|
|
30
|
+
* @returns {ReturnType<typeof defineSetupPluginEntry>} 配置完成的 setup 插件入口
|
|
31
|
+
*/
|
|
32
|
+
export default defineSetupPluginEntry(lightclawSetupPlugin);
|
package/dist/src/channel.js
CHANGED
|
@@ -1,272 +1,185 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LightClaw — ChannelPlugin 主定义
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 使用 SDK 标准的 createChatChannelPlugin 构建器,
|
|
5
|
+
* 参照官方 Discord/Slack channel 实现。
|
|
6
|
+
*
|
|
7
|
+
* 结构:
|
|
8
|
+
* base: 来自 shared.ts 的 createLightclawPluginBase + 扩展字段
|
|
9
|
+
* security: DM 安全策略
|
|
10
|
+
* outbound: 出站消息适配器
|
|
7
11
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const chunks = [];
|
|
17
|
-
let remaining = text;
|
|
18
|
-
while (remaining.length > 0) {
|
|
19
|
-
if (remaining.length <= limit) {
|
|
20
|
-
chunks.push(remaining);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
let splitAt = remaining.lastIndexOf("\n", limit);
|
|
24
|
-
if (splitAt <= 0 || splitAt < limit * 0.5) {
|
|
25
|
-
splitAt = remaining.lastIndexOf(" ", limit);
|
|
26
|
-
}
|
|
27
|
-
if (splitAt <= 0 || splitAt < limit * 0.5) {
|
|
28
|
-
splitAt = limit;
|
|
29
|
-
}
|
|
30
|
-
chunks.push(remaining.slice(0, splitAt));
|
|
31
|
-
remaining = remaining.slice(splitAt).trimStart();
|
|
32
|
-
}
|
|
33
|
-
return chunks;
|
|
34
|
-
}
|
|
12
|
+
import { createChatChannelPlugin } from 'openclaw/plugin-sdk/core';
|
|
13
|
+
import { chunkText, defaultAccountId } from './utils/index.js';
|
|
14
|
+
import { CHANNEL_KEY, DEFAULT_ACCOUNT_ID, TEXT_CHUNK_LIMIT } from './config.js';
|
|
15
|
+
import { sendText, sendMedia } from './outbound.js';
|
|
16
|
+
import { startGateway } from './gateway.js';
|
|
17
|
+
import { createLightclawPluginBase } from './shared.js';
|
|
18
|
+
import { lightclawSetupAdapter } from './setup-core.js';
|
|
19
|
+
import { normalizeTarget, looksLikeId } from './messaging.js';
|
|
35
20
|
// ============================================================
|
|
36
|
-
// ChannelPlugin
|
|
21
|
+
// ChannelPlugin 定义(使用 createChatChannelPlugin)
|
|
37
22
|
// ============================================================
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
label: "LightClawBot",
|
|
44
|
-
selectionLabel: "LightClawBot",
|
|
45
|
-
docsPath: "/docs/channels/lightclawbot",
|
|
46
|
-
blurb: "Connect OpenClaw to your LightClawBot via WebSocket long-connection",
|
|
47
|
-
order: 60,
|
|
48
|
-
},
|
|
49
|
-
// ---- 能力声明 ----
|
|
50
|
-
capabilities: {
|
|
51
|
-
chatTypes: ["direct"],
|
|
52
|
-
media: true,
|
|
53
|
-
reactions: false,
|
|
54
|
-
threads: false,
|
|
55
|
-
// true = deliver 回调会收到 kind="block" 的中间块,实现流式推送
|
|
56
|
-
blockStreaming: true,
|
|
57
|
-
},
|
|
58
|
-
// ---- 配置管理(多账户) ----
|
|
59
|
-
config: {
|
|
60
|
-
listAccountIds: (cfg) => listAccountIds(cfg),
|
|
61
|
-
resolveAccount: (cfg, accountId) => resolveAccount(cfg, accountId),
|
|
62
|
-
defaultAccountId: (cfg) => defaultAccountId(cfg),
|
|
63
|
-
setAccountEnabled: ({ cfg, accountId, enabled }) => setAccountEnabledInConfigSection({
|
|
64
|
-
cfg,
|
|
65
|
-
sectionKey: CHANNEL_KEY,
|
|
66
|
-
accountId,
|
|
67
|
-
enabled,
|
|
68
|
-
allowTopLevel: true,
|
|
69
|
-
}),
|
|
70
|
-
deleteAccount: ({ cfg, accountId }) => deleteAccountFromConfigSection({
|
|
71
|
-
cfg,
|
|
72
|
-
sectionKey: CHANNEL_KEY,
|
|
73
|
-
accountId,
|
|
74
|
-
clearBaseFields: ["apiKeys", "apiBaseUrl", "name"],
|
|
23
|
+
export const lightclawPlugin = createChatChannelPlugin({
|
|
24
|
+
base: {
|
|
25
|
+
// ---- 来自 shared.ts 的基础定义 ----
|
|
26
|
+
...createLightclawPluginBase({
|
|
27
|
+
setup: lightclawSetupAdapter,
|
|
75
28
|
}),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
setup: {
|
|
91
|
-
resolveAccountId: ({ accountId }) => accountId?.trim().toLowerCase() || DEFAULT_ACCOUNT_ID,
|
|
92
|
-
applyAccountName: ({ cfg, accountId, name }) => applyAccountNameToChannelSection({ cfg, channelKey: CHANNEL_KEY, accountId, name }),
|
|
93
|
-
validateInput: ({ input }) => {
|
|
94
|
-
if (!input.token && !input.useEnv) {
|
|
95
|
-
return "Requires --token <apiKey> or --use-env (set LIGHTCLAW_API_KEY, LIGHTCLAW_API_BASE_URL)";
|
|
96
|
-
}
|
|
97
|
-
return null;
|
|
98
|
-
},
|
|
99
|
-
applyAccountConfig: ({ cfg, accountId, input }) => {
|
|
100
|
-
return applyAccountConfig(cfg, accountId, {
|
|
101
|
-
apiKey: input.token,
|
|
102
|
-
apiBaseUrl: input.apiBaseUrl,
|
|
103
|
-
name: input.name,
|
|
104
|
-
});
|
|
29
|
+
// ---- 消息目标解析 ----
|
|
30
|
+
messaging: {
|
|
31
|
+
// 对原始目标字符串进行标准化处理,如去除空格、统一格式、转换编码等,返回标准化后的字符串
|
|
32
|
+
normalizeTarget: (target) => {
|
|
33
|
+
return normalizeTarget(target);
|
|
34
|
+
},
|
|
35
|
+
targetResolver: {
|
|
36
|
+
// 判断一个原始字符串是否看起来像一个 ID,用于在解析前快速分流处理逻辑
|
|
37
|
+
looksLikeId: (id, normalized) => {
|
|
38
|
+
return looksLikeId(id, normalized);
|
|
39
|
+
},
|
|
40
|
+
/** 目标格式提示文本,显示在 CLI 帮助信息中 */
|
|
41
|
+
hint: `user:<userId> or channel:<groupId>`,
|
|
42
|
+
},
|
|
105
43
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
44
|
+
// ---- 状态面板 ----
|
|
45
|
+
status: {
|
|
46
|
+
defaultRuntime: {
|
|
47
|
+
accountId: DEFAULT_ACCOUNT_ID,
|
|
48
|
+
running: false,
|
|
49
|
+
connected: false,
|
|
50
|
+
lastConnectedAt: null,
|
|
51
|
+
lastError: null,
|
|
52
|
+
},
|
|
53
|
+
buildChannelSummary: ({ snapshot }) => ({
|
|
54
|
+
configured: snapshot.configured ?? false,
|
|
55
|
+
running: snapshot.running ?? false,
|
|
56
|
+
connected: snapshot.connected ?? false,
|
|
57
|
+
lastConnectedAt: snapshot.lastConnectedAt ?? null,
|
|
58
|
+
lastError: snapshot.lastError ?? null,
|
|
59
|
+
}),
|
|
60
|
+
buildAccountSnapshot: ({ account, runtime, cfg }) => ({
|
|
61
|
+
accountId: account?.accountId ?? defaultAccountId(cfg),
|
|
62
|
+
name: account?.name,
|
|
63
|
+
enabled: account?.enabled ?? false,
|
|
64
|
+
configured: Boolean(account?.apiKey),
|
|
65
|
+
running: runtime?.running ?? false,
|
|
66
|
+
connected: runtime?.connected ?? false,
|
|
67
|
+
lastConnectedAt: runtime?.lastConnectedAt ?? null,
|
|
68
|
+
lastError: runtime?.lastError ?? null,
|
|
69
|
+
}),
|
|
129
70
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
71
|
+
// ---- Gateway 生命周期(核心!) ----
|
|
72
|
+
gateway: {
|
|
73
|
+
/**
|
|
74
|
+
* 启动账户:建立 WS 长连接到 AI 助手 Server
|
|
75
|
+
* OpenClaw 会在加载配置后为每个 enabled 的账户调用此方法
|
|
76
|
+
*/
|
|
77
|
+
startAccount: async (ctx) => {
|
|
78
|
+
const { account, abortSignal, log, cfg } = ctx;
|
|
79
|
+
log?.info(`[${CHANNEL_KEY}:${account.accountId}] Starting gateway...`);
|
|
80
|
+
// 启动并维持一个 Socket.IO Gateway 实例
|
|
81
|
+
await startGateway({
|
|
82
|
+
account,
|
|
83
|
+
abortSignal,
|
|
84
|
+
cfg,
|
|
85
|
+
log,
|
|
86
|
+
/** WS 连接就绪回调 */
|
|
87
|
+
onReady: () => {
|
|
88
|
+
log?.info(`[${CHANNEL_KEY}:${account.accountId}] Gateway ready: WS connected`);
|
|
89
|
+
const now = Date.now();
|
|
90
|
+
ctx.setStatus({
|
|
91
|
+
...ctx.getStatus(),
|
|
92
|
+
running: true,
|
|
93
|
+
connected: true,
|
|
94
|
+
lastConnectedAt: now,
|
|
95
|
+
// 连接建立时即设置 lastEventAt,作为 health-monitor stale-socket 检测的初始基准
|
|
96
|
+
lastEventAt: now,
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
/** WS 连接断开回调 */
|
|
100
|
+
onDisconnect: () => {
|
|
101
|
+
log?.info(`[${CHANNEL_KEY}:${account.accountId}] Gateway ready: WS disconnect`);
|
|
102
|
+
ctx.setStatus({
|
|
103
|
+
...ctx.getStatus(),
|
|
104
|
+
connected: false,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
/** 错误回调:记录错误信息,不中断重连逻辑(由 gateway 内部处理) */
|
|
108
|
+
onError: (error) => {
|
|
109
|
+
log?.error(`[${CHANNEL_KEY}:${account.accountId}] Gateway error: ${error.message}`);
|
|
110
|
+
ctx.setStatus({
|
|
111
|
+
...ctx.getStatus(),
|
|
112
|
+
lastError: error.message,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* 入站事件回调:每次收到消息时调用。
|
|
117
|
+
* 刷新 lastEventAt 和 lastInboundAt,
|
|
118
|
+
* 通知框架 health-monitor 该连接仍处于活跃状态。
|
|
119
|
+
*/
|
|
120
|
+
onEvent: () => {
|
|
121
|
+
log?.info(`[${CHANNEL_KEY}:${account.accountId}] Gateway Ready: WS message enter`);
|
|
122
|
+
ctx.setStatus({
|
|
123
|
+
...ctx.getStatus(),
|
|
124
|
+
lastEventAt: Date.now(),
|
|
125
|
+
lastInboundAt: Date.now(),
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
/** 登出账户:清除凭证 */
|
|
131
|
+
logoutAccount: async ({ accountId, cfg }) => {
|
|
132
|
+
const nextCfg = { ...cfg };
|
|
133
|
+
const section = nextCfg.channels?.[CHANNEL_KEY];
|
|
134
|
+
let cleared = false;
|
|
135
|
+
if (section) {
|
|
136
|
+
if (accountId === DEFAULT_ACCOUNT_ID && section.apiKeys) {
|
|
137
|
+
delete section.apiKeys;
|
|
138
|
+
cleared = true;
|
|
139
|
+
}
|
|
140
|
+
const accounts = section.accounts;
|
|
141
|
+
if (accounts?.[accountId]?.apiKeys) {
|
|
142
|
+
delete accounts[accountId].apiKeys;
|
|
143
|
+
cleared = true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return { ok: true, cleared };
|
|
141
147
|
},
|
|
142
|
-
hint: `user:<userId> or channel:<groupId>`,
|
|
143
148
|
},
|
|
144
149
|
},
|
|
145
150
|
// ---- 出站消息适配器 ----
|
|
146
151
|
outbound: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (mode === "implicit" && allowFrom && allowFrom.length > 0) {
|
|
158
|
-
const candidate = allowFrom.find((entry) => entry && entry !== "*");
|
|
159
|
-
if (candidate) {
|
|
160
|
-
return { ok: true, to: candidate };
|
|
152
|
+
base: {
|
|
153
|
+
deliveryMode: 'direct',
|
|
154
|
+
chunker: chunkText,
|
|
155
|
+
chunkerMode: 'markdown',
|
|
156
|
+
textChunkLimit: TEXT_CHUNK_LIMIT,
|
|
157
|
+
resolveTarget: ({ to, allowFrom, mode }) => {
|
|
158
|
+
// 优先使用显式 to;implicit 模式下回退到 allowFrom 第一个非通配符条目
|
|
159
|
+
const effectiveTo = to?.trim();
|
|
160
|
+
if (effectiveTo) {
|
|
161
|
+
return { ok: true, to: effectiveTo };
|
|
161
162
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
sendText: async ({ to, text, accountId, replyToId, cfg }) => {
|
|
169
|
-
return sendText({ to, text, accountId, replyToId, cfg });
|
|
170
|
-
},
|
|
171
|
-
sendMedia: async ({ to, text, mediaUrl, accountId, replyToId, cfg }) => {
|
|
172
|
-
return sendMedia({ to, text, mediaUrl, accountId, replyToId, cfg });
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
// ---- Gateway 生命周期(核心!) ----
|
|
176
|
-
gateway: {
|
|
177
|
-
/**
|
|
178
|
-
* 启动账户:建立 WS 长连接到你的 AI 助手 Server
|
|
179
|
-
* OpenClaw 会在加载配置后为每个 enabled 的账户调用此方法
|
|
180
|
-
*/
|
|
181
|
-
startAccount: async (ctx) => {
|
|
182
|
-
const { account, abortSignal, log, cfg } = ctx;
|
|
183
|
-
log?.info(`[${CHANNEL_KEY}:${account.accountId}] Starting gateway...`);
|
|
184
|
-
await startGateway({
|
|
185
|
-
account,
|
|
186
|
-
abortSignal,
|
|
187
|
-
cfg,
|
|
188
|
-
log,
|
|
189
|
-
onReady: () => {
|
|
190
|
-
log?.info(`[${CHANNEL_KEY}:${account.accountId}] Gateway ready, WS connected`);
|
|
191
|
-
const now = Date.now();
|
|
192
|
-
ctx.setStatus({
|
|
193
|
-
...ctx.getStatus(),
|
|
194
|
-
running: true,
|
|
195
|
-
connected: true,
|
|
196
|
-
lastConnectedAt: now,
|
|
197
|
-
// 连接建立时即设置 lastEventAt,作为 health-monitor stale-socket 检测的初始基准
|
|
198
|
-
lastEventAt: now,
|
|
199
|
-
});
|
|
200
|
-
},
|
|
201
|
-
onDisconnect: () => {
|
|
202
|
-
ctx.setStatus({
|
|
203
|
-
...ctx.getStatus(),
|
|
204
|
-
connected: false,
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
onError: (error) => {
|
|
208
|
-
log?.error(`[${CHANNEL_KEY}:${account.accountId}] Gateway error: ${error.message}`);
|
|
209
|
-
ctx.setStatus({
|
|
210
|
-
...ctx.getStatus(),
|
|
211
|
-
lastError: error.message,
|
|
212
|
-
});
|
|
213
|
-
},
|
|
214
|
-
onEvent: () => {
|
|
215
|
-
// 通知框架收到了入站事件,防止 health-monitor 因 lastEventAt 过期而误判 stale-socket
|
|
216
|
-
ctx.setStatus({
|
|
217
|
-
...ctx.getStatus(),
|
|
218
|
-
lastEventAt: Date.now(),
|
|
219
|
-
lastInboundAt: Date.now(),
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
/** 登出账户:清除凭证 */
|
|
225
|
-
logoutAccount: async ({ accountId, cfg }) => {
|
|
226
|
-
const nextCfg = { ...cfg };
|
|
227
|
-
const section = nextCfg.channels?.[CHANNEL_KEY];
|
|
228
|
-
let cleared = false;
|
|
229
|
-
if (section) {
|
|
230
|
-
if (accountId === DEFAULT_ACCOUNT_ID && section.apiKeys) {
|
|
231
|
-
delete section.apiKeys;
|
|
232
|
-
cleared = true;
|
|
163
|
+
if (mode === 'implicit' && allowFrom && allowFrom.length > 0) {
|
|
164
|
+
const candidate = allowFrom.find((entry) => entry && entry !== '*');
|
|
165
|
+
if (candidate) {
|
|
166
|
+
return { ok: true, to: candidate };
|
|
167
|
+
}
|
|
233
168
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
return { ok: true, cleared };
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
error: new Error(`No delivery target for ${CHANNEL_KEY}. Specify a target with --to or configure allowFrom.`),
|
|
172
|
+
};
|
|
173
|
+
},
|
|
241
174
|
},
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
lastError: null,
|
|
175
|
+
attachedResults: {
|
|
176
|
+
channel: CHANNEL_KEY,
|
|
177
|
+
sendText: async ({ to, text, accountId, replyToId, cfg }) => {
|
|
178
|
+
return sendText({ to, text, accountId, replyToId, cfg });
|
|
179
|
+
},
|
|
180
|
+
sendMedia: async ({ to, text, mediaUrl, accountId, replyToId, cfg }) => {
|
|
181
|
+
return sendMedia({ to, text, mediaUrl, accountId, replyToId, cfg });
|
|
182
|
+
},
|
|
251
183
|
},
|
|
252
|
-
buildChannelSummary: ({ snapshot }) => ({
|
|
253
|
-
configured: snapshot.configured ?? false,
|
|
254
|
-
running: snapshot.running ?? false,
|
|
255
|
-
connected: snapshot.connected ?? false,
|
|
256
|
-
lastConnectedAt: snapshot.lastConnectedAt ?? null,
|
|
257
|
-
lastError: snapshot.lastError ?? null,
|
|
258
|
-
}),
|
|
259
|
-
buildAccountSnapshot: ({ account, runtime, }) => ({
|
|
260
|
-
accountId: account?.accountId ?? DEFAULT_ACCOUNT_ID,
|
|
261
|
-
name: account?.name,
|
|
262
|
-
enabled: account?.enabled ?? false,
|
|
263
|
-
configured: Boolean(account?.allApiKeys?.length),
|
|
264
|
-
tokenSource: account?.secretSource,
|
|
265
|
-
running: runtime?.running ?? false,
|
|
266
|
-
connected: runtime?.connected ?? false,
|
|
267
|
-
lastConnectedAt: runtime?.lastConnectedAt ?? null,
|
|
268
|
-
lastError: runtime?.lastError ?? null,
|
|
269
|
-
}),
|
|
270
184
|
},
|
|
271
|
-
};
|
|
272
|
-
//# sourceMappingURL=channel.js.map
|
|
185
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LightClaw — Setup-only 轻量插件
|
|
3
|
+
*
|
|
4
|
+
* 参照 Discord 的 channel.setup.ts 模式:
|
|
5
|
+
* 仅包含 shared base 骨架(id, meta, config, setup),
|
|
6
|
+
* 不加载 gateway / inbound / outbound 等运行时重依赖。
|
|
7
|
+
*
|
|
8
|
+
* 用于插件未配置/未启用时的 setup 流程,避免拉起不必要的运行时。
|
|
9
|
+
*/
|
|
10
|
+
import { createLightclawPluginBase } from "./shared.js";
|
|
11
|
+
import { lightclawSetupAdapter } from "./setup-core.js";
|
|
12
|
+
export const lightclawSetupPlugin = {
|
|
13
|
+
...createLightclawPluginBase({
|
|
14
|
+
setup: lightclawSetupAdapter,
|
|
15
|
+
}),
|
|
16
|
+
};
|