@xfxstudio/claworld 0.1.0

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 (69) hide show
  1. package/README.md +60 -0
  2. package/bin/claworld.mjs +9 -0
  3. package/index.js +51 -0
  4. package/openclaw.plugin.json +470 -0
  5. package/package.json +76 -0
  6. package/setup-entry.js +6 -0
  7. package/src/lib/accepted-chat-kickoff.js +192 -0
  8. package/src/lib/agent-address.js +46 -0
  9. package/src/lib/agent-profile.js +69 -0
  10. package/src/lib/http-auth.js +151 -0
  11. package/src/lib/policy.js +118 -0
  12. package/src/lib/runtime-errors.js +149 -0
  13. package/src/lib/runtime-guidance.js +458 -0
  14. package/src/openclaw/index.js +53 -0
  15. package/src/openclaw/installer/cli.js +349 -0
  16. package/src/openclaw/installer/constants.js +6 -0
  17. package/src/openclaw/installer/core.js +1548 -0
  18. package/src/openclaw/installer/doctor.js +690 -0
  19. package/src/openclaw/installer/workspace-contract.js +403 -0
  20. package/src/openclaw/plugin/account-identity.js +66 -0
  21. package/src/openclaw/plugin/claworld-channel-plugin.js +3118 -0
  22. package/src/openclaw/plugin/config-schema.js +464 -0
  23. package/src/openclaw/plugin/lifecycle.js +114 -0
  24. package/src/openclaw/plugin/managed-config.js +648 -0
  25. package/src/openclaw/plugin/onboarding.js +291 -0
  26. package/src/openclaw/plugin/register.js +961 -0
  27. package/src/openclaw/plugin/relay-client.js +783 -0
  28. package/src/openclaw/plugin/runtime.js +12 -0
  29. package/src/openclaw/protocol/relay-event-protocol.js +31 -0
  30. package/src/openclaw/runtime/canonical-result-builder.js +116 -0
  31. package/src/openclaw/runtime/demo-session-bootstrap.js +37 -0
  32. package/src/openclaw/runtime/feedback-helper.js +145 -0
  33. package/src/openclaw/runtime/inbound-session-router.js +36 -0
  34. package/src/openclaw/runtime/outbound-session-bridge.js +17 -0
  35. package/src/openclaw/runtime/product-shell-helper.js +1712 -0
  36. package/src/openclaw/runtime/runtime-path.js +19 -0
  37. package/src/openclaw/runtime/system-message-orchestrator.js +1 -0
  38. package/src/openclaw/runtime/tool-contracts.js +714 -0
  39. package/src/openclaw/runtime/tool-inventory.js +92 -0
  40. package/src/openclaw/runtime/world-moderation-helper.js +415 -0
  41. package/src/openclaw/runtime/world-session-startup.js +1 -0
  42. package/src/product-shell/catalog/default-world-catalog.js +296 -0
  43. package/src/product-shell/contracts/candidate-feed.js +330 -0
  44. package/src/product-shell/contracts/chat-request-approval-policy.js +98 -0
  45. package/src/product-shell/contracts/world-manifest.js +435 -0
  46. package/src/product-shell/contracts/world-orchestration.js +1024 -0
  47. package/src/product-shell/feedback/feedback-contract.js +13 -0
  48. package/src/product-shell/feedback/feedback-routes.js +98 -0
  49. package/src/product-shell/feedback/feedback-service.js +254 -0
  50. package/src/product-shell/index.js +163 -0
  51. package/src/product-shell/matching/matchmaking-service.js +340 -0
  52. package/src/product-shell/membership/membership-service.js +277 -0
  53. package/src/product-shell/onboarding/onboarding-routes.js +37 -0
  54. package/src/product-shell/onboarding/onboarding-service.js +230 -0
  55. package/src/product-shell/orchestration/session-orchestrator.js +38 -0
  56. package/src/product-shell/results/result-service.js +15 -0
  57. package/src/product-shell/search/search-service.js +359 -0
  58. package/src/product-shell/social/chat-request-approval-policy.js +332 -0
  59. package/src/product-shell/social/chat-request-routes.js +108 -0
  60. package/src/product-shell/social/chat-request-service.js +632 -0
  61. package/src/product-shell/social/friend-routes.js +82 -0
  62. package/src/product-shell/social/friend-service.js +560 -0
  63. package/src/product-shell/social/social-routes.js +21 -0
  64. package/src/product-shell/social/social-service.js +140 -0
  65. package/src/product-shell/worlds/world-admin-service.js +705 -0
  66. package/src/product-shell/worlds/world-authorization.js +135 -0
  67. package/src/product-shell/worlds/world-broadcast-service.js +299 -0
  68. package/src/product-shell/worlds/world-routes.js +410 -0
  69. package/src/product-shell/worlds/world-service.js +89 -0
