@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.js CHANGED
@@ -33,6 +33,106 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
+ // src/decorators/chain.decorator.ts
37
+ var chain_decorator_exports = {};
38
+ __export(chain_decorator_exports, {
39
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
40
+ Chain: () => Chain
41
+ });
42
+ function Chain(options = {}) {
43
+ return (target, propertyKey) => {
44
+ const value = {
45
+ enabled: true,
46
+ ...options
47
+ };
48
+ Reflect.defineMetadata(CHAIN_METADATA_KEY, value, target, propertyKey);
49
+ };
50
+ }
51
+ var import_reflect_metadata, CHAIN_METADATA_KEY;
52
+ var init_chain_decorator = __esm({
53
+ "src/decorators/chain.decorator.ts"() {
54
+ import_reflect_metadata = require("reflect-metadata");
55
+ CHAIN_METADATA_KEY = "axis:chain";
56
+ }
57
+ });
58
+
59
+ // src/decorators/capsule-policy.decorator.ts
60
+ var capsule_policy_decorator_exports = {};
61
+ __export(capsule_policy_decorator_exports, {
62
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
63
+ CapsulePolicy: () => CapsulePolicy,
64
+ mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
65
+ normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
66
+ });
67
+ function CapsulePolicy(options = {}) {
68
+ const normalized = normalizeCapsulePolicyOptions(options);
69
+ return ((target, propertyKey) => {
70
+ if (propertyKey !== void 0) {
71
+ Reflect.defineMetadata(
72
+ CAPSULE_POLICY_METADATA_KEY,
73
+ normalized,
74
+ target,
75
+ propertyKey
76
+ );
77
+ return;
78
+ }
79
+ Reflect.defineMetadata(
80
+ CAPSULE_POLICY_METADATA_KEY,
81
+ normalized,
82
+ target
83
+ );
84
+ });
85
+ }
86
+ function normalizeCapsulePolicyOptions(options = {}) {
87
+ return {
88
+ required: options.required ?? true,
89
+ scopes: normalizeScopeValue(options.scopes),
90
+ scopeMode: options.scopeMode ?? "all",
91
+ intentBound: options.intentBound ?? true,
92
+ allowCapsuleRef: options.allowCapsuleRef ?? false
93
+ };
94
+ }
95
+ function mergeCapsulePolicyOptions(base, override) {
96
+ if (!base && !override) {
97
+ return void 0;
98
+ }
99
+ const normalizedBase = base ? normalizeCapsulePolicyOptions(base) : void 0;
100
+ const normalizedOverride = override ? normalizeCapsulePolicyOptions(override) : void 0;
101
+ const scopes = [
102
+ ...toScopeList(normalizedBase?.scopes),
103
+ ...toScopeList(normalizedOverride?.scopes)
104
+ ];
105
+ return {
106
+ required: normalizedOverride?.required ?? normalizedBase?.required ?? true,
107
+ scopes: normalizeScopeValue(scopes),
108
+ scopeMode: normalizedOverride?.scopeMode ?? normalizedBase?.scopeMode ?? "all",
109
+ intentBound: normalizedOverride?.intentBound ?? normalizedBase?.intentBound ?? true,
110
+ allowCapsuleRef: normalizedOverride?.allowCapsuleRef ?? normalizedBase?.allowCapsuleRef ?? false
111
+ };
112
+ }
113
+ function normalizeScopeValue(value) {
114
+ const list = toScopeList(value);
115
+ if (list.length === 0) {
116
+ return void 0;
117
+ }
118
+ return list.length === 1 ? list[0] : list;
119
+ }
120
+ function toScopeList(value) {
121
+ if (!value) {
122
+ return [];
123
+ }
124
+ return Array.from(new Set(Array.isArray(value) ? value : [value])).filter(
125
+ (entry) => entry.trim().length > 0
126
+ );
127
+ }
128
+ var import_reflect_metadata2, CAPSULE_POLICY_METADATA_KEY;
129
+ var init_capsule_policy_decorator = __esm({
130
+ "src/decorators/capsule-policy.decorator.ts"() {
131
+ import_reflect_metadata2 = require("reflect-metadata");
132
+ CAPSULE_POLICY_METADATA_KEY = "axis:capsule:policy";
133
+ }
134
+ });
135
+
36
136
  // src/decorators/handler.decorator.ts
37
137
  var handler_decorator_exports = {};
38
138
  __export(handler_decorator_exports, {
@@ -75,6 +175,7 @@ function Intent(action, options) {
75
175
  absolute: options?.absolute,
76
176
  frame: options?.frame,
77
177
  kind: options?.kind,
178
+ chain: options?.chain,
78
179
  bodyProfile: options?.bodyProfile,
79
180
  tlv: options?.tlv,
80
181
  dto: options?.dto
@@ -82,10 +183,10 @@ function Intent(action, options) {
82
183
  Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
83
184
  };
84
185
  }
85
- var import_reflect_metadata, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
186
+ var import_reflect_metadata3, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
86
187
  var init_intent_decorator = __esm({
87
188
  "src/decorators/intent.decorator.ts"() {
88
- import_reflect_metadata = require("reflect-metadata");
189
+ import_reflect_metadata3 = require("reflect-metadata");
89
190
  INTENT_METADATA_KEY = "axis:intent";
90
191
  INTENT_ROUTES_KEY = "axis:intent_routes";
91
192
  }
@@ -102,10 +203,10 @@ function IntentBody(decoder) {
102
203
  Reflect.defineMetadata(INTENT_BODY_KEY, decoder, target, propertyKey);
103
204
  };
104
205
  }
105
- var import_reflect_metadata2, INTENT_BODY_KEY;
206
+ var import_reflect_metadata4, INTENT_BODY_KEY;
106
207
  var init_intent_body_decorator = __esm({
107
208
  "src/decorators/intent-body.decorator.ts"() {
108
- import_reflect_metadata2 = require("reflect-metadata");
209
+ import_reflect_metadata4 = require("reflect-metadata");
109
210
  INTENT_BODY_KEY = "axis:intent:body";
110
211
  }
111
212
  });
@@ -121,14 +222,81 @@ function IntentSensors(sensors) {
121
222
  Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
122
223
  };
123
224
  }
124
- var import_reflect_metadata3, INTENT_SENSORS_KEY;
225
+ var import_reflect_metadata5, INTENT_SENSORS_KEY;
125
226
  var init_intent_sensors_decorator = __esm({
126
227
  "src/decorators/intent-sensors.decorator.ts"() {
127
- import_reflect_metadata3 = require("reflect-metadata");
228
+ import_reflect_metadata5 = require("reflect-metadata");
128
229
  INTENT_SENSORS_KEY = "axis:intent:sensors";
129
230
  }
130
231
  });
131
232
 
233
+ // src/decorators/observer.decorator.ts
234
+ var observer_decorator_exports = {};
235
+ __export(observer_decorator_exports, {
236
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
237
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
238
+ Observer: () => Observer
239
+ });
240
+ function isBindingOptions(value) {
241
+ return !!value && typeof value === "object" && "use" in value;
242
+ }
243
+ function isDefinitionOptions(value) {
244
+ return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
245
+ }
246
+ function toBinding(input) {
247
+ if (!input) return null;
248
+ if (isBindingOptions(input)) {
249
+ const refs = Array.isArray(input.use) ? input.use : [input.use];
250
+ return { refs, tags: input.tags, events: input.events };
251
+ }
252
+ if (Array.isArray(input)) {
253
+ return { refs: input };
254
+ }
255
+ if (typeof input === "function" || typeof input === "string") {
256
+ return { refs: [input] };
257
+ }
258
+ return null;
259
+ }
260
+ function Observer(input) {
261
+ return ((target, propertyKey) => {
262
+ const binding = toBinding(input);
263
+ if (binding) {
264
+ if (propertyKey !== void 0) {
265
+ const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
266
+ existing2.push(binding);
267
+ Reflect.defineMetadata(
268
+ OBSERVER_BINDINGS_KEY,
269
+ existing2,
270
+ target,
271
+ propertyKey
272
+ );
273
+ return;
274
+ }
275
+ const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
276
+ existing.push(binding);
277
+ Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
278
+ return;
279
+ }
280
+ if (propertyKey !== void 0) {
281
+ throw new Error(
282
+ "@Observer method usage must reference one or more observer classes or names"
283
+ );
284
+ }
285
+ const definition = isDefinitionOptions(input) ? input : {};
286
+ Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
287
+ (0, import_common2.Injectable)()(target);
288
+ });
289
+ }
290
+ var import_reflect_metadata6, import_common2, OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
291
+ var init_observer_decorator = __esm({
292
+ "src/decorators/observer.decorator.ts"() {
293
+ import_reflect_metadata6 = require("reflect-metadata");
294
+ import_common2 = require("@nestjs/common");
295
+ OBSERVER_METADATA_KEY = "axis:observer";
296
+ OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
297
+ }
298
+ });
299
+
132
300
  // src/decorators/handler-sensors.decorator.ts
133
301
  var handler_sensors_decorator_exports = {};
134
302
  __export(handler_sensors_decorator_exports, {
@@ -140,10 +308,10 @@ function HandlerSensors(sensors) {
140
308
  Reflect.defineMetadata(HANDLER_SENSORS_KEY, sensors, target);
141
309
  };
142
310
  }
143
- var import_reflect_metadata4, HANDLER_SENSORS_KEY;
311
+ var import_reflect_metadata7, HANDLER_SENSORS_KEY;
144
312
  var init_handler_sensors_decorator = __esm({
145
313
  "src/decorators/handler-sensors.decorator.ts"() {
146
- import_reflect_metadata4 = require("reflect-metadata");
314
+ import_reflect_metadata7 = require("reflect-metadata");
147
315
  HANDLER_SENSORS_KEY = "axis:handler:sensors";
148
316
  }
149
317
  });
@@ -155,12 +323,12 @@ __export(sensor_decorator_exports, {
155
323
  Sensor: () => Sensor
156
324
  });
157
325
  function Sensor(options) {
158
- return (0, import_common2.SetMetadata)(SENSOR_METADATA_KEY, options ?? true);
326
+ return (0, import_common3.SetMetadata)(SENSOR_METADATA_KEY, options ?? true);
159
327
  }
160
- var import_common2, SENSOR_METADATA_KEY;
328
+ var import_common3, SENSOR_METADATA_KEY;
161
329
  var init_sensor_decorator = __esm({
162
330
  "src/decorators/sensor.decorator.ts"() {
163
- import_common2 = require("@nestjs/common");
331
+ import_common3 = require("@nestjs/common");
164
332
  SENSOR_METADATA_KEY = "axis:sensor";
165
333
  }
166
334
  });
@@ -420,10 +588,10 @@ function AxisPartialType(BaseDto) {
420
588
  });
421
589
  return PartialDto;
422
590
  }
423
- var import_reflect_metadata5, import_tlv_field;
591
+ var import_reflect_metadata8, import_tlv_field;
424
592
  var init_axis_partial_type = __esm({
425
593
  "src/base/axis-partial-type.ts"() {
426
- import_reflect_metadata5 = require("reflect-metadata");
594
+ import_reflect_metadata8 = require("reflect-metadata");
427
595
  import_tlv_field = __toESM(require_tlv_field_decorator());
428
596
  }
429
597
  });
@@ -476,131 +644,264 @@ var require_axis_response_dto = __commonJS({
476
644
  }
477
645
  });
478
646
 
