@naylence/runtime 0.3.5-test.964 → 0.3.5-test.966

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.
@@ -13,12 +13,12 @@ import fastify from 'fastify';
13
13
  import websocketPlugin from '@fastify/websocket';
14
14
 
15
15
  // This file is auto-generated during build - do not edit manually
16
- // Generated from package.json version: 0.3.5-test.964
16
+ // Generated from package.json version: 0.3.5-test.966
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.5-test.964';
21
+ const VERSION = '0.3.5-test.966';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9885,11 +9885,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9885
9885
  ensureBroadcastEnvironment();
9886
9886
  super(baseConfig);
9887
9887
  this.listenerRegistered = false;
9888
- this.seenAckKeys = new Map();
9889
- this.seenAckOrder = [];
9890
- this.ackDedupTtlMs = 30000;
9891
- this.ackDedupMaxEntries = 4096;
9892
- this.textDecoder = new TextDecoder();
9893
9888
  this.visibilityChangeListenerRegistered = false;
9894
9889
  this.channelName =
9895
9890
  typeof config.channelName === 'string' && config.channelName.trim().length > 0
@@ -9981,9 +9976,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9981
9976
  connector_id: this.connectorId,
9982
9977
  payload_length: payload.byteLength,
9983
9978
  });
9984
- if (this._shouldSkipDuplicateAck(senderNodeId, payload)) {
9985
- return;
9986
- }
9987
9979
  try {
9988
9980
  if (typeof this.inbox.tryEnqueue === 'function') {
9989
9981
  const accepted = this.inbox.tryEnqueue(payload);
@@ -10087,9 +10079,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10087
10079
  }
10088
10080
  async pushToReceive(rawOrEnvelope) {
10089
10081
  const item = this._normalizeInboxItem(rawOrEnvelope);
10090
- if (this._shouldSkipDuplicateAckFromInboxItem(item)) {
10091
- return;
10092
- }
10093
10082
  try {
10094
10083
  if (typeof this.inbox.tryEnqueue === 'function') {
10095
10084
  const accepted = this.inbox.tryEnqueue(item);
@@ -10189,8 +10178,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10189
10178
  const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
10190
10179
  const shutdownError = new FameTransportClose(closeReason, closeCode);
10191
10180
  this.inbox.drain(shutdownError);
10192
- this.seenAckKeys.clear();
10193
- this.seenAckOrder.length = 0;
10194
10181
  }
10195
10182
  _normalizeInboxItem(rawOrEnvelope) {
10196
10183
  if (rawOrEnvelope instanceof Uint8Array) {
@@ -10267,125 +10254,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10267
10254
  ...extra,
10268
10255
  });
10269
10256
  }
10270
- _shouldSkipDuplicateAck(senderId, payload) {
10271
- const dedupKey = this._extractAckDedupKey(payload);
10272
- if (!dedupKey) {
10273
- return false;
10274
- }
10275
- const normalizedSenderId = typeof senderId === 'string' && senderId.length > 0
10276
- ? senderId
10277
- : undefined;
10278
- if (normalizedSenderId && normalizedSenderId !== this.localNodeId) {
10279
- logger$_.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
10280
- channel: this.channelName,
10281
- connector_id: this.connectorId,
10282
- sender_id: normalizedSenderId,
10283
- dedup_key: dedupKey,
10284
- source: 'listener',
10285
- });
10286
- return false;
10287
- }
10288
- logger$_.debug('broadcast_channel_duplicate_ack_check', {
10289
- channel: this.channelName,
10290
- connector_id: this.connectorId,
10291
- sender_id: normalizedSenderId ?? null,
10292
- dedup_key: dedupKey,
10293
- source: 'listener',
10294
- cache_entries: this.seenAckKeys.size,
10295
- });
10296
- return this._checkDuplicateAck(dedupKey, normalizedSenderId);
10297
- }
10298
- _shouldSkipDuplicateAckFromInboxItem(item) {
10299
- if (item instanceof Uint8Array) {
10300
- return this._shouldSkipDuplicateAck(undefined, item);
10301
- }
10302
- const envelope = this._extractEnvelopeFromInboxItem(item);
10303
- if (!envelope) {
10304
- return false;
10305
- }
10306
- const frame = envelope.frame;
10307
- if (!frame || frame.type !== 'DeliveryAck') {
10308
- return false;
10309
- }
10310
- const refId = typeof frame.refId === 'string' && frame.refId.length > 0
10311
- ? frame.refId
10312
- : null;
10313
- const dedupKey = refId ?? envelope.id ?? null;
10314
- if (!dedupKey) {
10315
- return false;
10316
- }
10317
- const senderId = this._extractSenderIdFromInboxItem(item);
10318
- if (senderId && senderId !== this.localNodeId) {
10319
- logger$_.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
10320
- channel: this.channelName,
10321
- connector_id: this.connectorId,
10322
- sender_id: senderId,
10323
- dedup_key: dedupKey,
10324
- source: 'inbox_item',
10325
- });
10326
- return false;
10327
- }
10328
- logger$_.debug('broadcast_channel_duplicate_ack_check', {
10329
- channel: this.channelName,
10330
- connector_id: this.connectorId,
10331
- sender_id: senderId ?? null,
10332
- dedup_key: dedupKey,
10333
- source: 'inbox_item',
10334
- cache_entries: this.seenAckKeys.size,
10335
- });
10336
- return this._checkDuplicateAck(dedupKey, senderId);
10337
- }
10338
- _checkDuplicateAck(dedupKey, senderId) {
10339
- const now = Date.now();
10340
- const lastSeen = this.seenAckKeys.get(dedupKey);
10341
- if (lastSeen && now - lastSeen < this.ackDedupTtlMs) {
10342
- logger$_.debug('broadcast_channel_duplicate_ack_suppressed', {
10343
- channel: this.channelName,
10344
- connector_id: this.connectorId,
10345
- sender_id: senderId ?? null,
10346
- dedup_key: dedupKey,
10347
- age_ms: now - lastSeen,
10348
- ttl_ms: this.ackDedupTtlMs,
10349
- cache_entries: this.seenAckKeys.size,
10350
- });
10351
- return true;
10352
- }
10353
- this.seenAckKeys.set(dedupKey, now);
10354
- this.seenAckOrder.push(dedupKey);
10355
- logger$_.debug('broadcast_channel_duplicate_ack_recorded', {
10356
- channel: this.channelName,
10357
- connector_id: this.connectorId,
10358
- sender_id: senderId ?? null,
10359
- dedup_key: dedupKey,
10360
- cache_entries: this.seenAckKeys.size,
10361
- });
10362
- this._trimSeenAcks(now);
10363
- return false;
10364
- }
10365
- _extractEnvelopeFromInboxItem(item) {
10366
- if (!item || typeof item !== 'object') {
10367
- return null;
10368
- }
10369
- if ('envelope' in item) {
10370
- return item.envelope;
10371
- }
10372
- if ('frame' in item) {
10373
- return item;
10374
- }
10375
- return null;
10376
- }
10377
- _extractSenderIdFromInboxItem(item) {
10378
- if (!item || typeof item !== 'object') {
10379
- return undefined;
10380
- }
10381
- if ('context' in item) {
10382
- const context = item.context;
10383
- if (context && typeof context.fromSystemId === 'string') {
10384
- return context.fromSystemId;
10385
- }
10386
- }
10387
- return undefined;
10388
- }
10389
10257
  /**
10390
10258
  * Override start() to check initial visibility state
10391
10259
  */
