@xfxstudio/claworld 0.2.13 → 0.2.14

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.
Files changed (57) hide show
  1. package/README.md +4 -4
  2. package/index.js +0 -1
  3. package/openclaw.plugin.json +1 -1
  4. package/package.json +1 -1
  5. package/skills/claworld-help/SKILL.md +19 -27
  6. package/skills/claworld-join-and-chat/SKILL.md +9 -9
  7. package/src/openclaw/index.js +0 -3
  8. package/src/openclaw/plugin/account-identity.js +0 -1
  9. package/src/openclaw/plugin/claworld-channel-plugin.js +8 -253
  10. package/src/openclaw/plugin/managed-config.js +1 -7
  11. package/src/openclaw/plugin/onboarding.js +1 -1
  12. package/src/openclaw/plugin/register.js +183 -232
  13. package/src/openclaw/plugin/relay-client.js +8 -5
  14. package/src/openclaw/runtime/product-shell-helper.js +11 -364
  15. package/src/openclaw/runtime/tool-contracts.js +0 -182
  16. package/src/openclaw/runtime/tool-inventory.js +4 -27
  17. package/src/lib/agent-profile.js +0 -74
  18. package/src/lib/http-auth.js +0 -151
  19. package/src/lib/policy.js +0 -114
  20. package/src/openclaw/installer/constants.js +0 -14
  21. package/src/product-shell/agent-cards/card-routes.js +0 -64
  22. package/src/product-shell/agent-cards/card-service.js +0 -287
  23. package/src/product-shell/agent-cards/spec-builder.js +0 -167
  24. package/src/product-shell/agent-cards/storage/image-host-storage.js +0 -192
  25. package/src/product-shell/agent-cards/storage/local-public-storage.js +0 -74
  26. package/src/product-shell/agent-cards/svg-renderer.js +0 -325
  27. package/src/product-shell/agent-cards/template-registry.js +0 -131
  28. package/src/product-shell/catalog/default-world-catalog.js +0 -38
  29. package/src/product-shell/contracts/candidate-feed.js +0 -393
  30. package/src/product-shell/contracts/world-manifest.js +0 -369
  31. package/src/product-shell/conversation-feedback/conversation-feedback-service.js +0 -261
  32. package/src/product-shell/feedback/feedback-contract.js +0 -13
  33. package/src/product-shell/feedback/feedback-routes.js +0 -98
  34. package/src/product-shell/feedback/feedback-service.js +0 -252
  35. package/src/product-shell/index.js +0 -212
  36. package/src/product-shell/matching/matchmaking-service.js +0 -395
  37. package/src/product-shell/membership/membership-service.js +0 -284
  38. package/src/product-shell/onboarding/onboarding-routes.js +0 -37
  39. package/src/product-shell/onboarding/onboarding-service.js +0 -222
  40. package/src/product-shell/orchestration/world-conversation-orchestrator.js +0 -28
  41. package/src/product-shell/profile/profile-service.js +0 -142
  42. package/src/product-shell/profile/public-identity-routes.js +0 -160
  43. package/src/product-shell/profile/public-identity-service.js +0 -192
  44. package/src/product-shell/search/search-service.js +0 -393
  45. package/src/product-shell/social/chat-request-approval-policy.js +0 -332
  46. package/src/product-shell/social/chat-request-routes.js +0 -130
  47. package/src/product-shell/social/chat-request-service.js +0 -723
  48. package/src/product-shell/social/friend-routes.js +0 -82
  49. package/src/product-shell/social/friend-service.js +0 -557
  50. package/src/product-shell/social/social-routes.js +0 -21
  51. package/src/product-shell/social/social-service.js +0 -136
  52. package/src/product-shell/worlds/world-admin-service.js +0 -486
  53. package/src/product-shell/worlds/world-authorization.js +0 -136
  54. package/src/product-shell/worlds/world-broadcast-service.js +0 -296
  55. package/src/product-shell/worlds/world-routes.js +0 -403
  56. package/src/product-shell/worlds/world-service.js +0 -89
  57. package/src/product-shell/worlds/world-text.js +0 -75
