@nextera.one/axis-server-sdk 2.0.0 → 2.1.1

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/index.mjs CHANGED
@@ -39,6 +39,106 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
39
  ));
40
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
41
 
42
+ // src/decorators/chain.decorator.ts
43
+ var chain_decorator_exports = {};
44
+ __export(chain_decorator_exports, {
45
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
46
+ Chain: () => Chain
47
+ });
48
+ import "reflect-metadata";
49
+ function Chain(options = {}) {
50
+ return (target, propertyKey) => {
51
+ const value = {
52
+ enabled: true,
53
+ ...options
54
+ };
55
+ Reflect.defineMetadata(CHAIN_METADATA_KEY, value, target, propertyKey);
56
+ };
57
+ }
58
+ var CHAIN_METADATA_KEY;
59
+ var init_chain_decorator = __esm({
60
+ "src/decorators/chain.decorator.ts"() {
61
+ CHAIN_METADATA_KEY = "axis:chain";
62
+ }
63
+ });
64
+
65
+ // src/decorators/capsule-policy.decorator.ts
66
+ var capsule_policy_decorator_exports = {};
67
+ __export(capsule_policy_decorator_exports, {
68
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
69
+ CapsulePolicy: () => CapsulePolicy,
70
+ mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
71
+ normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
72
+ });
73
+ import "reflect-metadata";
74
+ function CapsulePolicy(options = {}) {
75
+ const normalized = normalizeCapsulePolicyOptions(options);
76
+ return ((target, propertyKey) => {
77
+ if (propertyKey !== void 0) {
78
+ Reflect.defineMetadata(
79
+ CAPSULE_POLICY_METADATA_KEY,
80
+ normalized,
81
+ target,
82
+ propertyKey
83
+ );
84
+ return;
85
+ }
86
+ Reflect.defineMetadata(
87
+ CAPSULE_POLICY_METADATA_KEY,
88
+ normalized,
89
+ target
90
+ );
91
+ });
92
+ }
93
+ function normalizeCapsulePolicyOptions(options = {}) {
94
+ return {
95
+ required: options.required ?? true,
96
+ scopes: normalizeScopeValue(options.scopes),
97
+ scopeMode: options.scopeMode ?? "all",
98
+ intentBound: options.intentBound ?? true,
99
+ allowCapsuleRef: options.allowCapsuleRef ?? false
100
+ };
101
+ }
102
+ function mergeCapsulePolicyOptions(base, override) {
103
+ if (!base && !override) {
104
+ return void 0;
105
+ }
106
+ const normalizedBase = base ? normalizeCapsulePolicyOptions(base) : void 0;
107
+ const normalizedOverride = override ? normalizeCapsulePolicyOptions(override) : void 0;
108
+ const scopes = [
109
+ ...toScopeList(normalizedBase?.scopes),
110
+ ...toScopeList(normalizedOverride?.scopes)
111
+ ];
112
+ return {
113
+ required: normalizedOverride?.required ?? normalizedBase?.required ?? true,
114
+ scopes: normalizeScopeValue(scopes),
115
+ scopeMode: normalizedOverride?.scopeMode ?? normalizedBase?.scopeMode ?? "all",
116
+ intentBound: normalizedOverride?.intentBound ?? normalizedBase?.intentBound ?? true,
117
+ allowCapsuleRef: normalizedOverride?.allowCapsuleRef ?? normalizedBase?.allowCapsuleRef ?? false
118
+ };
119
+ }
120
+ function normalizeScopeValue(value) {
121
+ const list = toScopeList(value);
122
+ if (list.length === 0) {
123
+ return void 0;
124
+ }
125
+ return list.length === 1 ? list[0] : list;
126
+ }
127
+ function toScopeList(value) {
128
+ if (!value) {
129
+ return [];
130
+ }
131
+ return Array.from(new Set(Array.isArray(value) ? value : [value])).filter(
132
+ (entry) => entry.trim().length > 0
133
+ );
134
+ }
135
+ var CAPSULE_POLICY_METADATA_KEY;
136
+ var init_capsule_policy_decorator = __esm({
137
+ "src/decorators/capsule-policy.decorator.ts"() {
138
+ CAPSULE_POLICY_METADATA_KEY = "axis:capsule:policy";
139
+ }
140
+ });
141
+
42
142
  // src/decorators/handler.decorator.ts
43
143
  var handler_decorator_exports = {};
