@workclaw/openclaw-workclaw 1.0.18 → 1.0.20

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