@naylence/runtime 0.3.5-test.962 → 0.3.5-test.963

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.
@@ -98,12 +98,12 @@ installProcessEnvShim();
98
98
  // --- END ENV SHIM ---
99
99
 
100
100
  // This file is auto-generated during build - do not edit manually
101
- // Generated from package.json version: 0.3.5-test.962
101
+ // Generated from package.json version: 0.3.5-test.963
102
102
  /**
103
103
  * The package version, injected at build time.
104
104
  * @internal
105
105
  */
106
- const VERSION = '0.3.5-test.962';
106
+ const VERSION = '0.3.5-test.963';
107
107
 
108
108
  /**
109
109
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10993,6 +10993,20 @@ class UpstreamSessionManager extends TaskSpawner {
10993
10993
  waitEvent(event, signal) {
10994
10994
  return signal ? event.wait({ signal }) : event.wait();
10995
10995
  }
10996
+ _getLocalNodeId() {
10997
+ const normalized = this._normalizeNodeId(this.node.id);
10998
+ if (!normalized) {
10999
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
11000
+ }
11001
+ return normalized;
11002
+ }
11003
+ _normalizeNodeId(value) {
11004
+ if (typeof value !== 'string') {
11005
+ return null;
11006
+ }
11007
+ const trimmed = value.trim();
11008
+ return trimmed.length > 0 ? trimmed : null;
11009
+ }
10996
11010
  async connectCycle() {
10997
11011
  if (!this.admissionClient) {
10998
11012
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -11014,6 +11028,8 @@ class UpstreamSessionManager extends TaskSpawner {
11014
11028
  await this.onWelcome(welcome.frame);
11015
11029
  const connector = await ConnectorFactory.createConnector(grant, {
11016
11030
  systemId: welcome.frame.systemId,
11031
+ localNodeId: this._getLocalNodeId(),
11032
+ initialTargetNodeId: '*',
11017
11033
  });
11018
11034
  await connector.start(this.wrappedHandler);
11019
11035
  this.connector = connector;
@@ -11039,6 +11055,20 @@ class UpstreamSessionManager extends TaskSpawner {
11039
11055
  }
11040
11056
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
11041
11057
  this.targetSystemId = attachInfo.targetSystemId ?? null;
11058
+ if (this.targetSystemId) {
11059
+ const targetAware = connector;
11060
+ if (typeof targetAware.setTargetNodeId === 'function') {
11061
+ try {
11062
+ targetAware.setTargetNodeId(this.targetSystemId);
11063
+ }
11064
+ catch (error) {
11065
+ logger$Z.warning('broadcast_channel_target_apply_failed', {
11066
+ error: error instanceof Error ? error.message : String(error),
11067
+ target_node_id: this.targetSystemId,
11068
+ });
11069
+ }
11070
+ }
11071
+ }
11042
11072
  await this.onAttach(attachInfo, connector);
11043
11073
  // Close the admission client immediately after attach completes
11044
11074
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -29058,13 +29088,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29058
29088
  }
29059
29089
  const normalized = this._normalizeConfig(config);
29060
29090
  const options = (factoryArgs[0] ?? {});
29061
- const localNodeId = this._normalizeNodeId(options.localNodeId);
29091
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
29092
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
29062
29093
  if (!localNodeId) {
29063
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
29094
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
29064
29095
  }
29065
29096
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$4;
29066
29097
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$4;
29067
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
29098
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
29099
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
29100
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
29068
29101
  const baseConfig = {
29069
29102
  drainTimeout: normalized.drainTimeout,
29070
29103
  flowControl: normalized.flowControl,
@@ -29105,17 +29138,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29105
29138
  }
29106
29139
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
29107
29140
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
29108
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
29109
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
29110
- }
29111
- else if (initialTargetNodeId === '*') {
29112
- normalized.initialTargetNodeId = '*';
29141
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
29142
+ if (normalizedTarget) {
29143
+ normalized.initialTargetNodeId = normalizedTarget;
29113
29144
  }
29114
29145
  if (typeof capacity === 'number' &&
29115
29146
  Number.isFinite(capacity) &&
29116
29147
  capacity > 0) {
29117
29148
  normalized.inboxCapacity = Math.floor(capacity);
29118
29149
  }
29150
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29151
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
29152
+ if (normalizedLocalNodeId) {
29153
+ normalized.localNodeId = normalizedLocalNodeId;
29154
+ }
29119
29155
  if (typeof candidate.flowControl === 'boolean') {
29120
29156
  normalized.flowControl = candidate.flowControl;
29121
29157
  }
@@ -29162,10 +29198,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29162
29198
  return trimmed.length > 0 ? trimmed : null;
29163
29199
  }
29164
29200
  _normalizeTargetNodeId(value) {
29201
+ if (value === undefined || value === null) {
29202
+ return undefined;
29203
+ }
29165
29204
  if (value === '*') {
29166
29205
  return '*';
29167
29206
  }
29168
- return this._normalizeNodeId(value) ?? '*';
29207
+ return this._normalizeNodeId(value) ?? undefined;
29169
29208
  }
29170
29209
  }
29171
29210
 
@@ -96,12 +96,12 @@ installProcessEnvShim();
96
96
  // --- END ENV SHIM ---
97
97
 
98
98
  // This file is auto-generated during build - do not edit manually
99
- // Generated from package.json version: 0.3.5-test.962
99
+ // Generated from package.json version: 0.3.5-test.963
100
100
  /**
101
101
  * The package version, injected at build time.
102
102
  * @internal
103
103
  */
