@xfxstudio/claworld 0.2.13 → 0.2.15
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.
- package/README.md +4 -4
- package/index.js +0 -1
- package/openclaw.plugin.json +1 -97
- package/package.json +1 -1
- package/skills/claworld-help/SKILL.md +47 -27
- package/skills/claworld-join-and-chat/SKILL.md +13 -9
- package/src/openclaw/index.js +0 -3
- package/src/openclaw/plugin/account-identity.js +0 -1
- package/src/openclaw/plugin/claworld-channel-plugin.js +73 -319
- package/src/openclaw/plugin/config-schema.js +1 -55
- package/src/openclaw/plugin/managed-config.js +1 -42
- package/src/openclaw/plugin/onboarding.js +1 -1
- package/src/openclaw/plugin/register.js +302 -233
- package/src/openclaw/plugin/relay-client.js +9 -6
- package/src/openclaw/runtime/product-shell-helper.js +11 -364
- package/src/openclaw/runtime/tool-contracts.js +0 -182
- package/src/openclaw/runtime/tool-inventory.js +4 -27
- package/src/lib/agent-profile.js +0 -74
- package/src/lib/http-auth.js +0 -151
- package/src/lib/policy.js +0 -114
- package/src/openclaw/installer/constants.js +0 -14
- package/src/product-shell/agent-cards/card-routes.js +0 -64
- package/src/product-shell/agent-cards/card-service.js +0 -287
- package/src/product-shell/agent-cards/spec-builder.js +0 -167
- package/src/product-shell/agent-cards/storage/image-host-storage.js +0 -192
- package/src/product-shell/agent-cards/storage/local-public-storage.js +0 -74
- package/src/product-shell/agent-cards/svg-renderer.js +0 -325
- package/src/product-shell/agent-cards/template-registry.js +0 -131
- package/src/product-shell/catalog/default-world-catalog.js +0 -38
- package/src/product-shell/contracts/candidate-feed.js +0 -393
- package/src/product-shell/contracts/world-manifest.js +0 -369
- package/src/product-shell/conversation-feedback/conversation-feedback-service.js +0 -261
- package/src/product-shell/feedback/feedback-contract.js +0 -13
- package/src/product-shell/feedback/feedback-routes.js +0 -98
- package/src/product-shell/feedback/feedback-service.js +0 -252
- package/src/product-shell/index.js +0 -212
- package/src/product-shell/matching/matchmaking-service.js +0 -395
- package/src/product-shell/membership/membership-service.js +0 -284
- package/src/product-shell/onboarding/onboarding-routes.js +0 -37
- package/src/product-shell/onboarding/onboarding-service.js +0 -222
- package/src/product-shell/orchestration/world-conversation-orchestrator.js +0 -28
- package/src/product-shell/profile/profile-service.js +0 -142
- package/src/product-shell/profile/public-identity-routes.js +0 -160
- package/src/product-shell/profile/public-identity-service.js +0 -192
- package/src/product-shell/search/search-service.js +0 -393
- package/src/product-shell/social/chat-request-approval-policy.js +0 -332
- package/src/product-shell/social/chat-request-routes.js +0 -130
- package/src/product-shell/social/chat-request-service.js +0 -723
- package/src/product-shell/social/friend-routes.js +0 -82
- package/src/product-shell/social/friend-service.js +0 -557
- package/src/product-shell/social/social-routes.js +0 -21
- package/src/product-shell/social/social-service.js +0 -136
- package/src/product-shell/worlds/world-admin-service.js +0 -486
- package/src/product-shell/worlds/world-authorization.js +0 -136
- package/src/product-shell/worlds/world-broadcast-service.js +0 -296
- package/src/product-shell/worlds/world-routes.js +0 -403
- package/src/product-shell/worlds/world-service.js +0 -89
- package/src/product-shell/worlds/world-text.js +0 -75
|
@@ -36,12 +36,9 @@ import {
|
|
|
36
36
|
buildWorldSelectionPrompt,
|
|
37
37
|
buildCandidateDeliverySummary,
|
|
38
38
|
buildPostSetupWorldDirectory,
|
|
39
|
-
broadcastWorld,
|
|
40
|
-
fetchWorldSearch,
|
|
41
39
|
fetchWorldCandidateFeed,
|
|
42
40
|
fetchWorldDetail,
|
|
43
41
|
joinWorld,
|
|
44
|
-
submitWorldSearch,
|
|
45
42
|
resolveWorldSelection,
|
|
46
43
|
resolveWorldSelectionFlow,
|
|
47
44
|
} from '../runtime/product-shell-helper.js';
|
|
@@ -53,7 +50,6 @@ import {
|
|
|
53
50
|
serializeRuntimeBoundaryError,
|
|
54
51
|
} from '../../lib/runtime-errors.js';
|
|
55
52
|
import { PUBLIC_IDENTITY_STATUS } from '../../lib/public-identity.js';
|
|
56
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
57
53
|
|
|
58
54
|
function normalizeRelayHttpBaseUrl(serverUrl) {
|
|
59
55
|
const parsed = new URL(serverUrl);
|
|
@@ -70,8 +66,12 @@ function normalizePluginOptionalText(value) {
|
|
|
70
66
|
return normalized || null;
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
function
|
|
74
|
-
|
|
69
|
+
function requireClientMessageId(value = null) {
|
|
70
|
+
const normalized = normalizePluginOptionalText(value);
|
|
71
|
+
if (!normalized) {
|
|
72
|
+
throw new Error('claworld outbound clientMessageId is required for POST /v1/messages');
|
|
73
|
+
}
|
|
74
|
+
return normalized;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function buildRelayAgentSummary(item = {}) {
|
|
@@ -338,7 +338,7 @@ async function deliverRelayMessage({ runtimeConfig, to, text, fetchImpl, logger,
|
|
|
338
338
|
}
|
|
339
339
|
payload.source = normalizeClaworldText(payload.source, 'openclaw-claworld');
|
|
340
340
|
payload.accountId = normalizeClaworldText(payload.accountId, runtimeConfig.accountId);
|
|
341
|
-
const clientMessageId =
|
|
341
|
+
const clientMessageId = requireClientMessageId(
|
|
342
342
|
outboundContext.clientMessageId || outboundContext.metadata?.clientMessageId || null
|
|
343
343
|
);
|
|
344
344
|
|
|
@@ -433,129 +433,6 @@ function createRelayRouteError({
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
-
async function createFriendRequest({
|
|
437
|
-
runtimeConfig,
|
|
438
|
-
fromAgentId,
|
|
439
|
-
targetAgentId,
|
|
440
|
-
message = null,
|
|
441
|
-
metadata = {},
|
|
442
|
-
fetchImpl,
|
|
443
|
-
}) {
|
|
444
|
-
const baseUrl = normalizeRelayHttpBaseUrl(runtimeConfig.serverUrl);
|
|
445
|
-
const result = await fetchJson(fetchImpl, `${baseUrl}/v1/friend-requests`, {
|
|
446
|
-
method: 'POST',
|
|
447
|
-
headers: {
|
|
448
|
-
'content-type': 'application/json',
|
|
449
|
-
...(runtimeConfig.apiKey ? { 'x-api-key': runtimeConfig.apiKey } : {}),
|
|
450
|
-
...buildRuntimeAuthHeaders(runtimeConfig),
|
|
451
|
-
},
|
|
452
|
-
body: JSON.stringify({
|
|
453
|
-
fromAgentId,
|
|
454
|
-
targetAgentId,
|
|
455
|
-
message: normalizeClaworldText(message, null),
|
|
456
|
-
metadata: metadata && typeof metadata === 'object' && !Array.isArray(metadata) ? metadata : {},
|
|
457
|
-
}),
|
|
458
|
-
});
|
|
459
|
-
if (!result.ok) {
|
|
460
|
-
createRelayRouteError({
|
|
461
|
-
result,
|
|
462
|
-
runtimeConfig,
|
|
463
|
-
code: 'friend_request_failed',
|
|
464
|
-
publicMessage: 'failed to create friend request',
|
|
465
|
-
context: { fromAgentId, targetAgentId },
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
return result.body || {};
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
async function listFriendRequests({
|
|
472
|
-
runtimeConfig,
|
|
473
|
-
agentId,
|
|
474
|
-
direction = null,
|
|
475
|
-
status = null,
|
|
476
|
-
fetchImpl,
|
|
477
|
-
}) {
|
|
478
|
-
const baseUrl = normalizeRelayHttpBaseUrl(runtimeConfig.serverUrl);
|
|
479
|
-
const path = buildRelayJsonPath('/v1/friend-requests', {
|
|
480
|
-
agentId,
|
|
481
|
-
direction,
|
|
482
|
-
status,
|
|
483
|
-
});
|
|
484
|
-
const result = await fetchJson(fetchImpl, `${baseUrl}${path}`, {
|
|
485
|
-
method: 'GET',
|
|
486
|
-
headers: {
|
|
487
|
-
...(runtimeConfig.apiKey ? { 'x-api-key': runtimeConfig.apiKey } : {}),
|
|
488
|
-
...buildRuntimeAuthHeaders(runtimeConfig),
|
|
489
|
-
},
|
|
490
|
-
});
|
|
491
|
-
if (!result.ok) {
|
|
492
|
-
createRelayRouteError({
|
|
493
|
-
result,
|
|
494
|
-
runtimeConfig,
|
|
495
|
-
code: 'friend_request_list_failed',
|
|
496
|
-
publicMessage: 'failed to list friend requests',
|
|
497
|
-
context: { agentId, direction, status },
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
return result.body || {};
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
async function acceptFriendRequest({
|
|
504
|
-
runtimeConfig,
|
|
505
|
-
actorAgentId,
|
|
506
|
-
friendRequestId,
|
|
507
|
-
fetchImpl,
|
|
508
|
-
}) {
|
|
509
|
-
const baseUrl = normalizeRelayHttpBaseUrl(runtimeConfig.serverUrl);
|
|
510
|
-
const result = await fetchJson(fetchImpl, `${baseUrl}/v1/friend-requests/${encodeURIComponent(friendRequestId)}/accept`, {
|
|
511
|
-
method: 'POST',
|
|
512
|
-
headers: {
|
|
513
|
-
'content-type': 'application/json',
|
|
514
|
-
...(runtimeConfig.apiKey ? { 'x-api-key': runtimeConfig.apiKey } : {}),
|
|
515
|
-
...buildRuntimeAuthHeaders(runtimeConfig),
|
|
516
|
-
},
|
|
517
|
-
body: JSON.stringify({ actorAgentId }),
|
|
518
|
-
});
|
|
519
|
-
if (!result.ok) {
|
|
520
|
-
createRelayRouteError({
|
|
521
|
-
result,
|
|
522
|
-
runtimeConfig,
|
|
523
|
-
code: 'friend_request_accept_failed',
|
|
524
|
-
publicMessage: 'failed to accept friend request',
|
|
525
|
-
context: { actorAgentId, friendRequestId },
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
return result.body || {};
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
async function rejectFriendRequest({
|
|
532
|
-
runtimeConfig,
|
|
533
|
-
actorAgentId,
|
|
534
|
-
friendRequestId,
|
|
535
|
-
fetchImpl,
|
|
536
|
-
}) {
|
|
537
|
-
const baseUrl = normalizeRelayHttpBaseUrl(runtimeConfig.serverUrl);
|
|
538
|
-
const result = await fetchJson(fetchImpl, `${baseUrl}/v1/friend-requests/${encodeURIComponent(friendRequestId)}/reject`, {
|
|
539
|
-
method: 'POST',
|
|
540
|
-
headers: {
|
|
541
|
-
'content-type': 'application/json',
|
|
542
|
-
...(runtimeConfig.apiKey ? { 'x-api-key': runtimeConfig.apiKey } : {}),
|
|
543
|
-
...buildRuntimeAuthHeaders(runtimeConfig),
|
|
544
|
-
},
|
|
545
|
-
body: JSON.stringify({ actorAgentId }),
|
|
546
|
-
});
|
|
547
|
-
if (!result.ok) {
|
|
548
|
-
createRelayRouteError({
|
|
549
|
-
result,
|
|
550
|
-
runtimeConfig,
|
|
551
|
-
code: 'friend_request_reject_failed',
|
|
552
|
-
publicMessage: 'failed to reject friend request',
|
|
553
|
-
context: { actorAgentId, friendRequestId },
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
return result.body || {};
|
|
557
|
-
}
|
|
558
|
-
|
|
559
436
|
async function createChatRequest({
|
|
560
437
|
runtimeConfig,
|
|
561
438
|
fromAgentId,
|
|
@@ -693,62 +570,6 @@ async function rejectChatRequest({
|
|
|
693
570
|
return result.body || {};
|
|
694
571
|
}
|
|
695
572
|
|
|
696
|
-
async function syncChatRequestApprovalPolicy({
|
|
697
|
-
runtimeConfig,
|
|
698
|
-
fetchImpl,
|
|
699
|
-
logger,
|
|
700
|
-
}) {
|
|
701
|
-
const baseUrl = normalizeRelayHttpBaseUrl(runtimeConfig.serverUrl);
|
|
702
|
-
let result;
|
|
703
|
-
try {
|
|
704
|
-
result = await fetchJson(fetchImpl, `${baseUrl}/v1/chat-requests/approval-policy`, {
|
|
705
|
-
method: 'PUT',
|
|
706
|
-
headers: {
|
|
707
|
-
'content-type': 'application/json',
|
|
708
|
-
...(runtimeConfig.apiKey ? { 'x-api-key': runtimeConfig.apiKey } : {}),
|
|
709
|
-
...buildRuntimeAuthHeaders(runtimeConfig),
|
|
710
|
-
},
|
|
711
|
-
body: JSON.stringify({
|
|
712
|
-
accountId: runtimeConfig.accountId || null,
|
|
713
|
-
approval: runtimeConfig.approval || {},
|
|
714
|
-
}),
|
|
715
|
-
});
|
|
716
|
-
} catch (error) {
|
|
717
|
-
logger.warn?.(`[claworld:${runtimeConfig.accountId || 'default'}] approval policy sync failed`, {
|
|
718
|
-
error: error?.message || String(error),
|
|
719
|
-
code: error?.code || null,
|
|
720
|
-
category: error?.category || null,
|
|
721
|
-
});
|
|
722
|
-
return {
|
|
723
|
-
ok: false,
|
|
724
|
-
status: error?.status || null,
|
|
725
|
-
body: null,
|
|
726
|
-
error,
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
if (!result.ok) {
|
|
730
|
-
logger.warn?.(`[claworld:${runtimeConfig.accountId || 'default'}] approval policy sync failed`, {
|
|
731
|
-
status: result.status,
|
|
732
|
-
body: result.body,
|
|
733
|
-
});
|
|
734
|
-
return {
|
|
735
|
-
ok: false,
|
|
736
|
-
status: result.status,
|
|
737
|
-
body: result.body,
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
logger.info?.(`[claworld:${runtimeConfig.accountId || 'default'}] approval policy sync ok`, {
|
|
742
|
-
mode: result.body?.approvalPolicy?.policy?.mode || runtimeConfig.approval?.mode || null,
|
|
743
|
-
syncedAt: result.body?.approvalPolicy?.syncedAt || null,
|
|
744
|
-
});
|
|
745
|
-
return {
|
|
746
|
-
ok: true,
|
|
747
|
-
status: result.status,
|
|
748
|
-
body: result.body,
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
|
|
752
573
|
function waitForAbort(signal) {
|
|
753
574
|
return new Promise((resolve) => {
|
|
754
575
|
if (!signal) return resolve({ reason: 'missing_abort_signal' });
|
|
@@ -932,7 +753,7 @@ async function fetchPublicIdentity({
|
|
|
932
753
|
recommendedDisplayName,
|
|
933
754
|
nextAction: 'set_public_identity',
|
|
934
755
|
requiredAction: 'set_public_identity',
|
|
935
|
-
nextTool: '
|
|
756
|
+
nextTool: 'claworld_account',
|
|
936
757
|
missingFields: [
|
|
937
758
|
{
|
|
938
759
|
fieldId: 'displayName',
|
|
@@ -963,6 +784,7 @@ async function fetchPublicIdentity({
|
|
|
963
784
|
...buildRuntimeAuthHeaders(runtimeConfig),
|
|
964
785
|
},
|
|
965
786
|
body: JSON.stringify({
|
|
787
|
+
accountId: runtimeConfig.accountId || null,
|
|
966
788
|
...(agentId ? { agentId } : {}),
|
|
967
789
|
action: 'view',
|
|
968
790
|
...(generateShareCard === true ? { generateShareCard: true } : {}),
|
|
@@ -1057,6 +879,7 @@ async function updatePublicIdentity({
|
|
|
1057
879
|
...buildRuntimeAuthHeaders(resolvedRuntimeConfig),
|
|
1058
880
|
},
|
|
1059
881
|
body: JSON.stringify({
|
|
882
|
+
accountId: resolvedRuntimeConfig.accountId || null,
|
|
1060
883
|
...(resolvedAgentId ? { agentId: resolvedAgentId } : {}),
|
|
1061
884
|
action: 'update_identity',
|
|
1062
885
|
displayName: normalizedDisplayName,
|
|
@@ -1089,6 +912,53 @@ async function updatePublicIdentity({
|
|
|
1089
912
|
};
|
|
1090
913
|
}
|
|
1091
914
|
|
|
915
|
+
async function updateChatRequestApprovalPolicy({
|
|
916
|
+
runtimeConfig,
|
|
917
|
+
agentId = null,
|
|
918
|
+
chatRequestApprovalPolicy = null,
|
|
919
|
+
fetchImpl,
|
|
920
|
+
}) {
|
|
921
|
+
if (!resolveRuntimeAppToken(runtimeConfig)) {
|
|
922
|
+
throw createRuntimeBoundaryError({
|
|
923
|
+
code: 'claworld_account_unactivated',
|
|
924
|
+
category: 'conflict',
|
|
925
|
+
status: 409,
|
|
926
|
+
message: 'claworld account must be activated before updating chat policy',
|
|
927
|
+
publicMessage: 'activate the Claworld account before changing chat policy',
|
|
928
|
+
recoverable: true,
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
const baseUrl = normalizeRelayHttpBaseUrl(runtimeConfig.serverUrl);
|
|
933
|
+
const result = await fetchJson(fetchImpl, `${baseUrl}/v1/profile`, {
|
|
934
|
+
method: 'POST',
|
|
935
|
+
headers: {
|
|
936
|
+
'content-type': 'application/json',
|
|
937
|
+
...(runtimeConfig.apiKey ? { 'x-api-key': runtimeConfig.apiKey } : {}),
|
|
938
|
+
...buildRuntimeAuthHeaders(runtimeConfig),
|
|
939
|
+
},
|
|
940
|
+
body: JSON.stringify({
|
|
941
|
+
accountId: runtimeConfig.accountId || null,
|
|
942
|
+
...(agentId ? { agentId } : {}),
|
|
943
|
+
action: 'update_chat_policy',
|
|
944
|
+
chatRequestApprovalPolicy,
|
|
945
|
+
}),
|
|
946
|
+
});
|
|
947
|
+
if (!result.ok) {
|
|
948
|
+
createRelayRouteError({
|
|
949
|
+
result,
|
|
950
|
+
runtimeConfig,
|
|
951
|
+
code: 'chat_request_approval_policy_update_failed',
|
|
952
|
+
publicMessage: 'failed to update chat policy',
|
|
953
|
+
context: {
|
|
954
|
+
accountId: runtimeConfig.accountId || null,
|
|
955
|
+
agentId: normalizeClaworldText(agentId, null),
|
|
956
|
+
},
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
return result.body || {};
|
|
960
|
+
}
|
|
961
|
+
|
|
1092
962
|
async function renderAgentCard({
|
|
1093
963
|
runtimeConfig,
|
|
1094
964
|
agentId = null,
|
|
@@ -2333,12 +2203,6 @@ export function createClaworldChannelPlugin({
|
|
|
2333
2203
|
}
|
|
2334
2204
|
}
|
|
2335
2205
|
|
|
2336
|
-
await syncChatRequestApprovalPolicy({
|
|
2337
|
-
runtimeConfig,
|
|
2338
|
-
fetchImpl,
|
|
2339
|
-
logger,
|
|
2340
|
-
});
|
|
2341
|
-
|
|
2342
2206
|
accountRuntimeContexts.set(accountKey, {
|
|
2343
2207
|
runtime: pluginRuntime,
|
|
2344
2208
|
cfg: context.cfg || null,
|
|
@@ -2518,7 +2382,7 @@ export function createClaworldChannelPlugin({
|
|
|
2518
2382
|
});
|
|
2519
2383
|
}
|
|
2520
2384
|
|
|
2521
|
-
|
|
2385
|
+
async function updateRuntimePublicIdentity(context = {}) {
|
|
2522
2386
|
const resolvedContext = resolveConfiguredRuntimeContext(context);
|
|
2523
2387
|
const updateResult = await updatePublicIdentity({
|
|
2524
2388
|
runtimeConfig: resolvedContext.runtimeConfig,
|
|
@@ -2577,9 +2441,19 @@ export function createClaworldChannelPlugin({
|
|
|
2577
2441
|
const payload = updateResult && typeof updateResult === 'object' && !Array.isArray(updateResult)
|
|
2578
2442
|
? { ...updateResult }
|
|
2579
2443
|
: {};
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2444
|
+
delete payload.runtimeConfig;
|
|
2445
|
+
return payload;
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
async function updateRuntimeChatRequestApprovalPolicy(context = {}) {
|
|
2449
|
+
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2450
|
+
return updateChatRequestApprovalPolicy({
|
|
2451
|
+
runtimeConfig: resolvedContext.runtimeConfig,
|
|
2452
|
+
agentId: resolvedContext.agentId || null,
|
|
2453
|
+
chatRequestApprovalPolicy: context.chatRequestApprovalPolicy || null,
|
|
2454
|
+
fetchImpl,
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2583
2457
|
|
|
2584
2458
|
async function generateRuntimeProfileCard(context = {}) {
|
|
2585
2459
|
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
@@ -2748,45 +2622,6 @@ export function createClaworldChannelPlugin({
|
|
|
2748
2622
|
}),
|
|
2749
2623
|
},
|
|
2750
2624
|
social: {
|
|
2751
|
-
sendFriendRequest: async (context = {}) => {
|
|
2752
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2753
|
-
return createFriendRequest({
|
|
2754
|
-
runtimeConfig: resolvedContext.runtimeConfig,
|
|
2755
|
-
fromAgentId: resolvedContext.agentId || null,
|
|
2756
|
-
targetAgentId: context.targetAgentId || null,
|
|
2757
|
-
message: context.message || null,
|
|
2758
|
-
metadata: context.metadata || {},
|
|
2759
|
-
fetchImpl,
|
|
2760
|
-
});
|
|
2761
|
-
},
|
|
2762
|
-
listFriendRequests: async (context = {}) => {
|
|
2763
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2764
|
-
return listFriendRequests({
|
|
2765
|
-
runtimeConfig: resolvedContext.runtimeConfig,
|
|
2766
|
-
agentId: resolvedContext.agentId || null,
|
|
2767
|
-
direction: context.direction || null,
|
|
2768
|
-
status: context.status || null,
|
|
2769
|
-
fetchImpl,
|
|
2770
|
-
});
|
|
2771
|
-
},
|
|
2772
|
-
acceptFriendRequest: async (context = {}) => {
|
|
2773
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2774
|
-
return acceptFriendRequest({
|
|
2775
|
-
runtimeConfig: resolvedContext.runtimeConfig,
|
|
2776
|
-
actorAgentId: resolvedContext.agentId || null,
|
|
2777
|
-
friendRequestId: context.friendRequestId || null,
|
|
2778
|
-
fetchImpl,
|
|
2779
|
-
});
|
|
2780
|
-
},
|
|
2781
|
-
rejectFriendRequest: async (context = {}) => {
|
|
2782
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2783
|
-
return rejectFriendRequest({
|
|
2784
|
-
runtimeConfig: resolvedContext.runtimeConfig,
|
|
2785
|
-
actorAgentId: resolvedContext.agentId || null,
|
|
2786
|
-
friendRequestId: context.friendRequestId || null,
|
|
2787
|
-
fetchImpl,
|
|
2788
|
-
});
|
|
2789
|
-
},
|
|
2790
2625
|
requestChat: async (context = {}) => {
|
|
2791
2626
|
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2792
2627
|
const requestContext = resolvedContext.requesterSessionKey
|
|
@@ -2815,15 +2650,6 @@ export function createClaworldChannelPlugin({
|
|
|
2815
2650
|
fetchImpl,
|
|
2816
2651
|
});
|
|
2817
2652
|
},
|
|
2818
|
-
listChatRequests: async (context = {}) => {
|
|
2819
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2820
|
-
return listChatInbox({
|
|
2821
|
-
runtimeConfig: resolvedContext.runtimeConfig,
|
|
2822
|
-
agentId: resolvedContext.agentId || null,
|
|
2823
|
-
direction: context.direction || null,
|
|
2824
|
-
fetchImpl,
|
|
2825
|
-
});
|
|
2826
|
-
},
|
|
2827
2653
|
acceptChatRequest: async (context = {}) => {
|
|
2828
2654
|
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2829
2655
|
return acceptChatRequest({
|
|
@@ -2846,6 +2672,7 @@ export function createClaworldChannelPlugin({
|
|
|
2846
2672
|
profile: {
|
|
2847
2673
|
getPublicIdentity: getRuntimePublicIdentity,
|
|
2848
2674
|
updatePublicIdentity: updateRuntimePublicIdentity,
|
|
2675
|
+
updateChatRequestApprovalPolicy: updateRuntimeChatRequestApprovalPolicy,
|
|
2849
2676
|
generateShareCard: generateRuntimeProfileCard,
|
|
2850
2677
|
},
|
|
2851
2678
|
postSetup: {
|
|
@@ -2899,34 +2726,6 @@ export function createClaworldChannelPlugin({
|
|
|
2899
2726
|
logger,
|
|
2900
2727
|
});
|
|
2901
2728
|
},
|
|
2902
|
-
fetchWorldSearch: async (context = {}) => {
|
|
2903
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2904
|
-
return fetchWorldSearch({
|
|
2905
|
-
cfg: resolvedContext.cfg || {},
|
|
2906
|
-
accountId: resolvedContext.accountId || null,
|
|
2907
|
-
runtimeConfig: resolvedContext.runtimeConfig || null,
|
|
2908
|
-
worldId: context.worldId || null,
|
|
2909
|
-
agentId: resolvedContext.agentId || null,
|
|
2910
|
-
query: context.query || {},
|
|
2911
|
-
limit: context.limit ?? null,
|
|
2912
|
-
fetchImpl,
|
|
2913
|
-
logger,
|
|
2914
|
-
});
|
|
2915
|
-
},
|
|
2916
|
-
submitWorldSearch: async (context = {}) => {
|
|
2917
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
2918
|
-
return submitWorldSearch({
|
|
2919
|
-
cfg: resolvedContext.cfg || {},
|
|
2920
|
-
accountId: resolvedContext.accountId || null,
|
|
2921
|
-
runtimeConfig: resolvedContext.runtimeConfig || null,
|
|
2922
|
-
worldId: context.worldId || null,
|
|
2923
|
-
agentId: resolvedContext.agentId || null,
|
|
2924
|
-
query: context.query || {},
|
|
2925
|
-
limit: context.limit ?? null,
|
|
2926
|
-
fetchImpl,
|
|
2927
|
-
logger,
|
|
2928
|
-
});
|
|
2929
|
-
},
|
|
2930
2729
|
resolveWorldSelection: (context = {}) => resolveWorldSelection(
|
|
2931
2730
|
context.worldDirectory || {},
|
|
2932
2731
|
context.selection ?? context.userChoice ?? null,
|
|
@@ -3001,6 +2800,7 @@ export function createClaworldChannelPlugin({
|
|
|
3001
2800
|
profile: {
|
|
3002
2801
|
getPublicIdentity: getRuntimePublicIdentity,
|
|
3003
2802
|
updatePublicIdentity: updateRuntimePublicIdentity,
|
|
2803
|
+
updateChatRequestApprovalPolicy: updateRuntimeChatRequestApprovalPolicy,
|
|
3004
2804
|
generateShareCard: generateRuntimeProfileCard,
|
|
3005
2805
|
},
|
|
3006
2806
|
fetchWorldDirectory: async (context = {}) => {
|
|
@@ -3054,52 +2854,6 @@ export function createClaworldChannelPlugin({
|
|
|
3054
2854
|
logger,
|
|
3055
2855
|
});
|
|
3056
2856
|
},
|
|
3057
|
-
fetchWorldSearch: async (context = {}) => {
|
|
3058
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
3059
|
-
return fetchWorldSearch({
|
|
3060
|
-
cfg: resolvedContext.cfg || {},
|
|
3061
|
-
accountId: resolvedContext.accountId || null,
|
|
3062
|
-
runtimeConfig: resolvedContext.runtimeConfig || null,
|
|
3063
|
-
worldId: context.worldId || null,
|
|
3064
|
-
agentId: resolvedContext.agentId || null,
|
|
3065
|
-
query: context.query || {},
|
|
3066
|
-
limit: context.limit ?? null,
|
|
3067
|
-
fetchImpl,
|
|
3068
|
-
logger,
|
|
3069
|
-
});
|
|
3070
|
-
},
|
|
3071
|
-
submitWorldSearch: async (context = {}) => {
|
|
3072
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
3073
|
-
return submitWorldSearch({
|
|
3074
|
-
cfg: resolvedContext.cfg || {},
|
|
3075
|
-
accountId: resolvedContext.accountId || null,
|
|
3076
|
-
runtimeConfig: resolvedContext.runtimeConfig || null,
|
|
3077
|
-
worldId: context.worldId || null,
|
|
3078
|
-
agentId: resolvedContext.agentId || null,
|
|
3079
|
-
query: context.query || {},
|
|
3080
|
-
limit: context.limit ?? null,
|
|
3081
|
-
fetchImpl,
|
|
3082
|
-
logger,
|
|
3083
|
-
});
|
|
3084
|
-
},
|
|
3085
|
-
broadcastWorld: async (context = {}) => {
|
|
3086
|
-
const resolvedContext = await resolveBoundRuntimeContext(context);
|
|
3087
|
-
return broadcastWorld({
|
|
3088
|
-
cfg: resolvedContext.cfg || {},
|
|
3089
|
-
accountId: resolvedContext.accountId || null,
|
|
3090
|
-
runtimeConfig: resolvedContext.runtimeConfig || null,
|
|
3091
|
-
worldId: context.worldId || null,
|
|
3092
|
-
agentId: resolvedContext.agentId || null,
|
|
3093
|
-
message: context.message || null,
|
|
3094
|
-
payload: context.payload || {},
|
|
3095
|
-
audience: context.audience || null,
|
|
3096
|
-
replyPolicy: context.replyPolicy || null,
|
|
3097
|
-
...(Object.prototype.hasOwnProperty.call(context, 'excludeSelf') ? { excludeSelf: context.excludeSelf } : {}),
|
|
3098
|
-
conversation: context.conversation || {},
|
|
3099
|
-
fetchImpl,
|
|
3100
|
-
logger,
|
|
3101
|
-
});
|
|
3102
|
-
},
|
|
3103
2857
|
resolveWorldSelection,
|
|
3104
2858
|
buildCandidateDeliverySummary,
|
|
3105
2859
|
resolveWorldSelectionFlow: async (context = {}) => {
|
|
@@ -3,12 +3,6 @@ import {
|
|
|
3
3
|
normalizeRuntimeRegistration,
|
|
4
4
|
resolveRuntimeAppToken,
|
|
5
5
|
} from './account-identity.js';
|
|
6
|
-
import {
|
|
7
|
-
CHAT_REQUEST_APPROVAL_POLICY_MODES,
|
|
8
|
-
CHAT_REQUEST_APPROVAL_POLICY_ORIGIN_TYPES,
|
|
9
|
-
DEFAULT_CHAT_REQUEST_APPROVAL_POLICY_MODE,
|
|
10
|
-
normalizeChatRequestApprovalPolicy,
|
|
11
|
-
} from '../../product-shell/contracts/chat-request-approval-policy.js';
|
|
12
6
|
|
|
13
7
|
const REQUIRED_KEYS = ['enabled', 'serverUrl', 'apiKey', 'accountId'];
|
|
14
8
|
|
|
@@ -124,45 +118,6 @@ const SINGLE_ACCOUNT_PROPERTIES = {
|
|
|
124
118
|
},
|
|
125
119
|
},
|
|
126
120
|
},
|
|
127
|
-
approval: {
|
|
128
|
-
type: 'object',
|
|
129
|
-
additionalProperties: false,
|
|
130
|
-
properties: {
|
|
131
|
-
mode: {
|
|
132
|
-
type: 'string',
|
|
133
|
-
enum: [...CHAT_REQUEST_APPROVAL_POLICY_MODES],
|
|
134
|
-
description: 'Declarative inbound chat-request approval policy for this account.',
|
|
135
|
-
default: DEFAULT_CHAT_REQUEST_APPROVAL_POLICY_MODE,
|
|
136
|
-
},
|
|
137
|
-
blocks: {
|
|
138
|
-
type: 'object',
|
|
139
|
-
additionalProperties: false,
|
|
140
|
-
properties: {
|
|
141
|
-
originTypes: {
|
|
142
|
-
type: 'array',
|
|
143
|
-
items: {
|
|
144
|
-
type: 'string',
|
|
145
|
-
enum: [...CHAT_REQUEST_APPROVAL_POLICY_ORIGIN_TYPES],
|
|
146
|
-
},
|
|
147
|
-
description: 'Optional canonical chat-request origin types that should be rejected by backend policy.',
|
|
148
|
-
},
|
|
149
|
-
worldIds: {
|
|
150
|
-
type: 'array',
|
|
151
|
-
items: {
|
|
152
|
-
type: 'string',
|
|
153
|
-
minLength: 1,
|
|
154
|
-
},
|
|
155
|
-
description: 'Optional world ids that should be rejected by backend policy.',
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
autoAccept: {
|
|
160
|
-
type: 'boolean',
|
|
161
|
-
description: 'Legacy alias. `true` maps to `approval.mode = "open"` and `false` maps to `approval.mode = "manual_review"`.',
|
|
162
|
-
default: false,
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
121
|
testing: {
|
|
167
122
|
type: 'object',
|
|
168
123
|
additionalProperties: false,
|
|
@@ -204,7 +159,7 @@ export const claworldChannelConfigJsonSchema = {
|
|
|
204
159
|
export const claworldChannelConfigSchema = {
|
|
205
160
|
channelId: CLAWORLD_CHANNEL_ID,
|
|
206
161
|
required: REQUIRED_KEYS,
|
|
207
|
-
optional: ['name', 'heartbeatSeconds', 'reconnect', 'routing', '
|
|
162
|
+
optional: ['name', 'heartbeatSeconds', 'reconnect', 'routing', 'testing', 'appToken', 'registration', 'relay', 'toolProfile', 'defaultAccount', 'accounts'],
|
|
208
163
|
jsonSchema: claworldChannelConfigJsonSchema,
|
|
209
164
|
description:
|
|
210
165
|
'最小 OpenClaw claworld channel 配置;支持单账号或 accounts.<id> 多账号模式。canonical flow uses appToken + registration.displayName bootstrap.',
|
|
@@ -284,12 +239,6 @@ export function validateClaworldChannelConfig(config = {}, accountId = null) {
|
|
|
284
239
|
const errors = [];
|
|
285
240
|
const registration = normalizeRuntimeRegistration(candidate);
|
|
286
241
|
const appToken = resolveRuntimeAppToken(candidate);
|
|
287
|
-
const approval = normalizeChatRequestApprovalPolicy(candidate.approval, {
|
|
288
|
-
legacyAutoAccept: typeof candidate.approval?.autoAccept === 'boolean'
|
|
289
|
-
? candidate.approval.autoAccept
|
|
290
|
-
: null,
|
|
291
|
-
});
|
|
292
|
-
|
|
293
242
|
const configuredIds = listConfiguredClaworldAccountIds(config);
|
|
294
243
|
const hasMultipleAccounts = configuredIds.length > 1;
|
|
295
244
|
const explicitDefaultAccount = String(root?.defaultAccount || '').trim();
|
|
@@ -354,7 +303,6 @@ export function validateClaworldChannelConfig(config = {}, accountId = null) {
|
|
|
354
303
|
fallbackTarget,
|
|
355
304
|
allowHumanInterrupt: candidate.routing?.allowHumanInterrupt !== false,
|
|
356
305
|
},
|
|
357
|
-
approval,
|
|
358
306
|
testing: {
|
|
359
307
|
allowBridgedCommandDispatch: candidate.testing?.allowBridgedCommandDispatch === true,
|
|
360
308
|
},
|
|
@@ -391,7 +339,6 @@ export function inspectClaworldChannelAccount(config = {}, accountId = null) {
|
|
|
391
339
|
heartbeatSeconds: normalized.heartbeatSeconds,
|
|
392
340
|
reconnect: normalized.reconnect,
|
|
393
341
|
routing: normalized.routing,
|
|
394
|
-
approval: normalized.approval,
|
|
395
342
|
testing: normalized.testing,
|
|
396
343
|
appToken: normalized.appToken || null,
|
|
397
344
|
registration: normalized.registration,
|
|
@@ -421,7 +368,6 @@ export function resolveClaworldRuntimeConfig(config = {}, accountId = null) {
|
|
|
421
368
|
return {
|
|
422
369
|
...result.normalized,
|
|
423
370
|
accountId: result.normalized.accountId || accountId || readDefaultAccountId(config) || 'default',
|
|
424
|
-
approval: result.normalized.approval,
|
|
425
371
|
relay: result.normalized.relay,
|
|
426
372
|
};
|
|
427
373
|
}
|