@makaio/framework 1.0.0-dev-1790772200584 → 1.0.0-dev-1790783144258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/adapters/claude/index.d.mts +20 -20
  3. package/dist/bus/index.d.mts +39 -9
  4. package/dist/bus/index.mjs +1 -1
  5. package/dist/bus-B-ksy7YX.mjs +9 -0
  6. package/dist/contracts/adapter/index.d.mts +1 -1
  7. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  8. package/dist/contracts/artifact/index.d.mts +2 -2
  9. package/dist/contracts/automation-trigger/index.d.mts +1 -1
  10. package/dist/contracts/capabilities/index.d.mts +1 -1
  11. package/dist/contracts/client/index.d.mts +2 -2
  12. package/dist/contracts/extension/index.d.mts +4 -4
  13. package/dist/contracts/harness/index.d.mts +1 -1
  14. package/dist/contracts/index.d.mts +69 -69
  15. package/dist/contracts/materialization/index.d.mts +2 -2
  16. package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
  17. package/dist/contracts/reaction/index.d.mts +1 -1
  18. package/dist/contracts/session/index.d.mts +2 -2
  19. package/dist/contracts/worker/index.d.mts +1 -1
  20. package/dist/contracts/workflow/index.d.mts +2 -2
  21. package/dist/{contribution-CCVRsaNB.d.mts → contribution-CsDOPiDo.d.mts} +1 -1
  22. package/dist/{extension-context-BWrjVPXR.d.mts → extension-context-BY9o1ITm.d.mts} +3 -3
  23. package/dist/fast-connection-FG3yAA7o.mjs +1 -0
  24. package/dist/{hook-responses-v6EA_7WC.d.mts → hook-responses-Xxq6QAL2.d.mts} +1 -1
  25. package/dist/inbound-hooks/fast-connection.d.mts +1 -1
  26. package/dist/inbound-hooks/fast-connection.mjs +1 -1
  27. package/dist/inbound-hooks/index.mjs +1 -1
  28. package/dist/{index-vARKBSt9.d.mts → index-BrnOW7-5.d.mts} +17 -17
  29. package/dist/{index-DneUbrTU.d.mts → index-C9X6ei7S.d.mts} +4 -4
  30. package/dist/{index-CMmUS-p2.d.mts → index-CDezXPm9.d.mts} +247 -247
  31. package/dist/{index-DulipRwg.d.mts → index-CnVhfLrY.d.mts} +53 -53
  32. package/dist/{index-CBzHX2vt.d.mts → index-D9Ome4qp.d.mts} +1 -1
  33. package/dist/{index-Cxx1aoPR.d.mts → index-DMFFSC7x.d.mts} +1 -1
  34. package/dist/{index-Bt6KIvVk.d.mts → index-DWWP2cUb.d.mts} +1 -1
  35. package/dist/{index-v1-To1jx.d.mts → index-D_Zdnh0U.d.mts} +8 -8
  36. package/dist/{index-Dj60LBqi2.d.mts → index-Dnc0PaTv2.d.mts} +12 -12
  37. package/dist/{index-HsD17NLG.d.mts → index-Fmdwbgei.d.mts} +1 -1
  38. package/dist/{index-BPoX2Q9Z.d.mts → index-Fo4ALycy.d.mts} +47 -47
  39. package/dist/{index-DeSmhDs9.d.mts → index-OA1A-NWE.d.mts} +1 -1
  40. package/dist/{index-CFet5T7v2.d.mts → index-PymaxRkQ2.d.mts} +6 -6
  41. package/dist/{index-21Tx9_N1.d.mts → index-VG-C-ZHN.d.mts} +16 -16
  42. package/dist/{index-Bxm5RUGG2.d.mts → index-chwNKVMu2.d.mts} +33 -33
  43. package/dist/kernel/extension/index.d.mts +2 -2
  44. package/dist/kernel/index.d.mts +2 -2
  45. package/dist/kernel/observability/index.d.mts +1 -1
  46. package/dist/{namespace-ChJ-C9m_.d.mts → namespace-BH9U2C1O.d.mts} +2 -2
  47. package/dist/{namespace-u4eoUCLp.d.mts → namespace-DZooy1DW.d.mts} +18 -18
  48. package/dist/node/transports/index.mjs +2 -2
  49. package/dist/package.json +1 -1
  50. package/dist/{schemas-DrrpHMbF2.d.mts → schemas-BYEgjPst2.d.mts} +7 -7
  51. package/dist/{schemas-DKaUrczB.d.mts → schemas-CEc_v3dl.d.mts} +2 -2
  52. package/dist/{schemas-BQhtYuCM.d.mts → schemas-CiJpGURT.d.mts} +10 -10
  53. package/dist/{schemas-BKE3qw_w.d.mts → schemas-DyTbvDp-.d.mts} +1 -1
  54. package/dist/{schemas-BBMHnFq8.d.mts → schemas-JPaSXxNr.d.mts} +4 -4
  55. package/dist/services/context-rules/index.d.mts +3 -3
  56. package/dist/services/execution-target/index.d.mts +2 -2
  57. package/dist/services/execution-target/namespace.d.mts +1 -1
  58. package/dist/services/execution-target/schemas.d.mts +1 -1
  59. package/dist/services/filesystem/namespace.d.mts +12 -12
  60. package/dist/services/filesystem/schemas.d.mts +6 -6
  61. package/dist/services/git/namespace.d.mts +2 -2
  62. package/dist/services/git/schemas.d.mts +2 -2
  63. package/dist/services/index.d.mts +24 -24
  64. package/dist/services/preferences/index.d.mts +2 -2
  65. package/dist/services/preferences/schemas.d.mts +1 -1
  66. package/dist/services/preferences/storage-namespace.d.mts +2 -2
  67. package/dist/services/session/handlers/index.d.mts +1 -1
  68. package/dist/services/session/index.d.mts +3 -3
  69. package/dist/services/session/session-events/namespace.d.mts +1 -1
  70. package/dist/services/settings/namespace.d.mts +10 -10
  71. package/dist/services/subagent-template/index.d.mts +1 -1
  72. package/dist/services/subagent-template/schemas.d.mts +1 -1
  73. package/dist/{session-lineage-Bjh0Ccu7.d.mts → session-lineage-DZr5w2-z.d.mts} +1 -1
  74. package/dist/{storage-namespace-DoxNJ9Cg.d.mts → storage-namespace-Cl8qtHDu.d.mts} +10 -10
  75. package/dist/{transition-DNNBGMtx.d.mts → transition-CzxHvafT.d.mts} +1 -1
  76. package/dist/{types-DsZBnL7z.d.mts → types-CRKyrt5_.d.mts} +12 -12
  77. package/dist/ui-kernel/index.d.mts +4 -4
  78. package/dist/ui-kernel/pages/namespace.d.mts +4 -4
  79. package/dist/ui-kernel/pages/schemas.d.mts +1 -1
  80. package/dist/{view-builder-HU_v1Jg7.d.mts → view-builder-BLdSezFD.d.mts} +1 -1
  81. package/dist/workflow-engine/index.d.mts +24 -24
  82. package/package.json +1 -1
  83. package/dist/bus--m38BS3i.mjs +0 -9
  84. package/dist/fast-connection-CIZ6nL7o.mjs +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 1,
