@xfxstudio/claworld 0.2.7 → 0.2.8
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skills/claworld-help/SKILL.md +2 -2
- package/skills/claworld-join-and-chat/SKILL.md +9 -18
- package/src/lib/chat-request.js +0 -19
- package/src/lib/relay/kickoff-text.js +1 -6
- package/src/openclaw/installer/doctor.js +63 -0
- package/src/openclaw/plugin/claworld-channel-plugin.js +49 -30
- package/src/openclaw/plugin/managed-config.js +110 -0
- package/src/openclaw/plugin/register.js +199 -93
- package/src/openclaw/plugin/relay-client.js +14 -4
- package/src/openclaw/runtime/tool-contracts.js +1 -40
- package/src/openclaw/runtime/tool-inventory.js +3 -2
- package/src/openclaw/runtime/world-moderation-helper.js +2 -0
- package/src/product-shell/social/chat-request-routes.js +1 -4
- package/src/product-shell/social/chat-request-service.js +15 -162
- package/src/product-shell/worlds/world-admin-service.js +52 -12
- package/src/product-shell/worlds/world-routes.js +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createClaworldChannelPlugin } from './claworld-channel-plugin.js';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
projectToolChatRequestListResponse,
|
|
4
4
|
projectToolChatRequestMutationResponse,
|
|
5
5
|
projectToolCreateWorldResponse,
|
|
6
6
|
projectToolManagedWorldResponse,
|
|
@@ -19,8 +19,6 @@ import {
|
|
|
19
19
|
normalizeRuntimeBoundaryError,
|
|
20
20
|
} from '../../lib/runtime-errors.js';
|
|
21
21
|
|
|
22
|
-
const INTERNAL_REQUESTER_SESSION_KEY_PARAM = '__claworldRequesterSessionKey';
|
|
23
|
-
|
|
24
22
|
function normalizeText(value, fallback = null) {
|
|
25
23
|
if (value == null) return fallback;
|
|
26
24
|
const normalized = String(value).trim();
|
|
@@ -168,7 +166,6 @@ async function resolveToolContext(api, plugin, params = {}) {
|
|
|
168
166
|
accountId,
|
|
169
167
|
runtimeConfig,
|
|
170
168
|
agentId: normalizeText(params.agentId, runtimeConfig.relay?.agentId || null),
|
|
171
|
-
requesterSessionKey: normalizeText(params[INTERNAL_REQUESTER_SESSION_KEY_PARAM], null),
|
|
172
169
|
});
|
|
173
170
|
}
|
|
174
171
|
|
|
@@ -178,7 +175,6 @@ async function resolveToolContext(api, plugin, params = {}) {
|
|
|
178
175
|
accountId,
|
|
179
176
|
runtimeConfig,
|
|
180
177
|
agentId,
|
|
181
|
-
requesterSessionKey: normalizeText(params[INTERNAL_REQUESTER_SESSION_KEY_PARAM], null),
|
|
182
178
|
};
|
|
183
179
|
}
|
|
184
180
|
|
|
@@ -266,6 +262,56 @@ function buildToolMetadata({
|
|
|
266
262
|
};
|
|
267
263
|
}
|
|
268
264
|
|
|
265
|
+
const MANAGE_WORLD_ACTIONS = Object.freeze([
|
|
266
|
+
'list',
|
|
267
|
+
'get',
|
|
268
|
+
'update_context',
|
|
269
|
+
'pause',
|
|
270
|
+
'close',
|
|
271
|
+
'resume',
|
|
272
|
+
]);
|
|
273
|
+
|
|
274
|
+
function normalizeManageWorldAction(value, fallback = null) {
|
|
275
|
+
const normalized = normalizeText(value, fallback);
|
|
276
|
+
return MANAGE_WORLD_ACTIONS.includes(normalized) ? normalized : fallback;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function inferManageWorldAction(params = {}) {
|
|
280
|
+
const explicitAction = normalizeManageWorldAction(params.action, null);
|
|
281
|
+
if (explicitAction) return explicitAction;
|
|
282
|
+
if (!normalizeText(params.worldId, null)) return 'list';
|
|
283
|
+
if (normalizeText(params.worldContextText, null) || normalizeText(params.displayName, null)) {
|
|
284
|
+
return 'update_context';
|
|
285
|
+
}
|
|
286
|
+
return 'get';
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function requireManageWorldField(fieldId, message = `${fieldId} is required`) {
|
|
290
|
+
throw createRuntimeBoundaryError({
|
|
291
|
+
code: 'tool_input_invalid',
|
|
292
|
+
category: 'input',
|
|
293
|
+
status: 400,
|
|
294
|
+
message,
|
|
295
|
+
publicMessage: message,
|
|
296
|
+
recoverable: true,
|
|
297
|
+
context: { field: fieldId },
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function projectToolManageWorldActionResponse(payload = {}, { accountId = null, action = null } = {}) {
|
|
302
|
+
const resolvedAction = normalizeManageWorldAction(action, null) || 'get';
|
|
303
|
+
if (resolvedAction === 'list') {
|
|
304
|
+
return {
|
|
305
|
+
action: resolvedAction,
|
|
306
|
+
...projectToolOwnedWorldsResponse(payload, { accountId }),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
action: resolvedAction,
|
|
311
|
+
...projectToolManagedWorldResponse(payload, { accountId }),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
269
315
|
function buildRegisteredTools(api, plugin) {
|
|
270
316
|
const accountIdProperty = stringParam({
|
|
271
317
|
description: 'Claworld account id to execute the tool against. In managed installs this is usually the dedicated claworld account.',
|
|
@@ -509,67 +555,31 @@ function buildRegisteredTools(api, plugin) {
|
|
|
509
555
|
},
|
|
510
556
|
},
|
|
511
557
|
{
|
|
512
|
-
name: '
|
|
513
|
-
label: 'Claworld
|
|
514
|
-
description: '
|
|
558
|
+
name: 'claworld_manage_world',
|
|
559
|
+
label: 'Claworld Manage World',
|
|
560
|
+
description: 'Unified owner-only world governance tool. List owned worlds, inspect one world, update worldContextText, or change world lifecycle to paused/closed/enabled.',
|
|
515
561
|
metadata: buildToolMetadata({
|
|
516
562
|
category: 'world_management',
|
|
517
563
|
usageNotes: [
|
|
518
|
-
'Use
|
|
519
|
-
'
|
|
520
|
-
'
|
|
564
|
+
'Use action=list to inspect the worlds owned by the current account.',
|
|
565
|
+
'Use action=get to inspect one owned world before changing it.',
|
|
566
|
+
'Use action=update_context to change worldContextText and optional displayName.',
|
|
567
|
+
'Use action=pause, action=close, or action=resume for owner-only lifecycle changes.',
|
|
521
568
|
],
|
|
522
569
|
examples: [
|
|
523
570
|
{
|
|
524
571
|
title: 'List owned worlds',
|
|
525
572
|
input: {
|
|
526
573
|
accountId: 'claworld',
|
|
574
|
+
action: 'list',
|
|
527
575
|
},
|
|
528
576
|
outcome: 'Returns owner-managed worlds for the current account.',
|
|
529
577
|
},
|
|
530
|
-
],
|
|
531
|
-
}),
|
|
532
|
-
parameters: objectParam({
|
|
533
|
-
description: 'Minimal payload for listing worlds owned by the current account.',
|
|
534
|
-
required: ['accountId'],
|
|
535
|
-
properties: {
|
|
536
|
-
accountId: accountIdProperty,
|
|
537
|
-
includeDisabled: {
|
|
538
|
-
type: 'boolean',
|
|
539
|
-
description: 'Whether to include disabled or draft owned worlds.',
|
|
540
|
-
},
|
|
541
|
-
},
|
|
542
|
-
examples: [
|
|
543
|
-
{
|
|
544
|
-
accountId: 'claworld',
|
|
545
|
-
},
|
|
546
|
-
],
|
|
547
|
-
}),
|
|
548
|
-
async execute(_toolCallId, params = {}) {
|
|
549
|
-
const context = await resolveToolContext(api, plugin, params);
|
|
550
|
-
const payload = await plugin.runtime.productShell.moderation.listOwnedWorlds({
|
|
551
|
-
...context,
|
|
552
|
-
includeDisabled: params.includeDisabled !== false,
|
|
553
|
-
});
|
|
554
|
-
return buildToolResult(projectToolOwnedWorldsResponse(payload, { accountId: context.accountId }));
|
|
555
|
-
},
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
name: 'claworld_manage_world',
|
|
559
|
-
label: 'Claworld Manage World',
|
|
560
|
-
description: 'Owner-only world management tool. Update the canonical worldContextText for one owner-managed world, with optional displayName/enabled changes.',
|
|
561
|
-
metadata: buildToolMetadata({
|
|
562
|
-
category: 'world_management',
|
|
563
|
-
usageNotes: [
|
|
564
|
-
'Use only when the current agent owns the target world.',
|
|
565
|
-
'This is the minimal management tool on the current public surface.',
|
|
566
|
-
'Prefer updating worldContextText directly instead of editing legacy world schema fields.',
|
|
567
|
-
],
|
|
568
|
-
examples: [
|
|
569
578
|
{
|
|
570
579
|
title: 'Update one owned world context',
|
|
571
580
|
input: {
|
|
572
581
|
accountId: 'claworld',
|
|
582
|
+
action: 'update_context',
|
|
573
583
|
worldId: 'ugc-weekend-debate-club',
|
|
574
584
|
worldContextText: '世界:Weekend Debate Club [ugc-weekend-debate-club]\n简介:A creator-managed world for short structured debates.\n互动规则:Debate one topic at a time and stay concise.',
|
|
575
585
|
},
|
|
@@ -578,29 +588,39 @@ function buildRegisteredTools(api, plugin) {
|
|
|
578
588
|
],
|
|
579
589
|
}),
|
|
580
590
|
parameters: objectParam({
|
|
581
|
-
description: '
|
|
582
|
-
required: ['accountId'
|
|
591
|
+
description: 'Owner-only world governance payload. action=list replaces the old list_owned_worlds tool.',
|
|
592
|
+
required: ['accountId'],
|
|
583
593
|
properties: {
|
|
584
594
|
accountId: accountIdProperty,
|
|
595
|
+
action: stringParam({
|
|
596
|
+
description: 'Owner-only governance action. If omitted, the tool infers list/get/update_context from the provided fields.',
|
|
597
|
+
enumValues: MANAGE_WORLD_ACTIONS,
|
|
598
|
+
examples: ['list'],
|
|
599
|
+
}),
|
|
585
600
|
worldId: worldIdProperty,
|
|
586
601
|
worldContextText: stringParam({
|
|
587
|
-
description: 'Replacement canonical world context text for
|
|
602
|
+
description: 'Replacement canonical world context text for update_context.',
|
|
588
603
|
minLength: 1,
|
|
589
604
|
examples: ['世界:Weekend Debate Club [ugc-weekend-debate-club]\n简介:A creator-managed world for short structured debates.\n互动规则:Debate one topic at a time and stay concise.'],
|
|
590
605
|
}),
|
|
591
606
|
displayName: stringParam({
|
|
592
|
-
description: 'Optional new display name
|
|
607
|
+
description: 'Optional new display name when action=update_context.',
|
|
593
608
|
minLength: 1,
|
|
594
609
|
examples: ['Weekend Debate Club'],
|
|
595
610
|
}),
|
|
596
|
-
|
|
611
|
+
includeDisabled: {
|
|
597
612
|
type: 'boolean',
|
|
598
|
-
description: '
|
|
613
|
+
description: 'Whether action=list should include paused, closed, or draft owned worlds.',
|
|
599
614
|
},
|
|
600
615
|
},
|
|
601
616
|
examples: [
|
|
602
617
|
{
|
|
603
618
|
accountId: 'claworld',
|
|
619
|
+
action: 'list',
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
accountId: 'claworld',
|
|
623
|
+
action: 'update_context',
|
|
604
624
|
worldId: 'ugc-weekend-debate-club',
|
|
605
625
|
worldContextText: '世界:Weekend Debate Club [ugc-weekend-debate-club]\n简介:A creator-managed world for short structured debates.\n互动规则:Debate one topic at a time and stay concise.',
|
|
606
626
|
},
|
|
@@ -608,18 +628,72 @@ function buildRegisteredTools(api, plugin) {
|
|
|
608
628
|
}),
|
|
609
629
|
async execute(_toolCallId, params = {}) {
|
|
610
630
|
const context = await resolveToolContext(api, plugin, params);
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
631
|
+
if (Object.prototype.hasOwnProperty.call(params, 'action')
|
|
632
|
+
&& !normalizeManageWorldAction(params.action, null)) {
|
|
633
|
+
requireManageWorldField('action', 'action must be one of list, get, update_context, pause, close, or resume');
|
|
634
|
+
}
|
|
635
|
+
const action = inferManageWorldAction(params);
|
|
636
|
+
if (action === 'list') {
|
|
637
|
+
const payload = await plugin.runtime.productShell.moderation.listOwnedWorlds({
|
|
638
|
+
...context,
|
|
639
|
+
includeDisabled: params.includeDisabled !== false,
|
|
640
|
+
});
|
|
641
|
+
return buildToolResult(projectToolManageWorldActionResponse(payload, {
|
|
642
|
+
accountId: context.accountId,
|
|
643
|
+
action,
|
|
644
|
+
}));
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const worldId = normalizeText(params.worldId, null);
|
|
648
|
+
if (!worldId) requireManageWorldField('worldId');
|
|
649
|
+
|
|
650
|
+
if (action === 'get') {
|
|
651
|
+
const payload = await plugin.runtime.productShell.moderation.manageWorld({
|
|
652
|
+
...context,
|
|
653
|
+
worldId,
|
|
654
|
+
mode: 'get',
|
|
655
|
+
});
|
|
656
|
+
return buildToolResult(projectToolManageWorldActionResponse(payload, {
|
|
657
|
+
accountId: context.accountId,
|
|
658
|
+
action,
|
|
659
|
+
}));
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (action === 'update_context') {
|
|
663
|
+
const worldContextText = normalizeText(params.worldContextText, null);
|
|
664
|
+
if (!worldContextText) requireManageWorldField('worldContextText');
|
|
665
|
+
const payload = await plugin.runtime.productShell.moderation.manageWorld({
|
|
666
|
+
...context,
|
|
667
|
+
worldId,
|
|
668
|
+
mode: 'patch',
|
|
669
|
+
changes: {
|
|
670
|
+
worldContextText,
|
|
671
|
+
...(normalizeText(params.displayName, null) ? { displayName: normalizeText(params.displayName, null) } : {}),
|
|
672
|
+
},
|
|
673
|
+
});
|
|
674
|
+
return buildToolResult(projectToolManageWorldActionResponse(payload, {
|
|
675
|
+
accountId: context.accountId,
|
|
676
|
+
action,
|
|
677
|
+
}));
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const statusByAction = {
|
|
681
|
+
pause: 'paused',
|
|
682
|
+
close: 'closed',
|
|
683
|
+
resume: 'enabled',
|
|
614
684
|
};
|
|
685
|
+
const status = statusByAction[action] || null;
|
|
615
686
|
const payload = await plugin.runtime.productShell.moderation.manageWorld({
|
|
616
687
|
...context,
|
|
617
|
-
worldId
|
|
688
|
+
worldId,
|
|
618
689
|
mode: 'patch',
|
|
619
|
-
|
|
620
|
-
|
|
690
|
+
status,
|
|
691
|
+
enabled: action === 'resume',
|
|
621
692
|
});
|
|
622
|
-
return buildToolResult(
|
|
693
|
+
return buildToolResult(projectToolManageWorldActionResponse(payload, {
|
|
694
|
+
accountId: context.accountId,
|
|
695
|
+
action,
|
|
696
|
+
}));
|
|
623
697
|
},
|
|
624
698
|
},
|
|
625
699
|
{
|
|
@@ -630,7 +704,7 @@ function buildRegisteredTools(api, plugin) {
|
|
|
630
704
|
category: 'chat_request',
|
|
631
705
|
usageNotes: [
|
|
632
706
|
'For world-scoped chat, use the targetAgentId returned by claworld_join_world.',
|
|
633
|
-
'After creation, use
|
|
707
|
+
'After creation, use claworld_list_chat_requests or wait for the peer to accept.',
|
|
634
708
|
'Once accepted, the runtime owns the live conversation loop.',
|
|
635
709
|
],
|
|
636
710
|
examples: [
|
|
@@ -684,36 +758,33 @@ function buildRegisteredTools(api, plugin) {
|
|
|
684
758
|
},
|
|
685
759
|
},
|
|
686
760
|
{
|
|
687
|
-
name: '
|
|
688
|
-
label: 'Claworld Chat
|
|
689
|
-
description: 'Canonical
|
|
761
|
+
name: 'claworld_list_chat_requests',
|
|
762
|
+
label: 'Claworld List Chat Requests',
|
|
763
|
+
description: 'Canonical review tool for pending chat requests after request_chat or before accept_chat_request.',
|
|
690
764
|
metadata: buildToolMetadata({
|
|
691
765
|
category: 'chat_request',
|
|
692
766
|
usageNotes: [
|
|
693
|
-
'Use to review
|
|
694
|
-
'Use
|
|
695
|
-
'If the user asks about one chat, first locate it here, then use your local session-send tool to ask that local session for a progress update or short summary.',
|
|
696
|
-
'Prefer asking the local chat session for a concise update before inspecting raw local transcript details.',
|
|
697
|
-
'Use direction=outbound when focusing on chats you initiated.',
|
|
767
|
+
'Use to review inbound requests waiting for acceptance.',
|
|
768
|
+
'Use direction=outbound when checking whether a previously-created request is still pending.',
|
|
698
769
|
],
|
|
699
770
|
examples: [
|
|
700
771
|
{
|
|
701
|
-
title: 'Review inbound
|
|
772
|
+
title: 'Review inbound requests',
|
|
702
773
|
input: {
|
|
703
774
|
accountId: 'claworld',
|
|
704
775
|
direction: 'inbound',
|
|
705
776
|
},
|
|
706
|
-
outcome: 'Returns pending
|
|
777
|
+
outcome: 'Returns the current pending or accepted chat requests for the current account.',
|
|
707
778
|
},
|
|
708
779
|
],
|
|
709
780
|
}),
|
|
710
781
|
parameters: objectParam({
|
|
711
|
-
description: '
|
|
782
|
+
description: 'List direct or world-scoped chat requests for the current account.',
|
|
712
783
|
required: ['accountId'],
|
|
713
784
|
properties: {
|
|
714
785
|
accountId: accountIdProperty,
|
|
715
786
|
direction: stringParam({
|
|
716
|
-
description: 'Filter to inbound
|
|
787
|
+
description: 'Filter to inbound requests you can review or outbound requests you previously created.',
|
|
717
788
|
enumValues: ['inbound', 'outbound'],
|
|
718
789
|
examples: ['inbound'],
|
|
719
790
|
}),
|
|
@@ -727,11 +798,11 @@ function buildRegisteredTools(api, plugin) {
|
|
|
727
798
|
}),
|
|
728
799
|
async execute(_toolCallId, params = {}) {
|
|
729
800
|
const context = await resolveToolContext(api, plugin, params);
|
|
730
|
-
const payload = await plugin.helpers.social.
|
|
801
|
+
const payload = await plugin.helpers.social.listChatRequests({
|
|
731
802
|
...context,
|
|
732
803
|
direction: params.direction || null,
|
|
733
804
|
});
|
|
734
|
-
return buildToolResult(
|
|
805
|
+
return buildToolResult(projectToolChatRequestListResponse(payload, { accountId: context.accountId }));
|
|
735
806
|
},
|
|
736
807
|
},
|
|
737
808
|
{
|
|
@@ -741,7 +812,7 @@ function buildRegisteredTools(api, plugin) {
|
|
|
741
812
|
metadata: buildToolMetadata({
|
|
742
813
|
category: 'chat_request',
|
|
743
814
|
usageNotes: [
|
|
744
|
-
'Use the chatRequestId returned by
|
|
815
|
+
'Use the chatRequestId returned by claworld_list_chat_requests.',
|
|
745
816
|
'After acceptance, do not try to send a separate raw message tool call; wait for runtime-owned live conversation.',
|
|
746
817
|
],
|
|
747
818
|
examples: [
|
|
@@ -761,7 +832,7 @@ function buildRegisteredTools(api, plugin) {
|
|
|
761
832
|
properties: {
|
|
762
833
|
accountId: accountIdProperty,
|
|
763
834
|
chatRequestId: stringParam({
|
|
764
|
-
description: 'Canonical chat request id returned by
|
|
835
|
+
description: 'Canonical chat request id returned by claworld_list_chat_requests.',
|
|
765
836
|
minLength: 1,
|
|
766
837
|
examples: ['req_demo_1'],
|
|
767
838
|
}),
|
|
@@ -782,6 +853,54 @@ function buildRegisteredTools(api, plugin) {
|
|
|
782
853
|
return buildToolResult(projectToolChatRequestMutationResponse(payload, { accountId: context.accountId }));
|
|
783
854
|
},
|
|
784
855
|
},
|
|
856
|
+
{
|
|
857
|
+
name: 'claworld_reject_chat_request',
|
|
858
|
+
label: 'Claworld Reject Chat Request',
|
|
859
|
+
description: 'Canonical rejection tool for one inbound chat request. Use this when the current account explicitly declines the request instead of accepting it.',
|
|
860
|
+
metadata: buildToolMetadata({
|
|
861
|
+
category: 'chat_request',
|
|
862
|
+
usageNotes: [
|
|
863
|
+
'Use the chatRequestId returned by claworld_list_chat_requests.',
|
|
864
|
+
'Use only for inbound requests that the current account wants to reject.',
|
|
865
|
+
],
|
|
866
|
+
examples: [
|
|
867
|
+
{
|
|
868
|
+
title: 'Reject one inbound request',
|
|
869
|
+
input: {
|
|
870
|
+
accountId: 'claworld',
|
|
871
|
+
chatRequestId: 'req_demo_1',
|
|
872
|
+
},
|
|
873
|
+
outcome: 'Marks the request rejected and returns the closed request projection.',
|
|
874
|
+
},
|
|
875
|
+
],
|
|
876
|
+
}),
|
|
877
|
+
parameters: objectParam({
|
|
878
|
+
description: 'Reject one inbound chat request for the current account.',
|
|
879
|
+
required: ['accountId', 'chatRequestId'],
|
|
880
|
+
properties: {
|
|
881
|
+
accountId: accountIdProperty,
|
|
882
|
+
chatRequestId: stringParam({
|
|
883
|
+
description: 'Canonical chat request id returned by claworld_list_chat_requests.',
|
|
884
|
+
minLength: 1,
|
|
885
|
+
examples: ['req_demo_1'],
|
|
886
|
+
}),
|
|
887
|
+
},
|
|
888
|
+
examples: [
|
|
889
|
+
{
|
|
890
|
+
accountId: 'claworld',
|
|
891
|
+
chatRequestId: 'req_demo_1',
|
|
892
|
+
},
|
|
893
|
+
],
|
|
894
|
+
}),
|
|
895
|
+
async execute(_toolCallId, params = {}) {
|
|
896
|
+
const context = await resolveToolContext(api, plugin, params);
|
|
897
|
+
const payload = await plugin.helpers.social.rejectChatRequest({
|
|
898
|
+
...context,
|
|
899
|
+
chatRequestId: params.chatRequestId,
|
|
900
|
+
});
|
|
901
|
+
return buildToolResult(projectToolChatRequestMutationResponse(payload, { accountId: context.accountId }));
|
|
902
|
+
},
|
|
903
|
+
},
|
|
785
904
|
{
|
|
786
905
|
name: 'claworld_submit_feedback',
|
|
787
906
|
label: 'Claworld Submit Feedback',
|
|
@@ -1014,19 +1133,6 @@ export function registerClaworldPluginFull(api, plugin) {
|
|
|
1014
1133
|
if (!plugin) {
|
|
1015
1134
|
throw new Error('registerClaworldPluginFull requires a plugin instance');
|
|
1016
1135
|
}
|
|
1017
|
-
if (typeof api.on === 'function') {
|
|
1018
|
-
api.on('before_tool_call', async (event, ctx) => {
|
|
1019
|
-
if (event?.toolName !== 'claworld_request_chat') return;
|
|
1020
|
-
const requesterSessionKey = normalizeText(ctx?.sessionKey, null);
|
|
1021
|
-
if (!requesterSessionKey) return;
|
|
1022
|
-
return {
|
|
1023
|
-
params: {
|
|
1024
|
-
...(event?.params && typeof event.params === 'object' && !Array.isArray(event.params) ? event.params : {}),
|
|
1025
|
-
[INTERNAL_REQUESTER_SESSION_KEY_PARAM]: requesterSessionKey,
|
|
1026
|
-
},
|
|
1027
|
-
};
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
1136
|
if (typeof api.registerHttpRoute === 'function') {
|
|
1031
1137
|
api.registerHttpRoute(buildClaworldStatusRoute(plugin));
|
|
1032
1138
|
}
|
|
@@ -564,7 +564,7 @@ export class ClaworldRelayClient extends EventEmitter {
|
|
|
564
564
|
config,
|
|
565
565
|
agentId,
|
|
566
566
|
credential = null,
|
|
567
|
-
clientVersion = 'claworld-plugin/0.
|
|
567
|
+
clientVersion = 'claworld-plugin/0.1.5',
|
|
568
568
|
sessionTarget,
|
|
569
569
|
fallbackTarget,
|
|
570
570
|
} = {}) {
|
|
@@ -978,6 +978,7 @@ export class ClaworldRelayClient extends EventEmitter {
|
|
|
978
978
|
stage: 'reply_fallback',
|
|
979
979
|
deliveryId: envelope.deliveryId,
|
|
980
980
|
sessionKey: envelope.sessionKey,
|
|
981
|
+
fallbackFrom: error?.code || error?.message || null,
|
|
981
982
|
}),
|
|
982
983
|
});
|
|
983
984
|
}
|
|
@@ -1116,9 +1117,6 @@ export class ClaworldRelayClient extends EventEmitter {
|
|
|
1116
1117
|
kickoffBrief: normalized.kickoffBrief || null,
|
|
1117
1118
|
openingMessage: normalized.openingMessage || null,
|
|
1118
1119
|
worldId: normalized.conversation?.worldId || null,
|
|
1119
|
-
requestContext: requestContext && typeof requestContext === 'object' && !Array.isArray(requestContext)
|
|
1120
|
-
? requestContext
|
|
1121
|
-
: undefined,
|
|
1122
1120
|
}),
|
|
1123
1121
|
}, {
|
|
1124
1122
|
code: 'relay_request_create_failed',
|
|
@@ -1151,6 +1149,18 @@ export class ClaworldRelayClient extends EventEmitter {
|
|
|
1151
1149
|
return result;
|
|
1152
1150
|
}
|
|
1153
1151
|
|
|
1152
|
+
async rejectChatRequest(requestId, { actorAgentId, ...options } = {}) {
|
|
1153
|
+
return await this.requestJson(`/v1/chat-requests/${requestId}/reject`, {
|
|
1154
|
+
method: 'POST',
|
|
1155
|
+
headers: buildRuntimeAuthHeaders(this.runtimeConfig, { 'content-type': 'application/json' }),
|
|
1156
|
+
body: JSON.stringify({ actorAgentId, ...options }),
|
|
1157
|
+
}, {
|
|
1158
|
+
code: 'relay_request_reject_failed',
|
|
1159
|
+
message: 'failed to reject relay chat request',
|
|
1160
|
+
publicMessage: 'failed to reject relay chat request',
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1154
1164
|
async deliverMessage({ fromAgentId, toAddress, payload = {}, conversation = {} } = {}) {
|
|
1155
1165
|
return await this.requestJson('/v1/messages', {
|
|
1156
1166
|
method: 'POST',
|
|
@@ -391,7 +391,7 @@ export function projectToolOwnedWorldsResponse(payload = {}, { accountId = null
|
|
|
391
391
|
? payload.items.map((world) => ({
|
|
392
392
|
worldId: world.worldId,
|
|
393
393
|
displayName: world.displayName,
|
|
394
|
-
|
|
394
|
+
worldContextText: normalizeText(world.worldContextText, null),
|
|
395
395
|
enabled: normalizeOptionalBoolean(world.enabled, null),
|
|
396
396
|
status: normalizeText(world.status, null),
|
|
397
397
|
worldRole: projectWorldRole(world.worldRole, null),
|
|
@@ -622,22 +622,6 @@ function projectChatRequestItem(request = {}) {
|
|
|
622
622
|
};
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
-
function projectChatInboxChatItem(chat = {}) {
|
|
626
|
-
if (!chat || typeof chat !== 'object' || Array.isArray(chat)) return null;
|
|
627
|
-
return {
|
|
628
|
-
chatRequestId: normalizeText(chat.chatRequestId, null),
|
|
629
|
-
status: normalizeText(chat.status, null),
|
|
630
|
-
direction: normalizeText(chat.direction, null),
|
|
631
|
-
createdAt: normalizeText(chat.createdAt, null),
|
|
632
|
-
updatedAt: normalizeText(chat.updatedAt, null),
|
|
633
|
-
lastTurnAt: normalizeText(chat.lastTurnAt, null),
|
|
634
|
-
conversationKey: normalizeText(chat.conversationKey, null),
|
|
635
|
-
localSessionKey: normalizeText(chat.localSessionKey, normalizeText(chat.sessionKey, null)),
|
|
636
|
-
counterparty: projectToolAgentSummary(chat.counterparty),
|
|
637
|
-
conversation: normalizeConversationScopeDetails(chat.conversation),
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
|
|
641
625
|
export function projectToolFriendRequestMutationResponse(result = {}, { accountId = null } = {}) {
|
|
642
626
|
return {
|
|
643
627
|
status: result.alreadyFriends === true
|
|
@@ -706,26 +690,3 @@ export function projectToolChatRequestListResponse(result = {}, { accountId = nu
|
|
|
706
690
|
items,
|
|
707
691
|
};
|
|
708
692
|
}
|
|
709
|
-
|
|
710
|
-
export function projectToolChatInboxResponse(result = {}, { accountId = null } = {}) {
|
|
711
|
-
const pendingRequests = Array.isArray(result.pendingRequests)
|
|
712
|
-
? result.pendingRequests.map((request) => projectChatRequestItem(request)).filter(Boolean)
|
|
713
|
-
: [];
|
|
714
|
-
const chats = Array.isArray(result.chats)
|
|
715
|
-
? result.chats.map((chat) => projectChatInboxChatItem(chat)).filter(Boolean)
|
|
716
|
-
: [];
|
|
717
|
-
return {
|
|
718
|
-
accountId: normalizeText(accountId, null),
|
|
719
|
-
counts: result.counts && typeof result.counts === 'object' && !Array.isArray(result.counts)
|
|
720
|
-
? {
|
|
721
|
-
pendingRequestCount: normalizeInteger(result.counts.pendingRequestCount, pendingRequests.length),
|
|
722
|
-
chatCount: normalizeInteger(result.counts.chatCount, chats.length),
|
|
723
|
-
}
|
|
724
|
-
: {
|
|
725
|
-
pendingRequestCount: pendingRequests.length,
|
|
726
|
-
chatCount: chats.length,
|
|
727
|
-
},
|
|
728
|
-
pendingRequests,
|
|
729
|
-
chats,
|
|
730
|
-
};
|
|
731
|
-
}
|
|
@@ -2,8 +2,9 @@ export const CLAWORLD_TOOL_CONTRACT_VERSION = 'v1';
|
|
|
2
2
|
|
|
3
3
|
export const CLAWORLD_CHAT_REQUEST_TOOL_NAMES = Object.freeze([
|
|
4
4
|
'claworld_request_chat',
|
|
5
|
-
'
|
|
5
|
+
'claworld_list_chat_requests',
|
|
6
6
|
'claworld_accept_chat_request',
|
|
7
|
+
'claworld_reject_chat_request',
|
|
7
8
|
]);
|
|
8
9
|
|
|
9
10
|
export const CLAWORLD_BOOTSTRAP_TOOL_NAMES = Object.freeze([
|
|
@@ -22,11 +23,11 @@ export const CLAWORLD_WORLD_TOOL_NAMES = Object.freeze([
|
|
|
22
23
|
|
|
23
24
|
export const CLAWORLD_WORLD_ADMIN_PUBLIC_TOOL_NAMES = Object.freeze([
|
|
24
25
|
'claworld_create_world',
|
|
25
|
-
'claworld_list_owned_worlds',
|
|
26
26
|
'claworld_manage_world',
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
29
|
export const CLAWORLD_COMPATIBILITY_TOOL_NAMES = Object.freeze([
|
|
30
|
+
'claworld_list_owned_worlds',
|
|
30
31
|
'claworld_prepare_world_join',
|
|
31
32
|
'claworld_search_world',
|
|
32
33
|
]);
|
|
@@ -287,6 +287,7 @@ export async function manageModeratedWorld({
|
|
|
287
287
|
mode = 'get',
|
|
288
288
|
changes = null,
|
|
289
289
|
enabled = null,
|
|
290
|
+
status = null,
|
|
290
291
|
fetchImpl,
|
|
291
292
|
logger = console,
|
|
292
293
|
} = {}) {
|
|
@@ -340,6 +341,7 @@ export async function manageModeratedWorld({
|
|
|
340
341
|
agentId: resolvedAgentId,
|
|
341
342
|
...(changes && typeof changes === 'object' ? { changes } : {}),
|
|
342
343
|
...(enabled == null ? {} : { enabled }),
|
|
344
|
+
...(normalizeText(status, null) ? { status: normalizeText(status, null) } : {}),
|
|
343
345
|
}),
|
|
344
346
|
});
|
|
345
347
|
|
|
@@ -56,10 +56,7 @@ export function registerChatRequestRoutes(app, { chatRequestService, store }) {
|
|
|
56
56
|
targetAgentId: req.body?.targetAgentId,
|
|
57
57
|
kickoffBrief: req.body?.kickoffBrief,
|
|
58
58
|
openingMessage: req.body?.openingMessage,
|
|
59
|
-
openingPayload: req.body?.openingPayload,
|
|
60
59
|
worldId: req.body?.worldId,
|
|
61
|
-
requestContext: req.body?.requestContext,
|
|
62
|
-
source: req.body?.source,
|
|
63
60
|
});
|
|
64
61
|
res.status(201).json(result);
|
|
65
62
|
} catch (error) {
|
|
@@ -78,7 +75,7 @@ export function registerChatRequestRoutes(app, { chatRequestService, store }) {
|
|
|
78
75
|
if (!authAgent.agentId) return sendMissingAgentIdentity(res);
|
|
79
76
|
|
|
80
77
|
try {
|
|
81
|
-
const result = chatRequestService.
|
|
78
|
+
const result = chatRequestService.listChatRequests({
|
|
82
79
|
agentId: authAgent.agentId,
|
|
83
80
|
direction: req.query.direction,
|
|
84
81
|
});
|