@xfxstudio/claworld 0.1.5 → 0.2.1

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 (54) hide show
  1. package/README.md +12 -29
  2. package/openclaw.plugin.json +5 -29
  3. package/package.json +4 -12
  4. package/skills/claworld-help/SKILL.md +50 -182
  5. package/skills/claworld-join-and-chat/SKILL.md +78 -288
  6. package/skills/claworld-manage-worlds/SKILL.md +71 -288
  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 +18 -9
  11. package/src/openclaw/installer/core.js +12 -6
  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 +118 -623
  15. package/src/openclaw/plugin/config-schema.js +3 -15
  16. package/src/openclaw/plugin/managed-config.js +98 -47
  17. package/src/openclaw/plugin/onboarding.js +7 -3
  18. package/src/openclaw/plugin/register.js +37 -336
  19. package/src/openclaw/plugin/relay-client.js +111 -101
  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 +43 -636
  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 +33 -258
  30. package/src/openclaw/runtime/world-moderation-helper.js +11 -65
  31. package/src/product-shell/catalog/default-world-catalog.js +9 -27
  32. package/src/product-shell/contracts/candidate-feed.js +26 -1
  33. package/src/product-shell/contracts/chat-request-approval-policy.js +4 -4
  34. package/src/product-shell/contracts/world-manifest.js +115 -160
  35. package/src/product-shell/contracts/world-orchestration.js +47 -322
  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 +5 -6
  39. package/src/product-shell/membership/membership-service.js +125 -147
  40. package/src/product-shell/onboarding/onboarding-service.js +2 -2
  41. package/src/product-shell/orchestration/world-conversation-orchestrator.js +30 -0
  42. package/src/product-shell/orchestration/world-conversation-text.js +231 -0
  43. package/src/product-shell/results/result-service.js +9 -3
  44. package/src/product-shell/search/search-service.js +28 -1
  45. package/src/product-shell/social/chat-request-routes.js +0 -1
  46. package/src/product-shell/social/chat-request-service.js +1 -102
  47. package/src/product-shell/worlds/world-admin-service.js +85 -276
  48. package/src/product-shell/worlds/world-authorization.js +3 -5
  49. package/src/product-shell/worlds/world-routes.js +8 -38
  50. package/src/product-shell/worlds/world-service.js +3 -3
  51. package/src/product-shell/worlds/world-text.js +77 -0
  52. package/src/lib/runtime-guidance.js +0 -457
  53. package/src/openclaw/runtime/world-session-startup.js +0 -1
  54. package/src/product-shell/orchestration/session-orchestrator.js +0 -38
@@ -35,18 +35,13 @@ import {
35
35
  buildWorldSelectionPrompt,
36
36
  buildCandidateDeliverySummary,
37
37
  buildPostSetupWorldDirectory,
38
- buildRequiredFieldExplanation,
39
38
  broadcastWorld,
40
39
  fetchWorldSearch,
41
40
  fetchWorldCandidateFeed,
42
- fetchWorldJoinCheck,
43
41
  fetchWorldDetail,
44
42
  joinWorld,
45
- submitWorldJoin,
46
43
  submitWorldSearch,
47
- resolveWorldJoinFlow,
48
44
  resolveWorldSelection,
49
- resolveWorldProfileCollectionFlow,
50
45
  resolveWorldSelectionFlow,
51
46
  } from '../runtime/product-shell-helper.js';
52
47
  import { getClaworldRuntime } from './runtime.js';
@@ -55,11 +50,6 @@ import {
55
50
  normalizeRuntimeBoundaryError,
56
51
  serializeRuntimeBoundaryError,
57
52
  } from '../../lib/runtime-errors.js';
58
- import {
59
- ACCEPTED_CHAT_KICKOFF_PAYLOAD_KIND,
60
- readAcceptedChatKickoffRuntimeContext,
61
- resolveAcceptedChatKickoffViewer,
62
- } from '../../lib/accepted-chat-kickoff.js';
63
53
 