3
- "fingerprint": "33be7ac8fee47f44069567e22d11f2d8e86d6f1959500f8fbcf790f48afbad00",
4
- "builtAt": "2026-09-30T12:44:28.589Z",
3
+ "fingerprint": "021ddb175906c2e6e239354b7bff4312f80ed1aa1c483fedb35b10f95628a3ae",
4
+ "builtAt": "2026-09-30T15:46:24.549Z",
5
5
  "declarations": true,
6
6
  "declarationBackend": "tsc"
7
7
  }
@@ -1413,8 +1413,8 @@ declare const SDKMessageSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodD
1413
1413
  web_search_requests: z.ZodNumber;
1414
1414
  }, z.core.$strip>>>;
1415
1415
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
1416
- batch: "batch";
1417
1416
  priority: "priority";
1417
+ batch: "batch";
1418
1418
  standard: "standard";
1419
1419
  }>>>;
1420
1420
  }, z.core.$strip>;
@@ -2021,8 +2021,8 @@ declare const SDKMessageSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodD
2021
2021
  web_search_requests: z.ZodNumber;
2022
2022
  }, z.core.$strip>>;
2023
2023
  service_tier: z.ZodEnum<{
2024
- batch: "batch";
2025
2024
  priority: "priority";
2025
+ batch: "batch";
2026
2026
  standard: "standard";
2027
2027
  }>;
2028
2028
  }, z.core.$strip>;
@@ -2069,8 +2069,8 @@ declare const SDKMessageSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodD
2069
2069
  web_search_requests: z.ZodNumber;
2070
2070
  }, z.core.$strip>>;
2071
2071
  service_tier: z.ZodEnum<{
2072
- batch: "batch";
2073
2072
  priority: "priority";
2073
+ batch: "batch";
2074
2074
  standard: "standard";
2075
2075
  }>;
2076
2076
  }, z.core.$strip>;
@@ -2135,8 +2135,8 @@ declare const SDKMessageSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodD
2135
2135
  web_search_requests: z.ZodNumber;
2136
2136
  }, z.core.$strip>>>;
2137
2137
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2138
- batch: "batch";
2139
2138
  priority: "priority";
2139
+ batch: "batch";
2140
2140
  standard: "standard";
2141
2141
  }>>>;
2142
2142
  }, z.core.$strip>;
@@ -2742,8 +2742,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
2742
2742
  web_search_requests: z.ZodNumber;
2743
2743
  }, z.core.$strip>>>;
2744
2744
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2745
- batch: "batch";
2746
2745
  priority: "priority";
2746
+ batch: "batch";
2747
2747
  standard: "standard";
2748
2748
  }>>>;
2749
2749
  }, z.core.$strip>;
@@ -3350,8 +3350,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
3350
3350
  web_search_requests: z.ZodNumber;
3351
3351
  }, z.core.$strip>>;
3352
3352
  service_tier: z.ZodEnum<{
3353
- batch: "batch";
3354
3353
  priority: "priority";
3354
+ batch: "batch";
3355
3355
  standard: "standard";
3356
3356
  }>;
3357
3357
  }, z.core.$strip>;
@@ -3398,8 +3398,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
3398
3398
  web_search_requests: z.ZodNumber;
3399
3399
  }, z.core.$strip>>;
3400
3400
  service_tier: z.ZodEnum<{
3401
- batch: "batch";
3402
3401
  priority: "priority";
3402
+ batch: "batch";
3403
3403
  standard: "standard";
3404
3404
  }>;
3405
3405
  }, z.core.$strip>;
@@ -3464,8 +3464,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
3464
3464
  web_search_requests: z.ZodNumber;
3465
3465
  }, z.core.$strip>>>;
3466
3466
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
3467
- batch: "batch";
3468
3467
  priority: "priority";
3468
+ batch: "batch";
3469
3469
  standard: "standard";
3470
3470
  }>>>;
3471
3471
  }, z.core.$strip>;
@@ -4033,8 +4033,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
4033
4033
  web_search_requests: z.ZodNumber;
4034
4034
  }, z.core.$strip>>>;
4035
4035
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
4036
- batch: "batch";
4037
4036
  priority: "priority";
4037
+ batch: "batch";
4038
4038
  standard: "standard";
4039
4039
  }>>>;
4040
4040
  }, z.core.$strip>;
@@ -4643,8 +4643,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
4643
4643
  web_search_requests: z.ZodNumber;
4644
4644
  }, z.core.$strip>>;
4645
4645
  service_tier: z.ZodEnum<{
4646
- batch: "batch";
4647
4646
  priority: "priority";
4647
+ batch: "batch";
4648
4648
  standard: "standard";
4649
4649
  }>;
4650
4650
  }, z.core.$strip>;
@@ -4691,8 +4691,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
4691
4691
  web_search_requests: z.ZodNumber;
4692
4692
  }, z.core.$strip>>;
4693
4693
  service_tier: z.ZodEnum<{
4694
- batch: "batch";
4695
4694
  priority: "priority";
4695
+ batch: "batch";
4696
4696
  standard: "standard";
4697
4697
  }>;
4698
4698
  }, z.core.$strip>;
@@ -4758,8 +4758,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
4758
4758
  web_search_requests: z.ZodNumber;
4759
4759
  }, z.core.$strip>>>;
4760
4760
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
4761
- batch: "batch";
4762
4761
  priority: "priority";
4762
+ batch: "batch";
4763
4763
  standard: "standard";
4764
4764
  }>>>;
4765
4765
  }, z.core.$strip>;
@@ -5369,8 +5369,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
5369
5369
  web_search_requests: z.ZodNumber;
5370
5370
  }, z.core.$strip>>>;
5371
5371
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
5372
- batch: "batch";
5373
5372
  priority: "priority";
5373
+ batch: "batch";
5374
5374
  standard: "standard";
5375
5375
  }>>>;
5376
5376
  }, z.core.$strip>;
@@ -5977,8 +5977,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
5977
5977
  web_search_requests: z.ZodNumber;
5978
5978
  }, z.core.$strip>>;
5979
5979
  service_tier: z.ZodEnum<{
5980
- batch: "batch";
5981
5980
  priority: "priority";
5981
+ batch: "batch";
5982
5982
  standard: "standard";
5983
5983
  }>;
5984
5984
  }, z.core.$strip>;
@@ -6025,8 +6025,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
6025
6025
  web_search_requests: z.ZodNumber;
6026
6026
  }, z.core.$strip>>;
6027
6027
  service_tier: z.ZodEnum<{
6028
- batch: "batch";
6029
6028
  priority: "priority";
6029
+ batch: "batch";
6030
6030
  standard: "standard";
6031
6031
  }>;
