@xfxstudio/claworld 0.1.4 → 0.2.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 (55) hide show
  1. package/README.md +12 -29
  2. package/openclaw.plugin.json +9 -33
  3. package/package.json +2 -10
  4. package/skills/claworld-help/SKILL.md +86 -160
  5. package/skills/claworld-join-and-chat/SKILL.md +107 -203
  6. package/skills/claworld-manage-worlds/SKILL.md +75 -392
  7. package/src/lib/chat-request.js +347 -0
  8. package/src/lib/{accepted-chat-kickoff.js → relay/kickoff-text.js} +67 -26
  9. package/src/openclaw/index.js +0 -5
  10. package/src/openclaw/installer/cli.js +14 -16
  11. package/src/openclaw/installer/core.js +13 -14
  12. package/src/openclaw/installer/doctor.js +69 -31
  13. package/src/openclaw/installer/workspace-contract.js +33 -9
  14. package/src/openclaw/plugin/claworld-channel-plugin.js +156 -625
  15. package/src/openclaw/plugin/config-schema.js +4 -16
  16. package/src/openclaw/plugin/managed-config.js +127 -75
  17. package/src/openclaw/plugin/onboarding.js +7 -3
  18. package/src/openclaw/plugin/register.js +40 -339
  19. package/src/openclaw/plugin/relay-client.js +112 -102
  20. package/src/openclaw/protocol/relay-event-protocol.js +34 -22
  21. package/src/openclaw/runtime/canonical-result-builder.js +15 -5
  22. package/src/openclaw/runtime/demo-session-bootstrap.js +0 -4
  23. package/src/openclaw/runtime/feedback-helper.js +3 -2
  24. package/src/openclaw/runtime/inbound-session-router.js +28 -20
  25. package/src/openclaw/runtime/outbound-session-bridge.js +21 -9
  26. package/src/openclaw/runtime/product-shell-helper.js +45 -637
  27. package/src/openclaw/runtime/runtime-path.js +2 -2
  28. package/src/openclaw/runtime/system-message-orchestrator.js +1 -1
  29. package/src/openclaw/runtime/tool-contracts.js +36 -258
  30. package/src/openclaw/runtime/world-moderation-helper.js +11 -65
  31. package/src/product-shell/catalog/default-world-catalog.js +15 -33
  32. package/src/product-shell/contracts/candidate-feed.js +40 -5
  33. package/src/product-shell/contracts/chat-request-approval-policy.js +3 -3
  34. package/src/product-shell/contracts/world-manifest.js +134 -161
  35. package/src/product-shell/contracts/world-orchestration.js +55 -326
  36. package/src/product-shell/feedback/feedback-routes.js +4 -3
  37. package/src/product-shell/feedback/feedback-service.js +11 -8
  38. package/src/product-shell/index.js +6 -7
  39. package/src/product-shell/matching/matchmaking-service.js +39 -5
  40. package/src/product-shell/membership/membership-service.js +125 -147
  41. package/src/product-shell/onboarding/onboarding-service.js +2 -2
  42. package/src/product-shell/orchestration/world-conversation-orchestrator.js +30 -0
  43. package/src/product-shell/orchestration/world-conversation-text.js +231 -0
  44. package/src/product-shell/results/result-service.js +9 -3
  45. package/src/product-shell/search/search-service.js +28 -1
  46. package/src/product-shell/social/chat-request-routes.js +0 -1
  47. package/src/product-shell/social/chat-request-service.js +1 -102
  48. package/src/product-shell/worlds/world-admin-service.js +86 -277
  49. package/src/product-shell/worlds/world-authorization.js +3 -5
  50. package/src/product-shell/worlds/world-routes.js +8 -38
  51. package/src/product-shell/worlds/world-service.js +3 -3
  52. package/src/product-shell/worlds/world-text.js +77 -0
  53. package/src/lib/runtime-guidance.js +0 -457
  54. package/src/openclaw/runtime/world-session-startup.js +0 -1
  55. package/src/product-shell/orchestration/session-orchestrator.js +0 -38
@@ -3,9 +3,11 @@ import path from 'path';
3
3
  import { inspectClaworldChannelAccount } from '../plugin/config-schema.js';
4
4
  import {
5
5
  DEFAULT_CLAWORLD_ACCOUNT_ID,
6
+ DEFAULT_CLAWORLD_AGENT_ID,
6
7
  DEFAULT_CLAWORLD_SERVER_URL,
7
8
  expandUserPath,
8
9
  normalizeText,
10
+ resolveClaworldManagedRuntimeOptions,
9
11
  } from '../plugin/managed-config.js';