@@ -1,136 +0,0 @@
1
- function normalizeText(value, fallback = null) {
2
- if (value == null) return fallback;
3
- const normalized = String(value).trim();
4
- return normalized || fallback;
5
- }
6
-
7
- export const WORLD_ROLES = Object.freeze({
8
- OWNER: 'owner',
9
- MEMBER: 'member',
10
- });
11
-
12
- export const WORLD_ACTIONS = Object.freeze({
13
- VIEW_MANAGEMENT: 'view_world_management',
14
- MANAGE_WORLD: 'manage_world',
15
- CHANGE_ENABLED_STATE: 'change_world_enabled_state',
16
- BROADCAST: 'broadcast_world',
17
- SEARCH: 'search_world',
18
- VIEW_CANDIDATE_FEED: 'view_world_candidate_feed',
19
- CREATE_CHAT_REQUEST: 'create_world_chat_request',
20
- });
21
-
22
- function resolveWorldRole({ isOwner = false, isMember = false } = {}) {
23
- if (isOwner) return WORLD_ROLES.OWNER;
24
- if (isMember) return WORLD_ROLES.MEMBER;
25
- return null;
26
- }
27
-
28
- function resolveEffectiveRoles({ isOwner = false, isMember = false } = {}) {
29
- const roles = [];
30
- if (isOwner) {
31
- roles.push(WORLD_ROLES.OWNER);
32
- // World owners should retain member-scoped capabilities for worlds they are actively in.
33
- if (isMember) roles.push(WORLD_ROLES.MEMBER);
34
- return roles;
35
- }
36
- if (isMember) roles.push(WORLD_ROLES.MEMBER);
37
- return roles;
38
- }
39
-
40
- function resolveActionRequirement(action) {
41
- switch (action) {
42
- case WORLD_ACTIONS.VIEW_MANAGEMENT:
43
- case WORLD_ACTIONS.MANAGE_WORLD:
44
- case WORLD_ACTIONS.BROADCAST:
45
- case WORLD_ACTIONS.CHANGE_ENABLED_STATE:
46
- return {
47
- allowedRoles: [WORLD_ROLES.OWNER],
48
- reason: 'owner_role_required',
49
- };
50
- case WORLD_ACTIONS.SEARCH:
51
- case WORLD_ACTIONS.VIEW_CANDIDATE_FEED:
52
- case WORLD_ACTIONS.CREATE_CHAT_REQUEST:
53
- return {
54
- allowedRoles: [WORLD_ROLES.MEMBER],
55
- reason: 'active_membership_required',
56
- requiredMembershipStatus: 'active',
57
- };
58
- default:
59
- return {
60
- allowedRoles: [],
61
- reason: 'unknown_action',
62
- };
63
- }
64
- }
65
-
66
- export function createWorldAuthorizationService({ worldService, membershipService } = {}) {
67
- function resolveMembership(worldId, agentId, { includeDisabled = false } = {}) {
68
- const normalizedAgentId = normalizeText(agentId, null);
69
- if (!normalizedAgentId || !membershipService || typeof membershipService.getMembership !== 'function') {
70
- return null;
71
- }
72
- return membershipService.getMembership({
73
- worldId,
74
- agentId: normalizedAgentId,
75
- includeDisabled,
76
- });
77
- }
78
-
79
- function resolveWorldActorContextForWorld(world, actorAgentId, { includeDisabled = false } = {}) {
80
- const normalizedActorAgentId = normalizeText(actorAgentId, null);
81
- const membership = normalizedActorAgentId
82
- ? resolveMembership(world.worldId, normalizedActorAgentId, { includeDisabled })
83
- : null;
84
- const isOwner = normalizedActorAgentId != null && normalizedActorAgentId === world.creatorAgentId;
85
- const isMember = membership?.status === 'active';
86
- const worldRole = resolveWorldRole({ isOwner, isMember });
87
- const effectiveRoles = resolveEffectiveRoles({ isOwner, isMember });
88
-
89
- return {
90
- world,
91
- actorAgentId: normalizedActorAgentId,
92
- worldRole,
93
- effectiveRoles,
94
- managementRole: isOwner ? WORLD_ROLES.OWNER : null,
95
- membership,
96
- membershipStatus: membership?.status || null,
97
- roles: {
98
- owner: isOwner,
99
- member: isMember,
100
- },
101
- };
102
- }
103
-
104
- return {
105
- resolveWorldActorContext({ worldId, actorAgentId, includeDisabled = false } = {}) {
106
- const world = worldService.requireWorld(worldId, { includeDisabled });
107
- return resolveWorldActorContextForWorld(world, actorAgentId, { includeDisabled });
108
- },
109
-
110
- evaluateWorldAction({ worldId, actorAgentId, action, includeDisabled = false } = {}) {
111
- const actor = this.resolveWorldActorContext({
112
- worldId,
113
- actorAgentId,
114
- includeDisabled,
115
- });
116
- const requirement = resolveActionRequirement(action);
117
- const allowed = actor.effectiveRoles.some((role) => requirement.allowedRoles.includes(role));
118
-
119
- return {
120
- ...actor,
121
- action,
122
- allowed,
123
- allowedRoles: requirement.allowedRoles,
124
- requiredMembershipStatus: requirement.requiredMembershipStatus || null,
125
- reason: allowed ? 'authorized' : requirement.reason,
126
- };
127
- },
128
-
129
- listManagedWorlds({ actorAgentId, includeDisabled = true } = {}) {
130
- return worldService
131
- .listOwnedWorlds({ creatorAgentId: actorAgentId, includeDisabled })
132
- .map((world) => resolveWorldActorContextForWorld(world, actorAgentId, { includeDisabled }))
133
- .filter((context) => context.managementRole != null);
134
- },
135
- };
136
- }
@@ -1,296 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- import { WORLD_ACTIONS } from './world-authorization.js';
3
-
4
- function normalizeText(value, fallback = null) {
5
- if (value == null) return fallback;
6
- const normalized = String(value).trim();
7
- return normalized || fallback;
8
- }
9
-
10
- function cloneJsonObject(value) {
11
- if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
12
- try {
13
- const cloned = JSON.parse(JSON.stringify(value));
14
- if (!cloned || typeof cloned !== 'object' || Array.isArray(cloned)) return null;
15
- return cloned;
16
- } catch {
17
- return null;
18
- }
19
- }
20
-
21
- function normalizeBoolean(value, fallback = null) {
22
- if (typeof value === 'boolean') return value;
23
- return fallback;
24
- }
25
-
26
- function normalizeWorldEligibility(value, fallback = 'active') {
27
- const normalized = normalizeText(value, fallback);
28
- if (normalized === 'joined') return 'joined';
29
- return 'active';
30
- }
31
-
32
- function normalizeBroadcastAudience(value, fallback = 'members') {
33
- const normalized = normalizeText(value, fallback);
34
- if (normalized === 'admins') return 'admins';
35
- if (normalized === 'admins_and_owner') return 'admins_and_owner';
36
- return 'members';
37
- }
38
-
39
- function createBroadcastId() {
40
- return `brd_${uuidv4()}`;
41
- }
42
-
43
- function createConfigurationError() {
44
- const error = new Error('world_broadcast_unavailable');
45
- error.code = 'world_broadcast_unavailable';
46
- error.status = 500;
47
- return error;
48
- }
49
-
50
- function createInvalidBroadcastRequestError(fieldId, message = `${fieldId} is required`) {
51
- const error = new Error(`invalid_broadcast_request:${fieldId}`);
52
- error.code = 'invalid_broadcast_request';
53
- error.status = 400;
54
- error.responseBody = {
55
- error: error.code,
56
- message: 'broadcast request is invalid',
57
- fieldErrors: [
58
- {
59
- fieldId,
60
- message,
61
- },
62
- ],
63
- };
64
- return error;
65
- }
66
-
67
- function createBroadcastDisabledError(worldId) {
68
- const error = new Error(`broadcast_disabled:${worldId}`);
69
- error.code = 'broadcast_disabled';
70
- error.status = 403;
71
- error.responseBody = {
72
- error: error.code,
73
- message: 'broadcast is not enabled for this world',
74
- worldId,
75
- };
76
- return error;
77
- }
78
-
79
- function createBroadcastNotAllowedError({ worldId, senderAgentId, senderRole } = {}) {
80
- const error = new Error(`broadcast_not_allowed:${worldId}:${senderAgentId}`);
81
- error.code = 'broadcast_not_allowed';
82
- error.status = 403;
83
- error.responseBody = {
84
- error: error.code,
85
- message: 'sender does not have permission to broadcast in this world',
86
- worldId,
87
- senderAgentId,
88
- senderRole,
89
- allowedRoles: ['owner'],
90
- };
91
- return error;
92
- }
93
-
94
- function resolveMemberStatuses(world = {}) {
95
- const eligibility = normalizeWorldEligibility(world.eligibility, 'active');
96
- return eligibility === 'joined' ? new Set(['joined', 'active']) : new Set(['active']);
97
- }
98
-
99
- function dedupeAgentIds(agentIds = [], { excludeAgentId = null } = {}) {
100
- const seen = new Set();
101
- const items = [];
102
- for (const rawAgentId of agentIds) {
103
- const agentId = normalizeText(rawAgentId, null);
104
- if (!agentId || seen.has(agentId)) continue;
105
- if (excludeAgentId && agentId === excludeAgentId) continue;
106
- seen.add(agentId);
107
- items.push(agentId);
108
- }
109
- return items;
110
- }
111
-
112
- function normalizeBroadcastCreationError(error, { agentId = null } = {}) {
113
- const responseBody = error?.responseBody && typeof error.responseBody === 'object'
114
- ? error.responseBody
115
- : null;
116
- return {
117
- agentId,
118
- status: 'failed',
119
- httpStatus: Number.isInteger(error?.status) ? error.status : 500,
120
- error: normalizeText(responseBody?.error, normalizeText(error?.code, 'chat_request_create_failed')),
121
- reason: normalizeText(responseBody?.reason, null),
122
- message: normalizeText(responseBody?.message, normalizeText(error?.message, null)),
123
- };
124
- }
125
-
126
- export function createWorldBroadcastService({
127
- worldService,
128
- worldAuthorizationService,
129
- membershipService,
130
- chatRequestService = null,
131
- store = null,
132
- } = {}) {
133
- function assertRuntime() {
134
- if (!worldService || !membershipService || !chatRequestService || !store || typeof chatRequestService.createChatRequest !== 'function') {
135
- throw createConfigurationError();
136
- }
137
- }
138
-
139
- function resolveAudienceAgentIds(world, { audience, excludeSelf, senderAgentId } = {}) {
140
- if (audience === 'admins' || audience === 'admins_and_owner') {
141
- return dedupeAgentIds([world.creatorAgentId], {
142
- excludeAgentId: excludeSelf ? senderAgentId : null,
143
- });
144
- }
145
-
146
- const memberStatuses = resolveMemberStatuses(world);
147
- const memberAgentIds = membershipService
148
- .listMemberships({ worldId: world.worldId })
149
- .filter((membership) => memberStatuses.has(membership.status))
150
- .map((membership) => membership.agentId);
151
-
152
- return dedupeAgentIds(memberAgentIds, {
153
- excludeAgentId: excludeSelf ? senderAgentId : null,
154
- });
155
- }
156
-
157
- return {
158
- async broadcastWorld({
159
- worldId,
160
- senderAgentId,
161
- payload,
162
- audience = null,
163
- excludeSelf = null,
164
- } = {}) {
165
- assertRuntime();
166
- const world = worldService.requireWorld(worldId);
167
- const sender = store.getAgent(senderAgentId);
168
-
169
- if (!sender) {
170
- throw createInvalidBroadcastRequestError('agentId', 'agentId is required');
171
- }
172
- if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
173
- throw createInvalidBroadcastRequestError('payload', 'payload must be an object');
174
- }
175
- const openingMessage = normalizeText(payload.text, null);
176
- if (!openingMessage) {
177
- throw createInvalidBroadcastRequestError('payload.text', 'payload.text is required');
178
- }
179
-
180
- const worldBroadcast = world.broadcast && typeof world.broadcast === 'object'
181
- ? world.broadcast
182
- : {};
183
- if (worldBroadcast.enabled !== true) {
184
- throw createBroadcastDisabledError(world.worldId);
185
- }
186
-
187
- const authorization = worldAuthorizationService.evaluateWorldAction({
188
- worldId: world.worldId,
189
- actorAgentId: senderAgentId,
190
- action: WORLD_ACTIONS.BROADCAST,
191
- });
192
- const senderRole = authorization.worldRole;
193
- if (!authorization.allowed) {
194
- throw createBroadcastNotAllowedError({
195
- worldId: world.worldId,
196
- senderAgentId,
197
- senderRole,
198
- });
199
- }
200
-
201
- const effectiveAudience = normalizeBroadcastAudience(audience, worldBroadcast.audience || 'members');
202
- const effectiveExcludeSelf = normalizeBoolean(excludeSelf, worldBroadcast.excludeSelf !== false) !== false;
203
- const effectiveEligibility = normalizeWorldEligibility(world.eligibility, 'active');
204
- const targetAgentIds = resolveAudienceAgentIds(world, {
205
- audience: effectiveAudience,
206
- excludeSelf: effectiveExcludeSelf,
207
- senderAgentId,
208
- });
209
- const broadcastId = createBroadcastId();
210
- const openingPayload = cloneJsonObject(payload) || { text: openingMessage };
211
-
212
- const requests = [];
213
- const failures = [];
214
- for (const targetAgentId of targetAgentIds) {
215
- const targetAgent = store.getAgent(targetAgentId);
216
- if (!targetAgent?.agentId) {
217
- failures.push({
218
- agentId: targetAgentId,
219
- status: 'failed',
220
- httpStatus: 404,
221
- error: 'target_not_found',
222
- reason: 'target_not_found',
223
- message: 'target agent was not found',
224
- });
225
- continue;
226
- }
227
-
228
- try {
229
- const created = await chatRequestService.createChatRequest({
230
- fromAgentId: senderAgentId,
231
- targetAgentId,
232
- openingMessage,
233
- openingPayload,
234
- worldId: world.worldId,
235
- origin: {
236
- type: 'world_broadcast',
237
- broadcastId,
238
- },
239
- broadcast: {
240
- broadcastId,
241
- worldId: world.worldId,
242
- audience: effectiveAudience,
243
- senderRole,
244
- eligibility: effectiveEligibility,
245
- excludeSelf: effectiveExcludeSelf,
246
- },
247
- source: 'world_broadcast',
248
- });
249
-
250
- requests.push({
251
- agentId: targetAgentId,
252
- status: created.status,
253
- verdict: created.verdict,
254
- chatRequest: created.chatRequest,
255
- kickoff: created.kickoff || null,
256
- });
257
- } catch (error) {
258
- failures.push(normalizeBroadcastCreationError(error, {
259
- agentId: targetAgentId,
260
- }));
261
- }
262
- }
263
-
264
- const pendingCount = requests.filter((item) => item.chatRequest?.status === 'pending').length;
265
- const autoAcceptedCount = requests.filter((item) => item.chatRequest?.status === 'accepted').length;
266
- const rejectedCount = requests.filter((item) => item.chatRequest?.status === 'rejected').length;
267
-
268
- return {
269
- status: failures.length === 0 ? 'requests_created' : 'requests_created_with_failures',
270
- worldId: world.worldId,
271
- senderAgentId,
272
- senderRole,
273
- audience: effectiveAudience,
274
- excludeSelf: effectiveExcludeSelf,
275
- eligibility: effectiveEligibility,
276
- broadcastId,
277
- totalTargets: targetAgentIds.length,
278
- createdCount: requests.length,
279
- failedCount: failures.length,
280
- pendingCount,
281
- autoAcceptedCount,
282
- rejectedCount,
283
- requests,
284
- failures,
285
- nextAction:
286
- pendingCount > 0
287
- ? 'recipients_review_pending_requests'
288
- : autoAcceptedCount > 0
289
- ? 'backend_auto_accepted_requests'
290
- : rejectedCount > 0
291
- ? 'requests_rejected_by_policy'
292
- : 'no_pending_requests_created',
293
- };
294
- },
295
- };
296
- }