479
- // src/sensor/axis-sensor.ts
480
- var axis_sensor_exports = {};
481
- __export(axis_sensor_exports, {
482
- Decision: () => Decision,
483
- SensorDecisions: () => SensorDecisions,
484
- normalizeSensorDecision: () => normalizeSensorDecision
647
+ // src/core/constants.ts
648
+ var constants_exports = {};
649
+ __export(constants_exports, {
650
+ AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
651
+ AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
652
+ BodyProfile: () => import_axis_protocol2.BodyProfile,
653
+ ERR_BAD_SIGNATURE: () => import_axis_protocol2.ERR_BAD_SIGNATURE,
654
+ ERR_CONTRACT_VIOLATION: () => import_axis_protocol2.ERR_CONTRACT_VIOLATION,
655
+ ERR_INVALID_PACKET: () => import_axis_protocol2.ERR_INVALID_PACKET,
656
+ ERR_REPLAY_DETECTED: () => import_axis_protocol2.ERR_REPLAY_DETECTED,
657
+ FLAG_BODY_TLV: () => import_axis_protocol2.FLAG_BODY_TLV,
658
+ FLAG_CHAIN_REQ: () => import_axis_protocol2.FLAG_CHAIN_REQ,
659
+ FLAG_HAS_WITNESS: () => import_axis_protocol2.FLAG_HAS_WITNESS,
660
+ MAX_BODY_LEN: () => import_axis_protocol2.MAX_BODY_LEN,
661
+ MAX_FRAME_LEN: () => import_axis_protocol2.MAX_FRAME_LEN,
662
+ MAX_HDR_LEN: () => import_axis_protocol2.MAX_HDR_LEN,
663
+ MAX_SIG_LEN: () => import_axis_protocol2.MAX_SIG_LEN,
664
+ NCERT_ALG: () => import_axis_protocol2.NCERT_ALG,
665
+ NCERT_EXP: () => import_axis_protocol2.NCERT_EXP,
666
+ NCERT_ISSUER_KID: () => import_axis_protocol2.NCERT_ISSUER_KID,
667
+ NCERT_KID: () => import_axis_protocol2.NCERT_KID,
668
+ NCERT_NBF: () => import_axis_protocol2.NCERT_NBF,
669
+ NCERT_NODE_ID: () => import_axis_protocol2.NCERT_NODE_ID,
670
+ NCERT_PAYLOAD: () => import_axis_protocol2.NCERT_PAYLOAD,
671
+ NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
672
+ NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
673
+ NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
674
+ PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
675
+ PROOF_JWT: () => import_axis_protocol2.PROOF_JWT,
676
+ PROOF_LOOM: () => import_axis_protocol2.PROOF_LOOM,
677
+ PROOF_MTLS: () => import_axis_protocol2.PROOF_MTLS,
678
+ PROOF_NONE: () => import_axis_protocol2.PROOF_NONE,
679
+ PROOF_WITNESS: () => import_axis_protocol2.PROOF_WITNESS,
680
+ ProofType: () => import_axis_protocol2.ProofType,
681
+ TLV_ACTOR_ID: () => import_axis_protocol2.TLV_ACTOR_ID,
682
+ TLV_AUD: () => import_axis_protocol2.TLV_AUD,
683
+ TLV_BODY_ARR: () => import_axis_protocol2.TLV_BODY_ARR,
684
+ TLV_BODY_OBJ: () => import_axis_protocol2.TLV_BODY_OBJ,
685
+ TLV_CAPSULE: () => import_axis_protocol2.TLV_CAPSULE,
686
+ TLV_EFFECT: () => import_axis_protocol2.TLV_EFFECT,
687
+ TLV_ERROR_CODE: () => import_axis_protocol2.TLV_ERROR_CODE,
688
+ TLV_ERROR_MSG: () => import_axis_protocol2.TLV_ERROR_MSG,
689
+ TLV_INDEX: () => import_axis_protocol2.TLV_INDEX,
690
+ TLV_INTENT: () => import_axis_protocol2.TLV_INTENT,
691
+ TLV_KID: () => import_axis_protocol2.TLV_KID,
692
+ TLV_LOOM_PRESENCE_ID: () => import_axis_protocol2.TLV_LOOM_PRESENCE_ID,
693
+ TLV_LOOM_THREAD_HASH: () => import_axis_protocol2.TLV_LOOM_THREAD_HASH,
694
+ TLV_LOOM_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
695
+ TLV_NODE: () => import_axis_protocol2.TLV_NODE,
696
+ TLV_NODE_CERT_HASH: () => import_axis_protocol2.TLV_NODE_CERT_HASH,
697
+ TLV_NODE_KID: () => import_axis_protocol2.TLV_NODE_KID,
698
+ TLV_NONCE: () => import_axis_protocol2.TLV_NONCE,
699
+ TLV_OFFSET: () => import_axis_protocol2.TLV_OFFSET,
700
+ TLV_OK: () => import_axis_protocol2.TLV_OK,
701
+ TLV_PID: () => import_axis_protocol2.TLV_PID,
702
+ TLV_PREV_HASH: () => import_axis_protocol2.TLV_PREV_HASH,
703
+ TLV_PROOF_REF: () => import_axis_protocol2.TLV_PROOF_REF,
704
+ TLV_PROOF_TYPE: () => import_axis_protocol2.TLV_PROOF_TYPE,
705
+ TLV_REALM: () => import_axis_protocol2.TLV_REALM,
706
+ TLV_RECEIPT_HASH: () => import_axis_protocol2.TLV_RECEIPT_HASH,
707
+ TLV_RID: () => import_axis_protocol2.TLV_RID,
708
+ TLV_SHA256_CHUNK: () => import_axis_protocol2.TLV_SHA256_CHUNK,
709
+ TLV_TRACE_ID: () => import_axis_protocol2.TLV_TRACE_ID,
710
+ TLV_TS: () => import_axis_protocol2.TLV_TS,
711
+ TLV_UPLOAD_ID: () => import_axis_protocol2.TLV_UPLOAD_ID
485
712
  });
486
- function normalizeSensorDecision(sensorDecision) {
487
- if ("action" in sensorDecision) {
488
- switch (sensorDecision.action) {
489
- case "ALLOW":
490
- return {
491
- allow: true,
492
- riskScore: 0,
493
- reasons: [],
494
- meta: sensorDecision.meta
495
- };
496
- case "DENY":
497
- return {
498
- allow: false,
499
- riskScore: 100,
500
- reasons: [sensorDecision.code, sensorDecision.reason].filter(
501
- Boolean
502
- ),
503
- meta: sensorDecision.meta,
504
- retryAfterMs: sensorDecision.retryAfterMs
505
- };
506
- case "THROTTLE":
507
- return {
508
- allow: false,
509
- riskScore: 50,
510
- reasons: ["RATE_LIMIT"],
511
- retryAfterMs: sensorDecision.retryAfterMs,
512
- meta: sensorDecision.meta
513
- };
514
- case "FLAG":
515
- return {
516
- allow: true,
517
- riskScore: sensorDecision.scoreDelta,
518
- reasons: sensorDecision.reasons,
519
- meta: sensorDecision.meta
520
- };
521
- }
713
+ var import_axis_protocol2;
714
+ var init_constants = __esm({
715
+ "src/core/constants.ts"() {
716
+ import_axis_protocol2 = require("@nextera.one/axis-protocol");
717
+ }
718
+ });
719
+
720
+ // src/engine/axis-execution-context.ts
721
+ var axis_execution_context_exports = {};
722
+ __export(axis_execution_context_exports, {
723
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
724
+ getAxisExecutionContext: () => getAxisExecutionContext,
725
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
726
+ withAxisExecutionContext: () => withAxisExecutionContext
727
+ });
728
+ function getAxisExecutionContext(frame) {
729
+ return frame?.[AXIS_EXECUTION_CONTEXT_KEY];
730
+ }
731
+ function withAxisExecutionContext(target, context) {
732
+ Object.defineProperty(target, AXIS_EXECUTION_CONTEXT_KEY, {
733
+ value: context,
734
+ writable: true,
735
+ configurable: true,
736
+ enumerable: false
737
+ });
738
+ return target;
739
+ }
740
+ function mergeAxisExecutionContext(base, override) {
741
+ if (!base && !override) {
742
+ return void 0;
522
743
  }
523
744
  return {
524
- allow: sensorDecision.allow,
525
- riskScore: sensorDecision.riskScore,
526
- reasons: sensorDecision.reasons,
527
- tags: sensorDecision.tags,
528
- meta: sensorDecision.meta,
529
- tighten: sensorDecision.tighten,
530
- retryAfterMs: sensorDecision.retryAfterMs
745
+ ...base,
746
+ ...override,
747
+ capsuleRef: {
748
+ ...base?.capsuleRef || {},
749
+ ...override?.capsuleRef || {}
750
+ }
531
751
  };
532
752
  }
533
- var Decision, SensorDecisions;
534
- var init_axis_sensor = __esm({
535
- "src/sensor/axis-sensor.ts"() {
536
- Decision = /* @__PURE__ */ ((Decision2) => {
537
- Decision2["ALLOW"] = "ALLOW";
538
- Decision2["DENY"] = "DENY";
539
- Decision2["THROTTLE"] = "THROTTLE";
540
- Decision2["FLAG"] = "FLAG";
541
- return Decision2;
542
- })(Decision || {});
543
- SensorDecisions = {
544
- allow(meta, tags) {
545
- return {
546
- decision: "ALLOW" /* ALLOW */,
547
- allow: true,
548
- riskScore: 0,
549
- reasons: [],
550
- tags,
551
- meta
552
- };
553
- },
554
- deny(code, reason, meta) {
555
- return {
556
- decision: "DENY" /* DENY */,
557
- allow: false,
558
- riskScore: 100,
559
- code,
560
- reasons: [code, reason].filter(Boolean),
561
- meta
562
- };
563
- },
564
- throttle(retryAfterMs, meta) {
565
- return {
566
- decision: "THROTTLE" /* THROTTLE */,
567
- allow: false,
568
- riskScore: 50,
569
- retryAfterMs,
570
- code: "RATE_LIMIT",
571
- reasons: ["RATE_LIMIT"],
572
- meta
573
- };
574
- },
575
- flag(scoreDelta, reasons, meta) {
576
- return {
577
- decision: "FLAG" /* FLAG */,
578
- allow: true,
579
- riskScore: scoreDelta,
580
- scoreDelta,
581
- reasons,
582
- meta
583
- };
584
- }
585
- };
753
+ var AXIS_EXECUTION_CONTEXT_KEY;
754
+ var init_axis_execution_context = __esm({
755
+ "src/engine/axis-execution-context.ts"() {
756
+ AXIS_EXECUTION_CONTEXT_KEY = /* @__PURE__ */ Symbol.for("axis.executionContext");
586
757
  }
587
758
  });
588
759
 
589
- // src/cce/cce.types.ts
590
- var CCE_PROTOCOL_VERSION, CCE_DERIVATION, CCE_AES_KEY_BYTES, CCE_IV_BYTES, CCE_TAG_BYTES, CCE_NONCE_BYTES, CCE_ERROR, CceError;
591
- var init_cce_types = __esm({
592
- "src/cce/cce.types.ts"() {
593
- CCE_PROTOCOL_VERSION = "cce-v1";
594
- CCE_DERIVATION = {
595
- /** Request execution context */
596
- REQUEST: "axis:cce:req:v1",
597
- /** Response execution context */
598
- RESPONSE: "axis:cce:resp:v1",
599
- /** Witness binding context */
600
- WITNESS: "axis:cce:witness:v1"
601
- };
602
- CCE_AES_KEY_BYTES = 32;
603
- CCE_IV_BYTES = 12;
760
+ // src/engine/registry/observer.registry.ts
761
+ var require_observer_registry = __commonJS({
762
+ "src/engine/registry/observer.registry.ts"(exports2) {
763
+ "use strict";
764
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
765
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
766
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
767
+ 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;
768
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
769
+ };
770
+ var ObserverRegistry_1;
771
+ Object.defineProperty(exports2, "__esModule", { value: true });
772
+ exports2.ObserverRegistry = void 0;
773
+ var common_1 = require("@nestjs/common");
774
+ var ObserverRegistry2 = ObserverRegistry_1 = class ObserverRegistry {
775
+ constructor() {
776
+ this.logger = new common_1.Logger(ObserverRegistry_1.name);
777
+ this.byName = /* @__PURE__ */ new Map();
778
+ this.byType = /* @__PURE__ */ new Map();
779
+ }
780
+ register(instance, meta = {}) {
781
+ const name = meta.name || instance.name || instance.constructor.name;
782
+ const registration = {
783
+ name,
784
+ instance,
785
+ tags: meta.tags || [],
786
+ events: meta.events,
787
+ intents: meta.intents,
788
+ handlers: meta.handlers
789
+ };
790
+ this.byName.set(name, registration);
791
+ this.byType.set(instance.constructor, registration);
792
+ this.logger.debug(`Registered observer: ${name}`);
793
+ }
794
+ resolve(ref) {
795
+ if (typeof ref === "string") {
796
+ return this.byName.get(ref);
797
+ }
798
+ return this.byType.get(ref) || this.byName.get(ref.name);
799
+ }
800
+ list() {
801
+ return Array.from(this.byName.values()).sort((left, right) => left.name.localeCompare(right.name));
802
+ }
803
+ clear() {
804
+ this.byName.clear();
805
+ this.byType.clear();
806
+ }
807
+ };
808
+ exports2.ObserverRegistry = ObserverRegistry2;
809
+ exports2.ObserverRegistry = ObserverRegistry2 = ObserverRegistry_1 = __decorate([
810
+ (0, common_1.Injectable)()
811
+ ], ObserverRegistry2);
812
+ }
813
+ });
814
+
815
+ // src/engine/observer-dispatcher.service.ts
816
+ var require_observer_dispatcher_service = __commonJS({
817
+ "src/engine/observer-dispatcher.service.ts"(exports2) {
818
+ "use strict";
819
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
820
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
821
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
822
+ 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;
823
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
824
+ };
825
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
826
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
827
+ };
828
+ var ObserverDispatcherService_1;
829
+ var _a;
830
+ Object.defineProperty(exports2, "__esModule", { value: true });
831
+ exports2.ObserverDispatcherService = void 0;
832
+ var common_1 = require("@nestjs/common");
833
+ var observer_registry_1 = require_observer_registry();
834
+ function unique(values) {
835
+ return Array.from(new Set(values));
836
+ }
837
+ var ObserverDispatcherService2 = ObserverDispatcherService_1 = class ObserverDispatcherService {
838
+ constructor(registry) {
839
+ this.registry = registry;
840
+ this.logger = new common_1.Logger(ObserverDispatcherService_1.name);
841
+ }
842
+ async dispatch(bindings, context) {
843
+ if (!bindings || bindings.length === 0)
844
+ return;
845
+ const invoked = /* @__PURE__ */ new Set();
846
+ for (const binding of bindings) {
847
+ if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
848
+ continue;
849
+ }
850
+ for (const ref of binding.refs) {
851
+ const registration = this.registry.resolve(ref);
852
+ if (!registration) {
853
+ this.logger.warn(`Observer ${String(ref)} could not be resolved`);
854
+ continue;
855
+ }
856
+ if (invoked.has(registration.name))
857
+ continue;
858
+ if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
859
+ continue;
860
+ }
861
+ const observerContext = {
862
+ ...context,
863
+ observerTags: unique([
864
+ ...registration.tags || [],
865
+ ...binding.tags || [],
866
+ ...context.observerTags || []
867
+ ])
868
+ };
869
+ if (registration.instance.supports && !registration.instance.supports(observerContext)) {
870
+ continue;
871
+ }
872
+ try {
873
+ invoked.add(registration.name);
874
+ await registration.instance.observe(observerContext);
875
+ } catch (error) {
876
+ this.logger.warn(`Observer ${registration.name} failed during ${context.event}: ${error.message}`);
877
+ }
878
+ }
879
+ }
880
+ }
881
+ };
882
+ exports2.ObserverDispatcherService = ObserverDispatcherService2;
883
+ exports2.ObserverDispatcherService = ObserverDispatcherService2 = ObserverDispatcherService_1 = __decorate([
884
+ (0, common_1.Injectable)(),
885
+ __metadata("design:paramtypes", [typeof (_a = typeof observer_registry_1.ObserverRegistry !== "undefined" && observer_registry_1.ObserverRegistry) === "function" ? _a : Object])
886
+ ], ObserverDispatcherService2);
887
+ }
888
+ });
889
+
890
+ // src/cce/cce.types.ts
891
+ var CCE_PROTOCOL_VERSION, CCE_DERIVATION, CCE_AES_KEY_BYTES, CCE_IV_BYTES, CCE_TAG_BYTES, CCE_NONCE_BYTES, CCE_ERROR, CceError;
892
+ var init_cce_types = __esm({
893
+ "src/cce/cce.types.ts"() {
894
+ CCE_PROTOCOL_VERSION = "cce-v1";
895
+ CCE_DERIVATION = {
896
+ /** Request execution context */
897
+ REQUEST: "axis:cce:req:v1",
898
+ /** Response execution context */
899
+ RESPONSE: "axis:cce:resp:v1",
900
+ /** Witness binding context */
901
+ WITNESS: "axis:cce:witness:v1"
902
+ };
903
+ CCE_AES_KEY_BYTES = 32;
904
+ CCE_IV_BYTES = 12;
604
905
  CCE_TAG_BYTES = 16;
605
906
  CCE_NONCE_BYTES = 32;
606
907
  CCE_ERROR = {
@@ -1062,6 +1363,116 @@ var init_cce_witness_observer = __esm({
1062
1363
  }
1063
1364
  });
1064
1365
 
1366
+ // src/sensor/axis-sensor.ts
1367
+ var axis_sensor_exports = {};
1368
+ __export(axis_sensor_exports, {
1369
+ Decision: () => Decision,
1370
+ SensorDecisions: () => SensorDecisions,
1371
+ normalizeSensorDecision: () => normalizeSensorDecision
1372
+ });
1373
+ function normalizeSensorDecision(sensorDecision) {
1374
+ if ("action" in sensorDecision) {
1375
+ switch (sensorDecision.action) {
1376
+ case "ALLOW":
1377
+ return {
1378
+ allow: true,
1379
+ riskScore: 0,
1380
+ reasons: [],
1381
+ meta: sensorDecision.meta
1382
+ };
1383
+ case "DENY":
1384
+ return {
1385
+ allow: false,
1386
+ riskScore: 100,
1387
+ reasons: [sensorDecision.code, sensorDecision.reason].filter(
1388
+ Boolean
1389
+ ),
1390
+ meta: sensorDecision.meta,
1391
+ retryAfterMs: sensorDecision.retryAfterMs
1392
+ };
1393
+ case "THROTTLE":
1394
+ return {
1395
+ allow: false,
1396
+ riskScore: 50,
1397
+ reasons: ["RATE_LIMIT"],
1398
+ retryAfterMs: sensorDecision.retryAfterMs,
1399
+ meta: sensorDecision.meta
1400
+ };
1401
+ case "FLAG":
1402
+ return {
1403
+ allow: true,
1404
+ riskScore: sensorDecision.scoreDelta,
1405
+ reasons: sensorDecision.reasons,
1406
+ meta: sensorDecision.meta
1407
+ };
1408
+ }
1409
+ }
1410
+ return {
1411
+ allow: sensorDecision.allow,
1412
+ riskScore: sensorDecision.riskScore,
1413
+ reasons: sensorDecision.reasons,
1414
+ tags: sensorDecision.tags,
1415
+ meta: sensorDecision.meta,
1416
+ tighten: sensorDecision.tighten,
1417
+ retryAfterMs: sensorDecision.retryAfterMs
1418
+ };
1419
+ }
1420
+ var Decision, SensorDecisions;
1421
+ var init_axis_sensor = __esm({
1422
+ "src/sensor/axis-sensor.ts"() {
1423
+ Decision = /* @__PURE__ */ ((Decision2) => {
1424
+ Decision2["ALLOW"] = "ALLOW";
1425
+ Decision2["DENY"] = "DENY";
1426
+ Decision2["THROTTLE"] = "THROTTLE";
1427
+ Decision2["FLAG"] = "FLAG";
1428
+ return Decision2;
1429
+ })(Decision || {});
1430
+ SensorDecisions = {
1431
+ allow(meta, tags) {
1432
+ return {
1433
+ decision: "ALLOW" /* ALLOW */,
1434
+ allow: true,
1435
+ riskScore: 0,
1436
+ reasons: [],
1437
+ tags,
1438
+ meta
1439
+ };
1440
+ },
1441
+ deny(code, reason, meta) {
1442
+ return {
1443
+ decision: "DENY" /* DENY */,
1444
+ allow: false,
1445
+ riskScore: 100,
1446
+ code,
1447
+ reasons: [code, reason].filter(Boolean),
1448
+ meta
1449
+ };
1450
+ },
1451
+ throttle(retryAfterMs, meta) {
1452
+ return {
1453
+ decision: "THROTTLE" /* THROTTLE */,
1454
+ allow: false,
1455
+ riskScore: 50,
1456
+ retryAfterMs,
1457
+ code: "RATE_LIMIT",
1458
+ reasons: ["RATE_LIMIT"],
1459
+ meta
1460
+ };
1461
+ },
1462
+ flag(scoreDelta, reasons, meta) {
1463
+ return {
1464
+ decision: "FLAG" /* FLAG */,
1465
+ allow: true,
1466
+ riskScore: scoreDelta,
1467
+ scoreDelta,
1468
+ reasons,
1469
+ meta
1470
+ };
1471
+ }
1472
+ };
1473
+ }
1474
+ });
1475
+
1065
1476
  // src/cce/cce-pipeline.ts
1066
1477
  var cce_pipeline_exports = {};
1067
1478
  __export(cce_pipeline_exports, {
@@ -1294,16 +1705,242 @@ var init_cce_pipeline = __esm({
1294
1705
  }
1295
1706
  });
1296
1707
 
1708
+ // src/core/axis-error.ts
1709
+ var axis_error_exports = {};
1710
+ __export(axis_error_exports, {
1711
+ AxisError: () => AxisError
1712
+ });
1713
+ var AxisError;
1714
+ var init_axis_error = __esm({
1715
+ "src/core/axis-error.ts"() {
1716
+ AxisError = class extends Error {
1717
+ constructor(code, message, httpStatus = 400, details) {
1718
+ super(message);
1719
+ this.code = code;
1720
+ this.httpStatus = httpStatus;
1721
+ this.details = details;
1722
+ this.name = "AxisError";
1723
+ }
1724
+ };
1725
+ }
1726
+ });
1727
+
1728
+ // src/security/scopes.ts
1729
+ function hasScope(scopes, required) {
1730
+ if (!Array.isArray(scopes) || scopes.length === 0) {
1731
+ return false;
1732
+ }
1733
+ if (scopes.includes(required)) {
1734
+ return true;
1735
+ }
1736
+ const [resource, id] = required.split(":");
1737
+ if (resource && id) {
1738
+ const wildcard = `${resource}:*`;
1739
+ if (scopes.includes(wildcard)) {
1740
+ return true;
1741
+ }
1742
+ }
1743
+ return false;
1744
+ }
1745
+ function parseScope(scope) {
1746
+ const parts = scope.split(":");
1747
+ if (parts.length !== 2) return null;
1748
+ return { resource: parts[0], id: parts[1] };
1749
+ }
1750
+ function canAccessResource(scopes, resourceType, resourceId) {
1751
+ const required = `${resourceType}:${resourceId}`;
1752
+ return hasScope(scopes, required);
1753
+ }
1754
+ var init_scopes = __esm({
1755
+ "src/security/scopes.ts"() {
1756
+ }
1757
+ });
1758
+
1759
+ // src/security/inline-capsule.ts
1760
+ var inline_capsule_exports = {};
1761
+ __export(inline_capsule_exports, {
1762
+ inlineCapsuleAllowsIntent: () => inlineCapsuleAllowsIntent,
1763
+ inlineCapsuleSatisfiesScopes: () => inlineCapsuleSatisfiesScopes,
1764
+ isInlineCapsuleExpired: () => isInlineCapsuleExpired,
1765
+ normalizeInlineCapsule: () => normalizeInlineCapsule,
1766
+ resolvePolicyScopes: () => resolvePolicyScopes
1767
+ });
1768
+ function normalizeInlineCapsule(input) {
1769
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
1770
+ return null;
1771
+ }
1772
+ const raw = input;
1773
+ const scopes = normalizeStringList(raw.scopes ?? raw.scope);
1774
+ return {
1775
+ id: normalizeScalar(raw.id),
1776
+ actorId: normalizeScalar(raw.actorId),
1777
+ intents: normalizeStringList(raw.intents),
1778
+ issuedAt: normalizeTimestamp(raw.issuedAt ?? raw.iat),
1779
+ expiresAt: normalizeTimestamp(raw.expiresAt ?? raw.exp),
1780
+ realm: normalizeScalar(raw.realm),
1781
+ node: normalizeScalar(raw.node),
1782
+ scopes,
1783
+ raw
1784
+ };
1785
+ }
1786
+ function inlineCapsuleAllowsIntent(capsule, intent) {
1787
+ if (!capsule.intents || capsule.intents.length === 0) {
1788
+ return false;
1789
+ }
1790
+ for (const pattern of capsule.intents) {
1791
+ if (pattern === "*" || pattern === intent) {
1792
+ return true;
1793
+ }
1794
+ if (pattern.endsWith(".*")) {
1795
+ const prefix = pattern.slice(0, -1);
1796
+ if (intent.startsWith(prefix)) {
1797
+ return true;
1798
+ }
1799
+ }
1800
+ }
1801
+ return false;
1802
+ }
1803
+ function isInlineCapsuleExpired(capsule, clockSkewMs = 3e4) {
1804
+ if (capsule.expiresAt === void 0) {
1805
+ return false;
1806
+ }
1807
+ return BigInt(Date.now()) > capsule.expiresAt + BigInt(clockSkewMs);
1808
+ }
1809
+ function resolvePolicyScopes(scopes, context) {
1810
+ return scopes.map(
1811
+ (scope) => scope.replace(/\$\{([^}]+)\}/g, (_match, expression) => {
1812
+ const resolved = resolveTemplateExpression(expression.trim(), context);
1813
+ if (resolved === void 0 || resolved === null || resolved === "") {
1814
+ throw new Error(`CAPSULE_SCOPE_TEMPLATE_UNRESOLVED:${expression}`);
1815
+ }
1816
+ return String(resolved);
1817
+ })
1818
+ );
1819
+ }
1820
+ function inlineCapsuleSatisfiesScopes(capsule, requiredScopes, mode = "all") {
1821
+ if (!capsule.scopes || capsule.scopes.length === 0) {
1822
+ return false;
1823
+ }
1824
+ if (mode === "any") {
1825
+ return requiredScopes.some((scope) => hasScope(capsule.scopes, scope));
1826
+ }
1827
+ return requiredScopes.every((scope) => hasScope(capsule.scopes, scope));
1828
+ }
1829
+ function resolveTemplateExpression(expression, context) {
1830
+ if (expression === "intent") {
1831
+ return context.intent;
1832
+ }
1833
+ if (expression === "actorId") {
1834
+ return context.actorId;
1835
+ }
1836
+ if (expression === "chainId") {
1837
+ return context.chainId;
1838
+ }
1839
+ if (expression === "stepId") {
1840
+ return context.stepId;
1841
+ }
1842
+ if (expression.startsWith("body.")) {
1843
+ return getNestedValue(context.body, expression.slice(5));
1844
+ }
1845
+ return void 0;
1846
+ }
1847
+ function getNestedValue(value, path2) {
1848
+ if (!value || typeof value !== "object") {
1849
+ return void 0;
1850
+ }
1851
+ return path2.split(".").reduce((current, segment) => {
1852
+ if (!current || typeof current !== "object") {
1853
+ return void 0;
1854
+ }
1855
+ return current[segment];
1856
+ }, value);
1857
+ }
1858
+ function normalizeScalar(value) {
1859
+ if (typeof value === "string") {
1860
+ return value;
1861
+ }
1862
+ if (value instanceof Uint8Array) {
1863
+ return Buffer.from(value).toString("hex");
1864
+ }
1865
+ return void 0;
1866
+ }
1867
+ function normalizeStringList(value) {
1868
+ if (!value) {
1869
+ return void 0;
1870
+ }
1871
+ const list = Array.isArray(value) ? value : [value];
1872
+ const normalized = list.map((entry) => typeof entry === "string" ? entry : void 0).filter((entry) => !!entry && entry.trim().length > 0);
1873
+ return normalized.length > 0 ? Array.from(new Set(normalized)) : void 0;
1874
+ }
1875
+ function normalizeTimestamp(value) {
1876
+ if (typeof value === "bigint") {
1877
+ return value;
1878
+ }
1879
+ if (typeof value === "number" && Number.isFinite(value)) {
1880
+ return BigInt(Math.trunc(value));
1881
+ }
1882
+ if (typeof value === "string" && value.trim().length > 0) {
1883
+ try {
1884
+ return BigInt(value);
1885
+ } catch {
1886
+ return void 0;
1887
+ }
1888
+ }
1889
+ return void 0;
1890
+ }
1891
+ var init_inline_capsule = __esm({
1892
+ "src/security/inline-capsule.ts"() {
1893
+ init_scopes();
1894
+ }
1895
+ });
1896
+
1297
1897
  // src/engine/intent.router.ts
1298
1898
  var require_intent_router = __commonJS({
1299
1899
  "src/engine/intent.router.ts"(exports2) {
1300
1900
  "use strict";
1901
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
1902
+ if (k2 === void 0) k2 = k;
1903
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1904
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1905
+ desc = { enumerable: true, get: function() {
1906
+ return m[k];
1907
+ } };
1908
+ }
1909
+ Object.defineProperty(o, k2, desc);
1910
+ }) : (function(o, m, k, k2) {
1911
+ if (k2 === void 0) k2 = k;
1912
+ o[k2] = m[k];
1913
+ }));
1914
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
1915
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1916
+ }) : function(o, v) {
1917
+ o["default"] = v;
1918
+ });
1301
1919
  var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
1302
1920
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1303
1921
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1304
1922
  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;
1305
1923
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1306
1924
  };
1925
+ var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
1926
+ var ownKeys = function(o) {
1927
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1928
+ var ar = [];
1929
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1930
+ return ar;
1931
+ };
1932
+ return ownKeys(o);
1933
+ };
1934
+ return function(mod) {
1935
+ if (mod && mod.__esModule) return mod;
1936
+ var result = {};
1937
+ if (mod != null) {
1938
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1939
+ }
1940
+ __setModuleDefault(result, mod);
1941
+ return result;
1942
+ };
1943
+ })();
1307
1944
  var __metadata = exports2 && exports2.__metadata || function(k, v) {
1308
1945
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1309
1946
  };
