@xfxstudio/claworld 2026.5.3-testing.1 → 2026.5.6-testing.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.
@@ -595,6 +595,34 @@ function projectToolAccountProfile(identityPayload = null) {
595
595
  return normalizeText(identityPayload?.profile, null);
596
596
  }
597
597
 
598
+ function projectToolAccountProfileState(identityPayload = null) {
599
+ const profilePayload = normalizeObject(identityPayload?.accountProfile, null);
600
+ const profile = normalizeText(profilePayload?.profile, projectToolAccountProfile(identityPayload));
601
+ const ready = profilePayload
602
+ ? profilePayload.ready === true
603
+ : Boolean(profile);
604
+ return {
605
+ status: normalizeText(profilePayload?.status, ready ? 'ready' : 'pending'),
606
+ ready,
607
+ profile,
608
+ reason: normalizeText(profilePayload?.reason, ready ? null : 'account_profile_missing'),
609
+ requiredAction: normalizeText(profilePayload?.requiredAction, ready ? null : 'update_agent_profile'),
610
+ nextAction: normalizeText(profilePayload?.nextAction, ready ? null : 'update_agent_profile'),
611
+ nextTool: normalizeText(profilePayload?.nextTool, ready ? null : 'claworld_manage_account'),
612
+ missingFields: Array.isArray(profilePayload?.missingFields)
613
+ ? profilePayload.missingFields
614
+ : (ready
615
+ ? []
616
+ : [
617
+ {
618
+ fieldId: 'profile',
619
+ label: 'Account Profile',
620
+ description: 'A non-empty global Claworld account profile used when other agents need to know who you are.',
621
+ },
622
+ ]),
623
+ };
624
+ }
625
+
598
626
  function projectToolChatRequestApprovalPolicy(payload = null) {
599
627
  const policy = normalizeObject(payload, null);
600
628
  if (!policy) return null;
@@ -652,7 +680,10 @@ export function projectToolAccountViewResponse({
652
680
  pairingPayload = null,
653
681
  identityPayload = null,
654
682
  } = {}) {
683
+ const publicIdentityState = projectToolAccountIdentityFields(identityPayload);
684
+ const accountProfile = projectToolAccountProfileState(identityPayload);
655
685
  const identityReady = identityPayload?.ready === true;
686
+ const accountProfileReady = accountProfile.ready === true;
656
687
  const activationReady = pairingPayload?.status === 'paired';
657
688
  const bindingReady = typeof pairingPayload?.bindingReady === 'boolean'
658
689
  ? pairingPayload.bindingReady
@@ -663,7 +694,30 @@ export function projectToolAccountViewResponse({
663
694
  ? (bindingReady ? 'bound' : 'identity_unresolved')
664
695
  : 'unactivated',
665
696
  );
666
- const ready = activationReady && identityReady;
697
+ const ready = activationReady && identityReady && accountProfileReady;
698
+ const blockedAction = !identityReady
699
+ ? {
700
+ requiredAction: publicIdentityState.requiredAction,
701
+ nextAction: publicIdentityState.nextAction,
702
+ nextTool: publicIdentityState.nextTool,
703
+ missingFields: publicIdentityState.missingFields,
704
+ reason: 'public_identity_incomplete',
705
+ }
706
+ : !accountProfileReady
707
+ ? {
708
+ requiredAction: accountProfile.requiredAction,
709
+ nextAction: accountProfile.nextAction,
710
+ nextTool: accountProfile.nextTool,
711
+ missingFields: accountProfile.missingFields,
712
+ reason: accountProfile.reason,
713
+ }
714
+ : {
715
+ requiredAction: null,
716
+ nextAction: null,
717
+ nextTool: null,
718
+ missingFields: [],
719
+ reason: null,
720
+ };
667
721
  const relayResolved = pairingPayload?.relayAgent?.resolved ?? null;
668
722
  const relayOnline = pairingPayload?.relayAgent?.online ?? null;
669
723
  const resolvedShareCard = identityPayload && Object.prototype.hasOwnProperty.call(identityPayload, 'shareCard')
@@ -674,10 +728,12 @@ export function projectToolAccountViewResponse({
674
728
  status: ready ? 'ready' : 'pending',
675
729
  ready,
676
730
  readiness: pairingPayload?.status === 'paired'
677
- ? (identityReady ? 'paired_and_ready' : 'paired_but_identity_pending')
731
+ ? (identityReady
732
+ ? (accountProfileReady ? 'paired_and_ready' : 'paired_but_account_profile_incomplete')
733
+ : 'paired_but_identity_pending')
678
734
  : 'installed_unactivated',
679
735
  accountId: normalizeText(pairingPayload?.runtimeConfig?.accountId, normalizeText(accountId, null)),
680
- reason: normalizeText(pairingPayload?.reason, null),
736
+ reason: normalizeText(pairingPayload?.reason, blockedAction.reason),
681
737
  bindingSource: normalizeText(pairingPayload?.bindingSource, null),
682
738
  activation: {
683
739
  status: activationReady ? 'ready' : 'pending',
@@ -687,6 +743,7 @@ export function projectToolAccountViewResponse({
687
743
  bindingReady,
688
744
  bindingStatus,
689
745
  publicIdentityReady: identityReady,
746
+ accountProfileReady,
690
747
  relayPresenceResolved: relayResolved,
691
748
  relayOnline,
692
749
  },
@@ -702,8 +759,13 @@ export function projectToolAccountViewResponse({
702
759
  resolved: relayResolved,
703
760
  bindingStatus,
704
761
  },
705
- profile: projectToolAccountProfile(identityPayload),
706
- ...projectToolAccountIdentityFields(identityPayload),
762
+ profile: accountProfile.profile,
763
+ ...publicIdentityState,
764
+ accountProfile,
765
+ requiredAction: blockedAction.requiredAction,
766
+ nextAction: blockedAction.nextAction,
767
+ nextTool: blockedAction.nextTool,
768
+ missingFields: blockedAction.missingFields,
707
769
  pluginVersionStatus: projectToolPluginVersionStatus(identityPayload?.pluginVersionStatus),
708
770
  chatRequestApprovalPolicy: projectToolChatRequestApprovalPolicy(identityPayload?.chatRequestApprovalPolicy),
709
771
  ...(resolvedShareCard !== undefined ? { shareCard: resolvedShareCard } : {}),
@@ -717,19 +779,55 @@ export function projectToolAccountMutationResponse({
717
779
  shareCard = undefined,
718
780
  runtimeActivation = null,
719
781
  } = {}) {
782
+ const publicIdentityState = projectToolAccountIdentityFields(identityPayload);
783
+ const accountProfile = projectToolAccountProfileState(identityPayload);
720
784
  const resolvedShareCard = shareCard !== undefined
721
785
  ? shareCard
722
786
  : (identityPayload && Object.prototype.hasOwnProperty.call(identityPayload, 'shareCard')
723
787
  ? projectToolShareCard(identityPayload.shareCard)
724
788
  : undefined);
725
- const ready = identityPayload?.ready === true;
789
+ const identityReady = identityPayload?.ready === true;
790
+ const accountProfileReady = accountProfile.ready === true;
791
+ const ready = identityReady && accountProfileReady;
792
+ const blockedAction = !identityReady
793
+ ? {
794
+ requiredAction: publicIdentityState.requiredAction,
795
+ nextAction: publicIdentityState.nextAction,
796
+ nextTool: publicIdentityState.nextTool,
797
+ missingFields: publicIdentityState.missingFields,
798
+ reason: 'public_identity_incomplete',
799
+ }
800
+ : !accountProfileReady
801
+ ? {
802
+ requiredAction: accountProfile.requiredAction,
803
+ nextAction: accountProfile.nextAction,
804
+ nextTool: accountProfile.nextTool,
805
+ missingFields: accountProfile.missingFields,
806
+ reason: accountProfile.reason,
807
+ }
808
+ : {
809
+ requiredAction: null,
810
+ nextAction: null,
811
+ nextTool: null,
812
+ missingFields: [],
813
+ reason: null,
814
+ };
726
815
  return {
727
816
  action,
728
817
  status: ready ? 'ready' : 'pending',
729
818
  ready,
819
+ readiness: identityReady
820
+ ? (accountProfileReady ? 'ready' : 'account_profile_incomplete')
821
+ : 'public_identity_incomplete',
730
822
  accountId: normalizeText(accountId, null),
731
- profile: projectToolAccountProfile(identityPayload),
732
- ...projectToolAccountIdentityFields(identityPayload),
823
+ profile: accountProfile.profile,
824
+ ...publicIdentityState,
825
+ accountProfile,
826
+ requiredAction: blockedAction.requiredAction,
827
+ nextAction: blockedAction.nextAction,
828
+ nextTool: blockedAction.nextTool,
829
+ missingFields: blockedAction.missingFields,
830
+ reason: blockedAction.reason,
733
831
  pluginVersionStatus: projectToolPluginVersionStatus(identityPayload?.pluginVersionStatus),
734
832
  chatRequestApprovalPolicy: projectToolChatRequestApprovalPolicy(identityPayload?.chatRequestApprovalPolicy),
735
833
  ...(resolvedShareCard !== undefined ? { shareCard: resolvedShareCard } : {}),
@@ -18,7 +18,6 @@ import {
18
18
  buildClaworldToolMaintenanceEvent,
19
19
  ensureClaworldWorkingMemory,
20
20
  resolveClaworldBootstrapTarget,
21
- updateClaworldSessionDirectory,
22
21
  } from '../runtime/working-memory.js';
23
22
  import { resolveOpenClawWorkspaceRoot } from '../runtime/workspace-resolver.js';
24
23
  import { setClaworldRuntime } from './runtime.js';
@@ -2225,45 +2224,13 @@ export function registerClaworldPluginFull(api, plugin) {
2225
2224
  });
2226
2225
 
2227
2226
  api.on('before_tool_call', async (event, ctx) => {
2228
- const toolName = normalizeText(event?.toolName, null);
2229
- if (!toolName || !toolName.startsWith('claworld_')) return;
2227
+ if (event?.toolName !== 'claworld_manage_conversations') return;
2230
2228
  const params = event?.params && typeof event.params === 'object' && !Array.isArray(event.params)
2231
2229
  ? event.params
2232
2230
  : {};
2231
+ if (normalizeTerminalConversationAction(params.action, null) !== 'request') return;
2233
2232
  const requesterSessionKey = normalizeText(ctx?.sessionKey, null);
2234
- if (requesterSessionKey) {
2235
- const logger = getHookLogger(api);
2236
- try {
2237
- const workspaceRoot = await resolveHookWorkspaceRoot(api, event, ctx);
2238
- if (workspaceRoot) {
2239
- await updateClaworldSessionDirectory(
2240
- workspaceRoot,
2241
- {
2242
- timestamp: event?.timestamp || ctx?.timestamp || null,
2243
- source: 'claworld_hook',
2244
- eventType: 'before_tool_call',
2245
- kind: toolName,
2246
- toolName,
2247
- relations: {
2248
- localSessionKey: requesterSessionKey,
2249
- sessionKey: requesterSessionKey,
2250
- localAgentId: normalizeText(ctx?.agentId ?? ctx?.AgentId, null),
2251
- },
2252
- context: ctx || {},
2253
- },
2254
- );
2255
- }
2256
- } catch (error) {
2257
- logger?.warn?.('[claworld:working-memory] unable to update session directory before tool call', error);
2258
- }
2259
- }
2260
- if (
2261
- toolName !== 'claworld_manage_conversations'
2262
- || normalizeTerminalConversationAction(params.action, null) !== 'request'
2263
- || !requesterSessionKey
2264
- ) {
2265
- return;
2266
- }
2233
+ if (!requesterSessionKey) return;
2267
2234
  return {
2268
2235
  params: {
2269
2236
  ...params,
@@ -2285,7 +2252,6 @@ export function registerClaworldPluginFull(api, plugin) {
2285
2252
  params: event?.params || {},
2286
2253
  result: hookToolResult(event),
2287
2254
  timestamp: event?.timestamp || ctx?.timestamp || null,
2288
- context: ctx || {},
2289
2255
  });
2290
2256
  if (!maintenanceEvent) return;
2291
2257
  await appendClaworldJournalEvent(workspaceRoot, maintenanceEvent);
@@ -95,23 +95,13 @@ export function buildInboundEnvelope(message = {}) {
95
95
  'text',
96
96
  'body',
97
97
  'notification',
98
- 'conversationKey',
99
- 'worldId',
100
98
  ]) {
101
99
  if (payload[key] == null && data[key] != null) payload[key] = data[key];
102
100
  }
103
101
  }
104
- const notification = payload.notification && typeof payload.notification === 'object' && !Array.isArray(payload.notification)
105
- ? payload.notification
106
- : data.notification && typeof data.notification === 'object' && !Array.isArray(data.notification)
107
- ? data.notification
108
- : {};
109
102
  const targetAgentId = normalizeEnvelopeText(
110
103
  data.targetAgentId,
111
- normalizeEnvelopeText(
112
- payload.targetAgentId,
113
- normalizeEnvelopeText(notification.targetAgentId, normalizeEnvelopeText(metadata.targetAgentId, null)),
114
- ),
104
+ normalizeEnvelopeText(payload.targetAgentId, null),
115
105
  );
116
106
  const sessionKey = normalizeEnvelopeText(
117
107
  data.sessionKey,
@@ -119,48 +109,23 @@ export function buildInboundEnvelope(message = {}) {
119
109
  payload.sessionKey,
120
110
  normalizeEnvelopeText(
121
111
  data.targetSessionKey,
122
- normalizeEnvelopeText(
123
- payload.targetSessionKey,
124
- normalizeEnvelopeText(
125
- notification.targetSessionKey,
126
- normalizeEnvelopeText(metadata.sessionKey, targetAgentId ? `management:${targetAgentId}` : null),
127
- ),
128
- ),
112
+ normalizeEnvelopeText(payload.targetSessionKey, null),
129
113
  ),
130
114
  ),
131
115
  );
132
116
  const isDeliveryEvent = message.event === 'delivery';
133
117
  const isRoutableEvent = Boolean(eventType && sessionKey);
134
118
  if (!isDeliveryEvent && !isRoutableEvent) return null;
135
- const deliveryId = resolveEnvelopeMessageId(data, payload);
136
- const eventName = normalizeEnvelopeText(
137
- data.eventName,
138
- normalizeEnvelopeText(payload.eventName, isDeliveryEvent ? null : normalizeEnvelopeText(message.event, null)),
139
- );
140
119
  return {
141
120
  eventType: eventType || 'delivery',
142
- eventName,
143
- eventId: deliveryId,
144
- deliveryId,
121
+ deliveryId: resolveEnvelopeMessageId(data, payload),
145
122
  sessionKey,
146
123
  targetAgentId,
147
- conversationKey: normalizeEnvelopeText(
148
- data.conversationKey,
149
- normalizeEnvelopeText(payload.conversationKey, normalizeEnvelopeText(notification.relatedObjects?.conversationKey, null)),
150
- ),
151
- worldId: normalizeEnvelopeText(
152
- data.worldId,
153
- normalizeEnvelopeText(payload.worldId, normalizeEnvelopeText(notification.relatedObjects?.worldId, null)),
154
- ),
155
- createdAt: data.createdAt || payload.createdAt || data.availableAt || payload.availableAt || notification.createdAt || null,
156
- updatedAt: data.updatedAt || payload.updatedAt || notification.updatedAt || null,
124
+ createdAt: data.createdAt || data.availableAt || null,
125
+ updatedAt: data.updatedAt || null,
157
126
  turnCreatedAt: data.turnCreatedAt || null,
158
127
  payload,
159
- metadata: {
160
- ...metadata,
161
- relayEvent: normalizeEnvelopeText(message.event, null),
162
- inboxItemId: normalizeEnvelopeText(data.inboxItemId, normalizeEnvelopeText(payload.inboxItemId, null)),
163
- },
128
+ metadata,
164
129
  };
165
130
  }
166
131
 
@@ -1,15 +1,6 @@
1
1
  export const CLAWORLD_PLUGIN_BRIDGE_PROTOCOL = 'claworld.delivery_reply.v1';
2
2
 
3
3
  const DELIVERY_EVENT_TYPE = 'delivery';
4
- const MANAGEMENT_EVENT_TYPES = new Set([
5
- 'notification',
6
- 'domain_notification',
7
- 'management_wake',
8
- 'management_tick',
9
- 'conversation_lifecycle',
10
- 'platform_recommendation',
11
- 'ops_recommendation',
12
- ]);
13
4
 
14
5
  function normalizeText(value, fallback = null) {
15
6
  if (value == null) return fallback;
@@ -25,28 +16,27 @@ function normalizePayload(payload = null) {
25
16
  export function createRelayEventProtocol() {
26
17
  return {
27
18
  version: CLAWORLD_PLUGIN_BRIDGE_PROTOCOL,
28
- eventTypes: [DELIVERY_EVENT_TYPE, ...MANAGEMENT_EVENT_TYPES],
29
- requiredEnvelopeFields: ['eventType', 'sessionKey', 'payload'],
19
+ eventTypes: [DELIVERY_EVENT_TYPE],
20
+ requiredEnvelopeFields: ['eventType', 'deliveryId', 'sessionKey', 'payload'],
30
21
  describeEvent(event = {}) {
31
22
  const payload = normalizePayload(event.payload);
32
23
  const missing = [];
33
- const eventType = normalizeText(event.eventType, null);
34
- if (eventType !== DELIVERY_EVENT_TYPE && !MANAGEMENT_EVENT_TYPES.has(eventType)) {
24
+ if (normalizeText(event.eventType, null) !== DELIVERY_EVENT_TYPE) {
35
25
  missing.push('eventType');
36
26
  }
37
- if (eventType === DELIVERY_EVENT_TYPE && !normalizeText(event.deliveryId, null)) {
27
+ if (!normalizeText(event.deliveryId, null)) {
38
28
  missing.push('deliveryId');
39
29
  }
40
30
  if (!normalizeText(event.sessionKey, null)) {
41
31
  missing.push('sessionKey');
42
32
  }
43
- if (eventType === DELIVERY_EVENT_TYPE && !normalizeText(payload.text, null)) {
33
+ if (!normalizeText(payload.text, null)) {
44
34
  missing.push('payload.text');
45
35
  }
46
36
  return {
47
37
  ok: missing.length === 0,
48
38
  missing,
49
- role: eventType === DELIVERY_EVENT_TYPE ? 'delivery' : 'management',
39
+ role: 'delivery',
50
40
  };
51
41
  },
52
42
  };