104
- const VERSION = '0.3.5-test.962';
104
+ const VERSION = '0.3.5-test.963';
105
105
 
106
106
  /**
107
107
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10991,6 +10991,20 @@ class UpstreamSessionManager extends TaskSpawner {
10991
10991
  waitEvent(event, signal) {
10992
10992
  return signal ? event.wait({ signal }) : event.wait();
10993
10993
  }
10994
+ _getLocalNodeId() {
10995
+ const normalized = this._normalizeNodeId(this.node.id);
10996
+ if (!normalized) {
10997
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
10998
+ }
10999
+ return normalized;
11000
+ }
11001
+ _normalizeNodeId(value) {
11002
+ if (typeof value !== 'string') {
11003
+ return null;
11004
+ }
11005
+ const trimmed = value.trim();
11006
+ return trimmed.length > 0 ? trimmed : null;
11007
+ }
10994
11008
  async connectCycle() {
10995
11009
  if (!this.admissionClient) {
10996
11010
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -11012,6 +11026,8 @@ class UpstreamSessionManager extends TaskSpawner {
11012
11026
  await this.onWelcome(welcome.frame);
11013
11027
  const connector = await ConnectorFactory.createConnector(grant, {
11014
11028
  systemId: welcome.frame.systemId,
11029
+ localNodeId: this._getLocalNodeId(),
11030
+ initialTargetNodeId: '*',
11015
11031
  });
11016
11032
  await connector.start(this.wrappedHandler);
11017
11033
  this.connector = connector;
@@ -11037,6 +11053,20 @@ class UpstreamSessionManager extends TaskSpawner {
11037
11053
  }
11038
11054
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
11039
11055
  this.targetSystemId = attachInfo.targetSystemId ?? null;
11056
+ if (this.targetSystemId) {
11057
+ const targetAware = connector;
11058
+ if (typeof targetAware.setTargetNodeId === 'function') {
11059
+ try {
11060
+ targetAware.setTargetNodeId(this.targetSystemId);
11061
+ }
11062
+ catch (error) {
11063
+ logger$Z.warning('broadcast_channel_target_apply_failed', {
11064
+ error: error instanceof Error ? error.message : String(error),
11065
+ target_node_id: this.targetSystemId,
11066
+ });
11067
+ }
11068
+ }
11069
+ }
11040
11070
  await this.onAttach(attachInfo, connector);
11041
11071
  // Close the admission client immediately after attach completes
11042
11072
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -29056,13 +29086,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29056
29086
  }
29057
29087
  const normalized = this._normalizeConfig(config);
29058
29088
  const options = (factoryArgs[0] ?? {});
29059
- const localNodeId = this._normalizeNodeId(options.localNodeId);
29089
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
29090
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
29060
29091
  if (!localNodeId) {
29061
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
29092
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
29062
29093
  }
29063
29094
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$4;
29064
29095
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$4;
29065
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
29096
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
29097
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
29098
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
29066
29099
  const baseConfig = {
29067
29100
  drainTimeout: normalized.drainTimeout,
29068
29101
  flowControl: normalized.flowControl,
@@ -29103,17 +29136,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29103
29136
  }
29104
29137
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
29105
29138
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
29106
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
29107
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
29108
- }
29109
- else if (initialTargetNodeId === '*') {
29110
- normalized.initialTargetNodeId = '*';
29139
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
29140
+ if (normalizedTarget) {
29141
+ normalized.initialTargetNodeId = normalizedTarget;
29111
29142
  }
29112
29143
  if (typeof capacity === 'number' &&
29113
29144
  Number.isFinite(capacity) &&
29114
29145
  capacity > 0) {
29115
29146
  normalized.inboxCapacity = Math.floor(capacity);
29116
29147
  }
29148
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29149
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
29150
+ if (normalizedLocalNodeId) {
29151
+ normalized.localNodeId = normalizedLocalNodeId;
29152
+ }
29117
29153
  if (typeof candidate.flowControl === 'boolean') {
29118
29154
  normalized.flowControl = candidate.flowControl;
29119
29155
  }
@@ -29160,10 +29196,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29160
29196
  return trimmed.length > 0 ? trimmed : null;
29161
29197
  }
29162
29198
  _normalizeTargetNodeId(value) {
29199
+ if (value === undefined || value === null) {
29200
+ return undefined;
29201
+ }
29163
29202
  if (value === '*') {
29164
29203
  return '*';
29165
29204
  }
29166
- return this._normalizeNodeId(value) ?? '*';
29205
+ return this._normalizeNodeId(value) ?? undefined;
29167
29206
  }
29168
29207
  }
29169
29208
 
@@ -75,13 +75,16 @@ class BroadcastChannelConnectorFactory extends connector_factory_js_1.ConnectorF
75
75
  }
76
76
  const normalized = this._normalizeConfig(config);
77
77
  const options = (factoryArgs[0] ?? {});
78
- const localNodeId = this._normalizeNodeId(options.localNodeId);
78
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
79
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
79
80
  if (!localNodeId) {
80
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
81
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
81
82
  }
82
83
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL;
83
84
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
84
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
85
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
86
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
87
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
85
88
  const baseConfig = {
86
89
  drainTimeout: normalized.drainTimeout,
87
90
  flowControl: normalized.flowControl,
@@ -122,17 +125,20 @@ class BroadcastChannelConnectorFactory extends connector_factory_js_1.ConnectorF
122
125
  }
123
126
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
124
127
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
125
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
126
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
127
- }
128
- else if (initialTargetNodeId === '*') {
129
- normalized.initialTargetNodeId = '*';
128
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
129
+ if (normalizedTarget) {
130
+ normalized.initialTargetNodeId = normalizedTarget;
130
131
  }
131
132
  if (typeof capacity === 'number' &&
132
133
  Number.isFinite(capacity) &&
133
134
  capacity > 0) {
134
135
  normalized.inboxCapacity = Math.floor(capacity);
135
136
  }
137
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
138
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
139
+ if (normalizedLocalNodeId) {
140
+ normalized.localNodeId = normalizedLocalNodeId;
141
+ }
136
142
  if (typeof candidate.flowControl === 'boolean') {
137
143
  normalized.flowControl = candidate.flowControl;
138
144
  }
@@ -179,10 +185,13 @@ class BroadcastChannelConnectorFactory extends connector_factory_js_1.ConnectorF
179
185
  return trimmed.length > 0 ? trimmed : null;
180
186
  }
181
187
  _normalizeTargetNodeId(value) {
188
+ if (value === undefined || value === null) {
189
+ return undefined;
190
+ }
182
191
  if (value === '*') {
183
192
  return '*';
184
193
  }
185
- return this._normalizeNodeId(value) ?? '*';
194
+ return this._normalizeNodeId(value) ?? undefined;
186
195
  }
187
196
  }
188
197
  exports.BroadcastChannelConnectorFactory = BroadcastChannelConnectorFactory;
@@ -280,6 +280,20 @@ class UpstreamSessionManager extends task_spawner_js_1.TaskSpawner {
280
280
  waitEvent(event, signal) {
281
281
  return signal ? event.wait({ signal }) : event.wait();
282
282
  }
283
+ _getLocalNodeId() {
284
+ const normalized = this._normalizeNodeId(this.node.id);
285
+ if (!normalized) {
286
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
287
+ }
288
+ return normalized;
289
+ }
290
+ _normalizeNodeId(value) {
291
+ if (typeof value !== 'string') {
292
+ return null;
293
+ }
294
+ const trimmed = value.trim();
295
+ return trimmed.length > 0 ? trimmed : null;
296
+ }
283
297
  async connectCycle() {
284
298
  if (!this.admissionClient) {
285
299
  throw new errors_js_1.FameConnectError('Admission client is required to attach upstream');
@@ -301,6 +315,8 @@ class UpstreamSessionManager extends task_spawner_js_1.TaskSpawner {
301
315
  await this.onWelcome(welcome.frame);
302
316
  const connector = await connector_factory_js_1.ConnectorFactory.createConnector(grant, {
303
317
  systemId: welcome.frame.systemId,
318
+ localNodeId: this._getLocalNodeId(),
319
+ initialTargetNodeId: '*',
304
320
  });
305
321
  await connector.start(this.wrappedHandler);
306
322
  this.connector = connector;
@@ -326,6 +342,20 @@ class UpstreamSessionManager extends task_spawner_js_1.TaskSpawner {
326
342
  }
327
343
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
328
344
  this.targetSystemId = attachInfo.targetSystemId ?? null;
345
+ if (this.targetSystemId) {
346
+ const targetAware = connector;
347
+ if (typeof targetAware.setTargetNodeId === 'function') {
348
+ try {
349
+ targetAware.setTargetNodeId(this.targetSystemId);
350
+ }
351
+ catch (error) {
352
+ logger.warning('broadcast_channel_target_apply_failed', {
353
+ error: error instanceof Error ? error.message : String(error),
354
+ target_node_id: this.targetSystemId,
355
+ });
356
+ }
357
+ }
358
+ }
329
359
  await this.onAttach(attachInfo, connector);
330
360
  // Close the admission client immediately after attach completes
331
361
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // This file is auto-generated during build - do not edit manually
3
- // Generated from package.json version: 0.3.5-test.962
3
+ // Generated from package.json version: 0.3.5-test.963
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.VERSION = void 0;
6
6
  /**
7
7
  * The package version, injected at build time.
8
8
  * @internal
9
9
  */