44
144
  __export(handler_decorator_exports, {
@@ -82,6 +182,7 @@ function Intent(action, options) {
82
182
  absolute: options?.absolute,
83
183
  frame: options?.frame,
84
184
  kind: options?.kind,
185
+ chain: options?.chain,
85
186
  bodyProfile: options?.bodyProfile,
86
187
  tlv: options?.tlv,
87
188
  dto: options?.dto
@@ -135,6 +236,73 @@ var init_intent_sensors_decorator = __esm({
135
236
  }
136
237
  });
137
238
 
239
+ // src/decorators/observer.decorator.ts
240
+ var observer_decorator_exports = {};
241
+ __export(observer_decorator_exports, {
242
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
243
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
244
+ Observer: () => Observer
245
+ });
246
+ import "reflect-metadata";
247
+ import { Injectable as Injectable2 } from "@nestjs/common";
248
+ function isBindingOptions(value) {
249
+ return !!value && typeof value === "object" && "use" in value;
250
+ }
251
+ function isDefinitionOptions(value) {
252
+ return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
253
+ }
254
+ function toBinding(input) {
255
+ if (!input) return null;
256
+ if (isBindingOptions(input)) {
257
+ const refs = Array.isArray(input.use) ? input.use : [input.use];
258
+ return { refs, tags: input.tags, events: input.events };
259
+ }
260
+ if (Array.isArray(input)) {
261
+ return { refs: input };
262
+ }
263
+ if (typeof input === "function" || typeof input === "string") {
264
+ return { refs: [input] };
265
+ }
266
+ return null;
267
+ }
268
+ function Observer(input) {
269
+ return ((target, propertyKey) => {
270
+ const binding = toBinding(input);
271
+ if (binding) {
272
+ if (propertyKey !== void 0) {
273
+ const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
274
+ existing2.push(binding);
275
+ Reflect.defineMetadata(
276
+ OBSERVER_BINDINGS_KEY,
277
+ existing2,
278
+ target,
279
+ propertyKey
280
+ );
281
+ return;
282
+ }
283
+ const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
284
+ existing.push(binding);
285
+ Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
286
+ return;
287
+ }
288
+ if (propertyKey !== void 0) {
289
+ throw new Error(
290
+ "@Observer method usage must reference one or more observer classes or names"
291
+ );
292
+ }
293
+ const definition = isDefinitionOptions(input) ? input : {};
294
+ Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
295
+ Injectable2()(target);
296
+ });
297
+ }
298
+ var OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
299
+ var init_observer_decorator = __esm({
300
+ "src/decorators/observer.decorator.ts"() {
301
+ OBSERVER_METADATA_KEY = "axis:observer";
302
+ OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
303
+ }
304
+ });
305
+
138
306
  // src/decorators/handler-sensors.decorator.ts
139
307
  var handler_sensors_decorator_exports = {};
140
308
  __export(handler_sensors_decorator_exports, {
@@ -488,113 +656,308 @@ var require_axis_response_dto = __commonJS({
488
656
  }
489
657
  });
490
658
 
491
- // src/sensor/axis-sensor.ts
492
- var axis_sensor_exports = {};
493
- __export(axis_sensor_exports, {
494
- Decision: () => Decision,
495
- SensorDecisions: () => SensorDecisions,
496
- normalizeSensorDecision: () => normalizeSensorDecision
659
+ // src/core/constants.ts
660
+ var constants_exports = {};
661
+ __export(constants_exports, {
662
+ AXIS_MAGIC: () => AXIS_MAGIC,
663
+ AXIS_VERSION: () => AXIS_VERSION,
664
+ BodyProfile: () => BodyProfile,
665
+ ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
666
+ ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
667
+ ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
668
+ ERR_REPLAY_DETECTED: () => ERR_REPLAY_DETECTED,
669
+ FLAG_BODY_TLV: () => FLAG_BODY_TLV,
670
+ FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
671
+ FLAG_HAS_WITNESS: () => FLAG_HAS_WITNESS,
672
+ MAX_BODY_LEN: () => MAX_BODY_LEN,
673
+ MAX_FRAME_LEN: () => MAX_FRAME_LEN,
674
+ MAX_HDR_LEN: () => MAX_HDR_LEN,
675
+ MAX_SIG_LEN: () => MAX_SIG_LEN,
676
+ NCERT_ALG: () => NCERT_ALG,
677
+ NCERT_EXP: () => NCERT_EXP,
678
+ NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
679
+ NCERT_KID: () => NCERT_KID,
680
+ NCERT_NBF: () => NCERT_NBF,
681
+ NCERT_NODE_ID: () => NCERT_NODE_ID,
682
+ NCERT_PAYLOAD: () => NCERT_PAYLOAD,
683
+ NCERT_PUB: () => NCERT_PUB,
684
+ NCERT_SCOPE: () => NCERT_SCOPE,
685
+ NCERT_SIG: () => NCERT_SIG,
686
+ PROOF_CAPSULE: () => PROOF_CAPSULE,
687
+ PROOF_JWT: () => PROOF_JWT,
688
+ PROOF_LOOM: () => PROOF_LOOM,
689
+ PROOF_MTLS: () => PROOF_MTLS,
690
+ PROOF_NONE: () => PROOF_NONE,
691
+ PROOF_WITNESS: () => PROOF_WITNESS,
692
+ ProofType: () => ProofType,
693
+ TLV_ACTOR_ID: () => TLV_ACTOR_ID,
694
+ TLV_AUD: () => TLV_AUD,
695
+ TLV_BODY_ARR: () => TLV_BODY_ARR,
696
+ TLV_BODY_OBJ: () => TLV_BODY_OBJ,
697
+ TLV_CAPSULE: () => TLV_CAPSULE,
698
+ TLV_EFFECT: () => TLV_EFFECT,
699
+ TLV_ERROR_CODE: () => TLV_ERROR_CODE,
700
+ TLV_ERROR_MSG: () => TLV_ERROR_MSG,
701
+ TLV_INDEX: () => TLV_INDEX,
702
+ TLV_INTENT: () => TLV_INTENT,
703
+ TLV_KID: () => TLV_KID,
704
+ TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
705
+ TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
706
+ TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
707
+ TLV_NODE: () => TLV_NODE,
708
+ TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
709
+ TLV_NODE_KID: () => TLV_NODE_KID,
710
+ TLV_NONCE: () => TLV_NONCE,
711
+ TLV_OFFSET: () => TLV_OFFSET,
712
+ TLV_OK: () => TLV_OK,
713
+ TLV_PID: () => TLV_PID,
714
+ TLV_PREV_HASH: () => TLV_PREV_HASH,
715
+ TLV_PROOF_REF: () => TLV_PROOF_REF,
716
+ TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
717
+ TLV_REALM: () => TLV_REALM,
718
+ TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
719
+ TLV_RID: () => TLV_RID,
720
+ TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
721
+ TLV_TRACE_ID: () => TLV_TRACE_ID,
722
+ TLV_TS: () => TLV_TS,
723
+ TLV_UPLOAD_ID: () => TLV_UPLOAD_ID
497
724
  });
498
- function normalizeSensorDecision(sensorDecision) {
499
- if ("action" in sensorDecision) {
500
- switch (sensorDecision.action) {
501
- case "ALLOW":
502
- return {
503
- allow: true,
504
- riskScore: 0,
505
- reasons: [],
506
- meta: sensorDecision.meta
507
- };
508
- case "DENY":
509
- return {
510
- allow: false,
511
- riskScore: 100,
512
- reasons: [sensorDecision.code, sensorDecision.reason].filter(
513
- Boolean
514
- ),
515
- meta: sensorDecision.meta,
516
- retryAfterMs: sensorDecision.retryAfterMs
517
- };
518
- case "THROTTLE":
519
- return {
520
- allow: false,
521
- riskScore: 50,
522
- reasons: ["RATE_LIMIT"],
523
- retryAfterMs: sensorDecision.retryAfterMs,
524
- meta: sensorDecision.meta
525
- };
526
- case "FLAG":
527
- return {
528
- allow: true,
529
- riskScore: sensorDecision.scoreDelta,
530
- reasons: sensorDecision.reasons,
531
- meta: sensorDecision.meta
532
- };
533
- }
725
+ import {
726
+ AXIS_MAGIC,
727
+ AXIS_VERSION,
728
+ MAX_HDR_LEN,
729
+ MAX_BODY_LEN,
730
+ MAX_SIG_LEN,
731
+ MAX_FRAME_LEN,
732
+ FLAG_BODY_TLV,
733
+ FLAG_CHAIN_REQ,
734
+ FLAG_HAS_WITNESS,
735
+ TLV_PID,
736
+ TLV_TS,
737
+ TLV_INTENT,
738
+ TLV_ACTOR_ID,
739
+ TLV_PROOF_TYPE,
740
+ TLV_PROOF_REF,
741
+ TLV_NONCE,
742
+ TLV_AUD,
743
+ TLV_REALM,
744
+ TLV_NODE,
745
+ TLV_TRACE_ID,
746
+ TLV_KID,
747
+ TLV_RID,
748
+ TLV_OK,
749
+ TLV_EFFECT,
750
+ TLV_ERROR_CODE,
751
+ TLV_ERROR_MSG,
752
+ TLV_PREV_HASH,
753
+ TLV_RECEIPT_HASH,
754
+ TLV_NODE_KID,
755
+ TLV_NODE_CERT_HASH,
756
+ TLV_LOOM_PRESENCE_ID,
757
+ TLV_LOOM_WRIT,
758
+ TLV_LOOM_THREAD_HASH,
759
+ TLV_UPLOAD_ID,
760
+ TLV_INDEX,
761
+ TLV_OFFSET,
762
+ TLV_SHA256_CHUNK,
763
+ TLV_CAPSULE,
764
+ TLV_BODY_OBJ,
765
+ TLV_BODY_ARR,
766
+ NCERT_NODE_ID,
767
+ NCERT_KID,
768
+ NCERT_ALG,
769
+ NCERT_PUB,
770
+ NCERT_NBF,
771
+ NCERT_EXP,
772
+ NCERT_SCOPE,
773
+ NCERT_ISSUER_KID,
774
+ NCERT_PAYLOAD,
775
+ NCERT_SIG,
776
+ PROOF_NONE,
777
+ PROOF_CAPSULE,
778
+ PROOF_JWT,
779
+ PROOF_MTLS,
780
+ PROOF_LOOM,
781
+ PROOF_WITNESS,
782
+ ProofType,
783
+ BodyProfile,
784
+ ERR_INVALID_PACKET,
785
+ ERR_BAD_SIGNATURE,
786
+ ERR_REPLAY_DETECTED,
787
+ ERR_CONTRACT_VIOLATION
788
+ } from "@nextera.one/axis-protocol";
789
+ var init_constants = __esm({
790
+ "src/core/constants.ts"() {
791
+ }
792
+ });
793
+
794
+ // src/engine/axis-execution-context.ts
795
+ var axis_execution_context_exports = {};
796
+ __export(axis_execution_context_exports, {
797
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
798
+ getAxisExecutionContext: () => getAxisExecutionContext,
799
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
800
+ withAxisExecutionContext: () => withAxisExecutionContext
801
+ });
802
+ function getAxisExecutionContext(frame) {
803
+ return frame?.[AXIS_EXECUTION_CONTEXT_KEY];
804
+ }
805
+ function withAxisExecutionContext(target, context) {
806
+ Object.defineProperty(target, AXIS_EXECUTION_CONTEXT_KEY, {
807
+ value: context,
808
+ writable: true,
809
+ configurable: true,
810
+ enumerable: false
811
+ });
812
+ return target;
813
+ }
814
+ function mergeAxisExecutionContext(base, override) {
815
+ if (!base && !override) {
816
+ return void 0;
534
817
  }
535
818
  return {
536
- allow: sensorDecision.allow,
537
- riskScore: sensorDecision.riskScore,
538
- reasons: sensorDecision.reasons,
539
- tags: sensorDecision.tags,
540
- meta: sensorDecision.meta,
541
- tighten: sensorDecision.tighten,
542
- retryAfterMs: sensorDecision.retryAfterMs
819
+ ...base,
820
+ ...override,
821
+ capsuleRef: {
822
+ ...base?.capsuleRef || {},
823
+ ...override?.capsuleRef || {}
824
+ }
543
825
  };
544
826
  }
545
- var Decision, SensorDecisions;
546
- var init_axis_sensor = __esm({
547
- "src/sensor/axis-sensor.ts"() {
548
- Decision = /* @__PURE__ */ ((Decision2) => {
549
- Decision2["ALLOW"] = "ALLOW";
550
- Decision2["DENY"] = "DENY";
551
- Decision2["THROTTLE"] = "THROTTLE";
552
- Decision2["FLAG"] = "FLAG";
553
- return Decision2;
554
- })(Decision || {});
555
- SensorDecisions = {
556
- allow(meta, tags) {
557
- return {
558
- decision: "ALLOW" /* ALLOW */,
559
- allow: true,
560
- riskScore: 0,
561
- reasons: [],
562
- tags,
563
- meta
564
- };
565
- },
566
- deny(code, reason, meta) {
567
- return {
568
- decision: "DENY" /* DENY */,
569
- allow: false,
570
- riskScore: 100,
571
- code,
572
- reasons: [code, reason].filter(Boolean),
573
- meta
574
- };
575
- },
576
- throttle(retryAfterMs, meta) {
577
- return {
578
- decision: "THROTTLE" /* THROTTLE */,
579
- allow: false,
580
- riskScore: 50,
581
- retryAfterMs,
582
- code: "RATE_LIMIT",
583
- reasons: ["RATE_LIMIT"],
584
- meta
585
- };
586
- },
587
- flag(scoreDelta, reasons, meta) {
588
- return {
589
- decision: "FLAG" /* FLAG */,
590
- allow: true,
591
- riskScore: scoreDelta,
592
- scoreDelta,
593
- reasons,
594
- meta
827
+ var AXIS_EXECUTION_CONTEXT_KEY;
828
+ var init_axis_execution_context = __esm({
829
+ "src/engine/axis-execution-context.ts"() {
830
+ AXIS_EXECUTION_CONTEXT_KEY = /* @__PURE__ */ Symbol.for("axis.executionContext");
831
+ }
832
+ });
833
+
834
+ // src/engine/registry/observer.registry.ts
835
+ var require_observer_registry = __commonJS({
836
+ "src/engine/registry/observer.registry.ts"(exports) {
837
+ "use strict";
838
+ var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
839
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
840
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
841
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
842
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
843
+ };
844
+ var ObserverRegistry_1;
845
+ Object.defineProperty(exports, "__esModule", { value: true });
846
+ exports.ObserverRegistry = void 0;
847
+ var common_1 = __require("@nestjs/common");
848
+ var ObserverRegistry2 = ObserverRegistry_1 = class ObserverRegistry {
849
+ constructor() {
850
+ this.logger = new common_1.Logger(ObserverRegistry_1.name);
851
+ this.byName = /* @__PURE__ */ new Map();
852
+ this.byType = /* @__PURE__ */ new Map();
853
+ }
854
+ register(instance, meta = {}) {
855
+ const name = meta.name || instance.name || instance.constructor.name;
856
+ const registration = {
857
+ name,
858
+ instance,
859
+ tags: meta.tags || [],
860
+ events: meta.events,
861
+ intents: meta.intents,
862
+ handlers: meta.handlers
595
863
  };
864
+ this.byName.set(name, registration);
865
+ this.byType.set(instance.constructor, registration);
866
+ this.logger.debug(`Registered observer: ${name}`);
867
+ }
868
+ resolve(ref) {
869
+ if (typeof ref === "string") {
870
+ return this.byName.get(ref);
871
+ }
872
+ return this.byType.get(ref) || this.byName.get(ref.name);
873
+ }
874
+ list() {
875
+ return Array.from(this.byName.values()).sort((left, right) => left.name.localeCompare(right.name));
876
+ }
877
+ clear() {
878
+ this.byName.clear();
879
+ this.byType.clear();
880
+ }
881
+ };
882
+ exports.ObserverRegistry = ObserverRegistry2;
883
+ exports.ObserverRegistry = ObserverRegistry2 = ObserverRegistry_1 = __decorate([
884
+ (0, common_1.Injectable)()
885
+ ], ObserverRegistry2);
886
+ }
887
+ });
888
+
889
+ // src/engine/observer-dispatcher.service.ts
890
+ var require_observer_dispatcher_service = __commonJS({
891
+ "src/engine/observer-dispatcher.service.ts"(exports) {
892
+ "use strict";
893
+ var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
894
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
895
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
896
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
897
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
898
+ };
899
+ var __metadata = exports && exports.__metadata || function(k, v) {
900
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
901
+ };
902
+ var ObserverDispatcherService_1;
903
+ var _a;
904
+ Object.defineProperty(exports, "__esModule", { value: true });
905
+ exports.ObserverDispatcherService = void 0;
906
+ var common_1 = __require("@nestjs/common");
907
+ var observer_registry_1 = require_observer_registry();
908
+ function unique(values) {
909
+ return Array.from(new Set(values));
910
+ }
911
+ var ObserverDispatcherService2 = ObserverDispatcherService_1 = class ObserverDispatcherService {
912
+ constructor(registry) {
913
+ this.registry = registry;
914
+ this.logger = new common_1.Logger(ObserverDispatcherService_1.name);
915
+ }
916
+ async dispatch(bindings, context) {
917
+ if (!bindings || bindings.length === 0)
918
+ return;
919
+ const invoked = /* @__PURE__ */ new Set();
920
+ for (const binding of bindings) {
921
+ if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
922
+ continue;
923
+ }
924
+ for (const ref of binding.refs) {
925
+ const registration = this.registry.resolve(ref);
926
+ if (!registration) {
927
+ this.logger.warn(`Observer ${String(ref)} could not be resolved`);
928
+ continue;
929
+ }
930
+ if (invoked.has(registration.name))
931
+ continue;
932
+ if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
933
+ continue;
934
+ }
935
+ const observerContext = {
936
+ ...context,
937
+ observerTags: unique([
938
+ ...registration.tags || [],
939
+ ...binding.tags || [],
940
+ ...context.observerTags || []
941
+ ])
942
+ };
943
+ if (registration.instance.supports && !registration.instance.supports(observerContext)) {
944
+ continue;
945
+ }
946
+ try {
947
+ invoked.add(registration.name);
948
+ await registration.instance.observe(observerContext);
949
+ } catch (error) {
950
+ this.logger.warn(`Observer ${registration.name} failed during ${context.event}: ${error.message}`);
951
+ }
952
+ }
953
+ }
596
954
  }
597
955
  };
956
+ exports.ObserverDispatcherService = ObserverDispatcherService2;
957
+ exports.ObserverDispatcherService = ObserverDispatcherService2 = ObserverDispatcherService_1 = __decorate([
958
+ (0, common_1.Injectable)(),
959
+ __metadata("design:paramtypes", [typeof (_a = typeof observer_registry_1.ObserverRegistry !== "undefined" && observer_registry_1.ObserverRegistry) === "function" ? _a : Object])
960
+ ], ObserverDispatcherService2);
598
961
  }
599
962
  });
600
963
 
@@ -1072,6 +1435,116 @@ var init_cce_witness_observer = __esm({
1072
1435
  }
1073
1436
  });
1074
1437
 
1438
+ // src/sensor/axis-sensor.ts
1439
+ var axis_sensor_exports = {};
1440
+ __export(axis_sensor_exports, {
1441
+ Decision: () => Decision,
1442
+ SensorDecisions: () => SensorDecisions,
1443
+ normalizeSensorDecision: () => normalizeSensorDecision
1444
+ });
1445
+ function normalizeSensorDecision(sensorDecision) {
1446
+ if ("action" in sensorDecision) {
1447
+ switch (sensorDecision.action) {
1448
+ case "ALLOW":
1449
+ return {
1450
+ allow: true,
1451
+ riskScore: 0,
1452
+ reasons: [],
1453
+ meta: sensorDecision.meta
1454
+ };
1455
+ case "DENY":
1456
+ return {
1457
+ allow: false,
1458
+ riskScore: 100,
1459
+ reasons: [sensorDecision.code, sensorDecision.reason].filter(
1460
+ Boolean
1461
+ ),
1462
+ meta: sensorDecision.meta,
1463
+ retryAfterMs: sensorDecision.retryAfterMs
1464
+ };
1465
+ case "THROTTLE":
1466
+ return {
1467
+ allow: false,
1468
+ riskScore: 50,
1469
+ reasons: ["RATE_LIMIT"],
1470
+ retryAfterMs: sensorDecision.retryAfterMs,
1471
+ meta: sensorDecision.meta
1472
+ };
1473
+ case "FLAG":
1474
+ return {
1475
+ allow: true,
1476
+ riskScore: sensorDecision.scoreDelta,
1477
+ reasons: sensorDecision.reasons,
1478
+ meta: sensorDecision.meta
1479
+ };
1480
+ }
1481
+ }
1482
+ return {
1483
+ allow: sensorDecision.allow,
1484
+ riskScore: sensorDecision.riskScore,
1485
+ reasons: sensorDecision.reasons,
1486
+ tags: sensorDecision.tags,
1487
+ meta: sensorDecision.meta,
1488
+ tighten: sensorDecision.tighten,
1489
+ retryAfterMs: sensorDecision.retryAfterMs
1490
+ };
1491
+ }
1492
+ var Decision, SensorDecisions;
1493
+ var init_axis_sensor = __esm({
1494
+ "src/sensor/axis-sensor.ts"() {
1495
+ Decision = /* @__PURE__ */ ((Decision2) => {
1496
+ Decision2["ALLOW"] = "ALLOW";
1497
+ Decision2["DENY"] = "DENY";
1498
+ Decision2["THROTTLE"] = "THROTTLE";
1499
+ Decision2["FLAG"] = "FLAG";
1500
+ return Decision2;
1501
+ })(Decision || {});
1502
+ SensorDecisions = {
1503
+ allow(meta, tags) {
1504
+ return {
1505
+ decision: "ALLOW" /* ALLOW */,
1506
+ allow: true,
1507
+ riskScore: 0,
1508
+ reasons: [],
1509
+ tags,
1510
+ meta
1511
+ };
1512
+ },
1513
+ deny(code, reason, meta) {
1514
+ return {
1515
+ decision: "DENY" /* DENY */,
1516
+ allow: false,
1517
+ riskScore: 100,
1518
+ code,
1519
+ reasons: [code, reason].filter(Boolean),
1520
+ meta
1521
+ };
1522
+ },
1523
+ throttle(retryAfterMs, meta) {
1524
+ return {
1525
+ decision: "THROTTLE" /* THROTTLE */,
1526
+ allow: false,
1527
+ riskScore: 50,
1528
+ retryAfterMs,
1529
+ code: "RATE_LIMIT",
1530
+ reasons: ["RATE_LIMIT"],
1531
+ meta
1532
+ };
1533
+ },
1534
+ flag(scoreDelta, reasons, meta) {
1535
+ return {
1536
+ decision: "FLAG" /* FLAG */,
1537
+ allow: true,
1538
+ riskScore: scoreDelta,
1539
+ scoreDelta,
1540
+ reasons,
1541
+ meta
1542
+ };
1543
+ }
1544
+ };
1545
+ }
1546
+ });
1547
+
1075
1548
  // src/cce/cce-pipeline.ts
1076
1549
  var cce_pipeline_exports = {};
1077
1550
  __export(cce_pipeline_exports, {
@@ -1304,51 +1777,330 @@ var init_cce_pipeline = __esm({
1304
1777
  }
1305
1778
  });
1306
1779
 
1307
- // src/engine/intent.router.ts
1308
- var require_intent_router = __commonJS({
1309
- "src/engine/intent.router.ts"(exports) {
1310
- "use strict";
1311
- var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
1312
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1313
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1314
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1315
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1316
- };
1317
- var __metadata = exports && exports.__metadata || function(k, v) {
1318
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1319
- };
1320
- var __param = exports && exports.__param || function(paramIndex, decorator) {
1321
- return function(target, key) {
1322
- decorator(target, key, paramIndex);
1323
- };
1780
+ // src/core/axis-error.ts
1781
+ var axis_error_exports = {};
1782
+ __export(axis_error_exports, {
1783
+ AxisError: () => AxisError
1784
+ });
1785
+ var AxisError;
1786
+ var init_axis_error = __esm({
1787
+ "src/core/axis-error.ts"() {
1788
+ AxisError = class extends Error {
1789
+ constructor(code, message, httpStatus = 400, details) {
1790
+ super(message);
1791
+ this.code = code;
1792
+ this.httpStatus = httpStatus;
1793
+ this.details = details;
1794
+ this.name = "AxisError";
1795
+ }
1324
1796
  };
1325
- var IntentRouter_1;
1326
- var _a;
1327
- Object.defineProperty(exports, "__esModule", { value: true });
1328
- exports.IntentRouter = void 0;
1329
- var common_1 = __require("@nestjs/common");
1330
- var core_1 = __require("@nestjs/core");
1331
- var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
1332
- var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
1333
- var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
1334
- var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
1335
- var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
1336
- var dto_schema_util_1 = require_dto_schema_util();
1337
- var axis_sensor_1 = (init_axis_sensor(), __toCommonJS(axis_sensor_exports));
1338
- var cce_pipeline_1 = (init_cce_pipeline(), __toCommonJS(cce_pipeline_exports));
1339
- var IntentRouter2 = IntentRouter_1 = class IntentRouter {
1340
- constructor(moduleRef) {
1341
- this.moduleRef = moduleRef;
1797
+ }
1798
+ });
1799
+
1800
+ // src/security/scopes.ts
1801
+ function hasScope(scopes, required) {
1802
+ if (!Array.isArray(scopes) || scopes.length === 0) {
1803
+ return false;
1804
+ }
1805
+ if (scopes.includes(required)) {
1806
+ return true;
1807
+ }
1808
+ const [resource, id] = required.split(":");
1809
+ if (resource && id) {
1810
+ const wildcard = `${resource}:*`;
1811
+ if (scopes.includes(wildcard)) {
1812
+ return true;
1813
+ }
1814
+ }
1815
+ return false;
1816
+ }
1817
+ function parseScope(scope) {
1818
+ const parts = scope.split(":");
1819
+ if (parts.length !== 2) return null;
1820
+ return { resource: parts[0], id: parts[1] };
1821
+ }
1822
+ function canAccessResource(scopes, resourceType, resourceId) {
1823
+ const required = `${resourceType}:${resourceId}`;
1824
+ return hasScope(scopes, required);
1825
+ }
1826
+ var init_scopes = __esm({
1827
+ "src/security/scopes.ts"() {
1828
+ }
1829
+ });
1830
+
1831
+ // src/security/inline-capsule.ts
1832
+ var inline_capsule_exports = {};
1833
+ __export(inline_capsule_exports, {
1834
+ inlineCapsuleAllowsIntent: () => inlineCapsuleAllowsIntent,
1835
+ inlineCapsuleSatisfiesScopes: () => inlineCapsuleSatisfiesScopes,
1836
+ isInlineCapsuleExpired: () => isInlineCapsuleExpired,
1837
+ normalizeInlineCapsule: () => normalizeInlineCapsule,
1838
+ resolvePolicyScopes: () => resolvePolicyScopes
1839
+ });
1840
+ function normalizeInlineCapsule(input) {
1841
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
1842
+ return null;
1843
+ }
1844
+ const raw = input;
1845
+ const scopes = normalizeStringList(raw.scopes ?? raw.scope);
1846
+ return {
1847
+ id: normalizeScalar(raw.id),
1848
+ actorId: normalizeScalar(raw.actorId),
1849
+ intents: normalizeStringList(raw.intents),
1850
+ issuedAt: normalizeTimestamp(raw.issuedAt ?? raw.iat),
1851
+ expiresAt: normalizeTimestamp(raw.expiresAt ?? raw.exp),
1852
+ realm: normalizeScalar(raw.realm),
1853
+ node: normalizeScalar(raw.node),
1854
+ scopes,
1855
+ raw
1856
+ };
1857
+ }
1858
+ function inlineCapsuleAllowsIntent(capsule, intent) {
1859
+ if (!capsule.intents || capsule.intents.length === 0) {
1860
+ return false;
1861
+ }
1862
+ for (const pattern of capsule.intents) {
1863
+ if (pattern === "*" || pattern === intent) {
1864
+ return true;
1865
+ }
1866
+ if (pattern.endsWith(".*")) {
1867
+ const prefix = pattern.slice(0, -1);
1868
+ if (intent.startsWith(prefix)) {
1869
+ return true;
1870
+ }
1871
+ }
1872
+ }
1873
+ return false;
1874
+ }
1875
+ function isInlineCapsuleExpired(capsule, clockSkewMs = 3e4) {
1876
+ if (capsule.expiresAt === void 0) {
1877
+ return false;
1878
+ }
1879
+ return BigInt(Date.now()) > capsule.expiresAt + BigInt(clockSkewMs);
1880
+ }
1881
+ function resolvePolicyScopes(scopes, context) {
1882
+ return scopes.map(
1883
+ (scope) => scope.replace(/\$\{([^}]+)\}/g, (_match, expression) => {
1884
+ const resolved = resolveTemplateExpression(expression.trim(), context);
1885
+ if (resolved === void 0 || resolved === null || resolved === "") {
1886
+ throw new Error(`CAPSULE_SCOPE_TEMPLATE_UNRESOLVED:${expression}`);
1887
+ }
1888
+ return String(resolved);
1889
+ })
1890
+ );
1891
+ }
1892
+ function inlineCapsuleSatisfiesScopes(capsule, requiredScopes, mode = "all") {
1893
+ if (!capsule.scopes || capsule.scopes.length === 0) {
1894
+ return false;
1895
+ }
1896
+ if (mode === "any") {
1897
+ return requiredScopes.some((scope) => hasScope(capsule.scopes, scope));
1898
+ }
1899
+ return requiredScopes.every((scope) => hasScope(capsule.scopes, scope));
1900
+ }
1901
+ function resolveTemplateExpression(expression, context) {
1902
+ if (expression === "intent") {
1903
+ return context.intent;
1904
+ }
1905
+ if (expression === "actorId") {
1906
+ return context.actorId;
1907
+ }
1908
+ if (expression === "chainId") {
1909
+ return context.chainId;
1910
+ }
1911
+ if (expression === "stepId") {
1912
+ return context.stepId;
1913
+ }
1914
+ if (expression.startsWith("body.")) {
1915
+ return getNestedValue(context.body, expression.slice(5));
1916
+ }
1917
+ return void 0;
1918
+ }
1919
+ function getNestedValue(value, path2) {
1920
+ if (!value || typeof value !== "object") {
1921
+ return void 0;
1922
+ }
1923
+ return path2.split(".").reduce((current, segment) => {
1924
+ if (!current || typeof current !== "object") {
1925
+ return void 0;
1926
+ }
1927
+ return current[segment];
1928
+ }, value);
1929
+ }
1930
+ function normalizeScalar(value) {
1931
+ if (typeof value === "string") {
1932
+ return value;
1933
+ }
1934
+ if (value instanceof Uint8Array) {
1935
+ return Buffer.from(value).toString("hex");
1936
+ }
1937
+ return void 0;
1938
+ }
1939
+ function normalizeStringList(value) {
1940
+ if (!value) {
1941
+ return void 0;
1942
+ }
1943
+ const list = Array.isArray(value) ? value : [value];
1944
+ const normalized = list.map((entry) => typeof entry === "string" ? entry : void 0).filter((entry) => !!entry && entry.trim().length > 0);
1945
+ return normalized.length > 0 ? Array.from(new Set(normalized)) : void 0;
1946
+ }
1947
+ function normalizeTimestamp(value) {
1948
+ if (typeof value === "bigint") {
1949
+ return value;
1950
+ }
1951
+ if (typeof value === "number" && Number.isFinite(value)) {
1952
+ return BigInt(Math.trunc(value));
1953
+ }
1954
+ if (typeof value === "string" && value.trim().length > 0) {
1955
+ try {
1956
+ return BigInt(value);
1957
+ } catch {
1958
+ return void 0;
1959
+ }
1960
+ }
1961
+ return void 0;
1962
+ }
1963
+ var init_inline_capsule = __esm({
1964
+ "src/security/inline-capsule.ts"() {
1965
+ init_scopes();
1966
+ }
1967
+ });
1968
+
1969
+ // src/engine/intent.router.ts
1970
+ var require_intent_router = __commonJS({
1971
+ "src/engine/intent.router.ts"(exports) {
1972
+ "use strict";
1973
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
1974
+ if (k2 === void 0) k2 = k;
1975
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1976
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1977
+ desc = { enumerable: true, get: function() {
1978
+ return m[k];
1979
+ } };
1980
+ }
1981
+ Object.defineProperty(o, k2, desc);
1982
+ }) : (function(o, m, k, k2) {
1983
+ if (k2 === void 0) k2 = k;
1984
+ o[k2] = m[k];
1985
+ }));
1986
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
1987
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1988
+ }) : function(o, v) {
1989
+ o["default"] = v;
1990
+ });
1991
+ var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
1992
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1993
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1994
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1995
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1996
+ };
1997
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
1998
+ var ownKeys = function(o) {
1999
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
2000
+ var ar = [];
2001
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
2002
+ return ar;
2003
+ };
2004
+ return ownKeys(o);
2005
+ };
2006
+ return function(mod) {
2007
+ if (mod && mod.__esModule) return mod;
2008
+ var result = {};
2009
+ if (mod != null) {
2010
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2011
+ }
2012
+ __setModuleDefault(result, mod);
2013
+ return result;
2014
+ };
2015
+ })();
2016
+ var __metadata = exports && exports.__metadata || function(k, v) {
2017
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2018
+ };
2019
+ var __param = exports && exports.__param || function(paramIndex, decorator) {
2020
+ return function(target, key) {
2021
+ decorator(target, key, paramIndex);
2022
+ };
2023
+ };
2024
+ var IntentRouter_1;
2025
+ var _a;
2026
+ var _b;
2027
+ Object.defineProperty(exports, "__esModule", { value: true });
2028
+ exports.IntentRouter = void 0;
2029
+ var common_1 = __require("@nestjs/common");
2030
+ var core_1 = __require("@nestjs/core");
2031
+ var axis_protocol_1 = __require("@nextera.one/axis-protocol");
2032
+ var cce_pipeline_1 = (init_cce_pipeline(), __toCommonJS(cce_pipeline_exports));
2033
+ var axis_error_1 = (init_axis_error(), __toCommonJS(axis_error_exports));
2034
+ var constants_1 = (init_constants(), __toCommonJS(constants_exports));
2035
+ var capsule_policy_decorator_1 = (init_capsule_policy_decorator(), __toCommonJS(capsule_policy_decorator_exports));
2036
+ var chain_decorator_1 = (init_chain_decorator(), __toCommonJS(chain_decorator_exports));
2037
+ var dto_schema_util_1 = require_dto_schema_util();
2038
+ var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
2039
+ var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
2040
+ var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
2041
+ var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
2042
+ var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
2043
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
2044
+ var inline_capsule_1 = (init_inline_capsule(), __toCommonJS(inline_capsule_exports));
2045
+ var axis_sensor_1 = (init_axis_sensor(), __toCommonJS(axis_sensor_exports));
2046
+ var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
2047
+ var observer_dispatcher_service_1 = require_observer_dispatcher_service();
2048
+ function observerRefKey(ref) {
2049
+ return typeof ref === "string" ? ref : ref.name;
2050
+ }
2051
+ function mergeObserverBindings(bindings) {
2052
+ const merged = /* @__PURE__ */ new Map();
2053
+ for (const binding of bindings) {
2054
+ for (const ref of binding.refs) {
2055
+ const key = observerRefKey(ref);
2056
+ const existing = merged.get(key);
2057
+ if (!existing) {
2058
+ merged.set(key, {
2059
+ refs: [ref],
2060
+ tags: binding.tags ? [...new Set(binding.tags)] : void 0,
2061
+ events: binding.events ? [...new Set(binding.events)] : void 0
2062
+ });
2063
+ continue;
2064
+ }
2065
+ existing.tags = Array.from(/* @__PURE__ */ new Set([...existing.tags || [], ...binding.tags || []]));
2066
+ existing.events = existing.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...existing.events, ...binding.events]));
2067
+ }
2068
+ }
2069
+ return Array.from(merged.values());
2070
+ }
2071
+ function normalizeChainConfig(decoratorConfig, intentConfig) {
2072
+ if (decoratorConfig) {
2073
+ return decoratorConfig;
2074
+ }
2075
+ if (!intentConfig) {
2076
+ return void 0;
2077
+ }
2078
+ if (intentConfig === true) {
2079
+ return { enabled: true };
2080
+ }
2081
+ return {
2082
+ enabled: true,
2083
+ ...intentConfig
2084
+ };
2085
+ }
2086
+ var IntentRouter2 = IntentRouter_1 = class IntentRouter {
2087
+ constructor(moduleRef, observerDispatcher) {
2088
+ this.moduleRef = moduleRef;
2089
+ this.observerDispatcher = observerDispatcher;
1342
2090
  this.logger = new common_1.Logger(IntentRouter_1.name);
2091
+ this.decoder = new TextDecoder();
2092
+ this.encoder = new TextEncoder();
1343
2093
  this.handlers = /* @__PURE__ */ new Map();
1344
2094
  this.intentSensors = /* @__PURE__ */ new Map();
1345
2095
  this.intentDecoders = /* @__PURE__ */ new Map();
1346
2096
  this.intentSchemas = /* @__PURE__ */ new Map();
1347
2097
  this.intentValidators = /* @__PURE__ */ new Map();
1348
2098
  this.intentKinds = /* @__PURE__ */ new Map();
2099
+ this.intentChains = /* @__PURE__ */ new Map();
2100
+ this.intentObservers = /* @__PURE__ */ new Map();
2101
+ this.intentCapsulePolicies = /* @__PURE__ */ new Map();
1349
2102
  this.cceHandlers = /* @__PURE__ */ new Map();
1350
2103
  this.ccePipelineConfig = null;
1351
- this.idelCompiler = null;
1352
2104
  }
1353
2105
  getSchema(intent) {
1354
2106
  return this.intentSchemas.get(intent);
@@ -1362,34 +2114,6 @@ var require_intent_router = __commonJS({
1362
2114
  getRegisteredIntents() {
1363
2115
  return [...IntentRouter_1.BUILTIN_INTENTS, ...this.handlers.keys()];
1364
2116
  }
1365
- configureIdel(compiler) {
1366
- this.idelCompiler = compiler;
1367
- this.logger.log("IDEL compiler configured");
1368
- }
1369
- resolveIntent(proposal) {
1370
- if (!this.idelCompiler) {
1371
- throw new Error("IDEL compiler not configured. Call configureIdel() first.");
1372
- }
1373
- const result = this.idelCompiler.compile(proposal);
1374
- if (!result.ok || !result.compiled) {
1375
- const msg = result.errors?.map((e) => e.message).join("; ") ?? "Unknown compilation error";
1376
- throw new Error(`IDEL compilation failed: ${msg}`);
1377
- }
1378
- return result.compiled;
1379
- }
1380
- async routeIdel(proposal, frame) {
1381
- const compiled = this.resolveIntent(proposal);
1382
- const resolvedFrame = {
1383
- ...frame,
1384
- headers: new Map(frame.headers)
1385
- };
1386
- resolvedFrame.headers.set(3, new TextEncoder().encode(compiled.intent));
1387
- if (compiled.params && Object.keys(compiled.params).length > 0) {
1388
- resolvedFrame.body = new TextEncoder().encode(JSON.stringify(compiled.params));
1389
- }
1390
- const effect = await this.route(resolvedFrame);
1391
- return { ...effect, compiled };
1392
- }
1393
2117
  getIntentEntry(intent) {
1394
2118
  if (!this.has(intent))
1395
2119
  return null;
@@ -1398,9 +2122,18 @@ var require_intent_router = __commonJS({
1398
2122
  validators: this.intentValidators.get(intent),
1399
2123
  hasSensors: this.intentSensors.has(intent),
1400
2124
  builtin: IntentRouter_1.BUILTIN_INTENTS.has(intent),
1401
- kind: this.intentKinds.get(intent)
2125
+ kind: this.intentKinds.get(intent),
2126
+ chain: this.intentChains.get(intent),
2127
+ capsulePolicy: this.intentCapsulePolicies.get(intent),
2128
+ observerCount: this.getObservers(intent).length
1402
2129
  };
1403
2130
  }
2131
+ getChainConfig(intent) {
2132
+ return this.intentChains.get(intent);
2133
+ }
2134
+ getObservers(intent) {
2135
+ return this.intentObservers.get(intent) || [];
2136
+ }
1404
2137
  register(intent, handler) {
1405
2138
  this.handlers.set(intent, handler);
1406
2139
  }
@@ -1408,7 +2141,10 @@ var require_intent_router = __commonJS({
1408
2141
  const handlerMeta = Reflect.getMetadata(handler_decorator_1.HANDLER_METADATA_KEY, instance.constructor);
1409
2142
  const prefix = handlerMeta?.intent || instance.name;
1410
2143
  const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, instance.constructor) || [];
2144
+ const routedMethods = new Set(routes.map((route) => String(route.methodName)));
1411
2145
  const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, instance.constructor) || [];
2146
+ const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, instance.constructor) || [];
2147
+ const proto = Object.getPrototypeOf(instance);
1412
2148
  for (const route of routes) {
1413
2149
  const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
1414
2150
  const fn = instance[route.methodName].bind(instance);
@@ -1417,27 +2153,36 @@ var require_intent_router = __commonJS({
1417
2153
  } else {
1418
2154
  this.register(intentName, fn);
1419
2155
  }
1420
- this.registerIntentMeta(intentName, Object.getPrototypeOf(instance), String(route.methodName), handlerSensors);
2156
+ this.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
1421
2157
  }
1422
- const proto = Object.getPrototypeOf(instance);
1423
2158
  for (const key of Object.getOwnPropertyNames(proto)) {
2159
+ if (routedMethods.has(key))
2160
+ continue;
1424
2161
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, key);
1425
2162
  if (!meta?.intent)
1426
2163
  continue;
1427
- if (!this.handlers.has(meta.intent)) {
1428
- this.register(meta.intent, instance[key].bind(instance));
2164
+ const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
2165
+ if (!this.handlers.has(intentName)) {
2166
+ this.register(intentName, instance[key].bind(instance));
1429
2167
  }
1430
- this.registerIntentMeta(meta.intent, proto, key, handlerSensors);
2168
+ this.registerIntentMeta(intentName, proto, key, handlerSensors, handlerObservers);
1431
2169
  }
1432
2170
  }
1433
2171
  async route(frame) {
1434
2172
  const start = process.hrtime();
1435
2173
  let intent = "unknown";
1436
2174
  try {
1437
- const intentBytes = frame.headers.get(3);
2175
+ const intentBytes = frame.headers.get(constants_1.TLV_INTENT);
1438
2176
  if (!intentBytes)
1439
2177
  throw new Error("Missing intent");
1440
- intent = new TextDecoder().decode(intentBytes);
2178
+ intent = this.decoder.decode(intentBytes);
2179
+ const observerBindings = this.getObservers(intent);
2180
+ await this.emitIntentObservers(observerBindings, {
2181
+ event: "intent.received",
2182
+ timestamp: Date.now(),
2183
+ intent,
2184
+ frame
2185
+ });
1441
2186
  let effect;
1442
2187
  if (intent === "system.ping" || intent === "public.ping") {
1443
2188
  this.logger.debug("PING received");
@@ -1469,25 +2214,35 @@ var require_intent_router = __commonJS({
1469
2214
  effect: "echo",
1470
2215
  body: frame.body
1471
2216
  };
2217
+ } else if (intent === "CHAIN.EXEC" || intent === "axis.chain.exec") {
2218
+ const chainRequest = this.parseChainRequestBody(frame.body);
2219
+ effect = await this.executeChainRequest(frame, chainRequest);
1472
2220
  } else if (intent === "INTENT.EXEC" || intent === "axis.intent.exec") {
1473
- try {
1474
- const bodyJSON = JSON.parse(new TextDecoder().decode(frame.body));
1475
- const innerIntent = bodyJSON.intent;
1476
- const innerArgs = bodyJSON.args || {};
1477
- if (!innerIntent) {
1478
- throw new Error("INTENT.EXEC missing inner intent");
1479
- }
1480
- this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
1481
- const innerFrame = {
1482
- ...frame,
1483
- headers: new Map(frame.headers),
1484
- body: new TextEncoder().encode(JSON.stringify(innerArgs))
1485
- };
1486
- innerFrame.headers.set(3, new TextEncoder().encode(innerIntent));
1487
- return await this.route(innerFrame);
1488
- } catch (e) {
1489
- throw new Error(`INTENT.EXEC unwrapping failed: ${e.message}`);
2221
+ const execBody = this.parseIntentExecBody(frame.body);
2222
+ const innerIntent = execBody.intent;
2223
+ const innerArgs = execBody.args || {};
2224
+ if (!innerIntent) {
2225
+ throw new Error("INTENT.EXEC missing inner intent");
2226
+ }
2227
+ this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
2228
+ const innerHeaders = new Map(frame.headers);
2229
+ innerHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(innerIntent));
2230
+ const inlineCapsule = this.toInlineCapsuleRecord(execBody.capsule);
2231
+ const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2232
+ if (capsuleId) {
2233
+ innerHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2234
+ innerHeaders.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
1490
2235
  }
2236
+ const innerFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
2237
+ ...frame,
2238
+ headers: innerHeaders,
2239
+ body: this.encodeJson(innerArgs)
2240
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
2241
+ metaIntent: "INTENT.EXEC",
2242
+ actorId: this.getActorIdFromFrame(frame),
2243
+ inlineCapsule
2244
+ }) || {});
2245
+ effect = await this.route(innerFrame);
1491
2246
  } else {
1492
2247
  const handler = this.handlers.get(intent);
1493
2248
  if (!handler) {
@@ -1506,6 +2261,7 @@ var require_intent_router = __commonJS({
1506
2261
  throw new Error(`IntentBody decode failed for ${intent}: ${decodeErr.message}`);
1507
2262
  }
1508
2263
  }
2264
+ this.enforceCapsulePolicy(intent, frame, decodedBody, this.getEffectiveCapsulePolicy(intent, frame));
1509
2265
  if (typeof handler === "function") {
1510
2266
  const resultBody = decoder ? await handler(decodedBody, frame.headers) : await handler(frame.body, frame.headers);
1511
2267
  effect = {
@@ -1528,9 +2284,24 @@ var require_intent_router = __commonJS({
1528
2284
  }
1529
2285
  }
1530
2286
  }
2287
+ await this.emitIntentObservers(observerBindings, {
2288
+ event: "intent.completed",
2289
+ timestamp: Date.now(),
2290
+ intent,
2291
+ frame,
2292
+ effect,
2293
+ metadata: effect.metadata
2294
+ });
1531
2295
  this.logIntent(intent, start, true);
1532
2296
  return effect;
1533
2297
  } catch (e) {
2298
+ await this.emitIntentObservers(this.getObservers(intent), {
2299
+ event: "intent.failed",
2300
+ timestamp: Date.now(),
2301
+ intent,
2302
+ frame,
2303
+ error: e.message
2304
+ });
1534
2305
  this.logIntent(intent, start, false, e.message);
1535
2306
  throw e;
1536
2307
  }
@@ -1544,7 +2315,7 @@ var require_intent_router = __commonJS({
1544
2315
  this.logger.warn(`${intent} failed in ${ms}ms - ${error}`);
1545
2316
  }
1546
2317
  }
1547
- registerIntentMeta(intent, proto, methodName, handlerSensors) {
2318
+ registerIntentMeta(intent, proto, methodName, handlerSensors, handlerObservers) {
1548
2319
  const decoder = Reflect.getMetadata(intent_body_decorator_1.INTENT_BODY_KEY, proto, methodName);
1549
2320
  if (decoder) {
1550
2321
  this.intentDecoders.set(intent, decoder);
@@ -1557,14 +2328,38 @@ var require_intent_router = __commonJS({
1557
2328
  if (combined.length > 0) {
1558
2329
  this.intentSensors.set(intent, combined);
1559
2330
  }
2331
+ const methodObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, proto, methodName) || [];
2332
+ const observers = mergeObserverBindings([
2333
+ ...handlerObservers || [],
2334
+ ...methodObservers
2335
+ ]);
2336
+ if (observers.length > 0) {
2337
+ this.intentObservers.set(intent, observers);
2338
+ }
2339
+ const handlerCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto.constructor);
2340
+ const methodCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto, methodName);
2341
+ const capsulePolicy = (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(handlerCapsulePolicy, methodCapsulePolicy);
2342
+ if (capsulePolicy) {
2343
+ this.intentCapsulePolicies.set(intent, capsulePolicy);
2344
+ }
1560
2345
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
1561
2346
  if (meta) {
1562
- this.storeSchema(meta);
2347
+ this.storeSchema({ ...meta, intent });
1563
2348
  if (meta.kind) {
1564
2349
  this.intentKinds.set(intent, meta.kind);
1565
2350
  }
2351
+ const chainMeta = Reflect.getMetadata(chain_decorator_1.CHAIN_METADATA_KEY, proto, methodName);
2352
+ const chainConfig = normalizeChainConfig(chainMeta, meta.chain);
2353
+ if (chainConfig) {
2354
+ this.intentChains.set(intent, chainConfig);
2355
+ }
1566
2356
  }
1567
2357
  }
2358
+ async emitIntentObservers(bindings, context) {
2359
+ if (!this.observerDispatcher || bindings.length === 0)
2360
+ return;
2361
+ await this.observerDispatcher.dispatch(bindings, context);
2362
+ }
1568
2363
  async runIntentSensors(sensorClasses, intent, frame) {
1569
2364
  if (!this.moduleRef)
1570
2365
  return;
@@ -1593,6 +2388,226 @@ var require_intent_router = __commonJS({
1593
2388
  }
1594
2389
  }
1595
2390
  }
2391
+ getEffectiveCapsulePolicy(intent, frame) {
2392
+ const registeredPolicy = this.intentCapsulePolicies.get(intent);
2393
+ const chainConfig = this.intentChains.get(intent);
2394
+ const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
2395
+ const derivedScopes = Array.from(/* @__PURE__ */ new Set([
2396
+ ...this.toScopeList(chainConfig?.capsuleScope),
2397
+ ...this.toScopeList(executionContext?.capsuleRef?.scope),
2398
+ ...this.toScopeList(executionContext?.chainStep?.capsuleScope)
2399
+ ]));
2400
+ const requiresCapsule = chainConfig?.proofRequired || executionContext?.capsuleRef?.proofRequired || executionContext?.chainStep?.proofRequired || executionContext?.chainEnvelope?.capsule?.proofRequired || derivedScopes.length > 0;
2401
+ const derivedPolicy = requiresCapsule ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)({
2402
+ required: true,
2403
+ scopes: derivedScopes.length > 0 ? derivedScopes : void 0
2404
+ }) : void 0;
2405
+ return (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(registeredPolicy, derivedPolicy);
2406
+ }
2407
+ enforceCapsulePolicy(intent, frame, body, policy) {
2408
+ const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
2409
+ const inlineCapsuleRecord = this.toInlineCapsuleRecord(executionContext?.inlineCapsule);
2410
+ const inlineCapsule = (0, inline_capsule_1.normalizeInlineCapsule)(inlineCapsuleRecord);
2411
+ const normalizedPolicy = policy ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)(policy) : void 0;
2412
+ if (!inlineCapsule) {
2413
+ if (normalizedPolicy?.required) {
2414
+ if (normalizedPolicy.allowCapsuleRef && this.hasCapsuleReference(frame) && this.toScopeList(normalizedPolicy.scopes).length === 0 && normalizedPolicy.intentBound === false) {
2415
+ return;
2416
+ }
2417
+ throw new axis_error_1.AxisError(this.hasCapsuleReference(frame) ? "CAPSULE_CLAIMS_REQUIRED" : "CAPSULE_REQUIRED", `Intent ${intent} requires an inline capsule for policy enforcement`, 403, { intent });
2418
+ }
2419
+ return;
2420
+ }
2421
+ if ((0, inline_capsule_1.isInlineCapsuleExpired)(inlineCapsule)) {
2422
+ throw new axis_error_1.AxisError("CAPSULE_EXPIRED", `Capsule for ${intent} is expired`, 403, { intent, capsuleId: inlineCapsule.id });
2423
+ }
2424
+ const actorId = this.getActorIdFromFrame(frame) || executionContext?.actorId;
2425
+ if (actorId && inlineCapsule.actorId && !this.identifiersMatch(actorId, inlineCapsule.actorId)) {
2426
+ throw new axis_error_1.AxisError("CAPSULE_ACTOR_MISMATCH", `Capsule actor does not match request actor for ${intent}`, 403, {
2427
+ intent,
2428
+ actorId,
2429
+ capsuleActorId: inlineCapsule.actorId
2430
+ });
2431
+ }
2432
+ const proofRef = this.getProofRefFromFrame(frame);
2433
+ if (proofRef && inlineCapsule.id && !this.identifiersMatch(proofRef, inlineCapsule.id)) {
2434
+ throw new axis_error_1.AxisError("CAPSULE_REF_MISMATCH", `Capsule reference does not match request proof for ${intent}`, 403, {
2435
+ intent,
2436
+ proofRef,
2437
+ capsuleId: inlineCapsule.id
2438
+ });
2439
+ }
2440
+ const realm = this.getHeaderValue(frame, constants_1.TLV_REALM);
2441
+ if (realm && inlineCapsule.realm && realm !== inlineCapsule.realm) {
2442
+ throw new axis_error_1.AxisError("CAPSULE_REALM_MISMATCH", `Capsule realm does not match request realm for ${intent}`, 403, { intent, realm, capsuleRealm: inlineCapsule.realm });
2443
+ }
2444
+ const node = this.getHeaderValue(frame, constants_1.TLV_NODE);
2445
+ if (node && inlineCapsule.node && node !== inlineCapsule.node) {
2446
+ throw new axis_error_1.AxisError("CAPSULE_NODE_MISMATCH", `Capsule node does not match request node for ${intent}`, 403, { intent, node, capsuleNode: inlineCapsule.node });
2447
+ }
2448
+ const shouldCheckIntent = normalizedPolicy?.intentBound ?? true;
2449
+ if (shouldCheckIntent && !(0, inline_capsule_1.inlineCapsuleAllowsIntent)(inlineCapsule, intent)) {
2450
+ throw new axis_error_1.AxisError("CAPSULE_DENIED", `Capsule does not authorize ${intent}`, 403, {
2451
+ intent,
2452
+ capsuleId: inlineCapsule.id,
2453
+ allowedIntents: inlineCapsule.intents
2454
+ });
2455
+ }
2456
+ const requiredScopes = this.toScopeList(normalizedPolicy?.scopes);
2457
+ if (requiredScopes.length === 0) {
2458
+ return;
2459
+ }
2460
+ let resolvedScopes;
2461
+ try {
2462
+ resolvedScopes = (0, inline_capsule_1.resolvePolicyScopes)(requiredScopes, {
2463
+ body,
2464
+ intent,
2465
+ actorId,
2466
+ chainId: executionContext?.chainEnvelope?.chainId,
2467
+ stepId: executionContext?.chainStep?.stepId
2468
+ });
2469
+ } catch (error) {
2470
+ this.logger.error(`Scope template error for ${intent}: ${error.message}`);
2471
+ throw new axis_error_1.AxisError("CAPSULE_SCOPE_TEMPLATE_UNRESOLVED", "Scope policy validation failed", 400, { intent });
2472
+ }
2473
+ if (!(0, inline_capsule_1.inlineCapsuleSatisfiesScopes)(inlineCapsule, resolvedScopes, normalizedPolicy?.scopeMode ?? "all")) {
2474
+ throw new axis_error_1.AxisError("SCOPE_MISMATCH", `Capsule scopes do not satisfy ${intent}`, 403, {
2475
+ intent,
2476
+ requiredScopes: resolvedScopes,
2477
+ availableScopes: inlineCapsule.scopes || []
2478
+ });
2479
+ }
2480
+ }
2481
+ async executeChainRequest(frame, request) {
2482
+ const { AxisChainExecutor: AxisChainExecutor2 } = await Promise.resolve().then(() => __importStar(require_axis_chain_executor()));
2483
+ const headerActorId = this.getActorIdFromFrame(frame);
2484
+ if (request.actorId && headerActorId && !this.identifiersMatch(request.actorId, headerActorId)) {
2485
+ throw new axis_error_1.AxisError("ACTOR_MISMATCH", "CHAIN.EXEC actorId conflicts with authenticated frame identity", 403);
2486
+ }
2487
+ const actorId = headerActorId || request.actorId;
2488
+ const inlineCapsule = this.toInlineCapsuleRecord(request.capsule);
2489
+ const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2490
+ const headers = new Map(frame.headers);
2491
+ if (capsuleId) {
2492
+ headers.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2493
+ headers.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
2494
+ }
2495
+ const baseFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
2496
+ ...frame,
2497
+ headers
2498
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
2499
+ metaIntent: "CHAIN.EXEC",
2500
+ actorId,
2501
+ inlineCapsule,
2502
+ capsuleRef: request.envelope.capsule,
2503
+ chainEnvelope: request.envelope
2504
+ }) || {});
2505
+ const executor = new AxisChainExecutor2(this, this.observerDispatcher);
2506
+ const result = await executor.execute(request.envelope, {
2507
+ actorId,
2508
+ baseFrame
2509
+ });
2510
+ return {
2511
+ ok: result.status !== "FAILED",
2512
+ effect: "chain.complete",
2513
+ body: this.encodeJson(result),
2514
+ metadata: {
2515
+ chainId: result.chainId,
2516
+ status: result.status
2517
+ }
2518
+ };
2519
+ }
2520
+ parseIntentExecBody(bytes2) {
2521
+ try {
2522
+ return JSON.parse(this.decoder.decode(bytes2));
2523
+ } catch (error) {
2524
+ throw new Error(`INTENT.EXEC unwrapping failed: ${error.message}`);
2525
+ }
2526
+ }
2527
+ parseChainRequestBody(bytes2) {
2528
+ let jsonError;
2529
+ try {
2530
+ const parsed = JSON.parse(this.decoder.decode(bytes2));
2531
+ if (this.isChainRequestLike(parsed)) {
2532
+ return {
2533
+ envelope: parsed.envelope,
2534
+ capsule: this.toInlineCapsuleRecord(parsed.capsule),
2535
+ actorId: typeof parsed.actorId === "string" ? parsed.actorId : void 0
2536
+ };
2537
+ }
2538
+ if (this.isChainEnvelopeLike(parsed)) {
2539
+ return { envelope: parsed };
2540
+ }
2541
+ } catch (error) {
2542
+ jsonError = error;
2543
+ }
2544
+ try {
2545
+ const decoded = (0, axis_protocol_1.decodeChainRequest)(bytes2);
2546
+ return {
2547
+ envelope: decoded.envelope,
2548
+ capsule: this.toInlineCapsuleRecord(decoded.capsule),
2549
+ actorId: decoded.actorId
2550
+ };
2551
+ } catch (requestError) {
2552
+ try {
2553
+ return {
2554
+ envelope: (0, axis_protocol_1.decodeChainEnvelope)(bytes2)
2555
+ };
2556
+ } catch (envelopeError) {
2557
+ const reason = [jsonError?.message, requestError.message, envelopeError.message].filter(Boolean).join(" | ");
2558
+ throw new Error(`CHAIN.EXEC decode failed: ${reason}`);
2559
+ }
2560
+ }
2561
+ }
2562
+ isChainRequestLike(value) {
2563
+ return !!value && typeof value === "object" && "envelope" in value && this.isChainEnvelopeLike(value.envelope);
2564
+ }
2565
+ isChainEnvelopeLike(value) {
2566
+ return !!value && typeof value === "object" && typeof value.chainId === "string" && Array.isArray(value.steps);
2567
+ }
2568
+ encodeJson(value) {
2569
+ return this.encoder.encode(JSON.stringify(value));
2570
+ }
2571
+ getActorIdFromFrame(frame) {
2572
+ return this.getHeaderValue(frame, constants_1.TLV_ACTOR_ID);
2573
+ }
2574
+ getProofRefFromFrame(frame) {
2575
+ return this.getHeaderValue(frame, constants_1.TLV_PROOF_REF) || this.getHeaderValue(frame, constants_1.TLV_CAPSULE);
2576
+ }
2577
+ hasCapsuleReference(frame) {
2578
+ return !!this.getProofRefFromFrame(frame);
2579
+ }
2580
+ getHeaderValue(frame, tag) {
2581
+ const value = frame.headers.get(tag);
2582
+ if (!value || value.length === 0) {
2583
+ return void 0;
2584
+ }
2585
+ const decoded = this.decoder.decode(value);
2586
+ if (/^[\x20-\x7e]+$/.test(decoded)) {
2587
+ return decoded;
2588
+ }
2589
+ return Buffer.from(value).toString("hex");
2590
+ }
2591
+ identifiersMatch(left, right) {
2592
+ const normalize2 = (value) => /^[0-9a-f]+$/i.test(value) ? value.toLowerCase() : value;
2593
+ return normalize2(left) === normalize2(right);
2594
+ }
2595
+ extractInlineCapsuleId(capsule) {
2596
+ const id = capsule?.id;
2597
+ return typeof id === "string" && id.length > 0 ? id : void 0;
2598
+ }
2599
+ toInlineCapsuleRecord(value) {
2600
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
2601
+ return void 0;
2602
+ }
2603
+ return value;
2604
+ }
2605
+ toScopeList(value) {
2606
+ if (!value) {
2607
+ return [];
2608
+ }
2609
+ return Array.isArray(value) ? value : [value];
2610
+ }
1596
2611
  configureCce(config) {
1597
2612
  this.ccePipelineConfig = config;
1598
2613
  this.logger.log("CCE pipeline configured");
@@ -1666,23 +2681,460 @@ var require_intent_router = __commonJS({
1666
2681
  scope: f.scope
1667
2682
  }))
1668
2683
  };
1669
- this.intentSchemas.set(meta.intent, schema);
2684
+ this.intentSchemas.set(meta.intent, schema);
2685
+ }
2686
+ };
2687
+ exports.IntentRouter = IntentRouter2;
2688
+ IntentRouter2.BUILTIN_INTENTS = /* @__PURE__ */ new Set([
2689
+ "system.ping",
2690
+ "public.ping",
2691
+ "system.time",
2692
+ "system.echo",
2693
+ "CHAIN.EXEC",
2694
+ "axis.chain.exec",
2695
+ "INTENT.EXEC",
2696
+ "axis.intent.exec"
2697
+ ]);
2698
+ exports.IntentRouter = IntentRouter2 = IntentRouter_1 = __decorate([
2699
+ (0, common_1.Injectable)(),
2700
+ __param(0, (0, common_1.Optional)()),
2701
+ __param(1, (0, common_1.Optional)()),
2702
+ __metadata("design:paramtypes", [typeof (_a = typeof core_1.ModuleRef !== "undefined" && core_1.ModuleRef) === "function" ? _a : Object, typeof (_b = typeof observer_dispatcher_service_1.ObserverDispatcherService !== "undefined" && observer_dispatcher_service_1.ObserverDispatcherService) === "function" ? _b : Object])
2703
+ ], IntentRouter2);
2704
+ }
2705
+ });
2706
+
2707
+ // src/engine/axis-chain.executor.ts
2708
+ var require_axis_chain_executor = __commonJS({
2709
+ "src/engine/axis-chain.executor.ts"(exports) {
2710
+ "use strict";
2711
+ var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
2712
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2713
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2714
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2715
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2716
+ };
2717
+ var __metadata = exports && exports.__metadata || function(k, v) {
2718
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2719
+ };
2720
+ var __param = exports && exports.__param || function(paramIndex, decorator) {
2721
+ return function(target, key) {
2722
+ decorator(target, key, paramIndex);
2723
+ };
2724
+ };
2725
+ var AxisChainExecutor_1;
2726
+ var _a;
2727
+ var _b;
2728
+ Object.defineProperty(exports, "__esModule", { value: true });
2729
+ exports.AxisChainExecutor = void 0;
2730
+ var crypto_1 = __require("crypto");
2731
+ var common_1 = __require("@nestjs/common");
2732
+ var constants_1 = (init_constants(), __toCommonJS(constants_exports));
2733
+ var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
2734
+ var observer_dispatcher_service_1 = require_observer_dispatcher_service();
2735
+ var intent_router_1 = require_intent_router();
2736
+ var AxisChainExecutor2 = AxisChainExecutor_1 = class AxisChainExecutor {
2737
+ constructor(router, observerDispatcher) {
2738
+ this.router = router;
2739
+ this.observerDispatcher = observerDispatcher;
2740
+ this.logger = new common_1.Logger(AxisChainExecutor_1.name);
2741
+ this.encoder = new TextEncoder();
2742
+ this.decoder = new TextDecoder();
2743
+ }
2744
+ async execute(envelope, options = {}) {
2745
+ this.validateEnvelope(envelope);
2746
+ const startedAt = Date.now();
2747
+ const results = /* @__PURE__ */ new Map();
2748
+ const bindings = this.collectChainBindings(envelope);
2749
+ await this.dispatch(bindings, {
2750
+ event: "chain.received",
2751
+ timestamp: startedAt,
2752
+ chainId: envelope.chainId,
2753
+ envelope,
2754
+ observerTags: envelope.observerTags,
2755
+ capsule: envelope.capsule,
2756
+ keyExchange: envelope.keyExchange
2757
+ });
2758
+ await this.dispatch(bindings, {
2759
+ event: "chain.admitted",
2760
+ timestamp: Date.now(),
2761
+ chainId: envelope.chainId,
2762
+ envelope,
2763
+ observerTags: envelope.observerTags,
2764
+ capsule: envelope.capsule,
2765
+ keyExchange: envelope.keyExchange
2766
+ });
2767
+ const stepsById = new Map(envelope.steps.map((step) => [step.stepId, step]));
2768
+ const pending = new Set(stepsById.keys());
2769
+ while (pending.size > 0) {
2770
+ const ready = Array.from(pending).map((stepId) => stepsById.get(stepId)).filter((step) => this.canRun(step, results));
2771
+ if (ready.length === 0) {
2772
+ this.markUnresolvedSteps(pending, stepsById, results, "BLOCKED", "UNRESOLVED_DEPENDENCIES");
2773
+ break;
2774
+ }
2775
+ if (envelope.mode === "parallel") {
2776
+ const waveResults = await Promise.all(ready.map((step) => this.executeStep(step, envelope, results, options)));
2777
+ for (const result of waveResults) {
2778
+ results.set(result.stepId, result);
2779
+ pending.delete(result.stepId);
2780
+ }
2781
+ } else {
2782
+ for (const step of ready) {
2783
+ const result = await this.executeStep(step, envelope, results, options);
2784
+ results.set(result.stepId, result);
2785
+ pending.delete(result.stepId);
2786
+ if (result.status === "FAILED" && (envelope.mode === "strict" || envelope.mode === "atomic")) {
2787
+ this.markUnresolvedSteps(pending, stepsById, results, "SKIPPED", "CHAIN_HALTED");
2788
+ pending.clear();
2789
+ break;
2790
+ }
2791
+ }
2792
+ }
2793
+ this.blockStepsWithFailedDependencies(pending, stepsById, results);
2794
+ }
2795
+ const finishedAt = Date.now();
2796
+ const orderedResults = envelope.steps.map((step) => results.get(step.stepId));
2797
+ const summary = this.buildSummary(envelope.mode, orderedResults, startedAt, finishedAt, envelope.chainId);
2798
+ await this.dispatch(bindings, {
2799
+ event: summary.status === "SUCCEEDED" ? "chain.completed" : summary.status === "PARTIAL" ? "chain.partial" : "chain.failed",
2800
+ timestamp: finishedAt,
2801
+ chainId: envelope.chainId,
2802
+ envelope,
2803
+ result: summary,
2804
+ observerTags: envelope.observerTags,
2805
+ capsule: envelope.capsule,
2806
+ keyExchange: envelope.keyExchange
2807
+ });
2808
+ return summary;
2809
+ }
2810
+ async executeStep(step, envelope, results, options) {
2811
+ const stepBindings = this.router.getObservers(step.intent);
2812
+ const startedAt = Date.now();
2813
+ const input = this.resolveStepInput(step.input, results);
2814
+ await this.dispatch(stepBindings, {
2815
+ event: "step.started",
2816
+ timestamp: startedAt,
2817
+ chainId: envelope.chainId,
2818
+ stepId: step.stepId,
2819
+ intent: step.intent,
2820
+ envelope,
2821
+ step,
2822
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
2823
+ capsule: step.capsuleScope ? {
2824
+ ...envelope.capsule,
2825
+ scope: step.capsuleScope
2826
+ } : envelope.capsule,
2827
+ keyExchange: step.keyExchange || envelope.keyExchange
2828
+ });
2829
+ try {
2830
+ const frame = this.buildFrame(step, envelope, input, options);
2831
+ const effect = await this.router.route(frame);
2832
+ const finishedAt = Date.now();
2833
+ const output = this.decodeOutput(effect.body);
2834
+ const proofHash = this.computeProofHash(envelope.chainId, step.stepId, effect, output);
2835
+ const result = {
2836
+ stepId: step.stepId,
2837
+ intent: step.intent,
2838
+ status: "SUCCEEDED",
2839
+ effect: effect.effect,
2840
+ output,
2841
+ dependsOn: step.dependsOn,
2842
+ startedAt,
2843
+ finishedAt,
2844
+ proofHash,
2845
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
2846
+ metadata: effect.metadata
2847
+ };
2848
+ await this.dispatch(stepBindings, {
2849
+ event: "handler.completed",
2850
+ timestamp: finishedAt,
2851
+ chainId: envelope.chainId,
2852
+ stepId: step.stepId,
2853
+ intent: step.intent,
2854
+ effect,
2855
+ envelope,
2856
+ step,
2857
+ result,
2858
+ observerTags: result.observerTags,
2859
+ capsule: envelope.capsule,
2860
+ keyExchange: step.keyExchange || envelope.keyExchange
2861
+ });
2862
+ await this.dispatch(stepBindings, {
2863
+ event: "proof.recorded",
2864
+ timestamp: finishedAt,
2865
+ chainId: envelope.chainId,
2866
+ stepId: step.stepId,
2867
+ intent: step.intent,
2868
+ envelope,
2869
+ step,
2870
+ result,
2871
+ observerTags: result.observerTags,
2872
+ capsule: envelope.capsule,
2873
+ keyExchange: step.keyExchange || envelope.keyExchange,
2874
+ metadata: { proofHash }
2875
+ });
2876
+ await this.dispatch(stepBindings, {
2877
+ event: "step.completed",
2878
+ timestamp: finishedAt,
2879
+ chainId: envelope.chainId,
2880
+ stepId: step.stepId,
2881
+ intent: step.intent,
2882
+ effect,
2883
+ envelope,
2884
+ step,
2885
+ result,
2886
+ observerTags: result.observerTags,
2887
+ capsule: envelope.capsule,
2888
+ keyExchange: step.keyExchange || envelope.keyExchange
2889
+ });
2890
+ return result;
2891
+ } catch (error) {
2892
+ const finishedAt = Date.now();
2893
+ const result = {
2894
+ stepId: step.stepId,
2895
+ intent: step.intent,
2896
+ status: "FAILED",
2897
+ error: error.message,
2898
+ dependsOn: step.dependsOn,
2899
+ startedAt,
2900
+ finishedAt,
2901
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []]
2902
+ };
2903
+ this.logger.warn(`Chain ${envelope.chainId} step ${step.stepId} failed: ${error.message}`);
2904
+ await this.dispatch(stepBindings, {
2905
+ event: "step.failed",
2906
+ timestamp: finishedAt,
2907
+ chainId: envelope.chainId,
2908
+ stepId: step.stepId,
2909
+ intent: step.intent,
2910
+ error: error.message,
2911
+ envelope,
2912
+ step,
2913
+ result,
2914
+ observerTags: result.observerTags,
2915
+ capsule: envelope.capsule,
2916
+ keyExchange: step.keyExchange || envelope.keyExchange
2917
+ });
2918
+ return result;
2919
+ }
2920
+ }
2921
+ buildFrame(step, envelope, input, options) {
2922
+ const baseContext = (0, axis_execution_context_1.getAxisExecutionContext)(options.baseFrame);
2923
+ const baseHeaders = new Map(options.baseFrame?.headers || []);
2924
+ baseHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(step.intent));
2925
+ baseHeaders.set(constants_1.TLV_TRACE_ID, this.encoder.encode(envelope.chainId));
2926
+ const capsuleId = envelope.capsule?.capsuleId;
2927
+ if (capsuleId) {
2928
+ baseHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2929
+ }
2930
+ if (options.actorId) {
2931
+ baseHeaders.set(constants_1.TLV_ACTOR_ID, this.encoder.encode(options.actorId));
2932
+ }
2933
+ return (0, axis_execution_context_1.withAxisExecutionContext)({
2934
+ flags: (options.baseFrame?.flags || 0) | constants_1.FLAG_CHAIN_REQ,
2935
+ headers: baseHeaders,
2936
+ body: this.serializeInput(input),
2937
+ sig: options.baseFrame?.sig || new Uint8Array(0)
2938
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)(baseContext, {
2939
+ metaIntent: "CHAIN.EXEC",
2940
+ actorId: options.actorId || baseContext?.actorId,
2941
+ capsuleRef: step.capsuleScope ? {
2942
+ ...envelope.capsule || {},
2943
+ scope: step.capsuleScope
2944
+ } : envelope.capsule,
2945
+ chainEnvelope: envelope,
2946
+ chainStep: step
2947
+ }) || {});
2948
+ }
2949
+ validateEnvelope(envelope) {
2950
+ if (!envelope.chainId) {
2951
+ throw new Error("CHAIN_ID_REQUIRED");
2952
+ }
2953
+ if (!envelope.steps || envelope.steps.length === 0) {
2954
+ throw new Error("CHAIN_STEPS_REQUIRED");
2955
+ }
2956
+ const seen = /* @__PURE__ */ new Set();
2957
+ for (const step of envelope.steps) {
2958
+ if (!step.stepId) {
2959
+ throw new Error("CHAIN_STEP_ID_REQUIRED");
2960
+ }
2961
+ if (!step.intent) {
2962
+ throw new Error(`CHAIN_STEP_INTENT_REQUIRED:${step.stepId}`);
2963
+ }
2964
+ if (seen.has(step.stepId)) {
2965
+ throw new Error(`CHAIN_STEP_DUPLICATE:${step.stepId}`);
2966
+ }
2967
+ seen.add(step.stepId);
2968
+ }
2969
+ for (const step of envelope.steps) {
2970
+ for (const dependency of step.dependsOn || []) {
2971
+ if (!seen.has(dependency)) {
2972
+ throw new Error(`CHAIN_STEP_DEPENDENCY_UNKNOWN:${step.stepId}:${dependency}`);
2973
+ }
2974
+ }
2975
+ }
2976
+ }
2977
+ canRun(step, results) {
2978
+ return (step.dependsOn || []).every((dependency) => results.has(dependency));
2979
+ }
2980
+ blockStepsWithFailedDependencies(pending, stepsById, results) {
2981
+ for (const stepId of Array.from(pending)) {
2982
+ const step = stepsById.get(stepId);
2983
+ if (!step || !step.dependsOn || step.dependsOn.length === 0)
2984
+ continue;
2985
+ const dependencyResults = step.dependsOn.map((dependency) => results.get(dependency)).filter(Boolean);
2986
+ if (dependencyResults.length !== step.dependsOn.length)
2987
+ continue;
2988
+ const hasFailure = dependencyResults.some((dependency) => dependency.status !== "SUCCEEDED");
2989
+ if (!hasFailure)
2990
+ continue;
2991
+ results.set(step.stepId, {
2992
+ stepId: step.stepId,
2993
+ intent: step.intent,
2994
+ status: "BLOCKED",
2995
+ error: "DEPENDENCY_FAILED",
2996
+ dependsOn: step.dependsOn,
2997
+ startedAt: Date.now(),
2998
+ finishedAt: Date.now(),
2999
+ observerTags: step.observerTags
3000
+ });
3001
+ pending.delete(step.stepId);
3002
+ }
3003
+ }
3004
+ markUnresolvedSteps(pending, stepsById, results, status, error) {
3005
+ for (const stepId of pending) {
3006
+ const step = stepsById.get(stepId);
3007
+ if (!step)
3008
+ continue;
3009
+ results.set(stepId, {
3010
+ stepId,
3011
+ intent: step.intent,
3012
+ status,
3013
+ error,
3014
+ dependsOn: step.dependsOn,
3015
+ startedAt: Date.now(),
3016
+ finishedAt: Date.now(),
3017
+ observerTags: step.observerTags
3018
+ });
3019
+ }
3020
+ }
3021
+ buildSummary(mode, results, startedAt, finishedAt, chainId) {
3022
+ const completedSteps = results.filter((result) => result.status === "SUCCEEDED").length;
3023
+ const failedSteps = results.filter((result) => result.status === "FAILED").length;
3024
+ const blockedSteps = results.filter((result) => result.status === "BLOCKED").length;
3025
+ const skippedSteps = results.filter((result) => result.status === "SKIPPED").length;
3026
+ let status = "SUCCEEDED";
3027
+ if (failedSteps > 0 || blockedSteps > 0 || skippedSteps > 0) {
3028
+ status = mode === "best_effort" || mode === "parallel" ? completedSteps > 0 ? "PARTIAL" : "FAILED" : "FAILED";
3029
+ }
3030
+ return {
3031
+ chainId,
3032
+ mode,
3033
+ status,
3034
+ completedSteps,
3035
+ failedSteps,
3036
+ blockedSteps,
3037
+ skippedSteps,
3038
+ startedAt,
3039
+ finishedAt,
3040
+ results,
3041
+ rollback: mode === "atomic" ? {
3042
+ supported: false,
3043
+ attempted: false,
3044
+ reason: "AXIS handlers do not expose rollback semantics yet"
3045
+ } : void 0
3046
+ };
3047
+ }
3048
+ resolveStepInput(value, results) {
3049
+ if (typeof value === "string") {
3050
+ if (!value.startsWith("$"))
3051
+ return value;
3052
+ return this.lookupReference(value.slice(1), results);
3053
+ }
3054
+ if (Array.isArray(value)) {
3055
+ return value.map((entry) => this.resolveStepInput(entry, results));
3056
+ }
3057
+ if (value && typeof value === "object") {
3058
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
3059
+ key,
3060
+ this.resolveStepInput(entry, results)
3061
+ ]));
3062
+ }
3063
+ return value;
3064
+ }
3065
+ lookupReference(path2, results) {
3066
+ const [stepId, ...segments] = path2.split(".");
3067
+ const result = results.get(stepId);
3068
+ if (!result)
3069
+ return void 0;
3070
+ let current = result;
3071
+ for (const segment of segments) {
3072
+ if (current === void 0 || current === null)
3073
+ return void 0;
3074
+ if (typeof current !== "object")
3075
+ return void 0;
3076
+ current = current[segment];
3077
+ }
3078
+ return current;
3079
+ }
3080
+ serializeInput(input) {
3081
+ if (input instanceof Uint8Array)
3082
+ return input;
3083
+ if (typeof input === "string")
3084
+ return this.encoder.encode(input);
3085
+ if (input === void 0)
3086
+ return new Uint8Array(0);
3087
+ return this.encoder.encode(JSON.stringify(input));
3088
+ }
3089
+ decodeOutput(body) {
3090
+ if (!body || body.length === 0)
3091
+ return void 0;
3092
+ try {
3093
+ const text = this.decoder.decode(body);
3094
+ try {
3095
+ return JSON.parse(text);
3096
+ } catch {
3097
+ return /^[\x20-\x7E\s]+$/.test(text) ? text : body;
3098
+ }
3099
+ } catch {
3100
+ return body;
3101
+ }
3102
+ }
3103
+ computeProofHash(chainId, stepId, effect, output) {
3104
+ const hash = (0, crypto_1.createHash)("sha256");
3105
+ hash.update(chainId);
3106
+ hash.update(":");
3107
+ hash.update(stepId);
3108
+ hash.update(":");
3109
+ hash.update(effect.effect);
3110
+ hash.update(":");
3111
+ hash.update(JSON.stringify(output ?? null));
3112
+ return hash.digest("hex");
3113
+ }
3114
+ collectChainBindings(envelope) {
3115
+ const uniqueBindings = /* @__PURE__ */ new Map();
3116
+ for (const step of envelope.steps) {
3117
+ for (const binding of this.router.getObservers(step.intent)) {
3118
+ const key = binding.refs.map((ref) => String(ref)).sort().join("|");
3119
+ if (!uniqueBindings.has(key)) {
3120
+ uniqueBindings.set(key, binding);
3121
+ }
3122
+ }
3123
+ }
3124
+ return Array.from(uniqueBindings.values());
3125
+ }
3126
+ async dispatch(bindings, context) {
3127
+ if (!this.observerDispatcher)
3128
+ return;
3129
+ await this.observerDispatcher.dispatch(bindings, context);
1670
3130
  }
