@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.
Files changed (147) hide show
  1. package/README.md +364 -325
  2. package/dist/api.d.ts +3 -0
  3. package/dist/api.js +3 -0
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.js +263 -0
  6. package/dist/setup-entry.d.ts +2 -0
  7. package/dist/setup-entry.js +12 -0
  8. package/dist/src/accounts.d.ts +66 -0
  9. package/dist/src/accounts.js +279 -0
  10. package/dist/src/api/accounts-api.d.ts +2 -0
  11. package/dist/src/api/accounts-api.js +130 -0
  12. package/dist/src/api/prompts-api.d.ts +2 -0
  13. package/dist/src/api/prompts-api.js +103 -0
  14. package/dist/src/api/session-api.d.ts +2 -0
  15. package/dist/src/api/session-api.js +207 -0
  16. package/dist/src/api/skills-api.d.ts +2 -0
  17. package/dist/src/api/skills-api.js +64 -0
  18. package/dist/src/api/workspace.d.ts +3 -0
  19. package/dist/src/api/workspace.js +28 -0
  20. package/dist/src/channel.d.ts +11 -0
  21. package/dist/src/channel.js +198 -0
  22. package/dist/src/config-schema.d.ts +93 -0
  23. package/dist/src/config-schema.js +56 -0
  24. package/dist/src/connection/workclaw-client.d.ts +147 -0
  25. package/dist/src/connection/workclaw-client.js +351 -0
  26. package/dist/src/gateway/agent-handlers.d.ts +12 -0
  27. package/dist/src/gateway/agent-handlers.js +433 -0
  28. package/dist/src/gateway/config-writer.d.ts +71 -0
  29. package/dist/src/gateway/config-writer.js +312 -0
  30. package/dist/src/gateway/message-context.d.ts +76 -0
  31. package/dist/src/gateway/message-context.js +499 -0
  32. package/dist/src/gateway/message-dispatcher.d.ts +19 -0
  33. package/dist/src/gateway/message-dispatcher.js +512 -0
  34. package/dist/src/gateway/reconnect.d.ts +27 -0
  35. package/dist/src/gateway/reconnect.js +206 -0
  36. package/dist/src/gateway/skills-handler.d.ts +29 -0
  37. package/dist/src/gateway/skills-handler.js +576 -0
  38. package/dist/src/gateway/skills-list-handler.d.ts +27 -0
  39. package/dist/src/gateway/skills-list-handler.js +233 -0
  40. package/dist/src/gateway/tools-list-handler.d.ts +30 -0
  41. package/dist/src/gateway/tools-list-handler.js +101 -0
  42. package/dist/src/gateway/workclaw-gateway.d.ts +14 -0
  43. package/dist/src/gateway/workclaw-gateway.js +223 -0
  44. package/dist/src/media/upload.d.ts +13 -0
  45. package/dist/src/media/upload.js +125 -0
  46. package/dist/src/outbound/index.d.ts +36 -0
  47. package/dist/src/outbound/index.js +123 -0
  48. package/dist/src/outbound/workclaw-sender.d.ts +36 -0
  49. package/dist/src/outbound/workclaw-sender.js +95 -0
  50. package/dist/src/runtime.d.ts +116 -0
  51. package/dist/src/runtime.js +374 -0
  52. package/dist/src/secret-contract-api.d.ts +4 -0
  53. package/dist/src/secret-contract-api.js +4 -0
  54. package/dist/src/send.d.ts +1 -0
  55. package/dist/src/send.js +1 -0
  56. package/dist/src/setup-api.d.ts +3 -0
  57. package/dist/src/setup-api.js +3 -0
  58. package/dist/src/setup-core.d.ts +3 -0
  59. package/dist/src/setup-core.js +13 -0
  60. package/dist/src/setup-surface.d.ts +7 -0
  61. package/dist/src/setup-surface.js +363 -0
  62. package/dist/src/tools/openclaw-workclaw-cron/api/index.d.ts +93 -0
  63. package/dist/src/tools/openclaw-workclaw-cron/api/index.js +209 -0
  64. package/dist/src/tools/openclaw-workclaw-cron/index.d.ts +10 -0
  65. package/{src/tools/openclaw-workclaw-cron/index.ts → dist/src/tools/openclaw-workclaw-cron/index.js} +33 -39
  66. package/dist/src/tools/openclaw-workclaw-cron/src/add/params.d.ts +16 -0
  67. package/dist/src/tools/openclaw-workclaw-cron/src/add/params.js +152 -0
  68. package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.d.ts +18 -0
  69. package/dist/src/tools/openclaw-workclaw-cron/src/add/sync.js +162 -0
  70. package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.d.ts +14 -0
  71. package/dist/src/tools/openclaw-workclaw-cron/src/disable/params.js +80 -0
  72. package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.d.ts +14 -0
  73. package/dist/src/tools/openclaw-workclaw-cron/src/disable/sync.js +107 -0
  74. package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.d.ts +14 -0
  75. package/dist/src/tools/openclaw-workclaw-cron/src/enable/params.js +80 -0
  76. package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.d.ts +14 -0
  77. package/dist/src/tools/openclaw-workclaw-cron/src/enable/sync.js +107 -0
  78. package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.d.ts +17 -0
  79. package/dist/src/tools/openclaw-workclaw-cron/src/notify/sync.js +127 -0
  80. package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.d.ts +14 -0
  81. package/dist/src/tools/openclaw-workclaw-cron/src/remove/params.js +87 -0
  82. package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.d.ts +14 -0
  83. package/dist/src/tools/openclaw-workclaw-cron/src/remove/sync.js +107 -0
  84. package/dist/src/tools/openclaw-workclaw-cron/src/update/params.d.ts +17 -0
  85. package/dist/src/tools/openclaw-workclaw-cron/src/update/params.js +164 -0
  86. package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.d.ts +18 -0
  87. package/dist/src/tools/openclaw-workclaw-cron/src/update/sync.js +135 -0
  88. package/dist/src/tools/openclaw-workclaw-cron/types/index.d.ts +52 -0
  89. package/dist/src/tools/openclaw-workclaw-cron/types/index.js +4 -0
  90. package/dist/src/tools/openclaw-workclaw-cron/utils/index.d.ts +40 -0
  91. package/dist/src/tools/openclaw-workclaw-cron/utils/index.js +122 -0
  92. package/dist/src/tools/openclaw-workclaw-system/index.d.ts +10 -0
  93. package/{src/tools/openclaw-workclaw-system/index.ts → dist/src/tools/openclaw-workclaw-system/index.js} +15 -17
  94. package/dist/src/tools/openclaw-workclaw-system/src/get/index.d.ts +8 -0
  95. package/dist/src/tools/openclaw-workclaw-system/src/get/index.js +64 -0
  96. package/dist/src/tools/openclaw-workclaw-system/src/token/index.d.ts +8 -0
  97. package/dist/src/tools/openclaw-workclaw-system/src/token/index.js +78 -0
  98. package/dist/src/types.d.ts +39 -0
  99. package/dist/src/types.js +1 -0
  100. package/dist/src/utils/content.d.ts +15 -0
  101. package/dist/src/utils/content.js +38 -0
  102. package/openclaw.plugin.json +1 -0
  103. package/package.json +62 -42
  104. package/skills/openclaw-workclaw-cron/SKILL.md +45 -28
  105. package/index.ts +0 -302
  106. package/src/accounts.ts +0 -287
  107. package/src/api/accounts-api.ts +0 -157
  108. package/src/api/prompts-api.ts +0 -123
  109. package/src/api/session-api.ts +0 -247
  110. package/src/api/skills-api.ts +0 -74
  111. package/src/api/workspace.ts +0 -43
  112. package/src/channel.ts +0 -227
  113. package/src/config-schema.ts +0 -110
  114. package/src/connection/workclaw-client.ts +0 -656
  115. package/src/gateway/agent-handlers.ts +0 -557
  116. package/src/gateway/config-writer.ts +0 -311
  117. package/src/gateway/message-context.ts +0 -422
  118. package/src/gateway/message-dispatcher.ts +0 -601
  119. package/src/gateway/reconnect.ts +0 -149
  120. package/src/gateway/skills-handler.ts +0 -805
  121. package/src/gateway/skills-list-handler.ts +0 -332
  122. package/src/gateway/tools-list-handler.ts +0 -162
  123. package/src/gateway/workclaw-gateway.ts +0 -525
  124. package/src/media/upload.ts +0 -168
  125. package/src/outbound/index.ts +0 -183
  126. package/src/outbound/workclaw-sender.ts +0 -157
  127. package/src/runtime.ts +0 -400
  128. package/src/send.ts +0 -1
  129. package/src/tools/openclaw-workclaw-cron/api/index.ts +0 -326
  130. package/src/tools/openclaw-workclaw-cron/src/add/params.ts +0 -176
  131. package/src/tools/openclaw-workclaw-cron/src/add/sync.ts +0 -188
  132. package/src/tools/openclaw-workclaw-cron/src/disable/params.ts +0 -100
  133. package/src/tools/openclaw-workclaw-cron/src/disable/sync.ts +0 -127
  134. package/src/tools/openclaw-workclaw-cron/src/enable/params.ts +0 -100
  135. package/src/tools/openclaw-workclaw-cron/src/enable/sync.ts +0 -127
  136. package/src/tools/openclaw-workclaw-cron/src/notify/sync.ts +0 -148
  137. package/src/tools/openclaw-workclaw-cron/src/remove/params.ts +0 -109
  138. package/src/tools/openclaw-workclaw-cron/src/remove/sync.ts +0 -127
  139. package/src/tools/openclaw-workclaw-cron/src/update/params.ts +0 -197
  140. package/src/tools/openclaw-workclaw-cron/src/update/sync.ts +0 -161
  141. package/src/tools/openclaw-workclaw-cron/types/index.ts +0 -55
  142. package/src/tools/openclaw-workclaw-cron/utils/index.ts +0 -141
  143. package/src/tools/openclaw-workclaw-system/src/get/index.ts +0 -77
  144. package/src/tools/openclaw-workclaw-system/src/token/index.ts +0 -93
  145. package/src/types.ts +0 -60
  146. package/src/utils/content.ts +0 -40
  147. package/tsconfig.json +0 -11