6032
6032
  }, z.core.$strip>;
@@ -6091,8 +6091,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
6091
6091
  web_search_requests: z.ZodNumber;
6092
6092
  }, z.core.$strip>>>;
6093
6093
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
6094
- batch: "batch";
6095
6094
  priority: "priority";
6095
+ batch: "batch";
6096
6096
  standard: "standard";
6097
6097
  }>>>;
6098
6098
  }, z.core.$strip>;
@@ -6660,8 +6660,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
6660
6660
  web_search_requests: z.ZodNumber;
6661
6661
  }, z.core.$strip>>>;
6662
6662
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
6663
- batch: "batch";
6664
6663
  priority: "priority";
6664
+ batch: "batch";
6665
6665
  standard: "standard";
6666
6666
  }>>>;
6667
6667
  }, z.core.$strip>;
@@ -7270,8 +7270,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
7270
7270
  web_search_requests: z.ZodNumber;
7271
7271
  }, z.core.$strip>>;
7272
7272
  service_tier: z.ZodEnum<{
7273
- batch: "batch";
7274
7273
  priority: "priority";
7274
+ batch: "batch";
7275
7275
  standard: "standard";
7276
7276
  }>;
7277
7277
  }, z.core.$strip>;
@@ -7318,8 +7318,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
7318
7318
  web_search_requests: z.ZodNumber;
7319
7319
  }, z.core.$strip>>;
7320
7320
  service_tier: z.ZodEnum<{
7321
- batch: "batch";
7322
7321
  priority: "priority";
7322
+ batch: "batch";
7323
7323
  standard: "standard";
7324
7324
  }>;
7325
7325
  }, z.core.$strip>;
@@ -7385,8 +7385,8 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
7385
7385
  web_search_requests: z.ZodNumber;
7386
7386
  }, z.core.$strip>>>;
7387
7387
  service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
7388
- batch: "batch";
7389
7388
  priority: "priority";
7389
+ batch: "batch";
7390
7390
  standard: "standard";
7391
7391
  }>>>;
7392
7392
  }, z.core.$strip>;
@@ -2364,17 +2364,17 @@ interface MakaioBusContext {
2364
2364
  priority: number;
2365
2365
  }>>;
2366
2366
  /**
2367
- * Set of transport names that have subscribed to each subject with event-only handlers
2368
- * (i.e. subscribe messages whose priority array was empty).
2369
- *
2370
- * Tracked separately from `remoteRequestHandlers` because event-only subscriptions
2371
- * produce no priority entries yet must still influence advertised-state decisions:
2372
- * if a remote has event-only handlers for a subject, peers should still receive a
2373
- * `subscribe` (with an empty priority array) rather than an `unsubscribe`.
2367
+ * Set of transport names that subscribed to each subject with event-only handlers
2368
+ * (subscribe messages whose priority array was empty). Tracked separately from `remoteRequestHandlers`
2369
+ * because event-only subscriptions produce no priority entries yet must still influence advertised-state
2370
+ * decisions: if a remote has event-only handlers for a subject, peers should still receive a `subscribe`
2371
+ * (with an empty priority array) rather than an `unsubscribe`.
2374
2372
  */
2375
2373
  remoteEventHandlers: Map<string, Set<string>>;
2376
2374
  /** Owner-derived delivery semantics keyed by subject pattern and source transport. */
2377
2375
  remoteSubscriptionDeliveryClasses: Map<string, Map<string, SubscriptionDeliveryClass>>;
2376
+ /** Failure-safe sink for internal bus diagnostics; resolved once from `CreateBusOptions.debugLog`. */
2377
+ debugLog: (message: string) => void;
2378
2378
  }
2379
2379
  /**
2380
2380
  * Result of registering a transport on the bus.
@@ -3323,6 +3323,24 @@ declare function matchesSubscription(subject: string, pattern: string): boolean;
3323
3323
  */
3324
3324
  declare function matchesAnySubscription(subject: string, patterns: Iterable<string>): boolean;
3325
3325
  //#endregion
3326
+ //#region core/bus-core/src/utils/debug-log.d.ts
3327
+ /**
3328
+ * Sink for internal bus diagnostics (one formatted line per call).
3329
+ */
3330
+ type BusDebugLog = (message: string) => void;
3331
+ /**
3332
+ * Wrap a diagnostic sink so it can never change caller state.
3333
+ *
3334
+ * A diagnostic sink is observational only: a synchronous throw or a rejected
3335
+ * thenable returned by the callback (assignable to the `void`-returning type) is
3336
+ * swallowed instead of failing propagation, sync, or dispatch. The failure is
3337
+ * dropped deliberately: there is no safe channel to report it on (stdout may be a
3338
+ * protocol channel, and reporting through the same sink would recurse).
3339
+ * @param sink - Sink to wrap
3340
+ * @returns Sink that never throws and never leaves an unhandled rejection
3341
+ */
3342
+ declare function toSafeDebugLog(sink: BusDebugLog): BusDebugLog;
3343
+ //#endregion
3326
3344
  //#region core/bus-core/src/errors/bus-error.d.ts
3327
3345
  /**
3328
3346
  * Base error class for all bus-related errors.
@@ -3496,9 +3514,10 @@ declare class ValidationError extends BusError {
3496
3514
  * Used internally by createBusInstance to manage event and request handlers.
3497
3515
  * Can be used to create isolated bus instances (e.g., for testing) by providing
3498
3516
  * separate handler maps per instance.
3517
+ * @param debugLog - Optional diagnostic sink; defaults to `console.debug`. Wrapped so it never throws.
3499
3518
  * @returns A new MakaioBusContext instance with empty handler registries
3500
3519
  */
3501
- declare const createBusContext: () => MakaioBusContext;
3520
+ declare const createBusContext: (debugLog?: (message: string) => void) => MakaioBusContext;
3502
3521
  /**
3503
3522
  * Options for creating a bus instance.
3504
3523
  */
@@ -3509,6 +3528,17 @@ interface CreateBusOptions<Namespace extends string | undefined = undefined> {
3509
3528
  namespace?: Namespace;
3510
3529
  /** Transports to register immediately after creation. */
3511
3530
  transports?: BusTransport[];
3531
+ /**
3532
+ * Sink for internal bus diagnostics (subscription propagation and
3533
+ * subscribe-sync-complete failures, readiness-budget expiry). One formatted line
3534
+ * per call. Defaults to `console.debug`, so browser visibility is unchanged; a
3535
+ * Node CLI can pass a stderr writer. A throwing or rejecting sink never changes bus
3536
+ * state. With an explicit `context`, this replaces that context's sink.
3537
+ *
3538
+ * Named `debugLog` to match the transports' `debugLog` option (same
3539
+ * `(message: string) => void` shape).
3540
+ */
3541
+ debugLog?: (message: string) => void;
3512
3542
  }
3513
3543
  /**
3514
3544
  * Creates a new bus instance with optional context, namespace isolation, and transports.
@@ -4355,4 +4385,4 @@ interface ProjectedTelemetryTransportOptions {
4355
4385
  */
