@naylence/runtime 0.3.5-test.941 → 0.3.5-test.943

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 (33) hide show
  1. package/dist/browser/index.cjs +390 -8
  2. package/dist/browser/index.mjs +390 -8
  3. package/dist/cjs/naylence/fame/connector/broadcast-channel-connector-factory.js +12 -0
  4. package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +69 -1
  5. package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +12 -0
  6. package/dist/cjs/naylence/fame/connector/inpage-connector.js +159 -1
  7. package/dist/cjs/naylence/fame/connector/transport-frame.js +101 -0
  8. package/dist/cjs/naylence/fame/grants/broadcast-channel-connection-grant.js +28 -0
  9. package/dist/cjs/naylence/fame/grants/inpage-connection-grant.js +28 -0
  10. package/dist/cjs/naylence/fame/node/upstream-session-manager.js +2 -2
  11. package/dist/cjs/version.js +2 -2
  12. package/dist/esm/naylence/fame/connector/broadcast-channel-connector-factory.js +12 -0
  13. package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +69 -1
  14. package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +12 -0
  15. package/dist/esm/naylence/fame/connector/inpage-connector.js +159 -1
  16. package/dist/esm/naylence/fame/connector/transport-frame.js +94 -0
  17. package/dist/esm/naylence/fame/grants/broadcast-channel-connection-grant.js +28 -0
  18. package/dist/esm/naylence/fame/grants/inpage-connection-grant.js +28 -0
  19. package/dist/esm/naylence/fame/node/upstream-session-manager.js +2 -2
  20. package/dist/esm/version.js +2 -2
  21. package/dist/node/index.cjs +390 -8
  22. package/dist/node/index.mjs +390 -8
  23. package/dist/node/node.cjs +406 -8
  24. package/dist/node/node.mjs +406 -8
  25. package/dist/types/naylence/fame/connector/broadcast-channel-connector-factory.d.ts +2 -0
  26. package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +4 -0
  27. package/dist/types/naylence/fame/connector/inpage-connector-factory.d.ts +2 -0
  28. package/dist/types/naylence/fame/connector/inpage-connector.d.ts +11 -1
  29. package/dist/types/naylence/fame/connector/transport-frame.d.ts +58 -0
  30. package/dist/types/naylence/fame/grants/broadcast-channel-connection-grant.d.ts +6 -0
  31. package/dist/types/naylence/fame/grants/inpage-connection-grant.d.ts +8 -0
  32. package/dist/types/version.d.ts +1 -1
  33. package/package.json +1 -1
@@ -3,6 +3,7 @@ import { FameTransportClose } from '../errors/errors.js';
3
3
  import { getLogger } from '../util/logging.js';
4
4
  import { BoundedAsyncQueue, QueueFullError, } from '../util/bounded-async-queue.js';
5
5
  import { ConnectorState } from '@naylence/core';
6
+ import { wrapTransportFrame, unwrapTransportFrame, serializeTransportFrame, } from './transport-frame.js';
6
7
  const logger = getLogger('naylence.fame.connector.broadcast_channel_connector');
7
8
  export const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
8
9
  const DEFAULT_CHANNEL = 'naylence-fabric';
@@ -68,9 +69,20 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
68
69
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
69
70
  this.connectorId = BroadcastChannelConnector.generateConnectorId();
70
71
  this.channel = new BroadcastChannel(this.channelName);
72
+ // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
73
+ this.localNodeId =
74
+ typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
75
+ ? config.localNodeId.trim()
76
+ : this.connectorId;
77
+ this.remoteNodeId =
78
+ typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
79
+ ? config.remoteNodeId.trim()
80
+ : '*'; // Accept from any remote if not specified
71
81
  logger.debug('broadcast_channel_connector_created', {
72
82
  channel: this.channelName,
73
83
  connector_id: this.connectorId,
84
+ local_node_id: this.localNodeId,
85
+ remote_node_id: this.remoteNodeId,
74
86
  inbox_capacity: preferredCapacity,
75
87
  timestamp: new Date().toISOString(),
76
88
  });
@@ -103,6 +115,46 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
103
115
  if (busMessage.senderId === this.connectorId) {
104
116
  return;
105
117
  }