64
54
  function normalizeRelayHttpBaseUrl(serverUrl) {
65
55
  const parsed = new URL(serverUrl);
@@ -212,13 +202,10 @@ function normalizeClaworldInteger(value, fallback = null) {
212
202
  return Math.trunc(normalized);
213
203
  }
214
204
 
215
- function shouldAuthorizeBridgedCommand({ runtimeConfig = {}, relayEvent, incomingText }) {
205
+ function shouldAuthorizeBridgedCommand({ runtimeConfig = {}, incomingText }) {
216
206
  if (runtimeConfig.testing?.allowBridgedCommandDispatch !== true) {
217
207
  return false;
218
208
  }
219
- if (relayEvent !== 'turn.deliver') {
220
- return false;
221
- }
222
209
  return typeof incomingText === 'string' && incomingText.trim().startsWith('/');
223
210
  }
224
211
 
@@ -227,6 +214,7 @@ const CLAWORLD_RELAY_OPERATIONAL_NOTICE_PATTERNS = [
227
214
  /^🧹\s*Auto-compaction complete(?:\s*\(count \d+\))?\.$/i,
228
215
  /^↪️\s*Model Fallback:/i,
229
216
  /^↪️\s*Model Fallback cleared:/i,
217
+ /^⚠️\s*Agent failed before reply:/i,
230
218
  ];
231
219
 
232
220
  const CLAWORLD_RELAY_OPERATIONAL_SUFFIX_PATTERNS = [
@@ -352,52 +340,6 @@ function resolveContinuationState(turnData = {}) {
352
340
  };
353
341
  }
354
342
 
355
- function resolveBackendGuidanceMessages(payload = {}) {
356
- const guidance = payload?.guidance;
357
- if (!guidance || typeof guidance !== 'object' || Array.isArray(guidance)) return [];
358
- const messages = Array.isArray(guidance.messages) ? guidance.messages : [];
359
- return messages
360
- .map((message, index) => {
361
- const text = normalizeClaworldText(message?.text, null);
362
- if (!text) return null;
363
- return {
364
- text,
365
- contextKey:
366
- normalizeClaworldText(message?.contextKey, null)
367
- || `claworld:backend-guidance:${normalizeClaworldText(message?.kind, 'message')}:${index}`,
368
- };
369
- })
370
- .filter(Boolean);
371
- }
372
-
373
- function enqueueBackendGuidance({
374
- runtime,
375
- sessionKey,
376
- payload,
377
- } = {}) {
378
- if (!runtime?.system?.enqueueSystemEvent || !sessionKey) {
379
- return { skipped: true, reason: 'missing_runtime_or_session', count: 0 };
380
- }
381
-
382
- const messages = resolveBackendGuidanceMessages(payload);
383
- if (messages.length === 0) {
384
- return { skipped: true, reason: 'no_backend_guidance', count: 0 };
385
- }
386
-
387
- for (const message of messages) {
388
- runtime.system.enqueueSystemEvent(message.text, {
389
- sessionKey,
390
- contextKey: message.contextKey,
391
- });
392
- }
393
-
394
- return {
395
- skipped: false,
396
- reason: null,
397
- count: messages.length,
398
- };
399
- }
400
-
401
343
  function buildClaworldDirectoryEntries(config = {}, accountId = null) {
402
344
  const accountIds = listClaworldAccountIds(config);
403
345
  const currentAccountId = String(accountId || '').trim();
@@ -465,7 +407,7 @@ async function deliverRelayMessage({ runtimeConfig, to, text, fetchImpl, logger,
465
407
  conversation: {
466
408
  conversationKey: outboundContext.conversationKey || outboundContext.metadata?.conversationKey || null,
467
409
  worldId: outboundContext.worldId || outboundContext.metadata?.worldId || null,
468
- scope: outboundContext.scope || outboundContext.sessionScope || outboundContext.metadata?.scope || null,
410
+ scope: outboundContext.scope || outboundContext.metadata?.scope || null,
469
411
  conversationId: outboundContext.conversationId || outboundContext.metadata?.conversationId || null,
470
412
  threadId: outboundContext.threadId || outboundContext.metadata?.threadId || null,
471
413
  sessionKey: outboundContext.sessionKey || outboundContext.SessionKey || null,
@@ -474,7 +416,7 @@ async function deliverRelayMessage({ runtimeConfig, to, text, fetchImpl, logger,
474
416
  });
475
417
 
476
418
  if (!result.ok) {
477
- logger.error?.('[claworld:outbound] session request failed', { status: result.status, body: result.body });
419
+ logger.error?.('[claworld:outbound] message delivery failed', { status: result.status, body: result.body });
478
420
  throw createRuntimeBoundaryError({
479
421
  code: 'relay_message_delivery_failed',
480
422
  category: 'transport',
@@ -497,7 +439,7 @@ async function deliverRelayMessage({ runtimeConfig, to, text, fetchImpl, logger,
497
439
  chatId: toAddress,
498
440
  timestamp: Date.now(),
499
441
  meta: {
500
- sessionId: result.body?.session?.sessionId || null,
442
+ sessionKey: result.body?.delivery?.sessionKey || outboundContext.sessionKey || outboundContext.SessionKey || null,
501
443
  turnId: result.body?.turn?.turnId || null,
502
444
  conversationKey: result.body?.conversationKey || null,
503
445
  toAddress,
@@ -669,7 +611,6 @@ async function createChatRequest({
669
611
  targetAgentId,
670
612
  openingMessage = null,
671
613
  worldId = null,
672
- episodePolicy = null,
673
614
  fetchImpl,
674
615
  }) {
675
616
  const normalizedTargetAgentId = normalizeClaworldText(targetAgentId, null);
@@ -697,9 +638,6 @@ async function createChatRequest({
697
638
  targetAgentId: normalizedTargetAgentId,
698
639
  openingMessage: normalizeClaworldText(openingMessage, null),
699
640
  ...(normalizeClaworldText(worldId, null) ? { worldId: normalizeClaworldText(worldId, null) } : {}),
700
- ...(episodePolicy && typeof episodePolicy === 'object' && !Array.isArray(episodePolicy)
701
- ? { episodePolicy }
702
- : {}),
703
641
  }),
704
642
  });
705
643
  if (!result.ok) {
@@ -1283,187 +1221,22 @@ async function ensureRelayBinding({ runtimeConfig, fetchImpl, logger }) {
1283
1221
  });
1284
1222
  }
1285
1223
 
1286
- function resolveSessionCreatedWorldId(event = {}) {
1287
- const session = event?.raw?.data && typeof event.raw.data === 'object' ? event.raw.data : {};
1288
- const metadata = session.metadata && typeof session.metadata === 'object' ? session.metadata : {};
1289
- const candidateWorldId = [
1290
- metadata.worldId,
1291
- metadata.worldContext?.worldId,
1292
- session.worldContext?.worldId,
1293
- session.worldId,
1294
- session.session?.metadata?.worldId,
1295
- session.session?.metadata?.worldContext?.worldId,
1296
- session.session?.worldContext?.worldId,
1297
- session.session?.worldId,
1298
- event?.inboundEnvelope?.metadata?.worldId,
1299
- event?.inboundEnvelope?.metadata?.worldContext?.worldId,
1300
- event?.inboundEnvelope?.metadata?.session?.worldId,
1301
- event?.inboundEnvelope?.metadata?.session?.metadata?.worldId,
1302
- event?.inboundEnvelope?.metadata?.session?.metadata?.worldContext?.worldId,
1303
- ].map((value) => resolveNormalizedText(value, null)).find(Boolean);
1304
- return candidateWorldId || null;
1305
- }
1306
-
1307
- function resolveTurnWorldId(event = {}) {
1308
- const turnData = event?.raw?.data && typeof event.raw.data === 'object' ? event.raw.data : {};
1309
- const metadata = turnData.metadata && typeof turnData.metadata === 'object' ? turnData.metadata : {};
1310
- const candidateWorldId = [
1311
- metadata.worldId,
1312
- metadata.worldContext?.worldId,
1313
- turnData.worldContext?.worldId,
1314
- turnData.worldId,
1315
- turnData.session?.metadata?.worldId,
1316
- turnData.session?.metadata?.worldContext?.worldId,
1317
- turnData.session?.worldContext?.worldId,
1318
- turnData.session?.worldId,
1319
- event?.inboundEnvelope?.metadata?.worldId,
1320
- event?.inboundEnvelope?.metadata?.worldContext?.worldId,
1321
- event?.inboundEnvelope?.metadata?.session?.worldId,
1322
- event?.inboundEnvelope?.metadata?.session?.metadata?.worldId,
1323
- event?.inboundEnvelope?.metadata?.session?.metadata?.worldContext?.worldId,
1324
- ].map((value) => resolveNormalizedText(value, null)).find(Boolean);
1325
- return candidateWorldId || null;
1326
- }
1327
-
1328
- function resolveAcceptedChatKickoffBundle(event = {}) {
1329
- const turnData = event?.raw?.data && typeof event.raw.data === 'object' ? event.raw.data : {};
1330
- if (turnData.acceptedChatKickoff && typeof turnData.acceptedChatKickoff === 'object' && !Array.isArray(turnData.acceptedChatKickoff)) {
1331
- return turnData.acceptedChatKickoff;
1332
- }
1333
- const payload = turnData.payload && typeof turnData.payload === 'object' && !Array.isArray(turnData.payload)
1334
- ? turnData.payload
1224
+ function resolveDeliveryWorldId(delivery = {}) {
1225
+ const metadata = delivery?.metadata && typeof delivery.metadata === 'object' && !Array.isArray(delivery.metadata)
1226
+ ? delivery.metadata
1335
1227
  : {};
1336
- if (payload.kickoffBundle && typeof payload.kickoffBundle === 'object' && !Array.isArray(payload.kickoffBundle)) {
1337
- return payload.kickoffBundle;
1338
- }
1339
- return null;
1228
+ return resolveNormalizedText(metadata.worldId, null) || null;
1340
1229
  }
1341
1230
 
1342
- function resolveAcceptedChatKickoffRuntimeContext(event = {}, { bundle = null, localAgentId = null, fallback = 'recipient' } = {}) {
1343
- const turnData = event?.raw?.data && typeof event.raw.data === 'object' ? event.raw.data : {};
1344
- if (
1345
- turnData.acceptedChatKickoffRuntimeContext
1346
- && typeof turnData.acceptedChatKickoffRuntimeContext === 'object'
1347
- && !Array.isArray(turnData.acceptedChatKickoffRuntimeContext)
1348
- ) {
1349
- return turnData.acceptedChatKickoffRuntimeContext;
1350
- }
1351
- const payload = turnData.payload && typeof turnData.payload === 'object' && !Array.isArray(turnData.payload)
1352
- ? turnData.payload
1353
- : {};
1354
- if (
1355
- payload.acceptedChatKickoffRuntimeContext
1356
- && typeof payload.acceptedChatKickoffRuntimeContext === 'object'
1357
- && !Array.isArray(payload.acceptedChatKickoffRuntimeContext)
1358
- ) {
1359
- return payload.acceptedChatKickoffRuntimeContext;
1360
- }
1361
- if (!bundle) return null;
1362
- return readAcceptedChatKickoffRuntimeContext(bundle, {
1363
- viewer: resolveAcceptedChatKickoffViewer(bundle, {
1364
- localAgentId,
1365
- fallback,
1366
- }),
1367
- });
1368
- }
1369
-
1370
- function buildWorldAwareSessionKey(sessionKey, worldId = null) {
1371
- if (!worldId) return sessionKey;
1372
- return `${sessionKey}:world:${worldId}`;
1373
- }
1374
-
1375
- function buildSessionWorldCacheKey(runtimeAccountId, sessionId) {
1376
- const accountId = resolveNormalizedText(runtimeAccountId, 'default');
1377
- if (!sessionId || !accountId) return null;
1378
- return `${accountId}:${sessionId}`;
1379
- }
1380
-
1381
- function resolveSessionCreatedPeerAgentId(session = {}, localRelayAgentId = null) {
1382
- const agentAId = normalizeClaworldText(session.agentAId, null);
1383
- const agentBId = normalizeClaworldText(session.agentBId, null);
1384
- const localAgentId = normalizeClaworldText(localRelayAgentId, null);
1385
-
1386
- if (localAgentId && agentAId === localAgentId) return agentBId;
1387
- if (localAgentId && agentBId === localAgentId) return agentAId;
1388
- return agentAId || agentBId || null;
1389
- }
1390
-
1391
- async function maybeInjectWorldSessionStartupContext({
1392
- runtime,
1393
- cfg,
1394
- runtimeConfig,
1395
- runtimeAccountId,
1396
- event,
1397
- logger,
1398
- sessionIdToWorldId,
1399
- } = {}) {
1400
- const worldCache = sessionIdToWorldId || null;
1401
- if (!runtime?.system?.enqueueSystemEvent || !runtime?.channel?.routing?.resolveAgentRoute) {
1402
- return { skipped: true, reason: 'missing_runtime_system_or_routing' };
1403
- }
1404
-
1405
- const session = event?.raw?.data && typeof event.raw.data === 'object' ? event.raw.data : {};
1406
- const worldId = resolveSessionCreatedWorldId(event);
1407
- if (!worldId) {
1408
- return { skipped: true, reason: 'not_world_scoped' };
1409
- }
1410
- const sessionLookupKey = buildSessionWorldCacheKey(runtimeAccountId, session.sessionId);
1411
- if (sessionLookupKey && worldCache) {
1412
- worldCache.set(sessionLookupKey, worldId);
1413
- }
1414
-
1415
- const peerAgentId = resolveSessionCreatedPeerAgentId(session, runtimeConfig?.relay?.agentId || null);
1416
- if (!peerAgentId) {
1417
- return { skipped: true, reason: 'peer_agent_unresolved' };
1418
- }
1419
-
1420
- const currentCfg = cfg || await runtime.config?.loadConfig?.() || {};
1421
- const routePeerId = resolveRelayAddress(peerAgentId, runtimeConfig);
1422
- const route = runtime.channel.routing.resolveAgentRoute({
1423
- cfg: currentCfg,
1424
- channel: 'claworld',
1425
- accountId: runtimeConfig.accountId,
1426
- peer: { kind: 'direct', id: routePeerId || peerAgentId },
1427
- }) || {};
1428
- const sessionKey = route.sessionKey || `agent:${route.agentId || runtimeConfig.accountId}:main`;
1429
- const worldSessionKey = buildWorldAwareSessionKey(sessionKey, worldId);
1430
- const enqueueResult = enqueueBackendGuidance({
1431
- runtime,
1432
- sessionKey: worldSessionKey,
1433
- payload: session,
1434
- });
1435
- if (enqueueResult.skipped) {
1436
- return { skipped: true, reason: enqueueResult.reason, worldId, sessionKey: worldSessionKey };
1437
- }
1438
-
1439
- logger.info?.(`[claworld:${runtimeAccountId}] injected backend-authored world startup guidance`, {
1440
- worldId,
1441
- sessionId: session.sessionId || null,
1442
- sessionKey: worldSessionKey,
1443
- routePeerId: routePeerId || peerAgentId,
1444
- guidanceCount: enqueueResult.count,
1445
- });
1446
-
1447
- return {
1448
- skipped: false,
1449
- ok: true,
1450
- worldId,
1451
- sessionKey: worldSessionKey,
1452
- };
1453
- }
1454
-
1455
- function buildRelayInboundEnvelope({
1231
+ function buildDeliveryInboundEnvelope({
1456
1232
  runtime,
1457
1233
  currentCfg,
1458
- runtimeAccountId,
1459
1234
  remoteIdentity,
1460
1235
  incomingText,
1461
1236
  contextText = null,
1462
1237
  commandText = null,
1463
- sessionId,
1464
- turnId,
1465
- relayEvent,
1466
- mode = 'direct',
1238
+ deliveryId,
1239
+ sessionKey,
1467
1240
  worldId = null,
1468
1241
  conversationKey = null,
1469
1242
  }) {
@@ -1477,12 +1250,10 @@ function buildRelayInboundEnvelope({
1477
1250
  const remoteLabel = String(remoteIdentity || 'unknown-peer').trim() || 'unknown-peer';
1478
1251
  const systemLines = [
1479
1252
  `[claworld peer ${remoteLabel}]`,
1480
- `[claworld mode ${mode}]`,
1481
1253
  ...(worldId ? [`[claworld world ${worldId}]`] : []),
1482
1254
  ...(conversationKey ? [`[claworld conversation ${conversationKey}]`] : []),
1483
- `[claworld session ${sessionId}]`,
1484
- `[claworld turn ${turnId}]`,
1485
- `[relay event ${relayEvent}]`,
1255
+ `[claworld session ${sessionKey}]`,
1256
+ `[claworld delivery ${deliveryId}]`,
1486
1257
  ];
1487
1258
  const rawBody = `${bodyText}\n\n${systemLines.join('\n')}`;
1488
1259
  const normalizedCommandText = String(commandText || '').trim();
@@ -1511,24 +1282,22 @@ function buildRelayInboundEnvelope({
1511
1282
  };
1512
1283
  }
1513
1284
 
1514
- function createRelayReplyDispatcher({
1285
+ function createDeliveryReplyDispatcher({
1515
1286
  runtime,
1516
1287
  currentCfg,
1517
- route,
1518
1288
  relayClient,
1519
- sessionId,
1520
- turnId,
1521
- relayEvent,
1522
- localRelayAgentId,
1523
- allowRelayContinuation = true,
1289
+ deliveryId,
1290
+ sessionKey,
1291
+ localAgentId = null,
1292
+ allowReply = true,
1524
1293
  logger,
1525
1294
  runtimeAccountId,
1526
1295
  }) {
1527
1296
  const prefixContext = runtime?.channel?.reply?.createReplyPrefixContext
1528
- ? runtime.channel.reply.createReplyPrefixContext({ cfg: currentCfg, agentId: route.agentId })
1297
+ ? runtime.channel.reply.createReplyPrefixContext({ cfg: currentCfg, agentId: localAgentId || runtimeAccountId })
1529
1298
  : { responsePrefix: '', responsePrefixContextProvider: () => ({}) };
1530
1299
  const humanDelay = runtime?.channel?.reply?.resolveHumanDelayConfig
1531
- ? runtime.channel.reply.resolveHumanDelayConfig(currentCfg, route.agentId)
1300
+ ? runtime.channel.reply.resolveHumanDelayConfig(currentCfg, localAgentId || runtimeAccountId)
1532
1301
  : undefined;
1533
1302
 
1534
1303
  let replied = false;
@@ -1610,33 +1379,16 @@ function createRelayReplyDispatcher({
1610
1379
  const flushReply = async (text) => {
1611
1380
  const normalized = String(text || '').trim();
1612
1381
  if (!normalized || replied || suppressed) return false;
1613
- if (allowRelayContinuation === false) {
1382
+ if (allowReply === false) {
1614
1383
  suppressed = true;
1615
1384
  return false;
1616
1385
  }
1617
- if (relayEvent === 'turn.reply') {
1618
- if (!localRelayAgentId) {
1619
- throw new Error('missing local relay agent id for relay continuation');
1620
- }
1621
- const result = await relayClient.createTurn({
1622
- sessionId,
1623
- fromAgentId: localRelayAgentId,
1624
- payload: {
1625
- text: normalized,
1626
- source: 'openclaw-autochain',
1627
- },
1628
- });
1629
- if (result.status !== 201) {
1630
- throw new Error(`failed to create follow-up relay turn: ${result.status}`);
1631
- }
1632
- } else {
1633
- relayClient.sendTurnReply({
1634
- sessionId,
1635
- messageId: turnId,
1636
- replyText: normalized,
1637
- source: 'openclaw-autochain',
1638
- });
1639
- }
1386
+ relayClient.sendReply({
1387
+ deliveryId,
1388
+ sessionKey,
1389
+ replyText: normalized,
1390
+ source: 'openclaw-autochain',
1391
+ });
1640
1392
  replied = true;
1641
1393
  return true;
1642
1394
  };
@@ -1659,9 +1411,9 @@ function createRelayReplyDispatcher({
1659
1411
  }
1660
1412
  },
1661
1413
  onError: (error, info) => {
1662
- logger.error?.(`[claworld:${runtimeAccountId}] turn bridge dispatch error`, {
1663
- sessionId,
1664
- turnId,
1414
+ logger.error?.(`[claworld:${runtimeAccountId}] delivery bridge dispatch error`, {
1415
+ deliveryId,
1416
+ sessionKey,
1665
1417
  kind: info?.kind || null,
1666
1418
  error: error?.message || String(error),
1667
1419
  });
@@ -1681,9 +1433,8 @@ function createRelayReplyDispatcher({
1681
1433
  runtimeOutputSummary.relayContinuationPreview = continuation.text
1682
1434
  ? previewRuntimeOutputText(continuation.text)
1683
1435
  : null;
1684
- const continuationText = continuation.text;
1685
- if (continuationText) {
1686
- await flushReply(continuationText);
1436
+ if (continuation.text) {
1437
+ await flushReply(continuation.text);
1687
1438
  }
1688
1439
  }
1689
1440
  await dispatchApi.markDispatchIdle?.();
@@ -1737,7 +1488,7 @@ function createRelayReplyDispatcher({
1737
1488
  };
1738
1489
  }
1739
1490
 
1740
- async function maybeBridgeDeliveredTurn({
1491
+ async function maybeBridgeRuntimeDelivery({
1741
1492
  relayClient,
1742
1493
  runtimeConfig,
1743
1494
  runtimeAccountId,
@@ -1746,175 +1497,119 @@ async function maybeBridgeDeliveredTurn({
1746
1497
  runtime,
1747
1498
  cfg,
1748
1499
  inbound,
1749
- sessionIdToWorldId,
1750
1500
  }) {
1751
- const worldCache = sessionIdToWorldId || null;
1752
- const relayEvent = event?.relayEvent || 'turn.deliver';
1753
- const turnData = event?.raw?.data || {};
1754
- const sessionId = turnData.sessionId || event?.inboundEnvelope?.session_id || null;
1755
- const turnId = turnData.turnId || event?.inboundEnvelope?.event_id || null;
1756
- const kickoffBundle = resolveAcceptedChatKickoffBundle(event);
1757
- const payload = turnData.payload && typeof turnData.payload === 'object' && !Array.isArray(turnData.payload)
1758
- ? turnData.payload
1501
+ const delivery = event?.delivery && typeof event.delivery === 'object' && !Array.isArray(event.delivery)
1502
+ ? event.delivery
1759
1503
  : {};
1760
- const localRelayAgentId = runtimeConfig.relay?.agentId || relayClient?.boundAgentId || null;
1761
- const kickoffRuntimeContext = resolveAcceptedChatKickoffRuntimeContext(event, {
1762
- bundle: kickoffBundle,
1763
- localAgentId: localRelayAgentId,
1764
- fallback: relayEvent === 'turn.deliver' ? 'sender' : 'recipient',
1765
- });
1766
- const incomingText = turnData.payload?.text
1767
- || event?.inboundEnvelope?.payload?.text
1768
- || (
1769
- payload.kind === ACCEPTED_CHAT_KICKOFF_PAYLOAD_KIND
1770
- ? kickoffRuntimeContext?.text || ''
1771
- : ''
1772
- );
1773
- const fromAgentId = turnData.fromAgentId || event?.inboundEnvelope?.from_agent_id || null;
1774
- const conversationKey = turnData.conversationKey || null;
1775
- const bridgedCommandText = payload.kind === ACCEPTED_CHAT_KICKOFF_PAYLOAD_KIND
1776
- ? kickoffRuntimeContext?.briefText || kickoffBundle?.request?.brief?.text || incomingText
1777
- : incomingText;
1778
- const kickoffContextText = relayEvent === 'turn.reply'
1779
- && kickoffBundle?.kickoffTurnId
1780
- && kickoffBundle.kickoffTurnId === turnId
1781
- ? kickoffRuntimeContext?.text || null
1782
- : null;
1783
- const senderId = fromAgentId || 'unknown-peer';
1504
+ const metadata = delivery.metadata && typeof delivery.metadata === 'object' && !Array.isArray(delivery.metadata)
1505
+ ? delivery.metadata
1506
+ : {};
1507
+ const payload = delivery.payload && typeof delivery.payload === 'object' && !Array.isArray(delivery.payload)
1508
+ ? delivery.payload
1509
+ : {};
1510
+ const deliveryId = resolveNormalizedText(delivery.deliveryId, null);
1511
+ const sessionKey = resolveNormalizedText(delivery.sessionKey, null);
1512
+ const incomingText = resolveNormalizedText(payload.text, null);
1513
+ const contextText = null;
1514
+ const fromAgentId = resolveNormalizedText(metadata.fromAgentId, null);
1515
+ const remoteAddress = resolveNormalizedText(metadata.fromAddress, null)
1516
+ || resolveRelayAddress(fromAgentId || '', runtimeConfig)
1517
+ || fromAgentId
1518
+ || 'unknown-peer';
1519
+ const remoteRouteIdentity = resolveRelayAddress(fromAgentId || '', runtimeConfig)
1520
+ || remoteAddress;
1521
+
1784
1522
  if (
1785
- !runtime?.channel?.routing?.resolveAgentRoute
1786
- || !runtime?.channel?.reply?.finalizeInboundContext
1523
+ !runtime?.channel?.reply?.finalizeInboundContext
1787
1524
  || !runtime?.channel?.reply?.dispatchReplyFromConfig
1788
1525
  || !runtime?.channel?.reply?.createReplyDispatcherWithTyping
1789
1526
  ) {
1790
- logger.warn?.(`[claworld:${runtimeAccountId}] skipping relay bridge: missing runtime bridge hooks`, {
1791
- relayEvent,
1792
- sessionId,
1793
- turnId,
1527
+ logger.warn?.(`[claworld:${runtimeAccountId}] skipping delivery bridge: missing runtime bridge hooks`, {
1528
+ deliveryId,
1529
+ sessionKey,
1794
1530
  });
1795
1531
  return { skipped: true, reason: 'missing_runtime_bridge_hooks' };
1796
1532
  }
1797
- if (!sessionId || !turnId || !incomingText) {
1798
- logger.warn?.(`[claworld:${runtimeAccountId}] skipping relay bridge: missing turn payload`, {
1799
- relayEvent,
1800
- sessionId,
1801
- turnId,
1533
+ if (!deliveryId || !sessionKey || !incomingText) {
1534
+ logger.warn?.(`[claworld:${runtimeAccountId}] skipping delivery bridge: missing delivery payload`, {
1535
+ deliveryId,
1536
+ sessionKey,
1802
1537
  hasIncomingText: Boolean(incomingText),
1803
1538
  });
1804
- return { skipped: true, reason: 'missing_turn_payload' };
1539
+ return { skipped: true, reason: 'missing_delivery_payload' };
1805
1540
  }
1806
1541
 
1807
1542
  const currentCfg = cfg || await runtime.config?.loadConfig?.() || {};
1808
- const localAddress = resolveRelayAddress(runtimeConfig.accountId || '', runtimeConfig);
1809
- const remoteAddress = resolveRelayAddress(senderId, runtimeConfig);
1810
- const routePeerId = remoteAddress || senderId;
1811
- const worldId = resolveTurnWorldId(event);
1812
- const sessionLookupKey = buildSessionWorldCacheKey(runtimeAccountId, sessionId);
1813
- const resolvedWorldId = worldId || (sessionLookupKey ? worldCache?.get(sessionLookupKey) : null);
1814
- if (sessionLookupKey && resolvedWorldId && worldCache) {
1815
- worldCache.set(sessionLookupKey, resolvedWorldId);
1816
- }
1817
- // Gateway reply dispatch stays on the dedicated `claworld` channel surface.
1818
- // Accept may have been reviewed from another main-agent channel, but live
1819
- // continuation/generation cannot hop across channels mid-session.
1820
- const route = runtime.channel.routing.resolveAgentRoute({
1821
- cfg: currentCfg,
1822
- channel: 'claworld',
1823
- accountId: runtimeConfig.accountId,
1824
- peer: { kind: 'direct', id: routePeerId },
1825
- }) || {};
1826
- const routed = inbound?.routeInboundEvent?.(event?.inboundEnvelope || {}, {
1543
+ const routed = inbound?.routeInboundEvent?.(delivery, {
1827
1544
  sessionTarget: runtimeConfig.routing?.sessionTarget,
1828
1545
  fallbackTarget: runtimeConfig.routing?.fallbackTarget,
1829
- route,
1830
1546
  }) || null;
1831
-
1832
- const sessionKey = route.sessionKey || `agent:${route.agentId || runtimeConfig.accountId}:main`;
1833
- const worldSessionKey = buildWorldAwareSessionKey(sessionKey, resolvedWorldId);
1547
+ const worldId = resolveDeliveryWorldId(delivery);
1834
1548
  const commandAuthorized = shouldAuthorizeBridgedCommand({
1835
1549
  runtimeConfig,
1836
- relayEvent,
1837
- incomingText: bridgedCommandText,
1550
+ incomingText,
1838
1551
  });
1839
- const { Body, RawBody, CommandBody, ContextLines } = buildRelayInboundEnvelope({
1552
+ const { Body, RawBody, CommandBody, ContextLines } = buildDeliveryInboundEnvelope({
1840
1553
  runtime,
1841
1554
  currentCfg,
1842
- runtimeAccountId,
1843
- remoteIdentity: routePeerId,
1555
+ remoteIdentity: remoteAddress,
1844
1556
  incomingText,
1845
- contextText: kickoffContextText,
1846
- commandText: bridgedCommandText,
1847
- sessionId,
1848
- turnId,
1849
- relayEvent,
1850
- mode: resolvedWorldId ? 'world' : 'direct',
1851
- worldId: resolvedWorldId,
1852
- conversationKey,
1557
+ contextText,
1558
+ commandText: incomingText,
1559
+ deliveryId,
1560
+ sessionKey,
1561
+ worldId,
1562
+ conversationKey: metadata.conversationKey || null,
1853
1563
  });
1564
+ const localAddress = resolveRelayAddress(runtimeConfig.accountId || '', runtimeConfig);
1854
1565
  const inboundCtx = runtime.channel.reply.finalizeInboundContext({
1855
1566
  Body,
1856
1567
  RawBody,
1857
1568
  CommandBody,
1858
1569
  BodyForAgent: RawBody,
1859
1570
  BodyForCommands: CommandBody,
1860
- From: routePeerId ? `claworld:${routePeerId}` : `claworld:${senderId}`,
1571
+ From: `claworld:${remoteRouteIdentity}`,
1861
1572
  To: localAddress ? `claworld:${localAddress}` : `claworld:${runtimeConfig.accountId}`,
1862
- SessionKey: worldSessionKey,
1573
+ SessionKey: sessionKey,
1863
1574
  AccountId: runtimeConfig.accountId,
1864
1575
  OriginatingChannel: 'claworld',
1865
- OriginatingFrom: routePeerId || senderId,
1866
- // Match OpenClaw DM channel semantics: `To` is the local account surface,
1867
- // while `OriginatingTo` is the remote peer to reply back to.
1868
- OriginatingTo: routePeerId || localAddress || runtimeConfig.accountId,
1576
+ OriginatingFrom: remoteRouteIdentity,
1577
+ OriginatingTo: remoteRouteIdentity,
1869
1578
  ChatType: 'direct',
1870
- SenderName: routePeerId || senderId,
1871
- SenderId: routePeerId || senderId,
1872
- MessageId: turnId,
1579
+ SenderName: remoteAddress,
1580
+ SenderId: remoteRouteIdentity,
1581
+ MessageId: deliveryId,
1873
1582
  Provider: 'claworld',
1874
1583
  Surface: 'claworld',
1875
- ConversationLabel: routePeerId || senderId,
1584
+ ConversationLabel: remoteAddress,
1876
1585
  Timestamp: Date.now(),
1877
- MessageSid: turnId,
1586
+ MessageSid: deliveryId,
1878
1587
  WasMentioned: false,
1879
1588
  CommandAuthorized: commandAuthorized,
1880
- RelaySessionId: sessionId,
1881
- RelayTurnId: turnId,
1589
+ RelayDeliveryId: deliveryId,
1882
1590
  RelayFromAgentId: fromAgentId,
1883
1591
  UntrustedContext: ContextLines,
1884
1592
  });
1885
1593
 
1886
- enqueueBackendGuidance({
1887
- runtime,
1888
- sessionKey: worldSessionKey,
1889
- payload: turnData,
1890
- });
1891
-
1892
- logger.info?.(`[claworld:${runtimeAccountId}] bridging ${relayEvent} into agent session`, {
1893
- sessionId,
1894
- turnId,
1895
- routePeerId,
1896
- routeSessionKey: worldSessionKey,
1594
+ logger.info?.(`[claworld:${runtimeAccountId}] routing delivery into runtime session`, {
1595
+ deliveryId,
1596
+ sessionKey,
1597
+ remoteIdentity: remoteAddress,
1897
1598
  routeStatus: routed?.status || null,
1898
1599
  bodyPreview: String(Body || '').slice(0, 240),
1899
1600
  rawBodyPreview: String(RawBody || '').slice(0, 240),
1900
- inboundAccountId: inboundCtx?.AccountId || null,
1901
- inboundTo: inboundCtx?.To || null,
1902
- inboundFrom: inboundCtx?.From || null,
1903
- originatingTo: inboundCtx?.OriginatingTo || null,
1904
- originatingFrom: inboundCtx?.OriginatingFrom || null,
1601
+ allowReply: metadata.allowReply !== false,
1905
1602
  commandAuthorized,
1906
1603
  });
1907
1604
 
1908
- const { dispatcher, replyOptions, markDispatchIdle, didReply, getRuntimeOutputSummary } = createRelayReplyDispatcher({
1605
+ const { dispatcher, replyOptions, markDispatchIdle, didReply, getRuntimeOutputSummary } = createDeliveryReplyDispatcher({
1909
1606
  runtime,
1910
1607
  currentCfg,
1911
- route,
1912
1608
  relayClient,
1913
- sessionId,
1914
- turnId,
1915
- relayEvent,
1916
- localRelayAgentId,
1917
- allowRelayContinuation: resolveContinuationState(turnData).allowed !== false,
1609
+ deliveryId,
1610
+ sessionKey,
1611
+ localAgentId: runtimeConfig.relay?.agentId || relayClient?.boundAgentId || null,
1612
+ allowReply: metadata.allowReply !== false,
1918
1613
  logger,
1919
1614
  runtimeAccountId,
1920
1615
  });
@@ -1928,13 +1623,11 @@ async function maybeBridgeDeliveredTurn({
1928
1623
  const replied = didReply();
1929
1624
  const runtimeOutputSummary = getRuntimeOutputSummary();
1930
1625
 
1931
- logger.info?.(`[claworld:${runtimeAccountId}] relay message bridge completed`, {
1932
- sessionId,
1933
- turnId,
1934
- relayEvent,
1626
+ logger.info?.(`[claworld:${runtimeAccountId}] delivery bridge completed`, {
1627
+ deliveryId,
1628
+ sessionKey,
1935
1629
  queuedFinal: Boolean(dispatchResult?.queuedFinal),
1936
1630
  replied,
1937
- routeSessionKey: worldSessionKey,
1938
1631
  routeStatus: routed?.status || null,
1939
1632
  runtimeOutputSummary,
1940
1633
  });
@@ -1944,7 +1637,7 @@ async function maybeBridgeDeliveredTurn({
1944
1637
  ok: true,
1945
1638
  replied,
1946
1639
  queuedFinal: Boolean(dispatchResult?.queuedFinal),
1947
- routeSessionKey: worldSessionKey,
1640
+ sessionKey,
1948
1641
  routeStatus: routed?.status || null,
1949
1642
  };
1950
1643
  }
@@ -1962,7 +1655,6 @@ export function createClaworldChannelPlugin({
1962
1655
  const relayClients = new Map();
1963
1656
  const lifecycles = new Map();
1964
1657
  const accountRuntimeContexts = new Map();
1965
- const sessionIdToWorldId = new Map();
1966
1658
 
1967
1659
  async function persistRuntimeAppToken({ runtime, accountId, appToken }) {
1968
1660
  if (!runtime?.config?.loadConfig || !runtime?.config?.writeConfigFile) {
@@ -2028,16 +1720,6 @@ export function createClaworldChannelPlugin({
2028
1720
  };
2029
1721
  }
2030
1722
 
2031
- function clearSessionWorldCache(runtimeAccountId = 'default') {
2032
- const accountId = resolveNormalizedText(runtimeAccountId, 'default');
2033
- const prefix = `${accountId}:`;
2034
- Array.from(sessionIdToWorldId.keys()).forEach((cacheKey) => {
2035
- if (cacheKey.startsWith(prefix)) {
2036
- sessionIdToWorldId.delete(cacheKey);
2037
- }
2038
- });
2039
- }
2040
-
2041
1723
  function getAccountLifecycle(accountKey = 'default') {
2042
1724
  if (lifecycles.has(accountKey)) return lifecycles.get(accountKey);
2043
1725
 
@@ -2189,31 +1871,15 @@ export function createClaworldChannelPlugin({
2189
1871
  });
2190
1872
  relayClient.on?.('runtime_event', (event) => {
2191
1873
  logger.debug?.(`[claworld:${runtimeAccountId}] inbound relay event`, {
2192
- relayEvent: event?.relayEvent,
1874
+ eventType: event?.eventType || null,
2193
1875
  target: event?.route?.target || null,
2194
- sessionId: event?.inboundEnvelope?.session_id || null,
1876
+ deliveryId: event?.delivery?.deliveryId || null,
1877
+ sessionKey: event?.delivery?.sessionKey || null,
2195
1878
  });
2196
1879
 
2197
- if (event?.relayEvent === 'session.created') {
1880
+ if (event?.eventType === 'delivery') {
2198
1881
  const runtimeContext = accountRuntimeContexts.get(accountKey) || {};
2199
- maybeInjectWorldSessionStartupContext({
2200
- runtime: runtimeContext.runtime,
2201
- cfg: runtimeContext.cfg,
2202
- runtimeConfig,
2203
- runtimeAccountId,
2204
- event,
2205
- logger,
2206
- sessionIdToWorldId,
2207
- }).catch((error) => {
2208
- logger.error?.(`[claworld:${runtimeAccountId}] world startup injection exception`, {
2209
- error: error?.message || String(error),
2210
- });
2211
- });
2212
- }
2213
-
2214
- if (event?.relayEvent === 'turn.deliver') {
2215
- const runtimeContext = accountRuntimeContexts.get(accountKey) || {};
2216
- maybeBridgeDeliveredTurn({
1882
+ maybeBridgeRuntimeDelivery({
2217
1883
  relayClient,
2218
1884
  runtimeConfig,
2219
1885
  runtimeAccountId,
@@ -2222,28 +1888,8 @@ export function createClaworldChannelPlugin({
2222
1888
  runtime: runtimeContext.runtime,
2223
1889
  cfg: runtimeContext.cfg,
2224
1890
  inbound,
2225
- sessionIdToWorldId,
2226
1891
  }).catch((error) => {
2227
- logger.error?.(`[claworld:${runtimeAccountId}] turn bridge exception`, {
2228
- error: error?.message || String(error),
2229
- });
2230
- });
2231
- }
2232
-
2233
- if (event?.relayEvent === 'turn.reply') {
2234
- const runtimeContext = accountRuntimeContexts.get(accountKey) || {};
2235
- maybeBridgeDeliveredTurn({
2236
- relayClient,
2237
- runtimeConfig,
2238
- runtimeAccountId,
2239
- event,
2240
- logger,
2241
- runtime: runtimeContext.runtime,
2242
- cfg: runtimeContext.cfg,
2243
- inbound,
2244
- sessionIdToWorldId,
2245
- }).catch((error) => {
2246
- logger.error?.(`[claworld:${runtimeAccountId}] reply bridge exception`, {
1892
+ logger.error?.(`[claworld:${runtimeAccountId}] delivery bridge exception`, {
2247
1893
  error: error?.message || String(error),
2248
1894
  });
2249
1895
  });
@@ -2274,7 +1920,6 @@ export function createClaworldChannelPlugin({
2274
1920
  relayClients.delete(accountKey);
2275
1921
  }
2276
1922
  accountRuntimeContexts.delete(accountKey);
2277
- clearSessionWorldCache(accountKey);
2278
1923
  },
2279
1924
  });
2280
1925
 
@@ -2492,14 +2137,13 @@ export function createClaworldChannelPlugin({
2492
2137
  },
2493
2138
  inbound: {
2494
2139
  routeRelayEvent: (event = {}, options = {}) => {
2495
- const envelope = {
2496
- session_id: event.session_id || event.sessionId || null,
2497
- event_id: event.event_id || event.eventId || null,
2498
- from_agent_id: event.from_agent_id || event.fromAgentId || null,
2499
- type: event.type || 'message',
2140
+ return inbound.routeInboundEvent({
2141
+ eventType: event.eventType || event.type || 'delivery',
2142
+ deliveryId: event.deliveryId || event.event_id || event.eventId || null,
2143
+ sessionKey: event.sessionKey || null,
2500
2144
  payload: event.payload || {},
2501
- };
2502
- return inbound.routeInboundEvent(envelope, options);
2145
+ metadata: event.metadata || {},
2146
+ }, options);
2503
2147
  },
2504
2148
  },
2505
2149
  outbound: {
@@ -2583,7 +2227,6 @@ export function createClaworldChannelPlugin({
2583
2227
  targetAgentId: context.targetAgentId || null,
2584
2228
  openingMessage: context.openingMessage || context.message || context.text || null,
2585
2229
  worldId: context.worldId || null,
2586
- episodePolicy: context.episodePolicy || null,
2587
2230
  fetchImpl,
2588
2231
  });
2589
2232
  },
@@ -2631,19 +2274,6 @@ export function createClaworldChannelPlugin({
2631
2274
  logger,
2632
2275
  });
2633
2276
  },
2634
- fetchWorldJoinCheck: async (context = {}) => {
2635
- const resolvedContext = await resolveBoundRuntimeContext(context);
2636
- return fetchWorldJoinCheck({
2637
- cfg: resolvedContext.cfg || {},
2638
- accountId: resolvedContext.accountId || null,
2639
- runtimeConfig: resolvedContext.runtimeConfig || null,
2640
- worldId: context.worldId || null,
2641
- profile: context.profile || {},
2642
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? null,
2643
- fetchImpl,
2644
- logger,
2645
- });
2646
- },
2647
2277
  joinWorld: async (context = {}) => {
2648
2278
  const resolvedContext = await resolveBoundRuntimeContext(context);
2649
2279
  return joinWorld({
@@ -2652,25 +2282,7 @@ export function createClaworldChannelPlugin({
2652
2282
  runtimeConfig: resolvedContext.runtimeConfig || null,
2653
2283
  worldId: context.worldId || null,
2654
2284
  agentId: resolvedContext.agentId || null,
2655
- profile: context.profile || {},
2656
- profileSnapshot: context.profileSnapshot ?? null,
2657
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? null,
2658
- fetchImpl,
2659
- logger,
2660
- });
2661
- },
2662
- submitWorldJoin: async (context = {}) => {
2663
- const resolvedContext = await resolveBoundRuntimeContext(context);
2664
- return submitWorldJoin({
2665
- cfg: resolvedContext.cfg || {},
2666
- accountId: resolvedContext.accountId || null,
2667
- runtimeConfig: resolvedContext.runtimeConfig || null,
2668
- worldId: context.worldId || null,
2669
- agentId: resolvedContext.agentId || null,
2670
- profile: context.profile || {},
2671
- profileSnapshot: context.profileSnapshot ?? null,
2672
- profileUpdate: context.profileUpdate ?? context.profilePatch ?? null,
2673
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? 1,
2285
+ participantContextText: context.participantContextText || null,
2674
2286
  fetchImpl,
2675
2287
  logger,
2676
2288
  });
@@ -2721,39 +2333,6 @@ export function createClaworldChannelPlugin({
2721
2333
  context.selection ?? context.userChoice ?? null,
2722
2334
  ),
2723
2335
  buildCandidateDeliverySummary,
2724
- buildRequiredFieldExplanation,
2725
- resolveWorldProfileCollectionFlow: async (context = {}) => {
2726
- const resolvedContext = await resolveBoundRuntimeContext(context);
2727
- return resolveWorldProfileCollectionFlow({
2728
- cfg: resolvedContext.cfg || {},
2729
- accountId: resolvedContext.accountId || null,
2730
- runtimeConfig: resolvedContext.runtimeConfig || null,
2731
- worldId: context.worldId || null,
2732
- worldDetail: context.worldDetail || null,
2733
- profile: context.profile || {},
2734
- profileUpdate: context.profileUpdate ?? context.profilePatch ?? null,
2735
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? 1,
2736
- fetchImpl,
2737
- logger,
2738
- });
2739
- },
2740
- resolveWorldJoinFlow: async (context = {}) => {
2741
- const resolvedContext = await resolveBoundRuntimeContext(context);
2742
- return resolveWorldJoinFlow({
2743
- cfg: resolvedContext.cfg || {},
2744
- accountId: resolvedContext.accountId || null,
2745
- runtimeConfig: resolvedContext.runtimeConfig || null,
2746
- worldId: context.worldId || null,
2747
- worldDetail: context.worldDetail || null,
2748
- agentId: resolvedContext.agentId || null,
2749
- profile: context.profile || {},
2750
- profileSnapshot: context.profileSnapshot ?? null,
2751
- profileUpdate: context.profileUpdate ?? context.profilePatch ?? null,
2752
- limit: context.limit ?? context.candidateLimit ?? null,
2753
- fetchImpl,
2754
- logger,
2755
- });
2756
- },
2757
2336
  resolveWorldSelectionFlow: async (context = {}) => {
2758
2337
  const resolvedContext = await resolveBoundRuntimeContext(context);
2759
2338
  return resolveWorldSelectionFlow({
@@ -2763,7 +2342,6 @@ export function createClaworldChannelPlugin({
2763
2342
  worldDirectory: context.worldDirectory || null,
2764
2343
  selection: context.selection ?? context.userChoice ?? null,
2765
2344
  profile: context.profile || {},
2766
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? 1,
2767
2345
  fetchImpl,
2768
2346
  logger,
2769
2347
  });
@@ -2777,17 +2355,8 @@ export function createClaworldChannelPlugin({
2777
2355
  accountId: resolvedContext.accountId || null,
2778
2356
  runtimeConfig: resolvedContext.runtimeConfig || null,
2779
2357
  agentId: resolvedContext.agentId || null,
2780
- adminAgentIds: context.adminAgentIds || [],
2781
- eligibility: context.eligibility || 'active',
2782
- ...(Object.prototype.hasOwnProperty.call(context, 'broadcast') ? { broadcast: context.broadcast } : {}),
2783
2358
  displayName: context.displayName || null,
2784
- summary: context.summary || null,
2785
- description: context.description || null,
2786
- entryProfileSchema: context.entryProfileSchema || {},
2787
- sessionTemplate: context.sessionTemplate || null,
2788
- interactionRules: context.interactionRules || null,
2789
- prohibitedRules: context.prohibitedRules || null,
2790
- ratingRules: context.ratingRules || null,
2359
+ worldContextText: context.worldContextText || null,
2791
2360
  enabled: context.enabled === true,
2792
2361
  fetchImpl,
2793
2362
  logger,
@@ -2854,19 +2423,6 @@ export function createClaworldChannelPlugin({
2854
2423
  logger,
2855
2424
  });
2856
2425
  },
2857
- fetchWorldJoinCheck: async (context = {}) => {
2858
- const resolvedContext = await resolveBoundRuntimeContext(context);
2859
- return fetchWorldJoinCheck({
2860
- cfg: resolvedContext.cfg || {},
2861
- accountId: resolvedContext.accountId || null,
2862
- runtimeConfig: resolvedContext.runtimeConfig || null,
2863
- worldId: context.worldId || null,
2864
- profile: context.profile || {},
2865
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? null,
2866
- fetchImpl,
2867
- logger,
2868
- });
2869
- },
2870
2426
  joinWorld: async (context = {}) => {
2871
2427
  const resolvedContext = await resolveBoundRuntimeContext(context);
2872
2428
  return joinWorld({
@@ -2875,25 +2431,7 @@ export function createClaworldChannelPlugin({
2875
2431
  runtimeConfig: resolvedContext.runtimeConfig || null,
2876
2432
  worldId: context.worldId || null,
2877
2433
  agentId: resolvedContext.agentId || null,
2878
- profile: context.profile || {},
2879
- profileSnapshot: context.profileSnapshot ?? null,
2880
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? null,
2881
- fetchImpl,
2882
- logger,
2883
- });
2884
- },
2885
- submitWorldJoin: async (context = {}) => {
2886
- const resolvedContext = await resolveBoundRuntimeContext(context);
2887
- return submitWorldJoin({
2888
- cfg: resolvedContext.cfg || {},
2889
- accountId: resolvedContext.accountId || null,
2890
- runtimeConfig: resolvedContext.runtimeConfig || null,
2891
- worldId: context.worldId || null,
2892
- agentId: resolvedContext.agentId || null,
2893
- profile: context.profile || {},
2894
- profileSnapshot: context.profileSnapshot ?? null,
2895
- profileUpdate: context.profileUpdate ?? context.profilePatch ?? null,
2896
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? 1,
2434
+ participantContextText: context.participantContextText || null,
2897
2435
  fetchImpl,
2898
2436
  logger,
2899
2437
  });
@@ -2959,39 +2497,6 @@ export function createClaworldChannelPlugin({
2959
2497
  },
2960
2498
  resolveWorldSelection,
2961
2499
  buildCandidateDeliverySummary,
2962
- buildRequiredFieldExplanation,
2963
- resolveWorldProfileCollectionFlow: async (context = {}) => {
2964
- const resolvedContext = await resolveBoundRuntimeContext(context);
2965
- return resolveWorldProfileCollectionFlow({
2966
- cfg: resolvedContext.cfg || {},
2967
- accountId: resolvedContext.accountId || null,
2968
- runtimeConfig: resolvedContext.runtimeConfig || null,
2969
- worldId: context.worldId || null,
2970
- worldDetail: context.worldDetail || null,
2971
- profile: context.profile || {},
2972
- profileUpdate: context.profileUpdate ?? context.profilePatch ?? null,
2973
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? 1,
2974
- fetchImpl,
2975
- logger,
2976
- });
2977
- },
2978
- resolveWorldJoinFlow: async (context = {}) => {
2979
- const resolvedContext = await resolveBoundRuntimeContext(context);
2980
- return resolveWorldJoinFlow({
2981
- cfg: resolvedContext.cfg || {},
2982
- accountId: resolvedContext.accountId || null,
2983
- runtimeConfig: resolvedContext.runtimeConfig || null,
2984
- worldId: context.worldId || null,
2985
- worldDetail: context.worldDetail || null,
2986
- agentId: resolvedContext.agentId || null,
2987
- profile: context.profile || {},
2988
- profileSnapshot: context.profileSnapshot ?? null,
2989
- profileUpdate: context.profileUpdate ?? context.profilePatch ?? null,
2990
- limit: context.limit ?? context.candidateLimit ?? null,
2991
- fetchImpl,
2992
- logger,
2993
- });
2994
- },
2995
2500
  resolveWorldSelectionFlow: async (context = {}) => {
2996
2501
  const resolvedContext = await resolveBoundRuntimeContext(context);
2997
2502
  return resolveWorldSelectionFlow({
@@ -3001,7 +2506,6 @@ export function createClaworldChannelPlugin({
3001
2506
  worldDirectory: context.worldDirectory || null,
3002
2507
  selection: context.selection ?? context.userChoice ?? null,
3003
2508
  profile: context.profile || {},
3004
- maxFieldsPerStep: context.maxFieldsPerStep ?? context.maxPromptFields ?? 1,
3005
2509
  fetchImpl,
3006
2510
  logger,
3007
2511
  });
@@ -3034,23 +2538,14 @@ export function createClaworldChannelPlugin({
3034
2538
  moderation: {
3035
2539
  createWorld: async (context = {}) => {
3036
2540
  const resolvedContext = await resolveBoundRuntimeContext(context);
3037
- return createModeratedWorld({
2541
+ return createModeratedWorld({
3038
2542
  cfg: resolvedContext.cfg || {},
3039
2543
  accountId: resolvedContext.accountId || null,
3040
2544
  runtimeConfig: resolvedContext.runtimeConfig || null,
3041
2545
  agentId: resolvedContext.agentId || null,
3042
- adminAgentIds: context.adminAgentIds || [],
3043
- eligibility: context.eligibility || 'active',
3044
- ...(Object.prototype.hasOwnProperty.call(context, 'broadcast') ? { broadcast: context.broadcast } : {}),
3045
2546
  displayName: context.displayName || null,
3046
- summary: context.summary || null,
3047
- description: context.description || null,
3048
- entryProfileSchema: context.entryProfileSchema || {},
3049
- sessionTemplate: context.sessionTemplate || null,
3050
- interactionRules: context.interactionRules || null,
3051
- prohibitedRules: context.prohibitedRules || null,
3052
- ratingRules: context.ratingRules || null,
3053
- enabled: context.enabled === true,
2547
+ worldContextText: context.worldContextText || null,
2548
+ enabled: context.enabled === true,
3054
2549
  fetchImpl,
3055
2550
  logger,
3056
2551
  });
@@ -3120,7 +2615,7 @@ export function createClaworldChannelPlugin({
3120
2615
  'native channel setup/onboarding',
3121
2616
  'relay websocket adapter tests',
3122
2617
  'manual relay-agent binding',
3123
- 'minimal outbound session-request send',
2618
+ 'minimal outbound conversation send',
3124
2619
  ],
3125
2620
  notImplemented: [
3126
2621
  '真实 OpenClaw sdk import/types 对齐',