@@ -0,0 +1,349 @@
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import {
4
+ DEFAULT_CLAWORLD_TOOL_PROFILE,
5
+ expandUserPath,
6
+ normalizeClaworldToolProfile,
7
+ } from '../plugin/managed-config.js';
8
+ import {
9
+ CLAWORLD_DOCTOR_COMMAND,
10
+ CLAWORLD_INSTALLER_BIN_NAME,
11
+ CLAWORLD_INSTALLER_COMMAND,
12
+ CLAWORLD_INSTALLER_PACKAGE_NAME,
13
+ CLAWORLD_UPDATE_COMMAND,
14
+ } from './constants.js';
15
+ import { formatClaworldDoctorReport, runClaworldDoctor } from './doctor.js';
16
+ import {
17
+ DEFAULT_OPENCLAW_BIN,
18
+ DEFAULT_OPENCLAW_CONFIG_PATH,
19
+ runClaworldInstallerInstall,
20
+ runClaworldInstallerUpdate,
21
+ } from './core.js';
22
+
23
+ function printHelp() {
24
+ console.log(`Usage: ${CLAWORLD_INSTALLER_BIN_NAME} <command> [options]
25
+
26
+ Commands:
27
+ install Run the installer-first Claworld setup flow
28
+ doctor Validate the managed Claworld install health
29
+ update Update the tracked Claworld plugin, refresh managed state, and run doctor
30
+ upgrade Alias for update
31
+ help Show this help
32
+
33
+ Install options:
34
+ --config <path> OpenClaw config path (default: ${DEFAULT_OPENCLAW_CONFIG_PATH})
35
+ --state-dir <path> Optional OPENCLAW_STATE_DIR for OpenClaw commands
36
+ --openclaw-bin <path> OpenClaw CLI binary (default: ${DEFAULT_OPENCLAW_BIN})
37
+ --server-url <url> Override the Claworld backend URL
38
+ --api-key <value> Override the Claworld backend API key
39
+ --account-id <id> Managed Claworld account id (default: claworld)
40
+ --agent-id <id> Managed local OpenClaw agent id (default: claworld)
41
+ --workspace <path> Managed agent workspace path
42
+ --display-name <name> Managed display name override
43
+ --tool-profile <name> minimal | default | full (default: ${DEFAULT_CLAWORLD_TOOL_PROFILE})
44
+ --repo-root <path> Local repo root when using --plugin-install-mode link|copy
45
+ --plugin-install-mode <m> npm | link | copy | skip (default: npm)
46
+ --plugin-source <value> npm package or local path (default: ${CLAWORLD_INSTALLER_PACKAGE_NAME})
47
+ Update options:
48
+ --config <path> OpenClaw config path (default: ${DEFAULT_OPENCLAW_CONFIG_PATH})
49
+ --state-dir <path> Optional OPENCLAW_STATE_DIR for OpenClaw commands
50
+ --openclaw-bin <path> OpenClaw CLI binary (default: ${DEFAULT_OPENCLAW_BIN})
51
+ --server-url <url> Override the Claworld backend URL
52
+ --api-key <value> Override the Claworld backend API key
53
+ --account-id <id> Managed Claworld account id (default: claworld)
54
+ --agent-id <id> Managed local OpenClaw agent id (default: claworld)
55
+ --workspace <path> Managed agent workspace path
56
+ --display-name <name> Managed display name override
57
+ --tool-profile <name> minimal | default | full (default: ${DEFAULT_CLAWORLD_TOOL_PROFILE})
58
+ Doctor options:
59
+ --config <path> OpenClaw config path (default: ${DEFAULT_OPENCLAW_CONFIG_PATH})
60
+ --state-dir <path> Optional OPENCLAW_STATE_DIR for OpenClaw commands
61
+ --openclaw-bin <path> OpenClaw CLI binary (default: ${DEFAULT_OPENCLAW_BIN})
62
+ --server-url <url> Override the Claworld backend URL
63
+ --account-id <id> Managed Claworld account id (default: claworld)
64
+ --agent-id <id> Managed local OpenClaw agent id (default: claworld)
65
+ --workspace <path> Managed workspace path override
66
+ --json Print machine-readable result
67
+ --help, -h Show this help
68
+
69
+ Canonical commands:
70
+ ${CLAWORLD_INSTALLER_COMMAND}
71
+ ${CLAWORLD_DOCTOR_COMMAND}
72
+ ${CLAWORLD_UPDATE_COMMAND}
73
+ `);
74
+ }
75
+
76
+ function nextValue(argv, index) {
77
+ if (index + 1 >= argv.length) {
78
+ throw new Error(`Missing value for ${argv[index]}`);
79
+ }
80
+ return argv[index + 1];
81
+ }
82
+
83
+ export function parseInstallerCliArgs(argv = process.argv.slice(2), env = process.env) {
84
+ const homeDir = os.homedir();
85
+ const options = {
86
+ command: null,
87
+ json: false,
88
+ install: {
89
+ openclawBin: env.OPENCLAW_BIN || DEFAULT_OPENCLAW_BIN,
90
+ configPath: expandUserPath(env.OPENCLAW_CONFIG_PATH || DEFAULT_OPENCLAW_CONFIG_PATH, homeDir),
91
+ stateDir: env.OPENCLAW_STATE_DIR ? expandUserPath(env.OPENCLAW_STATE_DIR, homeDir) : null,
92
+ serverUrl: null,
93
+ apiKey: null,
94
+ accountId: 'claworld',
95
+ agentId: 'claworld',
96
+ workspace: null,
97
+ displayName: null,
98
+ toolProfile: DEFAULT_CLAWORLD_TOOL_PROFILE,
99
+ repoRoot: null,
100
+ pluginInstallMode: 'npm',
101
+ pluginInstallSource: CLAWORLD_INSTALLER_PACKAGE_NAME,
102
+ },
103
+ update: {
104
+ openclawBin: env.OPENCLAW_BIN || DEFAULT_OPENCLAW_BIN,
105
+ configPath: expandUserPath(env.OPENCLAW_CONFIG_PATH || DEFAULT_OPENCLAW_CONFIG_PATH, homeDir),
106
+ stateDir: env.OPENCLAW_STATE_DIR ? expandUserPath(env.OPENCLAW_STATE_DIR, homeDir) : null,
107
+ serverUrl: null,
108
+ apiKey: null,
109
+ accountId: 'claworld',
110
+ agentId: 'claworld',
111
+ workspace: null,
112
+ displayName: null,
113
+ toolProfile: DEFAULT_CLAWORLD_TOOL_PROFILE,
114
+ },
115
+ doctor: {
116
+ openclawBin: env.OPENCLAW_BIN || DEFAULT_OPENCLAW_BIN,
117
+ configPath: expandUserPath(env.OPENCLAW_CONFIG_PATH || DEFAULT_OPENCLAW_CONFIG_PATH, homeDir),
118
+ stateDir: env.OPENCLAW_STATE_DIR ? expandUserPath(env.OPENCLAW_STATE_DIR, homeDir) : null,
119
+ serverUrl: null,
120
+ accountId: 'claworld',
121
+ agentId: 'claworld',
122
+ workspace: null,
123
+ },
124
+ };
125
+
126
+ if (argv.length === 0) {
127
+ printHelp();
128
+ return { ...options, command: 'help' };
129
+ }
130
+
131
+ options.command = argv[0] === 'upgrade' ? 'update' : argv[0];
132
+ const remaining = argv.slice(1);
133
+
134
+ for (let index = 0; index < remaining.length; index += 1) {
135
+ const arg = remaining[index];
136
+ switch (arg) {
137
+ case '--config':
138
+ options.install.configPath = expandUserPath(nextValue(remaining, index), homeDir);
139
+ options.update.configPath = options.install.configPath;
140
+ options.doctor.configPath = options.install.configPath;
141
+ index += 1;
142
+ break;
143
+ case '--state-dir':
144
+ options.install.stateDir = expandUserPath(nextValue(remaining, index), homeDir);
145
+ options.update.stateDir = options.install.stateDir;
146
+ options.doctor.stateDir = options.install.stateDir;
147
+ index += 1;
148
+ break;
149
+ case '--openclaw-bin':
150
+ options.install.openclawBin = nextValue(remaining, index);
151
+ options.update.openclawBin = options.install.openclawBin;
152
+ options.doctor.openclawBin = options.install.openclawBin;
153
+ index += 1;
154
+ break;
155
+ case '--server-url':
156
+ options.install.serverUrl = nextValue(remaining, index);
157
+ options.update.serverUrl = options.install.serverUrl;
158
+ options.doctor.serverUrl = options.install.serverUrl;
159
+ index += 1;
160
+ break;
161
+ case '--api-key':
162
+ options.install.apiKey = nextValue(remaining, index);
163
+ options.update.apiKey = options.install.apiKey;
164
+ index += 1;
165
+ break;
166
+ case '--account-id':
167
+ options.install.accountId = nextValue(remaining, index);
168
+ options.update.accountId = options.install.accountId;
169
+ options.doctor.accountId = options.install.accountId;
170
+ index += 1;
171
+ break;
172
+ case '--agent-id':
173
+ options.install.agentId = nextValue(remaining, index);
174
+ options.update.agentId = options.install.agentId;
175
+ options.doctor.agentId = options.install.agentId;
176
+ index += 1;
177
+ break;
178
+ case '--workspace':
179
+ options.install.workspace = expandUserPath(nextValue(remaining, index), homeDir);
180
+ options.update.workspace = options.install.workspace;
181
+ options.doctor.workspace = options.install.workspace;
182
+ index += 1;
183
+ break;
184
+ case '--display-name':
185
+ options.install.displayName = nextValue(remaining, index);
186
+ options.update.displayName = options.install.displayName;
187
+ index += 1;
188
+ break;
189
+ case '--tool-profile':
190
+ options.install.toolProfile = normalizeClaworldToolProfile(nextValue(remaining, index));
191
+ options.update.toolProfile = options.install.toolProfile;
192
+ index += 1;
193
+ break;
194
+ case '--repo-root':
195
+ options.install.repoRoot = path.resolve(expandUserPath(nextValue(remaining, index), homeDir));
196
+ index += 1;
197
+ break;
198
+ case '--plugin-install-mode':
199
+ options.install.pluginInstallMode = nextValue(remaining, index);
200
+ index += 1;
201
+ break;
202
+ case '--plugin-source':
203
+ options.install.pluginInstallSource = nextValue(remaining, index);
204
+ index += 1;
205
+ break;
206
+ case '--json':
207
+ options.json = true;
208
+ break;
209
+ case '--help':
210
+ case '-h':
211
+ printHelp();
212
+ return { ...options, command: 'help' };
213
+ default:
214
+ throw new Error(`Unknown argument: ${arg}`);
215
+ }
216
+ }
217
+
218
+ if (!['install', 'update', 'doctor', 'help'].includes(options.command)) {
219
+ throw new Error(`Unknown command: ${options.command}`);
220
+ }
221
+ if (options.command === 'install' && !['npm', 'link', 'copy', 'skip'].includes(options.install.pluginInstallMode)) {
222
+ throw new Error(`Unsupported plugin install mode: ${options.install.pluginInstallMode}`);
223
+ }
224
+ if (
225
+ options.command === 'install'
226
+ && options.install.pluginInstallMode !== 'npm'
227
+ && !options.install.repoRoot
228
+ && !options.install.pluginInstallSource
229
+ ) {
230
+ throw new Error('Local plugin install mode requires --repo-root or --plugin-source.');
231
+ }
232
+ if (
233
+ options.command === 'install'
234
+ && options.install.pluginInstallMode === 'link'
235
+ && !options.install.repoRoot
236
+ && options.install.pluginInstallSource === CLAWORLD_INSTALLER_PACKAGE_NAME
237
+ ) {
238
+ throw new Error('Link install mode requires --repo-root or --plugin-source <local-path>.');
239
+ }
240
+ if (
241
+ options.command === 'install'
242
+ && options.install.pluginInstallMode === 'copy'
243
+ && !options.install.repoRoot
244
+ && options.install.pluginInstallSource === CLAWORLD_INSTALLER_PACKAGE_NAME
245
+ ) {
246
+ throw new Error('Copy install mode requires --repo-root or --plugin-source <local-path>.');
247
+ }
248
+
249
+ if (
250
+ options.command === 'install'
251
+ && options.install.pluginInstallMode !== 'npm'
252
+ && options.install.repoRoot
253
+ && options.install.pluginInstallSource === CLAWORLD_INSTALLER_PACKAGE_NAME
254
+ ) {
255
+ options.install.pluginInstallSource = options.install.repoRoot;
256
+ }
257
+
258
+ return options;
259
+ }
260
+
261
+ function printInstallSummary(result) {
262
+ console.log('');
263
+ console.log('Claworld installer complete');
264
+ console.log('===========================');
265
+ console.log(`Managed account: ${result.transformed?.config?.channels?.claworld?.defaultAccount || 'claworld'}`);
266
+ console.log(`Canonical agentId: ${result.activation?.agentId || '(unknown)'}`);
267
+ console.log(`OpenClaw version: ${result.host?.version || '(unknown)'}`);
268
+ console.log(`Plugin action: ${result.plugin?.action || 'unknown'}`);
269
+ console.log(`Activation mode: ${result.activationMode}`);
270
+ console.log(`Runtime refresh: ${result.runtimeRefresh?.action || 'unknown'}`);
271
+ console.log(`Config path: ${result.configPath}`);
272
+ console.log(`Backup path: ${result.backupPath || '(unchanged or new file)'}`);
273
+ console.log('');
274
+ }
275
+
276
+ function printUpdateSummary(result, doctorResult) {
277
+ const trackedInstall = result.plugin?.trackedInstall || null;
278
+ const trackedSummary = trackedInstall?.tracked
279
+ ? `${trackedInstall.source || 'tracked'}${trackedInstall.spec ? ` (${trackedInstall.spec})` : ''}`
280
+ : 'not recorded';
281
+ console.log('');
282
+ console.log('Claworld update complete');
283
+ console.log('========================');
284
+ console.log(`Managed account: ${result.managedOptions?.accountId || 'claworld'}`);
285
+ console.log(`Canonical agentId: ${result.activation?.agentId || '(unknown)'}`);
286
+ console.log(`OpenClaw version: ${result.host?.version || '(unknown)'}`);
287
+ console.log(`Plugin action: ${result.plugin?.action || 'unknown'}`);
288
+ console.log(`Tracked install: ${trackedSummary}`);
289
+ console.log(`Runtime refresh: ${result.runtimeRefresh?.action || 'unknown'}`);
290
+ console.log(`Doctor status: ${doctorResult?.status || 'unknown'}`);
291
+ console.log(`Config path: ${result.configPath}`);
292
+ console.log(`Backup path: ${result.backupPath || '(unchanged or new file)'}`);
293
+ console.log('');
294
+ }
295
+
296
+ export async function runInstallerCli(argv = process.argv.slice(2), env = process.env) {
297
+ const parsed = parseInstallerCliArgs(argv, env);
298
+ if (parsed.command === 'help') {
299
+ return { ok: true, command: 'help' };
300
+ }
301
+
302
+ if (parsed.command === 'install') {
303
+ const result = await runClaworldInstallerInstall(parsed.install);
304
+ if (parsed.json) {
305
+ console.log(JSON.stringify(result, null, 2));
306
+ } else {
307
+ printInstallSummary(result);
308
+ }
309
+ return result;
310
+ }
311
+
312
+ if (parsed.command === 'update') {
313
+ const result = await runClaworldInstallerUpdate(parsed.update);
314
+ const doctorResult = await runClaworldDoctor({
315
+ ...parsed.doctor,
316
+ configPath: result.configPath,
317
+ stateDir: result.stateDir,
318
+ serverUrl: result.effectiveServerUrl || parsed.doctor.serverUrl,
319
+ accountId: result.managedOptions?.accountId || parsed.doctor.accountId,
320
+ agentId: result.managedOptions?.agentId || parsed.doctor.agentId,
321
+ workspace: result.managedOptions?.workspace || parsed.doctor.workspace,
322
+ });
323
+ if (parsed.json) {
324
+ console.log(JSON.stringify({ ...result, doctor: doctorResult }, null, 2));
325
+ } else {
326
+ printUpdateSummary(result, doctorResult);
327
+ process.stdout.write(formatClaworldDoctorReport(doctorResult));
328
+ }
329
+ if (!doctorResult.ok) {
330
+ process.exitCode = 1;
331
+ }
332
+ return {
333
+ ...result,
334
+ doctor: doctorResult,
335
+ ok: doctorResult.ok,
336
+ };
337
+ }
338
+
339
+ const result = await runClaworldDoctor(parsed.doctor);
340
+ if (parsed.json) {
341
+ console.log(JSON.stringify(result, null, 2));
342
+ } else {
343
+ process.stdout.write(formatClaworldDoctorReport(result));
344
+ }
345
+ if (!result.ok) {
346
+ process.exitCode = 1;
347
+ }
348
+ return result;
349
+ }
@@ -0,0 +1,6 @@
1
+ export const CLAWORLD_INSTALLER_BIN_NAME = 'claworld';
2
+ export const CLAWORLD_INSTALLER_PACKAGE_NAME = '@xfxstudio/claworld';
3
+ export const CLAWORLD_INSTALLER_COMMAND = 'npx -y @xfxstudio/claworld install';
4
+ export const CLAWORLD_DOCTOR_COMMAND = 'npx -y @xfxstudio/claworld doctor';
5
+ export const CLAWORLD_UPDATE_COMMAND = 'npx -y @xfxstudio/claworld update';
6
+ export const CLAWORLD_OPENCLAW_MIN_HOST_VERSION = '>=2026.3.14';