118
+ // Try to unwrap as transport frame
119
+ const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
120
+ if (unwrapped) {
121
+ // Successfully unwrapped transport frame
122
+ logger.debug('broadcast_channel_transport_frame_received', {
123
+ channel: this.channelName,
124
+ sender_id: busMessage.senderId,
125
+ connector_id: this.connectorId,
126
+ local_node_id: this.localNodeId,
127
+ remote_node_id: this.remoteNodeId,
128
+ payload_length: unwrapped.byteLength,
129
+ });
130
+ if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
131
+ return;
132
+ }
133
+ try {
134
+ if (typeof this.inbox.tryEnqueue === 'function') {
135
+ const accepted = this.inbox.tryEnqueue(unwrapped);
136
+ if (accepted) {
137
+ return;
138
+ }
139
+ }
140
+ this.inbox.enqueue(unwrapped);
141
+ }
142
+ catch (error) {
143
+ if (error instanceof QueueFullError) {
144
+ logger.warning('broadcast_channel_receive_queue_full', {
145
+ channel: this.channelName,
146
+ });
147
+ }
148
+ else {
149
+ logger.error('broadcast_channel_receive_error', {
150
+ channel: this.channelName,
151
+ error: error instanceof Error ? error.message : String(error),
152
+ });
153
+ }
154
+ }
155
+ return;
156
+ }
157
+ // Fall back to legacy format (no transport frame)
106
158
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
107
159
  if (!payload) {
108
160
  logger.debug('broadcast_channel_payload_rejected', {
@@ -241,10 +293,26 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
241
293
  logger.debug('broadcast_channel_message_sending', {
242
294
  channel: this.channelName,
243
295
  sender_id: this.connectorId,
296
+ local_node_id: this.localNodeId,
297
+ remote_node_id: this.remoteNodeId,
244
298
  });
299
+ // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
300
+ // (not using default values). This ensures backwards compatibility.
301
+ const useTransportFrame = this.localNodeId !== this.connectorId ||
302
+ this.remoteNodeId !== '*';
303
+ let payload;
304
+ if (useTransportFrame) {
305
+ // Wrap payload in transport frame
306
+ const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
307
+ payload = serializeTransportFrame(frame);
308
+ }
309
+ else {
310
+ // Legacy format: send raw payload
311
+ payload = data;
312
+ }
245
313
  this.channel.postMessage({
246
314
  senderId: this.connectorId,
247
- payload: data,
315
+ payload,
248
316
  });
249
317
  }
250
318
  async _transportReceive() {
@@ -81,6 +81,8 @@ export class InPageConnectorFactory extends ConnectorFactory {
81
81
  type: INPAGE_CONNECTOR_TYPE,
82
82
  channelName,
83
83
  inboxCapacity,
84
+ localNodeId: normalized.localNodeId,
85
+ remoteNodeId: normalized.remoteNodeId,
84
86
  };
85
87
  const connector = new InPageConnector(connectorConfig, baseConfig);
86
88
  if (options.authorization) {
@@ -149,6 +151,16 @@ export class InPageConnectorFactory extends ConnectorFactory {
149
151
  if (candidate.authorizationContext !== undefined) {
150
152
  normalized.authorizationContext = candidate.authorizationContext;
151
153
  }
154
+ // Handle localNodeId
155
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
156
+ if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
157
+ normalized.localNodeId = localNodeId.trim();
158
+ }
159
+ // Handle remoteNodeId
160
+ const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
161
+ if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
162
+ normalized.remoteNodeId = remoteNodeId.trim();
163
+ }
152
164
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL;
153
165
  normalized.inboxCapacity =
154
166
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
@@ -6,6 +6,8 @@ import { BaseAsyncConnector, } from './base-async-connector.js';
6
6
  import { FameTransportClose } from '../errors/errors.js';
7
7
  import { getLogger } from '../util/logging.js';
8
8
  import { BoundedAsyncQueue, QueueFullError, } from '../util/bounded-async-queue.js';
9
+ import { ConnectorState } from '@naylence/core';
10
+ import { wrapTransportFrame, unwrapTransportFrame, serializeTransportFrame, } from './transport-frame.js';
9
11
  const logger = getLogger('naylence.fame.connector.inpage_connector');
10
12
  export const INPAGE_CONNECTOR_TYPE = 'inpage-connector';
11
13
  const DEFAULT_CHANNEL = 'naylence-fabric';
@@ -64,6 +66,7 @@ export class InPageConnector extends BaseAsyncConnector {
64
66
  ensureBrowserEnvironment();
65
67
  super(baseConfig);
66
68
  this.listenerRegistered = false;
69
+ this.visibilityChangeListenerRegistered = false;
67
70
  this.channelName =
68
71
  typeof config.channelName === 'string' && config.channelName.trim().length > 0
69
72
  ? config.channelName.trim()
@@ -75,9 +78,20 @@ export class InPageConnector extends BaseAsyncConnector {
75
78
  : DEFAULT_INBOX_CAPACITY;
76
79
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
77
80
  this.connectorId = InPageConnector.generateConnectorId();
81
+ // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
82
+ this.localNodeId =
83
+ typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
84
+ ? config.localNodeId.trim()
85
+ : this.connectorId;
86
+ this.remoteNodeId =
87
+ typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
88
+ ? config.remoteNodeId.trim()
89
+ : '*'; // Accept from any remote if not specified
78
90
  logger.debug('inpage_connector_initialized', {
79
91
  channel: this.channelName,
80
92
  connector_id: this.connectorId,
93
+ local_node_id: this.localNodeId,
94
+ remote_node_id: this.remoteNodeId,
81
95
  });
82
96
  this.onMsg = (event) => {
83
97
  const messageEvent = event;
@@ -111,6 +125,43 @@ export class InPageConnector extends BaseAsyncConnector {
111
125
  if (busMessage.senderId === this.connectorId) {
112
126
  return;
113
127
  }
128
+ // Try to unwrap as transport frame
129
+ const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
130
+ if (unwrapped) {
131
+ // Successfully unwrapped transport frame
132
+ logger.debug('inpage_transport_frame_received', {
133
+ channel: this.channelName,
134
+ sender_id: busMessage.senderId,
135
+ connector_id: this.connectorId,
136
+ local_node_id: this.localNodeId,
137
+ remote_node_id: this.remoteNodeId,
138
+ payload_length: unwrapped.byteLength,
139
+ });
140
+ try {
141
+ if (typeof this.inbox.tryEnqueue === 'function') {
142
+ const accepted = this.inbox.tryEnqueue(unwrapped);
143
+ if (accepted) {
144
+ return;
145
+ }
146
+ }
147
+ this.inbox.enqueue(unwrapped);
148
+ }
149
+ catch (error) {
150
+ if (error instanceof QueueFullError) {
151
+ logger.warning('inpage_receive_queue_full', {
152
+ channel: this.channelName,
153
+ });
154
+ }
155
+ else {
156
+ logger.error('inpage_receive_error', {
157
+ channel: this.channelName,
158
+ error: error instanceof Error ? error.message : String(error),
159
+ });
160
+ }
161
+ }
162
+ return;
163
+ }
164
+ // Fall back to legacy format (no transport frame)
114
165
  const payload = InPageConnector.coercePayload(busMessage.payload);
115
166
  if (!payload) {
116
167
  logger.debug('inpage_payload_rejected', {
@@ -151,6 +202,92 @@ export class InPageConnector extends BaseAsyncConnector {
151
202
  };
152
203
  getSharedBus().addEventListener(this.channelName, this.onMsg);
153
204
  this.listenerRegistered = true;
205
+ // Setup visibility change monitoring
206
+ this.visibilityChangeHandler = () => {
207
+ const isHidden = document.hidden;
208
+ logger.debug('inpage_visibility_changed', {
209
+ channel: this.channelName,
210
+ connector_id: this.connectorId,
211
+ visibility: isHidden ? 'hidden' : 'visible',
212
+ timestamp: new Date().toISOString(),
213
+ });
214
+ // Pause/resume connector based on visibility
215
+ if (isHidden && this.state === ConnectorState.STARTED) {
216
+ this.pause().catch((err) => {
217
+ logger.warning('inpage_pause_failed', {
218
+ channel: this.channelName,
219
+ connector_id: this.connectorId,
220
+ error: err instanceof Error ? err.message : String(err),
221
+ });
222
+ });
223
+ }
224
+ else if (!isHidden && this.state === ConnectorState.PAUSED) {
225
+ this.resume().catch((err) => {
226
+ logger.warning('inpage_resume_failed', {
227
+ channel: this.channelName,
228
+ connector_id: this.connectorId,
229
+ error: err instanceof Error ? err.message : String(err),
230
+ });
231
+ });
232
+ }
233
+ };
234
+ if (typeof document !== 'undefined') {
235
+ document.addEventListener('visibilitychange', this.visibilityChangeHandler);
236
+ this.visibilityChangeListenerRegistered = true;
237
+ // Track page lifecycle events to detect browser unload/discard
238
+ if (typeof window !== 'undefined') {
239
+ const lifecycleLogger = (event) => {
240
+ logger.info('inpage_page_lifecycle', {
241
+ channel: this.channelName,
242
+ connector_id: this.connectorId,
243
+ event_type: event.type,
244
+ visibility_state: document.visibilityState,
245
+ timestamp: new Date().toISOString(),
246
+ });
247
+ };
248
+ window.addEventListener('beforeunload', lifecycleLogger);
249
+ window.addEventListener('unload', lifecycleLogger);
250
+ window.addEventListener('pagehide', lifecycleLogger);
251
+ window.addEventListener('pageshow', lifecycleLogger);
252
+ document.addEventListener('freeze', lifecycleLogger);
253
+ document.addEventListener('resume', lifecycleLogger);
254
+ }
255
+ // Log initial state with detailed visibility info
256
+ logger.debug('inpage_initial_visibility', {
257
+ channel: this.channelName,
258
+ connector_id: this.connectorId,
259
+ visibility: document.hidden ? 'hidden' : 'visible',
260
+ document_hidden: document.hidden,
261
+ visibility_state: document.visibilityState,
262
+ has_focus: document.hasFocus(),
263
+ timestamp: new Date().toISOString(),
264
+ });
265
+ }
266
+ }
267
+ /**
268
+ * Override start() to check initial visibility state
269
+ */
270
+ async start(inboundHandler) {
271
+ await super.start(inboundHandler);
272
+ // After transitioning to STARTED, check if tab is already hidden
273
+ if (typeof document !== 'undefined' && document.hidden) {
274
+ logger.debug('inpage_start_in_hidden_tab', {
275
+ channel: this.channelName,
276
+ connector_id: this.connectorId,
277
+ document_hidden: document.hidden,
278
+ visibility_state: document.visibilityState,
279
+ has_focus: document.hasFocus(),
280
+ timestamp: new Date().toISOString(),
281
+ });
282
+ // Immediately pause if tab is hidden at start time
283
+ await this.pause().catch((err) => {
284
+ logger.warning('inpage_initial_pause_failed', {
285
+ channel: this.channelName,
286
+ connector_id: this.connectorId,
287
+ error: err instanceof Error ? err.message : String(err),
288
+ });
289
+ });
290
+ }
154
291
  }
155
292
  // Allow listeners to feed envelopes directly into the in-page receive queue.
156
293
  async pushToReceive(rawOrEnvelope) {
@@ -183,11 +320,27 @@ export class InPageConnector extends BaseAsyncConnector {
183
320
  logger.debug('inpage_message_sending', {
184
321
  channel: this.channelName,
185
322
  sender_id: this.connectorId,
323
+ local_node_id: this.localNodeId,
324
+ remote_node_id: this.remoteNodeId,
186
325
  });
326
+ // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
327
+ // (not using default values). This ensures backwards compatibility.
328
+ const useTransportFrame = this.localNodeId !== this.connectorId ||
329
+ this.remoteNodeId !== '*';
330
+ let payload;
331
+ if (useTransportFrame) {
332
+ // Wrap payload in transport frame
333
+ const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
334
+ payload = serializeTransportFrame(frame);
335
+ }
336
+ else {
337
+ // Legacy format: send raw payload
338
+ payload = data;
339
+ }
187
340
  const event = new MessageEvent(this.channelName, {
188
341
  data: {
189
342
  senderId: this.connectorId,
190
- payload: data,
343
+ payload,
191
344
  },
192
345
  });
193
346
  getSharedBus().dispatchEvent(event);
@@ -200,6 +353,11 @@ export class InPageConnector extends BaseAsyncConnector {
200
353
  getSharedBus().removeEventListener(this.channelName, this.onMsg);
201
354
  this.listenerRegistered = false;
202
355
  }
356
+ if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
357
+ document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
358
+ this.visibilityChangeListenerRegistered = false;
359
+ this.visibilityChangeHandler = undefined;
360
+ }
203
361
  const closeCode = typeof code === 'number' ? code : 1000;
204
362
  const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
205
363
  const shutdownError = new FameTransportClose(closeReason, closeCode);
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Transport frame layer for multiplexing logical links on physical channels.
3
+ *
4
+ * This lightweight framing layer wraps raw FAME payloads to enable multiple
5
+ * logical connections over a single physical channel (BroadcastChannel or InPage bus).
6
+ *
7
+ * The transport frame does NOT modify FAME envelopes - it only wraps the raw
8
+ * Uint8Array payload at the connector level.
9
+ */
10
+ /**
11
+ * Transport frame version for future compatibility
12
+ */
13
+ export const TRANSPORT_FRAME_VERSION = 1;
14
+ /**
15
+ * Wrap a raw payload in a transport frame
16
+ *
17
+ * @param payload - Raw FAME envelope bytes
18
+ * @param srcNodeId - Local node ID (this connector)
19
+ * @param dstNodeId - Remote node ID (target connector)
20
+ * @returns Transport frame ready for transmission
21
+ */
22
+ export function wrapTransportFrame(payload, srcNodeId, dstNodeId) {
23
+ return {
24
+ v: TRANSPORT_FRAME_VERSION,
25
+ src: srcNodeId,
26
+ dst: dstNodeId,
27
+ payload,
28
+ };
29
+ }
30
+ /**
31
+ * Serialize a transport frame for transmission over the bus
32
+ *
33
+ * @param frame - Transport frame to serialize
34
+ * @returns Serialized frame data ready for postMessage/dispatchEvent
35
+ */
36
+ export function serializeTransportFrame(frame) {
37
+ // Convert Uint8Array to regular array for JSON serialization
38
+ const serializable = {
39
+ v: frame.v,
40
+ src: frame.src,
41
+ dst: frame.dst,
42
+ payload: Array.from(frame.payload),
43
+ };
44
+ return serializable;
45
+ }
46
+ /**
47
+ * Unwrap a transport frame, validating source and destination
48
+ *
49
+ * @param raw - Raw data from the bus
50
+ * @param localNodeId - This connector's node ID
51
+ * @param remoteNodeId - Expected remote node ID
52
+ * @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
53
+ */
54
+ export function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
55
+ // Validate basic structure
56
+ if (!raw || typeof raw !== 'object') {
57
+ return null;
58
+ }
59
+ const frame = raw;
60
+ // Check version
61
+ if (frame.v !== TRANSPORT_FRAME_VERSION) {
62
+ return null;
63
+ }
64
+ // Check src and dst
65
+ if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
66
+ return null;
67
+ }
68
+ // Only accept frames addressed to us from the expected remote
69
+ if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
70
+ return null;
71
+ }
72
+ // Extract payload
73
+ if (!frame.payload || !Array.isArray(frame.payload)) {
74
+ return null;
75
+ }
76
+ // Convert array back to Uint8Array
77
+ return Uint8Array.from(frame.payload);
78
+ }
79
+ /**
80
+ * Check if raw data looks like a transport frame
81
+ *
82
+ * @param raw - Raw data from the bus
83
+ * @returns True if this appears to be a transport frame
84
+ */
85
+ export function isTransportFrame(raw) {
86
+ if (!raw || typeof raw !== 'object') {
87
+ return false;
88
+ }
89
+ const frame = raw;
90
+ return (typeof frame.v === 'number' &&
91
+ typeof frame.src === 'string' &&
92
+ typeof frame.dst === 'string' &&
93
+ Array.isArray(frame.payload));
94
+ }
@@ -19,6 +19,14 @@ export function isBroadcastChannelConnectionGrant(candidate) {
19
19
  record.inboxCapacity <= 0)) {
20
20
  return false;
21
21
  }
22
+ if (record.localNodeId !== undefined &&
23
+ (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
24
+ return false;
25
+ }
26
+ if (record.remoteNodeId !== undefined &&
27
+ (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
28
+ return false;
29
+ }
22
30
  return true;
23
31
  }
24
32
  export function normalizeBroadcastChannelConnectionGrant(candidate) {
@@ -52,6 +60,20 @@ export function normalizeBroadcastChannelConnectionGrant(candidate) {
52
60
  }
53
61
  result.inboxCapacity = Math.floor(inboxValue);
54
62
  }
63
+ const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
64
+ if (localNodeIdValue !== undefined) {
65
+ if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
66
+ throw new TypeError('BroadcastChannelConnectionGrant "localNodeId" must be a non-empty string when provided');
67
+ }
68
+ result.localNodeId = localNodeIdValue.trim();
69
+ }
70
+ const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
71
+ if (remoteNodeIdValue !== undefined) {
72
+ if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
73
+ throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
74
+ }
75
+ result.remoteNodeId = remoteNodeIdValue.trim();
76
+ }
55
77
  return result;
56
78
  }
57
79
  export function broadcastChannelGrantToConnectorConfig(grant) {
@@ -65,5 +87,11 @@ export function broadcastChannelGrantToConnectorConfig(grant) {
65
87
  if (normalized.inboxCapacity !== undefined) {
66
88
  config.inboxCapacity = normalized.inboxCapacity;
67
89
  }
90
+ if (normalized.localNodeId) {
91
+ config.localNodeId = normalized.localNodeId;
92
+ }
93
+ if (normalized.remoteNodeId) {
94
+ config.remoteNodeId = normalized.remoteNodeId;
95
+ }
68
96
  return config;
69
97
  }
@@ -19,6 +19,14 @@ export function isInPageConnectionGrant(candidate) {
19
19
  record.inboxCapacity <= 0)) {
20
20
  return false;
21
21
  }
22
+ if (record.localNodeId !== undefined &&
23
+ (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
24
+ return false;
25
+ }
26
+ if (record.remoteNodeId !== undefined &&
27
+ (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
28
+ return false;
29
+ }
22
30
  return true;
23
31
  }
24
32
  export function normalizeInPageConnectionGrant(candidate) {
@@ -52,6 +60,20 @@ export function normalizeInPageConnectionGrant(candidate) {
52
60
  }
53
61
  result.inboxCapacity = Math.floor(inboxValue);
54
62
  }
63
+ const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
64
+ if (localNodeIdValue !== undefined) {
65
+ if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
66
+ throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
67
+ }
68
+ result.localNodeId = localNodeIdValue.trim();
69
+ }
70
+ const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
71
+ if (remoteNodeIdValue !== undefined) {
72
+ if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
73
+ throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
74
+ }
75
+ result.remoteNodeId = remoteNodeIdValue.trim();
76
+ }
55
77
  return result;
56
78
  }
57
79
  export function inPageGrantToConnectorConfig(grant) {
@@ -65,5 +87,11 @@ export function inPageGrantToConnectorConfig(grant) {
65
87
  if (normalized.inboxCapacity !== undefined) {
66
88
  config.inboxCapacity = normalized.inboxCapacity;
67
89
  }
90
+ if (normalized.localNodeId) {
91
+ config.localNodeId = normalized.localNodeId;
92
+ }
93
+ if (normalized.remoteNodeId) {
94
+ config.remoteNodeId = normalized.remoteNodeId;
95
+ }
68
96
  return config;
69
97
  }
@@ -385,7 +385,7 @@ export class UpstreamSessionManager extends TaskSpawner {
385
385
  this.currentStopSubtasks = null;
386
386
  await Promise.allSettled(tasks.map((task) => task.promise));
387
387
  if (this.connector) {
388
- logger.info('upstream_stopping_old_connector', {
388
+ logger.debug('upstream_stopping_old_connector', {
389
389
  connect_epoch: this.connectEpoch,
390
390
  target_system_id: this.targetSystemId,
391
391
  timestamp: new Date().toISOString(),
@@ -396,7 +396,7 @@ export class UpstreamSessionManager extends TaskSpawner {
396
396
  error: err instanceof Error ? err.message : String(err),
397
397
  });
398
398
  });
399
- logger.info('upstream_old_connector_stopped', {
399
+ logger.debug('upstream_old_connector_stopped', {
400
400
  connect_epoch: this.connectEpoch,
401
401
  target_system_id: this.targetSystemId,
402
402
  timestamp: new Date().toISOString(),
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated during build - do not edit manually
2
- // Generated from package.json version: 0.3.5-test.941
2
+ // Generated from package.json version: 0.3.5-test.943
3
3
  /**
4
4
  * The package version, injected at build time.
5
5
  * @internal
6
6
  */
7
- export const VERSION = '0.3.5-test.941';
7
+ export const VERSION = '0.3.5-test.943';