@naylence/agent-sdk 0.3.4-test.705 → 0.3.4-test.709

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.
@@ -669,7 +669,7 @@
669
669
  const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
670
670
  // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
671
671
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
672
- const date$2 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
672
+ const date$3 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
673
673
  function timeSource(args) {
674
674
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
675
675
  const regex = typeof args.precision === "number"
@@ -1435,7 +1435,7 @@
1435
1435
  $ZodStringFormat.init(inst, def);
1436
1436
  });
1437
1437
  const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1438
- def.pattern ?? (def.pattern = date$2);
1438
+ def.pattern ?? (def.pattern = date$3);
1439
1439
  $ZodStringFormat.init(inst, def);
1440
1440
  });
1441
1441
  const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
@@ -2937,6 +2937,13 @@
2937
2937
  ...normalizeParams$1(params),
2938
2938
  });
2939
2939
  }
2940
+ function _coercedDate(Class, params) {
2941
+ return new Class({
2942
+ type: "date",
2943
+ coerce: true,
2944
+ ...normalizeParams$1(params),
2945
+ });
2946
+ }
2940
2947
  function _lt(value, params) {
2941
2948
  return new $ZodCheckLessThan({
2942
2949
  check: "less_than",
@@ -3128,7 +3135,7 @@
3128
3135
  $ZodISODate.init(inst, def);
3129
3136
  ZodStringFormat.init(inst, def);
3130
3137
  });
3131
- function date$1(params) {
3138
+ function date$2(params) {
3132
3139
  return _isoDate(ZodISODate, params);
3133
3140
  }
3134
3141
  const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
@@ -3338,7 +3345,7 @@
3338
3345
  inst.e164 = (params) => inst.check(_e164(ZodE164, params));
3339
3346
  // iso
3340
3347
  inst.datetime = (params) => inst.check(datetime(params));
3341
- inst.date = (params) => inst.check(date$1(params));
3348
+ inst.date = (params) => inst.check(date$2(params));
3342
3349
  inst.time = (params) => inst.check(time(params));
3343
3350
  inst.duration = (params) => inst.check(duration(params));
3344
3351
  });
@@ -3524,7 +3531,7 @@
3524
3531
  inst.minDate = c.minimum ? new Date(c.minimum) : null;
3525
3532
  inst.maxDate = c.maximum ? new Date(c.maximum) : null;
3526
3533
  });
3527
- function date(params) {
3534
+ function date$1(params) {
3528
3535
  return _date(ZodDate, params);
3529
3536
  }
3530
3537
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
@@ -3867,6 +3874,10 @@
3867
3874
  custom: "custom",
3868
3875
  };
3869
3876
 
3877
+ function date(params) {
3878
+ return _coercedDate(ZodDate, params);
3879
+ }
3880
+
3870
3881
  const PARTICIPANT_RE = /^[A-Za-z0-9_-]+$/;
3871
3882
  const SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
3872
3883
  const HOST_SEGMENT_RE = /^[A-Za-z0-9.-]+$/; // Allow dots for host parts
@@ -5974,7 +5985,7 @@
5974
5985
  }
5975
5986
  }
5976
5987
  return value;
5977
- }, date())
5988
+ }, date$1())
5978
5989
  .describe('UTC timestamp when the envelope was created');
5979
5990
  const FLOW_FLAG_MASK = FlowFlags.SYN | FlowFlags.ACK | FlowFlags.RESET;
5980
5991
  const FlowFlagsSchema = number()
@@ -6271,7 +6282,7 @@
6271
6282
  // Context metadata
6272
6283
  authMethod: string$1().optional()
6273
6284
  .describe('Authentication method used'),
6274
- expiresAt: date().optional()
6285
+ expiresAt: date$1().optional()
6275
6286
  .describe('When authorization expires'),
6276
6287
  }).transform((data) => {
6277
6288
  // Convert string dates to Date objects if needed
@@ -6532,7 +6543,7 @@
6532
6543
  }
6533
6544
  }
6534
6545
  return value;
6535
- }, date());
6546
+ }, date$1());
6536
6547
  const TaskStatusSchema = object({
6537
6548
  state: nativeEnum(exports.TaskState),
6538
6549
  message: MessageSchema.nullable().optional(),
@@ -6793,6 +6804,21 @@
6793
6804
  class MissingAPIKeyError extends Error {
6794
6805
  }
6795
6806
 
6807
+ /**
6808
+ * Utilities for hex, bytes, CSPRNG.
6809
+ * @module
6810
+ */
6811
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6812
+ /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
6813
+ /**
6814
+ * Converts string to bytes using UTF8 encoding.
6815
+ * Built-in doesn't validate input to be string: we do the check.
6816
+ * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
6817
+ */
6818
+ function utf8ToBytes(str) {
6819
+ return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
6820
+ }
6821
+
6796
6822
  const ALIAS = Symbol.for('yaml.alias');
6797
6823
  const DOC = Symbol.for('yaml.document');
6798
6824
  const MAP = Symbol.for('yaml.map');
@@ -19249,7 +19275,7 @@
19249
19275
  * limitations under the License.
19250
19276
  */
19251
19277
  // this is autogenerated file, see scripts/version-update.js
19252
- var VERSION$2 = '1.9.0';
19278
+ var VERSION$3 = '1.9.0';
19253
19279
 
19254
19280
  /*
19255
19281
  * Copyright The OpenTelemetry Authors
@@ -19366,7 +19392,7 @@
19366
19392
  *
19367
19393
  * @param version version of the API requesting an instance of the global API
19368
19394
  */
19369
- var isCompatible = _makeCompatibilityCheck(VERSION$2);
19395
+ var isCompatible = _makeCompatibilityCheck(VERSION$3);
19370
19396
 
19371
19397
  /*
19372
19398
  * Copyright The OpenTelemetry Authors
@@ -19383,14 +19409,14 @@
19383
19409
  * See the License for the specific language governing permissions and
19384
19410
  * limitations under the License.
19385
19411
  */
19386
- var major = VERSION$2.split('.')[0];
19412
+ var major = VERSION$3.split('.')[0];
19387
19413
  var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
19388
19414
  var _global = _globalThis$1;
19389
19415
  function registerGlobal(type, instance, diag, allowOverride) {
19390
19416
  var _a;
19391
19417
  if (allowOverride === void 0) { allowOverride = false; }
19392
19418
  var api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
19393
- version: VERSION$2,
19419
+ version: VERSION$3,
19394
19420
  });
19395
19421
  if (!allowOverride && api[type]) {
19396
19422
  // already registered an API of this type
@@ -19398,14 +19424,14 @@
19398
19424
  diag.error(err.stack || err.message);
19399
19425
  return false;
19400
19426
  }
19401
- if (api.version !== VERSION$2) {
19427
+ if (api.version !== VERSION$3) {
19402
19428
  // All registered APIs must be of the same version exactly
19403
- var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION$2);
19429
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION$3);
19404
19430
  diag.error(err.stack || err.message);
19405
19431
  return false;
19406
19432
  }
19407
19433
  api[type] = instance;
19408
- diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION$2 + ".");
19434
+ diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION$3 + ".");
19409
19435
  return true;
19410
19436
  }
19411
19437
  function getGlobal(type) {
@@ -19417,7 +19443,7 @@
19417
19443
  return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
19418
19444
  }
19419
19445
  function unregisterGlobal(type, diag) {
19420
- diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION$2 + ".");
19446
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION$3 + ".");
19421
19447
  var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
19422
19448
  if (api) {
19423
19449
  delete api[type];
@@ -21564,6 +21590,14 @@
21564
21590
  trace: trace
21565
21591
  });
21566
21592
 
21593
+ // This file is auto-generated during build - do not edit manually
21594
+ // Generated from package.json version: 0.3.5-test.909
21595
+ /**
21596
+ * The package version, injected at build time.
21597
+ * @internal
21598
+ */
21599
+ const VERSION$2 = '0.3.5-test.909';
21600
+
21567
21601
  /**
21568
21602
  * Cross-platform logging utilities for Naylence Fame
21569
21603
  *
@@ -22194,10 +22228,10 @@
22194
22228
  * General utility functions for JSON handling, string manipulation,
22195
22229
  * path normalization, base64 encoding, hashing, and more.
22196
22230
  */
