@makaio/framework 1.0.0-dev-1790165411632 → 1.0.0-dev-1790248497521
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.
- package/dist/.makaio-build.json +2 -2
- package/dist/adapters/claude/index.d.mts +24 -24
- package/dist/artifact-DF2UJsjP.mjs +1 -0
- package/dist/bridge/pty-bridge.cjs +222 -0
- package/dist/bus/index.d.mts +20 -20
- package/dist/bus/index.mjs +1 -1
- package/dist/bus-DgpPEPoM.mjs +9 -0
- package/dist/contracts/adapter/index.d.mts +2 -2
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/artifact/index.d.mts +3 -3
- package/dist/contracts/artifact/index.mjs +1 -1
- package/dist/contracts/canonical-model/index.d.mts +1 -1
- package/dist/contracts/capabilities/index.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +1 -1
- package/dist/contracts/extension/index.d.mts +3 -3
- package/dist/contracts/index.d.mts +162 -162
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/materialization/index.mjs +1 -1
- package/dist/contracts/native-session-supervisor/index.d.mts +1 -1
- package/dist/contracts/reaction/index.d.mts +1 -1
- package/dist/contracts/reaction/index.mjs +1 -1
- package/dist/contracts/session/index.d.mts +2 -2
- package/dist/contracts/shared/index.d.mts +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/worker/index.d.mts +1 -1
- package/dist/contracts/worker/index.mjs +1 -1
- package/dist/contracts/workflow/index.d.mts +2 -2
- package/dist/contracts/workflow/index.mjs +1 -1
- package/dist/framework-packages-mquh5_Yw.mjs +1 -0
- package/dist/{index-C9Dz8UoK2.d.mts → index-2YW8DTb62.d.mts} +6 -6
- package/dist/{index-B7KgjUmJ2.d.mts → index-6UlianLY2.d.mts} +4 -4
- package/dist/{index-BRF5X-EZ.d.mts → index-BRXETFym.d.mts} +9 -1
- package/dist/{index-BDTcg6tu.d.mts → index-BV3nQpdO.d.mts} +100 -100
- package/dist/{index-B1uHTa1l.d.mts → index-BZQ3OviE.d.mts} +1 -1
- package/dist/{index-z_wA9LhQ.d.mts → index-Bon00c4i.d.mts} +38 -1
- package/dist/{index-DyzmUD1S.d.mts → index-BrMihjbI.d.mts} +19 -19
- package/dist/{index-BVG-RaIu.d.mts → index-C4VB63lu.d.mts} +76 -76
- package/dist/{index-DRSeELQh.d.mts → index-CEX9qfLa.d.mts} +1 -1
- package/dist/{index-QYdQSOnc2.d.mts → index-CydQ1dLS2.d.mts} +6 -6
- package/dist/{index-CI5ss_XH.d.mts → index-D5Lw1UsO.d.mts} +339 -339
- package/dist/{index-BUxs65tf.d.mts → index-DDCixELI.d.mts} +1 -1
- package/dist/{index-8hJCLlAE.d.mts → index-DJLRXASA.d.mts} +11 -11
- package/dist/{index-CmTVBNCe.d.mts → index-Dcwee5Cl.d.mts} +372 -296
- package/dist/{index-CDuEmakt2.d.mts → index-LCumcYK12.d.mts} +378 -378
- package/dist/{index-qtH2O8j_.d.mts → index-QgSmUedN.d.mts} +6 -6
- package/dist/{index-BnNNfBck.d.mts → index-rkN_9bde.d.mts} +12 -12
- package/dist/kernel/extension/index.d.mts +2 -2
- package/dist/kernel/index.d.mts +2 -2
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/{materialization-iFhpbs1s.mjs → materialization-CIrHHspa.mjs} +4 -1
- package/dist/{namespace-Bz0ZDWhE.d.mts → namespace-BEi98VfQ.d.mts} +18 -18
- package/dist/{namespace-BhpzgnH3.d.mts → namespace-C5tKjqgb.d.mts} +1 -1
- package/dist/{namespace-CNX4llM5.d.mts → namespace-D8oTiLLo.d.mts} +12 -12
- package/dist/{namespace-B0__88KU.d.mts → namespace-HLrZerLd.d.mts} +154 -154
- package/dist/{namespace-BaUgxONS.d.mts → namespace-KomML5ti.d.mts} +2 -2
- package/dist/{package-jjugnMVh.d.mts → package-BswWlFSn.d.mts} +1 -1
- package/dist/package.json +1 -1
- package/dist/reaction-DVa5lwm5.mjs +1 -0
- package/dist/{schemas-DFamD1UF.d.mts → schemas-BOT1HUv6.d.mts} +154 -154
- package/dist/{schemas-KyQQPGjX.d.mts → schemas-CrOeGZHg.d.mts} +11 -11
- package/dist/{schemas-D9pXu76T.d.mts → schemas-__oTCzF6.d.mts} +8 -8
- package/dist/services/adapter-subsystem/index.d.mts +2 -2
- package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +3 -3
- package/dist/services/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/index.d.mts +137 -100
- package/dist/services/index.mjs +1 -1
- package/dist/services/provider-context/index.d.mts +1 -1
- package/dist/services/session/index.d.mts +3 -3
- package/dist/services/session/messages/namespace.d.mts +1 -1
- package/dist/services/session/session-events/namespace.d.mts +1 -1
- package/dist/services/settings/namespace.d.mts +8 -8
- package/dist/services/subagent-template/index.d.mts +2 -2
- package/dist/services/subagent-template/namespace.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/services/tools/index.mjs +1 -1
- package/dist/services/workflow-transitions/index.mjs +1 -1
- package/dist/{session-lineage-CmP7L5g2.d.mts → session-lineage-BQ9NWlt6.d.mts} +1 -1
- package/dist/{tools-ByDy0ueE.mjs → tools-K3DWA4Jr.mjs} +1 -1
- package/dist/{transition-CAtcgdUp.d.mts → transition-CSN6QoMp.d.mts} +1 -1
- package/dist/{types-BbqmHOM-.d.mts → types-BP_P1izV.d.mts} +350 -350
- package/dist/{view-builder-6YQFmKD6.d.mts → view-builder-2cR7vI7R.d.mts} +1 -1
- package/dist/{worker-B72n8bse.mjs → worker-YKEWHrx5.mjs} +1 -1
- package/dist/{workflow-D-X3rPsl.mjs → workflow-01evBylF.mjs} +1 -1
- package/dist/workflow-engine/index.d.mts +33 -33
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/{workflow-transitions-UOXY-VZa.mjs → workflow-transitions-C2BLDE5N.mjs} +1 -1
- package/package.json +1 -1
- package/dist/artifact-CKz9YQPu.mjs +0 -1
- package/dist/bus-D4DBDaoS.mjs +0 -9
- package/dist/framework-packages-C2tvdFmP.mjs +0 -1
- package/dist/reaction-C8WbJqLk.mjs +0 -1
- package/dist/{schemas-CuOZoC08.d.mts → schemas-CU2NE5Lg.d.mts} +8 -8
package/dist/.makaio-build.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 1,
|
|
3
|
-
"fingerprint": "
|
|
4
|
-
"builtAt": "2026-09-
|
|
3
|
+
"fingerprint": "00b2f1fc80e907d7a7aab0714b0dd9f34ccf9f10f89a11258eb8fa42537bd24c",
|
|
4
|
+
"builtAt": "2026-09-24T11:16:03.991Z",
|
|
5
5
|
"declarations": true,
|
|
6
6
|
"declarationBackend": "tsc"
|
|
7
7
|
}
|
|
@@ -4993,16 +4993,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
4993
4993
|
adapterId: z.ZodString;
|
|
4994
4994
|
agentId: z.ZodString;
|
|
4995
4995
|
oldState: z.ZodEnum<{
|
|
4996
|
-
paused: "paused";
|
|
4997
4996
|
idle: "idle";
|
|
4997
|
+
paused: "paused";
|
|
4998
4998
|
turn_started: "turn_started";
|
|
4999
4999
|
step_started: "step_started";
|
|
5000
5000
|
step_finished: "step_finished";
|
|
5001
5001
|
turn_finished: "turn_finished";
|
|
5002
5002
|
}>;
|
|
5003
5003
|
newState: z.ZodEnum<{
|
|
5004
|
-
paused: "paused";
|
|
5005
5004
|
idle: "idle";
|
|
5005
|
+
paused: "paused";
|
|
5006
5006
|
turn_started: "turn_started";
|
|
5007
5007
|
step_started: "step_started";
|
|
5008
5008
|
step_finished: "step_finished";
|
|
@@ -5014,16 +5014,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
5014
5014
|
adapterId: z.ZodString;
|
|
5015
5015
|
agentId: z.ZodString;
|
|
5016
5016
|
oldState: z.ZodEnum<{
|
|
5017
|
-
paused: "paused";
|
|
5018
5017
|
idle: "idle";
|
|
5018
|
+
paused: "paused";
|
|
5019
5019
|
turn_started: "turn_started";
|
|
5020
5020
|
step_started: "step_started";
|
|
5021
5021
|
step_finished: "step_finished";
|
|
5022
5022
|
turn_finished: "turn_finished";
|
|
5023
5023
|
}>;
|
|
5024
5024
|
newState: z.ZodEnum<{
|
|
5025
|
-
paused: "paused";
|
|
5026
5025
|
idle: "idle";
|
|
5026
|
+
paused: "paused";
|
|
5027
5027
|
turn_started: "turn_started";
|
|
5028
5028
|
step_started: "step_started";
|
|
5029
5029
|
step_finished: "step_finished";
|
|
@@ -5035,16 +5035,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
5035
5035
|
adapterId: z.ZodString;
|
|
5036
5036
|
agentId: z.ZodString;
|
|
5037
5037
|
oldState: z.ZodEnum<{
|
|
5038
|
-
paused: "paused";
|
|
5039
5038
|
idle: "idle";
|
|
5039
|
+
paused: "paused";
|
|
5040
5040
|
turn_started: "turn_started";
|
|
5041
5041
|
step_started: "step_started";
|
|
5042
5042
|
step_finished: "step_finished";
|
|
5043
5043
|
turn_finished: "turn_finished";
|
|
5044
5044
|
}>;
|
|
5045
5045
|
newState: z.ZodEnum<{
|
|
5046
|
-
paused: "paused";
|
|
5047
5046
|
idle: "idle";
|
|
5047
|
+
paused: "paused";
|
|
5048
5048
|
turn_started: "turn_started";
|
|
5049
5049
|
step_started: "step_started";
|
|
5050
5050
|
step_finished: "step_finished";
|
|
@@ -5056,16 +5056,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
5056
5056
|
adapterId: z.ZodString;
|
|
5057
5057
|
agentId: z.ZodString;
|
|
5058
5058
|
oldState: z.ZodEnum<{
|
|
5059
|
-
paused: "paused";
|
|
5060
5059
|
idle: "idle";
|
|
5060
|
+
paused: "paused";
|
|
5061
5061
|
turn_started: "turn_started";
|
|
5062
5062
|
step_started: "step_started";
|
|
5063
5063
|
step_finished: "step_finished";
|
|
5064
5064
|
turn_finished: "turn_finished";
|
|
5065
5065
|
}>;
|
|
5066
5066
|
newState: z.ZodEnum<{
|
|
5067
|
-
paused: "paused";
|
|
5068
5067
|
idle: "idle";
|
|
5068
|
+
paused: "paused";
|
|
5069
5069
|
turn_started: "turn_started";
|
|
5070
5070
|
step_started: "step_started";
|
|
5071
5071
|
step_finished: "step_finished";
|
|
@@ -5077,16 +5077,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
5077
5077
|
adapterId: z.ZodString;
|
|
5078
5078
|
agentId: z.ZodString;
|
|
5079
5079
|
oldState: z.ZodEnum<{
|
|
5080
|
-
paused: "paused";
|
|
5081
5080
|
idle: "idle";
|
|
5081
|
+
paused: "paused";
|
|
5082
5082
|
turn_started: "turn_started";
|
|
5083
5083
|
step_started: "step_started";
|
|
5084
5084
|
step_finished: "step_finished";
|
|
5085
5085
|
turn_finished: "turn_finished";
|
|
5086
5086
|
}>;
|
|
5087
5087
|
newState: z.ZodEnum<{
|
|
5088
|
-
paused: "paused";
|
|
5089
5088
|
idle: "idle";
|
|
5089
|
+
paused: "paused";
|
|
5090
5090
|
turn_started: "turn_started";
|
|
5091
5091
|
step_started: "step_started";
|
|
5092
5092
|
step_finished: "step_finished";
|
|
@@ -5098,16 +5098,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
5098
5098
|
adapterId: z.ZodString;
|
|
5099
5099
|
agentId: z.ZodString;
|
|
5100
5100
|
oldState: z.ZodEnum<{
|
|
5101
|
-
paused: "paused";
|
|
5102
5101
|
idle: "idle";
|
|
5102
|
+
paused: "paused";
|
|
5103
5103
|
turn_started: "turn_started";
|
|
5104
5104
|
step_started: "step_started";
|
|
5105
5105
|
step_finished: "step_finished";
|
|
5106
5106
|
turn_finished: "turn_finished";
|
|
5107
5107
|
}>;
|
|
5108
5108
|
newState: z.ZodEnum<{
|
|
5109
|
-
paused: "paused";
|
|
5110
5109
|
idle: "idle";
|
|
5110
|
+
paused: "paused";
|
|
5111
5111
|
turn_started: "turn_started";
|
|
5112
5112
|
step_started: "step_started";
|
|
5113
5113
|
step_finished: "step_finished";
|
|
@@ -7620,16 +7620,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
7620
7620
|
adapterId: z.ZodString;
|
|
7621
7621
|
agentId: z.ZodString;
|
|
7622
7622
|
oldState: z.ZodEnum<{
|
|
7623
|
-
paused: "paused";
|
|
7624
7623
|
idle: "idle";
|
|
7624
|
+
paused: "paused";
|
|
7625
7625
|
turn_started: "turn_started";
|
|
7626
7626
|
step_started: "step_started";
|
|
7627
7627
|
step_finished: "step_finished";
|
|
7628
7628
|
turn_finished: "turn_finished";
|
|
7629
7629
|
}>;
|
|
7630
7630
|
newState: z.ZodEnum<{
|
|
7631
|
-
paused: "paused";
|
|
7632
7631
|
idle: "idle";
|
|
7632
|
+
paused: "paused";
|
|
7633
7633
|
turn_started: "turn_started";
|
|
7634
7634
|
step_started: "step_started";
|
|
7635
7635
|
step_finished: "step_finished";
|
|
@@ -7641,16 +7641,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
7641
7641
|
adapterId: z.ZodString;
|
|
7642
7642
|
agentId: z.ZodString;
|
|
7643
7643
|
oldState: z.ZodEnum<{
|
|
7644
|
-
paused: "paused";
|
|
7645
7644
|
idle: "idle";
|
|
7645
|
+
paused: "paused";
|
|
7646
7646
|
turn_started: "turn_started";
|
|
7647
7647
|
step_started: "step_started";
|
|
7648
7648
|
step_finished: "step_finished";
|
|
7649
7649
|
turn_finished: "turn_finished";
|
|
7650
7650
|
}>;
|
|
7651
7651
|
newState: z.ZodEnum<{
|
|
7652
|
-
paused: "paused";
|
|
7653
7652
|
idle: "idle";
|
|
7653
|
+
paused: "paused";
|
|
7654
7654
|
turn_started: "turn_started";
|
|
7655
7655
|
step_started: "step_started";
|
|
7656
7656
|
step_finished: "step_finished";
|
|
@@ -7662,16 +7662,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
7662
7662
|
adapterId: z.ZodString;
|
|
7663
7663
|
agentId: z.ZodString;
|
|
7664
7664
|
oldState: z.ZodEnum<{
|
|
7665
|
-
paused: "paused";
|
|
7666
7665
|
idle: "idle";
|
|
7666
|
+
paused: "paused";
|
|
7667
7667
|
turn_started: "turn_started";
|
|
7668
7668
|
step_started: "step_started";
|
|
7669
7669
|
step_finished: "step_finished";
|
|
7670
7670
|
turn_finished: "turn_finished";
|
|
7671
7671
|
}>;
|
|
7672
7672
|
newState: z.ZodEnum<{
|
|
7673
|
-
paused: "paused";
|
|
7674
7673
|
idle: "idle";
|
|
7674
|
+
paused: "paused";
|
|
7675
7675
|
turn_started: "turn_started";
|
|
7676
7676
|
step_started: "step_started";
|
|
7677
7677
|
step_finished: "step_finished";
|
|
@@ -7683,16 +7683,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
7683
7683
|
adapterId: z.ZodString;
|
|
7684
7684
|
agentId: z.ZodString;
|
|
7685
7685
|
oldState: z.ZodEnum<{
|
|
7686
|
-
paused: "paused";
|
|
7687
7686
|
idle: "idle";
|
|
7687
|
+
paused: "paused";
|
|
7688
7688
|
turn_started: "turn_started";
|
|
7689
7689
|
step_started: "step_started";
|
|
7690
7690
|
step_finished: "step_finished";
|
|
7691
7691
|
turn_finished: "turn_finished";
|
|
7692
7692
|
}>;
|
|
7693
7693
|
newState: z.ZodEnum<{
|
|
7694
|
-
paused: "paused";
|
|
7695
7694
|
idle: "idle";
|
|
7695
|
+
paused: "paused";
|
|
7696
7696
|
turn_started: "turn_started";
|
|
7697
7697
|
step_started: "step_started";
|
|
7698
7698
|
step_finished: "step_finished";
|
|
@@ -7704,16 +7704,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
7704
7704
|
adapterId: z.ZodString;
|
|
7705
7705
|
agentId: z.ZodString;
|
|
7706
7706
|
oldState: z.ZodEnum<{
|
|
7707
|
-
paused: "paused";
|
|
7708
7707
|
idle: "idle";
|
|
7708
|
+
paused: "paused";
|
|
7709
7709
|
turn_started: "turn_started";
|
|
7710
7710
|
step_started: "step_started";
|
|
7711
7711
|
step_finished: "step_finished";
|
|
7712
7712
|
turn_finished: "turn_finished";
|
|
7713
7713
|
}>;
|
|
7714
7714
|
newState: z.ZodEnum<{
|
|
7715
|
-
paused: "paused";
|
|
7716
7715
|
idle: "idle";
|
|
7716
|
+
paused: "paused";
|
|
7717
7717
|
turn_started: "turn_started";
|
|
7718
7718
|
step_started: "step_started";
|
|
7719
7719
|
step_finished: "step_finished";
|
|
@@ -7725,16 +7725,16 @@ declare function createClaudeConnectorNamespace<N extends string>(namespaceName:
|
|
|
7725
7725
|
adapterId: z.ZodString;
|
|
7726
7726
|
agentId: z.ZodString;
|
|
7727
7727
|
oldState: z.ZodEnum<{
|
|
7728
|
-
paused: "paused";
|
|
7729
7728
|
idle: "idle";
|
|
7729
|
+
paused: "paused";
|
|
7730
7730
|
turn_started: "turn_started";
|
|
7731
7731
|
step_started: "step_started";
|
|
7732
7732
|
step_finished: "step_finished";
|
|
7733
7733
|
turn_finished: "turn_finished";
|
|
7734
7734
|
}>;
|
|
7735
7735
|
newState: z.ZodEnum<{
|
|
7736
|
-
paused: "paused";
|
|
7737
7736
|
idle: "idle";
|
|
7737
|
+
paused: "paused";
|
|
7738
7738
|
turn_started: "turn_started";
|
|
7739
7739
|
step_started: "step_started";
|
|
7740
7740
|
step_finished: "step_finished";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{n as t,o as n,s as r}from"./json-value-DM-EjTC1.mjs";import{C as i,_ as a,a as o,b as s,c,d as l,i as u,l as d,n as ee,p as te,r as ne,t as re,u as ie,w as f,x as ae,y as oe}from"./schemas-CHM0wMq4.mjs";import{C as se,a as p,b as ce,m as le,r as ue,s as m,t as h,u as g}from"./kind-registration-Dzfo6kyb.mjs";import{t as de}from"./zod-json-schema-ZUmGtQhT.mjs";import{t as fe}from"./ajv-Cvnmw2yn.mjs";import{t as pe}from"./2020-CRfgqanb.mjs";import{t as me}from"./dist-onY7e-pd.mjs";import{z as _}from"zod";import{createBusNamespace as he}from"@makaio/framework/core";const ge=_.strictObject({evidence:i}),v=_.strictObject({kind:_.literal(`text`),text:_.string()}),[_e,ve,ye]=i.options,be=_.union([_e.pick({source:!0,location:!0}).extend({content:v}),ve.pick({source:!0,location:!0}).extend({content:v}),ye.pick({source:!0,location:!0}).extend({content:v})]);function y(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function b(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function xe(e,t){if(t===`#`)return{node:e,pointer:``};if(!t.startsWith(`#/`))return;let n;try{n=decodeURIComponent(t.slice(1))}catch{return}let r=e;for(let e of n.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(t)||Number(t)>=r.length)return;r=r[Number(t)]}else{let e=y(r);if(!e||!Object.hasOwn(e,t))return;r=e[t]}}let i=typeof r==`boolean`?r:y(r);return i===void 0?void 0:{node:i,pointer:n}}function x(e,t){if(t===``)return!1;let n=e;for(let e of t.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(n=Array.isArray(n)?n[Number(t)]:y(n)?.[t],typeof y(n)?.$id==`string`)return!0}return!1}function Se(e,t,n){if(e[`x-makaio-value-type`]!==`evidence/v1`)return;let r=i.safeParse(t);if(!r.success)throw Error(`Invalid schema-declared evidence at ${n}`);return{evidence:r.data,dataPath:n}}function Ce(e,t,n,r){if(typeof t.$ref!=`string`)return!1;if(r)return!0;let i=xe(e,t.$ref);return i===void 0?!0:typeof i.node!=`boolean`&&S(e,i.node,n,x(e,i.pointer))}function S(e,t,n=new WeakSet,r=!1){let i=y(t);if(!i||n.has(i))return!1;n.add(i);let a=r||i!==e&&typeof i.$id==`string`;if(i[`x-makaio-value-type`]===`evidence/v1`||typeof i.$dynamicRef==`string`||Ce(e,i,n,a)||[`additionalItems`,`additionalProperties`,`contains`,`else`,`if`,`items`,`then`,`unevaluatedItems`,`unevaluatedProperties`].some(t=>S(e,i[t],n,a))||[`allOf`,`anyOf`,`oneOf`,`prefixItems`].some(t=>Array.isArray(i[t])&&i[t].some(t=>S(e,t,n,a)))||Array.isArray(i.items)&&i.items.some(t=>S(e,t,n,a)))return!0;for(let t of[`dependentSchemas`,`dependencies`,`patternProperties`,`properties`]){let r=y(i[t]);if(r&&Object.values(r).some(t=>S(e,t,n,a)))return!0}return!1}var we=class{dataSchema;matchesSchema;occurrences=new Map;visited=new WeakMap;constructor(e,t){this.dataSchema=e,this.matchesSchema=t}extract(e){return this.visit(this.dataSchema,e,`/data`),[...this.occurrences.values()]}visit(e,t,n,r=``){let i=this.visited.get(e)??new Set;if(i.has(n))return;if(i.add(n),this.visited.set(e,i),typeof e.$dynamicRef==`string`)throw Error(`Evidence discovery does not support active $dynamicRef at ${n}`);if(typeof e.$ref==`string`){if(x(this.dataSchema,r))throw Error(`Evidence discovery does not support local $ref inside nested $id resource at ${n}`);let i=xe(this.dataSchema,e.$ref);if(i===void 0)throw Error(`Cannot resolve local schema reference ${e.$ref} at ${n}`);if(typeof i.node!=`boolean`&&this.visit(i.node,t,n,i.pointer),this.dataSchema.$schema!==`https://json-schema.org/draft/2020-12/schema`)return}let a=Se(e,t,n);if(a){this.occurrences.set(n,a);return}this.visitCombiners(e,t,n,r),this.visitConditional(e,t,n,r),this.visitDependencies(e,t,n,r),this.assertSupportedApplicators(e,n,r),Array.isArray(t)?this.visitArray(e,t,n,r):typeof t==`object`&&t&&this.visitObject(e,t,n,r)}visitCombiners(e,t,n,r){for(let i of[`allOf`,`anyOf`,`oneOf`]){let a=e[i];if(Array.isArray(a))for(let[e,o]of a.entries()){let a=y(o),s=`${r}/${i}/${e}`;a&&(i===`allOf`||this.matchesSchema(this.dataSchema,s,t))&&this.visit(a,t,n,s)}}}visitConditional(e,t,n,r){let i=typeof e.if==`boolean`?e.if:y(e.if);if(i===void 0)return;let a=`${r}/if`,o=this.matchesSchema(this.dataSchema,a,t);o&&typeof i!=`boolean`&&this.visit(i,t,n,a);let s=o?`then`:`else`,c=y(e[s]);c&&this.visit(c,t,n,`${r}/${s}`)}visitDependencies(e,t,n,r){if(!(typeof t!=`object`||!t||Array.isArray(t)))for(let i of[`dependentSchemas`,`dependencies`]){let a=y(e[i]);if(a)for(let[e,o]of Object.entries(a)){let a=y(o);Object.hasOwn(t,e)&&a&&this.visit(a,t,n,`${r}/${i}/${b(e)}`)}}}assertSupportedApplicators(e,t,n){for(let r of[`unevaluatedProperties`,`unevaluatedItems`])if(S(this.dataSchema,e[r],void 0,x(this.dataSchema,n)))throw Error(`Evidence under unsupported ${r} applicator at ${t}`)}visitArray(e,t,n,r){let i=Array.isArray(e.prefixItems),a=i?e.prefixItems:Array.isArray(e.items)?e.items:[];a.forEach((e,a)=>{let o=y(e),s=i?`prefixItems`:`items`;o&&a<t.length&&this.visit(o,t[a],`${n}/${a}`,`${r}/${s}/${a}`)});let o=Array.isArray(e.items)?y(e.additionalItems):y(e.items);if(o){let i=Array.isArray(e.items)?`additionalItems`:`items`;t.slice(a.length).forEach((e,t)=>this.visit(o,e,`${n}/${a.length+t}`,`${r}/${i}`))}this.visitContains(e,t,n,r)}visitContains(e,t,n,r){let i=y(e.contains);if(!i)return;let a=`${r}/contains`;t.forEach((e,t)=>{this.matchesSchema(this.dataSchema,a,e)&&this.visit(i,e,`${n}/${t}`,a)})}visitObject(e,t,n,r){let i=y(e.properties),a=y(e.patternProperties);for(let[o,s]of Object.entries(t)){let t=b(o),c=i!==void 0&&Object.hasOwn(i,o),l=y(i?.[o]);l&&this.visit(l,s,`${n}/${t}`,`${r}/properties/${t}`);let u=this.visitPatterns(a,o,s,`${n}/${t}`,r),d=y(e.additionalProperties);!c&&!u&&d&&this.visit(d,s,`${n}/${t}`,`${r}/additionalProperties`)}}visitPatterns(e,t,n,r,i){let a=!1;for(let[o,s]of Object.entries(e??{})){if(!new RegExp(o,`u`).test(t))continue;a=!0;let e=y(s);e&&this.visit(e,n,r,`${i}/patternProperties/${b(o)}`)}return a}};function Te(e,t,n){return new we(e,n.matchesSchema).extract(t)}function Ee(e){let{dataSchema:t,hooks:n,...r}=e,i={$schema:`https://json-schema.org/draft/2020-12/schema`,...de(t)};ce(i);let a=p.parse({...r,dataSchema:i});if(a.kind!==e.kind)throw Error(`Artifact kind identifiers must not contain surrounding whitespace`);let o=_.fromJSONSchema(a.dataSchema),s=_.unknown().superRefine((e,t)=>{let n=o.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:`custom`,path:e.path,message:e.message})}).pipe(t).superRefine((e,t)=>{try{se(e,a.titlePath)}catch(e){t.addIssue({code:`custom`,path:a.titlePath.split(`.`),message:e instanceof Error?e.message:`Artifact title must be a nonblank string`})}});return{...structuredClone(a),kind:e.kind,schemaVersion:e.schemaVersion,dataSchema:s,...n?{hooks:n}:{},toRegistration:()=>structuredClone(a)}}var De=e(fe(),1),Oe=e(pe(),1),ke=e(me(),1);function C(e){let t={allErrors:!0,strict:!1,strictSchema:!0},n=e.dataSchema.$schema===`https://json-schema.org/draft/2020-12/schema`?new Oe.default(t):new De.default(t);return(0,ke.default)(n),n.addKeyword({keyword:ae,schemaType:`string`,valid:!0}),n.compile(e.dataSchema)}function Ae(e){return e.replace(/~1/gu,`/`).replace(/~0/gu,`~`)}function je(e){let t=e.instancePath.split(`/`).slice(1).map(Ae),n=e.keyword===`required`?e.params.missingProperty:e.params.additionalProperty;return typeof n==`string`&&(e.keyword===`required`||e.keyword===`additionalProperties`)&&t.push(n),t.join(`.`)}function Me(e){if(e.keyword!==`type`)return;let t=e.params.type;if(typeof t==`string`)return t;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t.join(` | `)}const Ne=n.array();function Pe(e){if(e.keyword!==`enum`)return;let t=Ne.safeParse(e.params.allowedValues);return t.success?t.data:void 0}function Fe(e){return(e??[]).map(e=>{let t=Me(e),n=Pe(e);return{path:je(e),reason:e.message??`violates ${e.keyword}`,...t===void 0?{}:{expectedType:t},...n===void 0?{}:{allowedValues:n}}})}function Ie(e){return C(e)}function Le(e){let t=C(e);return e=>t(e)?{valid:!0}:{valid:!1,issues:Fe(t.errors)}}function Re(e){return{hooks:[...e.hooks]}}const ze=[`inline`,`summary`,`link`,`omit`],w=[`outbound`,`inbound`],T=_.string().min(1),E=_.enum(w),D=_.object({kinds:_.array(_.string().min(1)).optional(),hint:T.optional(),depth:_.number().int().min(1).max(20).optional(),nested:_.lazy(()=>O).optional(),direction:E.optional()}),O=_.record(_.string().min(1),D);function k(e){return JSON.stringify([e.kind,e.id,e.revision])}const Be=_.enum([`not-selected`,`not-found`,`depth-exceeded`,`unsupported-ref-class`,`cycle-detected`]),Ve=_.object({target:d,sourceRef:f,relationType:_.string().min(1),sourceLocalId:c.shape.sourceLocalId,direction:E.optional(),hint:T,status:_.enum([`resolved`,`unresolved`]),reason:Be.optional()}).superRefine((e,t)=>{e.status===`unresolved`&&e.reason===void 0&&t.addIssue({code:_.ZodIssueCode.custom,path:[`reason`],message:`reason is required for unresolved artifact context refs`}),e.status===`resolved`&&e.reason!==void 0&&t.addIssue({code:_.ZodIssueCode.custom,path:[`reason`],message:`reason must be omitted for resolved artifact context refs`}),e.status===`resolved`&&e.target.refClass!==`artifact`&&t.addIssue({code:_.ZodIssueCode.custom,path:[`target`],message:`resolved artifact context refs must target an artifact revision`})}),A=_.object({rootRef:f,refs:_.array(Ve),resolved:_.array(l)}).superRefine((e,t)=>{let n=new Set(e.resolved.map(k));n.has(k(e.rootRef))||t.addIssue({code:_.ZodIssueCode.custom,path:[`resolved`],message:`resolved artifact context wire payloads must include the root artifact revision`}),e.refs.forEach((e,r)=>{n.has(k(e.sourceRef))||t.addIssue({code:_.ZodIssueCode.custom,path:[`refs`,r,`sourceRef`],message:`artifact context ref sources must have a matching revision in resolved`}),!(e.status!==`resolved`||e.target.refClass!==`artifact`)&&(n.has(k(e.target))||t.addIssue({code:_.ZodIssueCode.custom,path:[`refs`,r,`target`],message:`resolved artifact context refs must have a matching revision in resolved`}))})});function He(e){let t=A.parse(e),n=new Map(t.resolved.map(e=>[k(e),e])),r=new Map;for(let e of t.refs){let t=k(e.sourceRef),n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}let i=n.get(k(t.rootRef));if(!i)throw Error(`Resolved artifact context is missing root artifact '${k(t.rootRef)}'`);let a=Ue(t.rootRef,i,`inline`,r,n);return{root:a,flatten(){let e=[];return Ke(a,e),e}}}function Ue(e,t,n,r,i){return{status:`resolved`,ref:e,artifact:t,hint:n,children:Ge(e,r,i,new Set([k(e)]))}}function We(e,t,n,r,i,a,o,s,c){let l=k(e),u=new Set(c);return u.add(l),{status:`resolved`,ref:e,artifact:t,relation:n,sourceLocalId:r,direction:i,hint:a,children:Ge(e,o,s,u)}}function Ge(e,t,n,r){return(t.get(k(e))??[]).map(e=>{if(e.status===`unresolved`)return{status:`unresolved`,target:e.target,relation:e.relationType,sourceLocalId:e.sourceLocalId,direction:e.direction,hint:e.hint,reason:e.reason};if(e.target.refClass!==`artifact`)throw Error(`Resolved artifact context refs must target an artifact revision`);let i=k(e.target),a=n.get(i);if(!a)throw Error(`Resolved artifact context is missing target artifact '${i}'`);return r.has(i)?{status:`unresolved`,target:e.target,relation:e.relationType,sourceLocalId:e.sourceLocalId,direction:e.direction,hint:e.hint,reason:`cycle-detected`}:We(e.target,a,e.relationType,e.sourceLocalId,e.direction,e.hint,t,n,r)})}function Ke(e,t){if(e.status!==`unresolved`){t.push(e.artifact);for(let n of e.children)Ke(n,t)}}const j=[`$set`,`$unset`,`$push`,`$pull`],M=`[A-Za-z_$][A-Za-z0-9_$]*`,N=`[A-Za-z_$][A-Za-z0-9_$-]*`,qe=`(?:0|[1-9][0-9]*)`,Je=`(?:${`\\$\\[${M}\\]`}|${qe}|${N})`,Ye=RegExp(`^${N}(?:\\.${Je})*$`),Xe=RegExp(`^${M}(?:\\.${N})*$`),Ze=RegExp(`^${qe}$`),Qe=RegExp(`^\\$\\[(${M})\\]$`),P=_.string().regex(Ye,`Expected a data-relative path of object properties, array positions, or $[filter] placeholders`);function $e(e){let t=Qe.exec(e);return t?.[1]===void 0?Ze.test(e)?{kind:`index`,index:Number(e)}:{kind:`property`,name:e}:{kind:`filter`,placeholder:t[1]}}function et(e){return e.split(`.`).map($e)}function tt(e){return et(e).flatMap(e=>e.kind===`filter`?[e.placeholder]:[])}const nt=r(_.record(_.string().regex(Xe,`Expected a filter key of the form name or name.field.path`),n),{prototypeKey:`an array filter cannot compare a __proto__ key, which JSON transport drops`,nonPlainObject:`an array filter must be a plain object of comparison keys`,symbolKey:`an array filter cannot carry symbol-keyed comparisons`,nonEnumerableKey:`an array filter cannot carry non-enumerable comparison keys`,extraArrayKey:`an array filter must be a plain object, not an array`});function rt(e){let t=new Set(Object.keys(e).map(e=>e.split(`.`)[0]));if(t.size!==1)return;let[n]=t;return n!==void 0&&n.length>0?n:void 0}function F(e,t){return r(_.record(P,t),{prototypeKey:`${e} cannot address __proto__, which JSON transport drops`,nonPlainObject:`${e} must be a plain object of path instructions`,symbolKey:`${e} cannot carry symbol-keyed instructions`,nonEnumerableKey:`${e} cannot carry non-enumerable instructions`,extraArrayKey:`${e} must be a plain object, not an array`})}const it=_.literal(!0),at=_.strictObject({$set:F(`$set`,n).optional(),$unset:F(`$unset`,it).optional(),$push:F(`$push`,n).optional(),$pull:F(`$pull`,n).optional(),arrayFilters:_.array(nt).optional()});function I(e){return j.flatMap(t=>Object.entries(e[t]??{}).map(([e,n])=>({operator:t,path:e,value:n})))}function ot(e,t){let n=I(e),r=new Map;(e.arrayFilters??[]).forEach((e,n)=>{let i=rt(e);if(i===void 0){t.addIssue({code:`custom`,path:[`arrayFilters`,n],message:`An array filter must bind exactly one placeholder name across all of its keys`});return}if(r.has(i)){t.addIssue({code:`custom`,path:[`arrayFilters`,n],message:`Array filter placeholder ${i} is already bound by another filter`});return}r.set(i,n)});let i=new Set;for(let{operator:e,path:a}of n)for(let n of tt(a))i.add(n),r.has(n)||t.addIssue({code:`custom`,path:[e,a],message:`Path uses placeholder $[${n}] without a matching entry in arrayFilters`});for(let[e,n]of r)i.has(e)||t.addIssue({code:`custom`,path:[`arrayFilters`,n],message:`Array filter binds placeholder ${e}, which no path uses`})}const st=at.superRefine(ot).superRefine((e,t)=>{I(e).length===0&&t.addIssue({code:`custom`,message:`Declare at least one of ${j.join(`, `)}`})}),ct=at.superRefine(ot),lt=_.strictObject({kind:f.shape.kind,id:f.shape.id}),ut=_.strictObject({ref:lt,baseRevision:f.shape.revision,patch:ct,dryRun:_.boolean().optional(),schemaVersion:g.optional().describe(`Target schema version for the patched revision; defaults to the base revision's. Use it to migrate an artifact left at an older version by a kind bump.`),statusPath:te.optional(),representations:ie.strict().nullable().optional().describe(`Rendering hints (markdown, summary, plaintext) for the new revision. Omit to keep the previous revision's hints. An object replaces all of them, it does not merge: send every hint you want to keep. null clears them.`)}).superRefine((e,t)=>{e.schemaVersion===void 0&&I(e.patch).length===0&&t.addIssue({code:`custom`,path:[`patch`],message:`Declare at least one of ${j.join(`, `)}, or name a schemaVersion to migrate a payload that already fits`})}),dt=[`ARTIFACT_NOT_FOUND`,`BASE_REVISION_CONFLICT`,`KIND_NOT_REGISTERED`,`SCHEMA_VERSION_MISMATCH`,`PATH_NOT_DECLARED`,`PATH_NOT_RESOLVABLE`,`TARGET_NOT_A_COLLECTION`,`UNSUPPORTED_TARGET`,`NO_MATCH`,`SCHEMA_VALIDATION_FAILED`,`PAYLOAD_INVARIANT_FAILED`,`NO_CHANGE`,`STORE_REJECTED`,`HOST_FAILED`],ft=_.strictObject({path:_.string(),reason:_.string().min(1),expectedType:_.string().min(1).optional(),allowedValues:_.array(n).optional()}),pt=_.strictObject({code:_.enum(dt),message:_.string().min(1),operator:_.enum(j).optional(),path:P.optional(),currentRevision:f.shape.revision.optional(),issues:_.array(ft).optional(),repair:_.string().min(1)}).superRefine((e,t)=>{e.code===`BASE_REVISION_CONFLICT`&&e.currentRevision===void 0&&t.addIssue({code:_.ZodIssueCode.custom,message:`A BASE_REVISION_CONFLICT must name the revision the artifact carries.`,path:[`currentRevision`]})}),mt=_.strictObject({operator:_.enum(j),path:P,matched:_.number().int().positive()}),ht=_.strictObject({from:g,to:g}).refine(e=>e.to>e.from,{path:[`to`],message:`A migration moves the artifact forward to a newer schema version`}),gt=_.strictObject({ok:_.literal(!0),base:f,operations:_.array(mt),migration:ht.optional()});function _t(e,t){e.operations.length===0&&e.migration===void 0&&t.addIssue({code:`custom`,path:[`operations`],message:`A success without a migration must report at least one applied instruction`})}const vt=gt.extend({dryRun:_.literal(!0)}).superRefine(_t),yt=gt.extend({dryRun:_.literal(!1),artifact:f}).superRefine(_t),bt=_.discriminatedUnion(`dryRun`,[vt,yt]),xt=_.strictObject({ok:_.literal(!1),error:pt}),St=_.union([bt,xt]),Ct=_.object({ref:oe}),wt=_.union([_.strictObject({ok:_.literal(!0),ref:oe,areaPath:ue,part:t}),_.strictObject({ok:_.literal(!1),error:le})]),L=f.pick({kind:!0,id:!0}),R=_.number().int().positive(),z=R,B={knowledge:`valid`,commitment:`proposed`,interaction:`open`},V=_.discriminatedUnion(`category`,[_.strictObject({category:_.literal(`knowledge`),state:_.enum(h.knowledge),version:z}),_.strictObject({category:_.literal(`commitment`),state:_.enum(h.commitment),version:z}),_.strictObject({category:_.literal(`interaction`),state:_.enum(h.interaction),version:z})]).superRefine((e,t)=>{e.version===1&&e.state!==B[e.category]&&t.addIssue({code:`custom`,path:[`state`],message:`Lifecycle version 1 is reserved for the category initial state`})}),H=_.union([V,_.strictObject({category:_.literal(`record`)})]),U=_.string().trim().min(1),Tt=_.strictObject({kind:U,ref:U}),W=_.discriminatedUnion(`kind`,[_.strictObject({kind:_.literal(`revision-assessment`),assessedRevision:f.shape.revision,source:Tt.optional()}),_.strictObject({kind:_.literal(`handover`),source:Tt})]),Et={artifact:L,expectedVersion:z,state:m,situation:W,reason:U.optional()},G=_.strictObject(Et),Dt=_.strictObject({...Et,actor:re}),Ot={valid:[`retired`],retired:[`valid`],proposed:[`decided`],decided:[`fulfilled`,`revoked`],fulfilled:[],revoked:[],open:[`resolved`,`closed-without-resolution`],resolved:[],"closed-without-resolution":[]};function K(e,t){return Ot[e].includes(t)}const kt={artifact:L,lifecycle:V,actor:re,timestamp:_.number().int().nonnegative(),observedRevision:f.shape.revision},At=_.strictObject({...kt,operation:_.literal(`initialized`)}).superRefine((e,t)=>{(e.lifecycle.version!==1||e.lifecycle.state!==B[e.lifecycle.category])&&t.addIssue({code:`custom`,path:[`lifecycle`],message:`Initialization requires the category initial state and version 1`})});function jt(e,t){return t===`retired`||e===`retired`&&t===`valid`}const Mt=`Retiring or reinstating knowledge requires a reason`,q=_.strictObject({...kt,operation:_.literal(`transitioned`),previousState:m,situation:W,reason:G.shape.reason}).superRefine((e,t)=>{(!K(e.previousState,e.lifecycle.state)||e.lifecycle.version<=1)&&t.addIssue({code:`custom`,path:[`lifecycle`],message:`History requires a category-compatible transition after initialization`}),jt(e.previousState,e.lifecycle.state)&&!e.reason&&t.addIssue({code:`custom`,path:[`reason`],message:Mt}),e.situation.kind===`revision-assessment`&&e.situation.assessedRevision!==e.observedRevision&&t.addIssue({code:`custom`,path:[`situation`],message:`An assessment cannot authorize a different observed content revision`})}),Nt=_.discriminatedUnion(`operation`,[At,q]),J=_.discriminatedUnion(`reason`,[_.strictObject({reason:_.literal(`lifecycle-version-conflict`),expectedVersion:z,current:V,requestedState:m}),_.strictObject({reason:_.literal(`content-basis-conflict`),assessedRevision:f.shape.revision,currentRevision:f.shape.revision}),_.strictObject({reason:_.literal(`invalid-transition`),current:H,requestedState:m}),_.strictObject({reason:_.literal(`precondition-failed`),current:V,requestedState:m})]),Y=`artifact-lifecycle-rejected`;var X=class extends Error{code=Y;data;constructor(e,t){super(e),this.name=`ArtifactLifecycleError`,this.data=J.parse(t)}};function Pt(e){return e===`record`?{category:`record`}:V.parse({category:e,state:B[e],version:1})}function Ft(e){let t=H.parse(e.current),n=f.shape.revision.parse(e.currentRevision),r=Dt.parse(e.command);if(t.category===`record`)throw new X(`Record artifacts do not have a lifecycle`,{reason:`invalid-transition`,current:t,requestedState:r.state});if(r.expectedVersion!==t.version)throw new X(`Artifact lifecycle changed since the supplied baseline`,{reason:`lifecycle-version-conflict`,expectedVersion:r.expectedVersion,current:t,requestedState:r.state});if(r.situation.kind===`revision-assessment`&&r.situation.assessedRevision!==n)throw new X(`Assessed content revision is no longer current`,{reason:`content-basis-conflict`,assessedRevision:r.situation.assessedRevision,currentRevision:n});if(!K(t.state,r.state))throw new X(`Artifact lifecycle transition is not allowed`,{reason:`invalid-transition`,current:t,requestedState:r.state});if(jt(t.state,r.state)&&!r.reason)throw new X(Mt,{reason:`precondition-failed`,current:t,requestedState:r.state});return V.parse({...t,state:r.state,version:t.version+1})}const It=_.strictObject({artifact:L}),Lt=_.strictObject({lifecycle:H}),Rt=_.strictObject({artifact:L,afterVersion:R.optional(),limit:_.number().int().min(1).max(100).default(50)}),zt=_.strictObject({entries:_.array(Nt).max(100),nextCursor:R.optional()}).superRefine(({entries:e,nextCursor:t},n)=>{let r=e[0],i;for(let[t,a]of e.entries()){let e=a.artifact.kind===r?.artifact.kind&&a.artifact.id===r?.artifact.id,o=i===void 0||a.lifecycle.version===i.lifecycle.version+1,s=i===void 0||a.operation===`transitioned`&&a.lifecycle.category===i.lifecycle.category&&a.previousState===i.lifecycle.state;if(!e||!o||!s){n.addIssue({code:`custom`,path:[`entries`,t],message:`History pages contain one artifact in contiguous ascending, state-linked order`});break}i=a}t!==void 0&&t!==i?.lifecycle.version&&n.addIssue({code:`custom`,path:[`nextCursor`],message:`nextCursor must equal the last returned lifecycle version`})}),Z=_.strictObject({entry:q}),Bt=Z,Vt=_.strictObject({code:_.literal(Y),message:_.string().min(1),data:J});function Ht(e){return{code:e.code,message:e.message,data:e.data}}function Ut(e,t){switch(t.reason){case`content-basis-conflict`:return Kt(e,t);case`lifecycle-version-conflict`:return[...Wt(e,t),...Gt(e,t)];case`invalid-transition`:case`precondition-failed`:return[...Wt(e,t),...qt(e,t)]}}function Wt(e,t){return t.requestedState===e.state?[]:[{path:[`requestedState`],message:`Rejection requestedState must match the rejected transition`}]}function Gt(e,t){let n=[];return t.expectedVersion!==e.expectedVersion&&n.push({path:[`expectedVersion`],message:`Version conflict baseline must match the rejected transition`}),t.current.version===e.expectedVersion&&n.push({path:[`current`,`version`],message:`Version conflict requires a current version different from the supplied baseline`}),n}function Kt(e,t){let n=[];return(e.situation.kind!==`revision-assessment`||t.assessedRevision!==e.situation.assessedRevision)&&n.push({path:[`assessedRevision`],message:`Content conflict must identify the rejected revision assessment`}),t.currentRevision===t.assessedRevision&&n.push({path:[`currentRevision`],message:`Content conflict requires a current revision different from the assessed revision`}),n}function qt(e,t){if(t.current.category===`record`)return[];let n=[];t.current.version!==e.expectedVersion&&n.push({path:[`current`,`version`],message:`A rejection after the version check must report the supplied baseline version`});let r=K(t.current.state,t.requestedState);return t.reason===`invalid-transition`&&r&&n.push({path:[`reason`],message:`invalid-transition requires a transition the lifecycle matrix disallows`}),t.reason===`precondition-failed`&&!r&&n.push({path:[`reason`],message:`precondition-failed requires a transition the lifecycle matrix allows`}),n}const Jt=_.strictObject({transition:G,error:Vt}).superRefine(({transition:e,error:t},n)=>{for(let r of Ut(e,t.data))n.addIssue({code:`custom`,path:[`error`,`data`,...r.path],message:r.message})}),Q={"lifecycle.get":{request:It,response:Lt},"lifecycle.history":{request:Rt,response:zt},"lifecycle.transition":{request:G,response:Z},"lifecycle.committed":Bt,"lifecycle.rejected":Jt},Yt={...Q,"kind.register":{request:p,response:_.object({registered:_.boolean()})},"kind.list":{request:_.object({kind:_.string().min(1).optional()}),response:_.object({kinds:_.array(p)})},"relation-type.register":{request:s,response:_.object({registered:_.boolean()})},"relation-type.list":{request:_.object({type:_.string().min(1).optional()}),response:_.object({relationTypes:_.array(s)})},create:{request:l.omit({id:!0,revision:!0,timestamp:!0}).extend({id:f.shape.id.optional()}),response:_.object({artifact:l})},revise:{request:_.object({previous:f,statusPath:te.optional(),revision:l.omit({id:!0,revision:!0,timestamp:!0})}),response:_.object({artifact:l})},patch:{request:ut,response:St},resolve:{request:_.object({ref:f}),response:_.object({artifact:l.nullable()})},resolvePart:{request:Ct,response:wt},query:{request:o,response:_.object({artifacts:_.array(l)})},compare:{request:ee,response:ne},"evidence.resolve":{request:ge,response:be},resolveContext:{request:_.object({ref:f,selectors:O.optional(),maxDepth:_.number().int().min(1).max(20).default(5)}),response:_.object({context:A})},created:_.object({artifact:l}),revised:_.object({previous:f,artifact:l}),"relation.added":_.object({artifact:f,relation:c}),"observation.added":_.object({artifact:f,observation:u}),"status.changed":_.object({artifact:f,path:_.string().min(1),previous:_.unknown().optional(),current:_.unknown().optional()}),"kind.changed":_.object({kind:_.string().min(1),schemaVersion:g})},Xt=he(`artifact`,Yt),Zt=Xt.subjects,Qt=_.discriminatedUnion(`refClass`,[f.omit({revision:!0}),a]);function $t(e){if(e.refClass===`artifact`)return{refClass:`artifact`,kind:e.kind,id:e.id};if(e.refClass===`entity`)return{refClass:`entity`,entityType:e.entityType,id:e.id}}function $(e){return e.refClass===`artifact`?JSON.stringify([`artifact`,e.kind,e.id]):JSON.stringify([`entity`,e.entityType,e.id])}function en(e){return e.refClass===`artifact`?`artifact:${e.kind}/${e.id}`:`entity:${e.entityType}/${e.id}`}const tn=[`relation-target`];function nn(e,t){if(!e||e.length===0)return{ok:!0,rules:[]};let n=[];for(let[r,i]of e.entries()){for(let[e,a]of i.by.entries())(!tn.includes(a.kind)||!t.includes(a.kind))&&n.push({ruleIndex:r,selectorIndex:e,capability:a.kind,message:`rule #${r}, selector #${e}: '${a.kind}' selectors are not supported`});i.lifecycleStates!==void 0&&!t.includes(`lifecycle-states`)&&n.push({ruleIndex:r,capability:`lifecycle-states`,message:`rule #${r}: lifecycleStates is declared but 'lifecycle-states' is not a supported capability`})}return n.length>0?{ok:!1,issues:n}:{ok:!0,rules:e}}function rn(e,t,n,r){if(e.kind===`data`)return{ruleIndex:n,selectorIndex:r,reason:`unsupported-selector`,message:`rule #${n}, selector #${r}: data-path selectors cannot be derived from relations`};let{relationType:i}=e,a=t.filter(e=>e.type===i&&e.sourceLocalId===void 0),o=new Set,s,c;for(let e of a){let t=$t(e.target);if(t===void 0){c=e.target.refClass;break}o.add($(t)),s=t}return c===void 0?s===void 0?{ruleIndex:n,selectorIndex:r,reason:`missing-target`,relationType:i,message:`rule #${n}, selector #${r}, relation '${i}': no relations of this type found`}:o.size>1?{ruleIndex:n,selectorIndex:r,reason:`ambiguous-target`,relationType:i,message:`rule #${n}, selector #${r}, relation '${i}': ${o.size} distinct targets; expected exactly one`}:{type:i,target:s}:{ruleIndex:n,selectorIndex:r,reason:`unsupported-target`,relationType:i,message:`rule #${n}, selector #${r}, relation '${i}': found a relation with refClass '${c}'; only artifact and entity targets are supported`}}function an(e,t){let n=[],r=[];for(let[i,a]of e.entries()){let e=a.by.map((e,n)=>rn(e,t,i,n)),o=e.filter(e=>`reason`in e);if(o.length>0){r.push(...o);continue}let s=e.filter(e=>!(`reason`in e)),c=JSON.stringify(s.map(e=>[e.type,$(e.target)]));n.push({rule:a,ruleIndex:i,parts:s,serialized:c})}return{keys:n,issues:r}}function on(e){return e.parts.map(e=>`${e.type} → ${en(e.target)}`).join(`; `)}export{bt as $,Dt as A,j as B,X as C,be as Ct,J as D,At as E,Pt as F,xt as G,st as H,K as I,mt as J,ft as K,Ct as L,q as M,R as N,W as O,Ft as P,St as Q,wt as R,H as S,ge as St,L as T,vt as U,nt as V,pt as W,yt as X,P as Y,ut as Z,Jt as _,Re as _t,$t as a,et as at,Ht as b,Ee as bt,Xt as c,Be as ct,Bt as d,w as dt,lt as et,Vt as f,ze as ft,zt as g,O as gt,Rt as h,T as ht,Qt as i,$e as it,G as j,V as k,Yt as l,A as lt,Lt as m,D as mt,an as n,I as nt,en as o,He as ot,It as p,E as pt,ht as q,on as r,tt as rt,$ as s,Ve as st,nn as t,rt as tt,Zt as u,k as ut,Q as v,Le as vt,Nt as w,Y as x,Te as xt,Z as y,Ie as yt,dt as z};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTY Bridge — Node.js subprocess
|
|
3
|
+
*
|
|
4
|
+
* Runs under plain Node.js (not Bun) so it can load the node-pty native addon.
|
|
5
|
+
* Speaks newline-delimited JSON-RPC over stdin/stdout, multiplexing any number
|
|
6
|
+
* of PTY sessions for the Bun host process.
|
|
7
|
+
*
|
|
8
|
+
* Protocol (stdin, Bun → bridge):
|
|
9
|
+
* { "id": <number>, "cmd": "spawn", "file": <string>, "args": <string[]>,
|
|
10
|
+
* "options": { "cwd"?: <string>, "name"?: <string>, "cols"?: <number>,
|
|
11
|
+
* "rows"?: <number>, "env"?: <Record<string,string>>,
|
|
12
|
+
* "inheritEnvironment"?: <boolean> } }
|
|
13
|
+
* { "id": <number>, "cmd": "input", "ptyId": <number>, "data": <UTF-8 base64> }
|
|
14
|
+
* { "id": <number>, "cmd": "resize", "ptyId": <number>, "cols": <number>, "rows": <number> }
|
|
15
|
+
* { "id": <number>, "cmd": "kill", "ptyId": <number>, "signal"?: <string> }
|
|
16
|
+
*
|
|
17
|
+
* Protocol (stdout, bridge → Bun):
|
|
18
|
+
* { "id": <number>, "ptyId": <number>, "event": "spawned", "pid": <number>, "process": <string> }
|
|
19
|
+
* { "ptyId": <number>, "event": "data", "data": <UTF-8 base64> }
|
|
20
|
+
* { "ptyId": <number>, "event": "exit", "exitCode": <number>, "signal": <number> }
|
|
21
|
+
* { "id": <number>, "event": "error", "message": <string> }
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
const pty = require('node-pty');
|
|
27
|
+
const readline = require('readline');
|
|
28
|
+
|
|
29
|
+
/** @type {Map<number, import('node-pty').IPty>} */
|
|
30
|
+
const sessions = new Map();
|
|
31
|
+
|
|
32
|
+
let nextPtyId = 1;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Emit a JSON-RPC event to the Bun host via stdout.
|
|
36
|
+
* @param {Record<string, unknown>} payload
|
|
37
|
+
* @example
|
|
38
|
+
*/
|
|
39
|
+
function emit(payload) {
|
|
40
|
+
process.stdout.write(JSON.stringify(payload) + '\n');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Log a debug message to stderr (never interferes with the JSON-RPC protocol).
|
|
45
|
+
* @param {string} message
|
|
46
|
+
* @example
|
|
47
|
+
*/
|
|
48
|
+
function debug(message) {
|
|
49
|
+
process.stderr.write(`[pty-bridge] ${message}\n`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Kill and delete all active PTY sessions.
|
|
54
|
+
* @example
|
|
55
|
+
*/
|
|
56
|
+
function disposeAll() {
|
|
57
|
+
for (const [id, proc] of sessions) {
|
|
58
|
+
try {
|
|
59
|
+
proc.kill();
|
|
60
|
+
} catch {
|
|
61
|
+
// Ignore — process may have already exited.
|
|
62
|
+
}
|
|
63
|
+
sessions.delete(id);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Handle a "spawn" command.
|
|
69
|
+
* @param {{ id: number; file: string; args: string[]; options: Record<string, unknown> }} cmd
|
|
70
|
+
* @example
|
|
71
|
+
*/
|
|
72
|
+
function handleSpawn(cmd) {
|
|
73
|
+
const ptyId = nextPtyId++;
|
|
74
|
+
const { id, file, args, options } = cmd;
|
|
75
|
+
const env =
|
|
76
|
+
options.env !== null && typeof options.env === 'object' && !Array.isArray(options.env)
|
|
77
|
+
? /** @type {Record<string, string>} */ (options.env)
|
|
78
|
+
: undefined;
|
|
79
|
+
|
|
80
|
+
/** @type {import('node-pty').IWindowsPtyForkOptions | import('node-pty').IPtyForkOptions} */
|
|
81
|
+
const spawnOptions = {
|
|
82
|
+
name: typeof options.name === 'string' ? options.name : 'xterm-256color',
|
|
83
|
+
cols: typeof options.cols === 'number' ? options.cols : 80,
|
|
84
|
+
rows: typeof options.rows === 'number' ? options.rows : 24,
|
|
85
|
+
cwd: typeof options.cwd === 'string' ? options.cwd : undefined,
|
|
86
|
+
env: options.inheritEnvironment === true && env !== undefined ? { ...process.env, ...env } : env,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
let proc;
|
|
90
|
+
try {
|
|
91
|
+
proc = pty.spawn(file, args, spawnOptions);
|
|
92
|
+
} catch (err) {
|
|
93
|
+
emit({ id, event: 'error', message: err instanceof Error ? err.message : String(err) });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
sessions.set(ptyId, proc);
|
|
98
|
+
debug(`spawned ptyId=${ptyId} pid=${proc.pid} file=${file}`);
|
|
99
|
+
|
|
100
|
+
emit({ id, ptyId, event: 'spawned', pid: proc.pid, process: proc.process });
|
|
101
|
+
|
|
102
|
+
proc.onData((data) => {
|
|
103
|
+
// The backend contract carries terminal output as JavaScript text strings.
|
|
104
|
+
emit({ ptyId, event: 'data', data: Buffer.from(data, 'utf8').toString('base64') });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
proc.onExit(({ exitCode, signal }) => {
|
|
108
|
+
debug(`ptyId=${ptyId} exited exitCode=${exitCode} signal=${signal}`);
|
|
109
|
+
sessions.delete(ptyId);
|
|
110
|
+
emit({ ptyId, event: 'exit', exitCode, signal: signal ?? 0 });
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Handle an "input" command — write base64-decoded data to the PTY.
|
|
116
|
+
* @param {{ id: number; ptyId: number; data: string }} cmd
|
|
117
|
+
* @example
|
|
118
|
+
*/
|
|
119
|
+
function handleInput(cmd) {
|
|
120
|
+
const proc = sessions.get(cmd.ptyId);
|
|
121
|
+
if (!proc) {
|
|
122
|
+
emit({ id: cmd.id, event: 'error', message: `unknown ptyId: ${cmd.ptyId}` });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// Input originates as a JavaScript string, encoded as UTF-8 before base64 transport.
|
|
126
|
+
const decoded = Buffer.from(cmd.data, 'base64').toString('utf8');
|
|
127
|
+
proc.write(decoded);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Handle a "resize" command.
|
|
132
|
+
* @param {{ id: number; ptyId: number; cols: number; rows: number }} cmd
|
|
133
|
+
* @example
|
|
134
|
+
*/
|
|
135
|
+
function handleResize(cmd) {
|
|
136
|
+
const proc = sessions.get(cmd.ptyId);
|
|
137
|
+
if (!proc) {
|
|
138
|
+
emit({ id: cmd.id, event: 'error', message: `unknown ptyId: ${cmd.ptyId}` });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
proc.resize(cmd.cols, cmd.rows);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Handle a "kill" command.
|
|
146
|
+
* @param {{ id: number; ptyId: number; signal?: string }} cmd
|
|
147
|
+
* @example
|
|
148
|
+
*/
|
|
149
|
+
function handleKill(cmd) {
|
|
150
|
+
const proc = sessions.get(cmd.ptyId);
|
|
151
|
+
if (!proc) {
|
|
152
|
+
emit({ id: cmd.id, event: 'error', message: `unknown ptyId: ${cmd.ptyId}` });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
proc.kill(cmd.signal ?? 'SIGHUP');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ── Stdin / readline setup ───────────────────────────────────────────────────
|
|
159
|
+
|
|
160
|
+
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
161
|
+
|
|
162
|
+
rl.on('line', (line) => {
|
|
163
|
+
const trimmed = line.trim();
|
|
164
|
+
if (!trimmed) return;
|
|
165
|
+
|
|
166
|
+
/** @type {Record<string, unknown>} */
|
|
167
|
+
let cmd;
|
|
168
|
+
try {
|
|
169
|
+
cmd = JSON.parse(trimmed);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
debug(`malformed JSON: ${trimmed}`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
switch (cmd.cmd) {
|
|
177
|
+
case 'spawn':
|
|
178
|
+
handleSpawn(/** @type {Parameters<typeof handleSpawn>[0]} */ (cmd));
|
|
179
|
+
break;
|
|
180
|
+
case 'input':
|
|
181
|
+
handleInput(/** @type {Parameters<typeof handleInput>[0]} */ (cmd));
|
|
182
|
+
break;
|
|
183
|
+
case 'resize':
|
|
184
|
+
handleResize(/** @type {Parameters<typeof handleResize>[0]} */ (cmd));
|
|
185
|
+
break;
|
|
186
|
+
case 'kill':
|
|
187
|
+
handleKill(/** @type {Parameters<typeof handleKill>[0]} */ (cmd));
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
debug(`unknown command: ${String(cmd.cmd)}`);
|
|
191
|
+
}
|
|
192
|
+
} catch (err) {
|
|
193
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
194
|
+
debug(`error handling command: ${message}`);
|
|
195
|
+
if (cmd && cmd.id != null) {
|
|
196
|
+
emit({ id: cmd.id, event: 'error', message });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// When the host closes stdin the bridge shuts down cleanly.
|
|
202
|
+
rl.on('close', () => {
|
|
203
|
+
debug('stdin closed — shutting down');
|
|
204
|
+
disposeAll();
|
|
205
|
+
process.exit(0);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// ── Signal handling ──────────────────────────────────────────────────────────
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
*
|
|
212
|
+
* @param signal
|
|
213
|
+
* @example
|
|
214
|
+
*/
|
|
215
|
+
function shutdown(signal) {
|
|
216
|
+
debug(`received ${signal} — shutting down`);
|
|
217
|
+
disposeAll();
|
|
218
|
+
process.exit(0);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
222
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
package/dist/bus/index.d.mts
CHANGED
|
@@ -3961,25 +3961,6 @@ declare const CanonicalModelSelectionSchema: z.ZodObject<{
|
|
|
3961
3961
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3962
3962
|
mcpSessionContext: z.ZodOptional<z.ZodObject<{
|
|
3963
3963
|
sessionId: z.ZodString;
|
|
3964
|
-
directTools: z.ZodArray<z.ZodObject<{
|
|
3965
|
-
fullName: z.ZodString;
|
|
3966
|
-
originalName: z.ZodString;
|
|
3967
|
-
serverName: z.ZodString;
|
|
3968
|
-
description: z.ZodOptional<z.ZodString>;
|
|
3969
|
-
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
3970
|
-
exposureMode: z.ZodEnum<{
|
|
3971
|
-
discovery: "discovery";
|
|
3972
|
-
direct: "direct";
|
|
3973
|
-
hidden: "hidden";
|
|
3974
|
-
}>;
|
|
3975
|
-
enabled: z.ZodBoolean;
|
|
3976
|
-
enabledBy: z.ZodOptional<z.ZodEnum<{
|
|
3977
|
-
discovery: "discovery";
|
|
3978
|
-
toolset: "toolset";
|
|
3979
|
-
}>>;
|
|
3980
|
-
enabledAt: z.ZodOptional<z.ZodNumber>;
|
|
3981
|
-
exposed: z.ZodBoolean;
|
|
3982
|
-
}, z.core.$strip>>;
|
|
3983
3964
|
servers: z.ZodArray<z.ZodObject<{
|
|
3984
3965
|
name: z.ZodString;
|
|
3985
3966
|
transport: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -4016,9 +3997,28 @@ declare const CanonicalModelSelectionSchema: z.ZodObject<{
|
|
|
4016
3997
|
type: z.ZodLiteral<"http">;
|
|
4017
3998
|
}, z.core.$strip>], "type">;
|
|
4018
3999
|
exposureMode: z.ZodEnum<{
|
|
4000
|
+
direct: "direct";
|
|
4019
4001
|
discovery: "discovery";
|
|
4002
|
+
}>;
|
|
4003
|
+
}, z.core.$strip>>;
|
|
4004
|
+
directTools: z.ZodArray<z.ZodObject<{
|
|
4005
|
+
fullName: z.ZodString;
|
|
4006
|
+
originalName: z.ZodString;
|
|
4007
|
+
serverName: z.ZodString;
|
|
4008
|
+
description: z.ZodOptional<z.ZodString>;
|
|
4009
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
4010
|
+
exposureMode: z.ZodEnum<{
|
|
4020
4011
|
direct: "direct";
|
|
4012
|
+
discovery: "discovery";
|
|
4013
|
+
hidden: "hidden";
|
|
4021
4014
|
}>;
|
|
4015
|
+
enabled: z.ZodBoolean;
|
|
4016
|
+
enabledBy: z.ZodOptional<z.ZodEnum<{
|
|
4017
|
+
discovery: "discovery";
|
|
4018
|
+
toolset: "toolset";
|
|
4019
|
+
}>>;
|
|
4020
|
+
enabledAt: z.ZodOptional<z.ZodNumber>;
|
|
4021
|
+
exposed: z.ZodBoolean;
|
|
4022
4022
|
}, z.core.$strip>>;
|
|
4023
4023
|
discoverableTools: z.ZodArray<z.ZodObject<{
|
|
4024
4024
|
fullName: z.ZodString;
|
|
@@ -4027,8 +4027,8 @@ declare const CanonicalModelSelectionSchema: z.ZodObject<{
|
|
|
4027
4027
|
description: z.ZodOptional<z.ZodString>;
|
|
4028
4028
|
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
4029
4029
|
exposureMode: z.ZodEnum<{
|
|
4030
|
-
discovery: "discovery";
|
|
4031
4030
|
direct: "direct";
|
|
4031
|
+
discovery: "discovery";
|
|
4032
4032
|
hidden: "hidden";
|
|
4033
4033
|
}>;
|
|
4034
4034
|
enabled: z.ZodBoolean;
|
package/dist/bus/index.mjs
CHANGED
|
@@ -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-D4DBDaoS.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 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-DgpPEPoM.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};
|