4356
4386
  declare function createProjectedTelemetryTransport(options: ProjectedTelemetryTransportOptions): BusTransport;
4357
4387
  //#endregion
4358
- export { type BroadcastContext, type BroadcastResult, BusAbortError, type BusBroadcastMessage, type BusBroadcastResponseMessage, BusError, type BusEventMessage, type BusHeartbeatMessage, BusLifecycle, type BusMessage, type BusMessageObserver, type BusNamespace, type BusReceiveHandler, type BusRequestMessage, type BusResponseMessage, type BusSubscribeMessage, type BusSubscribeSyncCompleteMessage, type BusSubscriptionAckMessage, type BusTransport, type BusTransportError, type BusTransportKeys, type BusTransportRegistry, type BusUnsubscribeMessage, type BusUrlConfig, type BusValidationMode, CONNECTION_LOST_ERROR_CODE, ChannelAuthError, ChannelClosedError, type ChannelEndpoint, type ChannelEndpointOptions, ChannelOnlyError, type ConnectOptions, type ConnectedPayload, ConnectionLostError, CorrelationTracker, DEFAULT_READINESS_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type DefinedSubjectExtension, type DisconnectedPayload, type EmitOptions, type EventSubjectExtension, type ExtendedSubjectDefinition, type ExtensionNamespace, type ExtensionNamespaceConfig, type ExtensionNamespaceExtensions, type ExtensionNamespaceFromConfig, type IDirectChannel, type IFilteredBus, type IMakaioBus, type InterceptorContext, LOCAL_ORIGIN, LocalSubjectError, MakaioBus, type MakaioBusContext, NO_HANDLER_ERROR_CODE, type NamespaceRegistrationOptions, NoHandlerError, type ObservedBusMessage, type OnOptions, OnceAbortError, type OptionalResult, type PendingReadyEntry, type ProjectableBusMessage, type ProjectedTelemetryTransportOptions, REMOTE_ORIGIN, RequestError, type RequestOptions, type RequestSubjectExtension, type SchemaViolationCallback, type SchemaViolationReport, type ScopedBus, type ScopedBusFor, type SubjectExtension, type SubjectTelemetryAttributes, type SubjectTelemetryProjectionInput, type SubjectTelemetryProjector, type SubjectTelemetryProjectorInput, type SubjectTelemetryProjectorRegistry, type SubscriptionDeliveryClass, type SubscriptionEntry, SystemChannelSchemas, TimeoutError, type TransportRegistration, ValidationError, __resetWarnedSubjects, buildSubscribeMessage, buildUnsubscribeMessage, channelSubject, collectorOnlySubject, createBusContext, createBusInstance, createChannelEndpoint, createExtensionNamespace, createFilteredBus, createProjectedTelemetryTransport, createSubjectTelemetryProjectorRegistry, defaultTransports, defineSubjectExtension, deserializeTransportError, extendSubjectImpl as extendSubject, findInErrorChain, getFullSubjectForSubjectDefinition, getPath, getSubjectFromBusMessage, handleCorrelationResponse, hostLocalRequest, isNoHandlerErrorForSubject, isRequestCancellation, isRequestSchema, localSubject, matchesAnySubscription, matchesFilter, matchesSubscription, mergeFilters, openChannel, parseBusUrl, projectSubjectTelemetryFacts, serializeTransportError, shouldReceiveMessage, trackMessageCorrelation, transportErrorData, waitForSubscriptionPropagation };
4388
+ export { type BroadcastContext, type BroadcastResult, BusAbortError, type BusBroadcastMessage, type BusBroadcastResponseMessage, type BusDebugLog, BusError, type BusEventMessage, type BusHeartbeatMessage, BusLifecycle, type BusMessage, type BusMessageObserver, type BusNamespace, type BusReceiveHandler, type BusRequestMessage, type BusResponseMessage, type BusSubscribeMessage, type BusSubscribeSyncCompleteMessage, type BusSubscriptionAckMessage, type BusTransport, type BusTransportError, type BusTransportKeys, type BusTransportRegistry, type BusUnsubscribeMessage, type BusUrlConfig, type BusValidationMode, CONNECTION_LOST_ERROR_CODE, ChannelAuthError, ChannelClosedError, type ChannelEndpoint, type ChannelEndpointOptions, ChannelOnlyError, type ConnectOptions, type ConnectedPayload, ConnectionLostError, CorrelationTracker, DEFAULT_READINESS_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type DefinedSubjectExtension, type DisconnectedPayload, type EmitOptions, type EventSubjectExtension, type ExtendedSubjectDefinition, type ExtensionNamespace, type ExtensionNamespaceConfig, type ExtensionNamespaceExtensions, type ExtensionNamespaceFromConfig, type IDirectChannel, type IFilteredBus, type IMakaioBus, type InterceptorContext, LOCAL_ORIGIN, LocalSubjectError, MakaioBus, type MakaioBusContext, NO_HANDLER_ERROR_CODE, type NamespaceRegistrationOptions, NoHandlerError, type ObservedBusMessage, type OnOptions, OnceAbortError, type OptionalResult, type PendingReadyEntry, type ProjectableBusMessage, type ProjectedTelemetryTransportOptions, REMOTE_ORIGIN, RequestError, type RequestOptions, type RequestSubjectExtension, type SchemaViolationCallback, type SchemaViolationReport, type ScopedBus, type ScopedBusFor, type SubjectExtension, type SubjectTelemetryAttributes, type SubjectTelemetryProjectionInput, type SubjectTelemetryProjector, type SubjectTelemetryProjectorInput, type SubjectTelemetryProjectorRegistry, type SubscriptionDeliveryClass, type SubscriptionEntry, SystemChannelSchemas, TimeoutError, type TransportRegistration, ValidationError, __resetWarnedSubjects, buildSubscribeMessage, buildUnsubscribeMessage, channelSubject, collectorOnlySubject, createBusContext, createBusInstance, createChannelEndpoint, createExtensionNamespace, createFilteredBus, createProjectedTelemetryTransport, createSubjectTelemetryProjectorRegistry, defaultTransports, defineSubjectExtension, deserializeTransportError, extendSubjectImpl as extendSubject, findInErrorChain, getFullSubjectForSubjectDefinition, getPath, getSubjectFromBusMessage, handleCorrelationResponse, hostLocalRequest, isNoHandlerErrorForSubject, isRequestCancellation, isRequestSchema, localSubject, matchesAnySubscription, matchesFilter, matchesSubscription, mergeFilters, openChannel, parseBusUrl, projectSubjectTelemetryFacts, serializeTransportError, shouldReceiveMessage, toSafeDebugLog, trackMessageCorrelation, transportErrorData, waitForSubscriptionPropagation };
@@ -1 +1 @@
1
- import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as ee,M as te,N as f,O as ne,P as re,Q as p,R as m,S as h,T as ie,U as ae,V as g,W as oe,X as se,Y as ce,Z as le,_ as ue,a as de,at as fe,b as pe,d as _,et as me,f as he,g as v,h as y,i as ge,it as b,j as x,k as S,l as C,m as w,nt as T,o as E,p as D,q as O,r as k,rt as A,s as j,t as M,tt as N,u as P,v as F,w as I,x as L,y as _e,z as ve}from"../bus--m38BS3i.mjs";import{z as R}from"zod";const z={"channel.open":{request:R.object({endpoint:R.string(),token:R.string(),clientPubKey:R.string(),transports:R.array(R.string())}),response:R.object({channelId:R.string(),endpointPubKey:R.string()})}};function B(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Array(t.length);for(let e=0;e<t.length;e++)n[e]=String.fromCharCode(t[e]);return btoa(n.join(``))}function V(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}async function H(){return globalThis.crypto.subtle.generateKey({name:`ECDH`,namedCurve:`P-256`},!1,[`deriveKey`])}async function U(e){return B(await globalThis.crypto.subtle.exportKey(`raw`,e))}async function W(e){let t=V(e);return globalThis.crypto.subtle.importKey(`raw`,t,{name:`ECDH`,namedCurve:`P-256`},!1,[])}async function G(e,t){return globalThis.crypto.subtle.deriveKey({name:`ECDH`,public:t},e,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function K(e,t,n){let r=globalThis.crypto.getRandomValues(new Uint8Array(12)),i=new TextEncoder().encode(t),a={name:`AES-GCM`,iv:r};n!==void 0&&(a.additionalData=new TextEncoder().encode(n));let o=await globalThis.crypto.subtle.encrypt(a,e,i);return{iv:B(r),data:B(o)}}async function q(e,t,n){let r=V(t.iv),i=V(t.data),a={name:`AES-GCM`,iv:r};n!==void 0&&(a.additionalData=new TextEncoder().encode(n));let o=await globalThis.crypto.subtle.decrypt(a,e,i);return new TextDecoder().decode(o)}function J(e,t){return{subject:t,$meta:{namespace:`channel:${e}`,isRequest:!1,payload:{},local:!1,channel:!1}}}function Y(e,t){return{subject:t,$meta:{namespace:`channel:${e}`,isRequest:!0,payload:{},local:!1,channel:!1}}}var X=class{channelId;sharedKey;context;transportNames;cleanups=[];pendingRequests=new Set;closed=!1;constructor(e,t,n,r){this.channelId=e,this.sharedKey=t,this.context=n,this.transportNames=r;let i=J(e,`$close`);this.cleanups.push(this.registerEventHandler(i,t,e=>{this.handlePeerClose()}))}on(e,t,n){this.assertOpen();let r=this.requireKey(),i=e.$meta.isRequest?this.registerRequestHandler(e,r,t,n):this.registerEventHandler(e,r,t,n);return this.cleanups.push(i),()=>{i();let e=this.cleanups.indexOf(i);e!==-1&&this.cleanups.splice(e,1)}}once(e,t){this.assertOpen();let n=this.requireKey(),r=null,i=(e=>{let n=r;if(r=null,n){let e=this.cleanups.indexOf(n);e!==-1&&this.cleanups.splice(e,1)}return n?.(),t(e)});return r=e.$meta.isRequest?this.registerRequestHandler(e,n,i):this.registerEventHandler(e,n,i),this.cleanups.push(r),()=>{if(r){let e=r;r=null;let t=this.cleanups.indexOf(e);t!==-1&&this.cleanups.splice(t,1),e()}}}async emit(e,t){this.assertOpen();let n=this.requireKey(),r=J(this.channelId,e.subject),i=await K(n,JSON.stringify(t),`${this.channelId}:${e.subject}:evt`);await w(this.context,r,i,{...this.transportNames?{transports:[...this.transportNames]}:{}})}async request(e,t,n){this.assertOpen();let r=this.requireKey(),i=new AbortController;this.pendingRequests.add(i);try{let a=Y(this.channelId,e.subject),o=await K(r,JSON.stringify(t),`${this.channelId}:${e.subject}:req`),s=await q(r,await _(this.context,a,o,{signal:i.signal,...n?.timeout===void 0?{}:{timeout:n.timeout},...this.transportNames?{transports:[...this.transportNames]}:{}}),`${this.channelId}:${e.subject}:res`);return JSON.parse(s)}finally{this.pendingRequests.delete(i)}}async requestOptional(e,t,n){try{return{handled:!0,data:await this.request(e,t,n)}}catch(e){if(e instanceof l)return{handled:!1};throw e}}close(){if(this.closed)return;this.closed=!0;let e=this.sharedKey;if(e){let t=J(this.channelId,`$close`);K(e,JSON.stringify({}),`${this.channelId}:$close:evt`).then(e=>w(this.context,t,e,{...this.transportNames?{transports:[...this.transportNames]}:{}})).catch(()=>{})}this.abortPendingRequests(),this.runCleanups(),this.sharedKey=null}assertOpen(){if(this.closed)throw new g(this.channelId)}requireKey(){return this.sharedKey}registerEventHandler(e,t,n,r){let i=J(this.channelId,e.subject),a=`${this.channelId}:${e.subject}:evt`;return v(this.context,i,async e=>{let r=await q(t,e.payload,a),i=JSON.parse(r);return n({...e,payload:i})},r)}registerRequestHandler(e,t,n,r){let i=Y(this.channelId,e.subject),a=`${this.channelId}:${e.subject}:req`,o=`${this.channelId}:${e.subject}:res`;return v(this.context,i,async e=>{let r=await q(t,e.payload,a),i=JSON.parse(r),s,c=e=>{s={value:e}},l=e=>{s={value:{...s?.value??{},...e}}},u=async()=>{let n=s;if(await e.next(),n!==void 0){s=n;return}let r=e.result;if(r!==void 0){let e=await q(t,r,o);s={value:JSON.parse(e)}}};if(await n({...e,payload:i,get result(){return s?.value},setResult:c,extendResult:l,next:u}),s!==void 0){let n=await K(t,JSON.stringify(s.value),o);e.setResult(n)}},r)}handlePeerClose(){this.closed||(this.closed=!0,this.abortPendingRequests(),this.runCleanups(),this.sharedKey=null)}abortPendingRequests(){let e=new g(this.channelId);for(let t of this.pendingRequests)t.abort(e);this.pendingRequests.clear()}runCleanups(){for(let e of this.cleanups)try{e()}catch{}this.cleanups.length=0}};function Z(e){return e.namespaceRegistry.registerNamespace(p(`system`,z)).subjects.channel.open}function ye(e,t,n,r){let i=v(e,Z(e),async i=>{if(i.payload.endpoint!==t){await i.next();return}if(i.payload.token!==r.token)throw new c(t);let{publicKey:a,privateKey:o}=await H(),s=await G(o,await W(i.payload.clientPubKey)),l=globalThis.crypto.randomUUID(),u=new Set(e.transportRegistry.names()),d=new X(l,s,e,(i.payload.transports??[]).filter(e=>u.has(e)));try{n(d),i.setResult({channelId:l,endpointPubKey:await U(a)})}catch(e){throw d.close(),e}});return{name:t,token:r.token,close:i}}async function be(e,t,n){let r=Z(e),{publicKey:i,privateKey:a}=await H(),o=await U(i),s=n.transports!==void 0,c=s?[...n.transports]:[...e.transportRegistry.names()],l=s?{transports:c}:void 0,u=await _(e,r,{endpoint:t,token:n.token,clientPubKey:o,transports:c},l),d=await G(a,await W(u.endpointPubKey));return new X(u.channelId,d,e,c)}var xe=class{pending;constructor(){this.pending=new Map}track(e,t,n){return new Promise((r,i)=>{if(n?.aborted){i(s(n.reason));return}let a=t===0?void 0:setTimeout(()=>{let n=this.pending.get(e);n!==void 0&&(clearTimeout(n.timeoutId),n.removeAbortListener?.(),this.pending.delete(e),n.reject(new f(e,t)))},t);if(this.pending.set(e,{resolve:r,reject:i,timeoutId:a,removeAbortListener:void 0}),n){let t=()=>{this.reject(e,s(n.reason))};n.addEventListener(`abort`,t,{once:!0});let r=()=>{n.removeEventListener(`abort`,t)},i=this.pending.get(e);i&&(i.removeAbortListener=r)}n?.aborted&&this.reject(e,s(n.reason))})}resolve(e,t){let n=this.pending.get(e);n&&(clearTimeout(n.timeoutId),n.removeAbortListener?.(),this.pending.delete(e),n.resolve(t))}reject(e,t){let n=this.pending.get(e);n&&(clearTimeout(n.timeoutId),n.removeAbortListener?.(),this.pending.delete(e),n.reject(t))}cancel(e,t){this.reject(e,t??s(void 0))}rejectAll(e){for(let[t,n]of this.pending.entries())clearTimeout(n.timeoutId),n.removeAbortListener?.(),n.reject(e);this.pending.clear()}cleanup(){this.rejectAll(Error(`Transport disconnected`))}};const Se=p(`bus:lifecycle`,de).subjects;function Ce(e,t){let n={},r={},i={};for(let[t,a]of e)n[t]=a.priorities,r[t]=a.deliveryClass??`relayable`,a.filter!==void 0&&(i[t]=a.filter);return{type:`subscribe`,...t===void 0?{}:{ackId:t},subjects:n,deliveryClasses:r,...Object.keys(i).length>0&&{filters:i}}}function we(e,t){return{type:`unsubscribe`,...t===void 0?{}:{ackId:t},subjects:e}}function Q(e,t){let n=e.trim();if(n.length===0||n.startsWith(`extension:`))throw Error(`Invalid extensionName: expected a non-empty extension name without the "extension:" prefix.`);let r=n;return{...p(`extension:${r}`,t.schemas),domain:r,extensions:t.extensions??{}}}function $(e,t){return`${e}.${t}`}function Te(){let e=new Map;return{register(t){let n=$(t.namespace,t.subject);return e.set(n,t),()=>{e.get(n)===t&&e.delete(n)}},get(t,n){return e.get($(t,n))}}}const Ee=x.fact.$meta.namespace,De=x.fact.subject;function Oe(e){return e.type===`event`||e.type===`request`||e.type===`broadcast`}async function ke(e,t,n,r,i,a){let o=y({message:t,direction:`outbound`,observedAt:a(),machineId:i,namespaceRegistry:n,projectorRegistry:r});for(let n of o)await e.send({type:`event`,namespace:Ee,subject:De,payload:n,messageId:`${t.messageId}:telemetry:${n.factId}`,correlationId:t.correlationId})}function Ae(e,t,n,r,i){return async function(a,o){if(!Oe(a))return!0;if(await ke(e,a,t,n,r,i),a.type===`request`)throw Error(`Projected telemetry transport cannot satisfy request responses; exclude it from request routing.`);return a.type===`broadcast`?[]:!0}}function je(e){let{inner:t,namespaceRegistry:n,projectorRegistry:r,machineId:i,now:a=Date.now}=e,o={name:e.name,send:Ae(t,n,r,i,a),onReceive(e){return t.onReceive(async()=>{})},connect(){return t.connect()},disconnect(){return t.disconnect()},subscribe(){return Promise.resolve()},unsubscribe(){return Promise.resolve()},get ready(){return t.ready},get onNewReadySession(){return t.onNewReadySession},set onNewReadySession(e){t.onNewReadySession=e},get onConnected(){return t.onConnected},set onConnected(e){t.onConnected=e},get onDisconnected(){return t.onDisconnected},set onDisconnected(e){t.onDisconnected=e},isReady(){return t.isReady?.()??!0},cancelRequest(e,n){t.cancelRequest?.(e,n)},onBroadcastResults(e,n,r){t.onBroadcastResults?.(e,n,r)}};return t.reconnect&&(o.reconnect=()=>t.reconnect()),o}export{ae as BusAbortError,d as BusError,Se as BusLifecycle,m as CONNECTION_LOST_ERROR_CODE,c as ChannelAuthError,g as ChannelClosedError,n as ChannelOnlyError,ve as ConnectionLostError,xe as CorrelationTracker,he as DEFAULT_READINESS_TIMEOUT_MS,D as DEFAULT_REQUEST_TIMEOUT_MS,pe as LOCAL_ORIGIN,ee as LocalSubjectError,M as MakaioBus,o as NO_HANDLER_ERROR_CODE,l as NoHandlerError,P as OnceAbortError,L as REMOTE_ORIGIN,re as RequestError,z as SystemChannelSchemas,f as TimeoutError,te as ValidationError,F as __resetWarnedSubjects,Ce as buildSubscribeMessage,we as buildUnsubscribeMessage,b as channelSubject,me as collectorOnlySubject,k as createBusContext,ge as createBusInstance,ye as createChannelEndpoint,Q as createExtensionNamespace,C as createFilteredBus,je as createProjectedTelemetryTransport,Te as createSubjectTelemetryProjectorRegistry,N as defaultTransports,E as defineSubjectExtension,a as deserializeTransportError,j as extendSubject,i as findInErrorChain,e as getFullSubjectForSubjectDefinition,O as getPath,ne as getSubjectFromBusMessage,h as handleCorrelationResponse,T as hostLocalRequest,S as isNoHandlerErrorForSubject,oe as isRequestCancellation,fe as isRequestSchema,A as localSubject,se as matchesAnySubscription,u as matchesFilter,le as matchesSubscription,ce as mergeFilters,be as openChannel,_e as parseBusUrl,y as projectSubjectTelemetryFacts,r as serializeTransportError,I as shouldReceiveMessage,ie as trackMessageCorrelation,t as transportErrorData,ue as waitForSubscriptionPropagation};
1
+ import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as ee,O as te,P as m,Q as ne,R as re,S as h,T as ie,U as g,V as ae,W as oe,X as se,Y as ce,Z as le,_ as ue,a as de,at as fe,b as pe,d as _,et as me,f as he,g as v,h as y,i as ge,it as b,j as x,k as S,l as C,m as w,nt as T,o as E,ot as D,p as O,q as k,r as A,rt as j,s as M,t as N,tt as P,u as F,v as I,w as L,x as _e,y as ve,z as ye}from"../bus-B-ksy7YX.mjs";import{z as R}from"zod";const z={"channel.open":{request:R.object({endpoint:R.string(),token:R.string(),clientPubKey:R.string(),transports:R.array(R.string())}),response:R.object({channelId:R.string(),endpointPubKey:R.string()})}};function B(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Array(t.length);for(let e=0;e<t.length;e++)n[e]=String.fromCharCode(t[e]);return btoa(n.join(``))}function V(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}async function H(){return globalThis.crypto.subtle.generateKey({name:`ECDH`,namedCurve:`P-256`},!1,[`deriveKey`])}async function U(e){return B(await globalThis.crypto.subtle.exportKey(`raw`,e))}async function W(e){let t=V(e);return globalThis.crypto.subtle.importKey(`raw`,t,{name:`ECDH`,namedCurve:`P-256`},!1,[])}async function G(e,t){return globalThis.crypto.subtle.deriveKey({name:`ECDH`,public:t},e,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function K(e,t,n){let r=globalThis.crypto.getRandomValues(new Uint8Array(12)),i=new TextEncoder().encode(t),a={name:`AES-GCM`,iv:r};n!==void 0&&(a.additionalData=new TextEncoder().encode(n));let o=await globalThis.crypto.subtle.encrypt(a,e,i);return{iv:B(r),data:B(o)}}async function q(e,t,n){let r=V(t.iv),i=V(t.data),a={name:`AES-GCM`,iv:r};n!==void 0&&(a.additionalData=new TextEncoder().encode(n));let o=await globalThis.crypto.subtle.decrypt(a,e,i);return new TextDecoder().decode(o)}function J(e,t){return{subject:t,$meta:{namespace:`channel:${e}`,isRequest:!1,payload:{},local:!1,channel:!1}}}function Y(e,t){return{subject:t,$meta:{namespace:`channel:${e}`,isRequest:!0,payload:{},local:!1,channel:!1}}}var X=class{channelId;sharedKey;context;transportNames;cleanups=[];pendingRequests=new Set;closed=!1;constructor(e,t,n,r){this.channelId=e,this.sharedKey=t,this.context=n,this.transportNames=r;let i=J(e,`$close`);this.cleanups.push(this.registerEventHandler(i,t,e=>{this.handlePeerClose()}))}on(e,t,n){this.assertOpen();let r=this.requireKey(),i=e.$meta.isRequest?this.registerRequestHandler(e,r,t,n):this.registerEventHandler(e,r,t,n);return this.cleanups.push(i),()=>{i();let e=this.cleanups.indexOf(i);e!==-1&&this.cleanups.splice(e,1)}}once(e,t){this.assertOpen();let n=this.requireKey(),r=null,i=(e=>{let n=r;if(r=null,n){let e=this.cleanups.indexOf(n);e!==-1&&this.cleanups.splice(e,1)}return n?.(),t(e)});return r=e.$meta.isRequest?this.registerRequestHandler(e,n,i):this.registerEventHandler(e,n,i),this.cleanups.push(r),()=>{if(r){let e=r;r=null;let t=this.cleanups.indexOf(e);t!==-1&&this.cleanups.splice(t,1),e()}}}async emit(e,t){this.assertOpen();let n=this.requireKey(),r=J(this.channelId,e.subject),i=await K(n,JSON.stringify(t),`${this.channelId}:${e.subject}:evt`);await w(this.context,r,i,{...this.transportNames?{transports:[...this.transportNames]}:{}})}async request(e,t,n){this.assertOpen();let r=this.requireKey(),i=new AbortController;this.pendingRequests.add(i);try{let a=Y(this.channelId,e.subject),o=await K(r,JSON.stringify(t),`${this.channelId}:${e.subject}:req`),s=await q(r,await _(this.context,a,o,{signal:i.signal,...n?.timeout===void 0?{}:{timeout:n.timeout},...this.transportNames?{transports:[...this.transportNames]}:{}}),`${this.channelId}:${e.subject}:res`);return JSON.parse(s)}finally{this.pendingRequests.delete(i)}}async requestOptional(e,t,n){try{return{handled:!0,data:await this.request(e,t,n)}}catch(e){if(e instanceof f)return{handled:!1};throw e}}close(){if(this.closed)return;this.closed=!0;let e=this.sharedKey;if(e){let t=J(this.channelId,`$close`);K(e,JSON.stringify({}),`${this.channelId}:$close:evt`).then(e=>w(this.context,t,e,{...this.transportNames?{transports:[...this.transportNames]}:{}})).catch(()=>{})}this.abortPendingRequests(),this.runCleanups(),this.sharedKey=null}assertOpen(){if(this.closed)throw new c(this.channelId)}requireKey(){return this.sharedKey}registerEventHandler(e,t,n,r){let i=J(this.channelId,e.subject),a=`${this.channelId}:${e.subject}:evt`;return v(this.context,i,async e=>{let r=await q(t,e.payload,a),i=JSON.parse(r);return n({...e,payload:i})},r)}registerRequestHandler(e,t,n,r){let i=Y(this.channelId,e.subject),a=`${this.channelId}:${e.subject}:req`,o=`${this.channelId}:${e.subject}:res`;return v(this.context,i,async e=>{let r=await q(t,e.payload,a),i=JSON.parse(r),s,c=e=>{s={value:e}},l=e=>{s={value:{...s?.value??{},...e}}},u=async()=>{let n=s;if(await e.next(),n!==void 0){s=n;return}let r=e.result;if(r!==void 0){let e=await q(t,r,o);s={value:JSON.parse(e)}}};if(await n({...e,payload:i,get result(){return s?.value},setResult:c,extendResult:l,next:u}),s!==void 0){let n=await K(t,JSON.stringify(s.value),o);e.setResult(n)}},r)}handlePeerClose(){this.closed||(this.closed=!0,this.abortPendingRequests(),this.runCleanups(),this.sharedKey=null)}abortPendingRequests(){let e=new c(this.channelId);for(let t of this.pendingRequests)t.abort(e);this.pendingRequests.clear()}runCleanups(){for(let e of this.cleanups)try{e()}catch{}this.cleanups.length=0}};function Z(t){return t.namespaceRegistry.registerNamespace(e(`system`,z)).subjects.channel.open}function be(e,t,n,r){let i=v(e,Z(e),async i=>{if(i.payload.endpoint!==t){await i.next();return}if(i.payload.token!==r.token)throw new g(t);let{publicKey:a,privateKey:o}=await H(),s=await G(o,await W(i.payload.clientPubKey)),c=globalThis.crypto.randomUUID(),l=new Set(e.transportRegistry.names()),u=new X(c,s,e,(i.payload.transports??[]).filter(e=>l.has(e)));try{n(u),i.setResult({channelId:c,endpointPubKey:await U(a)})}catch(e){throw u.close(),e}});return{name:t,token:r.token,close:i}}async function xe(e,t,n){let r=Z(e),{publicKey:i,privateKey:a}=await H(),o=await U(i),s=n.transports!==void 0,c=s?[...n.transports]:[...e.transportRegistry.names()],l=s?{transports:c}:void 0,u=await _(e,r,{endpoint:t,token:n.token,clientPubKey:o,transports:c},l),d=await G(a,await W(u.endpointPubKey));return new X(u.channelId,d,e,c)}var Se=class{pending;constructor(){this.pending=new Map}track(e,t,n){return new Promise((r,i)=>{if(n?.aborted){i(d(n.reason));return}let a=t===0?void 0:setTimeout(()=>{let n=this.pending.get(e);n!==void 0&&(clearTimeout(n.timeoutId),n.removeAbortListener?.(),this.pending.delete(e),n.reject(new m(e,t)))},t);if(this.pending.set(e,{resolve:r,reject:i,timeoutId:a,removeAbortListener:void 0}),n){let t=()=>{this.reject(e,d(n.reason))};n.addEventListener(`abort`,t,{once:!0});let r=()=>{n.removeEventListener(`abort`,t)},i=this.pending.get(e);i&&(i.removeAbortListener=r)}n?.aborted&&this.reject(e,d(n.reason))})}resolve(e,t){let n=this.pending.get(e);n&&(clearTimeout(n.timeoutId),n.removeAbortListener?.(),this.pending.delete(e),n.resolve(t))}reject(e,t){let n=this.pending.get(e);n&&(clearTimeout(n.timeoutId),n.removeAbortListener?.(),this.pending.delete(e),n.reject(t))}cancel(e,t){this.reject(e,t??d(void 0))}rejectAll(e){for(let[t,n]of this.pending.entries())clearTimeout(n.timeoutId),n.removeAbortListener?.(),n.reject(e);this.pending.clear()}cleanup(){this.rejectAll(Error(`Transport disconnected`))}};const Ce=e(`bus:lifecycle`,de).subjects;function we(e,t){let n={},r={},i={};for(let[t,a]of e)n[t]=a.priorities,r[t]=a.deliveryClass??`relayable`,a.filter!==void 0&&(i[t]=a.filter);return{type:`subscribe`,...t===void 0?{}:{ackId:t},subjects:n,deliveryClasses:r,...Object.keys(i).length>0&&{filters:i}}}function Q(e,t){return{type:`unsubscribe`,...t===void 0?{}:{ackId:t},subjects:e}}function Te(t,n){let r=t.trim();if(r.length===0||r.startsWith(`extension:`))throw Error(`Invalid extensionName: expected a non-empty extension name without the "extension:" prefix.`);let i=r;return{...e(`extension:${i}`,n.schemas),domain:i,extensions:n.extensions??{}}}function $(e,t){return`${e}.${t}`}function Ee(){let e=new Map;return{register(t){let n=$(t.namespace,t.subject);return e.set(n,t),()=>{e.get(n)===t&&e.delete(n)}},get(t,n){return e.get($(t,n))}}}const De=p.fact.$meta.namespace,Oe=p.fact.subject;function ke(e){return e.type===`event`||e.type===`request`||e.type===`broadcast`}async function Ae(e,t,n,r,i,a){let o=y({message:t,direction:`outbound`,observedAt:a(),machineId:i,namespaceRegistry:n,projectorRegistry:r});for(let n of o)await e.send({type:`event`,namespace:De,subject:Oe,payload:n,messageId:`${t.messageId}:telemetry:${n.factId}`,correlationId:t.correlationId})}function je(e,t,n,r,i){return async function(a,o){if(!ke(a))return!0;if(await Ae(e,a,t,n,r,i),a.type===`request`)throw Error(`Projected telemetry transport cannot satisfy request responses; exclude it from request routing.`);return a.type===`broadcast`?[]:!0}}function Me(e){let{inner:t,namespaceRegistry:n,projectorRegistry:r,machineId:i,now:a=Date.now}=e,o={name:e.name,send:je(t,n,r,i,a),onReceive(e){return t.onReceive(async()=>{})},connect(){return t.connect()},disconnect(){return t.disconnect()},subscribe(){return Promise.resolve()},unsubscribe(){return Promise.resolve()},get ready(){return t.ready},get onNewReadySession(){return t.onNewReadySession},set onNewReadySession(e){t.onNewReadySession=e},get onConnected(){return t.onConnected},set onConnected(e){t.onConnected=e},get onDisconnected(){return t.onDisconnected},set onDisconnected(e){t.onDisconnected=e},isReady(){return t.isReady?.()??!0},cancelRequest(e,n){t.cancelRequest?.(e,n)},onBroadcastResults(e,n,r){t.onBroadcastResults?.(e,n,r)}};return t.reconnect&&(o.reconnect=()=>t.reconnect()),o}export{oe as BusAbortError,k as BusError,Ce as BusLifecycle,ye as CONNECTION_LOST_ERROR_CODE,g as ChannelAuthError,c as ChannelClosedError,ae as ChannelOnlyError,n as ConnectionLostError,Se as CorrelationTracker,he as DEFAULT_READINESS_TIMEOUT_MS,O as DEFAULT_REQUEST_TIMEOUT_MS,_e as LOCAL_ORIGIN,re as LocalSubjectError,N as MakaioBus,l as NO_HANDLER_ERROR_CODE,f as NoHandlerError,F as OnceAbortError,h as REMOTE_ORIGIN,o as RequestError,z as SystemChannelSchemas,m as TimeoutError,ee as ValidationError,I as __resetWarnedSubjects,we as buildSubscribeMessage,Q as buildUnsubscribeMessage,fe as channelSubject,P as collectorOnlySubject,A as createBusContext,ge as createBusInstance,be as createChannelEndpoint,Te as createExtensionNamespace,C as createFilteredBus,Me as createProjectedTelemetryTransport,Ee as createSubjectTelemetryProjectorRegistry,T as defaultTransports,E as defineSubjectExtension,i as deserializeTransportError,M as extendSubject,te as findInErrorChain,me as getFullSubjectForSubjectDefinition,u as getPath,S as getSubjectFromBusMessage,r as handleCorrelationResponse,j as hostLocalRequest,t as isNoHandlerErrorForSubject,s as isRequestCancellation,D as isRequestSchema,b as localSubject,le as matchesAnySubscription,ce as matchesFilter,ne as matchesSubscription,se as mergeFilters,xe as openChannel,pe as parseBusUrl,y as projectSubjectTelemetryFacts,L as serializeTransportError,ie as shouldReceiveMessage,ve as toSafeDebugLog,a as trackMessageCorrelation,x as transportErrorData,ue as waitForSubscriptionPropagation};