@workclaw/openclaw-workclaw 1.0.17 → 1.0.19
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 +364 -325
- package/dist/api.d.ts +3 -0
- package/dist/api.js +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +263 -0
- package/dist/setup-entry.d.ts +2 -0
- package/dist/setup-entry.js +12 -0
- package/dist/src/accounts.d.ts +66 -0
- package/dist/src/accounts.js +279 -0
- package/dist/src/api/accounts-api.d.ts +2 -0
- package/dist/src/api/accounts-api.js +130 -0
- package/dist/src/api/prompts-api.d.ts +2 -0
- package/dist/src/api/prompts-api.js +103 -0
- package/dist/src/api/session-api.d.ts +2 -0
- package/dist/src/api/session-api.js +207 -0
- package/dist/src/api/skills-api.d.ts +2 -0
- package/dist/src/api/skills-api.js +64 -0
- package/dist/src/api/workspace.d.ts +3 -0
- package/dist/src/api/workspace.js +28 -0
- package/dist/src/channel.d.ts +11 -0
- package/dist/src/channel.js +198 -0
- package/dist/src/config-schema.d.ts +93 -0
- package/dist/src/config-schema.js +56 -0
- package/dist/src/connection/workclaw-client.d.ts +147 -0
- package/dist/src/connection/workclaw-client.js +351 -0
- package/dist/src/gateway/agent-handlers.d.ts +12 -0
- package/dist/src/gateway/agent-handlers.js +433 -0
- package/dist/src/gateway/config-writer.d.ts +71 -0
- package/dist/src/gateway/config-writer.js +312 -0
- package/dist/src/gateway/message-context.d.ts +76 -0
- package/dist/src/gateway/message-context.js +499 -0
- package/dist/src/gateway/message-dispatcher.d.ts +19 -0
- package/dist/src/gateway/message-dispatcher.js +512 -0
- package/dist/src/gateway/reconnect.d.ts +27 -0
- package/dist/src/gateway/reconnect.js +206 -0
- package/dist/src/gateway/skills-handler.d.ts +29 -0
- package/dist/src/gateway/skills-handler.js +576 -0
- package/dist/src/gateway/skills-list-handler.d.ts +27 -0
- package/dist/src/gateway/skills-list-handler.js +233 -0
- package/dist/src/gateway/tools-list-handler.d.ts +30 -0
- package/dist/src/gateway/tools-list-handler.js +101 -0
- package/dist/src/gateway/workclaw-gateway.d.ts +14 -0
- package/dist/src/gateway/workclaw-gateway.js +223 -0
- package/dist/src/media/upload.d.ts +13 -0
- package/dist/src/media/upload.js +125 -0
- package/dist/src/outbound/index.d.ts +36 -0
- package/dist/src/outbound/index.js +123 -0
- package/dist/src/outbound/workclaw-sender.d.ts +36 -0
- package/dist/src/outbound/workclaw-sender.js +95 -0
- package/dist/src/runtime.d.ts +116 -0
- package/dist/src/runtime.js +374 -0
- package/dist/src/secret-contract-api.d.ts +4 -0
- package/dist/src/secret-contract-api.js +4 -0
- package/dist/src/send.d.ts +1 -0
- package/dist/src/send.js +1 -0
- package/dist/src/setup-api.d.ts +3 -0
- package/dist/src/setup-api.js +3 -0
- package/dist/src/setup-core.d.ts +3 -0
- package/dist/src/setup-core.js +13 -0
- package/dist/src/setup-surface.d.ts +7 -0
- package/dist/src/setup-surface.js +363 -0
- package/dist/src/tools/openclaw-workclaw-cron/api/index.d.ts +93 -0
- package/dist/src/tools/openclaw-workclaw-cron/api/index.js +209 -0
- package/dist/src/tools/openclaw-workclaw-cron/index.d.ts +10 -0
- package/{src/tools/openclaw-workclaw-cron/index.ts → dist/src/tools/openclaw-workclaw-cron/index.js} +33 -39
- package/dist/src/tools/openclaw-workclaw-cron/src/add/params.d.ts +16 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/params.js +152 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.d.ts +18 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.js +162 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.js +80 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.js +107 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.js +80 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.js +107 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.d.ts +17 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.js +127 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.js +87 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.d.ts +14 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.js +107 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/params.d.ts +17 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/params.js +164 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.d.ts +18 -0
- package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.js +135 -0
- package/dist/src/tools/openclaw-workclaw-cron/types/index.d.ts +52 -0
- package/dist/src/tools/openclaw-workclaw-cron/types/index.js +4 -0
- package/dist/src/tools/openclaw-workclaw-cron/utils/index.d.ts +40 -0
- package/dist/src/tools/openclaw-workclaw-cron/utils/index.js +122 -0
- package/dist/src/tools/openclaw-workclaw-system/index.d.ts +10 -0
- package/{src/tools/openclaw-workclaw-system/index.ts → dist/src/tools/openclaw-workclaw-system/index.js} +15 -17
- package/dist/src/tools/openclaw-workclaw-system/src/get/index.d.ts +8 -0
- package/dist/src/tools/openclaw-workclaw-system/src/get/index.js +64 -0
- package/dist/src/tools/openclaw-workclaw-system/src/token/index.d.ts +8 -0
- package/dist/src/tools/openclaw-workclaw-system/src/token/index.js +78 -0
- package/dist/src/types.d.ts +39 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils/content.d.ts +15 -0
- package/dist/src/utils/content.js +38 -0
- package/openclaw.plugin.json +1 -0
- package/package.json +62 -42
- package/skills/openclaw-workclaw-cron/SKILL.md +45 -28
- package/index.ts +0 -302
- package/src/accounts.ts +0 -287
- package/src/api/accounts-api.ts +0 -157
- package/src/api/prompts-api.ts +0 -123
- package/src/api/session-api.ts +0 -247
- package/src/api/skills-api.ts +0 -74
- package/src/api/workspace.ts +0 -43
- package/src/channel.ts +0 -227
- package/src/config-schema.ts +0 -110
- package/src/connection/workclaw-client.ts +0 -656
- package/src/gateway/agent-handlers.ts +0 -557
- package/src/gateway/config-writer.ts +0 -311
- package/src/gateway/message-context.ts +0 -422
- package/src/gateway/message-dispatcher.ts +0 -601
- package/src/gateway/reconnect.ts +0 -149
- package/src/gateway/skills-handler.ts +0 -805
- package/src/gateway/skills-list-handler.ts +0 -332
- package/src/gateway/tools-list-handler.ts +0 -162
- package/src/gateway/workclaw-gateway.ts +0 -525
- package/src/media/upload.ts +0 -168
- package/src/outbound/index.ts +0 -183
- package/src/outbound/workclaw-sender.ts +0 -157
- package/src/runtime.ts +0 -400
- package/src/send.ts +0 -1
- package/src/tools/openclaw-workclaw-cron/api/index.ts +0 -326
- package/src/tools/openclaw-workclaw-cron/src/add/params.ts +0 -176
- package/src/tools/openclaw-workclaw-cron/src/add/sync.ts +0 -188
- package/src/tools/openclaw-workclaw-cron/src/disable/params.ts +0 -100
- package/src/tools/openclaw-workclaw-cron/src/disable/sync.ts +0 -127
- package/src/tools/openclaw-workclaw-cron/src/enable/params.ts +0 -100
- package/src/tools/openclaw-workclaw-cron/src/enable/sync.ts +0 -127
- package/src/tools/openclaw-workclaw-cron/src/notify/sync.ts +0 -148
- package/src/tools/openclaw-workclaw-cron/src/remove/params.ts +0 -109
- package/src/tools/openclaw-workclaw-cron/src/remove/sync.ts +0 -127
- package/src/tools/openclaw-workclaw-cron/src/update/params.ts +0 -197
- package/src/tools/openclaw-workclaw-cron/src/update/sync.ts +0 -161
- package/src/tools/openclaw-workclaw-cron/types/index.ts +0 -55
- package/src/tools/openclaw-workclaw-cron/utils/index.ts +0 -141
- package/src/tools/openclaw-workclaw-system/src/get/index.ts +0 -77
- package/src/tools/openclaw-workclaw-system/src/token/index.ts +0 -93
- package/src/types.ts +0 -60
- package/src/utils/content.ts +0 -40
- package/tsconfig.json +0 -11
package/src/gateway/reconnect.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reconnect Scheduler - manages WebSocket reconnection with exponential backoff
|
|
3
|
-
* Supports both per-account and per-appKey strategies
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { WorkClawBaseConfig } from '../types.js'
|
|
7
|
-
import { clearOpenclawWorkclawTokenCache } from '../connection/workclaw-client.js'
|
|
8
|
-
import { clearOpenclawWorkclawWsConnection, setOpenclawWorkclawWsConnection } from '../runtime.js'
|
|
9
|
-
|
|
10
|
-
export interface ReconnectSchedulerOptions {
|
|
11
|
-
/** Key for WebSocket storage: accountId (per-account) or appKey (per-appKey) */
|
|
12
|
-
key: string
|
|
13
|
-
config: WorkClawBaseConfig
|
|
14
|
-
log?: {
|
|
15
|
-
info?: (msg: string) => void
|
|
16
|
-
warn?: (msg: string) => void
|
|
17
|
-
error?: (msg: string) => void
|
|
18
|
-
debug?: (msg: string) => void
|
|
19
|
-
}
|
|
20
|
-
onMessage: (data: string) => void
|
|
21
|
-
onReconnectSuccess?: () => void
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createReconnectScheduler(options: ReconnectSchedulerOptions): {
|
|
25
|
-
scheduleReconnect: () => void
|
|
26
|
-
stopReconnect: () => void
|
|
27
|
-
} {
|
|
28
|
-
const { key, config, log, onMessage, onReconnectSuccess } = options
|
|
29
|
-
|
|
30
|
-
let reconnectBackoff = 5000
|
|
31
|
-
let shouldStopReconnect = false
|
|
32
|
-
let pendingReconnectTimer: NodeJS.Timeout | null = null
|
|
33
|
-
|
|
34
|
-
const scheduleReconnect = (): void => {
|
|
35
|
-
if (shouldStopReconnect) {
|
|
36
|
-
log?.info?.(`Reconnect: Stopped due to previous auth failure`)
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
if (pendingReconnectTimer !== null) {
|
|
40
|
-
log?.info?.(`Reconnect: Already scheduled, skipping duplicate`)
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const jitter = Math.floor(Math.random() * 3000)
|
|
45
|
-
const delayMs = reconnectBackoff + jitter
|
|
46
|
-
log?.info?.(`Reconnect: Scheduling in ${delayMs}ms (base=${reconnectBackoff} + jitter=${jitter}) key=${key}`)
|
|
47
|
-
|
|
48
|
-
pendingReconnectTimer = setTimeout(async () => {
|
|
49
|
-
pendingReconnectTimer = null
|
|
50
|
-
try {
|
|
51
|
-
log?.info?.(`Reconnect: Attempting... key=${key}`)
|
|
52
|
-
|
|
53
|
-
const tokenCacheKey = config.appKey || key
|
|
54
|
-
clearOpenclawWorkclawTokenCache(tokenCacheKey)
|
|
55
|
-
|
|
56
|
-
const connConfig = {
|
|
57
|
-
baseUrl: config.baseUrl || '',
|
|
58
|
-
websocketUrl: config.websocketUrl,
|
|
59
|
-
appKey: config.appKey,
|
|
60
|
-
appSecret: config.appSecret,
|
|
61
|
-
localIp: config.localIp,
|
|
62
|
-
allowInsecureTls: config.allowInsecureTls,
|
|
63
|
-
requestTimeout: config.requestTimeout,
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const { openOpenclawWorkclawConnection } = await import('../connection/workclaw-client.js')
|
|
67
|
-
const { endpoint, ticket } = await openOpenclawWorkclawConnection(tokenCacheKey, connConfig)
|
|
68
|
-
const url = `${endpoint}?ticket=${encodeURIComponent(ticket)}`
|
|
69
|
-
|
|
70
|
-
const { Agent } = await import('undici')
|
|
71
|
-
const dispatcher = connConfig.allowInsecureTls
|
|
72
|
-
? new Agent({ connect: { rejectUnauthorized: false } })
|
|
73
|
-
: undefined
|
|
74
|
-
const wsOptions = dispatcher ? { dispatcher } : undefined
|
|
75
|
-
|
|
76
|
-
const ws = new (await import('undici')).WebSocket(url, wsOptions)
|
|
77
|
-
setOpenclawWorkclawWsConnection(key, ws)
|
|
78
|
-
|
|
79
|
-
ws.onopen = () => {
|
|
80
|
-
log?.info?.(`Reconnect: Success`)
|
|
81
|
-
reconnectBackoff = 5000
|
|
82
|
-
onReconnectSuccess?.()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
ws.onmessage = (event: any) => {
|
|
86
|
-
const data = typeof event.data === 'string' ? event.data : String(event.data ?? '')
|
|
87
|
-
log?.info?.(`Reconnect: Message bytes=${data.length}`)
|
|
88
|
-
onMessage(data)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
ws.onclose = (event: any) => {
|
|
92
|
-
const code = String(event?.code ?? '')
|
|
93
|
-
const reason = String(event?.reason ?? '')
|
|
94
|
-
log?.warn?.(`Reconnect: Closed code=${code} reason=${reason}`)
|
|
95
|
-
clearOpenclawWorkclawWsConnection(key)
|
|
96
|
-
scheduleReconnect()
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
ws.onerror = (event: any) => {
|
|
100
|
-
log?.error?.(`Reconnect: Error: ${String(event?.message ?? event)}`)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
const errorStr = String(err)
|
|
105
|
-
log?.error?.(`Reconnect: Failed: ${errorStr}`)
|
|
106
|
-
|
|
107
|
-
if (errorStr.includes('访问过于频繁')) {
|
|
108
|
-
log?.warn?.(`Reconnect: Rate limited, retrying with minimal backoff`)
|
|
109
|
-
if (pendingReconnectTimer !== null) {
|
|
110
|
-
clearTimeout(pendingReconnectTimer)
|
|
111
|
-
pendingReconnectTimer = null
|
|
112
|
-
}
|
|
113
|
-
reconnectBackoff = 1000
|
|
114
|
-
scheduleReconnect()
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const isAuthError
|
|
119
|
-
= errorStr.includes('"errCode":2001')
|
|
120
|
-
|| errorStr.includes('"code":2001')
|
|
121
|
-
|| errorStr.includes('鉴权失败')
|
|
122
|
-
|| errorStr.includes('invalid credentials')
|
|
123
|
-
|| errorStr.includes('unauthorized')
|
|
124
|
-
|
|
125
|
-
if (isAuthError) {
|
|
126
|
-
log?.error?.(`Reconnect: Authentication failed, stopping`)
|
|
127
|
-
shouldStopReconnect = true
|
|
128
|
-
if (pendingReconnectTimer !== null) {
|
|
129
|
-
clearTimeout(pendingReconnectTimer)
|
|
130
|
-
pendingReconnectTimer = null
|
|
131
|
-
}
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
scheduleReconnect()
|
|
136
|
-
}
|
|
137
|
-
}, delayMs)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const stopReconnect = (): void => {
|
|
141
|
-
shouldStopReconnect = true
|
|
142
|
-
if (pendingReconnectTimer !== null) {
|
|
143
|
-
clearTimeout(pendingReconnectTimer)
|
|
144
|
-
pendingReconnectTimer = null
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return { scheduleReconnect, stopReconnect }
|
|
149
|
-
}
|