10
- exports.VERSION = '0.3.5-test.962';
10
+ exports.VERSION = '0.3.5-test.963';
@@ -72,13 +72,16 @@ export class BroadcastChannelConnectorFactory extends ConnectorFactory {
72
72
  }
73
73
  const normalized = this._normalizeConfig(config);
74
74
  const options = (factoryArgs[0] ?? {});
75
- const localNodeId = this._normalizeNodeId(options.localNodeId);
75
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
76
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
76
77
  if (!localNodeId) {
77
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
78
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
78
79
  }
79
80
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL;
80
81
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
81
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
82
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
83
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
84
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
82
85
  const baseConfig = {
83
86
  drainTimeout: normalized.drainTimeout,
84
87
  flowControl: normalized.flowControl,
@@ -119,17 +122,20 @@ export class BroadcastChannelConnectorFactory extends ConnectorFactory {
119
122
  }
120
123
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
121
124
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
122
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
123
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
124
- }
125
- else if (initialTargetNodeId === '*') {
126
- normalized.initialTargetNodeId = '*';
125
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
126
+ if (normalizedTarget) {
127
+ normalized.initialTargetNodeId = normalizedTarget;
127
128
  }
128
129
  if (typeof capacity === 'number' &&
129
130
  Number.isFinite(capacity) &&
130
131
  capacity > 0) {
131
132
  normalized.inboxCapacity = Math.floor(capacity);
132
133
  }
134
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
135
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
136
+ if (normalizedLocalNodeId) {
137
+ normalized.localNodeId = normalizedLocalNodeId;
138
+ }
133
139
  if (typeof candidate.flowControl === 'boolean') {
134
140
  normalized.flowControl = candidate.flowControl;
135
141
  }
@@ -176,10 +182,13 @@ export class BroadcastChannelConnectorFactory extends ConnectorFactory {
176
182
  return trimmed.length > 0 ? trimmed : null;
177
183
  }
178
184
  _normalizeTargetNodeId(value) {
185
+ if (value === undefined || value === null) {
186
+ return undefined;
187
+ }
179
188
  if (value === '*') {
180
189
  return '*';
181
190
  }
182
- return this._normalizeNodeId(value) ?? '*';
191
+ return this._normalizeNodeId(value) ?? undefined;
183
192
  }
184
193
  }