10
12
  import {
11
13
  CLAWORLD_DOCTOR_COMMAND,
@@ -195,7 +197,7 @@ export async function runClaworldDoctor({
195
197
  configPath = DEFAULT_OPENCLAW_CONFIG_PATH,
196
198
  stateDir = DEFAULT_OPENCLAW_STATE_DIR,
197
199
  accountId = DEFAULT_CLAWORLD_ACCOUNT_ID,
198
- agentId = DEFAULT_CLAWORLD_ACCOUNT_ID,
200
+ agentId = DEFAULT_CLAWORLD_AGENT_ID,
199
201
  workspace = null,
200
202
  serverUrl = null,
201
203
  fetchImpl = globalThis.fetch?.bind(globalThis),
@@ -209,26 +211,39 @@ export async function runClaworldDoctor({
209
211
  const configState = await loadConfigFromDisk(resolvedConfigPath);
210
212
  const config = configState.config;
211
213
  const configuredAccount = inspectClaworldChannelAccount(config, accountId);
214
+ const managedOptions = resolveClaworldManagedRuntimeOptions({
215
+ cfg: config,
216
+ accountId,
217
+ overrides: {
218
+ agentId,
219
+ workspace,
220
+ },
221
+ });
212
222
  const rawManagedAccount = config?.channels?.claworld?.accounts?.[configuredAccount.accountId] || null;
213
223
  const configuredApiKey = normalizeText(rawManagedAccount?.apiKey, 'local-test');
214
- const resolvedAgentId = normalizeText(agentId, normalizeText(configuredAccount.accountId, DEFAULT_CLAWORLD_ACCOUNT_ID));
215
- const resolvedWorkspace = normalizeText(
216
- workspace,
217
- normalizeText(findManagedAgentEntry(config, resolvedAgentId)?.workspace, `~/.openclaw/workspace-${resolvedAgentId}`),
218
- );
224
+ const resolvedAgentId = normalizeText(managedOptions.agentId, DEFAULT_CLAWORLD_AGENT_ID);
225
+ const resolvedWorkspace = normalizeText(managedOptions.workspace, null);
219
226
  const effectiveServerUrl = normalizeText(
220
227
  serverUrl,
221
228
  normalizeText(configuredAccount.serverUrl, DEFAULT_CLAWORLD_SERVER_URL),
222
229
  );
223
- const workspaceInspection = await inspectManagedWorkspaceContract({
224
- agentId: resolvedAgentId,
225
- accountId: normalizeText(accountId, configuredAccount.accountId || DEFAULT_CLAWORLD_ACCOUNT_ID),
226
- workspace: resolvedWorkspace,
227
- serverUrl: effectiveServerUrl,
228
- appToken: configuredAccount.appToken,
229
- registrationAgentCode: configuredAccount.registration?.agentCode || null,
230
- defaultToAddress: configuredAccount.relay?.defaultToAddress || null,
231
- });
230
+ const workspaceInspection = managedOptions.manageWorkspace
231
+ ? await inspectManagedWorkspaceContract({
232
+ agentId: resolvedAgentId,
233
+ accountId: normalizeText(accountId, configuredAccount.accountId || DEFAULT_CLAWORLD_ACCOUNT_ID),
234
+ workspace: resolvedWorkspace,
235
+ serverUrl: effectiveServerUrl,
236
+ appToken: configuredAccount.appToken,
237
+ registrationAgentCode: configuredAccount.registration?.agentCode || null,
238
+ defaultToAddress: configuredAccount.relay?.defaultToAddress || null,
239
+ })
240
+ : {
241
+ ok: true,
242
+ workspacePath: resolvedWorkspace,
243
+ metadataPath: null,
244
+ files: [],
245
+ issues: [],
246
+ };
232
247
 
233
248
  const checks = [];
234
249
  const facts = {
@@ -362,15 +377,31 @@ export async function runClaworldDoctor({
362
377
  checks.push(createCheck({
363
378
  id: 'managed-agent',
364
379
  category: 'Managed config',
365
- label: 'Managed local agent entry',
366
- status: agentEntry && agentWorkspace === resolvedWorkspace ? 'pass' : 'fail',
367
- summary: agentEntry && agentWorkspace === resolvedWorkspace
368
- ? `Managed agent \`${resolvedAgentId}\` points at \`${resolvedWorkspace}\`.`
369
- : agentEntry
370
- ? `Managed agent \`${resolvedAgentId}\` exists but points at \`${agentWorkspace || 'missing workspace'}\`.`
371
- : `Managed agent \`${resolvedAgentId}\` is missing from agents.list.`,
372
- action: `Rerun \`${CLAWORLD_INSTALLER_COMMAND}\` to reconcile the managed agent entry.`,
373
- details: { expectedWorkspace: resolvedWorkspace, actualWorkspace: agentWorkspace },
380
+ label: managedOptions.manageAgentEntry ? 'Managed local agent entry' : 'Bound local agent target',
381
+ status: managedOptions.manageAgentEntry
382
+ ? (agentEntry && agentWorkspace === resolvedWorkspace ? 'pass' : 'fail')
383
+ : (agentEntry ? 'pass' : 'warn'),
384
+ summary: managedOptions.manageAgentEntry
385
+ ? (
386
+ agentEntry && agentWorkspace === resolvedWorkspace
387
+ ? `Managed agent \`${resolvedAgentId}\` points at \`${resolvedWorkspace}\`.`
388
+ : agentEntry
389
+ ? `Managed agent \`${resolvedAgentId}\` exists but points at \`${agentWorkspace || 'missing workspace'}\`.`
390
+ : `Managed agent \`${resolvedAgentId}\` is missing from agents.list.`
391
+ )
392
+ : (
393
+ agentEntry
394
+ ? `Claworld is bound to existing local agent \`${resolvedAgentId}\` (${agentWorkspace || 'workspace unspecified'}).`
395
+ : `Claworld is configured to bind to local agent \`${resolvedAgentId}\`; this doctor run could not confirm an agents.list entry and will rely on runtime binding visibility instead.`
396
+ ),
397
+ action: managedOptions.manageAgentEntry
398
+ ? `Rerun \`${CLAWORLD_INSTALLER_COMMAND}\` to reconcile the managed agent entry.`
399
+ : null,
400
+ details: {
401
+ expectedWorkspace: resolvedWorkspace,
402
+ actualWorkspace: agentWorkspace,
403
+ manageAgentEntry: managedOptions.manageAgentEntry,
404
+ },
374
405
  }));
375
406
 
376
407
  checks.push(createCheck({
@@ -689,11 +720,17 @@ export async function runClaworldDoctor({
689
720
  id: 'workspace-contract',
690
721
  category: 'Workspace',
691
722
  label: 'Managed workspace contract',
692
- status: workspaceWorstStatus,
693
- summary: workspaceInspection.ok
694
- ? `Managed workspace is present with ${formatWorkspaceState(workspaceInspection)}.`
695
- : `Managed workspace needs repair: ${workspaceInspection.issues.map((issue) => issue.code).join(', ')}.`,
696
- action: workspaceInspection.ok ? null : `Rerun \`${CLAWORLD_INSTALLER_COMMAND}\` to repair the managed workspace bootstrap.`,
723
+ status: managedOptions.manageWorkspace ? workspaceWorstStatus : 'pass',
724
+ summary: managedOptions.manageWorkspace
725
+ ? (
726
+ workspaceInspection.ok
727
+ ? `Managed workspace is present with ${formatWorkspaceState(workspaceInspection)}.`
728
+ : `Managed workspace needs repair: ${workspaceInspection.issues.map((issue) => issue.code).join(', ')}.`
729
+ )
730
+ : `Claworld is attached to existing local agent \`${resolvedAgentId}\`; no dedicated managed workspace is expected.`,
731
+ action: managedOptions.manageWorkspace && !workspaceInspection.ok
732
+ ? `Rerun \`${CLAWORLD_INSTALLER_COMMAND}\` to repair the managed workspace bootstrap.`
733
+ : null,
697
734
  details: {
698
735
  workspacePath: workspaceInspection.workspacePath,
699
736
  metadataPath: workspaceInspection.metadataPath,
@@ -704,6 +741,7 @@ export async function runClaworldDoctor({
704
741
  exists: file.exists,
705
742
  })),
706
743
  issues: workspaceInspection.issues,
744
+ manageWorkspace: managedOptions.manageWorkspace,
707
745
  },
708
746
  }));
709
747
 
@@ -735,8 +773,8 @@ export function formatClaworldDoctorReport(result = {}) {
735
773
  `Command: ${CLAWORLD_DOCTOR_COMMAND}`,
736
774
  `Config: ${result.configPath || '(unknown)'}`,
737
775
  `Managed account: ${result.accountId || '(unknown)'}`,
738
- `Managed agent: ${result.agentId || '(unknown)'}`,
739
- `Managed workspace: ${result.workspacePath || '(unknown)'}`,
776
+ `Bound local agent: ${result.agentId || '(unknown)'}`,
777
+ `Managed workspace: ${result.workspacePath || '(not used)'}`,
740
778
  '',
741
779
  ];
742
780
 
@@ -12,6 +12,28 @@ import {
12
12
  export const CLAWORLD_MANAGED_WORKSPACE_METADATA_FILE = '.claworld-managed.json';
13
13
  export const CLAWORLD_MANAGED_WORKSPACE_CONTRACT_VERSION = 1;
14
14
 
15
+ function resolveHomeDir(homeDir = null) {
16
+ const explicitHomeDir = normalizeText(homeDir, null);
17
+ if (explicitHomeDir) {
18
+ return explicitHomeDir;
19
+ }
20
+
21
+ const envHomeDir = normalizeText(
22
+ process.env.HOME,
23
+ normalizeText(
24
+ process.env.USERPROFILE,
25
+ normalizeText(
26
+ process.env.HOMEDRIVE && process.env.HOMEPATH
27
+ ? path.join(process.env.HOMEDRIVE, process.env.HOMEPATH)
28
+ : null,
29
+ null,
30
+ ),
31
+ ),
32
+ );
33
+
34
+ return envHomeDir || os.homedir();
35
+ }
36
+
15
37
  function createHash(content) {
16
38
  return crypto.createHash('sha256').update(String(content || ''), 'utf8').digest('hex');
17
39
  }
@@ -51,12 +73,13 @@ function normalizeMetadata(source = {}) {
51
73
  };
52
74
  }
53
75
 
54
- export function resolveManagedWorkspacePath(workspace, homeDir = os.homedir()) {
55
- return path.resolve(expandUserPath(workspace, homeDir));
76
+ export function resolveManagedWorkspacePath(workspace, homeDir = null) {
77
+ return path.resolve(expandUserPath(workspace, resolveHomeDir(homeDir)));
56
78
  }
57
79
 
58
- export function buildManagedWorkspaceContract(options = {}, homeDir = os.homedir()) {
59
- const workspacePath = resolveManagedWorkspacePath(options.workspace, homeDir);
80
+ export function buildManagedWorkspaceContract(options = {}, homeDir = null) {
81
+ const resolvedHomeDir = resolveHomeDir(homeDir);
82
+ const workspacePath = resolveManagedWorkspacePath(options.workspace, resolvedHomeDir);
60
83
  const files = [
61
84
  createWorkspaceFileSpec('AGENTS.md', 'refreshable', buildWorkspaceAgentsContent(options)),
62
85
  createWorkspaceFileSpec('MEMORY.md', 'durable', buildWorkspaceMemoryContent(options)),
@@ -75,7 +98,7 @@ export function buildManagedWorkspaceContract(options = {}, homeDir = os.homedir
75
98
  };
76
99
  }
77
100
 
78
- export async function loadManagedWorkspaceMetadata(workspacePath, homeDir = os.homedir()) {
101
+ export async function loadManagedWorkspaceMetadata(workspacePath, homeDir = null) {
79
102
  const resolvedWorkspacePath = resolveManagedWorkspacePath(workspacePath, homeDir);
80
103
  const metadataPath = path.join(resolvedWorkspacePath, CLAWORLD_MANAGED_WORKSPACE_METADATA_FILE);
81
104
  const raw = await readTextIfPresent(metadataPath);
@@ -214,12 +237,13 @@ function evaluateDurableFile({
214
237
  };
215
238
  }
216
239
 
217
- export async function seedManagedWorkspaceContract(options = {}, dryRun = false, homeDir = os.homedir()) {
218
- const contract = buildManagedWorkspaceContract(options, homeDir);
240
+ export async function seedManagedWorkspaceContract(options = {}, dryRun = false, homeDir = null) {
241
+ const resolvedHomeDir = resolveHomeDir(homeDir);
242
+ const contract = buildManagedWorkspaceContract(options, resolvedHomeDir);
219
243
  const agentDirPath = options.agentDirExplicit && options.agentDir
220
- ? path.resolve(expandUserPath(options.agentDir, homeDir))
244
+ ? path.resolve(expandUserPath(options.agentDir, resolvedHomeDir))
221
245
  : null;
222
- const metadataState = await loadManagedWorkspaceMetadata(contract.workspacePath, homeDir);
246
+ const metadataState = await loadManagedWorkspaceMetadata(contract.workspacePath, resolvedHomeDir);
223
247
  const previousFiles = metadataState.value?.files || {};
224
248
  const actions = [];
225
249