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

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.964
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.964';
107
107
 
108
108
  /**
109
109
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10288,7 +10288,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10288
10288
  }
10289
10289
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
10290
10290
  if (this._isWildcardTarget()) {
10291
- if (targetNodeId && targetNodeId !== '*') {
10291
+ if (targetNodeId &&
10292
+ targetNodeId !== '*' &&
10293
+ targetNodeId !== this.localNodeId) {
10292
10294
  logger$_.debug('broadcast_channel_message_rejected', {
10293
10295
  channel: this.channelName,
10294
10296
  connector_id: this.connectorId,
@@ -10993,6 +10995,20 @@ class UpstreamSessionManager extends TaskSpawner {
10993
10995
  waitEvent(event, signal) {
10994
10996
  return signal ? event.wait({ signal }) : event.wait();
10995
10997
  }
10998
+ _getLocalNodeId() {
10999
+ const normalized = this._normalizeNodeId(this.node.id);
11000
+ if (!normalized) {
11001
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
11002
+ }
11003
+ return normalized;
11004
+ }
11005
+ _normalizeNodeId(value) {
11006
+ if (typeof value !== 'string') {
11007
+ return null;
11008
+ }
11009
+ const trimmed = value.trim();
11010
+ return trimmed.length > 0 ? trimmed : null;
11011
+ }
10996
11012
  async connectCycle() {
10997
11013
  if (!this.admissionClient) {
10998
11014
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -11014,6 +11030,8 @@ class UpstreamSessionManager extends TaskSpawner {
11014
11030
  await this.onWelcome(welcome.frame);
11015
11031
  const connector = await ConnectorFactory.createConnector(grant, {
11016
11032
  systemId: welcome.frame.systemId,
11033
+ localNodeId: this._getLocalNodeId(),
11034
+ initialTargetNodeId: '*',
11017
11035
  });
11018
11036
  await connector.start(this.wrappedHandler);
11019
11037
  this.connector = connector;
@@ -11039,6 +11057,20 @@ class UpstreamSessionManager extends TaskSpawner {
11039
11057
  }
11040
11058
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
11041
11059
  this.targetSystemId = attachInfo.targetSystemId ?? null;
11060
+ if (this.targetSystemId) {
11061
+ const targetAware = connector;
11062
+ if (typeof targetAware.setTargetNodeId === 'function') {
11063
+ try {
11064
+ targetAware.setTargetNodeId(this.targetSystemId);
11065
+ }
11066
+ catch (error) {
11067
+ logger$Z.warning('broadcast_channel_target_apply_failed', {
11068
+ error: error instanceof Error ? error.message : String(error),
11069
+ target_node_id: this.targetSystemId,
11070
+ });
11071
+ }
11072
+ }
11073
+ }
11042
11074
  await this.onAttach(attachInfo, connector);
11043
11075
  // Close the admission client immediately after attach completes
11044
11076
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -29058,13 +29090,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29058
29090
  }
29059
29091
  const normalized = this._normalizeConfig(config);
29060
29092
  const options = (factoryArgs[0] ?? {});
29061
- const localNodeId = this._normalizeNodeId(options.localNodeId);
29093
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
29094
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
29062
29095
  if (!localNodeId) {
29063
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
29096
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
29064
29097
  }
29065
29098
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$4;
29066
29099
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$4;
29067
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
29100
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
29101
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
29102
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
29068
29103
  const baseConfig = {
29069
29104
  drainTimeout: normalized.drainTimeout,
29070
29105
  flowControl: normalized.flowControl,
@@ -29105,17 +29140,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29105
29140
  }
29106
29141
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
29107
29142
  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 = '*';
29143
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
29144
+ if (normalizedTarget) {
29145
+ normalized.initialTargetNodeId = normalizedTarget;
29113
29146
  }
29114
29147
  if (typeof capacity === 'number' &&
29115
29148
  Number.isFinite(capacity) &&
29116
29149
  capacity > 0) {
29117
29150
  normalized.inboxCapacity = Math.floor(capacity);
29118
29151
  }
29152
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29153
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
29154
+ if (normalizedLocalNodeId) {
29155
+ normalized.localNodeId = normalizedLocalNodeId;
29156
+ }
29119
29157
  if (typeof candidate.flowControl === 'boolean') {
29120
29158
  normalized.flowControl = candidate.flowControl;
29121
29159
  }
@@ -29162,10 +29200,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29162
29200
  return trimmed.length > 0 ? trimmed : null;
29163
29201
  }
29164
29202
  _normalizeTargetNodeId(value) {
29203
+ if (value === undefined || value === null) {
29204
+ return undefined;
29205
+ }
29165
29206
  if (value === '*') {
29166
29207
  return '*';
29167
29208
  }
29168
- return this._normalizeNodeId(value) ?? '*';
29209
+ return this._normalizeNodeId(value) ?? undefined;
29169
29210
  }
29170
29211
  }
29171
29212
 
@@ -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.964
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.964';
105
105
 
106
106
  /**
107
107
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10286,7 +10286,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10286
10286
  }
10287
10287
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
10288
10288
  if (this._isWildcardTarget()) {
10289
- if (targetNodeId && targetNodeId !== '*') {
10289
+ if (targetNodeId &&
10290
+ targetNodeId !== '*' &&
10291
+ targetNodeId !== this.localNodeId) {
10290
10292
  logger$_.debug('broadcast_channel_message_rejected', {
10291
10293
  channel: this.channelName,
10292
10294
  connector_id: this.connectorId,
@@ -10991,6 +10993,20 @@ class UpstreamSessionManager extends TaskSpawner {
10991
10993
  waitEvent(event, signal) {
10992
10994
  return signal ? event.wait({ signal }) : event.wait();
10993
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
+ }
10994
11010
  async connectCycle() {
10995
11011
  if (!this.admissionClient) {
10996
11012
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -11012,6 +11028,8 @@ class UpstreamSessionManager extends TaskSpawner {
11012
11028
  await this.onWelcome(welcome.frame);
11013
11029
  const connector = await ConnectorFactory.createConnector(grant, {
11014
11030
  systemId: welcome.frame.systemId,
11031
+ localNodeId: this._getLocalNodeId(),
11032
+ initialTargetNodeId: '*',
11015
11033
  });
11016
11034
  await connector.start(this.wrappedHandler);
11017
11035
  this.connector = connector;
@@ -11037,6 +11055,20 @@ class UpstreamSessionManager extends TaskSpawner {
11037
11055
  }
11038
11056
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
11039
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
+ }
11040
11072
  await this.onAttach(attachInfo, connector);
11041
11073
  // Close the admission client immediately after attach completes
11042
11074
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -29056,13 +29088,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29056
29088
  }
29057
29089
  const normalized = this._normalizeConfig(config);
29058
29090
  const options = (factoryArgs[0] ?? {});
29059
- const localNodeId = this._normalizeNodeId(options.localNodeId);
29091
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
29092
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
29060
29093
  if (!localNodeId) {
29061
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
29094
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
29062
29095
  }
29063
29096
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$4;
29064
29097
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$4;
29065
- 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 ?? '*';
29066
29101
  const baseConfig = {
29067
29102
  drainTimeout: normalized.drainTimeout,
29068
29103
  flowControl: normalized.flowControl,
@@ -29103,17 +29138,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29103
29138
  }
29104
29139
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
29105
29140
  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 = '*';
29141
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
29142
+ if (normalizedTarget) {
29143
+ normalized.initialTargetNodeId = normalizedTarget;
29111
29144
  }
29112
29145
  if (typeof capacity === 'number' &&
29113
29146
  Number.isFinite(capacity) &&
29114
29147
  capacity > 0) {
29115
29148
  normalized.inboxCapacity = Math.floor(capacity);
29116
29149
  }
29150
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29151
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
29152
+ if (normalizedLocalNodeId) {
29153
+ normalized.localNodeId = normalizedLocalNodeId;
29154
+ }
29117
29155
  if (typeof candidate.flowControl === 'boolean') {
29118
29156
  normalized.flowControl = candidate.flowControl;
29119
29157
  }
@@ -29160,10 +29198,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29160
29198
  return trimmed.length > 0 ? trimmed : null;
29161
29199
  }
29162
29200
  _normalizeTargetNodeId(value) {
29201
+ if (value === undefined || value === null) {
29202
+ return undefined;
29203
+ }
29163
29204
  if (value === '*') {
29164
29205
  return '*';
29165
29206
  }
29166
- return this._normalizeNodeId(value) ?? '*';
29207
+ return this._normalizeNodeId(value) ?? undefined;
29167
29208
  }
29168
29209
  }
29169
29210
 
@@ -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;
@@ -391,7 +391,9 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
391
391
  }
392
392
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
393
393
  if (this._isWildcardTarget()) {
394
- if (targetNodeId && targetNodeId !== '*') {
394
+ if (targetNodeId &&
395
+ targetNodeId !== '*' &&
396
+ targetNodeId !== this.localNodeId) {
395
397
  logger.debug('broadcast_channel_message_rejected', {
396
398
  channel: this.channelName,
397
399
  connector_id: this.connectorId,
@@ -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.964
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.964';
@@ -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;
@@ -388,7 +388,9 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
388
388
  }
389
389
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
390
390
  if (this._isWildcardTarget()) {
391
- if (targetNodeId && targetNodeId !== '*') {
391
+ if (targetNodeId &&
392
+ targetNodeId !== '*' &&
393
+ targetNodeId !== this.localNodeId) {
392
394
  logger.debug('broadcast_channel_message_rejected', {
393
395
  channel: this.channelName,
394
396
  connector_id: this.connectorId,
@@ -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.964
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.964';
@@ -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.964
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.964';
23
23
 
24
24
  /**
25
25
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10204,7 +10204,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10204
10204
  }
10205
10205
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
10206
10206
  if (this._isWildcardTarget()) {
10207
- if (targetNodeId && targetNodeId !== '*') {
10207
+ if (targetNodeId &&
10208
+ targetNodeId !== '*' &&
10209
+ targetNodeId !== this.localNodeId) {
10208
10210
  logger$_.debug('broadcast_channel_message_rejected', {
10209
10211
  channel: this.channelName,
10210
10212
  connector_id: this.connectorId,
@@ -10909,6 +10911,20 @@ class UpstreamSessionManager extends TaskSpawner {
10909
10911
  waitEvent(event, signal) {
10910
10912
  return signal ? event.wait({ signal }) : event.wait();
10911
10913
  }
10914
+ _getLocalNodeId() {
10915
+ const normalized = this._normalizeNodeId(this.node.id);
10916
+ if (!normalized) {
10917
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
10918
+ }
10919
+ return normalized;
10920
+ }
10921
+ _normalizeNodeId(value) {
10922
+ if (typeof value !== 'string') {
10923
+ return null;
10924
+ }
10925
+ const trimmed = value.trim();
10926
+ return trimmed.length > 0 ? trimmed : null;
10927
+ }
10912
10928
  async connectCycle() {
10913
10929
  if (!this.admissionClient) {
10914
10930
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -10930,6 +10946,8 @@ class UpstreamSessionManager extends TaskSpawner {
10930
10946
  await this.onWelcome(welcome.frame);
10931
10947
  const connector = await ConnectorFactory.createConnector(grant, {
10932
10948
  systemId: welcome.frame.systemId,
10949
+ localNodeId: this._getLocalNodeId(),
10950
+ initialTargetNodeId: '*',
10933
10951
  });
10934
10952
  await connector.start(this.wrappedHandler);
10935
10953
  this.connector = connector;
@@ -10955,6 +10973,20 @@ class UpstreamSessionManager extends TaskSpawner {
10955
10973
  }
10956
10974
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
10957
10975
  this.targetSystemId = attachInfo.targetSystemId ?? null;
10976
+ if (this.targetSystemId) {
10977
+ const targetAware = connector;
10978
+ if (typeof targetAware.setTargetNodeId === 'function') {
10979
+ try {
10980
+ targetAware.setTargetNodeId(this.targetSystemId);
10981
+ }
10982
+ catch (error) {
10983
+ logger$Z.warning('broadcast_channel_target_apply_failed', {
10984
+ error: error instanceof Error ? error.message : String(error),
10985
+ target_node_id: this.targetSystemId,
10986
+ });
10987
+ }
10988
+ }
10989
+ }
10958
10990
  await this.onAttach(attachInfo, connector);
10959
10991
  // Close the admission client immediately after attach completes
10960
10992
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -28812,13 +28844,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28812
28844
  }
28813
28845
  const normalized = this._normalizeConfig(config);
28814
28846
  const options = (factoryArgs[0] ?? {});
28815
- const localNodeId = this._normalizeNodeId(options.localNodeId);
28847
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
28848
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
28816
28849
  if (!localNodeId) {
28817
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
28850
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
28818
28851
  }
28819
28852
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28820
28853
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
28821
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
28854
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
28855
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
28856
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
28822
28857
  const baseConfig = {
28823
28858
  drainTimeout: normalized.drainTimeout,
28824
28859
  flowControl: normalized.flowControl,
@@ -28859,17 +28894,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28859
28894
  }
28860
28895
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
28861
28896
  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 = '*';
28897
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
28898
+ if (normalizedTarget) {
28899
+ normalized.initialTargetNodeId = normalizedTarget;
28867
28900
  }
28868
28901
  if (typeof capacity === 'number' &&
28869
28902
  Number.isFinite(capacity) &&
28870
28903
  capacity > 0) {
28871
28904
  normalized.inboxCapacity = Math.floor(capacity);
28872
28905
  }
28906
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
28907
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
28908
+ if (normalizedLocalNodeId) {
28909
+ normalized.localNodeId = normalizedLocalNodeId;
28910
+ }
28873
28911
  if (typeof candidate.flowControl === 'boolean') {
28874
28912
  normalized.flowControl = candidate.flowControl;
28875
28913
  }
@@ -28916,10 +28954,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28916
28954
  return trimmed.length > 0 ? trimmed : null;
28917
28955
  }
28918
28956
  _normalizeTargetNodeId(value) {
28957
+ if (value === undefined || value === null) {
28958
+ return undefined;
28959
+ }
28919
28960
  if (value === '*') {
28920
28961
  return '*';
28921
28962
  }
28922
- return this._normalizeNodeId(value) ?? '*';
28963
+ return this._normalizeNodeId(value) ?? undefined;
28923
28964
  }
28924
28965
  }
28925
28966
 
@@ -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.964
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.964';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -10203,7 +10203,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10203
10203
  }
10204
10204
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
10205
10205
  if (this._isWildcardTarget()) {
10206
- if (targetNodeId && targetNodeId !== '*') {
10206
+ if (targetNodeId &&
10207
+ targetNodeId !== '*' &&
10208
+ targetNodeId !== this.localNodeId) {
10207
10209
  logger$_.debug('broadcast_channel_message_rejected', {
10208
10210
  channel: this.channelName,
10209
10211
  connector_id: this.connectorId,
@@ -10908,6 +10910,20 @@ class UpstreamSessionManager extends TaskSpawner {
10908
10910
  waitEvent(event, signal) {
10909
10911
  return signal ? event.wait({ signal }) : event.wait();
10910
10912
  }
10913
+ _getLocalNodeId() {
10914
+ const normalized = this._normalizeNodeId(this.node.id);
10915
+ if (!normalized) {
10916
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
10917
+ }
10918
+ return normalized;
10919
+ }
10920
+ _normalizeNodeId(value) {
10921
+ if (typeof value !== 'string') {
10922
+ return null;
10923
+ }
10924
+ const trimmed = value.trim();
10925
+ return trimmed.length > 0 ? trimmed : null;
10926
+ }
10911
10927
  async connectCycle() {
10912
10928
  if (!this.admissionClient) {
10913
10929
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -10929,6 +10945,8 @@ class UpstreamSessionManager extends TaskSpawner {
10929
10945
  await this.onWelcome(welcome.frame);
10930
10946
  const connector = await ConnectorFactory.createConnector(grant, {
10931
10947
  systemId: welcome.frame.systemId,
10948
+ localNodeId: this._getLocalNodeId(),
10949
+ initialTargetNodeId: '*',
10932
10950
  });
10933
10951
  await connector.start(this.wrappedHandler);
10934
10952
  this.connector = connector;
@@ -10954,6 +10972,20 @@ class UpstreamSessionManager extends TaskSpawner {
10954
10972
  }
10955
10973
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
10956
10974
  this.targetSystemId = attachInfo.targetSystemId ?? null;
10975
+ if (this.targetSystemId) {
10976
+ const targetAware = connector;
10977
+ if (typeof targetAware.setTargetNodeId === 'function') {
10978
+ try {
10979
+ targetAware.setTargetNodeId(this.targetSystemId);
10980
+ }
10981
+ catch (error) {
10982
+ logger$Z.warning('broadcast_channel_target_apply_failed', {
10983
+ error: error instanceof Error ? error.message : String(error),
10984
+ target_node_id: this.targetSystemId,
10985
+ });
10986
+ }
10987
+ }
10988
+ }
10957
10989
  await this.onAttach(attachInfo, connector);
10958
10990
  // Close the admission client immediately after attach completes
10959
10991
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -28811,13 +28843,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28811
28843
  }
28812
28844
  const normalized = this._normalizeConfig(config);
28813
28845
  const options = (factoryArgs[0] ?? {});
28814
- const localNodeId = this._normalizeNodeId(options.localNodeId);
28846
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
28847
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
28815
28848
  if (!localNodeId) {
28816
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
28849
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
28817
28850
  }
28818
28851
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28819
28852
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
28820
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
28853
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
28854
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
28855
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
28821
28856
  const baseConfig = {
28822
28857
  drainTimeout: normalized.drainTimeout,
28823
28858
  flowControl: normalized.flowControl,
@@ -28858,17 +28893,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28858
28893
  }
28859
28894
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
28860
28895
  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 = '*';
28896
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
28897
+ if (normalizedTarget) {
28898
+ normalized.initialTargetNodeId = normalizedTarget;
28866
28899
  }
28867
28900
  if (typeof capacity === 'number' &&
28868
28901
  Number.isFinite(capacity) &&
28869
28902
  capacity > 0) {
28870
28903
  normalized.inboxCapacity = Math.floor(capacity);
28871
28904
  }
28905
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
28906
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
28907
+ if (normalizedLocalNodeId) {
28908
+ normalized.localNodeId = normalizedLocalNodeId;
28909
+ }
28872
28910
  if (typeof candidate.flowControl === 'boolean') {
28873
28911
  normalized.flowControl = candidate.flowControl;
28874
28912
  }
@@ -28915,10 +28953,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28915
28953
  return trimmed.length > 0 ? trimmed : null;
28916
28954
  }
28917
28955
  _normalizeTargetNodeId(value) {
28956
+ if (value === undefined || value === null) {
28957
+ return undefined;
28958
+ }
28918
28959
  if (value === '*') {
28919
28960
  return '*';
28920
28961
  }
28921
- return this._normalizeNodeId(value) ?? '*';
28962
+ return this._normalizeNodeId(value) ?? undefined;
28922
28963
  }
28923
28964
  }
28924
28965
 
@@ -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.964
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.964';
5572
5572
 
5573
5573
  /**
5574
5574
  * Fame errors module - Fame protocol specific error classes
@@ -11941,7 +11941,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11941
11941
  }
11942
11942
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
11943
11943
  if (this._isWildcardTarget()) {
11944
- if (targetNodeId && targetNodeId !== '*') {
11944
+ if (targetNodeId &&
11945
+ targetNodeId !== '*' &&
11946
+ targetNodeId !== this.localNodeId) {
11945
11947
  logger$10.debug('broadcast_channel_message_rejected', {
11946
11948
  channel: this.channelName,
11947
11949
  connector_id: this.connectorId,
@@ -12601,6 +12603,20 @@ class UpstreamSessionManager extends TaskSpawner {
12601
12603
  waitEvent(event, signal) {
12602
12604
  return signal ? event.wait({ signal }) : event.wait();
12603
12605
  }
12606
+ _getLocalNodeId() {
12607
+ const normalized = this._normalizeNodeId(this.node.id);
12608
+ if (!normalized) {
12609
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
12610
+ }
12611
+ return normalized;
12612
+ }
12613
+ _normalizeNodeId(value) {
12614
+ if (typeof value !== 'string') {
12615
+ return null;
12616
+ }
12617
+ const trimmed = value.trim();
12618
+ return trimmed.length > 0 ? trimmed : null;
12619
+ }
12604
12620
  async connectCycle() {
12605
12621
  if (!this.admissionClient) {
12606
12622
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -12622,6 +12638,8 @@ class UpstreamSessionManager extends TaskSpawner {
12622
12638
  await this.onWelcome(welcome.frame);
12623
12639
  const connector = await ConnectorFactory.createConnector(grant, {
12624
12640
  systemId: welcome.frame.systemId,
12641
+ localNodeId: this._getLocalNodeId(),
12642
+ initialTargetNodeId: '*',
12625
12643
  });
12626
12644
  await connector.start(this.wrappedHandler);
12627
12645
  this.connector = connector;
@@ -12647,6 +12665,20 @@ class UpstreamSessionManager extends TaskSpawner {
12647
12665
  }
12648
12666
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
12649
12667
  this.targetSystemId = attachInfo.targetSystemId ?? null;
12668
+ if (this.targetSystemId) {
12669
+ const targetAware = connector;
12670
+ if (typeof targetAware.setTargetNodeId === 'function') {
12671
+ try {
12672
+ targetAware.setTargetNodeId(this.targetSystemId);
12673
+ }
12674
+ catch (error) {
12675
+ logger$$.warning('broadcast_channel_target_apply_failed', {
12676
+ error: error instanceof Error ? error.message : String(error),
12677
+ target_node_id: this.targetSystemId,
12678
+ });
12679
+ }
12680
+ }
12681
+ }
12650
12682
  await this.onAttach(attachInfo, connector);
12651
12683
  // Close the admission client immediately after attach completes
12652
12684
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -30745,13 +30777,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30745
30777
  }
30746
30778
  const normalized = this._normalizeConfig(config);
30747
30779
  const options = (factoryArgs[0] ?? {});
30748
- const localNodeId = this._normalizeNodeId(options.localNodeId);
30780
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
30781
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
30749
30782
  if (!localNodeId) {
30750
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
30783
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
30751
30784
  }
30752
30785
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$2;
30753
30786
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
30754
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
30787
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
30788
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
30789
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
30755
30790
  const baseConfig = {
30756
30791
  drainTimeout: normalized.drainTimeout,
30757
30792
  flowControl: normalized.flowControl,
@@ -30792,17 +30827,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30792
30827
  }
30793
30828
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
30794
30829
  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 = '*';
30830
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
30831
+ if (normalizedTarget) {
30832
+ normalized.initialTargetNodeId = normalizedTarget;
30800
30833
  }
30801
30834
  if (typeof capacity === 'number' &&
30802
30835
  Number.isFinite(capacity) &&
30803
30836
  capacity > 0) {
30804
30837
  normalized.inboxCapacity = Math.floor(capacity);
30805
30838
  }
30839
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
30840
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
30841
+ if (normalizedLocalNodeId) {
30842
+ normalized.localNodeId = normalizedLocalNodeId;
30843
+ }
30806
30844
  if (typeof candidate.flowControl === 'boolean') {
30807
30845
  normalized.flowControl = candidate.flowControl;
30808
30846
  }
@@ -30849,10 +30887,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30849
30887
  return trimmed.length > 0 ? trimmed : null;
30850
30888
  }
30851
30889
  _normalizeTargetNodeId(value) {
30890
+ if (value === undefined || value === null) {
30891
+ return undefined;
30892
+ }
30852
30893
  if (value === '*') {
30853
30894
  return '*';
30854
30895
  }
30855
- return this._normalizeNodeId(value) ?? '*';
30896
+ return this._normalizeNodeId(value) ?? undefined;
30856
30897
  }
30857
30898
  }
30858
30899
 
@@ -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.964
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.964';
5571
5571
 
5572
5572
  /**
5573
5573
  * Fame errors module - Fame protocol specific error classes
@@ -11940,7 +11940,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11940
11940
  }
11941
11941
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
11942
11942
  if (this._isWildcardTarget()) {
11943
- if (targetNodeId && targetNodeId !== '*') {
11943
+ if (targetNodeId &&
11944
+ targetNodeId !== '*' &&
11945
+ targetNodeId !== this.localNodeId) {
11944
11946
  logger$10.debug('broadcast_channel_message_rejected', {
11945
11947
  channel: this.channelName,
11946
11948
  connector_id: this.connectorId,
@@ -12600,6 +12602,20 @@ class UpstreamSessionManager extends TaskSpawner {
12600
12602
  waitEvent(event, signal) {
12601
12603
  return signal ? event.wait({ signal }) : event.wait();
12602
12604
  }
12605
+ _getLocalNodeId() {
12606
+ const normalized = this._normalizeNodeId(this.node.id);
12607
+ if (!normalized) {
12608
+ throw new Error('UpstreamSessionManager requires node with a stable identifier');
12609
+ }
12610
+ return normalized;
12611
+ }
12612
+ _normalizeNodeId(value) {
12613
+ if (typeof value !== 'string') {
12614
+ return null;
12615
+ }
12616
+ const trimmed = value.trim();
12617
+ return trimmed.length > 0 ? trimmed : null;
12618
+ }
12603
12619
  async connectCycle() {
12604
12620
  if (!this.admissionClient) {
12605
12621
  throw new FameConnectError('Admission client is required to attach upstream');
@@ -12621,6 +12637,8 @@ class UpstreamSessionManager extends TaskSpawner {
12621
12637
  await this.onWelcome(welcome.frame);
12622
12638
  const connector = await ConnectorFactory.createConnector(grant, {
12623
12639
  systemId: welcome.frame.systemId,
12640
+ localNodeId: this._getLocalNodeId(),
12641
+ initialTargetNodeId: '*',
12624
12642
  });
12625
12643
  await connector.start(this.wrappedHandler);
12626
12644
  this.connector = connector;
@@ -12646,6 +12664,20 @@ class UpstreamSessionManager extends TaskSpawner {
12646
12664
  }
12647
12665
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
12648
12666
  this.targetSystemId = attachInfo.targetSystemId ?? null;
12667
+ if (this.targetSystemId) {
12668
+ const targetAware = connector;
12669
+ if (typeof targetAware.setTargetNodeId === 'function') {
12670
+ try {
12671
+ targetAware.setTargetNodeId(this.targetSystemId);
12672
+ }
12673
+ catch (error) {
12674
+ logger$$.warning('broadcast_channel_target_apply_failed', {
12675
+ error: error instanceof Error ? error.message : String(error),
12676
+ target_node_id: this.targetSystemId,
12677
+ });
12678
+ }
12679
+ }
12680
+ }
12649
12681
  await this.onAttach(attachInfo, connector);
12650
12682
  // Close the admission client immediately after attach completes
12651
12683
  // This releases HTTP keep-alive connections (Node.js fetch/undici requires explicit cleanup)
@@ -30744,13 +30776,16 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30744
30776
  }
30745
30777
  const normalized = this._normalizeConfig(config);
30746
30778
  const options = (factoryArgs[0] ?? {});
30747
- const localNodeId = this._normalizeNodeId(options.localNodeId);
30779
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
30780
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
30748
30781
  if (!localNodeId) {
30749
- throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
30782
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
30750
30783
  }
30751
30784
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$2;
30752
30785
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
30753
- const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
30786
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
30787
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
30788
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
30754
30789
  const baseConfig = {
30755
30790
  drainTimeout: normalized.drainTimeout,
30756
30791
  flowControl: normalized.flowControl,
@@ -30791,17 +30826,20 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30791
30826
  }
30792
30827
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
30793
30828
  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 = '*';
30829
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
30830
+ if (normalizedTarget) {
30831
+ normalized.initialTargetNodeId = normalizedTarget;
30799
30832
  }
30800
30833
  if (typeof capacity === 'number' &&
30801
30834
  Number.isFinite(capacity) &&
30802
30835
  capacity > 0) {
30803
30836
  normalized.inboxCapacity = Math.floor(capacity);
30804
30837
  }
30838
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
30839
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
30840
+ if (normalizedLocalNodeId) {
30841
+ normalized.localNodeId = normalizedLocalNodeId;
30842
+ }
30805
30843
  if (typeof candidate.flowControl === 'boolean') {
30806
30844
  normalized.flowControl = candidate.flowControl;
30807
30845
  }
@@ -30848,10 +30886,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30848
30886
  return trimmed.length > 0 ? trimmed : null;
30849
30887
  }
30850
30888
  _normalizeTargetNodeId(value) {
30889
+ if (value === undefined || value === null) {
30890
+ return undefined;
30891
+ }
30851
30892
  if (value === '*') {
30852
30893
  return '*';
30853
30894
  }
30854
- return this._normalizeNodeId(value) ?? '*';
30895
+ return this._normalizeNodeId(value) ?? undefined;
30855
30896
  }
30856
30897
  }
30857
30898
 
@@ -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.964";
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.964",
4
4
  "type": "module",
5
5
  "description": "Naylence Runtime - Complete TypeScript runtime",
6
6
  "author": "Naylence Dev <naylencedev@gmail.com>",