@xfxstudio/claworld 0.1.5 → 0.2.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.
- package/README.md +12 -29
- package/openclaw.plugin.json +5 -29
- package/package.json +4 -12
- package/skills/claworld-help/SKILL.md +50 -182
- package/skills/claworld-join-and-chat/SKILL.md +78 -288
- package/skills/claworld-manage-worlds/SKILL.md +71 -288
- package/src/lib/chat-request.js +347 -0
- package/src/lib/{accepted-chat-kickoff.js → relay/kickoff-text.js} +67 -26
- package/src/openclaw/index.js +0 -5
- package/src/openclaw/installer/cli.js +18 -9
- package/src/openclaw/installer/core.js +12 -6
- package/src/openclaw/installer/doctor.js +69 -31
- package/src/openclaw/installer/workspace-contract.js +33 -9
- package/src/openclaw/plugin/claworld-channel-plugin.js +118 -623
- package/src/openclaw/plugin/config-schema.js +3 -15
- package/src/openclaw/plugin/managed-config.js +98 -47
- package/src/openclaw/plugin/onboarding.js +7 -3
- package/src/openclaw/plugin/register.js +37 -336
- package/src/openclaw/plugin/relay-client.js +111 -101
- package/src/openclaw/protocol/relay-event-protocol.js +34 -22
- package/src/openclaw/runtime/canonical-result-builder.js +15 -5
- package/src/openclaw/runtime/demo-session-bootstrap.js +0 -4
- package/src/openclaw/runtime/feedback-helper.js +3 -2
- package/src/openclaw/runtime/inbound-session-router.js +28 -20
- package/src/openclaw/runtime/outbound-session-bridge.js +21 -9
- package/src/openclaw/runtime/product-shell-helper.js +43 -636
- package/src/openclaw/runtime/runtime-path.js +2 -2
- package/src/openclaw/runtime/system-message-orchestrator.js +1 -1
- package/src/openclaw/runtime/tool-contracts.js +33 -258
- package/src/openclaw/runtime/world-moderation-helper.js +11 -65
- package/src/product-shell/catalog/default-world-catalog.js +9 -27
- package/src/product-shell/contracts/candidate-feed.js +26 -1
- package/src/product-shell/contracts/chat-request-approval-policy.js +4 -4
- package/src/product-shell/contracts/world-manifest.js +115 -160
- package/src/product-shell/contracts/world-orchestration.js +47 -322
- package/src/product-shell/feedback/feedback-routes.js +4 -3
- package/src/product-shell/feedback/feedback-service.js +11 -8
- package/src/product-shell/index.js +5 -6
- package/src/product-shell/membership/membership-service.js +125 -147
- package/src/product-shell/onboarding/onboarding-service.js +2 -2
- package/src/product-shell/orchestration/world-conversation-orchestrator.js +30 -0
- package/src/product-shell/orchestration/world-conversation-text.js +231 -0
- package/src/product-shell/results/result-service.js +9 -3
- package/src/product-shell/search/search-service.js +28 -1
- package/src/product-shell/social/chat-request-routes.js +0 -1
- package/src/product-shell/social/chat-request-service.js +1 -102
- package/src/product-shell/worlds/world-admin-service.js +85 -276
- package/src/product-shell/worlds/world-authorization.js +3 -5
- package/src/product-shell/worlds/world-routes.js +8 -38
- package/src/product-shell/worlds/world-service.js +3 -3
- package/src/product-shell/worlds/world-text.js +77 -0
- package/src/lib/runtime-guidance.js +0 -457
- package/src/openclaw/runtime/world-session-startup.js +0 -1
- package/src/product-shell/orchestration/session-orchestrator.js +0 -38
|
@@ -37,6 +37,16 @@ function normalizeComparableText(value) {
|
|
|
37
37
|
return normalizeText(value, null)?.toLowerCase() || null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function tokenizeText(value) {
|
|
41
|
+
return [...new Set(
|
|
42
|
+
String(value || '')
|
|
43
|
+
.toLowerCase()
|
|
44
|
+
.split(/[^a-z0-9\u4e00-\u9fff]+/i)
|
|
45
|
+
.map((entry) => entry.trim())
|
|
46
|
+
.filter((entry) => entry.length >= 2),
|
|
47
|
+
)];
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
function normalizeSearchLimit(limit, fallback = 10) {
|
|
41
51
|
const normalized = normalizeInteger(limit, fallback);
|
|
42
52
|
if (normalized <= 0) return fallback;
|
|
@@ -133,6 +143,23 @@ function compareField(field, queryValue, candidateValue, worldId) {
|
|
|
133
143
|
|
|
134
144
|
const weights = resolveFieldWeight(worldId, field);
|
|
135
145
|
|
|
146
|
+
if (field.fieldId === 'participantContextText') {
|
|
147
|
+
const queryTokens = tokenizeText(queryValue);
|
|
148
|
+
const candidateTokens = tokenizeText(candidateValue);
|
|
149
|
+
const sharedValues = queryTokens.filter((entry) => candidateTokens.includes(entry));
|
|
150
|
+
if (sharedValues.length === 0) return null;
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
fieldId: field.fieldId,
|
|
154
|
+
label: field.label,
|
|
155
|
+
matchType: 'overlap',
|
|
156
|
+
queryValue: normalizeText(queryValue, ''),
|
|
157
|
+
candidateValue: normalizeText(candidateValue, ''),
|
|
158
|
+
sharedValues,
|
|
159
|
+
contribution: Math.min(sharedValues.length * 8, 48),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
136
163
|
if (field.type === 'string[]') {
|
|
137
164
|
const queryItems = normalizeStringList(queryValue);
|
|
138
165
|
const candidateItems = normalizeStringList(candidateValue);
|
|
@@ -180,7 +207,7 @@ function projectSummaryField(field, profile = {}) {
|
|
|
180
207
|
function projectProfileSummary(world, profile = {}, agent = null) {
|
|
181
208
|
return {
|
|
182
209
|
displayName: normalizeText(agent?.displayName, null),
|
|
183
|
-
headline: normalizeText(profile.headline, null),
|
|
210
|
+
headline: normalizeText(profile.participantContextText, normalizeText(profile.headline, null)),
|
|
184
211
|
requiredFields: world.joinSchema.requiredFields
|
|
185
212
|
.map((field) => projectSummaryField(field, profile))
|
|
186
213
|
.filter(Boolean),
|
|
@@ -57,7 +57,6 @@ export function registerChatRequestRoutes(app, { chatRequestService, store }) {
|
|
|
57
57
|
kickoffBrief: req.body?.kickoffBrief,
|
|
58
58
|
openingMessage: req.body?.openingMessage,
|
|
59
59
|
worldId: req.body?.worldId,
|
|
60
|
-
episodePolicy: req.body?.episodePolicy,
|
|
61
60
|
});
|
|
62
61
|
res.status(201).json(result);
|
|
63
62
|
} catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeAgentProfile, resolveAgentDisplayName, resolveAgentVisibility } from '../../lib/agent-profile.js';
|
|
2
|
-
import { createKickoffBrief, resolveStoredKickoffBrief } from '../../lib/
|
|
2
|
+
import { createKickoffBrief, resolveStoredKickoffBrief } from '../../lib/relay/kickoff-text.js';
|
|
3
3
|
import { WORLD_ACTIONS } from '../worlds/world-authorization.js';
|
|
4
4
|
import { normalizeChatRequestApprovalPolicy } from '../contracts/chat-request-approval-policy.js';
|
|
5
5
|
import {
|
|
@@ -39,87 +39,6 @@ function normalizeConversationWorldId(value) {
|
|
|
39
39
|
return normalizeText(value, null);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function parseEpisodePolicy(episodePolicy = null) {
|
|
43
|
-
if (episodePolicy == null) return { value: null, error: null };
|
|
44
|
-
if (!episodePolicy || typeof episodePolicy !== 'object' || Array.isArray(episodePolicy)) {
|
|
45
|
-
return {
|
|
46
|
-
value: null,
|
|
47
|
-
error: {
|
|
48
|
-
code: 'chat_request_episode_policy_invalid',
|
|
49
|
-
message: 'episodePolicy must be an object',
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const hasMaxTurns = Object.prototype.hasOwnProperty.call(episodePolicy, 'maxTurns');
|
|
55
|
-
const hasTurnTimeoutMs = Object.prototype.hasOwnProperty.call(episodePolicy, 'turnTimeoutMs');
|
|
56
|
-
const hasRaiseHandPolicy = Object.prototype.hasOwnProperty.call(episodePolicy, 'raiseHandPolicy');
|
|
57
|
-
|
|
58
|
-
const maxTurns = !hasMaxTurns
|
|
59
|
-
? null
|
|
60
|
-
: episodePolicy.maxTurns === null
|
|
61
|
-
? null
|
|
62
|
-
: normalizePositiveInteger(episodePolicy.maxTurns, null);
|
|
63
|
-
if (hasMaxTurns && episodePolicy.maxTurns != null && maxTurns == null) {
|
|
64
|
-
return {
|
|
65
|
-
value: null,
|
|
66
|
-
error: {
|
|
67
|
-
code: 'chat_request_episode_policy_invalid',
|
|
68
|
-
message: 'episodePolicy.maxTurns must be a positive integer',
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const turnTimeoutMs = !hasTurnTimeoutMs
|
|
74
|
-
? null
|
|
75
|
-
: episodePolicy.turnTimeoutMs === null
|
|
76
|
-
? null
|
|
77
|
-
: normalizePositiveInteger(episodePolicy.turnTimeoutMs, null);
|
|
78
|
-
if (hasTurnTimeoutMs && episodePolicy.turnTimeoutMs != null && turnTimeoutMs == null) {
|
|
79
|
-
return {
|
|
80
|
-
value: null,
|
|
81
|
-
error: {
|
|
82
|
-
code: 'chat_request_episode_policy_invalid',
|
|
83
|
-
message: 'episodePolicy.turnTimeoutMs must be a positive integer',
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
hasRaiseHandPolicy
|
|
90
|
-
&& episodePolicy.raiseHandPolicy != null
|
|
91
|
-
&& (
|
|
92
|
-
typeof episodePolicy.raiseHandPolicy !== 'object'
|
|
93
|
-
|| Array.isArray(episodePolicy.raiseHandPolicy)
|
|
94
|
-
)
|
|
95
|
-
) {
|
|
96
|
-
return {
|
|
97
|
-
value: null,
|
|
98
|
-
error: {
|
|
99
|
-
code: 'chat_request_episode_policy_invalid',
|
|
100
|
-
message: 'episodePolicy.raiseHandPolicy must be an object',
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const raiseHandPolicy = cloneJsonObject(episodePolicy.raiseHandPolicy);
|
|
106
|
-
const value = {
|
|
107
|
-
...(maxTurns != null ? { maxTurns } : {}),
|
|
108
|
-
...(turnTimeoutMs != null ? { turnTimeoutMs } : {}),
|
|
109
|
-
...(raiseHandPolicy ? { raiseHandPolicy } : {}),
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
value: Object.keys(value).length > 0 ? value : null,
|
|
114
|
-
error: null,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function projectEpisodePolicy(conversation = {}) {
|
|
119
|
-
const parsed = parseEpisodePolicy(conversation);
|
|
120
|
-
return parsed.error ? null : parsed.value;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
42
|
function sortByRecency(items = [], ...fieldNames) {
|
|
124
43
|
return items.slice().sort((left, right) => {
|
|
125
44
|
for (const fieldName of fieldNames) {
|
|
@@ -267,8 +186,6 @@ function projectKickoff(kickoff = {}) {
|
|
|
267
186
|
return {
|
|
268
187
|
status: normalizeText(kickoff.status, 'skipped'),
|
|
269
188
|
deliveredAt: normalizeText(kickoff.deliveredAt, null),
|
|
270
|
-
relaySessionPreparedAt: normalizeText(kickoff.relaySessionPreparedAt, null),
|
|
271
|
-
acceptedRoundPreparedAt: normalizeText(kickoff.acceptedRoundPreparedAt, null),
|
|
272
189
|
senderKickoffDeliveredAt: normalizeText(kickoff.senderKickoffDeliveredAt, normalizeText(kickoff.deliveredAt, null)),
|
|
273
190
|
openerAcceptedAt: normalizeText(kickoff.openerAcceptedAt, null),
|
|
274
191
|
openerDeliveredAt: normalizeText(kickoff.openerDeliveredAt, null),
|
|
@@ -399,8 +316,6 @@ export function createChatRequestService({
|
|
|
399
316
|
: {};
|
|
400
317
|
const worldId = normalizeConversationWorldId(conversation.worldId)
|
|
401
318
|
|| normalizeConversationWorldId(requestContext.conversation?.worldId);
|
|
402
|
-
const episodePolicy = projectEpisodePolicy(conversation)
|
|
403
|
-
|| projectEpisodePolicy(requestContext.conversation || {});
|
|
404
319
|
const counterpartyAgentId =
|
|
405
320
|
viewerAgentId === request.fromAgentId
|
|
406
321
|
? request.toAgentId
|
|
@@ -430,7 +345,6 @@ export function createChatRequestService({
|
|
|
430
345
|
mode: worldId ? 'world' : 'direct',
|
|
431
346
|
worldId,
|
|
432
347
|
world: projectWorldSummary(worldService, worldId),
|
|
433
|
-
...(episodePolicy ? { episodePolicy } : {}),
|
|
434
348
|
},
|
|
435
349
|
};
|
|
436
350
|
}
|
|
@@ -474,7 +388,6 @@ export function createChatRequestService({
|
|
|
474
388
|
openingMessage = null,
|
|
475
389
|
openingPayload = null,
|
|
476
390
|
worldId = null,
|
|
477
|
-
episodePolicy = null,
|
|
478
391
|
origin = null,
|
|
479
392
|
broadcast = null,
|
|
480
393
|
source = 'chat_request',
|
|
@@ -505,20 +418,7 @@ export function createChatRequestService({
|
|
|
505
418
|
});
|
|
506
419
|
const normalizedOrigin = normalizeChatRequestOrigin(origin);
|
|
507
420
|
const normalizedBroadcast = normalizeChatRequestBroadcastMetadata(broadcast);
|
|
508
|
-
const normalizedEpisodePolicy = parseEpisodePolicy(episodePolicy);
|
|
509
|
-
if (normalizedEpisodePolicy.error) {
|
|
510
|
-
throw createInvalidChatRequestError(
|
|
511
|
-
normalizedEpisodePolicy.error.code,
|
|
512
|
-
normalizedEpisodePolicy.error.message,
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
421
|
if (normalizedWorldId) {
|
|
516
|
-
if (normalizedEpisodePolicy.value) {
|
|
517
|
-
throw createInvalidChatRequestError(
|
|
518
|
-
'world_chat_request_episode_policy_not_supported',
|
|
519
|
-
'world-scoped chat requests inherit episode policy from the world template',
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
422
|
worldService?.requireWorld?.(normalizedWorldId);
|
|
523
423
|
if (normalizeText(source, 'chat_request') !== 'world_broadcast') {
|
|
524
424
|
const authorization = worldAuthorizationService.evaluateWorldAction({
|
|
@@ -543,7 +443,6 @@ export function createChatRequestService({
|
|
|
543
443
|
openingPayload: cloneJsonObject(normalizedKickoffBrief?.payload) || normalizedOpeningPayload,
|
|
544
444
|
conversation: {
|
|
545
445
|
...(normalizedWorldId ? { worldId: normalizedWorldId } : {}),
|
|
546
|
-
...(normalizedEpisodePolicy.value || {}),
|
|
547
446
|
},
|
|
548
447
|
origin: normalizedOrigin,
|
|
549
448
|
broadcast: normalizedBroadcast,
|