@@ -1314,31 +1951,84 @@ var require_intent_router = __commonJS({
1314
1951
  };
1315
1952
  var IntentRouter_1;
1316
1953
  var _a;
1954
+ var _b;
1317
1955
  Object.defineProperty(exports2, "__esModule", { value: true });
1318
1956
  exports2.IntentRouter = void 0;
1319
1957
  var common_1 = require("@nestjs/common");
1320
1958
  var core_1 = require("@nestjs/core");
1959
+ var axis_protocol_1 = require("@nextera.one/axis-protocol");
1960
+ var cce_pipeline_1 = (init_cce_pipeline(), __toCommonJS(cce_pipeline_exports));
1961
+ var axis_error_1 = (init_axis_error(), __toCommonJS(axis_error_exports));
1962
+ var constants_1 = (init_constants(), __toCommonJS(constants_exports));
1963
+ var capsule_policy_decorator_1 = (init_capsule_policy_decorator(), __toCommonJS(capsule_policy_decorator_exports));
1964
+ var chain_decorator_1 = (init_chain_decorator(), __toCommonJS(chain_decorator_exports));
1965
+ var dto_schema_util_1 = require_dto_schema_util();
1321
1966
  var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
1322
- var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
1323
- var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
1324
1967
  var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
1968
+ var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
1969
+ var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
1325
1970
  var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
1326
- var dto_schema_util_1 = require_dto_schema_util();
1971
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
1972
+ var inline_capsule_1 = (init_inline_capsule(), __toCommonJS(inline_capsule_exports));
1327
1973
  var axis_sensor_1 = (init_axis_sensor(), __toCommonJS(axis_sensor_exports));
1328
- var cce_pipeline_1 = (init_cce_pipeline(), __toCommonJS(cce_pipeline_exports));
1974
+ var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
1975
+ var observer_dispatcher_service_1 = require_observer_dispatcher_service();
1976
+ function observerRefKey(ref) {
1977
+ return typeof ref === "string" ? ref : ref.name;
1978
+ }
1979
+ function mergeObserverBindings(bindings) {
1980
+ const merged = /* @__PURE__ */ new Map();
1981
+ for (const binding of bindings) {
1982
+ for (const ref of binding.refs) {
1983
+ const key = observerRefKey(ref);
1984
+ const existing = merged.get(key);
1985
+ if (!existing) {
1986
+ merged.set(key, {
1987
+ refs: [ref],
1988
+ tags: binding.tags ? [...new Set(binding.tags)] : void 0,
1989
+ events: binding.events ? [...new Set(binding.events)] : void 0
1990
+ });
1991
+ continue;
1992
+ }
1993
+ existing.tags = Array.from(/* @__PURE__ */ new Set([...existing.tags || [], ...binding.tags || []]));
1994
+ existing.events = existing.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...existing.events, ...binding.events]));
1995
+ }
1996
+ }
1997
+ return Array.from(merged.values());
1998
+ }
1999
+ function normalizeChainConfig(decoratorConfig, intentConfig) {
2000
+ if (decoratorConfig) {
2001
+ return decoratorConfig;
2002
+ }
2003
+ if (!intentConfig) {
2004
+ return void 0;
2005
+ }
2006
+ if (intentConfig === true) {
2007
+ return { enabled: true };
2008
+ }
2009
+ return {
2010
+ enabled: true,
2011
+ ...intentConfig
2012
+ };
2013
+ }
1329
2014
  var IntentRouter2 = IntentRouter_1 = class IntentRouter {
1330
- constructor(moduleRef) {
2015
+ constructor(moduleRef, observerDispatcher) {
1331
2016
  this.moduleRef = moduleRef;
2017
+ this.observerDispatcher = observerDispatcher;
1332
2018
  this.logger = new common_1.Logger(IntentRouter_1.name);
2019
+ this.decoder = new TextDecoder();
2020
+ this.encoder = new TextEncoder();
1333
2021
  this.handlers = /* @__PURE__ */ new Map();
1334
2022
  this.intentSensors = /* @__PURE__ */ new Map();
1335
2023
  this.intentDecoders = /* @__PURE__ */ new Map();
1336
2024
  this.intentSchemas = /* @__PURE__ */ new Map();
1337
2025
  this.intentValidators = /* @__PURE__ */ new Map();
1338
2026
  this.intentKinds = /* @__PURE__ */ new Map();
2027
+ this.intentChains = /* @__PURE__ */ new Map();
2028
+ this.intentObservers = /* @__PURE__ */ new Map();
2029
+ this.intentCapsulePolicies = /* @__PURE__ */ new Map();
1339
2030
  this.cceHandlers = /* @__PURE__ */ new Map();
1340
2031
  this.ccePipelineConfig = null;
1341
- this.idelCompiler = null;
1342
2032
  }
1343
2033
  getSchema(intent) {
1344
2034
  return this.intentSchemas.get(intent);
@@ -1352,34 +2042,6 @@ var require_intent_router = __commonJS({
1352
2042
  getRegisteredIntents() {
1353
2043
  return [...IntentRouter_1.BUILTIN_INTENTS, ...this.handlers.keys()];
1354
2044
  }
1355
- configureIdel(compiler) {
1356
- this.idelCompiler = compiler;
1357
- this.logger.log("IDEL compiler configured");
1358
- }
1359
- resolveIntent(proposal) {
1360
- if (!this.idelCompiler) {
1361
- throw new Error("IDEL compiler not configured. Call configureIdel() first.");
1362
- }
1363
- const result = this.idelCompiler.compile(proposal);
1364
- if (!result.ok || !result.compiled) {
1365
- const msg = result.errors?.map((e) => e.message).join("; ") ?? "Unknown compilation error";
1366
- throw new Error(`IDEL compilation failed: ${msg}`);
1367
- }
1368
- return result.compiled;
1369
- }
1370
- async routeIdel(proposal, frame) {
1371
- const compiled = this.resolveIntent(proposal);
1372
- const resolvedFrame = {
1373
- ...frame,
1374
- headers: new Map(frame.headers)
1375
- };
1376
- resolvedFrame.headers.set(3, new TextEncoder().encode(compiled.intent));
1377
- if (compiled.params && Object.keys(compiled.params).length > 0) {
1378
- resolvedFrame.body = new TextEncoder().encode(JSON.stringify(compiled.params));
1379
- }
1380
- const effect = await this.route(resolvedFrame);
1381
- return { ...effect, compiled };
1382
- }
1383
2045
  getIntentEntry(intent) {
1384
2046
  if (!this.has(intent))
1385
2047
  return null;
@@ -1388,9 +2050,18 @@ var require_intent_router = __commonJS({
1388
2050
  validators: this.intentValidators.get(intent),
1389
2051
  hasSensors: this.intentSensors.has(intent),
1390
2052
  builtin: IntentRouter_1.BUILTIN_INTENTS.has(intent),
1391
- kind: this.intentKinds.get(intent)
2053
+ kind: this.intentKinds.get(intent),
2054
+ chain: this.intentChains.get(intent),
2055
+ capsulePolicy: this.intentCapsulePolicies.get(intent),
2056
+ observerCount: this.getObservers(intent).length
1392
2057
  };
1393
2058
  }
2059
+ getChainConfig(intent) {
2060
+ return this.intentChains.get(intent);
2061
+ }
2062
+ getObservers(intent) {
2063
+ return this.intentObservers.get(intent) || [];
2064
+ }
1394
2065
  register(intent, handler) {
1395
2066
  this.handlers.set(intent, handler);
1396
2067
  }
@@ -1398,7 +2069,10 @@ var require_intent_router = __commonJS({
1398
2069
  const handlerMeta = Reflect.getMetadata(handler_decorator_1.HANDLER_METADATA_KEY, instance.constructor);
1399
2070
  const prefix = handlerMeta?.intent || instance.name;
1400
2071
  const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, instance.constructor) || [];
2072
+ const routedMethods = new Set(routes.map((route) => String(route.methodName)));
1401
2073
  const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, instance.constructor) || [];
2074
+ const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, instance.constructor) || [];
2075
+ const proto = Object.getPrototypeOf(instance);
1402
2076
  for (const route of routes) {
1403
2077
  const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
1404
2078
  const fn = instance[route.methodName].bind(instance);
@@ -1407,27 +2081,36 @@ var require_intent_router = __commonJS({
1407
2081
  } else {
1408
2082
  this.register(intentName, fn);
1409
2083
  }
1410
- this.registerIntentMeta(intentName, Object.getPrototypeOf(instance), String(route.methodName), handlerSensors);
2084
+ this.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
1411
2085
  }
1412
- const proto = Object.getPrototypeOf(instance);
1413
2086
  for (const key of Object.getOwnPropertyNames(proto)) {
2087
+ if (routedMethods.has(key))
2088
+ continue;
1414
2089
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, key);
1415
2090
  if (!meta?.intent)
1416
2091
  continue;
1417
- if (!this.handlers.has(meta.intent)) {
1418
- this.register(meta.intent, instance[key].bind(instance));
2092
+ const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
2093
+ if (!this.handlers.has(intentName)) {
2094
+ this.register(intentName, instance[key].bind(instance));
1419
2095
  }
1420
- this.registerIntentMeta(meta.intent, proto, key, handlerSensors);
2096
+ this.registerIntentMeta(intentName, proto, key, handlerSensors, handlerObservers);
1421
2097
  }
1422
2098
  }
1423
2099
  async route(frame) {
1424
2100
  const start = process.hrtime();
1425
2101
  let intent = "unknown";
1426
2102
  try {
1427
- const intentBytes = frame.headers.get(3);
2103
+ const intentBytes = frame.headers.get(constants_1.TLV_INTENT);
1428
2104
  if (!intentBytes)
1429
2105
  throw new Error("Missing intent");
1430
- intent = new TextDecoder().decode(intentBytes);
2106
+ intent = this.decoder.decode(intentBytes);
2107
+ const observerBindings = this.getObservers(intent);
2108
+ await this.emitIntentObservers(observerBindings, {
2109
+ event: "intent.received",
2110
+ timestamp: Date.now(),
2111
+ intent,
2112
+ frame
2113
+ });
1431
2114
  let effect;
1432
2115
  if (intent === "system.ping" || intent === "public.ping") {
1433
2116
  this.logger.debug("PING received");
@@ -1459,25 +2142,35 @@ var require_intent_router = __commonJS({
1459
2142
  effect: "echo",
1460
2143
  body: frame.body
1461
2144
  };
2145
+ } else if (intent === "CHAIN.EXEC" || intent === "axis.chain.exec") {
2146
+ const chainRequest = this.parseChainRequestBody(frame.body);
2147
+ effect = await this.executeChainRequest(frame, chainRequest);
1462
2148
  } else if (intent === "INTENT.EXEC" || intent === "axis.intent.exec") {
1463
- try {
1464
- const bodyJSON = JSON.parse(new TextDecoder().decode(frame.body));
1465
- const innerIntent = bodyJSON.intent;
1466
- const innerArgs = bodyJSON.args || {};
1467
- if (!innerIntent) {
1468
- throw new Error("INTENT.EXEC missing inner intent");
1469
- }
1470
- this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
1471
- const innerFrame = {
1472
- ...frame,
1473
- headers: new Map(frame.headers),
1474
- body: new TextEncoder().encode(JSON.stringify(innerArgs))
1475
- };
1476
- innerFrame.headers.set(3, new TextEncoder().encode(innerIntent));
1477
- return await this.route(innerFrame);
1478
- } catch (e) {
1479
- throw new Error(`INTENT.EXEC unwrapping failed: ${e.message}`);
2149
+ const execBody = this.parseIntentExecBody(frame.body);
2150
+ const innerIntent = execBody.intent;
2151
+ const innerArgs = execBody.args || {};
2152
+ if (!innerIntent) {
2153
+ throw new Error("INTENT.EXEC missing inner intent");
2154
+ }
2155
+ this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
2156
+ const innerHeaders = new Map(frame.headers);
2157
+ innerHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(innerIntent));
2158
+ const inlineCapsule = this.toInlineCapsuleRecord(execBody.capsule);
2159
+ const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2160
+ if (capsuleId) {
2161
+ innerHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2162
+ innerHeaders.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
1480
2163
  }
2164
+ const innerFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
2165
+ ...frame,
2166
+ headers: innerHeaders,
2167
+ body: this.encodeJson(innerArgs)
2168
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
2169
+ metaIntent: "INTENT.EXEC",
2170
+ actorId: this.getActorIdFromFrame(frame),
2171
+ inlineCapsule
2172
+ }) || {});
2173
+ effect = await this.route(innerFrame);
1481
2174
  } else {
1482
2175
  const handler = this.handlers.get(intent);
1483
2176
  if (!handler) {
@@ -1496,6 +2189,7 @@ var require_intent_router = __commonJS({
1496
2189
  throw new Error(`IntentBody decode failed for ${intent}: ${decodeErr.message}`);
1497
2190
  }
1498
2191
  }
2192
+ this.enforceCapsulePolicy(intent, frame, decodedBody, this.getEffectiveCapsulePolicy(intent, frame));
1499
2193
  if (typeof handler === "function") {
1500
2194
  const resultBody = decoder ? await handler(decodedBody, frame.headers) : await handler(frame.body, frame.headers);
1501
2195
  effect = {
@@ -1518,9 +2212,24 @@ var require_intent_router = __commonJS({
1518
2212
  }
1519
2213
  }
1520
2214
  }
2215
+ await this.emitIntentObservers(observerBindings, {
2216
+ event: "intent.completed",
2217
+ timestamp: Date.now(),
2218
+ intent,
2219
+ frame,
2220
+ effect,
2221
+ metadata: effect.metadata
2222
+ });
1521
2223
  this.logIntent(intent, start, true);
1522
2224
  return effect;
1523
2225
  } catch (e) {
2226
+ await this.emitIntentObservers(this.getObservers(intent), {
2227
+ event: "intent.failed",
2228
+ timestamp: Date.now(),
2229
+ intent,
2230
+ frame,
2231
+ error: e.message
2232
+ });
1524
2233
  this.logIntent(intent, start, false, e.message);
1525
2234
  throw e;
1526
2235
  }
@@ -1534,7 +2243,7 @@ var require_intent_router = __commonJS({
1534
2243
  this.logger.warn(`${intent} failed in ${ms}ms - ${error}`);
1535
2244
  }
1536
2245
  }
1537
- registerIntentMeta(intent, proto, methodName, handlerSensors) {
2246
+ registerIntentMeta(intent, proto, methodName, handlerSensors, handlerObservers) {
1538
2247
  const decoder = Reflect.getMetadata(intent_body_decorator_1.INTENT_BODY_KEY, proto, methodName);
1539
2248
  if (decoder) {
1540
2249
  this.intentDecoders.set(intent, decoder);
@@ -1547,14 +2256,38 @@ var require_intent_router = __commonJS({
1547
2256
  if (combined.length > 0) {
1548
2257
  this.intentSensors.set(intent, combined);
1549
2258
  }
2259
+ const methodObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, proto, methodName) || [];
2260
+ const observers = mergeObserverBindings([
2261
+ ...handlerObservers || [],
2262
+ ...methodObservers
2263
+ ]);
2264
+ if (observers.length > 0) {
2265
+ this.intentObservers.set(intent, observers);
2266
+ }
2267
+ const handlerCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto.constructor);
2268
+ const methodCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto, methodName);
2269
+ const capsulePolicy = (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(handlerCapsulePolicy, methodCapsulePolicy);
2270
+ if (capsulePolicy) {
2271
+ this.intentCapsulePolicies.set(intent, capsulePolicy);
2272
+ }
1550
2273
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
1551
2274
  if (meta) {
1552
- this.storeSchema(meta);
2275
+ this.storeSchema({ ...meta, intent });
1553
2276
  if (meta.kind) {
1554
2277
  this.intentKinds.set(intent, meta.kind);
1555
2278
  }
2279
+ const chainMeta = Reflect.getMetadata(chain_decorator_1.CHAIN_METADATA_KEY, proto, methodName);
2280
+ const chainConfig = normalizeChainConfig(chainMeta, meta.chain);
2281
+ if (chainConfig) {
2282
+ this.intentChains.set(intent, chainConfig);
2283
+ }
1556
2284
  }
1557
2285
  }
2286
+ async emitIntentObservers(bindings, context) {
2287
+ if (!this.observerDispatcher || bindings.length === 0)
2288
+ return;
2289
+ await this.observerDispatcher.dispatch(bindings, context);
2290
+ }
1558
2291
  async runIntentSensors(sensorClasses, intent, frame) {
1559
2292
  if (!this.moduleRef)
1560
2293
  return;
@@ -1583,6 +2316,226 @@ var require_intent_router = __commonJS({
1583
2316
  }
1584
2317
  }
1585
2318
  }
2319
+ getEffectiveCapsulePolicy(intent, frame) {
2320
+ const registeredPolicy = this.intentCapsulePolicies.get(intent);
2321
+ const chainConfig = this.intentChains.get(intent);
2322
+ const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
2323
+ const derivedScopes = Array.from(/* @__PURE__ */ new Set([
2324
+ ...this.toScopeList(chainConfig?.capsuleScope),
2325
+ ...this.toScopeList(executionContext?.capsuleRef?.scope),
2326
+ ...this.toScopeList(executionContext?.chainStep?.capsuleScope)
2327
+ ]));
2328
+ const requiresCapsule = chainConfig?.proofRequired || executionContext?.capsuleRef?.proofRequired || executionContext?.chainStep?.proofRequired || executionContext?.chainEnvelope?.capsule?.proofRequired || derivedScopes.length > 0;
2329
+ const derivedPolicy = requiresCapsule ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)({
2330
+ required: true,
2331
+ scopes: derivedScopes.length > 0 ? derivedScopes : void 0
2332
+ }) : void 0;
2333
+ return (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(registeredPolicy, derivedPolicy);
2334
+ }
2335
+ enforceCapsulePolicy(intent, frame, body, policy) {
2336
+ const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
2337
+ const inlineCapsuleRecord = this.toInlineCapsuleRecord(executionContext?.inlineCapsule);
2338
+ const inlineCapsule = (0, inline_capsule_1.normalizeInlineCapsule)(inlineCapsuleRecord);
2339
+ const normalizedPolicy = policy ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)(policy) : void 0;
2340
+ if (!inlineCapsule) {
2341
+ if (normalizedPolicy?.required) {
2342
+ if (normalizedPolicy.allowCapsuleRef && this.hasCapsuleReference(frame) && this.toScopeList(normalizedPolicy.scopes).length === 0 && normalizedPolicy.intentBound === false) {
2343
+ return;
2344
+ }
2345
+ 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 });
2346
+ }
2347
+ return;
2348
+ }
2349
+ if ((0, inline_capsule_1.isInlineCapsuleExpired)(inlineCapsule)) {
2350
+ throw new axis_error_1.AxisError("CAPSULE_EXPIRED", `Capsule for ${intent} is expired`, 403, { intent, capsuleId: inlineCapsule.id });
2351
+ }
2352
+ const actorId = this.getActorIdFromFrame(frame) || executionContext?.actorId;
2353
+ if (actorId && inlineCapsule.actorId && !this.identifiersMatch(actorId, inlineCapsule.actorId)) {
2354
+ throw new axis_error_1.AxisError("CAPSULE_ACTOR_MISMATCH", `Capsule actor does not match request actor for ${intent}`, 403, {
2355
+ intent,
2356
+ actorId,
2357
+ capsuleActorId: inlineCapsule.actorId
2358
+ });
2359
+ }
2360
+ const proofRef = this.getProofRefFromFrame(frame);
2361
+ if (proofRef && inlineCapsule.id && !this.identifiersMatch(proofRef, inlineCapsule.id)) {
2362
+ throw new axis_error_1.AxisError("CAPSULE_REF_MISMATCH", `Capsule reference does not match request proof for ${intent}`, 403, {
2363
+ intent,
2364
+ proofRef,
2365
+ capsuleId: inlineCapsule.id
2366
+ });
2367
+ }
2368
+ const realm = this.getHeaderValue(frame, constants_1.TLV_REALM);
2369
+ if (realm && inlineCapsule.realm && realm !== inlineCapsule.realm) {
2370
+ throw new axis_error_1.AxisError("CAPSULE_REALM_MISMATCH", `Capsule realm does not match request realm for ${intent}`, 403, { intent, realm, capsuleRealm: inlineCapsule.realm });
2371
+ }
2372
+ const node = this.getHeaderValue(frame, constants_1.TLV_NODE);
2373
+ if (node && inlineCapsule.node && node !== inlineCapsule.node) {
2374
+ throw new axis_error_1.AxisError("CAPSULE_NODE_MISMATCH", `Capsule node does not match request node for ${intent}`, 403, { intent, node, capsuleNode: inlineCapsule.node });
2375
+ }
2376
+ const shouldCheckIntent = normalizedPolicy?.intentBound ?? true;
2377
+ if (shouldCheckIntent && !(0, inline_capsule_1.inlineCapsuleAllowsIntent)(inlineCapsule, intent)) {
2378
+ throw new axis_error_1.AxisError("CAPSULE_DENIED", `Capsule does not authorize ${intent}`, 403, {
2379
+ intent,
2380
+ capsuleId: inlineCapsule.id,
2381
+ allowedIntents: inlineCapsule.intents
2382
+ });
2383
+ }
2384
+ const requiredScopes = this.toScopeList(normalizedPolicy?.scopes);
2385
+ if (requiredScopes.length === 0) {
2386
+ return;
2387
+ }
2388
+ let resolvedScopes;
2389
+ try {
2390
+ resolvedScopes = (0, inline_capsule_1.resolvePolicyScopes)(requiredScopes, {
2391
+ body,
2392
+ intent,
2393
+ actorId,
2394
+ chainId: executionContext?.chainEnvelope?.chainId,
2395
+ stepId: executionContext?.chainStep?.stepId
2396
+ });
2397
+ } catch (error) {
2398
+ this.logger.error(`Scope template error for ${intent}: ${error.message}`);
2399
+ throw new axis_error_1.AxisError("CAPSULE_SCOPE_TEMPLATE_UNRESOLVED", "Scope policy validation failed", 400, { intent });
2400
+ }
2401
+ if (!(0, inline_capsule_1.inlineCapsuleSatisfiesScopes)(inlineCapsule, resolvedScopes, normalizedPolicy?.scopeMode ?? "all")) {
2402
+ throw new axis_error_1.AxisError("SCOPE_MISMATCH", `Capsule scopes do not satisfy ${intent}`, 403, {
2403
+ intent,
2404
+ requiredScopes: resolvedScopes,
2405
+ availableScopes: inlineCapsule.scopes || []
2406
+ });
2407
+ }
2408
+ }
2409
+ async executeChainRequest(frame, request) {
2410
+ const { AxisChainExecutor: AxisChainExecutor2 } = await Promise.resolve().then(() => __importStar(require_axis_chain_executor()));
2411
+ const headerActorId = this.getActorIdFromFrame(frame);
2412
+ if (request.actorId && headerActorId && !this.identifiersMatch(request.actorId, headerActorId)) {
2413
+ throw new axis_error_1.AxisError("ACTOR_MISMATCH", "CHAIN.EXEC actorId conflicts with authenticated frame identity", 403);
2414
+ }
2415
+ const actorId = headerActorId || request.actorId;
2416
+ const inlineCapsule = this.toInlineCapsuleRecord(request.capsule);
2417
+ const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2418
+ const headers = new Map(frame.headers);
2419
+ if (capsuleId) {
2420
+ headers.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2421
+ headers.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
2422
+ }
2423
+ const baseFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
2424
+ ...frame,
2425
+ headers
2426
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
2427
+ metaIntent: "CHAIN.EXEC",
2428
+ actorId,
2429
+ inlineCapsule,
2430
+ capsuleRef: request.envelope.capsule,
2431
+ chainEnvelope: request.envelope
2432
+ }) || {});
2433
+ const executor = new AxisChainExecutor2(this, this.observerDispatcher);
2434
+ const result = await executor.execute(request.envelope, {
2435
+ actorId,
2436
+ baseFrame
2437
+ });
2438
+ return {
2439
+ ok: result.status !== "FAILED",
2440
+ effect: "chain.complete",
2441
+ body: this.encodeJson(result),
2442
+ metadata: {
2443
+ chainId: result.chainId,
2444
+ status: result.status
2445
+ }
2446
+ };
2447
+ }
2448
+ parseIntentExecBody(bytes2) {
2449
+ try {
2450
+ return JSON.parse(this.decoder.decode(bytes2));
2451
+ } catch (error) {
2452
+ throw new Error(`INTENT.EXEC unwrapping failed: ${error.message}`);
2453
+ }
2454
+ }
2455
+ parseChainRequestBody(bytes2) {
2456
+ let jsonError;
2457
+ try {
2458
+ const parsed = JSON.parse(this.decoder.decode(bytes2));
2459
+ if (this.isChainRequestLike(parsed)) {
2460
+ return {
2461
+ envelope: parsed.envelope,
2462
+ capsule: this.toInlineCapsuleRecord(parsed.capsule),
2463
+ actorId: typeof parsed.actorId === "string" ? parsed.actorId : void 0
2464
+ };
2465
+ }
2466
+ if (this.isChainEnvelopeLike(parsed)) {
2467
+ return { envelope: parsed };
2468
+ }
2469
+ } catch (error) {
2470
+ jsonError = error;
2471
+ }
2472
+ try {
2473
+ const decoded = (0, axis_protocol_1.decodeChainRequest)(bytes2);
2474
+ return {
2475
+ envelope: decoded.envelope,
2476
+ capsule: this.toInlineCapsuleRecord(decoded.capsule),
2477
+ actorId: decoded.actorId
2478
+ };
2479
+ } catch (requestError) {
2480
+ try {
2481
+ return {
2482
+ envelope: (0, axis_protocol_1.decodeChainEnvelope)(bytes2)
2483
+ };
2484
+ } catch (envelopeError) {
2485
+ const reason = [jsonError?.message, requestError.message, envelopeError.message].filter(Boolean).join(" | ");
2486
+ throw new Error(`CHAIN.EXEC decode failed: ${reason}`);
2487
+ }
2488
+ }
2489
+ }
2490
+ isChainRequestLike(value) {
2491
+ return !!value && typeof value === "object" && "envelope" in value && this.isChainEnvelopeLike(value.envelope);
2492
+ }
2493
+ isChainEnvelopeLike(value) {
2494
+ return !!value && typeof value === "object" && typeof value.chainId === "string" && Array.isArray(value.steps);
2495
+ }
2496
+ encodeJson(value) {
2497
+ return this.encoder.encode(JSON.stringify(value));
2498
+ }
2499
+ getActorIdFromFrame(frame) {
2500
+ return this.getHeaderValue(frame, constants_1.TLV_ACTOR_ID);
2501
+ }
2502
+ getProofRefFromFrame(frame) {
2503
+ return this.getHeaderValue(frame, constants_1.TLV_PROOF_REF) || this.getHeaderValue(frame, constants_1.TLV_CAPSULE);
2504
+ }
2505
+ hasCapsuleReference(frame) {
2506
+ return !!this.getProofRefFromFrame(frame);
2507
+ }
2508
+ getHeaderValue(frame, tag) {
2509
+ const value = frame.headers.get(tag);
2510
+ if (!value || value.length === 0) {
2511
+ return void 0;
2512
+ }
2513
+ const decoded = this.decoder.decode(value);
2514
+ if (/^[\x20-\x7e]+$/.test(decoded)) {
2515
+ return decoded;
2516
+ }
2517
+ return Buffer.from(value).toString("hex");
2518
+ }
2519
+ identifiersMatch(left, right) {
2520
+ const normalize2 = (value) => /^[0-9a-f]+$/i.test(value) ? value.toLowerCase() : value;
2521
+ return normalize2(left) === normalize2(right);
2522
+ }
2523
+ extractInlineCapsuleId(capsule) {
2524
+ const id = capsule?.id;
2525
+ return typeof id === "string" && id.length > 0 ? id : void 0;
2526
+ }
2527
+ toInlineCapsuleRecord(value) {
2528
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
2529
+ return void 0;
2530
+ }
2531
+ return value;
2532
+ }
2533
+ toScopeList(value) {
2534
+ if (!value) {
2535
+ return [];
2536
+ }
2537
+ return Array.isArray(value) ? value : [value];
2538
+ }
1586
2539
  configureCce(config) {
1587
2540
  this.ccePipelineConfig = config;
1588
2541
  this.logger.log("CCE pipeline configured");
@@ -1665,17 +2618,454 @@ var require_intent_router = __commonJS({
1665
2618
  "public.ping",
1666
2619
  "system.time",
1667
2620
  "system.echo",
2621
+ "CHAIN.EXEC",
2622
+ "axis.chain.exec",
1668
2623
  "INTENT.EXEC",
1669
2624
  "axis.intent.exec"
1670
2625
  ]);
1671
2626
  exports2.IntentRouter = IntentRouter2 = IntentRouter_1 = __decorate([
1672
2627
  (0, common_1.Injectable)(),
1673
2628
  __param(0, (0, common_1.Optional)()),
1674
- __metadata("design:paramtypes", [typeof (_a = typeof core_1.ModuleRef !== "undefined" && core_1.ModuleRef) === "function" ? _a : Object])
2629
+ __param(1, (0, common_1.Optional)()),
2630
+ __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])
1675
2631
  ], IntentRouter2);
1676
2632
  }