185
194
  export default BroadcastChannelConnectorFactory;
@@ -277,6 +277,20 @@ export class UpstreamSessionManager extends TaskSpawner {
277
277
  waitEvent(event, signal) {
278
278
  return signal ? event.wait({ signal }) : event.wait();
279
279
  }
280
+ _getLocalNodeId() {
281
+ const normalized = this._normalizeNodeId(this.node.id);
282
+ if (!normalized) {
283
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
284
+ }
285
+ return normalized;
286
+ }
287
+ _normalizeNodeId(value) {
288
+ if (typeof value !== 'string') {
289
+ return null;
290
+ }
291
+ const trimmed = value.trim();
292
+ return trimmed.length > 0 ? trimmed : null;
293
+ }
280
294
  async connectCycle() {
281
295
  if (!this.admissionClient) {
282
296
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -298,6 +312,8 @@ export class UpstreamSessionManager extends TaskSpawner {
298
312
  await this.onWelcome(welcome.frame);
299
313
  const connector = await ConnectorFactory.createConnector(grant, {
300
314
  systemId: welcome.frame.systemId,
315
+ localNodeId: this._getLocalNodeId(),
316
+ initialTargetNodeId: '*',
301
317
  });
302
318
  await connector.start(this.wrappedHandler);
303
319
  this.connector = connector;
@@ -323,6 +339,20 @@ export class UpstreamSessionManager extends TaskSpawner {
323
339
  }
324
340
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
325
341
  this.targetSystemId = attachInfo.targetSystemId ?? null;
342
+ if (this.targetSystemId) {
343
+ const targetAware = connector;
344
+ if (typeof targetAware.setTargetNodeId === 'function') {
345
+ try {
346
+ targetAware.setTargetNodeId(this.targetSystemId);
347
+ }
348
+ catch (error) {
349
+ logger.warning('broadcast_channel_target_apply_failed', {
350
+ error: error instanceof Error ? error.message : String(error),
351
+ target_node_id: this.targetSystemId,
352
+ });
353
+ }
354
+ }
355
+ }
326
356
  await this.onAttach(attachInfo, connector);
327
357
  // Close the admission client immediately after attach completes
328
358
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -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.962
2
+ // Generated from package.json version: 0.3.5-test.963
3
3
  /**
4
4
  * The package version, injected at build time.
5
5
  * @internal
6
6
  */
7
- export const VERSION = '0.3.5-test.962';
7
+ export const VERSION = '0.3.5-test.963';
@@ -14,12 +14,12 @@ var fastify = require('fastify');
14
14
  var websocketPlugin = require('@fastify/websocket');
15
15
 
16
16
  // This file is auto-generated during build - do not edit manually
17
- // Generated from package.json version: 0.3.5-test.962
17
+ // Generated from package.json version: 0.3.5-test.963
18
18
  /**
19
19
  * The package version, injected at build time.
20
20
  * @internal
21
21
  */
22
- const VERSION = '0.3.5-test.962';
22
+ const VERSION = '0.3.5-test.963';
23
23
 
24
24
  /**
25
25
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10909,6 +10909,20 @@ class UpstreamSessionManager extends TaskSpawner {
10909
10909
  waitEvent(event, signal) {
10910
10910
  return signal ? event.wait({ signal }) : event.wait();
10911
10911
  }
10912
+ _getLocalNodeId() {
10913
+ const normalized = this._normalizeNodeId(this.node.id);
10914
+ if (!normalized) {
10915
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
10916
+ }
10917
+ return normalized;
10918
+ }
10919
+ _normalizeNodeId(value) {
10920
+ if (typeof value !== 'string') {
10921
+ return null;
10922
+ }
10923
+ const trimmed = value.trim();
10924
+ return trimmed.length > 0 ? trimmed : null;
10925
+ }
10912
10926
  async connectCycle() {
10913
10927
  if (!this.admissionClient) {
10914
10928
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -10930,6 +10944,8 @@ class UpstreamSessionManager extends TaskSpawner {
10930
10944
  await this.onWelcome(welcome.frame);
10931
10945
  const connector = await ConnectorFactory.createConnector(grant, {
10932
10946
  systemId: welcome.frame.systemId,
10947
+ localNodeId: this._getLocalNodeId(),
10948
+ initialTargetNodeId: '*',
10933
10949
  });
10934
10950
  await connector.start(this.wrappedHandler);
10935
10951
  this.connector = connector;
@@ -10955,6 +10971,20 @@ class UpstreamSessionManager extends TaskSpawner {
10955
10971
  }
10956
10972
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
10957
10973
  this.targetSystemId = attachInfo.targetSystemId ?? null;
10974
+ if (this.targetSystemId) {
10975
+ const targetAware = connector;
10976
+ if (typeof targetAware.setTargetNodeId === 'function') {
10977
+ try {
10978
+ targetAware.setTargetNodeId(this.targetSystemId);
10979
+ }
10980
+ catch (error) {
10981
+ logger$Z.warning('broadcast_channel_target_apply_failed', {
10982
+ error: error instanceof Error ? error.message : String(error),
10983
+ target_node_id: this.targetSystemId,
10984
+ });
10985
+ }
10986
+ }
10987
+ }
10958
10988
  await this.onAttach(attachInfo, connector);
10959
10989
  // Close the admission client immediately after attach completes
10960
10990
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -28812,13 +28842,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28812
28842
  }
28813
28843
  const normalized = this._normalizeConfig(config);
28814
28844
  const options = (factoryArgs[0] ?? {});
28815
- const localNodeId = this._normalizeNodeId(options.localNodeId);
28845
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
28846
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
28816
28847
  if (!localNodeId) {
28817
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
28848
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
28818
28849
  }
28819
28850
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28820
28851
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
28821
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
28852
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
28853
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
28854
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
28822
28855
  const baseConfig = {
28823
28856
  drainTimeout: normalized.drainTimeout,
28824
28857
  flowControl: normalized.flowControl,
@@ -28859,17 +28892,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28859
28892
  }
28860
28893
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
28861
28894
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
28862
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
28863
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
28864
- }
28865
- else if (initialTargetNodeId === '*') {
28866
- normalized.initialTargetNodeId = '*';
28895
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
28896
+ if (normalizedTarget) {
28897
+ normalized.initialTargetNodeId = normalizedTarget;
28867
28898
  }
28868
28899
  if (typeof capacity === 'number' &&
28869
28900
  Number.isFinite(capacity) &&
28870
28901
  capacity > 0) {
28871
28902
  normalized.inboxCapacity = Math.floor(capacity);
28872
28903
  }
28904
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
28905
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
28906
+ if (normalizedLocalNodeId) {
28907
+ normalized.localNodeId = normalizedLocalNodeId;
28908
+ }
28873
28909
  if (typeof candidate.flowControl === 'boolean') {
28874
28910
  normalized.flowControl = candidate.flowControl;
28875
28911
  }
@@ -28916,10 +28952,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28916
28952
  return trimmed.length > 0 ? trimmed : null;
28917
28953
  }
28918
28954
  _normalizeTargetNodeId(value) {
28955
+ if (value === undefined || value === null) {
28956
+ return undefined;
28957
+ }
28919
28958
  if (value === '*') {
28920
28959
  return '*';
28921
28960
  }
28922
- return this._normalizeNodeId(value) ?? '*';
28961
+ return this._normalizeNodeId(value) ?? undefined;
28923
28962
  }
28924
28963
  }
28925
28964
 
@@ -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.962
16
+ // Generated from package.json version: 0.3.5-test.963
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.5-test.962';
21
+ const VERSION = '0.3.5-test.963';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10908,6 +10908,20 @@ class UpstreamSessionManager extends TaskSpawner {
10908
10908
  waitEvent(event, signal) {
10909
10909
  return signal ? event.wait({ signal }) : event.wait();
10910
10910
  }
10911
+ _getLocalNodeId() {
10912
+ const normalized = this._normalizeNodeId(this.node.id);
10913
+ if (!normalized) {
10914
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
10915
+ }
10916
+ return normalized;
10917
+ }
10918
+ _normalizeNodeId(value) {
10919
+ if (typeof value !== 'string') {
10920
+ return null;
10921
+ }
10922
+ const trimmed = value.trim();
10923
+ return trimmed.length > 0 ? trimmed : null;
10924
+ }
10911
10925
  async connectCycle() {
10912
10926
  if (!this.admissionClient) {
10913
10927
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -10929,6 +10943,8 @@ class UpstreamSessionManager extends TaskSpawner {
10929
10943
  await this.onWelcome(welcome.frame);
10930
10944
  const connector = await ConnectorFactory.createConnector(grant, {
10931
10945
  systemId: welcome.frame.systemId,
10946
+ localNodeId: this._getLocalNodeId(),
10947
+ initialTargetNodeId: '*',
10932
10948
  });
10933
10949
  await connector.start(this.wrappedHandler);
10934
10950
  this.connector = connector;
@@ -10954,6 +10970,20 @@ class UpstreamSessionManager extends TaskSpawner {
10954
10970
  }
10955
10971
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
10956
10972
  this.targetSystemId = attachInfo.targetSystemId ?? null;
10973
+ if (this.targetSystemId) {
10974
+ const targetAware = connector;
10975
+ if (typeof targetAware.setTargetNodeId === 'function') {
10976
+ try {
10977
+ targetAware.setTargetNodeId(this.targetSystemId);
10978
+ }
10979
+ catch (error) {
10980
+ logger$Z.warning('broadcast_channel_target_apply_failed', {
10981
+ error: error instanceof Error ? error.message : String(error),
10982
+ target_node_id: this.targetSystemId,
10983
+ });
10984
+ }
10985
+ }
10986
+ }
10957
10987
  await this.onAttach(attachInfo, connector);
10958
10988
  // Close the admission client immediately after attach completes
10959
10989
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -28811,13 +28841,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28811
28841
  }
28812
28842
  const normalized = this._normalizeConfig(config);
28813
28843
  const options = (factoryArgs[0] ?? {});
28814
- const localNodeId = this._normalizeNodeId(options.localNodeId);
28844
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
28845
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
28815
28846
  if (!localNodeId) {
28816
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
28847
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
28817
28848
  }
28818
28849
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28819
28850
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
28820
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
28851
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
28852
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
28853
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
28821
28854
  const baseConfig = {
28822
28855
  drainTimeout: normalized.drainTimeout,
28823
28856
  flowControl: normalized.flowControl,
@@ -28858,17 +28891,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28858
28891
  }
28859
28892
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
28860
28893
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
28861
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
28862
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
28863
- }
28864
- else if (initialTargetNodeId === '*') {
28865
- normalized.initialTargetNodeId = '*';
28894
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
28895
+ if (normalizedTarget) {
28896
+ normalized.initialTargetNodeId = normalizedTarget;
28866
28897
  }
28867
28898
  if (typeof capacity === 'number' &&
28868
28899
  Number.isFinite(capacity) &&
28869
28900
  capacity > 0) {
28870
28901
  normalized.inboxCapacity = Math.floor(capacity);
28871
28902
  }
28903
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
28904
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
28905
+ if (normalizedLocalNodeId) {
28906
+ normalized.localNodeId = normalizedLocalNodeId;
28907
+ }
28872
28908
  if (typeof candidate.flowControl === 'boolean') {
28873
28909
  normalized.flowControl = candidate.flowControl;
28874
28910
  }
@@ -28915,10 +28951,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28915
28951
  return trimmed.length > 0 ? trimmed : null;
28916
28952
  }
28917
28953
  _normalizeTargetNodeId(value) {
28954
+ if (value === undefined || value === null) {
28955
+ return undefined;
28956
+ }
28918
28957
  if (value === '*') {
28919
28958
  return '*';
28920
28959
  }
28921
- return this._normalizeNodeId(value) ?? '*';
28960
+ return this._normalizeNodeId(value) ?? undefined;
28922
28961
  }
28923
28962
  }
28924
28963
 
@@ -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.962
5566
+ // Generated from package.json version: 0.3.5-test.963
5567
5567
  /**
5568
5568
  * The package version, injected at build time.
5569
5569
  * @internal
5570
5570
  */
5571
- const VERSION = '0.3.5-test.962';
5571
+ const VERSION = '0.3.5-test.963';
5572
5572
 
5573
5573
  /**
5574
5574
  * Fame errors module - Fame protocol specific error classes
@@ -12601,6 +12601,20 @@ class UpstreamSessionManager extends TaskSpawner {
12601
12601
  waitEvent(event, signal) {
12602
12602
  return signal ? event.wait({ signal }) : event.wait();
12603
12603
  }
12604
+ _getLocalNodeId() {
12605
+ const normalized = this._normalizeNodeId(this.node.id);
12606
+ if (!normalized) {
12607
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
12608
+ }
12609
+ return normalized;
12610
+ }
12611
+ _normalizeNodeId(value) {
12612
+ if (typeof value !== 'string') {
12613
+ return null;
12614
+ }
12615
+ const trimmed = value.trim();
12616
+ return trimmed.length > 0 ? trimmed : null;
12617
+ }
12604
12618
  async connectCycle() {
12605
12619
  if (!this.admissionClient) {
12606
12620
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -12622,6 +12636,8 @@ class UpstreamSessionManager extends TaskSpawner {
12622
12636
  await this.onWelcome(welcome.frame);
12623
12637
  const connector = await ConnectorFactory.createConnector(grant, {
12624
12638
  systemId: welcome.frame.systemId,
12639
+ localNodeId: this._getLocalNodeId(),
12640
+ initialTargetNodeId: '*',
12625
12641
  });
12626
12642
  await connector.start(this.wrappedHandler);
12627
12643
  this.connector = connector;
@@ -12647,6 +12663,20 @@ class UpstreamSessionManager extends TaskSpawner {
12647
12663
  }
12648
12664
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
12649
12665
  this.targetSystemId = attachInfo.targetSystemId ?? null;
12666
+ if (this.targetSystemId) {
12667
+ const targetAware = connector;
12668
+ if (typeof targetAware.setTargetNodeId === 'function') {
12669
+ try {
12670
+ targetAware.setTargetNodeId(this.targetSystemId);
12671
+ }
12672
+ catch (error) {
12673
+ logger$$.warning('broadcast_channel_target_apply_failed', {
12674
+ error: error instanceof Error ? error.message : String(error),
12675
+ target_node_id: this.targetSystemId,
12676
+ });
12677
+ }
12678
+ }
12679
+ }
12650
12680
  await this.onAttach(attachInfo, connector);
12651
12681
  // Close the admission client immediately after attach completes
12652
12682
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -30745,13 +30775,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30745
30775
  }
30746
30776
  const normalized = this._normalizeConfig(config);
30747
30777
  const options = (factoryArgs[0] ?? {});
30748
- const localNodeId = this._normalizeNodeId(options.localNodeId);
30778
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
30779
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
30749
30780
  if (!localNodeId) {
30750
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
30781
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
30751
30782
  }
30752
30783
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$2;
30753
30784
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
30754
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
30785
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
30786
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
30787
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
30755
30788
  const baseConfig = {
30756
30789
  drainTimeout: normalized.drainTimeout,
30757
30790
  flowControl: normalized.flowControl,
@@ -30792,17 +30825,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30792
30825
  }
30793
30826
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
30794
30827
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
30795
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
30796
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
30797
- }
30798
- else if (initialTargetNodeId === '*') {
30799
- normalized.initialTargetNodeId = '*';
30828
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
30829
+ if (normalizedTarget) {
30830
+ normalized.initialTargetNodeId = normalizedTarget;
30800
30831
  }
30801
30832
  if (typeof capacity === 'number' &&
30802
30833
  Number.isFinite(capacity) &&
30803
30834
  capacity > 0) {
30804
30835
  normalized.inboxCapacity = Math.floor(capacity);
30805
30836
  }
30837
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
30838
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
30839
+ if (normalizedLocalNodeId) {
30840
+ normalized.localNodeId = normalizedLocalNodeId;
30841
+ }
30806
30842
  if (typeof candidate.flowControl === 'boolean') {
30807
30843
  normalized.flowControl = candidate.flowControl;
30808
30844
  }
@@ -30849,10 +30885,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30849
30885
  return trimmed.length > 0 ? trimmed : null;
30850
30886
  }
30851
30887
  _normalizeTargetNodeId(value) {
30888
+ if (value === undefined || value === null) {
30889
+ return undefined;
30890
+ }
30852
30891
  if (value === '*') {
30853
30892
  return '*';
30854
30893
  }
30855
- return this._normalizeNodeId(value) ?? '*';
30894
+ return this._normalizeNodeId(value) ?? undefined;
30856
30895
  }
30857
30896
  }
30858
30897
 
@@ -5562,12 +5562,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5562
5562
  }
5563
5563
 
5564
5564
  // This file is auto-generated during build - do not edit manually
5565
- // Generated from package.json version: 0.3.5-test.962
5565
+ // Generated from package.json version: 0.3.5-test.963
5566
5566
  /**
5567
5567
  * The package version, injected at build time.
5568
5568
  * @internal
5569
5569
  */
5570
- const VERSION = '0.3.5-test.962';
5570
+ const VERSION = '0.3.5-test.963';
5571
5571
 
5572
5572
  /**
5573
5573
  * Fame errors module - Fame protocol specific error classes
@@ -12600,6 +12600,20 @@ class UpstreamSessionManager extends TaskSpawner {
12600
12600
  waitEvent(event, signal) {
12601
12601
  return signal ? event.wait({ signal }) : event.wait();
12602
12602
  }
12603
+ _getLocalNodeId() {
12604
+ const normalized = this._normalizeNodeId(this.node.id);
12605
+ if (!normalized) {
12606
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
12607
+ }
12608
+ return normalized;
12609
+ }
12610
+ _normalizeNodeId(value) {
12611
+ if (typeof value !== 'string') {
12612
+ return null;
12613
+ }
12614
+ const trimmed = value.trim();
12615
+ return trimmed.length > 0 ? trimmed : null;
12616
+ }
12603
12617
  async connectCycle() {
12604
12618
  if (!this.admissionClient) {
12605
12619
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -12621,6 +12635,8 @@ class UpstreamSessionManager extends TaskSpawner {
12621
12635
  await this.onWelcome(welcome.frame);
12622
12636
  const connector = await ConnectorFactory.createConnector(grant, {
12623
12637
  systemId: welcome.frame.systemId,
12638
+ localNodeId: this._getLocalNodeId(),
12639
+ initialTargetNodeId: '*',
12624
12640
  });
12625
12641
  await connector.start(this.wrappedHandler);
12626
12642
  this.connector = connector;
@@ -12646,6 +12662,20 @@ class UpstreamSessionManager extends TaskSpawner {
12646
12662
  }
12647
12663
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
12648
12664
  this.targetSystemId = attachInfo.targetSystemId ?? null;
12665
+ if (this.targetSystemId) {
12666
+ const targetAware = connector;
12667
+ if (typeof targetAware.setTargetNodeId === 'function') {
12668
+ try {
12669
+ targetAware.setTargetNodeId(this.targetSystemId);
12670
+ }
12671
+ catch (error) {
12672
+ logger$$.warning('broadcast_channel_target_apply_failed', {
12673
+ error: error instanceof Error ? error.message : String(error),
12674
+ target_node_id: this.targetSystemId,
12675
+ });
12676
+ }
12677
+ }
12678
+ }
12649
12679
  await this.onAttach(attachInfo, connector);
12650
12680
  // Close the admission client immediately after attach completes
12651
12681
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -30744,13 +30774,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30744
30774
  }
30745
30775
  const normalized = this._normalizeConfig(config);
30746
30776
  const options = (factoryArgs[0] ?? {});
30747
- const localNodeId = this._normalizeNodeId(options.localNodeId);
30777
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
30778
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
30748
30779
  if (!localNodeId) {
30749
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
30780
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
30750
30781
  }
30751
30782
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$2;
30752
30783
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
30753
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
30784
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
30785
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
30786
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
30754
30787
  const baseConfig = {
30755
30788
  drainTimeout: normalized.drainTimeout,
30756
30789
  flowControl: normalized.flowControl,
@@ -30791,17 +30824,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30791
30824
  }
30792
30825
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
30793
30826
  const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
30794
- if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
30795
- normalized.initialTargetNodeId = initialTargetNodeId.trim();
30796
- }
30797
- else if (initialTargetNodeId === '*') {
30798
- normalized.initialTargetNodeId = '*';
30827
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
30828
+ if (normalizedTarget) {
30829
+ normalized.initialTargetNodeId = normalizedTarget;
30799
30830
  }
30800
30831
  if (typeof capacity === 'number' &&
30801
30832
  Number.isFinite(capacity) &&
30802
30833
  capacity > 0) {
30803
30834
  normalized.inboxCapacity = Math.floor(capacity);
30804
30835
  }
30836
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
30837
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
30838
+ if (normalizedLocalNodeId) {
30839
+ normalized.localNodeId = normalizedLocalNodeId;
30840
+ }
30805
30841
  if (typeof candidate.flowControl === 'boolean') {
30806
30842
  normalized.flowControl = candidate.flowControl;
30807
30843
  }
@@ -30848,10 +30884,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30848
30884
  return trimmed.length > 0 ? trimmed : null;
30849
30885
  }
30850
30886
  _normalizeTargetNodeId(value) {
30887
+ if (value === undefined || value === null) {
30888
+ return undefined;
30889
+ }
30851
30890
  if (value === '*') {
30852
30891
  return '*';
30853
30892
  }
30854
- return this._normalizeNodeId(value) ?? '*';
30893
+ return this._normalizeNodeId(value) ?? undefined;
30855
30894
  }
30856
30895
  }
30857
30896
 
@@ -7,11 +7,12 @@ export interface BroadcastChannelConnectorFactoryConfig extends ConnectorConfig,
7
7
  type: typeof BROADCAST_CHANNEL_CONNECTOR_TYPE;
8
8
  channelName?: string;
9
9
  inboxCapacity?: number;
10
+ localNodeId?: string;
10
11
  initialTargetNodeId?: string | '*';
11
12
  }
12
13
  export interface CreateBroadcastChannelConnectorOptions {
13
14
  authorization?: AuthorizationContext;
14
- localNodeId: string;
15
+ localNodeId?: string;
15
16
  initialTargetNodeId?: string | '*';
16
17
  }
17
18
  export declare const FACTORY_META: {
@@ -82,6 +82,8 @@ export declare class UpstreamSessionManager extends TaskSpawner implements Sessi
82
82
  private sleepWithStop;
83
83
  private getNodeAttachGrant;
84
84
  private waitEvent;
85
+ private _getLocalNodeId;
86
+ private _normalizeNodeId;
85
87
  private connectCycle;
86
88
  private shouldAdvertiseBroadcastGrant;
87
89
  private createBroadcastCallbackGrant;
@@ -2,4 +2,4 @@
2
2
  * The package version, injected at build time.
3
3
  * @internal
4
4
  */
5
- export declare const VERSION = "0.3.5-test.962";
5
+ export declare const VERSION = "0.3.5-test.963";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naylence/runtime",
3
- "version": "0.3.5-test.962",
3
+ "version": "0.3.5-test.963",
4
4
  "type": "module",
5
5
  "description": "Naylence Runtime - Complete TypeScript runtime",
6
6
  "author": "Naylence Dev <naylencedev@gmail.com>",