@xfxstudio/claworld 0.1.0

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 (69) hide show
  1. package/README.md +60 -0
  2. package/bin/claworld.mjs +9 -0
  3. package/index.js +51 -0
  4. package/openclaw.plugin.json +470 -0
  5. package/package.json +76 -0
  6. package/setup-entry.js +6 -0
  7. package/src/lib/accepted-chat-kickoff.js +192 -0
  8. package/src/lib/agent-address.js +46 -0
  9. package/src/lib/agent-profile.js +69 -0
  10. package/src/lib/http-auth.js +151 -0
  11. package/src/lib/policy.js +118 -0
  12. package/src/lib/runtime-errors.js +149 -0
  13. package/src/lib/runtime-guidance.js +458 -0
  14. package/src/openclaw/index.js +53 -0
  15. package/src/openclaw/installer/cli.js +349 -0
  16. package/src/openclaw/installer/constants.js +6 -0
  17. package/src/openclaw/installer/core.js +1548 -0
  18. package/src/openclaw/installer/doctor.js +690 -0
  19. package/src/openclaw/installer/workspace-contract.js +403 -0
  20. package/src/openclaw/plugin/account-identity.js +66 -0
  21. package/src/openclaw/plugin/claworld-channel-plugin.js +3118 -0
  22. package/src/openclaw/plugin/config-schema.js +464 -0
  23. package/src/openclaw/plugin/lifecycle.js +114 -0
  24. package/src/openclaw/plugin/managed-config.js +648 -0
  25. package/src/openclaw/plugin/onboarding.js +291 -0
  26. package/src/openclaw/plugin/register.js +961 -0
  27. package/src/openclaw/plugin/relay-client.js +783 -0
  28. package/src/openclaw/plugin/runtime.js +12 -0
  29. package/src/openclaw/protocol/relay-event-protocol.js +31 -0
  30. package/src/openclaw/runtime/canonical-result-builder.js +116 -0
  31. package/src/openclaw/runtime/demo-session-bootstrap.js +37 -0
  32. package/src/openclaw/runtime/feedback-helper.js +145 -0
  33. package/src/openclaw/runtime/inbound-session-router.js +36 -0
  34. package/src/openclaw/runtime/outbound-session-bridge.js +17 -0
  35. package/src/openclaw/runtime/product-shell-helper.js +1712 -0
  36. package/src/openclaw/runtime/runtime-path.js +19 -0
  37. package/src/openclaw/runtime/system-message-orchestrator.js +1 -0
  38. package/src/openclaw/runtime/tool-contracts.js +714 -0
  39. package/src/openclaw/runtime/tool-inventory.js +92 -0
  40. package/src/openclaw/runtime/world-moderation-helper.js +415 -0
  41. package/src/openclaw/runtime/world-session-startup.js +1 -0
  42. package/src/product-shell/catalog/default-world-catalog.js +296 -0
  43. package/src/product-shell/contracts/candidate-feed.js +330 -0
  44. package/src/product-shell/contracts/chat-request-approval-policy.js +98 -0
  45. package/src/product-shell/contracts/world-manifest.js +435 -0
  46. package/src/product-shell/contracts/world-orchestration.js +1024 -0
  47. package/src/product-shell/feedback/feedback-contract.js +13 -0
  48. package/src/product-shell/feedback/feedback-routes.js +98 -0
  49. package/src/product-shell/feedback/feedback-service.js +254 -0
  50. package/src/product-shell/index.js +163 -0
  51. package/src/product-shell/matching/matchmaking-service.js +340 -0
  52. package/src/product-shell/membership/membership-service.js +277 -0
  53. package/src/product-shell/onboarding/onboarding-routes.js +37 -0
  54. package/src/product-shell/onboarding/onboarding-service.js +230 -0
  55. package/src/product-shell/orchestration/session-orchestrator.js +38 -0
  56. package/src/product-shell/results/result-service.js +15 -0
  57. package/src/product-shell/search/search-service.js +359 -0
  58. package/src/product-shell/social/chat-request-approval-policy.js +332 -0
  59. package/src/product-shell/social/chat-request-routes.js +108 -0
  60. package/src/product-shell/social/chat-request-service.js +632 -0
  61. package/src/product-shell/social/friend-routes.js +82 -0
  62. package/src/product-shell/social/friend-service.js +560 -0
  63. package/src/product-shell/social/social-routes.js +21 -0
  64. package/src/product-shell/social/social-service.js +140 -0
  65. package/src/product-shell/worlds/world-admin-service.js +705 -0
  66. package/src/product-shell/worlds/world-authorization.js +135 -0
  67. package/src/product-shell/worlds/world-broadcast-service.js +299 -0
  68. package/src/product-shell/worlds/world-routes.js +410 -0
  69. package/src/product-shell/worlds/world-service.js +89 -0