1671
3131
  };
1672
- exports.IntentRouter = IntentRouter2;
1673
- IntentRouter2.BUILTIN_INTENTS = /* @__PURE__ */ new Set([
1674
- "system.ping",
1675
- "public.ping",
1676
- "system.time",
1677
- "system.echo",
1678
- "INTENT.EXEC",
1679
- "axis.intent.exec"
1680
- ]);
1681
- exports.IntentRouter = IntentRouter2 = IntentRouter_1 = __decorate([
3132
+ exports.AxisChainExecutor = AxisChainExecutor2;
3133
+ exports.AxisChainExecutor = AxisChainExecutor2 = AxisChainExecutor_1 = __decorate([
1682
3134
  (0, common_1.Injectable)(),
1683
- __param(0, (0, common_1.Optional)()),
1684
- __metadata("design:paramtypes", [typeof (_a = typeof core_1.ModuleRef !== "undefined" && core_1.ModuleRef) === "function" ? _a : Object])
1685
- ], IntentRouter2);
3135
+ __param(1, (0, common_1.Optional)()),
3136
+ __metadata("design:paramtypes", [typeof (_a = typeof intent_router_1.IntentRouter !== "undefined" && intent_router_1.IntentRouter) === "function" ? _a : Object, typeof (_b = typeof observer_dispatcher_service_1.ObserverDispatcherService !== "undefined" && observer_dispatcher_service_1.ObserverDispatcherService) === "function" ? _b : Object])
3137
+ ], AxisChainExecutor2);
1686
3138
  }