@@ -10439,47 +10307,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10439
10307
  target_mode: 'wildcard',
10440
10308
  });
10441
10309
  }
10442
- _trimSeenAcks(now) {
10443
- while (this.seenAckOrder.length > 0) {
10444
- const candidate = this.seenAckOrder[0];
10445
- const timestamp = this.seenAckKeys.get(candidate);
10446
- if (timestamp === undefined) {
10447
- this.seenAckOrder.shift();
10448
- continue;
10449
- }
10450
- if (this.seenAckKeys.size > this.ackDedupMaxEntries ||
10451
- now - timestamp > this.ackDedupTtlMs) {
10452
- this.seenAckKeys.delete(candidate);
10453
- this.seenAckOrder.shift();
10454
- continue;
10455
- }
10456
- break;
10457
- }
10458
- }
10459
- _extractAckDedupKey(payload) {
10460
- try {
10461
- const decoded = this.textDecoder.decode(payload);
10462
- const parsed = JSON.parse(decoded);
10463
- const envelopeId = typeof parsed?.id === 'string' ? parsed.id : null;
10464
- const frameType = parsed?.frame?.type;
10465
- if (typeof frameType !== 'string' || frameType !== 'DeliveryAck') {
10466
- return null;
10467
- }
10468
- const refId = parsed.frame?.refId;
10469
- if (typeof refId === 'string' && refId.length > 0) {
10470
- return refId;
10471
- }
10472
- return envelopeId;
10473
- }
10474
- catch (error) {
10475
- logger$_.debug('broadcast_channel_ack_dedup_parse_failed', {
10476
- channel: this.channelName,
10477
- connector_id: this.connectorId,
10478
- error: error instanceof Error ? error.message : String(error),
10479
- });
10480
- return null;
10481
- }
10482
- }
10483
10310
  };