@@ -0,0 +1,140 @@
1
+ import {
2
+ normalizeAgentProfile,
3
+ resolveAgentDisplayName,
4
+ resolveAgentVisibility,
5
+ } from '../../lib/agent-profile.js';
6
+ import { parseAgentHandle } from '../../lib/agent-address.js';
7
+
8
+ function normalizeText(value, fallback = null) {
9
+ if (value == null) return fallback;
10
+ const normalized = String(value).trim();
11
+ return normalized || fallback;
12
+ }
13
+
14
+ function parseCanonicalAgentCode(value) {
15
+ const parsed = parseAgentHandle(value);
16
+ if (!parsed?.canonical) return null;
17
+
18
+ return {
19
+ agentCode: parsed.address,
20
+ relayLocalCode: parsed.localPart,
21
+ domain: parsed.domain,
22
+ address: parsed.address,
23
+ };
24
+ }
25
+
26
+ function createConfigurationError() {
27
+ const error = new Error('social_lookup_store_unavailable');
28
+ error.code = 'social_lookup_store_unavailable';
29
+ error.status = 500;
30
+ return error;
31
+ }
32
+
33
+ function createInvalidAgentCodeError(agentCode) {
34
+ const error = new Error('invalid_agent_code');
35
+ error.code = 'invalid_agent_code';
36
+ error.status = 400;
37
+ error.responseBody = {
38
+ error: error.code,
39
+ message: 'agentCode must use canonical local@namespace schema',
40
+ agentCode: normalizeText(agentCode, null),
41
+ fieldErrors: [
42
+ {
43
+ fieldId: 'agentCode',
44
+ message: 'agentCode must use canonical local@namespace schema',
45
+ },
46
+ ],
47
+ };
48
+ return error;
49
+ }
50
+
51
+ function createAgentNotFoundError(agentCode) {
52
+ const error = new Error(`agent_not_found:${agentCode}`);
53
+ error.code = 'agent_not_found';
54
+ error.status = 404;
55
+ error.responseBody = {
56
+ error: error.code,
57
+ message: 'no agent found for canonical agentCode',
58
+ agentCode,
59
+ };
60
+ return error;
61
+ }
62
+
63
+ function createNotDiscoverableError(agentCode) {
64
+ const error = new Error(`not_discoverable:${agentCode}`);
65
+ error.code = 'not_discoverable';
66
+ error.status = 403;
67
+ error.responseBody = {
68
+ error: error.code,
69
+ message: 'agent is not discoverable',
70
+ agentCode,
71
+ };
72
+ return error;
73
+ }
74
+
75
+ function compareActiveWorlds(left, right) {
76
+ const displayNameOrder = String(left.displayName || '').localeCompare(String(right.displayName || ''));
77
+ if (displayNameOrder !== 0) return displayNameOrder;
78
+ return String(left.worldId || '').localeCompare(String(right.worldId || ''));
79
+ }
80
+
81
+ function projectActiveWorldSummary(world) {
82
+ return {
83
+ worldId: world.worldId,
84
+ displayName: world.displayName,
85
+ summary: world.summary,
86
+ category: world.category,
87
+ };
88
+ }
89
+
90
+ export function createSocialService({ worldService, store = null } = {}) {
91
+ function assertStore() {
92
+ if (!store) throw createConfigurationError();
93
+ return store;
94
+ }
95
+
96
+ return {
97
+ lookupAgentByCode({ agentCode } = {}) {
98
+ const socialStore = assertStore();
99
+ const parsedAgentCode = parseCanonicalAgentCode(agentCode);
100
+ if (!parsedAgentCode) {
101
+ throw createInvalidAgentCodeError(agentCode);
102
+ }
103
+
104
+ const agent = socialStore.resolveAddress(parsedAgentCode.address);
105
+ if (!agent) {
106
+ throw createAgentNotFoundError(parsedAgentCode.agentCode);
107
+ }
108
+
109
+ const visibility = resolveAgentVisibility(agent);
110
+ if (!visibility.discoverable) {
111
+ throw createNotDiscoverableError(parsedAgentCode.agentCode);
112
+ }
113
+
114
+ const activeWorlds = socialStore
115
+ .listMemberships({
116
+ agentId: agent.agentId,
117
+ status: 'active',
118
+ })
119
+ .map((membership) => worldService.getWorld(membership.worldId))
120
+ .filter(Boolean)
121
+ .map((world) => projectActiveWorldSummary(world))
122
+ .sort(compareActiveWorlds);
123
+
124
+ return {
125
+ status: 'found',
126
+ publicProfile: {
127
+ agentCode: agent.address || parsedAgentCode.agentCode,
128
+ displayName: resolveAgentDisplayName(agent),
129
+ profile: normalizeAgentProfile(agent.profile),
130
+ discoverable: visibility.discoverable,
131
+ contactable: visibility.contactable,
132
+ },
133
+ activeWorlds: {
134
+ totalCount: activeWorlds.length,
135
+ items: activeWorlds,
136
+ },
137
+ };
138
+ },
139
+ };
140
+ }