1687
3139
  });
1688
3140
 
@@ -2092,141 +3544,6 @@ var init_truth_scoring = __esm({
2092
3544
  }
2093
3545
  });
2094
3546
 
2095
- // src/core/constants.ts
2096
- var constants_exports = {};
2097
- __export(constants_exports, {
2098
- AXIS_MAGIC: () => AXIS_MAGIC,
2099
- AXIS_VERSION: () => AXIS_VERSION,
2100
- BodyProfile: () => BodyProfile,
2101
- ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
2102
- ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
2103
- ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
2104
- ERR_REPLAY_DETECTED: () => ERR_REPLAY_DETECTED,
2105
- FLAG_BODY_TLV: () => FLAG_BODY_TLV,
2106
- FLAG_CHAIN_REQ: () => FLAG_CHAIN_REQ,
2107
- FLAG_HAS_WITNESS: () => FLAG_HAS_WITNESS,
2108
- MAX_BODY_LEN: () => MAX_BODY_LEN,
2109
- MAX_FRAME_LEN: () => MAX_FRAME_LEN,
2110
- MAX_HDR_LEN: () => MAX_HDR_LEN,
2111
- MAX_SIG_LEN: () => MAX_SIG_LEN,
2112
- NCERT_ALG: () => NCERT_ALG,
2113
- NCERT_EXP: () => NCERT_EXP,
2114
- NCERT_ISSUER_KID: () => NCERT_ISSUER_KID,
2115
- NCERT_KID: () => NCERT_KID,
2116
- NCERT_NBF: () => NCERT_NBF,
2117
- NCERT_NODE_ID: () => NCERT_NODE_ID,
2118
- NCERT_PAYLOAD: () => NCERT_PAYLOAD,
2119
- NCERT_PUB: () => NCERT_PUB,
2120
- NCERT_SCOPE: () => NCERT_SCOPE,
2121
- NCERT_SIG: () => NCERT_SIG,
2122
- PROOF_CAPSULE: () => PROOF_CAPSULE,
2123
- PROOF_JWT: () => PROOF_JWT,
2124
- PROOF_LOOM: () => PROOF_LOOM,
2125
- PROOF_MTLS: () => PROOF_MTLS,
2126
- PROOF_NONE: () => PROOF_NONE,
2127
- PROOF_WITNESS: () => PROOF_WITNESS,
2128
- ProofType: () => ProofType,
2129
- TLV_ACTOR_ID: () => TLV_ACTOR_ID,
2130
- TLV_AUD: () => TLV_AUD,
2131
- TLV_BODY_ARR: () => TLV_BODY_ARR,
2132
- TLV_BODY_OBJ: () => TLV_BODY_OBJ,
2133
- TLV_CAPSULE: () => TLV_CAPSULE,
2134
- TLV_EFFECT: () => TLV_EFFECT,
2135
- TLV_ERROR_CODE: () => TLV_ERROR_CODE,
2136
- TLV_ERROR_MSG: () => TLV_ERROR_MSG,
2137
- TLV_INDEX: () => TLV_INDEX,
2138
- TLV_INTENT: () => TLV_INTENT,
2139
- TLV_KID: () => TLV_KID,
2140
- TLV_LOOM_PRESENCE_ID: () => TLV_LOOM_PRESENCE_ID,
2141
- TLV_LOOM_THREAD_HASH: () => TLV_LOOM_THREAD_HASH,
2142
- TLV_LOOM_WRIT: () => TLV_LOOM_WRIT,
2143
- TLV_NODE: () => TLV_NODE,
2144
- TLV_NODE_CERT_HASH: () => TLV_NODE_CERT_HASH,
2145
- TLV_NODE_KID: () => TLV_NODE_KID,
2146
- TLV_NONCE: () => TLV_NONCE,
2147
- TLV_OFFSET: () => TLV_OFFSET,
2148
- TLV_OK: () => TLV_OK,
2149
- TLV_PID: () => TLV_PID,
2150
- TLV_PREV_HASH: () => TLV_PREV_HASH,
2151
- TLV_PROOF_REF: () => TLV_PROOF_REF,
2152
- TLV_PROOF_TYPE: () => TLV_PROOF_TYPE,
2153
- TLV_REALM: () => TLV_REALM,
2154
- TLV_RECEIPT_HASH: () => TLV_RECEIPT_HASH,
2155
- TLV_RID: () => TLV_RID,
2156
- TLV_SHA256_CHUNK: () => TLV_SHA256_CHUNK,
2157
- TLV_TRACE_ID: () => TLV_TRACE_ID,
2158
- TLV_TS: () => TLV_TS,
2159
- TLV_UPLOAD_ID: () => TLV_UPLOAD_ID
2160
- });
2161
- import {
2162
- AXIS_MAGIC,
2163
- AXIS_VERSION,
2164
- MAX_HDR_LEN,
2165
- MAX_BODY_LEN,
2166
- MAX_SIG_LEN,
2167
- MAX_FRAME_LEN,
2168
- FLAG_BODY_TLV,
2169
- FLAG_CHAIN_REQ,
2170
- FLAG_HAS_WITNESS,
2171
- TLV_PID,
2172
- TLV_TS,
2173
- TLV_INTENT,
2174
- TLV_ACTOR_ID,
2175
- TLV_PROOF_TYPE,
2176
- TLV_PROOF_REF,
2177
- TLV_NONCE,
2178
- TLV_AUD,
2179
- TLV_REALM,
2180
- TLV_NODE,
2181
- TLV_TRACE_ID,
2182
- TLV_KID,
2183
- TLV_RID,
2184
- TLV_OK,
2185
- TLV_EFFECT,
2186
- TLV_ERROR_CODE,
2187
- TLV_ERROR_MSG,
2188
- TLV_PREV_HASH,
2189
- TLV_RECEIPT_HASH,
2190
- TLV_NODE_KID,
2191
- TLV_NODE_CERT_HASH,
2192
- TLV_LOOM_PRESENCE_ID,
2193
- TLV_LOOM_WRIT,
2194
- TLV_LOOM_THREAD_HASH,
2195
- TLV_UPLOAD_ID,
2196
- TLV_INDEX,
2197
- TLV_OFFSET,
2198
- TLV_SHA256_CHUNK,
2199
- TLV_CAPSULE,
2200
- TLV_BODY_OBJ,
2201
- TLV_BODY_ARR,
2202
- NCERT_NODE_ID,
2203
- NCERT_KID,
2204
- NCERT_ALG,
2205
- NCERT_PUB,
2206
- NCERT_NBF,
2207
- NCERT_EXP,
2208
- NCERT_SCOPE,
2209
- NCERT_ISSUER_KID,
2210
- NCERT_PAYLOAD,
2211
- NCERT_SIG,
2212
- PROOF_NONE,
2213
- PROOF_CAPSULE,
2214
- PROOF_JWT,
2215
- PROOF_MTLS,
2216
- PROOF_LOOM,
2217
- PROOF_WITNESS,
2218
- ProofType,
2219
- BodyProfile,
2220
- ERR_INVALID_PACKET,
2221
- ERR_BAD_SIGNATURE,
2222
- ERR_REPLAY_DETECTED,
2223
- ERR_CONTRACT_VIOLATION
2224
- } from "@nextera.one/axis-protocol";
2225
- var init_constants = __esm({
2226
- "src/core/constants.ts"() {
2227
- }
2228
- });
2229
-
2230
3547
  // src/engine/observation/response-observer.ts