10484
10311
 
10485
10312
  const ERROR_MESSAGE = 'BroadcastChannelConnector is browser-only and requires BroadcastChannel support';
@@ -36679,8 +36506,7 @@ class BroadcastChannelListener extends TransportListener {
36679
36506
  if (!this._routingNode) {
36680
36507
  throw new Error('BroadcastChannelListener requires routing node context');
36681
36508
  }
36682
- const normalized = this._normalizeNodeId(this._routingNode.sid) ??
36683
- this._normalizeNodeId(this._routingNode.id);
36509
+ const normalized = this._normalizeNodeId(this._routingNode.id);
36684
36510
  if (!normalized) {
36685
36511
  throw new Error('BroadcastChannelListener requires routing node with a stable identifier');
36686
36512
  }
@@ -5563,12 +5563,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5563
5563
  }
5564
5564
 
5565
5565
  // This file is auto-generated during build - do not edit manually
5566
- // Generated from package.json version: 0.3.5-test.964
5566
+ // Generated from package.json version: 0.3.5-test.966
5567
5567
  /**
5568
5568
  * The package version, injected at build time.
5569
5569
  * @internal
5570
5570
  */
5571
- const VERSION = '0.3.5-test.964';
5571
+ const VERSION = '0.3.5-test.966';
5572
5572
 
