@xfxstudio/claworld 2026.7.1-testing.2 → 2026.7.7-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.
@@ -25,10 +25,6 @@ import {
25
25
  } from '../runtime/working-memory.js';
26
26
  import { resolveOpenClawWorkspaceRoot } from '../runtime/workspace-resolver.js';
27
27
  import { setClaworldRuntime } from './runtime.js';
28
- import {
29
- CHAT_REQUEST_APPROVAL_POLICY_MODES,
30
- CHAT_REQUEST_APPROVAL_POLICY_ORIGIN_TYPES,
31
- } from '../../product-shell/contracts/chat-request-approval-policy.js';
32
28
  import { PUBLIC_TOOL_ACTION_CATALOG } from '../../product-shell/contracts/search-item.js';
33
29
  import {
34
30
  ACCOUNT_ACTIONS,
@@ -236,13 +232,50 @@ function normalizeTerminalAccountAction(params = {}) {
236
232
  Object.prototype.hasOwnProperty.call(params, 'agentProfile')
237
233
  || Object.prototype.hasOwnProperty.call(params, 'profile')
238
234
  ) return 'update_agent_profile';
239
- if (Object.prototype.hasOwnProperty.call(params, 'discoverable')) return 'set_discoverability';
240
- if (Object.prototype.hasOwnProperty.call(params, 'contactable')) return 'set_contactability';
241
- if (normalizeObject(params.chatRequestApprovalPolicy, null)) return 'set_chat_policy';
235
+ if (Object.prototype.hasOwnProperty.call(params, 'visibilityMode')) return 'set_visibility_mode';
236
+ if (Object.prototype.hasOwnProperty.call(params, 'contactPolicy')) return 'set_contact_policy';
237
+ if (Object.prototype.hasOwnProperty.call(params, 'chatRequestPolicy')) {
238
+ requireManageWorldField('chatRequestPolicy', 'chatRequestPolicy is not supported by claworld_manage_account; use contactPolicy');
239
+ }
242
240
  if (Object.prototype.hasOwnProperty.call(params, 'proactivitySettings')) return 'set_proactivity';
243
241
  return 'view_account';
244
242
  }
245
243
 