22197
- const ENV_VAR_SHOW_ENVELOPES = 'FAME_SHOW_ENVELOPES';
22231
+ const ENV_VAR_SHOW_ENVELOPES$1 = 'FAME_SHOW_ENVELOPES';
22198
22232
  function isEnvelopeLoggingEnabled() {
22199
22233
  return (typeof process !== 'undefined' &&
22200
- process.env?.[ENV_VAR_SHOW_ENVELOPES] === 'true');
22234
+ process.env?.[ENV_VAR_SHOW_ENVELOPES$1] === 'true');
22201
22235
  }
22202
22236
  isEnvelopeLoggingEnabled();
22203
22237
  // Base62 characters: 0–9, a–z, A–Z
@@ -22707,7 +22741,7 @@
22707
22741
  function isArrayBufferView(value) {
22708
22742
  return Boolean(value) && ArrayBuffer.isView(value);
22709
22743
  }
22710
- function toUint8Array(value) {
22744
+ function toUint8Array$1(value) {
22711
22745
  if (!value) {
22712
22746
  return null;
22713
22747
  }
@@ -22749,7 +22783,7 @@
22749
22783
  reject(request.error ?? new Error('Failed to read master key from IndexedDB'));
22750
22784
  };
22751
22785
  request.onsuccess = () => {
22752
- resolve(toUint8Array(request.result));
22786
+ resolve(toUint8Array$1(request.result));
22753
22787
  };
22754
22788
  });
22755
22789
  }
@@ -22768,7 +22802,7 @@
22768
22802
  };
22769
22803
  });
22770
22804
  }