5573
5573
  /**
5574
5574
  * Fame errors module - Fame protocol specific error classes
@@ -11623,11 +11623,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11623
11623
  ensureBroadcastEnvironment();
11624
11624
  super(baseConfig);
11625
11625
  this.listenerRegistered = false;
11626
- this.seenAckKeys = new Map();
11627
- this.seenAckOrder = [];
11628
- this.ackDedupTtlMs = 30000;
11629
- this.ackDedupMaxEntries = 4096;
11630
- this.textDecoder = new TextDecoder();
11631
11626
  this.visibilityChangeListenerRegistered = false;
11632
11627
  this.channelName =
11633
11628
  typeof config.channelName === 'string' && config.channelName.trim().length > 0
@@ -11719,9 +11714,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11719
11714
  connector_id: this.connectorId,
11720
11715
  payload_length: payload.byteLength,
11721
11716
  });
11722
- if (this._shouldSkipDuplicateAck(senderNodeId, payload)) {
11723
- return;
11724
- }
11725
11717
  try {
11726
11718
  if (typeof this.inbox.tryEnqueue === 'function') {
11727
11719
  const accepted = this.inbox.tryEnqueue(payload);
@@ -11825,9 +11817,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11825
11817
  }
11826
11818
  async pushToReceive(rawOrEnvelope) {
11827
11819
  const item = this._normalizeInboxItem(rawOrEnvelope);
11828
- if (this._shouldSkipDuplicateAckFromInboxItem(item)) {
11829
- return;
11830
- }
11831
11820
  try {
11832
11821
  if (typeof this.inbox.tryEnqueue === 'function') {
11833
11822
  const accepted = this.inbox.tryEnqueue(item);
@@ -11927,8 +11916,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11927
11916
  const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
11928
11917
  const shutdownError = new FameTransportClose(closeReason, closeCode);
11929
11918
  this.inbox.drain(shutdownError);
11930
- this.seenAckKeys.clear();
11931
- this.seenAckOrder.length = 0;
11932
11919
  }
11933
11920
  _normalizeInboxItem(rawOrEnvelope) {
11934
11921
  if (rawOrEnvelope instanceof Uint8Array) {
@@ -12005,125 +11992,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
12005
11992
  ...extra,
12006
11993
  });
12007
11994
  }
12008
- _shouldSkipDuplicateAck(senderId, payload) {
12009
- const dedupKey = this._extractAckDedupKey(payload);
12010
- if (!dedupKey) {
12011
- return false;
12012
- }
12013
- const normalizedSenderId = typeof senderId === 'string' && senderId.length > 0
12014
- ? senderId
12015
- : undefined;
12016
- if (normalizedSenderId && normalizedSenderId !== this.localNodeId) {
12017
- logger$10.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
12018
- channel: this.channelName,
12019
- connector_id: this.connectorId,
12020
- sender_id: normalizedSenderId,
12021
- dedup_key: dedupKey,
12022
- source: 'listener',
12023
- });
12024
- return false;
12025
- }
12026
- logger$10.debug('broadcast_channel_duplicate_ack_check', {
12027
- channel: this.channelName,
12028
- connector_id: this.connectorId,
12029
- sender_id: normalizedSenderId ?? null,
12030
- dedup_key: dedupKey,
12031
- source: 'listener',
12032
- cache_entries: this.seenAckKeys.size,
12033
- });
12034
- return this._checkDuplicateAck(dedupKey, normalizedSenderId);
12035
- }
12036
- _shouldSkipDuplicateAckFromInboxItem(item) {
12037
- if (item instanceof Uint8Array) {
12038
- return this._shouldSkipDuplicateAck(undefined, item);
12039
- }
12040
- const envelope = this._extractEnvelopeFromInboxItem(item);
12041
- if (!envelope) {
12042
- return false;
12043
- }
12044
- const frame = envelope.frame;
12045
- if (!frame || frame.type !== 'DeliveryAck') {
12046
- return false;
12047
- }
12048
- const refId = typeof frame.refId === 'string' && frame.refId.length > 0
12049
- ? frame.refId
12050
- : null;
12051
- const dedupKey = refId ?? envelope.id ?? null;
12052
- if (!dedupKey) {
12053
- return false;
12054
- }
12055
- const senderId = this._extractSenderIdFromInboxItem(item);
12056
- if (senderId && senderId !== this.localNodeId) {
12057
- logger$10.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
12058
- channel: this.channelName,
12059
- connector_id: this.connectorId,
12060
- sender_id: senderId,
12061
- dedup_key: dedupKey,
12062
- source: 'inbox_item',
12063
- });
12064
- return false;
12065
- }
12066
- logger$10.debug('broadcast_channel_duplicate_ack_check', {
12067
- channel: this.channelName,
12068
- connector_id: this.connectorId,
12069
- sender_id: senderId ?? null,
12070
- dedup_key: dedupKey,
12071
- source: 'inbox_item',
12072
- cache_entries: this.seenAckKeys.size,
12073
- });
12074
- return this._checkDuplicateAck(dedupKey, senderId);
12075
- }
12076
- _checkDuplicateAck(dedupKey, senderId) {
12077
- const now = Date.now();
12078
- const lastSeen = this.seenAckKeys.get(dedupKey);
12079
- if (lastSeen && now - lastSeen < this.ackDedupTtlMs) {
12080
- logger$10.debug('broadcast_channel_duplicate_ack_suppressed', {
12081
- channel: this.channelName,
12082
- connector_id: this.connectorId,
12083
- sender_id: senderId ?? null,
12084
- dedup_key: dedupKey,
12085
- age_ms: now - lastSeen,
12086
- ttl_ms: this.ackDedupTtlMs,
12087
- cache_entries: this.seenAckKeys.size,
12088
- });
12089
- return true;
12090
- }
12091
- this.seenAckKeys.set(dedupKey, now);
12092
- this.seenAckOrder.push(dedupKey);
12093
- logger$10.debug('broadcast_channel_duplicate_ack_recorded', {
12094
- channel: this.channelName,
12095
- connector_id: this.connectorId,
12096
- sender_id: senderId ?? null,
12097
- dedup_key: dedupKey,
12098
- cache_entries: this.seenAckKeys.size,
12099
- });
12100
- this._trimSeenAcks(now);
12101
- return false;
12102
- }
12103
- _extractEnvelopeFromInboxItem(item) {
12104
- if (!item || typeof item !== 'object') {
12105
- return null;
12106
- }
12107
- if ('envelope' in item) {
12108
- return item.envelope;
12109
- }
12110
- if ('frame' in item) {
12111
- return item;
12112
- }
12113
- return null;
12114
- }
12115
- _extractSenderIdFromInboxItem(item) {
12116
- if (!item || typeof item !== 'object') {
12117
- return undefined;
12118
- }
12119
- if ('context' in item) {
12120
- const context = item.context;
12121
- if (context && typeof context.fromSystemId === 'string') {
12122
- return context.fromSystemId;
12123
- }
12124
- }
12125
- return undefined;
12126
- }
12127
11995
  /**
12128
11996
  * Override start() to check initial visibility state
12129
11997
  */