244
+ function hasProvidedTerminalAccountPolicyField(params = {}, fieldId) {
245
+ if (!Object.prototype.hasOwnProperty.call(params, fieldId)) return false;
246
+ const value = params[fieldId];
247
+ if (value == null) return false;
248
+ if (typeof value === 'string') return normalizeText(value, null) != null;
249
+ return true;
250
+ }
251
+
252
+ function validateTerminalAccountPolicyPayload(action, params = {}) {
253
+ if (action === 'set_visibility_mode') {
254
+ if (!normalizeText(params.visibilityMode, null)) {
255
+ requireManageWorldField('visibilityMode', 'visibilityMode is required for action=set_visibility_mode');
256
+ }
257
+ if (hasProvidedTerminalAccountPolicyField(params, 'contactPolicy')) {
258
+ requireManageWorldField('contactPolicy', 'contactPolicy is not supported for action=set_visibility_mode');
259
+ }
260
+ if (hasProvidedTerminalAccountPolicyField(params, 'chatRequestPolicy')) {
261
+ requireManageWorldField('chatRequestPolicy', 'chatRequestPolicy is not supported by claworld_manage_account; use contactPolicy');
262
+ }
263
+ return;
264
+ }
265
+ if (action === 'set_contact_policy') {
266
+ if (!normalizeText(params.contactPolicy, null)) {
267
+ requireManageWorldField('contactPolicy', 'contactPolicy is required for action=set_contact_policy');
268
+ }
269
+ if (hasProvidedTerminalAccountPolicyField(params, 'visibilityMode')) {
270
+ requireManageWorldField('visibilityMode', 'visibilityMode is not supported for action=set_contact_policy');
271
+ }
272
+ if (hasProvidedTerminalAccountPolicyField(params, 'chatRequestPolicy')) {
273
+ requireManageWorldField('chatRequestPolicy', 'chatRequestPolicy is not supported by claworld_manage_account; use contactPolicy');
274
+ }
275
+ return;
276
+ }
277
+ }
278
+
246
279
  function normalizeTerminalWorldAction(params = {}) {
247
280
  if (hasExplicitAction(params)) {
248
281
  const explicitAction = normalizeText(params.action, null);
@@ -470,12 +503,12 @@ function createTerminalToolAdapters(api, plugin, internalTools) {
470
503
  {
471
504
  name: accountTool,
472
505
  label: 'Claworld Manage Account',
473
- description: 'Terminal account surface for readiness, public identity, global profile, share-card generation, account-level chat policy, and email-based identity verification.',
506
+ description: 'Terminal account surface for readiness, public identity, global profile, share-card generation, visibility, inbound contact policy, and email-based identity verification.',
474
507
  metadata: buildToolMetadata({
475
508
  category: 'account',
476
509
  usageNotes: [
477
510
  'Use this human-facing account surface for identity verification, profile, policy, and subscription decisions.',
478
- 'Use action=view_account for readiness; update_display_name, update_agent_profile, or set_chat_policy for common account mutations.',
511
+ 'Use action=view_account for readiness; update_display_name, update_agent_profile, or set_contact_policy for common account mutations.',
479
512
  'Use start_email_verification with email + optional displayName to start email-based identity verification, then complete_email_verification with email + code to finish.',
480
513
  'Use subscribe_person or unsubscribe_person when a search/profile result exposes a person subscription target.',
481
514
  ],
@@ -488,7 +521,7 @@ function createTerminalToolAdapters(api, plugin, internalTools) {
488
521
  action: stringParam({
489
522
  description: 'Account action.',
490
523
  enumValues: TERMINAL_ACCOUNT_ACTIONS,
491
- examples: ['view_account', 'start_email_verification', 'update_display_name', 'set_chat_policy'],
524
+ examples: ['view_account', 'start_email_verification', 'update_display_name', 'set_contact_policy'],
492
525
  }),
493
526
  displayName: stringParam({
494
527
  description: 'Public-facing display name for update_display_name or start_email_verification.',
@@ -507,11 +540,15 @@ function createTerminalToolAdapters(api, plugin, internalTools) {
507
540
  description: 'Agent-facing profile/personality text for update_agent_profile.',
508
541
  examples: ['偏主动但会先确认边界,擅长总结和约局。'],
509
542
  }),
510
- discoverable: booleanParam({ description: 'Whether this account can appear in global people search.' }),
511
- contactable: booleanParam({ description: 'Whether this account can receive direct public-profile chat requests.' }),
512
- chatRequestApprovalPolicy: objectParam({
513
- description: 'Backend-managed inbound chat-request policy for this account.',
514
- additionalProperties: true,
543
+ visibilityMode: stringParam({
544
+ description: 'Account visibility mode: public is searchable, unlisted is explicit-identity reachable, private is not publicly reachable.',
545
+ enumValues: ['public', 'unlisted', 'private'],
546
+ examples: ['public', 'unlisted', 'private'],
547
+ }),
548
+ contactPolicy: stringParam({
549
+ description: 'Inbound contact policy: open accepts eligible requests, approval_required keeps the request path open but requires review, closed blocks new inbound contact.',
550
+ enumValues: ['open', 'approval_required', 'closed'],
551
+ examples: ['open', 'approval_required', 'closed'],
515
552
  }),
516
553
  proactivitySettings: objectParam({
517
554
  description: 'Account-level proactive-management settings.',
@@ -554,6 +591,7 @@ function createTerminalToolAdapters(api, plugin, internalTools) {
554
591
  }),
555
592
  async execute(toolCallId, params = {}) {
556
593
  const action = normalizeTerminalAccountAction(params);
594
+ validateTerminalAccountPolicyPayload(action, params);
557
595
  const subscriptionTargetId = normalizeText(params.targetAgentId, normalizeText(params.targetId, null));
558
596
  if (action === 'subscribe_person') {
559
597
  if (!subscriptionTargetId) requireManageWorldField('targetAgentId', 'targetAgentId is required for action=subscribe_person');
@@ -641,9 +679,8 @@ function createTerminalToolAdapters(api, plugin, internalTools) {
641
679
  profile: params.profile,
642
680
  humanProfile: params.humanProfile,
643
681
  agentProfile: params.agentProfile,
644
- discoverable: params.discoverable,
645
- contactable: params.contactable,
646
- chatRequestApprovalPolicy: params.chatRequestApprovalPolicy || null,
682
+ visibilityMode: params.visibilityMode,
683
+ contactPolicy: params.contactPolicy,
647
684
  proactivitySettings: params.proactivitySettings,
648
685
  generateShareCard,
649
686
  shareCardVariant: params.shareCardVariant ?? null,
@@ -661,7 +698,7 @@ function createTerminalToolAdapters(api, plugin, internalTools) {
661
698
  usageNotes: [
662
699
  'scope=worlds searches or browses visible worlds.',
663
700
  'scope=world_members searches members in an authorized world.',
664
- 'scope=people searches globally discoverable/contactable public identities.',
701
+ 'scope=people searches globally public identities; unlisted people require explicit identity/profile lookup.',
665
702
  'scope=mixed combines world, optional world-member, and global people search results in one SearchItemEnvelope list.',
666
703
  ],
667
704
  }),
@@ -1200,43 +1237,6 @@ function buildRegisteredTools(api, plugin) {
1200
1237
  enumValues: ['en', 'zh'],
1201
1238
  examples: ['en', 'zh'],
1202
1239
  });
1203
- const chatRequestApprovalPolicyProperty = objectParam({
1204
- description: 'Backend-managed inbound chat-request policy for this account.',
1205
- required: ['mode'],
1206
- properties: {
1207
- mode: stringParam({
1208
- description: 'Policy mode controlling which new inbound chat requests auto-accept.',
1209
- enumValues: CHAT_REQUEST_APPROVAL_POLICY_MODES,
1210
- examples: ['open', 'manual_review'],
1211
- }),
1212
- blocks: objectParam({
1213
- description: 'Optional deny rules applied before the allow mode is evaluated.',
1214
- properties: {
1215
- originTypes: arrayParam({
1216
- description: 'Canonical request origin types that should always be rejected.',
1217
- items: stringParam({
1218
- enumValues: CHAT_REQUEST_APPROVAL_POLICY_ORIGIN_TYPES,
1219
- }),
1220
- examples: [['world_broadcast']],
1221
- }),
1222
- worldIds: arrayParam({
1223
- description: 'World ids that should always be rejected.',
1224
- items: stringParam({}),
1225
- examples: [['dating-demo-world']],
1226
- }),
1227
- },
1228
- }),
1229
- },
1230
- examples: [
1231
- {
1232
- mode: 'trusted_or_world',
1233
- blocks: {
1234
- originTypes: ['world_broadcast'],
1235
- worldIds: [],
1236
- },
1237
- },
1238
- ],
1239
- });
1240
1240
  const worldIdProperty = stringParam({
1241
1241
  description: 'Canonical world id returned by claworld_search(scope=worlds) or claworld_manage_worlds(action=get_world).',
1242
1242
  minLength: 1,
@@ -1925,20 +1925,6 @@ function buildRegisteredTools(api, plugin) {
1925
1925
  },
1926
1926
  outcome: 'Stores the current account profile text. Pass an empty string to clear it.',
1927
1927
  },
1928
- {
1929
- title: 'Update the inbound chat policy',
1930
- input: {
1931
- accountId: 'claworld',
1932
- action: 'update_chat_policy',
1933
- chatRequestApprovalPolicy: {
1934
- mode: 'trusted_or_world',
1935
- blocks: {
1936
- originTypes: ['world_broadcast'],
1937
- },
1938
- },
1939
- },
1940
- outcome: 'Stores the account-level chat-request policy in the backend and returns the updated policy snapshot.',
1941
- },
1942
1928
  ],
1943
1929
  }),
1944
1930
  parameters: objectParam({
@@ -1947,9 +1933,9 @@ function buildRegisteredTools(api, plugin) {
1947
1933
  properties: {
1948
1934
  accountId: accountIdProperty,
1949
1935
  action: stringParam({
1950
- description: 'Account action. Defaults to view; inferred from displayName, profile, or chatRequestApprovalPolicy when omitted.',
1936
+ description: 'Account action. Defaults to view; inferred from displayName or profile when omitted.',
1951
1937
  enumValues: ACCOUNT_ACTIONS,
1952
- examples: ['view', 'update_identity', 'update_profile', 'update_chat_policy'],
1938
+ examples: ['view', 'update_identity', 'update_profile'],
1953
1939
  }),
1954
1940
  displayName: stringParam({
1955
1941
  description: 'Public-facing display name. Required for action=update_identity. # is reserved and must not appear here.',
@@ -1960,7 +1946,6 @@ function buildRegisteredTools(api, plugin) {
1960
1946
  description: 'Global plain-text profile for this account. Maximum 500 characters. Use an empty string to clear it. HTML is not supported.',
1961
1947
  examples: ['喜欢慢节奏介绍和小范围世界,也愿意先让 agent 帮我做初步认识。🙂'],
1962
1948
  }),
1963
- chatRequestApprovalPolicy: chatRequestApprovalPolicyProperty,
1964
1949
  generateShareCard: booleanParam({
1965
1950
  description: 'When true, return a temporary public identity card URL. Defaults to false for view and true for update_identity.',
1966
1951
  }),
@@ -1988,13 +1973,6 @@ function buildRegisteredTools(api, plugin) {
1988
1973
  action: 'update_profile',
1989
1974
  profile: '喜欢慢节奏介绍和小范围世界,也愿意先让 agent 帮我做初步认识。🙂',
1990
1975
  },
1991
- {
1992
- accountId: 'claworld',
1993
- action: 'update_chat_policy',
1994
- chatRequestApprovalPolicy: {
1995
- mode: 'manual_review',
1996
- },
1997
- },
1998
1976
  ],
1999
1977
  }),
2000
1978
  async execute(_toolCallId, params = {}) {
@@ -2040,26 +2018,6 @@ function buildRegisteredTools(api, plugin) {
2040
2018
  }));
2041
2019
  }
2042
2020
 
2043
- if (action === 'update_chat_policy') {
2044
- const context = await resolveToolContext(api, plugin, params);
2045
- const chatRequestApprovalPolicy = normalizeObject(params.chatRequestApprovalPolicy, null);
2046
- if (!chatRequestApprovalPolicy) {
2047
- requireManageWorldField(
2048
- 'chatRequestApprovalPolicy',
2049
- 'chatRequestApprovalPolicy is required for action=update_chat_policy',
2050
- );
2051
- }
2052
- const payload = await plugin.runtime.productShell.profile.updateChatRequestApprovalPolicy({
2053
- ...context,
2054
- chatRequestApprovalPolicy,
2055
- });
2056
- return buildToolResult(projectToolAccountMutationResponse({
2057
- action,
2058
- accountId: context.accountId,
2059
- identityPayload: payload,
2060
- }));
2061
- }
2062
-
2063
2021
  const context = await resolveToolContext(api, plugin, params);
2064
2022
  const cfg = context.cfg || await loadCurrentConfig(api);
2065
2023
  const accountId = context.accountId;
@@ -2094,8 +2052,8 @@ function buildRegisteredTools(api, plugin) {
2094
2052
  normalizeText(runtimeConfig?.name, normalizeText(runtimeConfig?.registration?.displayName, null)),
2095
2053
  ),
2096
2054
  ),
2097
- discoverable: null,
2098
- contactable: null,
2055
+ visibilityMode: null,
2056
+ contactPolicy: null,
2099
2057
  online: null,
2100
2058
  resolved: null,
2101
2059
  }
@@ -2113,7 +2071,13 @@ function buildRegisteredTools(api, plugin) {
2113
2071
  agentId: pairedAgentId,
2114
2072
  })
2115
2073
  : null;
2116
- const emailVerified = identityStatus?.emailVerified === true;
2074
+ const accountPayload = normalizeObject(identityStatus?.accountView, null)
2075
+ || (normalizeObject(identityStatus?.relay, null) ? identityStatus : null);
2076
+ const accountViewAccount = normalizeObject(accountPayload?.account, null);
2077
+ const accountViewDiagnostics = normalizeObject(accountPayload?.diagnostics, null);
2078
+ const emailVerified = identityStatus?.emailVerified === true
2079
+ || accountViewAccount?.emailVerified === true
2080
+ || accountViewDiagnostics?.emailVerified === true;
2117
2081
  const bindingReady = hasConfiguredAppToken && Boolean(pairedAgentId);
2118
2082
  const bindingStatus = hasConfiguredAppToken
2119
2083
  ? (bindingReady ? 'bound' : 'identity_unresolved')
@@ -2140,8 +2104,8 @@ function buildRegisteredTools(api, plugin) {
2140
2104
  bindingReady,
2141
2105
  bindingStatus,
2142
2106
  emailVerified,
2143
- email: identityStatus?.email || null,
2144
- verifiedAt: identityStatus?.verifiedAt || null,
2107
+ email: identityStatus?.email || accountViewAccount?.email || null,
2108
+ verifiedAt: identityStatus?.verifiedAt || accountViewAccount?.verifiedAt || null,
2145
2109
  reason: hasConfiguredAppToken
2146
2110
  ? (pairedAgentId ? null : 'missing_agent_id')
2147
2111
  : 'missing_app_token',
@@ -2155,6 +2119,7 @@ function buildRegisteredTools(api, plugin) {
2155
2119
  accountId,
2156
2120
  pairingPayload,
2157
2121
  identityPayload,
2122
+ accountPayload,
2158
2123
  }));
2159
2124
  },
2160
2125
  },