@@ -1,311 +0,0 @@
1
- /**
2
- * Config Writer - handles writing account config to openclaw.json
3
- */
4
-
5
- import { existsSync } from 'node:fs'
6
- import { readFile, writeFile } from 'node:fs/promises'
7
- import { homedir } from 'node:os'
8
- import { join } from 'node:path'
9
- import process from 'node:process'
10
-
11
- interface ConfigLogger {
12
- info?: (msg: string) => void
13
- error?: (msg: string) => void
14
- }
15
-
16
- /**
17
- * Find the actual openclaw.json config path.
18
- */
19
- function findConfigPath(): string {
20
- // Prefer homedir config over cwd, since cwd might be the project directory
21
- // which could have a stale or unrelated openclaw.json
22
- const configPaths = [
23
- join(homedir(), '.openclaw', 'openclaw.json'),
24
- join(homedir(), '.openclaw', 'config.json'),
25
- join(process.cwd(), 'openclaw.json'),
26
- join(process.cwd(), 'config.json'),
27
- ]
28
-
29
- const found = configPaths.find(p => existsSync(p))
30
- return found ?? join(homedir(), '.openclaw', 'openclaw.json')
31
- }
32
-
33
- /**
34
- * Write a new config to the openclaw.json file.
35
- */
36
- export async function writeConfigFile(
37
- newConfig: any,
38
- cfg: any,
39
- log?: ConfigLogger,
40
- ): Promise<void> {
41
- const configPath = findConfigPath()
42
-
43
- try {
44
- let existingConfig: any = {}
45
- if (existsSync(configPath)) {
46
- try {
47
- const content = await readFile(configPath, 'utf-8')
48
- existingConfig = JSON.parse(content)
49
- }
50
- catch (parseErr) {
51
- log?.error?.(`[WriteConfig] Failed to parse existing config: ${String(parseErr)}`)
52
- }
53
- }
54
-
55
- const mergedConfig = { ...existingConfig, ...newConfig }
56
- await writeFile(configPath, JSON.stringify(mergedConfig, null, 2), 'utf-8')
57
- log?.info?.(`[WriteConfig] Config written to ${configPath}`)
58
- Object.assign(cfg, newConfig)
59
- }
60
- catch (err) {
61
- log?.error?.(`[WriteConfig] Failed to write config: ${String(err)}`)
62
- Object.assign(cfg, newConfig)
63
- throw err
64
- }
65
- }
66
-
67
- /**
68
- * Save openConversationId to account config.
69
- */
70
- export async function saveOpenConversationId(
71
- accountId: string,
72
- openConversationId: string,
73
- cfg: any,
74
- log?: ConfigLogger,
75
- ): Promise<void> {
76
- try {
77
- const configPath = findConfigPath()
78
- let existingConfig: any = {}
79
- if (existsSync(configPath)) {
80
- try {
81
- const content = await readFile(configPath, 'utf-8')
82
- existingConfig = JSON.parse(content)
83
- }
84
- catch (parseErr) {
85
- log?.error?.(`SaveConversation: Failed to parse existing config: ${String(parseErr)}`)
86
- }
87
- }
88
-
89
- const channels = existingConfig?.channels && typeof existingConfig.channels === 'object' ? existingConfig.channels : {}
90
- const openclawWorkclaw
91
- = channels['openclaw-workclaw'] && typeof channels['openclaw-workclaw'] === 'object' ? channels['openclaw-workclaw'] : {}
92
- const accounts
93
- = openclawWorkclaw.accounts && typeof openclawWorkclaw.accounts === 'object' ? { ...openclawWorkclaw.accounts } : {}
94
-
95
- let savedToAccount: string | null = null
96
-
97
- if (accounts[accountId]) {
98
- accounts[accountId] = {
99
- ...accounts[accountId],
100
- openConversationId,
101
- }
102
- savedToAccount = accountId
103
- }
104
- else {
105
- const defaultAccount = accounts.default
106
- if (defaultAccount) {
107
- defaultAccount.openConversationId = openConversationId
108
- savedToAccount = 'default'
109
- log?.info?.(`SaveConversation: Saved openConversationId ${openConversationId} to default account`)
110
- }
111
- else {
112
- log?.info?.(`SaveConversation: Account ${accountId} not found, default account also missing`)
113
- }
114
- }
115
-
116
- if (!savedToAccount) {
117
- return
118
- }
119
-
120
- const mergedConfig = {
121
- ...existingConfig,
122
- channels: {
123
- ...channels,
124
- 'openclaw-workclaw': {
125
- ...openclawWorkclaw,
126
- accounts,
127
- },
128
- },
129
- }
130
-
131
- await writeFile(configPath, JSON.stringify(mergedConfig, null, 2), 'utf-8')
132
- log?.info?.(`SaveConversation: Saved openConversationId to ${configPath} for account ${savedToAccount}`)
133
- Object.assign(cfg, mergedConfig)
134
- }
135
- catch (err) {
136
- log?.error?.(`SaveConversation: Failed to write config: ${String(err)}`)
137
- throw err
138
- }
139
- }
140
-
141
- /**
142
- * Save userId to openclawWorkclaw config.
143
- */
144
- export async function saveWorkClawUserId(
145
- accountId: string,
146
- userId: string | number,
147
- cfg: any,
148
- log?: ConfigLogger,
149
- ): Promise<void> {
150
- try {
151
- const configPath = findConfigPath()
152
- let existingConfig: any = {}
153
- if (existsSync(configPath)) {
154
- try {
155
- const content = await readFile(configPath, 'utf-8')
156
- existingConfig = JSON.parse(content)
157
- }
158
- catch (parseErr) {
159
- log?.error?.(`SaveUserId: Failed to parse existing config: ${String(parseErr)}`)
160
- }
161
- }
162
-
163
- const channels = existingConfig?.channels && typeof existingConfig.channels === 'object' ? existingConfig.channels : {}
164
- const openclawWorkclaw
165
- = channels['openclaw-workclaw'] && typeof channels['openclaw-workclaw'] === 'object' ? channels['openclaw-workclaw'] : {}
166
-
167
- const mergedConfig = {
168
- ...existingConfig,
169
- channels: {
170
- ...channels,
171
- 'openclaw-workclaw': {
172
- ...openclawWorkclaw,
173
- userId,
174
- },
175
- },
176
- }
177
-
178
- await writeFile(configPath, JSON.stringify(mergedConfig, null, 2), 'utf-8')
179
- log?.info?.(`SaveUserId: Saved userId ${userId} to ${configPath} for account ${accountId}`)
180
- Object.assign(cfg, mergedConfig)
181
- }
182
- catch (err) {
183
- log?.error?.(`SaveUserId: Failed to write config: ${String(err)}`)
184
- throw err
185
- }
186
- }
187
-
188
- /**
189
- * Save agentId to account config.
190
- */
191
- export async function saveWorkClawAgentId(
192
- accountId: string,
193
- agentId: string | number,
194
- cfg: any,
195
- log?: ConfigLogger,
196
- ): Promise<void> {
197
- try {
198
- const configPath = findConfigPath()
199
- let existingConfig: any = {}
200
- if (existsSync(configPath)) {
201
- try {
202
- const content = await readFile(configPath, 'utf-8')
203
- existingConfig = JSON.parse(content)
204
- }
205
- catch (parseErr) {
206
- log?.error?.(`SaveAgentId: Failed to parse existing config: ${String(parseErr)}`)
207
- }
208
- }
209
-
210
- const channels = existingConfig?.channels && typeof existingConfig.channels === 'object' ? existingConfig.channels : {}
211
- const openclawWorkclaw
212
- = channels['openclaw-workclaw'] && typeof channels['openclaw-workclaw'] === 'object' ? channels['openclaw-workclaw'] : {}
213
- const accounts
214
- = openclawWorkclaw.accounts && typeof openclawWorkclaw.accounts === 'object' ? { ...openclawWorkclaw.accounts } : {}
215
-
216
- let savedToAccount: string | null = null
217
-
218
- if (accounts[accountId]) {
219
- accounts[accountId] = {
220
- ...accounts[accountId],
221
- agentId,
222
- }
223
- savedToAccount = accountId
224
- }
225
- else {
226
- const defaultAccount = accounts.default
227
- if (defaultAccount) {
228
- if (!defaultAccount.agentId) {
229
- defaultAccount.agentId = agentId
230
- savedToAccount = 'default'
231
- log?.info?.(`SaveAgentId: Saved agentId ${agentId} to default account`)
232
- }
233
- }
234
- else {
235
- log?.info?.(`SaveAgentId: Account ${accountId} not found, default account also missing`)
236
- }
237
- }
238
-
239
- if (!savedToAccount) {
240
- return
241
- }
242
-
243
- const mergedConfig = {
244
- ...existingConfig,
245
- channels: {
246
- ...channels,
247
- 'openclaw-workclaw': {
248
- ...openclawWorkclaw,
249
- accounts,
250
- },
251
- },
252
- }
253
-
254
- await writeFile(configPath, JSON.stringify(mergedConfig, null, 2), 'utf-8')
255
- log?.info?.(`SaveAgentId: Saved agentId ${agentId} to ${configPath} for account ${savedToAccount}`)
256
- Object.assign(cfg, mergedConfig)
257
- }
258
- catch (err) {
259
- log?.error?.(`SaveAgentId: Failed to write config: ${String(err)}`)
260
- throw err
261
- }
262
- }
263
-
264
- /**
265
- * Save apiKey to models configuration
266
- */
267
- export async function saveWorkClawApiKey(
268
- apiKey: string,
269
- cfg: any,
270
- log?: ConfigLogger,
271
- ): Promise<void> {
272
- try {
273
- const configPath = findConfigPath()
274
- let existingConfig: any = {}
275
- if (existsSync(configPath)) {
276
- try {
277
- const content = await readFile(configPath, 'utf-8')
278
- existingConfig = JSON.parse(content)
279
- }
280
- catch (parseErr) {
281
- log?.error?.(`SaveApiKey: Failed to parse existing config: ${String(parseErr)}`)
282
- }
283
- }
284
-
285
- const existingModels = existingConfig.models || {}
286
- const existingProviders = existingModels.providers || {}
287
- const existingSophnetMinimax = existingProviders['sophnet-minimax'] || {}
288
-
289
- const mergedConfig = {
290
- ...existingConfig,
291
- models: {
292
- ...existingModels,
293
- providers: {
294
- ...existingProviders,
295
- 'sophnet-minimax': {
296
- ...existingSophnetMinimax,
297
- apiKey,
298
- },
299
- },
300
- },
301
- }
302
-
303
- await writeFile(configPath, JSON.stringify(mergedConfig, null, 2), 'utf-8')
304
- log?.info?.(`SaveApiKey: Saved apiKey to ${configPath}`)
305
- Object.assign(cfg, mergedConfig)
306
- }
307
- catch (err) {
308
- log?.error?.(`SaveApiKey: Failed to write config: ${String(err)}`)
309
- throw err
310
- }
311
- }