@@ -12177,47 +12045,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
12177
12045
  target_mode: 'wildcard',
12178
12046
  });
12179
12047
  }
12180
- _trimSeenAcks(now) {
12181
- while (this.seenAckOrder.length > 0) {
12182
- const candidate = this.seenAckOrder[0];
12183
- const timestamp = this.seenAckKeys.get(candidate);
12184
- if (timestamp === undefined) {
12185
- this.seenAckOrder.shift();
12186
- continue;
12187
- }
12188
- if (this.seenAckKeys.size > this.ackDedupMaxEntries ||
12189
- now - timestamp > this.ackDedupTtlMs) {
12190
- this.seenAckKeys.delete(candidate);
12191
- this.seenAckOrder.shift();
12192
- continue;
12193
- }
12194
- break;
12195
- }
12196
- }
12197
- _extractAckDedupKey(payload) {
12198
- try {
12199
- const decoded = this.textDecoder.decode(payload);
12200
- const parsed = JSON.parse(decoded);
12201
- const envelopeId = typeof parsed?.id === 'string' ? parsed.id : null;
12202
- const frameType = parsed?.frame?.type;
12203
- if (typeof frameType !== 'string' || frameType !== 'DeliveryAck') {
12204
- return null;
12205
- }
12206
- const refId = parsed.frame?.refId;
12207
- if (typeof refId === 'string' && refId.length > 0) {
12208
- return refId;
12209
- }
12210
- return envelopeId;
12211
- }
12212
- catch (error) {
12213
- logger$10.debug('broadcast_channel_ack_dedup_parse_failed', {
12214
- channel: this.channelName,
12215
- connector_id: this.connectorId,
12216
- error: error instanceof Error ? error.message : String(error),
12217
- });
12218
- return null;
12219
- }
12220
- }
12221
12048
  };
12222
12049
 
12223
12050
  const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
@@ -33193,8 +33020,7 @@ class BroadcastChannelListener extends TransportListener {
33193
33020
  if (!this._routingNode) {
33194
33021
  throw new Error('BroadcastChannelListener requires routing node context');
33195
33022
  }
33196
- const normalized = this._normalizeNodeId(this._routingNode.sid) ??
33197
- this._normalizeNodeId(this._routingNode.id);
33023
+ const normalized = this._normalizeNodeId(this._routingNode.id);
33198
33024
  if (!normalized) {
33199
33025
  throw new Error('BroadcastChannelListener requires routing node with a stable identifier');
33200
33026
  }