2231
3548
  function verifyResponse(ctx, response) {
2232
3549
  if (!response.effect || typeof response.effect !== "string") {
@@ -3665,37 +4982,6 @@ var init_packet = __esm({
3665
4982
  }
3666
4983
  });
3667
4984
 
3668
- // src/security/scopes.ts
3669
- function hasScope(scopes, required) {
3670
- if (!Array.isArray(scopes) || scopes.length === 0) {
3671
- return false;
3672
- }
3673
- if (scopes.includes(required)) {
3674
- return true;
3675
- }
3676
- const [resource, id] = required.split(":");
3677
- if (resource && id) {
3678
- const wildcard = `${resource}:*`;
3679
- if (scopes.includes(wildcard)) {
3680
- return true;
3681
- }
3682
- }
3683
- return false;
3684
- }
3685
- function parseScope(scope) {
3686
- const parts = scope.split(":");
3687
- if (parts.length !== 2) return null;
3688
- return { resource: parts[0], id: parts[1] };
3689
- }
3690
- function canAccessResource(scopes, resourceType, resourceId) {
3691
- const required = `${resourceType}:${resourceId}`;
3692
- return hasScope(scopes, required);
3693
- }
3694
- var init_scopes = __esm({
3695
- "src/security/scopes.ts"() {
3696
- }
3697
- });
3698
-
3699
4985
  // src/security/capabilities.ts
3700
4986
  var CAPABILITIES, PROOF_CAPABILITIES, INTENT_REQUIREMENTS;
3701
4987
  var init_capabilities = __esm({
@@ -4425,23 +5711,62 @@ var require_axis_request_decorator = __commonJS({
4425
5711
  }
4426
5712
  });
4427
5713
 
4428
- // src/core/axis-error.ts
4429
- var axis_error_exports = {};
4430
- __export(axis_error_exports, {
4431
- AxisError: () => AxisError
4432
- });
4433
- var AxisError;
4434
- var init_axis_error = __esm({
4435
- "src/core/axis-error.ts"() {
4436
- AxisError = class extends Error {
4437
- constructor(code, message, httpStatus = 400, details) {
4438
- super(message);
4439
- this.code = code;
4440
- this.httpStatus = httpStatus;
4441
- this.details = details;
4442
- this.name = "AxisError";
5714
+ // src/engine/observer-discovery.service.ts
5715
+ var require_observer_discovery_service = __commonJS({
5716
+ "src/engine/observer-discovery.service.ts"(exports) {
5717
+ "use strict";
5718
+ var __decorate = exports && exports.__decorate || function(decorators, target, key, desc) {
5719
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5720
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5721
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5722
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5723
+ };
5724
+ var __metadata = exports && exports.__metadata || function(k, v) {
5725
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5726
+ };
5727
+ var ObserverDiscoveryService_1;
5728
+ var _a;
5729
+ var _b;
5730
+ var _c;
5731
+ Object.defineProperty(exports, "__esModule", { value: true });
5732
+ exports.ObserverDiscoveryService = void 0;
5733
+ var common_1 = __require("@nestjs/common");
5734
+ var core_1 = __require("@nestjs/core");
5735
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
5736
+ var observer_registry_1 = require_observer_registry();
5737
+ var ObserverDiscoveryService2 = ObserverDiscoveryService_1 = class ObserverDiscoveryService {
5738
+ constructor(discovery, reflector, registry) {
5739
+ this.discovery = discovery;
5740
+ this.reflector = reflector;
5741
+ this.registry = registry;
5742
+ this.logger = new common_1.Logger(ObserverDiscoveryService_1.name);
5743
+ }
5744
+ onApplicationBootstrap() {
5745
+ const providers = this.discovery.getProviders();
5746
+ let count = 0;
5747
+ for (const wrapper of providers) {
5748
+ const { instance } = wrapper;
5749
+ if (!instance || !instance.constructor)
5750
+ continue;
5751
+ const meta = this.reflector.get(observer_decorator_1.OBSERVER_METADATA_KEY, instance.constructor);
5752
+ if (!meta)
5753
+ continue;
5754
+ const observer = instance;
5755
+ if (typeof observer.observe !== "function") {
5756
+ this.logger.warn(`@Observer on ${instance.constructor.name} is missing observe() and was skipped`);
5757
+ continue;
5758
+ }
5759
+ this.registry.register(observer, meta);
5760
+ count++;
5761
+ }
5762
+ this.logger.log(`Auto-registered ${count} observers via @Observer()`);
4443
5763
  }
4444
5764
  };
5765
+ exports.ObserverDiscoveryService = ObserverDiscoveryService2;
5766
+ exports.ObserverDiscoveryService = ObserverDiscoveryService2 = ObserverDiscoveryService_1 = __decorate([
5767
+ (0, common_1.Injectable)(),
5768
+ __metadata("design:paramtypes", [typeof (_a = typeof core_1.DiscoveryService !== "undefined" && core_1.DiscoveryService) === "function" ? _a : Object, typeof (_b = typeof core_1.Reflector !== "undefined" && core_1.Reflector) === "function" ? _b : Object, typeof (_c = typeof observer_registry_1.ObserverRegistry !== "undefined" && observer_registry_1.ObserverRegistry) === "function" ? _c : Object])
5769
+ ], ObserverDiscoveryService2);
4445
5770
  }
4446
5771
  });
4447
5772
 
@@ -4466,6 +5791,7 @@ var require_handler_discovery_service = __commonJS({
4466
5791
  exports.HandlerDiscoveryService = void 0;
4467
5792
  var common_1 = __require("@nestjs/common");
4468
5793
  var core_1 = __require("@nestjs/core");
5794
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
4469
5795
  var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
4470
5796
  var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
4471
5797
  var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
@@ -4488,20 +5814,36 @@ var require_handler_discovery_service = __commonJS({
4488
5814
  if (!handlerMeta)
4489
5815
  continue;
4490
5816
  const handlerName = handlerMeta.intent || metatype.name;
5817
+ const prefix = handlerMeta.intent || metatype.name;
4491
5818
  const proto = Object.getPrototypeOf(instance);
4492
5819
  const methods = this.scanner.getAllMethodNames(proto);
5820
+ const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, metatype) || [];
5821
+ const routedMethods = new Set(routes.map((route) => String(route.methodName)));
4493
5822
  let registered = 0;
4494
5823
  const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, metatype) || [];
5824
+ const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, metatype) || [];
5825
+ for (const route of routes) {
5826
+ const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
5827
+ if (!this.router.has(intentName)) {
5828
+ this.router.register(intentName, instance[route.methodName].bind(instance));
5829
+ registered++;
5830
+ totalIntents++;
5831
+ }
5832
+ this.router.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
5833
+ }
4495
5834
  for (const methodName of methods) {
5835
+ if (routedMethods.has(methodName))
5836
+ continue;
4496
5837
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
4497
5838
  if (!meta?.intent)
4498
5839
  continue;
4499
- if (!this.router.has(meta.intent)) {
4500
- this.router.register(meta.intent, instance[methodName].bind(instance));
5840
+ const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
5841
+ if (!this.router.has(intentName)) {
5842
+ this.router.register(intentName, instance[methodName].bind(instance));
4501
5843
  registered++;
4502
5844
  totalIntents++;
4503
5845
  }
4504
- this.router.registerIntentMeta(meta.intent, proto, methodName, handlerSensors);
5846
+ this.router.registerIntentMeta(intentName, proto, methodName, handlerSensors, handlerObservers);
4505
5847
  }
4506
5848
  if (registered > 0) {
4507
5849
  this.logger.log(`Auto-registered ${registered} intents from ${handlerName}`);
@@ -8075,6 +9417,10 @@ var init_crypto = __esm({
8075
9417
  // src/decorators/index.ts
8076
9418
  var decorators_exports = {};
8077
9419
  __export(decorators_exports, {
9420
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
9421
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
9422
+ CapsulePolicy: () => CapsulePolicy,
9423
+ Chain: () => Chain,
8078
9424
  HANDLER_METADATA_KEY: () => HANDLER_METADATA_KEY,
8079
9425
  Handler: () => Handler,
8080
9426
  INTENT_BODY_KEY: () => INTENT_BODY_KEY,
@@ -8084,17 +9430,25 @@ __export(decorators_exports, {
8084
9430
  Intent: () => Intent,
8085
9431
  IntentBody: () => IntentBody,
8086
9432
  IntentSensors: () => IntentSensors,
9433
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
9434
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
9435
+ Observer: () => Observer,
8087
9436
  SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
8088
- Sensor: () => Sensor
9437
+ Sensor: () => Sensor,
9438
+ mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
9439
+ normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
8089
9440
  });
8090
9441
  var init_decorators = __esm({
8091
9442
  "src/decorators/index.ts"() {
8092
9443
  __reExport(decorators_exports, __toESM(require_axis_request_decorator()));
9444
+ init_capsule_policy_decorator();
9445
+ init_chain_decorator();
8093
9446
  __reExport(decorators_exports, __toESM(require_dto_schema_util()));
8094
9447
  init_handler_decorator();
8095
9448
  init_intent_body_decorator();
8096
9449
  init_intent_sensors_decorator();
8097
9450
  init_intent_decorator();
9451
+ init_observer_decorator();
8098
9452
  init_sensor_decorator();
8099
9453
  __reExport(decorators_exports, __toESM(require_tlv_field_decorator()));
8100
9454
  }
@@ -8106,6 +9460,18 @@ var init_axis_decoded = __esm({
8106
9460
  }
8107
9461
  });
8108
9462
 
9463
+ // src/engine/axis-chain.types.ts
9464
+ var init_axis_chain_types = __esm({
9465
+ "src/engine/axis-chain.types.ts"() {
9466
+ }
9467
+ });
9468
+
9469
+ // src/engine/axis-observer.interface.ts
9470
+ var init_axis_observer_interface = __esm({
9471
+ "src/engine/axis-observer.interface.ts"() {
9472
+ }
9473
+ });
9474
+
8109
9475
  // src/engine/observation/observation-queue.types.ts
8110
9476
  var init_observation_queue_types = __esm({
8111
9477
  "src/engine/observation/observation-queue.types.ts"() {
@@ -8140,6 +9506,7 @@ var init_observation = __esm({
8140
9506
  // src/engine/index.ts
8141
9507
  var engine_exports = {};
8142
9508
  __export(engine_exports, {
9509
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
8143
9510
  BAND: () => BAND,
8144
9511
  PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
8145
9512
  ResponseObserver: () => ResponseObserver,
@@ -8151,24 +9518,34 @@ __export(engine_exports, {
8151
9518
  encodeQueueMessage: () => encodeQueueMessage,
8152
9519
  endStage: () => endStage,
8153
9520
  finalizeObservation: () => finalizeObservation,
9521
+ getAxisExecutionContext: () => getAxisExecutionContext,
8154
9522
  hashObservation: () => hashObservation,
9523
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
8155
9524
  observation: () => observation_exports,
8156
9525
  parseAutoClaimEntries: () => parseAutoClaimEntries,
8157
9526
  parseStreamEntries: () => parseStreamEntries,
8158
9527
  recordSensor: () => recordSensor,
8159
9528
  stableJsonStringify: () => stableJsonStringify,
8160
9529
  startStage: () => startStage,
8161
- verifyResponse: () => verifyResponse
9530
+ verifyResponse: () => verifyResponse,
9531
+ withAxisExecutionContext: () => withAxisExecutionContext
8162
9532
  });
8163
9533
  var init_engine = __esm({
8164
9534
  "src/engine/index.ts"() {
8165
9535
  init_axis_decoded();
9536
+ __reExport(engine_exports, __toESM(require_axis_chain_executor()));
9537
+ init_axis_chain_types();
9538
+ init_axis_execution_context();
8166
9539
  init_axis_observation();
9540
+ init_axis_observer_interface();
8167
9541
  __reExport(engine_exports, __toESM(require_handler_discovery_service()));
8168
9542
  __reExport(engine_exports, __toESM(require_intent_router()));
8169
9543
  init_observation();
9544
+ __reExport(engine_exports, __toESM(require_observer_discovery_service()));
9545
+ __reExport(engine_exports, __toESM(require_observer_dispatcher_service()));
8170
9546
  init_sensor_bands();
8171
9547
  __reExport(engine_exports, __toESM(require_sensor_discovery_service()));
9548
+ __reExport(engine_exports, __toESM(require_observer_registry()));
8172
9549
  __reExport(engine_exports, __toESM(require_sensor_registry()));
8173
9550
  init_observation();
8174
9551
  }
@@ -10473,6 +11850,7 @@ var index_exports = {};
10473
11850
  __export(index_exports, {
10474
11851
  ATS1_HDR: () => ATS1_HDR,
10475
11852
  ATS1_SCHEMA: () => ATS1_SCHEMA,
11853
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
10476
11854
  AXIS_MAGIC: () => AXIS_MAGIC,
10477
11855
  AXIS_OPCODES: () => AXIS_OPCODES,
10478
11856
  AXIS_UPLOAD_FILE_STORE: () => AXIS_UPLOAD_FILE_STORE,
@@ -10480,6 +11858,7 @@ __export(index_exports, {
10480
11858
  AXIS_UPLOAD_SESSION_STORE: () => AXIS_UPLOAD_SESSION_STORE,
10481
11859
  AXIS_VERSION: () => AXIS_VERSION,
10482
11860
  Ats1Codec: () => ats1_exports,
11861
+ AxisChainExecutor: () => import_axis_chain.AxisChainExecutor,
10483
11862
  AxisContext: () => import_axis_request.AxisContext,
10484
11863
  AxisDemoPubkey: () => import_axis_request.AxisDemoPubkey,
10485
11864
  AxisEffect: () => import_intent2.AxisEffect,
@@ -10498,9 +11877,13 @@ __export(index_exports, {
10498
11877
  BAND: () => BAND,
10499
11878
  BodyProfile: () => BodyProfile,
10500
11879
  CAPABILITIES: () => CAPABILITIES,
11880
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
10501
11881
  CCE_ERROR: () => CCE_ERROR,
10502
11882
  CCE_PROTOCOL_VERSION: () => CCE_PROTOCOL_VERSION,
11883
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
11884
+ CapsulePolicy: () => CapsulePolicy,
10503
11885
  CceError: () => CceError,
11886
+ Chain: () => Chain,
10504
11887
  ContractViolationError: () => ContractViolationError,
10505
11888
  DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
10506
11889
  DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
@@ -10550,6 +11933,12 @@ __export(index_exports, {
10550
11933
  NCERT_PUB: () => NCERT_PUB,
10551
11934
  NCERT_SCOPE: () => NCERT_SCOPE,
10552
11935
  NCERT_SIG: () => NCERT_SIG,
11936
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
11937
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
11938
+ Observer: () => Observer,
11939
+ ObserverDiscoveryService: () => import_observer_discovery.ObserverDiscoveryService,
11940
+ ObserverDispatcherService: () => import_observer_dispatcher.ObserverDispatcherService,
11941
+ ObserverRegistry: () => import_observer2.ObserverRegistry,
10553
11942
  PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
10554
11943
  PROOF_CAPABILITIES: () => PROOF_CAPABILITIES,
10555
11944
  PROOF_CAPSULE: () => PROOF_CAPSULE,
@@ -10690,6 +12079,7 @@ __export(index_exports, {
10690
12079
  forkFromKnot: () => forkFromKnot,
10691
12080
  formStitch: () => formStitch,
10692
12081
  generateEd25519KeyPair: () => generateEd25519KeyPair,
12082
+ getAxisExecutionContext: () => getAxisExecutionContext,
10693
12083
  getDecisionPoints: () => getDecisionPoints,
10694
12084
  getFabricValue: () => getFabricValue,
10695
12085
  getGrantStatus: () => getGrantStatus,
@@ -10709,6 +12099,7 @@ __export(index_exports, {
10709
12099
  lockCells: () => lockCells,
10710
12100
  loom: () => loom_exports,
10711
12101
  matchPatterns: () => matchPatterns,
12102
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
10712
12103
  needle: () => needle_exports,
10713
12104
  nonce16: () => nonce16,
10714
12105
  normalizeSensorDecision: () => normalizeSensorDecision,
@@ -10759,15 +12150,19 @@ __export(index_exports, {
10759
12150
  verifyPresenceProof: () => verifyPresenceProof,
10760
12151
  verifyReceiptChain: () => verifyReceiptChain,
10761
12152
  verifyResponse: () => verifyResponse,
10762
- weave: () => weave
12153
+ weave: () => weave,
12154
+ withAxisExecutionContext: () => withAxisExecutionContext
10763
12155
  });
10764
- var import_tlv_field2, import_dto_schema, import_axis_id, import_axis_response, import_intent2, import_axis_files, import_axis_request, import_handler_discovery, import_sensor_discovery, import_sensor2, import_axis_sensor_chain, import_tps, import_risk_gate, import_tickauth;
12156
+ var import_tlv_field2, import_dto_schema, import_axis_id, import_axis_response, import_axis_chain, import_intent2, import_axis_files, import_axis_request, import_observer_discovery, import_observer_dispatcher, import_handler_discovery, import_sensor_discovery, import_observer2, import_sensor2, import_axis_sensor_chain, import_tps, import_risk_gate, import_tickauth;
10765
12157
  var init_index = __esm({
10766
12158
  "src/index.ts"() {
12159
+ init_chain_decorator();
12160
+ init_capsule_policy_decorator();
10767
12161
  init_handler_decorator();
10768
12162
  init_intent_decorator();
10769
12163
  init_intent_body_decorator();
10770
12164
  init_intent_sensors_decorator();
12165
+ init_observer_decorator();
10771
12166
  init_handler_sensors_decorator();
10772
12167
  init_sensor_decorator();
10773
12168
  import_tlv_field2 = __toESM(require_tlv_field_decorator());
@@ -10776,6 +12171,8 @@ var init_index = __esm({
10776
12171
  import_axis_id = __toESM(require_axis_id_dto());
10777
12172
  init_axis_partial_type();
10778
12173
  import_axis_response = __toESM(require_axis_response_dto());
12174
+ import_axis_chain = __toESM(require_axis_chain_executor());
12175
+ init_axis_execution_context();
10779
12176
  import_intent2 = __toESM(require_intent_router());
10780
12177
  init_sensor_bands();
10781
12178
  init_stable_json();
@@ -10815,8 +12212,11 @@ var init_index = __esm({
10815
12212
  init_disk_upload_file_store();
10816
12213
  import_axis_request = __toESM(require_axis_request_decorator());
10817
12214
  init_axis_error();
12215
+ import_observer_discovery = __toESM(require_observer_discovery_service());
12216
+ import_observer_dispatcher = __toESM(require_observer_dispatcher_service());
10818
12217
  import_handler_discovery = __toESM(require_handler_discovery_service());
10819
12218
  import_sensor_discovery = __toESM(require_sensor_discovery_service());
12219
+ import_observer2 = __toESM(require_observer_registry());
10820
12220
  import_sensor2 = __toESM(require_sensor_registry());
10821
12221
  init_axis_observation();
10822
12222
  import_axis_sensor_chain = __toESM(require_axis_sensor_chain_service());
@@ -10851,6 +12251,7 @@ var init_index = __esm({
10851
12251
  }
10852
12252
  });
10853
12253
  init_index();
12254
+ var export_AxisChainExecutor = import_axis_chain.AxisChainExecutor;
10854
12255
  var export_AxisContext = import_axis_request.AxisContext;
10855
12256
  var export_AxisDemoPubkey = import_axis_request.AxisDemoPubkey;
10856
12257
  var export_AxisEffect = import_intent2.AxisEffect;
@@ -10863,6 +12264,9 @@ var export_AxisResponseDto = import_axis_response.AxisResponseDto;
10863
12264
  var export_AxisSensorChainService = import_axis_sensor_chain.AxisSensorChainService;
10864
12265
  var export_HandlerDiscoveryService = import_handler_discovery.HandlerDiscoveryService;
10865
12266
  var export_IntentRouter = import_intent2.IntentRouter;
12267
+ var export_ObserverDiscoveryService = import_observer_discovery.ObserverDiscoveryService;
12268
+ var export_ObserverDispatcherService = import_observer_dispatcher.ObserverDispatcherService;
12269
+ var export_ObserverRegistry = import_observer2.ObserverRegistry;
10866
12270
  var export_RESPONSE_TAG_CREATED_AT = import_axis_response.RESPONSE_TAG_CREATED_AT;
10867
12271
  var export_RESPONSE_TAG_CREATED_BY = import_axis_response.RESPONSE_TAG_CREATED_BY;
10868
12272
  var export_RESPONSE_TAG_ID = import_axis_response.RESPONSE_TAG_ID;
@@ -10886,6 +12290,7 @@ var export_extractDtoSchema = import_dto_schema.extractDtoSchema;
10886
12290
  export {
10887
12291
  ATS1_HDR,
10888
12292
  ATS1_SCHEMA,
12293
+ AXIS_EXECUTION_CONTEXT_KEY,
10889
12294
  AXIS_MAGIC,
10890
12295
  AXIS_OPCODES,
10891
12296
  AXIS_UPLOAD_FILE_STORE,
@@ -10893,6 +12298,7 @@ export {
10893
12298
  AXIS_UPLOAD_SESSION_STORE,
10894
12299
  AXIS_VERSION,
10895
12300
  ats1_exports as Ats1Codec,
12301
+ export_AxisChainExecutor as AxisChainExecutor,
10896
12302
  export_AxisContext as AxisContext,
10897
12303
  export_AxisDemoPubkey as AxisDemoPubkey,
10898
12304
  export_AxisEffect as AxisEffect,
@@ -10911,9 +12317,13 @@ export {
10911
12317
  BAND,
10912
12318
  BodyProfile,
10913
12319
  CAPABILITIES,
12320
+ CAPSULE_POLICY_METADATA_KEY,
10914
12321
  CCE_ERROR,
10915
12322
  CCE_PROTOCOL_VERSION,
12323
+ CHAIN_METADATA_KEY,
12324
+ CapsulePolicy,
10916
12325
  CceError,
12326
+ Chain,
10917
12327
  ContractViolationError,
10918
12328
  DEFAULT_CONTRACTS,
10919
12329
  DEFAULT_TIMEOUT,
@@ -10963,6 +12373,12 @@ export {
10963
12373
  NCERT_PUB,
10964
12374
  NCERT_SCOPE,
10965
12375
  NCERT_SIG,
12376
+ OBSERVER_BINDINGS_KEY,
12377
+ OBSERVER_METADATA_KEY,
12378
+ Observer,
12379
+ export_ObserverDiscoveryService as ObserverDiscoveryService,
12380
+ export_ObserverDispatcherService as ObserverDispatcherService,
12381
+ export_ObserverRegistry as ObserverRegistry,
10966
12382
  PRE_DECODE_BOUNDARY,
10967
12383
  PROOF_CAPABILITIES,
10968
12384
  PROOF_CAPSULE,
@@ -11103,6 +12519,7 @@ export {
11103
12519
  forkFromKnot,
11104
12520
  formStitch,
11105
12521
  generateEd25519KeyPair,
12522
+ getAxisExecutionContext,
11106
12523
  getDecisionPoints,
11107
12524
  getFabricValue,
11108
12525
  getGrantStatus,
@@ -11122,6 +12539,7 @@ export {
11122
12539
  lockCells,
11123
12540
  loom_exports as loom,
11124
12541
  matchPatterns,
12542
+ mergeAxisExecutionContext,
11125
12543
  needle_exports as needle,
11126
12544
  nonce16,
11127
12545
  normalizeSensorDecision,
@@ -11172,6 +12590,7 @@ export {
11172
12590
  verifyPresenceProof,
11173
12591
  verifyReceiptChain,
11174
12592
  verifyResponse,
11175
- weave
12593
+ weave,
12594
+ withAxisExecutionContext
11176
12595
  };
11177
12596
  //# sourceMappingURL=index.mjs.map