22771
- function getRandomBytes$2(length) {
22805
+ function getRandomBytes$3(length) {
22772
22806
  if (!globalThis.crypto?.getRandomValues) {
22773
22807
  throw new Error('crypto.getRandomValues is not available in this environment');
22774
22808
  }
@@ -22817,7 +22851,7 @@
22817
22851
  if (existing) {
22818
22852
  return existing;
22819
22853
  }
22820
- const masterKey = getRandomBytes$2(MASTER_KEY_LENGTH$1);
22854
+ const masterKey = getRandomBytes$3(MASTER_KEY_LENGTH$1);
22821
22855
  await persistKey(db, this.storeName, this.keyId, masterKey);
22822
22856
  return masterKey;
22823
22857
  }
@@ -22830,11 +22864,11 @@
22830
22864
  const DEFAULT_KEY_ID$1 = 'default';
22831
22865
  const DEFAULT_ALGORITHM = 'AES-GCM';
22832
22866
  const GCM_IV_LENGTH$1 = 12;
22833
- function isBrowserEnvironment() {
22867
+ function isBrowserEnvironment$1() {
22834
22868
  return (typeof indexedDB !== 'undefined' && typeof globalThis.crypto !== 'undefined');
22835
22869
  }
22836
22870
  function tryCreateBrowserAutoKeyCredentialProvider() {
22837
- if (!isBrowserEnvironment()) {
22871
+ if (!isBrowserEnvironment$1()) {
22838
22872
  return null;
22839
22873
  }
22840
22874
  try {
@@ -22844,18 +22878,18 @@
22844
22878
  return null;
22845
22879
  }
22846
22880
  }
22847
- let cachedNodeCrypto$1;
22881
+ let cachedNodeCrypto$2;
22848
22882
  let cachedSubtle;
22849
- async function loadNodeCrypto$1() {
22850
- if (cachedNodeCrypto$1 !== undefined) {
22851
- return cachedNodeCrypto$1;
22883
+ async function loadNodeCrypto$2() {
22884
+ if (cachedNodeCrypto$2 !== undefined) {
22885
+ return cachedNodeCrypto$2;
22852
22886
  }
22853
22887
  try {
22854
- cachedNodeCrypto$1 = await Promise.resolve().then(function () { return _nodeResolve_empty$1; });
22855
- return cachedNodeCrypto$1;
22888
+ cachedNodeCrypto$2 = await Promise.resolve().then(function () { return _nodeResolve_empty$1; });
22889
+ return cachedNodeCrypto$2;
22856
22890
  }
22857
22891
  catch {
22858
- cachedNodeCrypto$1 = null;
22892
+ cachedNodeCrypto$2 = null;
22859
22893
  return null;
22860
22894
  }
22861
22895
  }
@@ -22867,21 +22901,21 @@
22867
22901
  cachedSubtle = globalThis.crypto.subtle;
22868
22902
  return cachedSubtle;
22869
22903
  }
22870
- const nodeCrypto = await loadNodeCrypto$1();
22904
+ const nodeCrypto = await loadNodeCrypto$2();
22871
22905
  if (nodeCrypto?.webcrypto?.subtle) {
22872
22906
  cachedSubtle = nodeCrypto.webcrypto.subtle;
22873
22907
  return cachedSubtle;
22874
22908
  }
22875
22909
  throw new Error('Web Crypto API is not available in this environment');
22876
22910
  }
22877
- async function getRandomBytes$1(length) {
22911
+ async function getRandomBytes$2(length) {
22878
22912
  if (typeof globalThis.crypto !== 'undefined' &&
22879
22913
  typeof globalThis.crypto.getRandomValues === 'function') {
22880
22914
  const buffer = new Uint8Array(length);
22881
22915
  globalThis.crypto.getRandomValues(buffer);
22882
22916
  return buffer;
22883
22917
  }
22884
- const nodeCrypto = await loadNodeCrypto$1();
22918
+ const nodeCrypto = await loadNodeCrypto$2();
22885
22919
  if (nodeCrypto) {
22886
22920
  const buffer = nodeCrypto.randomBytes(length);
22887
22921
  return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
@@ -22970,7 +23004,7 @@
22970
23004
  const normalizedKey = normalizeKey(key);
22971
23005
  const keyBuffer = toArrayBuffer$1(normalizedKey);
22972
23006
  const cryptoKey = await subtle.importKey('raw', keyBuffer, { name: 'AES-GCM' }, false, ['encrypt']);
22973
- const iv = await getRandomBytes$1(GCM_IV_LENGTH$1);
23007
+ const iv = await getRandomBytes$2(GCM_IV_LENGTH$1);
22974
23008
  const ivBuffer = toArrayBuffer$1(iv);
22975
23009
  const ciphertextBuffer = await subtle.encrypt({ name: 'AES-GCM', iv: ivBuffer }, cryptoKey, toArrayBuffer$1(plaintext));
22976
23010
  const ciphertext = new Uint8Array(ciphertextBuffer);
@@ -23453,29 +23487,17 @@
23453
23487
  IndexedDBStorageProvider: IndexedDBStorageProvider
23454
23488
  });
23455
23489
 
23456
- const globalScope$1 = globalThis;
23457
- const nodeStack = globalScope$1.__naylenceNodeStack__ ?? (globalScope$1.__naylenceNodeStack__ = []);
23458
- function getCurrentNode() {
23459
- return nodeStack.length > 0 ? nodeStack[nodeStack.length - 1] : null;
23460
- }
23490
+ getLogger('naylence.fame.node.binding_manager');
23461
23491
 
23462
- const GRANT_PURPOSE_NODE_ATTACH = 'node.attach';
23463
- function isGrant(candidate) {
23464
- if (!candidate || typeof candidate !== 'object') {
23465
- return false;
23466
- }
23467
- const grant = candidate;
23468
- return typeof grant.type === 'string' && typeof grant.purpose === 'string';
23469
- }
23470
- function assertGrant(candidate, message = 'Invalid grant object') {
23471
- if (!isGrant(candidate)) {
23472
- throw new TypeError(message);
23473
- }
23474
- }
23492
+ getLogger('naylence.fame.node.response_context_manager');
23475
23493
 
23476
- getLogger('naylence.fame.node.admission.default_node_attach_client');
23494
+ getLogger('naylence.fame.node.streaming_response_handler');
23477
23495
 
23478
- getLogger('naylence.fame.node.binding_manager');
23496
+ getLogger('naylence.fame.node.channel_polling_manager');
23497
+
23498
+ getLogger('naylence.fame.node.rpc_server_handler');
23499
+
23500
+ getLogger('naylence.fame.node.rpc_client_manager');
23479
23501
 
23480
23502
  var EnvelopeStatus;
23481
23503
  (function (EnvelopeStatus) {
@@ -23512,8 +23534,103 @@
23512
23534
  outbox: MailboxType.OUTBOX,
23513
23535
  });
23514
23536
 
23537
+ getLogger('naylence.fame.node.envelope_listener_manager');
23538
+
23515
23539
  getLogger('naylence.fame.delivery.default_delivery_tracker');
23516
23540
 
23541
+ getLogger('naylence.fame.node.root_session_manager');
23542
+
23543
+ /**
23544
+ * Base factory for creating FameConnector instances from either ConnectorConfig or ConnectionGrant.
23545
+ *
23546
+ * Concrete implementations must define supported grant types and provide grant-to-connector
23547
+ * conversion logic.
23548
+ */
23549
+ getLogger('naylence.fame.connector.connector_factory');
23550
+ getLogger('naylence.fame.connector.base_async_connector');
23551
+ // Environment variables
23552
+ const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
23553
+ typeof process !== 'undefined' && process?.env
23554
+ ? process.env[ENV_VAR_FAME_FLOW_CONTROL] !== '0'
23555
+ : true;
23556
+
23557
+ getLogger('naylence.fame.connector.broadcast_channel_connector');
23558
+
23559
+ const GRANT_PURPOSE_NODE_ATTACH = 'node.attach';
23560
+ function isGrant(candidate) {
23561
+ if (!candidate || typeof candidate !== 'object') {
23562
+ return false;
23563
+ }
23564
+ const grant = candidate;
23565
+ return typeof grant.type === 'string' && typeof grant.purpose === 'string';
23566
+ }
23567
+ function assertGrant(candidate, message = 'Invalid grant object') {
23568
+ if (!isGrant(candidate)) {
23569
+ throw new TypeError(message);
23570
+ }
23571
+ }
23572
+
23573
+ const AUTH_INJECTION_STRATEGY_TYPE_ALIASES = {
23574
+ BearerTokenHeaderAuthInjectionStrategy: 'BearerTokenHeaderAuth',
23575
+ BearerTokenHeaderAuthStrategy: 'BearerTokenHeaderAuth',
23576
+ NoAuthInjectionStrategy: 'NoAuth',
23577
+ QueryParamAuthInjectionStrategy: 'QueryParamAuth',
23578
+ QueryParamAuthStrategy: 'QueryParamAuth',
23579
+ WebSocketSubprotocolAuthInjectionStrategy: 'WebSocketSubprotocolAuth',
23580
+ WebSocketSubprotocolAuthStrategy: 'WebSocketSubprotocolAuth',
23581
+ };
23582
+ function canonicalizeAuthConfig(auth) {
23583
+ if (!auth || typeof auth !== 'object' || Array.isArray(auth)) {
23584
+ return undefined;
23585
+ }
23586
+ const typeValue = auth.type;
23587
+ if (typeof typeValue !== 'string') {
23588
+ return auth;
23589
+ }
23590
+ const normalizedType = AUTH_INJECTION_STRATEGY_TYPE_ALIASES[typeValue] ?? typeValue;
23591
+ if (normalizedType === typeValue) {
23592
+ return auth;
23593
+ }
23594
+ return {
23595
+ ...auth,
23596
+ type: normalizedType,
23597
+ };
23598
+ }
23599
+ function assertConnectionGrant(candidate, message = 'Invalid connection grant') {
23600
+ assertGrant(candidate, message);
23601
+ }
23602
+
23603
+ getLogger('naylence.fame.node.upstream_session_manager');
23604
+
23605
+ getLogger('naylence.fame.node.admission.noop_admission_client');
23606
+ getLogger('naylence.fame.node.node');
23607
+
23608
+ const FameNodeModeSchema = union([literal('dev'), literal('prod')])
23609
+ .default('prod');
23610
+ object({
23611
+ type: literal('Node').default('Node'),
23612
+ mode: FameNodeModeSchema,
23613
+ id: string$1().optional().nullable(),
23614
+ directParentUrl: string$1().optional().nullable(),
23615
+ admission: unknown().optional().nullable(),
23616
+ requestedLogicals: array(string$1()).default([]),
23617
+ delivery: unknown().optional().nullable(),
23618
+ envContext: record(string$1(), unknown()).default({}),
23619
+ services: array(unknown()).default([]),
23620
+ hasParent: boolean().default(false),
23621
+ security: unknown().optional().nullable(),
23622
+ listeners: array(record(string$1(), unknown())).default([]),
23623
+ publicUrl: string$1().optional().nullable(),
23624
+ keyStore: unknown().optional().nullable(),
23625
+ storage: unknown().optional().nullable(),
23626
+ attachmentKeyValidator: unknown().optional().nullable(),
23627
+ telemetry: unknown().optional().nullable(),
23628
+ requestedCapabilities: array(string$1()).optional(),
23629
+ })
23630
+ .passthrough();
23631
+
23632
+ getLogger('naylence.fame.node.admission.default_node_attach_client');
23633
+
23517
23634
  const TRACE_EMITTER_FACTORY_BASE_TYPE = 'TraceEmitterFactory';
23518
23635
  class TraceEmitterFactory extends AbstractResourceFactory {
23519
23636
  static async createTraceEmitter(config, options = {}) {
@@ -23553,12 +23670,12 @@
23553
23670
  welcome: unknown().optional(),
23554
23671
  })
23555
23672
  .loose());
23556
- function isPlainObject$1(value) {
23673
+ function isPlainObject$2(value) {
23557
23674
  return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
23558
23675
  }
23559
23676
  function parseJson(content) {
23560
23677
  const parsed = JSON.parse(content);
23561
- if (!isPlainObject$1(parsed)) {
23678
+ if (!isPlainObject$2(parsed)) {
23562
23679
  throw new Error('Parsed JSON config must be an object');
23563
23680
  }
23564
23681
  return parsed;
@@ -23568,7 +23685,7 @@
23568
23685
  if (parsed == null) {
23569
23686
  return {};
23570
23687
  }
23571
- if (!isPlainObject$1(parsed)) {
23688
+ if (!isPlainObject$2(parsed)) {
23572
23689
  throw new Error('Parsed YAML config must be an object');
23573
23690
  }
23574
23691
  return parsed;
@@ -23699,127 +23816,233 @@
23699
23816
  if (isNode && !getDefaultFameConfigResolver()) {
23700
23817
  setDefaultFameConfigResolver(async () => loadRawFameConfig());
23701
23818
  }
23702
- // export function registerNodeLikeFactory(
23703
- // type: string,
23704
- // factory: new (...args: unknown[]) => NodeLikeFactory
23705
- // ): void {
23706
- // registerFactory(NODE_LIKE_FACTORY_BASE_TYPE, type, factory);
23707
- // }
23708
-
23709
- const FameNodeModeSchema = union([literal('dev'), literal('prod')])
23710
- .default('prod');
23711
- object({
23712
- type: literal('Node').default('Node'),
23713
- mode: FameNodeModeSchema,
23714
- id: string$1().optional().nullable(),
23715
- directParentUrl: string$1().optional().nullable(),
23716
- admission: unknown().optional().nullable(),
23717
- requestedLogicals: array(string$1()).default([]),
23718
- delivery: unknown().optional().nullable(),
23719
- envContext: record(string$1(), unknown()).default({}),
23720
- services: array(unknown()).default([]),
23721
- hasParent: boolean().default(false),
23722
- security: unknown().optional().nullable(),
23723
- listeners: array(record(string$1(), unknown())).default([]),
23724
- publicUrl: string$1().optional().nullable(),
23725
- keyStore: unknown().optional().nullable(),
23726
- storage: unknown().optional().nullable(),
23727
- attachmentKeyValidator: unknown().optional().nullable(),
23728
- telemetry: unknown().optional().nullable(),
23729
- requestedCapabilities: array(string$1()).optional(),
23730
- })
23731
- .passthrough();
23732
-
23733
- getLogger('naylence.fame.sentinel.load_balancing.composite_load_balancing_strategy');
23734
-
23735
- getLogger('naylence.fame.sentinel.load_balancing.sticky_load_balancing_strategy');
23736
-
23737
- getLogger('naylence.fame.node.response_context_manager');
23738
-
23739
- getLogger('naylence.fame.node.streaming_response_handler');
23740
-
23741
- getLogger('naylence.fame.node.channel_polling_manager');
23742
-
23743
- getLogger('naylence.fame.node.rpc_server_handler');
23744
-
23745
- getLogger('naylence.fame.node.rpc_client_manager');
23746
-
23747
- getLogger('naylence.fame.node.envelope_listener_manager');
23748
-
23749
- getLogger('naylence.fame.node.root_session_manager');
23750
23819
 
23751
23820
  /**
23752
- * Base factory for creating FameConnector instances from either ConnectorConfig or ConnectionGrant.
23753
- *
23754
- * Concrete implementations must define supported grant types and provide grant-to-connector
23755
- * conversion logic.
23821
+ * Node event listener interface for clean, event-driven node lifecycle management.
23756
23822
  */
23757
- getLogger('naylence.fame.connector.connector_factory');
23758
-
23759
- getLogger('naylence.fame.node.upstream_session_manager');
23760
-
23761
- getLogger('naylence.fame.node.admission.noop_admission_client');
23762
- getLogger('naylence.fame.node.node');
23763
-
23764
- getLogger('naylence.fame.sentinel.route_manager');
23765
-
23766
- getLogger('naylence.fame.sentinel.router');
23767
-
23768
- getLogger('naylence.fame.sentinel.capability_aware_routing_policy');
23769
-
23770
- getLogger('naylence.fame.sentinel.node_attach_frame_handler');
23771
- new Set([
23772
- DeliveryOriginType.DOWNSTREAM,
23773
- DeliveryOriginType.PEER,
23774
- ]);
23775
-
23776
- getLogger('naylence.fame.sentinel.address_bind_frame_handler');
23777
-
23778
- getLogger('naylence.fame.sentinel.node_heartbeat_frame_handler');
23779
-
23780
- getLogger('naylence.fame.sentinel.capability_frame_handler');
23781
-
23782
- getLogger('naylence.fame.sentinel.credit_update_frame_handler');
23783
-
23784
- getLogger('naylence.fame.sentinel.sentinel');
23785
-
23786
- object({
23787
- directUrl: string$1().trim().min(1).optional().nullable(),
23788
- admission: unknown().optional().nullable(),
23789
- })
23790
- .passthrough();
23791
-
23792
- object({
23793
- type: literal('Sentinel').default('Sentinel'),
23794
- routingPolicy: unknown().optional().nullable(),
23795
- loadBalancing: unknown().optional().nullable(),
23796
- stickiness: unknown().optional().nullable(),
23797
- peers: unknown().optional().nullable(),
23798
- maxAttachTtlSec: number().min(0).optional().nullable(),
23799
- bindingAckTimeoutMs: number().min(0).optional().nullable(),
23800
- attachTimeoutSec: number().min(0).optional().nullable(),
23801
- routeStore: unknown().optional().nullable(),
23802
- })
23803
- .passthrough();
23804
- getLogger('naylence.fame.connector.base_async_connector');
23805
- // Environment variables
23806
- const ENV_VAR_FAME_FLOW_CONTROL = 'FAME_FLOW_CONTROL';
23807
- typeof process !== 'undefined' && process?.env
23808
- ? process.env[ENV_VAR_FAME_FLOW_CONTROL] !== '0'
23809
- : true;
23810
-
23811
23823
  /**
23812
- * WebSocket Connector Implementation
23824
+ * Abstract base class providing default implementations for NodeEventListener.
23813
23825
  *
23814
- * A transport adapter that works with both Node.js and browser WebSocket APIs.
23815
- * Supports both native WebSocket clients and server-side WebSocket connections.
23826
+ * This class provides a convenient base for implementing node event listeners
23827
+ * where you only need to override specific lifecycle methods. All methods
23828
+ * have sensible default implementations.
23816
23829
  */
23817
- getLogger('naylence.fame.connector.websocket_connector');
23818
-
23819
- const RPC_REGISTRY = Symbol('naylence.rpc.registry');
23820
- function isPlainObject$2(value) {
23821
- return Boolean(value &&
23822
- typeof value === 'object' &&
23830
+ class BaseNodeEventListener {
23831
+ constructor(priority = 1000) {
23832
+ this.priority = priority;
23833
+ }
23834
+ async onNodeStarted(_node) {
23835
+ // Default implementation does nothing
23836
+ }
23837
+ async onWelcome(_welcomeFrame) {
23838
+ // Default implementation does nothing
23839
+ }
23840
+ async onHeartbeatReceived(_envelope) {
23841
+ // Default implementation does nothing
23842
+ }
23843
+ async onHeartbeatSent(_node, _envelope) {
23844
+ // Default implementation does nothing
23845
+ }
23846
+ async onNodeInitialized(_node) {
23847
+ // Default implementation does nothing
23848
+ }
23849
+ async onNodeAttachToPeer(_node, _attachInfo, _connector) {
23850
+ // Default implementation does nothing
23851
+ }
23852
+ async onNodeAttachToUpstream(_node, _attachInfo) {
23853
+ // Default implementation does nothing
23854
+ }
23855
+ async onEnvelopeReceived(_node, envelope, _context) {
23856
+ // Default implementation passes envelope through unchanged
23857
+ return envelope;
23858
+ }
23859
+ async onDeliverLocal(_node, _address, envelope, _context) {
23860
+ // Default implementation passes envelope through unchanged
23861
+ return envelope;
23862
+ }
23863
+ async onDeliver(_node, envelope, _context) {
23864
+ // Default implementation passes envelope through unchanged
23865
+ return envelope;
23866
+ }
23867
+ async onForwardUpstream(_node, envelope, _context) {
23868
+ // Default implementation passes envelope through unchanged
23869
+ return envelope;
23870
+ }
23871
+ async onForwardToRoute(_node, _nextSegment, envelope, _context) {
23872
+ // Default implementation passes envelope through unchanged
23873
+ return envelope;
23874
+ }
23875
+ async onForwardToPeer(_node, _peerSegment, envelope, _context) {
23876
+ // Default implementation passes envelope through unchanged
23877
+ return envelope;
23878
+ }
23879
+ async onForwardUpstreamComplete(_node, envelope, _result, _error, _context) {
23880
+ // Default implementation passes envelope through unchanged
23881
+ return envelope;
23882
+ }
23883
+ async onForwardToRouteComplete(_node, _nextSegment, envelope, _result, _error, _context) {
23884
+ // Default implementation passes envelope through unchanged
23885
+ return envelope;
23886
+ }
23887
+ async onForwardToPeerComplete(_node, _peerSegment, envelope, _result, _error, _context) {
23888
+ // Default implementation passes envelope through unchanged
23889
+ return envelope;
23890
+ }
23891
+ async onForwardToPeers(_node, envelope, _peers, _excludePeers, _context) {
23892
+ // Default implementation passes envelope through unchanged
23893
+ return envelope;
23894
+ }
23895
+ async onForwardToPeersComplete(_node, envelope, _peers, _excludePeers, _result, _error, _context) {
23896
+ // Default implementation passes envelope through unchanged
23897
+ return envelope;
23898
+ }
23899
+ async onChildAttach(_options) {
23900
+ // Default implementation does nothing
23901
+ }
23902
+ async onEpochChange(_node, _epoch) {
23903
+ // Default implementation does nothing
23904
+ }
23905
+ async onNodePreparingToStop(_node) {
23906
+ // Default implementation does nothing
23907
+ }
23908
+ async onNodeStopped(_node) {
23909
+ // Default implementation does nothing
23910
+ }
23911
+ }
23912
+ var EncryptionStatus;
23913
+ (function (EncryptionStatus) {
23914
+ EncryptionStatus["OK"] = "OK";
23915
+ EncryptionStatus["SKIPPED"] = "SKIPPED";
23916
+ EncryptionStatus["QUEUED"] = "QUEUED";
23917
+ })(EncryptionStatus || (EncryptionStatus = {}));
23918
+
23919
+ var CryptoLevel;
23920
+ (function (CryptoLevel) {
23921
+ CryptoLevel["PLAINTEXT"] = "plaintext";
23922
+ CryptoLevel["CHANNEL"] = "channel";
23923
+ CryptoLevel["SEALED"] = "sealed";
23924
+ })(CryptoLevel || (CryptoLevel = {}));
23925
+ ({
23926
+ [CryptoLevel.PLAINTEXT]: 1,
23927
+ [CryptoLevel.CHANNEL]: 2,
23928
+ [CryptoLevel.SEALED]: 3,
23929
+ });
23930
+ var SecurityAction;
23931
+ (function (SecurityAction) {
23932
+ SecurityAction["ALLOW"] = "allow";
23933
+ SecurityAction["REJECT"] = "reject";
23934
+ SecurityAction["NACK"] = "nack";
23935
+ })(SecurityAction || (SecurityAction = {}));
23936
+ var SignaturePolicy;
23937
+ (function (SignaturePolicy) {
23938
+ SignaturePolicy["REQUIRED"] = "required";
23939
+ SignaturePolicy["OPTIONAL"] = "optional";
23940
+ SignaturePolicy["DISABLED"] = "disabled";
23941
+ SignaturePolicy["FORBIDDEN"] = "forbidden";
23942
+ })(SignaturePolicy || (SignaturePolicy = {}));
23943
+ ({
23944
+ plaintextViolationAction: SecurityAction.NACK,
23945
+ channelViolationAction: SecurityAction.NACK,
23946
+ sealedViolationAction: SecurityAction.NACK,
23947
+ });
23948
+ ({
23949
+ minimumResponseLevel: CryptoLevel.CHANNEL});
23950
+ ({
23951
+ defaultLevel: CryptoLevel.CHANNEL});
23952
+ ({
23953
+ signaturePolicy: SignaturePolicy.OPTIONAL,
23954
+ unsignedViolationAction: SecurityAction.ALLOW,
23955
+ invalidSignatureAction: SecurityAction.REJECT,
23956
+ missingKeyAction: SecurityAction.NACK,
23957
+ });
23958
+ ({
23959
+ signingMaterial: SigningMaterial.RAW_KEY});
23960
+ ({
23961
+ minimumCryptoLevel: CryptoLevel.PLAINTEXT});
23962
+
23963
+ getLogger('naylence.fame.node.envelope_security_handler');
23964
+
23965
+ getLogger('naylence.fame.node.secure_channel_frame_handler');
23966
+
23967
+ const FameNodeAuthorizationContextSchema = AuthorizationContextSchema.and(object({
23968
+ sub: string$1().optional(),
23969
+ aud: string$1().optional(),
23970
+ assignedPath: string$1().optional(),
23971
+ acceptedCapabilities: array(string$1()).optional(),
23972
+ acceptedLogicals: array(string$1()).optional(),
23973
+ instanceId: string$1().optional(),
23974
+ scopes: array(string$1()).optional(),
23975
+ attachExpiresAt: date().optional(),
23976
+ }));
23977
+ FameDeliveryContextSchema.extend({
23978
+ security: SecurityContextSchema.extend({
23979
+ authorization: FameNodeAuthorizationContextSchema.optional(),
23980
+ }).optional(),
23981
+ });
23982
+
23983
+ getLogger('naylence.fame.sentinel.load_balancing.composite_load_balancing_strategy');
23984
+
23985
+ getLogger('naylence.fame.sentinel.load_balancing.sticky_load_balancing_strategy');
23986
+
23987
+ getLogger('naylence.fame.sentinel.route_manager');
23988
+
23989
+ getLogger('naylence.fame.sentinel.router');
23990
+
23991
+ getLogger('naylence.fame.sentinel.capability_aware_routing_policy');
23992
+
23993
+ getLogger('naylence.fame.sentinel.node_attach_frame_handler');
23994
+ new Set([
23995
+ DeliveryOriginType.DOWNSTREAM,
23996
+ DeliveryOriginType.PEER,
23997
+ ]);
23998
+
23999
+ getLogger('naylence.fame.sentinel.address_bind_frame_handler');
24000
+
24001
+ getLogger('naylence.fame.sentinel.node_heartbeat_frame_handler');
24002
+
24003
+ getLogger('naylence.fame.sentinel.capability_frame_handler');
24004
+
24005
+ getLogger('naylence.fame.sentinel.credit_update_frame_handler');
24006
+
24007
+ getLogger('naylence.fame.sentinel.sentinel');
24008
+
24009
+ object({
24010
+ directUrl: string$1().trim().min(1).optional().nullable(),
24011
+ admission: unknown().optional().nullable(),
24012
+ })
24013
+ .passthrough();
24014
+
24015
+ object({
24016
+ type: literal('Sentinel').default('Sentinel'),
24017
+ routingPolicy: unknown().optional().nullable(),
24018
+ loadBalancing: unknown().optional().nullable(),
24019
+ stickiness: unknown().optional().nullable(),
24020
+ peers: unknown().optional().nullable(),
24021
+ maxAttachTtlSec: number().min(0).optional().nullable(),
24022
+ bindingAckTimeoutMs: number().min(0).optional().nullable(),
24023
+ attachTimeoutSec: number().min(0).optional().nullable(),
24024
+ routeStore: unknown().optional().nullable(),
24025
+ })
24026
+ .passthrough();
24027
+
24028
+ /**
24029
+ * WebSocket Connector Implementation
24030
+ *
24031
+ * A transport adapter that works with both Node.js and browser WebSocket APIs.
24032
+ * Supports both native WebSocket clients and server-side WebSocket connections.
24033
+ */
24034
+ getLogger('naylence.fame.connector.websocket_connector');
24035
+
24036
+ /**
24037
+ * Browser-local connector that routes binary frames between peers via an in-page EventTarget.
24038
+ * Relies on BaseAsyncConnector for flow control and shutdown behavior.
24039
+ */
24040
+ getLogger('naylence.fame.connector.inpage_connector');
24041
+
24042
+ const RPC_REGISTRY = Symbol('naylence.rpc.registry');
24043
+ function isPlainObject$1(value) {
24044
+ return Boolean(value &&
24045
+ typeof value === 'object' &&
23823
24046
  Object.prototype.toString.call(value) === '[object Object]');
23824
24047
  }
23825
24048
  function getOrCreateRegistry(ctor) {
@@ -23836,10 +24059,10 @@
23836
24059
  return { positional: [], keyword: {} };
23837
24060
  }
23838
24061
  const positional = Array.isArray(params.args) ? [...params.args] : [];
23839
- const keyword = isPlainObject$2(params.kwargs) ? { ...params.kwargs } : {};
24062
+ const keyword = isPlainObject$1(params.kwargs) ? { ...params.kwargs } : {};
23840
24063
  if (positional.length === 0 &&
23841
24064
  Object.keys(keyword).length === 0 &&
23842
- isPlainObject$2(params)) {
24065
+ isPlainObject$1(params)) {
23843
24066
  return { positional: [], keyword: { ...params } };
23844
24067
  }
23845
24068
  return { positional, keyword };
@@ -23883,7 +24106,7 @@
23883
24106
  return { stream: false, args };
23884
24107
  }
23885
24108
  const last = args[args.length - 1];
23886
- if (isPlainObject$2(last) &&
24109
+ if (isPlainObject$1(last) &&
23887
24110
  Object.prototype.hasOwnProperty.call(last, '_stream')) {
23888
24111
  const { _stream, ...rest } = last;
23889
24112
  const cleanedArgs = [...args.slice(0, -1)];
@@ -23893,7 +24116,7 @@
23893
24116
  return { stream: Boolean(_stream), args: cleanedArgs };
23894
24117
  }
23895
24118
  if (args.length === 1 &&
23896
- isPlainObject$2(args[0]) &&
24119
+ isPlainObject$1(args[0]) &&
23897
24120
  Object.prototype.hasOwnProperty.call(args[0], '_stream')) {
23898
24121
  const { _stream, ...rest } = args[0];
23899
24122
  return {
@@ -23912,7 +24135,7 @@
23912
24135
  return async (...rawArgs) => {
23913
24136
  const { stream, args } = extractStreamFlag(rawArgs);
23914
24137
  let params;
23915
- if (args.length === 1 && isPlainObject$2(args[0])) {
24138
+ if (args.length === 1 && isPlainObject$1(args[0])) {
23916
24139
  params = args[0];
23917
24140
  }
23918
24141
  else {
@@ -23955,8 +24178,12 @@
23955
24178
  * Provides the list of runtime factory modules for registration.
23956
24179
  */
23957
24180
  const MODULES = [
24181
+ "./connector/broadcast-channel-connector-factory.js",
24182
+ "./connector/broadcast-channel-listener-factory.js",
23958
24183
  "./connector/http-listener-factory.js",
23959
24184
  "./connector/http-stateless-connector-factory.js",
24185
+ "./connector/inpage-connector-factory.js",
24186
+ "./connector/inpage-listener-factory.js",
23960
24187
  "./connector/websocket-connector-factory.js",
23961
24188
  "./connector/websocket-listener-factory.js",
23962
24189
  "./delivery/at-least-once-delivery-policy-factory.js",
@@ -23969,7 +24196,6 @@
23969
24196
  "./node/admission/welcome-service-client-factory.js",
23970
24197
  "./node/node-factory.js",
23971
24198
  "./placement/static-node-placement-strategy-factory.js",
23972
- "./placement/websocket-node-placement-strategy-factory.js",
23973
24199
  "./security/auth/bearer-token-header-auth-injection-strategy-factory.js",
23974
24200
  "./security/auth/default-authorizer-factory.js",
23975
24201
  "./security/auth/jwks-jwt-token-verifier-factory.js",
@@ -24217,8 +24443,153 @@
24217
24443
  async function registerRuntimeFactories(registry = ResourceFactoryRegistry) {
24218
24444
  await registerDefaultFactories(registry);
24219
24445
  }
24446
+
24447
+ const AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE = 'AuthInjectionStrategyFactory';
24448
+ class AuthInjectionStrategyFactory extends AbstractResourceFactory {
24449
+ static async createAuthInjectionStrategy(config, options = {}) {
24450
+ if (config) {
24451
+ const strategy = await createResource$1(AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE, config, options);
24452
+ if (!strategy) {
24453
+ throw new Error('Failed to create auth injection strategy from configuration');
24454
+ }
24455
+ return strategy;
24456
+ }
24457
+ const strategy = await createDefaultResource(AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE, null, options);
24458
+ if (!strategy) {
24459
+ throw new Error('Failed to create default auth injection strategy');
24460
+ }
24461
+ return strategy;
24462
+ }
24463
+ }
24464
+
24465
+ getLogger('naylence.fame.security.keys.default_key_manager');
24466
+
24467
+ getLogger('naylence.fame.security.keys.noop_key_validator');
24468
+
24469
+ getLogger('naylence.fame.security.keys.key_management_handler');
24470
+
24471
+ getLogger('naylence.fame.security.keys.key_store');
24472
+
24473
+ utf8ToBytes('naylence-sealed-envelope');
24474
+
24475
+ getLogger('naylence.fame.security.policy.default_security_policy');
24476
+
24477
+ getLogger('naylence.fame.sentinel.key_correlation_map');
24478
+
24479
+ getLogger('naylence.fame.sentinel.key_frame_handler');
24480
+ getLogger('naylence.fame.security.default_security_manager');
24481
+
24482
+ getLogger('naylence.fame.security.auth.jwt_token_issuer');
24483
+
24484
+ getLogger('naylence.fame.security.auth.jwt_token_verifier');
24485
+
24486
+ getLogger('naylence.fame.security.crypto.providers.default_crypto_provider');
24487
+
24488
+ typeof TextDecoder !== 'undefined' ? new TextDecoder() : null;
24220
24489
  new TextEncoder();
24221
24490
 
24491
+ getLogger('naylence.fame.security.node_security_profile_factory');
24492
+
24493
+ getLogger('naylence.fame.stickiness.simple_load_balancer_stickiness_manager');
24494
+
24495
+ const WEBSOCKET_CONNECTION_GRANT_TYPE = 'WebSocketConnectionGrant';
24496
+ function normalizeWebSocketConnectionGrant(candidate) {
24497
+ const type = typeof candidate.type === 'string'
24498
+ ? candidate.type
24499
+ : WEBSOCKET_CONNECTION_GRANT_TYPE;
24500
+ if (type !== WEBSOCKET_CONNECTION_GRANT_TYPE) {
24501
+ throw new TypeError(`WebSocketConnectionGrant expected type "${WEBSOCKET_CONNECTION_GRANT_TYPE}", received "${type}"`);
24502
+ }
24503
+ const purpose = typeof candidate.purpose === 'string' && candidate.purpose.length > 0
24504
+ ? candidate.purpose
24505
+ : GRANT_PURPOSE_NODE_ATTACH;
24506
+ assertConnectionGrant({ ...candidate, type, purpose }, 'WebSocketConnectionGrant requires a valid base grant');
24507
+ const urlValue = candidate.url;
24508
+ if (urlValue !== undefined &&
24509
+ (typeof urlValue !== 'string' || urlValue.trim().length === 0)) {
24510
+ throw new TypeError('WebSocketConnectionGrant "url" must be a non-empty string when provided');
24511
+ }
24512
+ const base = {
24513
+ type,
24514
+ purpose,
24515
+ };
24516
+ if (typeof urlValue === 'string') {
24517
+ base.url = urlValue;
24518
+ }
24519
+ const authConfig = canonicalizeAuthConfig(candidate.auth);
24520
+ if (authConfig) {
24521
+ base.auth = authConfig;
24522
+ }
24523
+ return base;
24524
+ }
24525
+
24526
+ const TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE = 'TransportProvisionerFactory';
24527
+ class TransportProvisionerFactory extends AbstractResourceFactory {
24528
+ static async createTransportProvisioner(config, options = {}) {
24529
+ if (config) {
24530
+ const provisioner = await createResource$1(TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, config, options);
24531
+ if (!provisioner) {
24532
+ throw new Error('Failed to create transport provisioner from configuration');
24533
+ }
24534
+ return provisioner;
24535
+ }
24536
+ let provisioner = null;
24537
+ try {
24538
+ provisioner = await createDefaultResource(TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, null, options);
24539
+ }
24540
+ catch (error) {
24541
+ const message = 'Failed to create default transport provisioner' +
24542
+ (error instanceof Error && error.message ? `: ${error.message}` : '');
24543
+ throw new Error(message);
24544
+ }
24545
+ if (!provisioner) {
24546
+ throw new Error('Failed to create default transport provisioner');
24547
+ }
24548
+ return provisioner;
24549
+ }
24550
+ }
24551
+
24552
+ getLogger('naylence.fame.welcome.default_welcome_service');
24553
+ const ENV_VAR_SHOW_ENVELOPES = 'FAME_SHOW_ENVELOPES';
24554
+ typeof process !== 'undefined' && resolveShowEnvelopesFlag(process.env);
24555
+ function toCamelAlias(snakeKey) {
24556
+ return snakeKey
24557
+ .toLowerCase()
24558
+ .replace(/_([a-z])/g, (_match, char) => char.toUpperCase());
24559
+ }
24560
+ function readEnvValue(env, snakeKey) {
24561
+ if (!env) {
24562
+ return undefined;
24563
+ }
24564
+ if (env[snakeKey] !== undefined) {
24565
+ return env[snakeKey];
24566
+ }
24567
+ const lowerKey = snakeKey.toLowerCase();
24568
+ if (env[lowerKey] !== undefined) {
24569
+ return env[lowerKey];
24570
+ }
24571
+ const camelKey = toCamelAlias(snakeKey);
24572
+ if (env[camelKey] !== undefined) {
24573
+ return env[camelKey];
24574
+ }
24575
+ const pascalKey = camelKey.length > 0
24576
+ ? camelKey[0].toUpperCase() + camelKey.slice(1)
24577
+ : camelKey;
24578
+ if (pascalKey && env[pascalKey] !== undefined) {
24579
+ return env[pascalKey];
24580
+ }
24581
+ return undefined;
24582
+ }
24583
+ function resolveShowEnvelopesFlag(env) {
24584
+ const candidate = readEnvValue(env, ENV_VAR_SHOW_ENVELOPES);
24585
+ if (typeof candidate !== 'string') {
24586
+ return false;
24587
+ }
24588
+ return candidate.trim().toLowerCase() === 'true';
24589
+ }
24590
+
24591
+ getLogger('naylence.fame.welcome.node_welcome_router');
24592
+
24222
24593
  /**
24223
24594
  * Browser-friendly entry point for Naylence Runtime.
24224
24595
  *
@@ -24266,99 +24637,6 @@
24266
24637
  };
24267
24638
  ensureRuntimePluginLoader();
24268
24639
 
24269
- /**
24270
- * Node event listener interface for clean, event-driven node lifecycle management.
24271
- */
24272
- /**
24273
- * Abstract base class providing default implementations for NodeEventListener.
24274
- *
24275
- * This class provides a convenient base for implementing node event listeners
24276
- * where you only need to override specific lifecycle methods. All methods
24277
- * have sensible default implementations.
24278
- */
24279
- class BaseNodeEventListener {
24280
- constructor(priority = 1000) {
24281
- this.priority = priority;
24282
- }
24283
- async onNodeStarted(_node) {
24284
- // Default implementation does nothing
24285
- }
24286
- async onWelcome(_welcomeFrame) {
24287
- // Default implementation does nothing
24288
- }
24289
- async onHeartbeatReceived(_envelope) {
24290
- // Default implementation does nothing
24291
- }
24292
- async onHeartbeatSent(_node, _envelope) {
24293
- // Default implementation does nothing
24294
- }
24295
- async onNodeInitialized(_node) {
24296
- // Default implementation does nothing
24297
- }
24298
- async onNodeAttachToPeer(_node, _attachInfo, _connector) {
24299
- // Default implementation does nothing
24300
- }
24301
- async onNodeAttachToUpstream(_node, _attachInfo) {
24302
- // Default implementation does nothing
24303
- }
24304
- async onEnvelopeReceived(_node, envelope, _context) {
24305
- // Default implementation passes envelope through unchanged
24306
- return envelope;
24307
- }
24308
- async onDeliverLocal(_node, _address, envelope, _context) {
24309
- // Default implementation passes envelope through unchanged
24310
- return envelope;
24311
- }
24312
- async onDeliver(_node, envelope, _context) {
24313
- // Default implementation passes envelope through unchanged
24314
- return envelope;
24315
- }
24316
- async onForwardUpstream(_node, envelope, _context) {
24317
- // Default implementation passes envelope through unchanged
24318
- return envelope;
24319
- }
24320
- async onForwardToRoute(_node, _nextSegment, envelope, _context) {
24321
- // Default implementation passes envelope through unchanged
24322
- return envelope;
24323
- }
24324
- async onForwardToPeer(_node, _peerSegment, envelope, _context) {
24325
- // Default implementation passes envelope through unchanged
24326
- return envelope;
24327
- }
24328
- async onForwardUpstreamComplete(_node, envelope, _result, _error, _context) {
24329
- // Default implementation passes envelope through unchanged
24330
- return envelope;
24331
- }
24332
- async onForwardToRouteComplete(_node, _nextSegment, envelope, _result, _error, _context) {
24333
- // Default implementation passes envelope through unchanged
24334
- return envelope;
24335
- }
24336
- async onForwardToPeerComplete(_node, _peerSegment, envelope, _result, _error, _context) {
24337
- // Default implementation passes envelope through unchanged
24338
- return envelope;
24339
- }
24340
- async onForwardToPeers(_node, envelope, _peers, _excludePeers, _context) {
24341
- // Default implementation passes envelope through unchanged
24342
- return envelope;
24343
- }
24344
- async onForwardToPeersComplete(_node, envelope, _peers, _excludePeers, _result, _error, _context) {
24345
- // Default implementation passes envelope through unchanged
24346
- return envelope;
24347
- }
24348
- async onChildAttach(_options) {
24349
- // Default implementation does nothing
24350
- }
24351
- async onEpochChange(_node, _epoch) {
24352
- // Default implementation does nothing
24353
- }
24354
- async onNodePreparingToStop(_node) {
24355
- // Default implementation does nothing
24356
- }
24357
- async onNodeStopped(_node) {
24358
- // Default implementation does nothing
24359
- }
24360
- }
24361
-
24362
24640
  const telemetryLogger = getLogger('naylence.fame.telemetry.base_trace_emitter');
24363
24641
  function logTelemetryFailure(event, error, context = {}) {
24364
24642
  telemetryLogger.warning(event, {
@@ -24672,31 +24950,13 @@
24672
24950
  default: NoopTraceEmitterFactory
24673
24951
  });
24674
24952
 
24675
- const AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE = 'AuthInjectionStrategyFactory';
24676
- class AuthInjectionStrategyFactory extends AbstractResourceFactory {
24677
- static async createAuthInjectionStrategy(config, options = {}) {
24678
- if (config) {
24679
- const strategy = await createResource$1(AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE, config, options);
24680
- if (!strategy) {
24681
- throw new Error('Failed to create auth injection strategy from configuration');
24682
- }
24683
- return strategy;
24684
- }
24685
- const strategy = await createDefaultResource(AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE, null, options);
24686
- if (!strategy) {
24687
- throw new Error('Failed to create default auth injection strategy');
24688
- }
24689
- return strategy;
24690
- }
24691
- }
24692
-
24693
- const logger$5 = getLogger('naylence.fame.telemetry.otel_setup');
24953
+ const logger$2$1 = getLogger('naylence.fame.telemetry.otel_setup');
24694
24954
  let registeredOtel = null;
24695
24955
  async function setupOtel(options) {
24696
24956
  const normalized = normalizeSetupOtelOptions(options);
24697
24957
  try {
24698
24958
  if (registeredOtel) {
24699
- logger$5.debug('open_telemetry_reusing_provider', {
24959
+ logger$2$1.debug('open_telemetry_reusing_provider', {
24700
24960
  service_name: normalized.serviceName,
24701
24961
  });
24702
24962
  return registeredOtel.control;
@@ -24717,12 +24977,12 @@
24717
24977
  }
24718
24978
  if (currentProvider &&
24719
24979
  currentProvider.constructor?.name === 'NodeTracerProvider') {
24720
- logger$5.debug('open_telemetry_existing_node_provider', {
24980
+ logger$2$1.debug('open_telemetry_existing_node_provider', {
24721
24981
  service_name: normalized.serviceName,
24722
24982
  });
24723
24983
  return null;
24724
24984
  }
24725
- logger$5.debug('open_telemetry_initializing', {
24985
+ logger$2$1.debug('open_telemetry_initializing', {
24726
24986
  service_name: normalized.serviceName,
24727
24987
  endpoint: normalized.endpoint ?? null,
24728
24988
  environment: normalized.environment ?? null,
@@ -24750,7 +25010,7 @@
24750
25010
  spanProcessors: [spanProcessor],
24751
25011
  });
24752
25012
  provider.register();
24753
- logger$5.debug('open_telemetry_initialized', {
25013
+ logger$2$1.debug('open_telemetry_initialized', {
24754
25014
  service_name: normalized.serviceName,
24755
25015
  exporter: exporter.constructor?.name ?? 'unknown_exporter',
24756
25016
  });
@@ -24760,7 +25020,7 @@
24760
25020
  await provider.forceFlush();
24761
25021
  }
24762
25022
  catch (flushError) {
24763
- logger$5.warning('open_telemetry_force_flush_failed', {
25023
+ logger$2$1.warning('open_telemetry_force_flush_failed', {
24764
25024
  error: flushError instanceof Error
24765
25025
  ? flushError.message
24766
25026
  : String(flushError),
@@ -24772,7 +25032,7 @@
24772
25032
  await provider.shutdown();
24773
25033
  }
24774
25034
  catch (shutdownError) {
24775
- logger$5.warning('open_telemetry_shutdown_failed', {
25035
+ logger$2$1.warning('open_telemetry_shutdown_failed', {
24776
25036
  error: shutdownError instanceof Error
24777
25037
  ? shutdownError.message
24778
25038
  : String(shutdownError),
@@ -24790,7 +25050,7 @@
24790
25050
  return control;
24791
25051
  }
24792
25052
  catch (error) {
24793
- logger$5.error('open_telemetry_not_available', {
25053
+ logger$2$1.error('open_telemetry_not_available', {
24794
25054
  error: error instanceof Error ? error.message : String(error),
24795
25055
  stack: error instanceof Error && error.stack ? error.stack : undefined,
24796
25056
  });
@@ -24896,7 +25156,7 @@
24896
25156
  if (headers && Object.keys(headers).length > 0) {
24897
25157
  exporterOptions.headers = headers;
24898
25158
  }
24899
- logger$5.debug('open_telemetry_using_otlp_http_exporter', {
25159
+ logger$2$1.debug('open_telemetry_using_otlp_http_exporter', {
24900
25160
  endpoint,
24901
25161
  headers_present: Boolean(headers && Object.keys(headers).length),
24902
25162
  });
@@ -24904,17 +25164,17 @@
24904
25164
  }
24905
25165
  }
24906
25166
  catch (error) {
24907
- logger$5.error('open_telemetry_exporter_not_available', {
25167
+ logger$2$1.error('open_telemetry_exporter_not_available', {
24908
25168
  error: error instanceof Error ? error.message : String(error),
24909
25169
  });
24910
25170
  }
24911
25171
  }
24912
- logger$5.warning('open_telemetry_falling_back_to_console_exporter');
25172
+ logger$2$1.warning('open_telemetry_falling_back_to_console_exporter');
24913
25173
  return new ConsoleSpanExporter();
24914
25174
  }
24915
25175
 
24916
25176
  let openTelemetryTraceEmitterModulePromise = null;
24917
- const logger$4 = getLogger('naylence.fame.telemetry.open_telemetry_trace_emitter_factory');
25177
+ const logger$1$1 = getLogger('naylence.fame.telemetry.open_telemetry_trace_emitter_factory');
24918
25178
  function getOpenTelemetryTraceEmitterModule() {
24919
25179
  if (!openTelemetryTraceEmitterModulePromise) {
24920
25180
  openTelemetryTraceEmitterModulePromise = safeImport(() => Promise.resolve().then(function () { return openTelemetryTraceEmitter; }), '@opentelemetry/api', {
@@ -24946,7 +25206,7 @@
24946
25206
  await AuthInjectionStrategyFactory.createAuthInjectionStrategy(normalized.auth);
24947
25207
  try {
24948
25208
  await authStrategy.apply(mergedHeaders);
24949
- logger$4.info('trace_emitter_auth_applied', {
25209
+ logger$1$1.info('trace_emitter_auth_applied', {
24950
25210
  service_name: normalized.serviceName,
24951
25211
  });
24952
25212
  }
@@ -24969,7 +25229,7 @@
24969
25229
  sampler: normalized.sampler,
24970
25230
  headers: Object.keys(mergedHeaders).length > 0 ? mergedHeaders : undefined,
24971
25231
  });
24972
- logger$4.debug('trace_emitter_lifecycle_acquired', {
25232
+ logger$1$1.debug('trace_emitter_lifecycle_acquired', {
24973
25233
  service_name: normalized.serviceName,
24974
25234
  lifecycle_available: Boolean(lifecycle),
24975
25235
  });
@@ -25000,7 +25260,7 @@
25000
25260
  }
25001
25261
  try {
25002
25262
  const emitter = new OpenTelemetryTraceEmitter(emitterOptions);
25003
- logger$4.debug('trace_emitter_created', {
25263
+ logger$1$1.debug('trace_emitter_created', {
25004
25264
  service_name: normalized.serviceName,
25005
25265
  has_lifecycle: Boolean(lifecycle),
25006
25266
  has_auth_strategy: Boolean(authStrategy),
@@ -25194,15 +25454,10 @@
25194
25454
  default: TraceEmitterProfileFactory
25195
25455
  });
25196
25456
 
25197
- getLogger('naylence.fame.security.auth.jwt_token_issuer');
25198
-
25199
- getLogger('naylence.fame.security.auth.jwt_token_verifier');
25200
-
25201
- getLogger('naylence.fame.security.crypto.providers.default_crypto_provider');
25202
-
25203
25457
  let initialized = false;
25204
25458
  const runtimePlugin = {
25205
25459
  name: 'naylence:runtime',
25460
+ version: VERSION$2,
25206
25461
  async register() {
25207
25462
  // console.log('[naylence:runtime] register() called, initialized=', initialized);
25208
25463
  if (initialized) {
@@ -25511,93 +25766,6 @@
25511
25766
  OpenTelemetryTraceEmitter: OpenTelemetryTraceEmitter
25512
25767
  });
25513
25768
 
25514
- const AUTH_INJECTION_STRATEGY_TYPE_ALIASES = {
25515
- BearerTokenHeaderAuthInjectionStrategy: 'BearerTokenHeaderAuth',
25516
- BearerTokenHeaderAuthStrategy: 'BearerTokenHeaderAuth',
25517
- NoAuthInjectionStrategy: 'NoAuth',
25518
- QueryParamAuthInjectionStrategy: 'QueryParamAuth',
25519
- QueryParamAuthStrategy: 'QueryParamAuth',
25520
- WebSocketSubprotocolAuthInjectionStrategy: 'WebSocketSubprotocolAuth',
25521
- WebSocketSubprotocolAuthStrategy: 'WebSocketSubprotocolAuth',
25522
- };
25523
- function canonicalizeAuthConfig(auth) {
25524
- if (!auth || typeof auth !== 'object' || Array.isArray(auth)) {
25525
- return undefined;
25526
- }
25527
- const typeValue = auth.type;
25528
- if (typeof typeValue !== 'string') {
25529
- return auth;
25530
- }
25531
- const normalizedType = AUTH_INJECTION_STRATEGY_TYPE_ALIASES[typeValue] ?? typeValue;
25532
- if (normalizedType === typeValue) {
25533
- return auth;
25534
- }
25535
- return {
25536
- ...auth,
25537
- type: normalizedType,
25538
- };
25539
- }
25540
- function assertConnectionGrant(candidate, message = 'Invalid connection grant') {
25541
- assertGrant(candidate, message);
25542
- }
25543
-
25544
- const WEBSOCKET_CONNECTION_GRANT_TYPE = 'WebSocketConnectionGrant';
25545
- function normalizeWebSocketConnectionGrant(candidate) {
25546
- const type = typeof candidate.type === 'string'
25547
- ? candidate.type
25548
- : WEBSOCKET_CONNECTION_GRANT_TYPE;
25549
- if (type !== WEBSOCKET_CONNECTION_GRANT_TYPE) {
25550
- throw new TypeError(`WebSocketConnectionGrant expected type "${WEBSOCKET_CONNECTION_GRANT_TYPE}", received "${type}"`);
25551
- }
25552
- const purpose = typeof candidate.purpose === 'string' && candidate.purpose.length > 0
25553
- ? candidate.purpose
25554
- : GRANT_PURPOSE_NODE_ATTACH;
25555
- assertConnectionGrant({ ...candidate, type, purpose }, 'WebSocketConnectionGrant requires a valid base grant');
25556
- const urlValue = candidate.url;
25557
- if (urlValue !== undefined &&
25558
- (typeof urlValue !== 'string' || urlValue.trim().length === 0)) {
25559
- throw new TypeError('WebSocketConnectionGrant "url" must be a non-empty string when provided');
25560
- }
25561
- const base = {
25562
- type,
25563
- purpose,
25564
- };
25565
- if (typeof urlValue === 'string') {
25566
- base.url = urlValue;
25567
- }
25568
- const authConfig = canonicalizeAuthConfig(candidate.auth);
25569
- if (authConfig) {
25570
- base.auth = authConfig;
25571
- }
25572
- return base;
25573
- }
25574
-
25575
- const TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE = 'TransportProvisionerFactory';
25576
- class TransportProvisionerFactory extends AbstractResourceFactory {
25577
- static async createTransportProvisioner(config, options = {}) {
25578
- if (config) {
25579
- const provisioner = await createResource$1(TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, config, options);
25580
- if (!provisioner) {
25581
- throw new Error('Failed to create transport provisioner from configuration');
25582
- }
25583
- return provisioner;
25584
- }
25585
- let provisioner = null;
25586
- try {
25587
- provisioner = await createDefaultResource(TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, null, options);
25588
- }
25589
- catch (error) {
25590
- const message = 'Failed to create default transport provisioner' +
25591
- (error instanceof Error && error.message ? `: ${error.message}` : '');
25592
- throw new Error(message);
25593
- }
25594
- if (!provisioner) {
25595
- throw new Error('Failed to create default transport provisioner');
25596
- }
25597
- return provisioner;
25598
- }
25599
- }
25600
-
25601
25769
  class WebSocketTransportProvisioner {
25602
25770
  constructor(options) {
25603
25771
  this.url = options.url;
@@ -26605,6 +26773,7 @@
26605
26773
  this._capabilities = [AGENT_CAPABILITY];
26606
26774
  this._subscriptions = new Map();
26607
26775
  this._stateLock = new AsyncLock();
26776
+ this._node = null;
26608
26777
  this._stateStore = null;
26609
26778
  this._stateCache = null;
26610
26779
  this._name = name ?? camelToSnakeCase(this.constructor.name);
@@ -26635,10 +26804,8 @@
26635
26804
  }
26636
26805
  get storageProvider() {
26637
26806
  if (!this._storageProvider) {
26638
- // Try to get storage provider from current node context (matches Python behavior)
26639
- const node = getCurrentNode();
26640
- if (node) {
26641
- this._storageProvider = node.storageProvider;
26807
+ if (this._node) {
26808
+ this._storageProvider = this._node.storageProvider;
26642
26809
  }
26643
26810
  }
26644
26811
  if (!this._storageProvider) {
@@ -26646,6 +26813,9 @@
26646
26813
  }
26647
26814
  return this._storageProvider;
26648
26815
  }
26816
+ async onRegister(node) {
26817
+ this._node = node;
26818
+ }
26649
26819
  async acquireStateLock() {
26650
26820
  let acquiredResolve;
26651
26821
  const acquired = new Promise((resolve) => {