1677
2633
  });
1678
2634
 
2635
+ // src/engine/axis-chain.executor.ts
2636
+ var require_axis_chain_executor = __commonJS({
2637
+ "src/engine/axis-chain.executor.ts"(exports2) {
2638
+ "use strict";
2639
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
2640
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2641
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2642
+ 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;
2643
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2644
+ };
2645
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
2646
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2647
+ };
2648
+ var __param = exports2 && exports2.__param || function(paramIndex, decorator) {
2649
+ return function(target, key) {
2650
+ decorator(target, key, paramIndex);
2651
+ };
2652
+ };
2653
+ var AxisChainExecutor_1;
2654
+ var _a;
2655
+ var _b;
2656
+ Object.defineProperty(exports2, "__esModule", { value: true });
2657
+ exports2.AxisChainExecutor = void 0;
2658
+ var crypto_1 = require("crypto");
2659
+ var common_1 = require("@nestjs/common");
2660
+ var constants_1 = (init_constants(), __toCommonJS(constants_exports));
2661
+ var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
2662
+ var observer_dispatcher_service_1 = require_observer_dispatcher_service();
2663
+ var intent_router_1 = require_intent_router();
2664
+ var AxisChainExecutor2 = AxisChainExecutor_1 = class AxisChainExecutor {
2665
+ constructor(router, observerDispatcher) {
2666
+ this.router = router;
2667
+ this.observerDispatcher = observerDispatcher;
2668
+ this.logger = new common_1.Logger(AxisChainExecutor_1.name);
2669
+ this.encoder = new TextEncoder();
2670
+ this.decoder = new TextDecoder();
2671
+ }
2672
+ async execute(envelope, options = {}) {
2673
+ this.validateEnvelope(envelope);
2674
+ const startedAt = Date.now();
2675
+ const results = /* @__PURE__ */ new Map();
2676
+ const bindings = this.collectChainBindings(envelope);
2677
+ await this.dispatch(bindings, {
2678
+ event: "chain.received",
2679
+ timestamp: startedAt,
2680
+ chainId: envelope.chainId,
2681
+ envelope,
2682
+ observerTags: envelope.observerTags,
2683
+ capsule: envelope.capsule,
2684
+ keyExchange: envelope.keyExchange
2685
+ });
2686
+ await this.dispatch(bindings, {
2687
+ event: "chain.admitted",
2688
+ timestamp: Date.now(),
2689
+ chainId: envelope.chainId,
2690
+ envelope,
2691
+ observerTags: envelope.observerTags,
2692
+ capsule: envelope.capsule,
2693
+ keyExchange: envelope.keyExchange
2694
+ });
2695
+ const stepsById = new Map(envelope.steps.map((step) => [step.stepId, step]));
2696
+ const pending = new Set(stepsById.keys());
2697
+ while (pending.size > 0) {
2698
+ const ready = Array.from(pending).map((stepId) => stepsById.get(stepId)).filter((step) => this.canRun(step, results));
2699
+ if (ready.length === 0) {
2700
+ this.markUnresolvedSteps(pending, stepsById, results, "BLOCKED", "UNRESOLVED_DEPENDENCIES");
2701
+ break;
2702
+ }
2703
+ if (envelope.mode === "parallel") {
2704
+ const waveResults = await Promise.all(ready.map((step) => this.executeStep(step, envelope, results, options)));
2705
+ for (const result of waveResults) {
2706
+ results.set(result.stepId, result);
2707
+ pending.delete(result.stepId);
2708
+ }
2709
+ } else {
2710
+ for (const step of ready) {
2711
+ const result = await this.executeStep(step, envelope, results, options);
2712
+ results.set(result.stepId, result);
2713
+ pending.delete(result.stepId);
2714
+ if (result.status === "FAILED" && (envelope.mode === "strict" || envelope.mode === "atomic")) {
2715
+ this.markUnresolvedSteps(pending, stepsById, results, "SKIPPED", "CHAIN_HALTED");
2716
+ pending.clear();
2717
+ break;
2718
+ }
2719
+ }
2720
+ }
2721
+ this.blockStepsWithFailedDependencies(pending, stepsById, results);
2722
+ }
2723
+ const finishedAt = Date.now();
2724
+ const orderedResults = envelope.steps.map((step) => results.get(step.stepId));
2725
+ const summary = this.buildSummary(envelope.mode, orderedResults, startedAt, finishedAt, envelope.chainId);
2726
+ await this.dispatch(bindings, {
2727
+ event: summary.status === "SUCCEEDED" ? "chain.completed" : summary.status === "PARTIAL" ? "chain.partial" : "chain.failed",
2728
+ timestamp: finishedAt,
2729
+ chainId: envelope.chainId,
2730
+ envelope,
2731
+ result: summary,
2732
+ observerTags: envelope.observerTags,
2733
+ capsule: envelope.capsule,
2734
+ keyExchange: envelope.keyExchange
2735
+ });
2736
+ return summary;
2737
+ }
2738
+ async executeStep(step, envelope, results, options) {
2739
+ const stepBindings = this.router.getObservers(step.intent);
2740
+ const startedAt = Date.now();
2741
+ const input = this.resolveStepInput(step.input, results);
2742
+ await this.dispatch(stepBindings, {
2743
+ event: "step.started",
2744
+ timestamp: startedAt,
2745
+ chainId: envelope.chainId,
2746
+ stepId: step.stepId,
2747
+ intent: step.intent,
2748
+ envelope,
2749
+ step,
2750
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
2751
+ capsule: step.capsuleScope ? {
2752
+ ...envelope.capsule,
2753
+ scope: step.capsuleScope
2754
+ } : envelope.capsule,
2755
+ keyExchange: step.keyExchange || envelope.keyExchange
2756
+ });
2757
+ try {
2758
+ const frame = this.buildFrame(step, envelope, input, options);
2759
+ const effect = await this.router.route(frame);
2760
+ const finishedAt = Date.now();
2761
+ const output = this.decodeOutput(effect.body);
2762
+ const proofHash = this.computeProofHash(envelope.chainId, step.stepId, effect, output);
2763
+ const result = {
2764
+ stepId: step.stepId,
2765
+ intent: step.intent,
2766
+ status: "SUCCEEDED",
2767
+ effect: effect.effect,
2768
+ output,
2769
+ dependsOn: step.dependsOn,
2770
+ startedAt,
2771
+ finishedAt,
2772
+ proofHash,
2773
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
2774
+ metadata: effect.metadata
2775
+ };
2776
+ await this.dispatch(stepBindings, {
2777
+ event: "handler.completed",
2778
+ timestamp: finishedAt,
2779
+ chainId: envelope.chainId,
2780
+ stepId: step.stepId,
2781
+ intent: step.intent,
2782
+ effect,
2783
+ envelope,
2784
+ step,
2785
+ result,
2786
+ observerTags: result.observerTags,
2787
+ capsule: envelope.capsule,
2788
+ keyExchange: step.keyExchange || envelope.keyExchange
2789
+ });
2790
+ await this.dispatch(stepBindings, {
2791
+ event: "proof.recorded",
2792
+ timestamp: finishedAt,
2793
+ chainId: envelope.chainId,
2794
+ stepId: step.stepId,
2795
+ intent: step.intent,
2796
+ envelope,
2797
+ step,
2798
+ result,
2799
+ observerTags: result.observerTags,
2800
+ capsule: envelope.capsule,
2801
+ keyExchange: step.keyExchange || envelope.keyExchange,
2802
+ metadata: { proofHash }
2803
+ });
2804
+ await this.dispatch(stepBindings, {
2805
+ event: "step.completed",
2806
+ timestamp: finishedAt,
2807
+ chainId: envelope.chainId,
2808
+ stepId: step.stepId,
2809
+ intent: step.intent,
2810
+ effect,
2811
+ envelope,
2812
+ step,
2813
+ result,
2814
+ observerTags: result.observerTags,
2815
+ capsule: envelope.capsule,
2816
+ keyExchange: step.keyExchange || envelope.keyExchange
2817
+ });
2818
+ return result;
2819
+ } catch (error) {
2820
+ const finishedAt = Date.now();
2821
+ const result = {
2822
+ stepId: step.stepId,
2823
+ intent: step.intent,
2824
+ status: "FAILED",
2825
+ error: error.message,
2826
+ dependsOn: step.dependsOn,
2827
+ startedAt,
2828
+ finishedAt,
2829
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []]
2830
+ };
2831
+ this.logger.warn(`Chain ${envelope.chainId} step ${step.stepId} failed: ${error.message}`);
2832
+ await this.dispatch(stepBindings, {
2833
+ event: "step.failed",
2834
+ timestamp: finishedAt,
2835
+ chainId: envelope.chainId,
2836
+ stepId: step.stepId,
2837
+ intent: step.intent,
2838
+ error: error.message,
2839
+ envelope,
2840
+ step,
2841
+ result,
2842
+ observerTags: result.observerTags,
2843
+ capsule: envelope.capsule,
2844
+ keyExchange: step.keyExchange || envelope.keyExchange
2845
+ });
2846
+ return result;
2847
+ }
2848
+ }
2849
+ buildFrame(step, envelope, input, options) {
2850
+ const baseContext = (0, axis_execution_context_1.getAxisExecutionContext)(options.baseFrame);
2851
+ const baseHeaders = new Map(options.baseFrame?.headers || []);
2852
+ baseHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(step.intent));
2853
+ baseHeaders.set(constants_1.TLV_TRACE_ID, this.encoder.encode(envelope.chainId));
2854
+ const capsuleId = envelope.capsule?.capsuleId;
2855
+ if (capsuleId) {
2856
+ baseHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2857
+ }
2858
+ if (options.actorId) {
2859
+ baseHeaders.set(constants_1.TLV_ACTOR_ID, this.encoder.encode(options.actorId));
2860
+ }
2861
+ return (0, axis_execution_context_1.withAxisExecutionContext)({
2862
+ flags: (options.baseFrame?.flags || 0) | constants_1.FLAG_CHAIN_REQ,
2863
+ headers: baseHeaders,
2864
+ body: this.serializeInput(input),
2865
+ sig: options.baseFrame?.sig || new Uint8Array(0)
2866
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)(baseContext, {
2867
+ metaIntent: "CHAIN.EXEC",
2868
+ actorId: options.actorId || baseContext?.actorId,
2869
+ capsuleRef: step.capsuleScope ? {
2870
+ ...envelope.capsule || {},
2871
+ scope: step.capsuleScope
2872
+ } : envelope.capsule,
2873
+ chainEnvelope: envelope,
2874
+ chainStep: step
2875
+ }) || {});
2876
+ }
2877
+ validateEnvelope(envelope) {
2878
+ if (!envelope.chainId) {
2879
+ throw new Error("CHAIN_ID_REQUIRED");
2880
+ }
2881
+ if (!envelope.steps || envelope.steps.length === 0) {
2882
+ throw new Error("CHAIN_STEPS_REQUIRED");
2883
+ }
2884
+ const seen = /* @__PURE__ */ new Set();
2885
+ for (const step of envelope.steps) {
2886
+ if (!step.stepId) {
2887
+ throw new Error("CHAIN_STEP_ID_REQUIRED");
2888
+ }
2889
+ if (!step.intent) {
2890
+ throw new Error(`CHAIN_STEP_INTENT_REQUIRED:${step.stepId}`);
2891
+ }
2892
+ if (seen.has(step.stepId)) {
2893
+ throw new Error(`CHAIN_STEP_DUPLICATE:${step.stepId}`);
2894
+ }
2895
+ seen.add(step.stepId);
2896
+ }
2897
+ for (const step of envelope.steps) {
2898
+ for (const dependency of step.dependsOn || []) {
2899
+ if (!seen.has(dependency)) {
2900
+ throw new Error(`CHAIN_STEP_DEPENDENCY_UNKNOWN:${step.stepId}:${dependency}`);
2901
+ }
2902
+ }
2903
+ }
2904
+ }
2905
+ canRun(step, results) {
2906
+ return (step.dependsOn || []).every((dependency) => results.has(dependency));
2907
+ }
2908
+ blockStepsWithFailedDependencies(pending, stepsById, results) {
2909
+ for (const stepId of Array.from(pending)) {
2910
+ const step = stepsById.get(stepId);
2911
+ if (!step || !step.dependsOn || step.dependsOn.length === 0)
2912
+ continue;
2913
+ const dependencyResults = step.dependsOn.map((dependency) => results.get(dependency)).filter(Boolean);
2914
+ if (dependencyResults.length !== step.dependsOn.length)
2915
+ continue;
2916
+ const hasFailure = dependencyResults.some((dependency) => dependency.status !== "SUCCEEDED");
2917
+ if (!hasFailure)
2918
+ continue;
2919
+ results.set(step.stepId, {
2920
+ stepId: step.stepId,
2921
+ intent: step.intent,
2922
+ status: "BLOCKED",
2923
+ error: "DEPENDENCY_FAILED",
2924
+ dependsOn: step.dependsOn,
2925
+ startedAt: Date.now(),
2926
+ finishedAt: Date.now(),
2927
+ observerTags: step.observerTags
2928
+ });
2929
+ pending.delete(step.stepId);
2930
+ }
2931
+ }
2932
+ markUnresolvedSteps(pending, stepsById, results, status, error) {
2933
+ for (const stepId of pending) {
2934
+ const step = stepsById.get(stepId);
2935
+ if (!step)
2936
+ continue;
2937
+ results.set(stepId, {
2938
+ stepId,
2939
+ intent: step.intent,
2940
+ status,
2941
+ error,
2942
+ dependsOn: step.dependsOn,
2943
+ startedAt: Date.now(),
2944
+ finishedAt: Date.now(),
2945
+ observerTags: step.observerTags
2946
+ });
2947
+ }
2948
+ }
2949
+ buildSummary(mode, results, startedAt, finishedAt, chainId) {
2950
+ const completedSteps = results.filter((result) => result.status === "SUCCEEDED").length;
2951
+ const failedSteps = results.filter((result) => result.status === "FAILED").length;
2952
+ const blockedSteps = results.filter((result) => result.status === "BLOCKED").length;
2953
+ const skippedSteps = results.filter((result) => result.status === "SKIPPED").length;
2954
+ let status = "SUCCEEDED";
2955
+ if (failedSteps > 0 || blockedSteps > 0 || skippedSteps > 0) {
2956
+ status = mode === "best_effort" || mode === "parallel" ? completedSteps > 0 ? "PARTIAL" : "FAILED" : "FAILED";
2957
+ }
2958
+ return {
2959
+ chainId,
2960
+ mode,
2961
+ status,
2962
+ completedSteps,
2963
+ failedSteps,
2964
+ blockedSteps,
2965
+ skippedSteps,
2966
+ startedAt,
2967
+ finishedAt,
2968
+ results,
2969
+ rollback: mode === "atomic" ? {
2970
+ supported: false,
2971
+ attempted: false,
2972
+ reason: "AXIS handlers do not expose rollback semantics yet"
2973
+ } : void 0
2974
+ };
2975
+ }
2976
+ resolveStepInput(value, results) {
2977
+ if (typeof value === "string") {
2978
+ if (!value.startsWith("$"))
2979
+ return value;
2980
+ return this.lookupReference(value.slice(1), results);
2981
+ }
2982
+ if (Array.isArray(value)) {
2983
+ return value.map((entry) => this.resolveStepInput(entry, results));
2984
+ }
2985
+ if (value && typeof value === "object") {
2986
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
2987
+ key,
2988
+ this.resolveStepInput(entry, results)
2989
+ ]));
2990
+ }
2991
+ return value;
2992
+ }
2993
+ lookupReference(path2, results) {
2994
+ const [stepId, ...segments] = path2.split(".");
2995
+ const result = results.get(stepId);
2996
+ if (!result)
2997
+ return void 0;
2998
+ let current = result;
2999
+ for (const segment of segments) {
3000
+ if (current === void 0 || current === null)
3001
+ return void 0;
3002
+ if (typeof current !== "object")
3003
+ return void 0;
3004
+ current = current[segment];
3005
+ }
3006
+ return current;
3007
+ }
3008
+ serializeInput(input) {
3009
+ if (input instanceof Uint8Array)
3010
+ return input;
3011
+ if (typeof input === "string")
3012
+ return this.encoder.encode(input);
3013
+ if (input === void 0)
3014
+ return new Uint8Array(0);
3015
+ return this.encoder.encode(JSON.stringify(input));
3016
+ }
3017
+ decodeOutput(body) {
3018
+ if (!body || body.length === 0)
3019
+ return void 0;
3020
+ try {
3021
+ const text = this.decoder.decode(body);
3022
+ try {
3023
+ return JSON.parse(text);
3024
+ } catch {
3025
+ return /^[\x20-\x7E\s]+$/.test(text) ? text : body;
3026
+ }
3027
+ } catch {
3028
+ return body;
3029
+ }
3030
+ }
3031
+ computeProofHash(chainId, stepId, effect, output) {
3032
+ const hash = (0, crypto_1.createHash)("sha256");
3033
+ hash.update(chainId);
3034
+ hash.update(":");
3035
+ hash.update(stepId);
3036
+ hash.update(":");
3037
+ hash.update(effect.effect);
3038
+ hash.update(":");
3039
+ hash.update(JSON.stringify(output ?? null));
3040
+ return hash.digest("hex");
3041
+ }
3042
+ collectChainBindings(envelope) {
3043
+ const uniqueBindings = /* @__PURE__ */ new Map();
3044
+ for (const step of envelope.steps) {
3045
+ for (const binding of this.router.getObservers(step.intent)) {
3046
+ const key = binding.refs.map((ref) => String(ref)).sort().join("|");
3047
+ if (!uniqueBindings.has(key)) {
3048
+ uniqueBindings.set(key, binding);
3049
+ }
3050
+ }
3051
+ }
3052
+ return Array.from(uniqueBindings.values());
3053
+ }
3054
+ async dispatch(bindings, context) {
3055
+ if (!this.observerDispatcher)
3056
+ return;
3057
+ await this.observerDispatcher.dispatch(bindings, context);
3058
+ }
3059
+ };
3060
+ exports2.AxisChainExecutor = AxisChainExecutor2;
3061
+ exports2.AxisChainExecutor = AxisChainExecutor2 = AxisChainExecutor_1 = __decorate([
3062
+ (0, common_1.Injectable)(),
3063
+ __param(1, (0, common_1.Optional)()),
3064
+ __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])
3065
+ ], AxisChainExecutor2);
3066
+ }
3067
+ });
3068
+
1679
3069
  // src/engine/sensor-bands.ts
