@xfxstudio/claworld 0.2.24 → 0.2.25

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.
@@ -1,5 +1,4 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import claworldPackageJson from '../../../package.json' with { type: 'json' };
3
2
 
4
3
  import {
5
4
  applyRuntimeIdentity,
@@ -38,6 +37,12 @@ import {
38
37
  fetchOwnedWorlds,
39
38
  manageModeratedWorld,
40
39
  } from '../runtime/world-moderation-helper.js';
40
+ import {
41
+ fetchWorldMembership,
42
+ fetchWorldMemberships,
43
+ leaveWorldMembership,
44
+ updateWorldMembershipProfile,
45
+ } from '../runtime/world-membership-helper.js';
41
46
  import { submitFeedbackReport } from '../runtime/feedback-helper.js';
42
47
  import {
43
48
  buildWorldSelectionPrompt,
@@ -51,6 +56,9 @@ import {
51
56
  } from '../runtime/product-shell-helper.js';
52
57
  import { extractBackendErrorContext } from '../runtime/backend-error-context.js';
53
58
  import { getClaworldRuntime } from './runtime.js';
59
+ import {
60
+ CLAWORLD_PLUGIN_CURRENT_VERSION,
61
+ } from '../plugin-version.js';
54
62
  import {
55
63
  createRuntimeBoundaryError,
56
64
  normalizeRuntimeBoundaryError,
@@ -58,8 +66,6 @@ import {
58
66
  } from '../../lib/runtime-errors.js';
59
67
  import { PUBLIC_IDENTITY_STATUS } from '../../lib/public-identity.js';
60
68
 
61
- const CLAWORLD_PLUGIN_VERSION = claworldPackageJson.version;
62
-
63
69
  function normalizeRelayHttpBaseUrl(serverUrl) {
64
70
  const parsed = new URL(serverUrl);
65
71
  if (parsed.protocol === 'ws:') parsed.protocol = 'http:';
@@ -439,6 +445,10 @@ function buildRelayContinuationText({
439
445
  };
440
446
  }
441
447
 
448
+ function isExactNoReplyToken(text) {
449
+ return String(text || '').trim() === 'NO_REPLY';
450
+ }
451
+
442
452
  function resolveContinuationState(turnData = {}) {
443
453
  const continuation = turnData?.continuation;
444
454
  if (!continuation || typeof continuation !== 'object' || Array.isArray(continuation)) {
@@ -1618,7 +1628,11 @@ function createDeliveryReplyDispatcher({
1618
1628
  runtimeOutputSummary.relayContinuationPreview = safeContinuation.text
1619
1629
  ? previewRuntimeOutputText(safeContinuation.text)
1620
1630
  : null;
1621
- if (safeContinuation.text) {
1631
+ if (safeContinuation.text && isExactNoReplyToken(safeContinuation.text)) {
1632
+ runtimeOutputSummary.relayContinuationSource = 'no_reply_token';
1633
+ runtimeOutputSummary.relayContinuationPreview = 'NO_REPLY';
1634
+ await flushKeptSilent('no_reply_token');
1635
+ } else if (safeContinuation.text) {
1622
1636
  await flushReply(safeContinuation.text);
1623
1637
  } else {
1624
1638
  const silentReason = resolveRelaySilentReason(runtimeOutputSummary, safeContinuation);
@@ -2603,7 +2617,7 @@ export function createClaworldChannelPlugin({
2603
2617
  return {
2604
2618
  ok: true,
2605
2619
  pluginId: 'claworld',
2606
- version: CLAWORLD_PLUGIN_VERSION,
2620
+ version: CLAWORLD_PLUGIN_CURRENT_VERSION,
2607
2621
  defaultAccountId: null,
2608
2622
  accounts: accountSnapshots,
2609
2623
  relayClients: Object.fromEntries(
@@ -2752,7 +2766,7 @@ async function generateRuntimeProfileCard(context = {}) {
2752
2766
  docsPath: '/channels/claworld',
2753
2767
  docsLabel: 'claworld',
2754
2768
  blurb: 'Claworld relay channel backed by the Claworld backend.',
2755
- version: CLAWORLD_PLUGIN_VERSION,
2769
+ version: CLAWORLD_PLUGIN_CURRENT_VERSION,
2756
2770
  forceAccountBinding: true,
2757
2771
  },
2758
2772
  onboarding: claworldOnboardingAdapter,
@@ -3031,6 +3045,7 @@ async function generateRuntimeProfileCard(context = {}) {
3031
3045
  agentId: resolvedContext.agentId || null,
3032
3046
  displayName: context.displayName || null,
3033
3047
  worldContextText: context.worldContextText || null,
3048
+ participantContextText: context.participantContextText || null,
3034
3049
  enabled: typeof context.enabled === 'boolean' ? context.enabled : true,
3035
3050
  fetchImpl,
3036
3051
  logger,
@@ -3065,6 +3080,60 @@ async function generateRuntimeProfileCard(context = {}) {
3065
3080
  });
3066
3081
  },
3067
3082
  },
3083
+ membership: {
3084
+ listWorldMemberships: async (context = {}) => {
3085
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3086
+ return fetchWorldMemberships({
3087
+ cfg: resolvedContext.cfg || {},
3088
+ accountId: resolvedContext.accountId || null,
3089
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3090
+ agentId: resolvedContext.agentId || null,
3091
+ status: context.status || null,
3092
+ includeInactive: context.includeInactive === true,
3093
+ includeDisabled: context.includeDisabled !== false,
3094
+ fetchImpl,
3095
+ logger,
3096
+ });
3097
+ },
3098
+ getWorldMembership: async (context = {}) => {
3099
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3100
+ return fetchWorldMembership({
3101
+ cfg: resolvedContext.cfg || {},
3102
+ accountId: resolvedContext.accountId || null,
3103
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3104
+ agentId: resolvedContext.agentId || null,
3105
+ worldId: context.worldId || null,
3106
+ includeDisabled: context.includeDisabled !== false,
3107
+ fetchImpl,
3108
+ logger,
3109
+ });
3110
+ },
3111
+ updateWorldMembershipProfile: async (context = {}) => {
3112
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3113
+ return updateWorldMembershipProfile({
3114
+ cfg: resolvedContext.cfg || {},
3115
+ accountId: resolvedContext.accountId || null,
3116
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3117
+ agentId: resolvedContext.agentId || null,
3118
+ worldId: context.worldId || null,
3119
+ participantContextText: context.participantContextText || null,
3120
+ fetchImpl,
3121
+ logger,
3122
+ });
3123
+ },
3124
+ leaveWorldMembership: async (context = {}) => {
3125
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3126
+ return leaveWorldMembership({
3127
+ cfg: resolvedContext.cfg || {},
3128
+ accountId: resolvedContext.accountId || null,
3129
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3130
+ agentId: resolvedContext.agentId || null,
3131
+ worldId: context.worldId || null,
3132
+ fetchImpl,
3133
+ logger,
3134
+ });
3135
+ },
3136
+ },
3068
3137
  },
3069
3138
  runtime: {
3070
3139
  protocol,
@@ -3181,6 +3250,7 @@ async function generateRuntimeProfileCard(context = {}) {
3181
3250
  agentId: resolvedContext.agentId || null,
3182
3251
  displayName: context.displayName || null,
3183
3252
  worldContextText: context.worldContextText || null,
3253
+ participantContextText: context.participantContextText || null,
3184
3254
  enabled: typeof context.enabled === 'boolean' ? context.enabled : true,
3185
3255
  fetchImpl,
3186
3256
  logger,
@@ -3215,6 +3285,60 @@ async function generateRuntimeProfileCard(context = {}) {
3215
3285
  });
3216
3286
  },
3217
3287
  },
3288
+ membership: {
3289
+ listWorldMemberships: async (context = {}) => {
3290
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3291
+ return fetchWorldMemberships({
3292
+ cfg: resolvedContext.cfg || {},
3293
+ accountId: resolvedContext.accountId || null,
3294
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3295
+ agentId: resolvedContext.agentId || null,
3296
+ status: context.status || null,
3297
+ includeInactive: context.includeInactive === true,
3298
+ includeDisabled: context.includeDisabled !== false,
3299
+ fetchImpl,
3300
+ logger,
3301
+ });
3302
+ },
3303
+ getWorldMembership: async (context = {}) => {
3304
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3305
+ return fetchWorldMembership({
3306
+ cfg: resolvedContext.cfg || {},
3307
+ accountId: resolvedContext.accountId || null,
3308
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3309
+ agentId: resolvedContext.agentId || null,
3310
+ worldId: context.worldId || null,
3311
+ includeDisabled: context.includeDisabled !== false,
3312
+ fetchImpl,
3313
+ logger,
3314
+ });
3315
+ },
3316
+ updateWorldMembershipProfile: async (context = {}) => {
3317
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3318
+ return updateWorldMembershipProfile({
3319
+ cfg: resolvedContext.cfg || {},
3320
+ accountId: resolvedContext.accountId || null,
3321
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3322
+ agentId: resolvedContext.agentId || null,
3323
+ worldId: context.worldId || null,
3324
+ participantContextText: context.participantContextText || null,
3325
+ fetchImpl,
3326
+ logger,
3327
+ });
3328
+ },
3329
+ leaveWorldMembership: async (context = {}) => {
3330
+ const resolvedContext = await resolveBoundRuntimeContext(context);
3331
+ return leaveWorldMembership({
3332
+ cfg: resolvedContext.cfg || {},
3333
+ accountId: resolvedContext.accountId || null,
3334
+ runtimeConfig: resolvedContext.runtimeConfig || null,
3335
+ agentId: resolvedContext.agentId || null,
3336
+ worldId: context.worldId || null,
3337
+ fetchImpl,
3338
+ logger,
3339
+ });
3340
+ },
3341
+ },
3218
3342
  },
3219
3343
  createRelayClient: (options = {}) => relayClientFactory({ logger, inbound, outbound, protocol, ...options }),
3220
3344
  },
@@ -13,6 +13,8 @@ export const DEFAULT_CLAWORLD_AGENT_ID = 'main';
13
13
  export const DEFAULT_CLAWORLD_ACCOUNT_ID = 'claworld';
14
14
  export const DEFAULT_CLAWORLD_TOOL_PROFILE = 'default';
15
15
  export const DEFAULT_CLAWORLD_DM_SCOPE = 'per-channel-peer';
16
+ export const DEFAULT_CLAWORLD_SESSION_RESET_MODE = 'idle';
17
+ export const DEFAULT_CLAWORLD_SESSION_RESET_IDLE_MINUTES = 43200;
16
18
  export const DEFAULT_CLAWORLD_SESSION_TARGET = 'mainagent';
17
19
  export const DEFAULT_CLAWORLD_FALLBACK_TARGET = 'mainagent';
18
20
  export const CLAWORLD_PLUGIN_TOOL_ALLOW_ENTRY = 'claworld';
@@ -44,6 +46,13 @@ export function ensureObject(value) {
44
46
  return value;
45
47
  }
46
48
 
49
+ function buildDefaultClaworldSessionResetOverride() {
50
+ return {
51
+ mode: DEFAULT_CLAWORLD_SESSION_RESET_MODE,
52
+ idleMinutes: DEFAULT_CLAWORLD_SESSION_RESET_IDLE_MINUTES,
53
+ };
54
+ }
55
+
47
56
  function normalizeRegistrationDisplayName(value, fallback = null) {
48
57
  const normalized = normalizeText(value, fallback);
49
58
  return normalized || fallback;
@@ -713,6 +722,16 @@ export function applyClaworldManagedRuntimeConfig(inputConfig = {}, options = {}
713
722
  config.session.dmScope = sessionDmScope;
714
723
  summary.push(`session.dmScope set to ${sessionDmScope}`);
715
724
  }
725
+ const resetByChannel = ensureObject(config.session.resetByChannel);
726
+ if (!Object.prototype.hasOwnProperty.call(resetByChannel, 'claworld')) {
727
+ config.session.resetByChannel = {
728
+ ...resetByChannel,
729
+ claworld: buildDefaultClaworldSessionResetOverride(),
730
+ };
731
+ summary.push(
732
+ `session.resetByChannel.claworld set to ${DEFAULT_CLAWORLD_SESSION_RESET_MODE}/${DEFAULT_CLAWORLD_SESSION_RESET_IDLE_MINUTES}m`,
733
+ );
734
+ }
716
735
 
717
736
  config.agents = ensureObject(config.agents);
718
737
  const existingAgentList = Array.isArray(config.agents.list) ? [...config.agents.list] : [];
@@ -3,6 +3,8 @@ import {
3
3
  projectToolChatRequestMutationResponse,
4
4
  projectToolManagedWorldResponse,
5
5
  projectToolOwnedWorldsResponse,
6
+ projectToolWorldMembershipListResponse,
7
+ projectToolWorldMembershipResponse,
6
8
  } from '../runtime/tool-contracts.js';
7
9
  import {
8
10
  buildPublicErrorPayload,
@@ -383,6 +385,10 @@ export const MANAGE_WORLD_ACTIONS = Object.freeze([
383
385
  'pause',
384
386
  'close',
385
387
  'resume',
388
+ 'list_memberships',
389
+ 'get_membership',
390
+ 'update_profile',
391
+ 'leave',
386
392
  ]);
387
393
 
388
394
  export function normalizeManageWorldAction(value, fallback = null) {
@@ -394,6 +400,7 @@ export function inferManageWorldAction(params = {}) {
394
400
  const explicitAction = normalizeManageWorldAction(params.action, null);
395
401
  if (explicitAction) return explicitAction;
396
402
  if (!normalizeText(params.worldId, null)) return 'list';
403
+ if (normalizeText(params.participantContextText, null)) return 'update_profile';
397
404
  if (normalizeText(params.worldContextText, null) || normalizeText(params.displayName, null)) {
398
405
  return 'update_context';
399
406
  }
@@ -420,6 +427,18 @@ export function projectToolManageWorldActionResponse(payload = {}, { accountId =
420
427
  ...projectToolOwnedWorldsResponse(payload, { accountId }),
421
428
  };
422
429
  }
430
+ if (resolvedAction === 'list_memberships') {
431
+ return {
432
+ action: resolvedAction,
433
+ ...projectToolWorldMembershipListResponse(payload, { accountId }),
434
+ };
435
+ }
436
+ if (['get_membership', 'update_profile', 'leave'].includes(resolvedAction)) {
437
+ return {
438
+ action: resolvedAction,
439
+ ...projectToolWorldMembershipResponse(payload, { accountId }),
440
+ };
441
+ }
423
442
  return {
424
443
  action: resolvedAction,
425
444
  ...projectToolManagedWorldResponse(payload, { accountId }),
@@ -585,6 +604,31 @@ function projectToolChatRequestApprovalPolicy(payload = null) {
585
604
  };
586
605
  }
587
606
 
607
+ function projectToolPluginVersionStatus(payload = null) {
608
+ const versionStatus = normalizeObject(payload, null);
609
+ if (!versionStatus) return null;
610
+
611
+ const warning = normalizeObject(versionStatus.warning, null);
612
+ return {
613
+ reportedVersion: normalizeText(versionStatus.reportedVersion, null),
614
+ minSupportedVersion: normalizeText(versionStatus.minSupportedVersion, null),
615
+ latestVersion: normalizeText(versionStatus.latestVersion, null),
616
+ compatible: typeof versionStatus.compatible === 'boolean' ? versionStatus.compatible : null,
617
+ status: normalizeText(versionStatus.status, 'unknown'),
618
+ upgradeCommand: normalizeText(versionStatus.upgradeCommand, null),
619
+ message: normalizeText(versionStatus.message, null),
620
+ ...(warning
621
+ ? {
622
+ warning: {
623
+ level: normalizeText(warning.level, null),
624
+ code: normalizeText(warning.code, null),
625
+ message: normalizeText(warning.message, null),
626
+ },
627
+ }
628
+ : {}),
629
+ };
630
+ }
631
+
588
632
  export function projectToolAccountViewResponse({
589
633
  accountId = null,
590
634
  pairingPayload = null,
@@ -622,6 +666,7 @@ export function projectToolAccountViewResponse({
622
666
  },
623
667
  profile: projectToolAccountProfile(identityPayload),
624
668
  ...projectToolAccountIdentityFields(identityPayload),
669
+ pluginVersionStatus: projectToolPluginVersionStatus(identityPayload?.pluginVersionStatus),
625
670
  chatRequestApprovalPolicy: projectToolChatRequestApprovalPolicy(identityPayload?.chatRequestApprovalPolicy),
626
671
  ...(resolvedShareCard !== undefined ? { shareCard: resolvedShareCard } : {}),
627
672
  };
@@ -647,6 +692,7 @@ export function projectToolAccountMutationResponse({
647
692
  accountId: normalizeText(accountId, null),
648
693
  profile: projectToolAccountProfile(identityPayload),
649
694
  ...projectToolAccountIdentityFields(identityPayload),
695
+ pluginVersionStatus: projectToolPluginVersionStatus(identityPayload?.pluginVersionStatus),
650
696
  chatRequestApprovalPolicy: projectToolChatRequestApprovalPolicy(identityPayload?.chatRequestApprovalPolicy),
651
697
  ...(resolvedShareCard !== undefined ? { shareCard: resolvedShareCard } : {}),
652
698
  ...(runtimeActivation ? { runtimeActivation } : {}),