@xfxstudio/claworld 2026.6.10-testing.2 → 2026.6.10-testing.4

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.
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "name": "Claworld Persona Relay",
19
19
  "description": "Claworld relay world channel plugin for OpenClaw.",
20
- "version": "2026.6.10-testing.2",
20
+ "version": "2026.6.10-testing.4",
21
21
  "configSchema": {
22
22
  "type": "object",
23
23
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfxstudio/claworld",
3
- "version": "2026.6.10-testing.2",
3
+ "version": "2026.6.10-testing.4",
4
4
  "description": "Claworld channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -984,10 +984,18 @@ function buildStateLabel(status, { peerName = null, peerOnline = null } = {}) {
984
984
  return peerName ? `Conversation with ${peerName}` : 'Claworld conversation';
985
985
  }
986
986
 
987
- function resolveSnapshotStatus({ request = null, chat = null, conversation = null } = {}) {
987
+ function resolveSnapshotStatus({
988
+ request = null,
989
+ chat = null,
990
+ conversation = null,
991
+ fallbackStatus = null,
992
+ } = {}) {
988
993
  const conversationStatus = normalizeText(conversation?.status, null);
989
994
  if (conversationStatus === 'closed') return 'ended';
990
- return normalizeText(chat?.status, normalizeText(request?.status, conversationStatus || 'pending'));
995
+ return normalizeText(
996
+ chat?.status,
997
+ normalizeText(request?.status, normalizeText(conversationStatus, normalizeText(fallbackStatus, 'pending'))),
998
+ );
991
999
  }
992
1000
 
993
1001
  function collectTurns(turnsPayload = {}) {
@@ -1028,42 +1036,47 @@ export async function loadConversationViewerSnapshot({
1028
1036
  const fetchedAt = new Date().toISOString();
1029
1037
  const diagnostics = [];
1030
1038
  const viewerAgentId = normalizeText(manifest.viewerAgentId, runtimeConfig?.relay?.agentId || null);
1031
- const inboxQuery = queryString({
1032
- agentId: viewerAgentId,
1033
- chatRequestId: manifest.chatRequestId,
1034
- conversationKey: manifest.conversationKey,
1035
- localSessionKey: manifest.localSessionKey,
1036
- });
1037
- let inboxResult = await fetchBackendJson(fetchImpl, runtimeConfig, `/v1/chat-requests${inboxQuery}`, { timeoutMs });
1038
- if (!inboxResult.ok && inboxQuery) {
1039
- diagnostics.push({
1040
- source: 'chat_requests_filtered',
1041
- status: inboxResult.status,
1042
- error: inboxResult.error || null,
1043
- path: inboxResult.path || null,
1039
+ let inbox = {};
1040
+ let request = null;
1041
+ let chat = null;
1042
+ let conversationKey = normalizeText(manifest.conversationKey, null);
1043
+ if (!conversationKey) {
1044
+ const inboxQuery = queryString({
1045
+ agentId: viewerAgentId,
1046
+ chatRequestId: manifest.chatRequestId,
1047
+ localSessionKey: manifest.localSessionKey,
1044
1048
  });
1045
- const fallbackQuery = queryString({ agentId: viewerAgentId });
1046
- inboxResult = await fetchBackendJson(fetchImpl, runtimeConfig, `/v1/chat-requests${fallbackQuery}`, { timeoutMs });
1047
- }
1048
- if (!inboxResult.ok) {
1049
- return {
1050
- ok: false,
1051
- error: 'chat_inbox_snapshot_failed',
1052
- status: inboxResult.status,
1053
- message: inboxResult.error || null,
1054
- fetchedAt,
1055
- viewer: buildPublicConversationViewer(manifest),
1056
- body: inboxResult.body,
1057
- diagnostics,
1058
- };
1049
+ let inboxResult = await fetchBackendJson(fetchImpl, runtimeConfig, `/v1/chat-requests${inboxQuery}`, { timeoutMs });
1050
+ if (!inboxResult.ok && inboxQuery) {
1051
+ diagnostics.push({
1052
+ source: 'chat_requests_filtered',
1053
+ status: inboxResult.status,
1054
+ error: inboxResult.error || null,
1055
+ path: inboxResult.path || null,
1056
+ });
1057
+ const fallbackQuery = queryString({ agentId: viewerAgentId });
1058
+ inboxResult = await fetchBackendJson(fetchImpl, runtimeConfig, `/v1/chat-requests${fallbackQuery}`, { timeoutMs });
1059
+ }
1060
+ if (!inboxResult.ok) {
1061
+ return {
1062
+ ok: false,
1063
+ error: 'chat_inbox_snapshot_failed',
1064
+ status: inboxResult.status,
1065
+ message: inboxResult.error || null,
1066
+ fetchedAt,
1067
+ viewer: buildPublicConversationViewer(manifest),
1068
+ body: inboxResult.body,
1069
+ diagnostics,
1070
+ };
1071
+ }
1072
+ inbox = normalizeObject(inboxResult.body, {});
1073
+ request = resolveSnapshotRequest(inbox, manifest);
1074
+ chat = resolveSnapshotChat(inbox, manifest);
1075
+ conversationKey = normalizeText(
1076
+ chat?.conversationKey,
1077
+ normalizeText(request?.kickoff?.conversationKey, null),
1078
+ );
1059
1079
  }
1060
- const inbox = normalizeObject(inboxResult.body, {});
1061
- const request = resolveSnapshotRequest(inbox, manifest);
1062
- const chat = resolveSnapshotChat(inbox, manifest);
1063
- const conversationKey = normalizeText(
1064
- chat?.conversationKey,
1065
- normalizeText(manifest.conversationKey, normalizeText(request?.kickoff?.conversationKey, null)),
1066
- );
1067
1080
  let activeManifest = manifest;
1068
1081
  if (conversationKey) {
1069
1082
  activeManifest = await maybeUpdateManifestFromSnapshot(manifest, {
@@ -1110,7 +1123,12 @@ export async function loadConversationViewerSnapshot({
1110
1123
  || normalizeObject(request?.counterparty, null)
1111
1124
  || null;
1112
1125
  const peerName = normalizeText(peer?.displayName, normalizeText(activeManifest.counterpartyName, 'Peer agent'));
1113
- const status = resolveSnapshotStatus({ request, chat, conversation });
1126
+ const status = resolveSnapshotStatus({
1127
+ request,
1128
+ chat,
1129
+ conversation,
1130
+ fallbackStatus: activeManifest.targetStatus,
1131
+ });
1114
1132
  const worldName = normalizeText(chat?.conversation?.world?.displayName, normalizeText(request?.conversation?.world?.displayName, null));
1115
1133
  return {
1116
1134
  ok: true,
@@ -159,6 +159,12 @@ export function buildPublicToolErrorExtras(error) {
159
159
  }
160
160
 
161
161
  export async function loadCurrentConfig(api) {
162
+ if (api?.config && typeof api.config.current === 'function') {
163
+ return api.config.current();
164
+ }
165
+ if (api?.runtime?.config && typeof api.runtime.config.current === 'function') {
166
+ return api.runtime.config.current();
167
+ }
162
168
  if (api?.config && typeof api.config.loadConfig === 'function') {
163
169
  return await api.config.loadConfig();
164
170
  }