1680
3070
  var sensor_bands_exports = {};
1681
3071
  __export(sensor_bands_exports, {
@@ -2083,79 +3473,6 @@ var init_truth_scoring = __esm({
2083
3473
  }
2084
3474
  });
2085
3475
 
2086
- // src/core/constants.ts
2087
- var constants_exports = {};
2088
- __export(constants_exports, {
2089
- AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
2090
- AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
2091
- BodyProfile: () => import_axis_protocol2.BodyProfile,
2092
- ERR_BAD_SIGNATURE: () => import_axis_protocol2.ERR_BAD_SIGNATURE,
2093
- ERR_CONTRACT_VIOLATION: () => import_axis_protocol2.ERR_CONTRACT_VIOLATION,
2094
- ERR_INVALID_PACKET: () => import_axis_protocol2.ERR_INVALID_PACKET,
2095
- ERR_REPLAY_DETECTED: () => import_axis_protocol2.ERR_REPLAY_DETECTED,
2096
- FLAG_BODY_TLV: () => import_axis_protocol2.FLAG_BODY_TLV,
2097
- FLAG_CHAIN_REQ: () => import_axis_protocol2.FLAG_CHAIN_REQ,
2098
- FLAG_HAS_WITNESS: () => import_axis_protocol2.FLAG_HAS_WITNESS,
2099
- MAX_BODY_LEN: () => import_axis_protocol2.MAX_BODY_LEN,
2100
- MAX_FRAME_LEN: () => import_axis_protocol2.MAX_FRAME_LEN,
2101
- MAX_HDR_LEN: () => import_axis_protocol2.MAX_HDR_LEN,
2102
- MAX_SIG_LEN: () => import_axis_protocol2.MAX_SIG_LEN,
2103
- NCERT_ALG: () => import_axis_protocol2.NCERT_ALG,
2104
- NCERT_EXP: () => import_axis_protocol2.NCERT_EXP,
2105
- NCERT_ISSUER_KID: () => import_axis_protocol2.NCERT_ISSUER_KID,
2106
- NCERT_KID: () => import_axis_protocol2.NCERT_KID,
2107
- NCERT_NBF: () => import_axis_protocol2.NCERT_NBF,
2108
- NCERT_NODE_ID: () => import_axis_protocol2.NCERT_NODE_ID,
2109
- NCERT_PAYLOAD: () => import_axis_protocol2.NCERT_PAYLOAD,
2110
- NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
2111
- NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
2112
- NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
2113
- PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
2114
- PROOF_JWT: () => import_axis_protocol2.PROOF_JWT,
2115
- PROOF_LOOM: () => import_axis_protocol2.PROOF_LOOM,
2116
- PROOF_MTLS: () => import_axis_protocol2.PROOF_MTLS,
2117
- PROOF_NONE: () => import_axis_protocol2.PROOF_NONE,
2118
- PROOF_WITNESS: () => import_axis_protocol2.PROOF_WITNESS,
2119
- ProofType: () => import_axis_protocol2.ProofType,
2120
- TLV_ACTOR_ID: () => import_axis_protocol2.TLV_ACTOR_ID,
2121
- TLV_AUD: () => import_axis_protocol2.TLV_AUD,
2122
- TLV_BODY_ARR: () => import_axis_protocol2.TLV_BODY_ARR,
2123
- TLV_BODY_OBJ: () => import_axis_protocol2.TLV_BODY_OBJ,
2124
- TLV_CAPSULE: () => import_axis_protocol2.TLV_CAPSULE,
2125
- TLV_EFFECT: () => import_axis_protocol2.TLV_EFFECT,
2126
- TLV_ERROR_CODE: () => import_axis_protocol2.TLV_ERROR_CODE,
2127
- TLV_ERROR_MSG: () => import_axis_protocol2.TLV_ERROR_MSG,
2128
- TLV_INDEX: () => import_axis_protocol2.TLV_INDEX,
2129
- TLV_INTENT: () => import_axis_protocol2.TLV_INTENT,
2130
- TLV_KID: () => import_axis_protocol2.TLV_KID,
2131
- TLV_LOOM_PRESENCE_ID: () => import_axis_protocol2.TLV_LOOM_PRESENCE_ID,
2132
- TLV_LOOM_THREAD_HASH: () => import_axis_protocol2.TLV_LOOM_THREAD_HASH,
2133
- TLV_LOOM_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
2134
- TLV_NODE: () => import_axis_protocol2.TLV_NODE,
2135
- TLV_NODE_CERT_HASH: () => import_axis_protocol2.TLV_NODE_CERT_HASH,
2136
- TLV_NODE_KID: () => import_axis_protocol2.TLV_NODE_KID,
2137
- TLV_NONCE: () => import_axis_protocol2.TLV_NONCE,
2138
- TLV_OFFSET: () => import_axis_protocol2.TLV_OFFSET,
2139
- TLV_OK: () => import_axis_protocol2.TLV_OK,
2140
- TLV_PID: () => import_axis_protocol2.TLV_PID,
2141
- TLV_PREV_HASH: () => import_axis_protocol2.TLV_PREV_HASH,
2142
- TLV_PROOF_REF: () => import_axis_protocol2.TLV_PROOF_REF,
2143
- TLV_PROOF_TYPE: () => import_axis_protocol2.TLV_PROOF_TYPE,
2144
- TLV_REALM: () => import_axis_protocol2.TLV_REALM,
2145
- TLV_RECEIPT_HASH: () => import_axis_protocol2.TLV_RECEIPT_HASH,
2146
- TLV_RID: () => import_axis_protocol2.TLV_RID,
2147
- TLV_SHA256_CHUNK: () => import_axis_protocol2.TLV_SHA256_CHUNK,
2148
- TLV_TRACE_ID: () => import_axis_protocol2.TLV_TRACE_ID,
2149
- TLV_TS: () => import_axis_protocol2.TLV_TS,
2150
- TLV_UPLOAD_ID: () => import_axis_protocol2.TLV_UPLOAD_ID
2151
- });
2152
- var import_axis_protocol2;
2153
- var init_constants = __esm({
2154
- "src/core/constants.ts"() {
2155
- import_axis_protocol2 = require("@nextera.one/axis-protocol");
2156
- }
2157
- });
2158
-
2159
3476
  // src/engine/observation/response-observer.ts
2160
3477
  function verifyResponse(ctx, response) {
2161
3478
  if (!response.effect || typeof response.effect !== "string") {
@@ -3593,37 +4910,6 @@ var init_packet = __esm({
3593
4910
  }
3594
4911
  });
3595
4912
 
3596
- // src/security/scopes.ts
3597
- function hasScope(scopes, required) {
3598
- if (!Array.isArray(scopes) || scopes.length === 0) {
3599
- return false;
3600
- }
3601
- if (scopes.includes(required)) {
3602
- return true;
3603
- }
3604
- const [resource, id] = required.split(":");
3605
- if (resource && id) {
3606
- const wildcard = `${resource}:*`;
3607
- if (scopes.includes(wildcard)) {
3608
- return true;
3609
- }
3610
- }
3611
- return false;
3612
- }
3613
- function parseScope(scope) {
3614
- const parts = scope.split(":");
3615
- if (parts.length !== 2) return null;
3616
- return { resource: parts[0], id: parts[1] };
3617
- }
3618
- function canAccessResource(scopes, resourceType, resourceId) {
3619
- const required = `${resourceType}:${resourceId}`;
3620
- return hasScope(scopes, required);
3621
- }
3622
- var init_scopes = __esm({
3623
- "src/security/scopes.ts"() {
3624
- }
3625
- });
3626
-
3627
4913
  // src/security/capabilities.ts
3628
4914
  var CAPABILITIES, PROOF_CAPABILITIES, INTENT_REQUIREMENTS;
3629
4915
  var init_capabilities = __esm({
@@ -4354,23 +5640,62 @@ var require_axis_request_decorator = __commonJS({
4354
5640
  }
4355
5641
  });
4356
5642
 
4357
- // src/core/axis-error.ts
4358
- var axis_error_exports = {};
4359
- __export(axis_error_exports, {
4360
- AxisError: () => AxisError
4361
- });
4362
- var AxisError;
4363
- var init_axis_error = __esm({
4364
- "src/core/axis-error.ts"() {
4365
- AxisError = class extends Error {
4366
- constructor(code, message, httpStatus = 400, details) {
4367
- super(message);
4368
- this.code = code;
4369
- this.httpStatus = httpStatus;
4370
- this.details = details;
4371
- this.name = "AxisError";
5643
+ // src/engine/observer-discovery.service.ts
5644
+ var require_observer_discovery_service = __commonJS({
5645
+ "src/engine/observer-discovery.service.ts"(exports2) {
5646
+ "use strict";
5647
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
5648
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5649
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5650
+ 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;
5651
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5652
+ };
5653
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
5654
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5655
+ };
5656
+ var ObserverDiscoveryService_1;
5657
+ var _a;
5658
+ var _b;
5659
+ var _c;
5660
+ Object.defineProperty(exports2, "__esModule", { value: true });
5661
+ exports2.ObserverDiscoveryService = void 0;
5662
+ var common_1 = require("@nestjs/common");
5663
+ var core_1 = require("@nestjs/core");
5664
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
5665
+ var observer_registry_1 = require_observer_registry();
5666
+ var ObserverDiscoveryService2 = ObserverDiscoveryService_1 = class ObserverDiscoveryService {
5667
+ constructor(discovery, reflector, registry) {
5668
+ this.discovery = discovery;
5669
+ this.reflector = reflector;
5670
+ this.registry = registry;
5671
+ this.logger = new common_1.Logger(ObserverDiscoveryService_1.name);
5672
+ }
5673
+ onApplicationBootstrap() {
5674
+ const providers = this.discovery.getProviders();
5675
+ let count = 0;
5676
+ for (const wrapper of providers) {
5677
+ const { instance } = wrapper;
5678
+ if (!instance || !instance.constructor)
5679
+ continue;
5680
+ const meta = this.reflector.get(observer_decorator_1.OBSERVER_METADATA_KEY, instance.constructor);
5681
+ if (!meta)
5682
+ continue;
5683
+ const observer = instance;
5684
+ if (typeof observer.observe !== "function") {
5685
+ this.logger.warn(`@Observer on ${instance.constructor.name} is missing observe() and was skipped`);
5686
+ continue;
5687
+ }
5688
+ this.registry.register(observer, meta);
5689
+ count++;
5690
+ }
5691
+ this.logger.log(`Auto-registered ${count} observers via @Observer()`);
4372
5692
  }
4373
5693
  };
5694
+ exports2.ObserverDiscoveryService = ObserverDiscoveryService2;
5695
+ exports2.ObserverDiscoveryService = ObserverDiscoveryService2 = ObserverDiscoveryService_1 = __decorate([
5696
+ (0, common_1.Injectable)(),
5697
+ __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])
5698
+ ], ObserverDiscoveryService2);
4374
5699
  }
4375
5700
  });
4376
5701
 
@@ -4395,6 +5720,7 @@ var require_handler_discovery_service = __commonJS({
4395
5720
  exports2.HandlerDiscoveryService = void 0;
4396
5721
  var common_1 = require("@nestjs/common");
4397
5722
  var core_1 = require("@nestjs/core");
5723
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
4398
5724
  var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
4399
5725
  var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
4400
5726
  var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
@@ -4417,20 +5743,36 @@ var require_handler_discovery_service = __commonJS({
4417
5743
  if (!handlerMeta)
4418
5744
  continue;
4419
5745
  const handlerName = handlerMeta.intent || metatype.name;
5746
+ const prefix = handlerMeta.intent || metatype.name;
4420
5747
  const proto = Object.getPrototypeOf(instance);
4421
5748
  const methods = this.scanner.getAllMethodNames(proto);
5749
+ const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, metatype) || [];
5750
+ const routedMethods = new Set(routes.map((route) => String(route.methodName)));
4422
5751
  let registered = 0;
4423
5752
  const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, metatype) || [];
5753
+ const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, metatype) || [];
5754
+ for (const route of routes) {
5755
+ const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
5756
+ if (!this.router.has(intentName)) {
5757
+ this.router.register(intentName, instance[route.methodName].bind(instance));
5758
+ registered++;
5759
+ totalIntents++;
5760
+ }
5761
+ this.router.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
5762
+ }
4424
5763
  for (const methodName of methods) {
5764
+ if (routedMethods.has(methodName))
5765
+ continue;
4425
5766
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
4426
5767
  if (!meta?.intent)
4427
5768
  continue;
4428
- if (!this.router.has(meta.intent)) {
4429
- this.router.register(meta.intent, instance[methodName].bind(instance));
5769
+ const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
5770
+ if (!this.router.has(intentName)) {
5771
+ this.router.register(intentName, instance[methodName].bind(instance));
4430
5772
  registered++;
4431
5773
  totalIntents++;
4432
5774
  }
4433
- this.router.registerIntentMeta(meta.intent, proto, methodName, handlerSensors);
5775
+ this.router.registerIntentMeta(intentName, proto, methodName, handlerSensors, handlerObservers);
4434
5776
  }
4435
5777
  if (registered > 0) {
4436
5778
  this.logger.log(`Auto-registered ${registered} intents from ${handlerName}`);
@@ -8007,6 +9349,10 @@ var init_crypto = __esm({
8007
9349
  // src/decorators/index.ts
8008
9350
  var decorators_exports = {};
8009
9351
  __export(decorators_exports, {
9352
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
9353
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
9354
+ CapsulePolicy: () => CapsulePolicy,
9355
+ Chain: () => Chain,
8010
9356
  HANDLER_METADATA_KEY: () => HANDLER_METADATA_KEY,
8011
9357
  Handler: () => Handler,
8012
9358
  INTENT_BODY_KEY: () => INTENT_BODY_KEY,
@@ -8016,17 +9362,25 @@ __export(decorators_exports, {
8016
9362
  Intent: () => Intent,
8017
9363
  IntentBody: () => IntentBody,
8018
9364
  IntentSensors: () => IntentSensors,
9365
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
9366
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
9367
+ Observer: () => Observer,
8019
9368
  SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
8020
- Sensor: () => Sensor
9369
+ Sensor: () => Sensor,
9370
+ mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
9371
+ normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
8021
9372
  });
8022
9373
  var init_decorators = __esm({
8023
9374
  "src/decorators/index.ts"() {
8024
9375
  __reExport(decorators_exports, __toESM(require_axis_request_decorator()));
9376
+ init_capsule_policy_decorator();
9377
+ init_chain_decorator();
8025
9378
  __reExport(decorators_exports, __toESM(require_dto_schema_util()));
8026
9379
  init_handler_decorator();
8027
9380
  init_intent_body_decorator();
8028
9381
  init_intent_sensors_decorator();
8029
9382
  init_intent_decorator();
9383
+ init_observer_decorator();
8030
9384
  init_sensor_decorator();
8031
9385
  __reExport(decorators_exports, __toESM(require_tlv_field_decorator()));
8032
9386
  }
@@ -8038,6 +9392,18 @@ var init_axis_decoded = __esm({
8038
9392
  }
8039
9393
  });
8040
9394
 
9395
+ // src/engine/axis-chain.types.ts
9396
+ var init_axis_chain_types = __esm({
9397
+ "src/engine/axis-chain.types.ts"() {
9398
+ }
9399
+ });
9400
+
9401
+ // src/engine/axis-observer.interface.ts
9402
+ var init_axis_observer_interface = __esm({
9403
+ "src/engine/axis-observer.interface.ts"() {
9404
+ }
9405
+ });
9406
+
8041
9407
  // src/engine/observation/observation-queue.types.ts
8042
9408
  var init_observation_queue_types = __esm({
8043
9409
  "src/engine/observation/observation-queue.types.ts"() {
@@ -8072,6 +9438,7 @@ var init_observation = __esm({
8072
9438
  // src/engine/index.ts
8073
9439
  var engine_exports = {};
8074
9440
  __export(engine_exports, {
9441
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
8075
9442
  BAND: () => BAND,
8076
9443
  PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
8077
9444
  ResponseObserver: () => ResponseObserver,
@@ -8083,24 +9450,34 @@ __export(engine_exports, {
8083
9450
  encodeQueueMessage: () => encodeQueueMessage,
8084
9451
  endStage: () => endStage,
8085
9452
  finalizeObservation: () => finalizeObservation,
9453
+ getAxisExecutionContext: () => getAxisExecutionContext,
8086
9454
  hashObservation: () => hashObservation,
9455
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
8087
9456
  observation: () => observation_exports,
8088
9457
  parseAutoClaimEntries: () => parseAutoClaimEntries,
8089
9458
  parseStreamEntries: () => parseStreamEntries,
8090
9459
  recordSensor: () => recordSensor,
8091
9460
  stableJsonStringify: () => stableJsonStringify,
8092
9461
  startStage: () => startStage,
8093
- verifyResponse: () => verifyResponse
9462
+ verifyResponse: () => verifyResponse,
9463
+ withAxisExecutionContext: () => withAxisExecutionContext
8094
9464
  });
8095
9465
  var init_engine = __esm({
8096
9466
  "src/engine/index.ts"() {
8097
9467
  init_axis_decoded();
9468
+ __reExport(engine_exports, __toESM(require_axis_chain_executor()));
9469
+ init_axis_chain_types();
9470
+ init_axis_execution_context();
8098
9471
  init_axis_observation();
9472
+ init_axis_observer_interface();
8099
9473
  __reExport(engine_exports, __toESM(require_handler_discovery_service()));
8100
9474
  __reExport(engine_exports, __toESM(require_intent_router()));
8101
9475
  init_observation();
9476
+ __reExport(engine_exports, __toESM(require_observer_discovery_service()));
9477
+ __reExport(engine_exports, __toESM(require_observer_dispatcher_service()));
8102
9478
  init_sensor_bands();
8103
9479
  __reExport(engine_exports, __toESM(require_sensor_discovery_service()));
9480
+ __reExport(engine_exports, __toESM(require_observer_registry()));
8104
9481
  __reExport(engine_exports, __toESM(require_sensor_registry()));
8105
9482
  init_observation();
8106
9483
  }
@@ -10405,6 +11782,7 @@ var index_exports = {};
10405
11782
  __export(index_exports, {
10406
11783
  ATS1_HDR: () => ATS1_HDR,
10407
11784
  ATS1_SCHEMA: () => ATS1_SCHEMA,
11785
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
10408
11786
  AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
10409
11787
  AXIS_OPCODES: () => AXIS_OPCODES,
10410
11788
  AXIS_UPLOAD_FILE_STORE: () => AXIS_UPLOAD_FILE_STORE,
@@ -10412,6 +11790,7 @@ __export(index_exports, {
10412
11790
  AXIS_UPLOAD_SESSION_STORE: () => AXIS_UPLOAD_SESSION_STORE,
10413
11791
  AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
10414
11792
  Ats1Codec: () => ats1_exports,
11793
+ AxisChainExecutor: () => import_axis_chain.AxisChainExecutor,
10415
11794
  AxisContext: () => import_axis_request.AxisContext,
10416
11795
  AxisDemoPubkey: () => import_axis_request.AxisDemoPubkey,
10417
11796
  AxisEffect: () => import_intent2.AxisEffect,
@@ -10430,9 +11809,13 @@ __export(index_exports, {
10430
11809
  BAND: () => BAND,
10431
11810
  BodyProfile: () => import_axis_protocol2.BodyProfile,
10432
11811
  CAPABILITIES: () => CAPABILITIES,
11812
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
10433
11813
  CCE_ERROR: () => CCE_ERROR,
10434
11814
  CCE_PROTOCOL_VERSION: () => CCE_PROTOCOL_VERSION,
11815
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
11816
+ CapsulePolicy: () => CapsulePolicy,
10435
11817
  CceError: () => CceError,
11818
+ Chain: () => Chain,
10436
11819
  ContractViolationError: () => ContractViolationError,
10437
11820
  DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
10438
11821
  DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
@@ -10482,6 +11865,12 @@ __export(index_exports, {
10482
11865
  NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
10483
11866
  NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
10484
11867
  NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
11868
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
11869
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
11870
+ Observer: () => Observer,
11871
+ ObserverDiscoveryService: () => import_observer_discovery.ObserverDiscoveryService,
11872
+ ObserverDispatcherService: () => import_observer_dispatcher.ObserverDispatcherService,
11873
+ ObserverRegistry: () => import_observer2.ObserverRegistry,
10485
11874
  PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
10486
11875
  PROOF_CAPABILITIES: () => PROOF_CAPABILITIES,
10487
11876
  PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
@@ -10622,6 +12011,7 @@ __export(index_exports, {
10622
12011
  forkFromKnot: () => forkFromKnot,
10623
12012
  formStitch: () => formStitch,
10624
12013
  generateEd25519KeyPair: () => generateEd25519KeyPair,
12014
+ getAxisExecutionContext: () => getAxisExecutionContext,
10625
12015
  getDecisionPoints: () => getDecisionPoints,
10626
12016
  getFabricValue: () => getFabricValue,
10627
12017
  getGrantStatus: () => getGrantStatus,
@@ -10641,6 +12031,7 @@ __export(index_exports, {
10641
12031
  lockCells: () => lockCells,
10642
12032
  loom: () => loom_exports,
10643
12033
  matchPatterns: () => matchPatterns,
12034
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
10644
12035
  needle: () => needle_exports,
10645
12036
  nonce16: () => nonce16,
10646
12037
  normalizeSensorDecision: () => normalizeSensorDecision,
@@ -10691,16 +12082,20 @@ __export(index_exports, {
10691
12082
  verifyPresenceProof: () => verifyPresenceProof,
10692
12083
  verifyReceiptChain: () => verifyReceiptChain,
10693
12084
  verifyResponse: () => verifyResponse,
10694
- weave: () => weave
12085
+ weave: () => weave,
12086
+ withAxisExecutionContext: () => withAxisExecutionContext
10695
12087
  });
10696
12088
  module.exports = __toCommonJS(index_exports);
10697
- 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;
12089
+ 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;
10698
12090
  var init_index = __esm({
10699
12091
  "src/index.ts"() {
12092
+ init_chain_decorator();
12093
+ init_capsule_policy_decorator();
10700
12094
  init_handler_decorator();
10701
12095
  init_intent_decorator();
10702
12096
  init_intent_body_decorator();
10703
12097
  init_intent_sensors_decorator();
12098
+ init_observer_decorator();
10704
12099
  init_handler_sensors_decorator();
10705
12100
  init_sensor_decorator();
10706
12101
  import_tlv_field2 = __toESM(require_tlv_field_decorator());
@@ -10709,6 +12104,8 @@ var init_index = __esm({
10709
12104
  import_axis_id = __toESM(require_axis_id_dto());
10710
12105
  init_axis_partial_type();
10711
12106
  import_axis_response = __toESM(require_axis_response_dto());
12107
+ import_axis_chain = __toESM(require_axis_chain_executor());
12108
+ init_axis_execution_context();
10712
12109
  import_intent2 = __toESM(require_intent_router());
10713
12110
  init_sensor_bands();
10714
12111
  init_stable_json();
@@ -10748,8 +12145,11 @@ var init_index = __esm({
10748
12145
  init_disk_upload_file_store();
10749
12146
  import_axis_request = __toESM(require_axis_request_decorator());
10750
12147
  init_axis_error();
12148
+ import_observer_discovery = __toESM(require_observer_discovery_service());
12149
+ import_observer_dispatcher = __toESM(require_observer_dispatcher_service());
10751
12150
  import_handler_discovery = __toESM(require_handler_discovery_service());
10752
12151
  import_sensor_discovery = __toESM(require_sensor_discovery_service());
12152
+ import_observer2 = __toESM(require_observer_registry());
10753
12153
  import_sensor2 = __toESM(require_sensor_registry());
10754
12154
  init_axis_observation();
10755
12155
  import_axis_sensor_chain = __toESM(require_axis_sensor_chain_service());
@@ -10788,6 +12188,7 @@ init_index();
10788
12188
  0 && (module.exports = {
10789
12189
  ATS1_HDR,
10790
12190
  ATS1_SCHEMA,
12191
+ AXIS_EXECUTION_CONTEXT_KEY,
10791
12192
  AXIS_MAGIC,
10792
12193
  AXIS_OPCODES,
10793
12194
  AXIS_UPLOAD_FILE_STORE,
@@ -10795,6 +12196,7 @@ init_index();
10795
12196
  AXIS_UPLOAD_SESSION_STORE,
10796
12197
  AXIS_VERSION,
10797
12198
  Ats1Codec,
12199
+ AxisChainExecutor,
10798
12200
  AxisContext,
10799
12201
  AxisDemoPubkey,
10800
12202
  AxisEffect,
@@ -10813,9 +12215,13 @@ init_index();
10813
12215
  BAND,
10814
12216
  BodyProfile,
10815
12217
  CAPABILITIES,
12218
+ CAPSULE_POLICY_METADATA_KEY,
10816
12219
  CCE_ERROR,
10817
12220
  CCE_PROTOCOL_VERSION,
12221
+ CHAIN_METADATA_KEY,
12222
+ CapsulePolicy,
10818
12223
  CceError,
12224
+ Chain,
10819
12225
  ContractViolationError,
10820
12226
  DEFAULT_CONTRACTS,
10821
12227
  DEFAULT_TIMEOUT,
@@ -10865,6 +12271,12 @@ init_index();
10865
12271
  NCERT_PUB,
10866
12272
  NCERT_SCOPE,
10867
12273
  NCERT_SIG,
12274
+ OBSERVER_BINDINGS_KEY,
12275
+ OBSERVER_METADATA_KEY,
12276
+ Observer,
12277
+ ObserverDiscoveryService,
12278
+ ObserverDispatcherService,
12279
+ ObserverRegistry,
10868
12280
  PRE_DECODE_BOUNDARY,
10869
12281
  PROOF_CAPABILITIES,
10870
12282
  PROOF_CAPSULE,
@@ -11005,6 +12417,7 @@ init_index();
11005
12417
  forkFromKnot,
11006
12418
  formStitch,
11007
12419
  generateEd25519KeyPair,
12420
+ getAxisExecutionContext,
11008
12421
  getDecisionPoints,
11009
12422
  getFabricValue,
11010
12423
  getGrantStatus,
@@ -11024,6 +12437,7 @@ init_index();
11024
12437
  lockCells,
11025
12438
  loom,
11026
12439
  matchPatterns,
12440
+ mergeAxisExecutionContext,
11027
12441
  needle,
11028
12442
  nonce16,
11029
12443
  normalizeSensorDecision,
@@ -11074,6 +12488,7 @@ init_index();
11074
12488
  verifyPresenceProof,
11075
12489
  verifyReceiptChain,
11076
12490
  verifyResponse,
11077
- weave
12491
+ weave,
12492
+ withAxisExecutionContext
11078
12493
  });
11079
12494
  //# sourceMappingURL=index.js.map