@nextera.one/axis-server-sdk 1.9.0 → 2.1.0

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
  });
@@ -230,10 +398,10 @@ function TlvRange(min, max, message) {
230
398
  return null;
231
399
  });
232
400
  }
233
- var import_reflect_metadata5, TLV_FIELDS_KEY, TLV_VALIDATORS_KEY;
401
+ var import_reflect_metadata8, TLV_FIELDS_KEY, TLV_VALIDATORS_KEY;
234
402
  var init_tlv_field_decorator = __esm({
235
403
  "src/decorators/tlv-field.decorator.ts"() {
236
- import_reflect_metadata5 = require("reflect-metadata");
404
+ import_reflect_metadata8 = require("reflect-metadata");
237
405
  TLV_FIELDS_KEY = "axis:tlv:fields";
238
406
  TLV_VALIDATORS_KEY = "axis:tlv:validators";
239
407
  }
@@ -406,10 +574,10 @@ function AxisPartialType(BaseDto) {
406
574
  });
407
575
  return PartialDto;
408
576
  }
409
- var import_reflect_metadata6;
577
+ var import_reflect_metadata9;
410
578
  var init_axis_partial_type = __esm({
411
579
  "src/base/axis-partial-type.ts"() {
412
- import_reflect_metadata6 = require("reflect-metadata");
580
+ import_reflect_metadata9 = require("reflect-metadata");
413
581
  init_tlv_field_decorator();
414
582
  }
415
583
  });
@@ -462,113 +630,246 @@ var require_axis_response_dto = __commonJS({
462
630
  }
463
631
  });
464
632
 
465
- // src/sensor/axis-sensor.ts
466
- var axis_sensor_exports = {};
467
- __export(axis_sensor_exports, {
468
- Decision: () => Decision,
469
- SensorDecisions: () => SensorDecisions,
470
- normalizeSensorDecision: () => normalizeSensorDecision
633
+ // src/core/constants.ts
634
+ var constants_exports = {};
635
+ __export(constants_exports, {
636
+ AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
637
+ AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
638
+ BodyProfile: () => import_axis_protocol2.BodyProfile,
639
+ ERR_BAD_SIGNATURE: () => import_axis_protocol2.ERR_BAD_SIGNATURE,
640
+ ERR_CONTRACT_VIOLATION: () => import_axis_protocol2.ERR_CONTRACT_VIOLATION,
641
+ ERR_INVALID_PACKET: () => import_axis_protocol2.ERR_INVALID_PACKET,
642
+ ERR_REPLAY_DETECTED: () => import_axis_protocol2.ERR_REPLAY_DETECTED,
643
+ FLAG_BODY_TLV: () => import_axis_protocol2.FLAG_BODY_TLV,
644
+ FLAG_CHAIN_REQ: () => import_axis_protocol2.FLAG_CHAIN_REQ,
645
+ FLAG_HAS_WITNESS: () => import_axis_protocol2.FLAG_HAS_WITNESS,
646
+ MAX_BODY_LEN: () => import_axis_protocol2.MAX_BODY_LEN,
647
+ MAX_FRAME_LEN: () => import_axis_protocol2.MAX_FRAME_LEN,
648
+ MAX_HDR_LEN: () => import_axis_protocol2.MAX_HDR_LEN,
649
+ MAX_SIG_LEN: () => import_axis_protocol2.MAX_SIG_LEN,
650
+ NCERT_ALG: () => import_axis_protocol2.NCERT_ALG,
651
+ NCERT_EXP: () => import_axis_protocol2.NCERT_EXP,
652
+ NCERT_ISSUER_KID: () => import_axis_protocol2.NCERT_ISSUER_KID,
653
+ NCERT_KID: () => import_axis_protocol2.NCERT_KID,
654
+ NCERT_NBF: () => import_axis_protocol2.NCERT_NBF,
655
+ NCERT_NODE_ID: () => import_axis_protocol2.NCERT_NODE_ID,
656
+ NCERT_PAYLOAD: () => import_axis_protocol2.NCERT_PAYLOAD,
657
+ NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
658
+ NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
659
+ NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
660
+ PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
661
+ PROOF_JWT: () => import_axis_protocol2.PROOF_JWT,
662
+ PROOF_LOOM: () => import_axis_protocol2.PROOF_LOOM,
663
+ PROOF_MTLS: () => import_axis_protocol2.PROOF_MTLS,
664
+ PROOF_NONE: () => import_axis_protocol2.PROOF_NONE,
665
+ PROOF_WITNESS: () => import_axis_protocol2.PROOF_WITNESS,
666
+ ProofType: () => import_axis_protocol2.ProofType,
667
+ TLV_ACTOR_ID: () => import_axis_protocol2.TLV_ACTOR_ID,
668
+ TLV_AUD: () => import_axis_protocol2.TLV_AUD,
669
+ TLV_BODY_ARR: () => import_axis_protocol2.TLV_BODY_ARR,
670
+ TLV_BODY_OBJ: () => import_axis_protocol2.TLV_BODY_OBJ,
671
+ TLV_CAPSULE: () => import_axis_protocol2.TLV_CAPSULE,
672
+ TLV_EFFECT: () => import_axis_protocol2.TLV_EFFECT,
673
+ TLV_ERROR_CODE: () => import_axis_protocol2.TLV_ERROR_CODE,
674
+ TLV_ERROR_MSG: () => import_axis_protocol2.TLV_ERROR_MSG,
675
+ TLV_INDEX: () => import_axis_protocol2.TLV_INDEX,
676
+ TLV_INTENT: () => import_axis_protocol2.TLV_INTENT,
677
+ TLV_KID: () => import_axis_protocol2.TLV_KID,
678
+ TLV_LOOM_PRESENCE_ID: () => import_axis_protocol2.TLV_LOOM_PRESENCE_ID,
679
+ TLV_LOOM_THREAD_HASH: () => import_axis_protocol2.TLV_LOOM_THREAD_HASH,
680
+ TLV_LOOM_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
681
+ TLV_NODE: () => import_axis_protocol2.TLV_NODE,
682
+ TLV_NODE_CERT_HASH: () => import_axis_protocol2.TLV_NODE_CERT_HASH,
683
+ TLV_NODE_KID: () => import_axis_protocol2.TLV_NODE_KID,
684
+ TLV_NONCE: () => import_axis_protocol2.TLV_NONCE,
685
+ TLV_OFFSET: () => import_axis_protocol2.TLV_OFFSET,
686
+ TLV_OK: () => import_axis_protocol2.TLV_OK,
687
+ TLV_PID: () => import_axis_protocol2.TLV_PID,
688
+ TLV_PREV_HASH: () => import_axis_protocol2.TLV_PREV_HASH,
689
+ TLV_PROOF_REF: () => import_axis_protocol2.TLV_PROOF_REF,
690
+ TLV_PROOF_TYPE: () => import_axis_protocol2.TLV_PROOF_TYPE,
691
+ TLV_REALM: () => import_axis_protocol2.TLV_REALM,
692
+ TLV_RECEIPT_HASH: () => import_axis_protocol2.TLV_RECEIPT_HASH,
693
+ TLV_RID: () => import_axis_protocol2.TLV_RID,
694
+ TLV_SHA256_CHUNK: () => import_axis_protocol2.TLV_SHA256_CHUNK,
695
+ TLV_TRACE_ID: () => import_axis_protocol2.TLV_TRACE_ID,
696
+ TLV_TS: () => import_axis_protocol2.TLV_TS,
697
+ TLV_UPLOAD_ID: () => import_axis_protocol2.TLV_UPLOAD_ID
471
698
  });
472
- function normalizeSensorDecision(sensorDecision) {
473
- if ("action" in sensorDecision) {
474
- switch (sensorDecision.action) {
475
- case "ALLOW":
476
- return {
477
- allow: true,
478
- riskScore: 0,
479
- reasons: [],
480
- meta: sensorDecision.meta
481
- };
482
- case "DENY":
483
- return {
484
- allow: false,
485
- riskScore: 100,
486
- reasons: [sensorDecision.code, sensorDecision.reason].filter(
487
- Boolean
488
- ),
489
- meta: sensorDecision.meta,
490
- retryAfterMs: sensorDecision.retryAfterMs
491
- };
492
- case "THROTTLE":
493
- return {
494
- allow: false,
495
- riskScore: 50,
496
- reasons: ["RATE_LIMIT"],
497
- retryAfterMs: sensorDecision.retryAfterMs,
498
- meta: sensorDecision.meta
499
- };
500
- case "FLAG":
501
- return {
502
- allow: true,
503
- riskScore: sensorDecision.scoreDelta,
504
- reasons: sensorDecision.reasons,
505
- meta: sensorDecision.meta
506
- };
507
- }
699
+ var import_axis_protocol2;
700
+ var init_constants = __esm({
701
+ "src/core/constants.ts"() {
702
+ import_axis_protocol2 = require("@nextera.one/axis-protocol");
703
+ }
704
+ });
705
+
706
+ // src/engine/axis-execution-context.ts
707
+ var axis_execution_context_exports = {};
708
+ __export(axis_execution_context_exports, {
709
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
710
+ getAxisExecutionContext: () => getAxisExecutionContext,
711
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
712
+ withAxisExecutionContext: () => withAxisExecutionContext
713
+ });
714
+ function getAxisExecutionContext(frame) {
715
+ return frame?.[AXIS_EXECUTION_CONTEXT_KEY];
716
+ }
717
+ function withAxisExecutionContext(target, context) {
718
+ Object.defineProperty(target, AXIS_EXECUTION_CONTEXT_KEY, {
719
+ value: context,
720
+ writable: true,
721
+ configurable: true,
722
+ enumerable: false
723
+ });
724
+ return target;
725
+ }
726
+ function mergeAxisExecutionContext(base, override) {
727
+ if (!base && !override) {
728
+ return void 0;
508
729
  }
509
730
  return {
510
- allow: sensorDecision.allow,
511
- riskScore: sensorDecision.riskScore,
512
- reasons: sensorDecision.reasons,
513
- tags: sensorDecision.tags,
514
- meta: sensorDecision.meta,
515
- tighten: sensorDecision.tighten,
516
- retryAfterMs: sensorDecision.retryAfterMs
731
+ ...base,
732
+ ...override,
733
+ capsuleRef: {
734
+ ...base?.capsuleRef || {},
735
+ ...override?.capsuleRef || {}
736
+ }
517
737
  };
518
738
  }
519
- var Decision, SensorDecisions;
520
- var init_axis_sensor = __esm({
521
- "src/sensor/axis-sensor.ts"() {
522
- Decision = /* @__PURE__ */ ((Decision2) => {
523
- Decision2["ALLOW"] = "ALLOW";
524
- Decision2["DENY"] = "DENY";
525
- Decision2["THROTTLE"] = "THROTTLE";
526
- Decision2["FLAG"] = "FLAG";
527
- return Decision2;
528
- })(Decision || {});
529
- SensorDecisions = {
530
- allow(meta, tags) {
531
- return {
532
- decision: "ALLOW" /* ALLOW */,
533
- allow: true,
534
- riskScore: 0,
535
- reasons: [],
536
- tags,
537
- meta
538
- };
539
- },
540
- deny(code, reason, meta) {
541
- return {
542
- decision: "DENY" /* DENY */,
543
- allow: false,
544
- riskScore: 100,
545
- code,
546
- reasons: [code, reason].filter(Boolean),
547
- meta
548
- };
549
- },
550
- throttle(retryAfterMs, meta) {
551
- return {
552
- decision: "THROTTLE" /* THROTTLE */,
553
- allow: false,
554
- riskScore: 50,
555
- retryAfterMs,
556
- code: "RATE_LIMIT",
557
- reasons: ["RATE_LIMIT"],
558
- meta
559
- };
560
- },
561
- flag(scoreDelta, reasons, meta) {
562
- return {
563
- decision: "FLAG" /* FLAG */,
564
- allow: true,
565
- riskScore: scoreDelta,
566
- scoreDelta,
567
- reasons,
568
- meta
739
+ var AXIS_EXECUTION_CONTEXT_KEY;
740
+ var init_axis_execution_context = __esm({
741
+ "src/engine/axis-execution-context.ts"() {
742
+ AXIS_EXECUTION_CONTEXT_KEY = /* @__PURE__ */ Symbol.for("axis.executionContext");
743
+ }
744
+ });
745
+
746
+ // src/engine/registry/observer.registry.ts
747
+ var require_observer_registry = __commonJS({
748
+ "src/engine/registry/observer.registry.ts"(exports2) {
749
+ "use strict";
750
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
751
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
752
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
753
+ 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;
754
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
755
+ };
756
+ var ObserverRegistry_1;
757
+ Object.defineProperty(exports2, "__esModule", { value: true });
758
+ exports2.ObserverRegistry = void 0;
759
+ var common_1 = require("@nestjs/common");
760
+ var ObserverRegistry2 = ObserverRegistry_1 = class ObserverRegistry {
761
+ constructor() {
762
+ this.logger = new common_1.Logger(ObserverRegistry_1.name);
763
+ this.byName = /* @__PURE__ */ new Map();
764
+ this.byType = /* @__PURE__ */ new Map();
765
+ }
766
+ register(instance, meta = {}) {
767
+ const name = meta.name || instance.name || instance.constructor.name;
768
+ const registration = {
769
+ name,
770
+ instance,
771
+ tags: meta.tags || [],
772
+ events: meta.events,
773
+ intents: meta.intents,
774
+ handlers: meta.handlers
569
775
  };
776
+ this.byName.set(name, registration);
777
+ this.byType.set(instance.constructor, registration);
778
+ this.logger.debug(`Registered observer: ${name}`);
779
+ }
780
+ resolve(ref) {
781
+ if (typeof ref === "string") {
782
+ return this.byName.get(ref);
783
+ }
784
+ return this.byType.get(ref) || this.byName.get(ref.name);
785
+ }
786
+ list() {
787
+ return Array.from(this.byName.values()).sort((left, right) => left.name.localeCompare(right.name));
788
+ }
789
+ clear() {
790
+ this.byName.clear();
791
+ this.byType.clear();
792
+ }
793
+ };
794
+ exports2.ObserverRegistry = ObserverRegistry2;
795
+ exports2.ObserverRegistry = ObserverRegistry2 = ObserverRegistry_1 = __decorate([
796
+ (0, common_1.Injectable)()
797
+ ], ObserverRegistry2);
798
+ }
799
+ });
800
+
801
+ // src/engine/observer-dispatcher.service.ts
802
+ var require_observer_dispatcher_service = __commonJS({
803
+ "src/engine/observer-dispatcher.service.ts"(exports2) {
804
+ "use strict";
805
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
806
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
807
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
808
+ 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;
809
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
810
+ };
811
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
812
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
813
+ };
814
+ var ObserverDispatcherService_1;
815
+ var _a;
816
+ Object.defineProperty(exports2, "__esModule", { value: true });
817
+ exports2.ObserverDispatcherService = void 0;
818
+ var common_1 = require("@nestjs/common");
819
+ var observer_registry_1 = require_observer_registry();
820
+ function unique(values) {
821
+ return Array.from(new Set(values));
822
+ }
823
+ var ObserverDispatcherService2 = ObserverDispatcherService_1 = class ObserverDispatcherService {
824
+ constructor(registry) {
825
+ this.registry = registry;
826
+ this.logger = new common_1.Logger(ObserverDispatcherService_1.name);
827
+ }
828
+ async dispatch(bindings, context) {
829
+ if (!bindings || bindings.length === 0)
830
+ return;
831
+ const invoked = /* @__PURE__ */ new Set();
832
+ for (const binding of bindings) {
833
+ if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
834
+ continue;
835
+ }
836
+ for (const ref of binding.refs) {
837
+ const registration = this.registry.resolve(ref);
838
+ if (!registration) {
839
+ this.logger.warn(`Observer ${String(ref)} could not be resolved`);
840
+ continue;
841
+ }
842
+ if (invoked.has(registration.name))
843
+ continue;
844
+ if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
845
+ continue;
846
+ }
847
+ const observerContext = {
848
+ ...context,
849
+ observerTags: unique([
850
+ ...registration.tags || [],
851
+ ...binding.tags || [],
852
+ ...context.observerTags || []
853
+ ])
854
+ };
855
+ if (registration.instance.supports && !registration.instance.supports(observerContext)) {
856
+ continue;
857
+ }
858
+ try {
859
+ invoked.add(registration.name);
860
+ await registration.instance.observe(observerContext);
861
+ } catch (error) {
862
+ this.logger.warn(`Observer ${registration.name} failed during ${context.event}: ${error.message}`);
863
+ }
864
+ }
865
+ }
570
866
  }
571
867
  };
868
+ exports2.ObserverDispatcherService = ObserverDispatcherService2;
869
+ exports2.ObserverDispatcherService = ObserverDispatcherService2 = ObserverDispatcherService_1 = __decorate([
870
+ (0, common_1.Injectable)(),
871
+ __metadata("design:paramtypes", [typeof (_a = typeof observer_registry_1.ObserverRegistry !== "undefined" && observer_registry_1.ObserverRegistry) === "function" ? _a : Object])
872
+ ], ObserverDispatcherService2);
572
873
  }
573
874
  });
574
875
 
@@ -1048,6 +1349,116 @@ var init_cce_witness_observer = __esm({
1048
1349
  }
1049
1350
  });
1050
1351
 
1352
+ // src/sensor/axis-sensor.ts
1353
+ var axis_sensor_exports = {};
1354
+ __export(axis_sensor_exports, {
1355
+ Decision: () => Decision,
1356
+ SensorDecisions: () => SensorDecisions,
1357
+ normalizeSensorDecision: () => normalizeSensorDecision
1358
+ });
1359
+ function normalizeSensorDecision(sensorDecision) {
1360
+ if ("action" in sensorDecision) {
1361
+ switch (sensorDecision.action) {
1362
+ case "ALLOW":
1363
+ return {
1364
+ allow: true,
1365
+ riskScore: 0,
1366
+ reasons: [],
1367
+ meta: sensorDecision.meta
1368
+ };
1369
+ case "DENY":
1370
+ return {
1371
+ allow: false,
1372
+ riskScore: 100,
1373
+ reasons: [sensorDecision.code, sensorDecision.reason].filter(
1374
+ Boolean
1375
+ ),
1376
+ meta: sensorDecision.meta,
1377
+ retryAfterMs: sensorDecision.retryAfterMs
1378
+ };
1379
+ case "THROTTLE":
1380
+ return {
1381
+ allow: false,
1382
+ riskScore: 50,
1383
+ reasons: ["RATE_LIMIT"],
1384
+ retryAfterMs: sensorDecision.retryAfterMs,
1385
+ meta: sensorDecision.meta
1386
+ };
1387
+ case "FLAG":
1388
+ return {
1389
+ allow: true,
1390
+ riskScore: sensorDecision.scoreDelta,
1391
+ reasons: sensorDecision.reasons,
1392
+ meta: sensorDecision.meta
1393
+ };
1394
+ }
1395
+ }
1396
+ return {
1397
+ allow: sensorDecision.allow,
1398
+ riskScore: sensorDecision.riskScore,
1399
+ reasons: sensorDecision.reasons,
1400
+ tags: sensorDecision.tags,
1401
+ meta: sensorDecision.meta,
1402
+ tighten: sensorDecision.tighten,
1403
+ retryAfterMs: sensorDecision.retryAfterMs
1404
+ };
1405
+ }
1406
+ var Decision, SensorDecisions;
1407
+ var init_axis_sensor = __esm({
1408
+ "src/sensor/axis-sensor.ts"() {
1409
+ Decision = /* @__PURE__ */ ((Decision2) => {
1410
+ Decision2["ALLOW"] = "ALLOW";
1411
+ Decision2["DENY"] = "DENY";
1412
+ Decision2["THROTTLE"] = "THROTTLE";
1413
+ Decision2["FLAG"] = "FLAG";
1414
+ return Decision2;
1415
+ })(Decision || {});
1416
+ SensorDecisions = {
1417
+ allow(meta, tags) {
1418
+ return {
1419
+ decision: "ALLOW" /* ALLOW */,
1420
+ allow: true,
1421
+ riskScore: 0,
1422
+ reasons: [],
1423
+ tags,
1424
+ meta
1425
+ };
1426
+ },
1427
+ deny(code, reason, meta) {
1428
+ return {
1429
+ decision: "DENY" /* DENY */,
1430
+ allow: false,
1431
+ riskScore: 100,
1432
+ code,
1433
+ reasons: [code, reason].filter(Boolean),
1434
+ meta
1435
+ };
1436
+ },
1437
+ throttle(retryAfterMs, meta) {
1438
+ return {
1439
+ decision: "THROTTLE" /* THROTTLE */,
1440
+ allow: false,
1441
+ riskScore: 50,
1442
+ retryAfterMs,
1443
+ code: "RATE_LIMIT",
1444
+ reasons: ["RATE_LIMIT"],
1445
+ meta
1446
+ };
1447
+ },
1448
+ flag(scoreDelta, reasons, meta) {
1449
+ return {
1450
+ decision: "FLAG" /* FLAG */,
1451
+ allow: true,
1452
+ riskScore: scoreDelta,
1453
+ scoreDelta,
1454
+ reasons,
1455
+ meta
1456
+ };
1457
+ }
1458
+ };
1459
+ }
1460
+ });
1461
+
1051
1462
  // src/cce/cce-pipeline.ts
1052
1463
  var cce_pipeline_exports = {};
1053
1464
  __export(cce_pipeline_exports, {
@@ -1280,16 +1691,242 @@ var init_cce_pipeline = __esm({
1280
1691
  }
1281
1692
  });
1282
1693
 
1694
+ // src/core/axis-error.ts
1695
+ var axis_error_exports = {};
1696
+ __export(axis_error_exports, {
1697
+ AxisError: () => AxisError
1698
+ });
1699
+ var AxisError;
1700
+ var init_axis_error = __esm({
1701
+ "src/core/axis-error.ts"() {
1702
+ AxisError = class extends Error {
1703
+ constructor(code, message, httpStatus = 400, details) {
1704
+ super(message);
1705
+ this.code = code;
1706
+ this.httpStatus = httpStatus;
1707
+ this.details = details;
1708
+ this.name = "AxisError";
1709
+ }
1710
+ };
1711
+ }
1712
+ });
1713
+
1714
+ // src/security/scopes.ts
1715
+ function hasScope(scopes, required) {
1716
+ if (!Array.isArray(scopes) || scopes.length === 0) {
1717
+ return false;
1718
+ }
1719
+ if (scopes.includes(required)) {
1720
+ return true;
1721
+ }
1722
+ const [resource, id] = required.split(":");
1723
+ if (resource && id) {
1724
+ const wildcard = `${resource}:*`;
1725
+ if (scopes.includes(wildcard)) {
1726
+ return true;
1727
+ }
1728
+ }
1729
+ return false;
1730
+ }
1731
+ function parseScope(scope) {
1732
+ const parts = scope.split(":");
1733
+ if (parts.length !== 2) return null;
1734
+ return { resource: parts[0], id: parts[1] };
1735
+ }
1736
+ function canAccessResource(scopes, resourceType, resourceId) {
1737
+ const required = `${resourceType}:${resourceId}`;
1738
+ return hasScope(scopes, required);
1739
+ }
1740
+ var init_scopes = __esm({
1741
+ "src/security/scopes.ts"() {
1742
+ }
1743
+ });
1744
+
1745
+ // src/security/inline-capsule.ts
1746
+ var inline_capsule_exports = {};
1747
+ __export(inline_capsule_exports, {
1748
+ inlineCapsuleAllowsIntent: () => inlineCapsuleAllowsIntent,
1749
+ inlineCapsuleSatisfiesScopes: () => inlineCapsuleSatisfiesScopes,
1750
+ isInlineCapsuleExpired: () => isInlineCapsuleExpired,
1751
+ normalizeInlineCapsule: () => normalizeInlineCapsule,
1752
+ resolvePolicyScopes: () => resolvePolicyScopes
1753
+ });
1754
+ function normalizeInlineCapsule(input) {
1755
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
1756
+ return null;
1757
+ }
1758
+ const raw = input;
1759
+ const scopes = normalizeStringList(raw.scopes ?? raw.scope);
1760
+ return {
1761
+ id: normalizeScalar(raw.id),
1762
+ actorId: normalizeScalar(raw.actorId),
1763
+ intents: normalizeStringList(raw.intents),
1764
+ issuedAt: normalizeTimestamp(raw.issuedAt ?? raw.iat),
1765
+ expiresAt: normalizeTimestamp(raw.expiresAt ?? raw.exp),
1766
+ realm: normalizeScalar(raw.realm),
1767
+ node: normalizeScalar(raw.node),
1768
+ scopes,
1769
+ raw
1770
+ };
1771
+ }
1772
+ function inlineCapsuleAllowsIntent(capsule, intent) {
1773
+ if (!capsule.intents || capsule.intents.length === 0) {
1774
+ return false;
1775
+ }
1776
+ for (const pattern of capsule.intents) {
1777
+ if (pattern === "*" || pattern === intent) {
1778
+ return true;
1779
+ }
1780
+ if (pattern.endsWith(".*")) {
1781
+ const prefix = pattern.slice(0, -1);
1782
+ if (intent.startsWith(prefix)) {
1783
+ return true;
1784
+ }
1785
+ }
1786
+ }
1787
+ return false;
1788
+ }
1789
+ function isInlineCapsuleExpired(capsule, clockSkewMs = 3e4) {
1790
+ if (capsule.expiresAt === void 0) {
1791
+ return false;
1792
+ }
1793
+ return BigInt(Date.now()) > capsule.expiresAt + BigInt(clockSkewMs);
1794
+ }
1795
+ function resolvePolicyScopes(scopes, context) {
1796
+ return scopes.map(
1797
+ (scope) => scope.replace(/\$\{([^}]+)\}/g, (_match, expression) => {
1798
+ const resolved = resolveTemplateExpression(expression.trim(), context);
1799
+ if (resolved === void 0 || resolved === null || resolved === "") {
1800
+ throw new Error(`CAPSULE_SCOPE_TEMPLATE_UNRESOLVED:${expression}`);
1801
+ }
1802
+ return String(resolved);
1803
+ })
1804
+ );
1805
+ }
1806
+ function inlineCapsuleSatisfiesScopes(capsule, requiredScopes, mode = "all") {
1807
+ if (!capsule.scopes || capsule.scopes.length === 0) {
1808
+ return false;
1809
+ }
1810
+ if (mode === "any") {
1811
+ return requiredScopes.some((scope) => hasScope(capsule.scopes, scope));
1812
+ }
1813
+ return requiredScopes.every((scope) => hasScope(capsule.scopes, scope));
1814
+ }
1815
+ function resolveTemplateExpression(expression, context) {
1816
+ if (expression === "intent") {
1817
+ return context.intent;
1818
+ }
1819
+ if (expression === "actorId") {
1820
+ return context.actorId;
1821
+ }
1822
+ if (expression === "chainId") {
1823
+ return context.chainId;
1824
+ }
1825
+ if (expression === "stepId") {
1826
+ return context.stepId;
1827
+ }
1828
+ if (expression.startsWith("body.")) {
1829
+ return getNestedValue(context.body, expression.slice(5));
1830
+ }
1831
+ return void 0;
1832
+ }
1833
+ function getNestedValue(value, path2) {
1834
+ if (!value || typeof value !== "object") {
1835
+ return void 0;
1836
+ }
1837
+ return path2.split(".").reduce((current, segment) => {
1838
+ if (!current || typeof current !== "object") {
1839
+ return void 0;
1840
+ }
1841
+ return current[segment];
1842
+ }, value);
1843
+ }
1844
+ function normalizeScalar(value) {
1845
+ if (typeof value === "string") {
1846
+ return value;
1847
+ }
1848
+ if (value instanceof Uint8Array) {
1849
+ return Buffer.from(value).toString("hex");
1850
+ }
1851
+ return void 0;
1852
+ }
1853
+ function normalizeStringList(value) {
1854
+ if (!value) {
1855
+ return void 0;
1856
+ }
1857
+ const list = Array.isArray(value) ? value : [value];
1858
+ const normalized = list.map((entry) => typeof entry === "string" ? entry : void 0).filter((entry) => !!entry && entry.trim().length > 0);
1859
+ return normalized.length > 0 ? Array.from(new Set(normalized)) : void 0;
1860
+ }
1861
+ function normalizeTimestamp(value) {
1862
+ if (typeof value === "bigint") {
1863
+ return value;
1864
+ }
1865
+ if (typeof value === "number" && Number.isFinite(value)) {
1866
+ return BigInt(Math.trunc(value));
1867
+ }
1868
+ if (typeof value === "string" && value.trim().length > 0) {
1869
+ try {
1870
+ return BigInt(value);
1871
+ } catch {
1872
+ return void 0;
1873
+ }
1874
+ }
1875
+ return void 0;
1876
+ }
1877
+ var init_inline_capsule = __esm({
1878
+ "src/security/inline-capsule.ts"() {
1879
+ init_scopes();
1880
+ }
1881
+ });
1882
+
1283
1883
  // src/engine/intent.router.ts
1284
1884
  var require_intent_router = __commonJS({
1285
1885
  "src/engine/intent.router.ts"(exports2) {
1286
1886
  "use strict";
1887
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
1888
+ if (k2 === void 0) k2 = k;
1889
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1890
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1891
+ desc = { enumerable: true, get: function() {
1892
+ return m[k];
1893
+ } };
1894
+ }
1895
+ Object.defineProperty(o, k2, desc);
1896
+ }) : (function(o, m, k, k2) {
1897
+ if (k2 === void 0) k2 = k;
1898
+ o[k2] = m[k];
1899
+ }));
1900
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
1901
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1902
+ }) : function(o, v) {
1903
+ o["default"] = v;
1904
+ });
1287
1905
  var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
1288
1906
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1289
1907
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1290
1908
  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;
1291
1909
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1292
1910
  };
1911
+ var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
1912
+ var ownKeys = function(o) {
1913
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1914
+ var ar = [];
1915
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1916
+ return ar;
1917
+ };
1918
+ return ownKeys(o);
1919
+ };
1920
+ return function(mod) {
1921
+ if (mod && mod.__esModule) return mod;
1922
+ var result = {};
1923
+ if (mod != null) {
1924
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1925
+ }
1926
+ __setModuleDefault(result, mod);
1927
+ return result;
1928
+ };
1929
+ })();
1293
1930
  var __metadata = exports2 && exports2.__metadata || function(k, v) {
1294
1931
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1295
1932
  };
@@ -1300,28 +1937,82 @@ var require_intent_router = __commonJS({
1300
1937
  };
1301
1938
  var IntentRouter_1;
1302
1939
  var _a;
1940
+ var _b;
1303
1941
  Object.defineProperty(exports2, "__esModule", { value: true });
1304
1942
  exports2.IntentRouter = void 0;
1305
1943
  var common_1 = require("@nestjs/common");
1306
1944
  var core_1 = require("@nestjs/core");
1945
+ var axis_protocol_1 = require("@nextera.one/axis-protocol");
1946
+ var cce_pipeline_1 = (init_cce_pipeline(), __toCommonJS(cce_pipeline_exports));
1947
+ var axis_error_1 = (init_axis_error(), __toCommonJS(axis_error_exports));
1948
+ var constants_1 = (init_constants(), __toCommonJS(constants_exports));
1949
+ var capsule_policy_decorator_1 = (init_capsule_policy_decorator(), __toCommonJS(capsule_policy_decorator_exports));
1950
+ var chain_decorator_1 = (init_chain_decorator(), __toCommonJS(chain_decorator_exports));
1951
+ var dto_schema_util_1 = require_dto_schema_util();
1307
1952
  var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
1308
- var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
1309
- var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
1310
1953
  var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
1954
+ var intent_body_decorator_1 = (init_intent_body_decorator(), __toCommonJS(intent_body_decorator_exports));
1955
+ var intent_sensors_decorator_1 = (init_intent_sensors_decorator(), __toCommonJS(intent_sensors_decorator_exports));
1311
1956
  var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
1312
- var dto_schema_util_1 = require_dto_schema_util();
1957
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
1958
+ var inline_capsule_1 = (init_inline_capsule(), __toCommonJS(inline_capsule_exports));
1313
1959
  var axis_sensor_1 = (init_axis_sensor(), __toCommonJS(axis_sensor_exports));
1314
- var cce_pipeline_1 = (init_cce_pipeline(), __toCommonJS(cce_pipeline_exports));
1960
+ var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
1961
+ var observer_dispatcher_service_1 = require_observer_dispatcher_service();
1962
+ function observerRefKey(ref) {
1963
+ return typeof ref === "string" ? ref : ref.name;
1964
+ }
1965
+ function mergeObserverBindings(bindings) {
1966
+ const merged = /* @__PURE__ */ new Map();
1967
+ for (const binding of bindings) {
1968
+ for (const ref of binding.refs) {
1969
+ const key = observerRefKey(ref);
1970
+ const existing = merged.get(key);
1971
+ if (!existing) {
1972
+ merged.set(key, {
1973
+ refs: [ref],
1974
+ tags: binding.tags ? [...new Set(binding.tags)] : void 0,
1975
+ events: binding.events ? [...new Set(binding.events)] : void 0
1976
+ });
1977
+ continue;
1978
+ }
1979
+ existing.tags = Array.from(/* @__PURE__ */ new Set([...existing.tags || [], ...binding.tags || []]));
1980
+ existing.events = existing.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...existing.events, ...binding.events]));
1981
+ }
1982
+ }
1983
+ return Array.from(merged.values());
1984
+ }
1985
+ function normalizeChainConfig(decoratorConfig, intentConfig) {
1986
+ if (decoratorConfig) {
1987
+ return decoratorConfig;
1988
+ }
1989
+ if (!intentConfig) {
1990
+ return void 0;
1991
+ }
1992
+ if (intentConfig === true) {
1993
+ return { enabled: true };
1994
+ }
1995
+ return {
1996
+ enabled: true,
1997
+ ...intentConfig
1998
+ };
1999
+ }
1315
2000
  var IntentRouter2 = IntentRouter_1 = class IntentRouter {
1316
- constructor(moduleRef) {
2001
+ constructor(moduleRef, observerDispatcher) {
1317
2002
  this.moduleRef = moduleRef;
2003
+ this.observerDispatcher = observerDispatcher;
1318
2004
  this.logger = new common_1.Logger(IntentRouter_1.name);
2005
+ this.decoder = new TextDecoder();
2006
+ this.encoder = new TextEncoder();
1319
2007
  this.handlers = /* @__PURE__ */ new Map();
1320
2008
  this.intentSensors = /* @__PURE__ */ new Map();
1321
2009
  this.intentDecoders = /* @__PURE__ */ new Map();
1322
2010
  this.intentSchemas = /* @__PURE__ */ new Map();
1323
2011
  this.intentValidators = /* @__PURE__ */ new Map();
1324
2012
  this.intentKinds = /* @__PURE__ */ new Map();
2013
+ this.intentChains = /* @__PURE__ */ new Map();
2014
+ this.intentObservers = /* @__PURE__ */ new Map();
2015
+ this.intentCapsulePolicies = /* @__PURE__ */ new Map();
1325
2016
  this.cceHandlers = /* @__PURE__ */ new Map();
1326
2017
  this.ccePipelineConfig = null;
1327
2018
  }
@@ -1345,9 +2036,18 @@ var require_intent_router = __commonJS({
1345
2036
  validators: this.intentValidators.get(intent),
1346
2037
  hasSensors: this.intentSensors.has(intent),
1347
2038
  builtin: IntentRouter_1.BUILTIN_INTENTS.has(intent),
1348
- kind: this.intentKinds.get(intent)
2039
+ kind: this.intentKinds.get(intent),
2040
+ chain: this.intentChains.get(intent),
2041
+ capsulePolicy: this.intentCapsulePolicies.get(intent),
2042
+ observerCount: this.getObservers(intent).length
1349
2043
  };
1350
2044
  }
2045
+ getChainConfig(intent) {
2046
+ return this.intentChains.get(intent);
2047
+ }
2048
+ getObservers(intent) {
2049
+ return this.intentObservers.get(intent) || [];
2050
+ }
1351
2051
  register(intent, handler) {
1352
2052
  this.handlers.set(intent, handler);
1353
2053
  }
@@ -1355,7 +2055,10 @@ var require_intent_router = __commonJS({
1355
2055
  const handlerMeta = Reflect.getMetadata(handler_decorator_1.HANDLER_METADATA_KEY, instance.constructor);
1356
2056
  const prefix = handlerMeta?.intent || instance.name;
1357
2057
  const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, instance.constructor) || [];
2058
+ const routedMethods = new Set(routes.map((route) => String(route.methodName)));
1358
2059
  const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, instance.constructor) || [];
2060
+ const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, instance.constructor) || [];
2061
+ const proto = Object.getPrototypeOf(instance);
1359
2062
  for (const route of routes) {
1360
2063
  const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
1361
2064
  const fn = instance[route.methodName].bind(instance);
@@ -1364,27 +2067,36 @@ var require_intent_router = __commonJS({
1364
2067
  } else {
1365
2068
  this.register(intentName, fn);
1366
2069
  }
1367
- this.registerIntentMeta(intentName, Object.getPrototypeOf(instance), String(route.methodName), handlerSensors);
2070
+ this.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
1368
2071
  }
1369
- const proto = Object.getPrototypeOf(instance);
1370
2072
  for (const key of Object.getOwnPropertyNames(proto)) {
2073
+ if (routedMethods.has(key))
2074
+ continue;
1371
2075
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, key);
1372
2076
  if (!meta?.intent)
1373
2077
  continue;
1374
- if (!this.handlers.has(meta.intent)) {
1375
- this.register(meta.intent, instance[key].bind(instance));
2078
+ const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
2079
+ if (!this.handlers.has(intentName)) {
2080
+ this.register(intentName, instance[key].bind(instance));
1376
2081
  }
1377
- this.registerIntentMeta(meta.intent, proto, key, handlerSensors);
2082
+ this.registerIntentMeta(intentName, proto, key, handlerSensors, handlerObservers);
1378
2083
  }
1379
2084
  }
1380
2085
  async route(frame) {
1381
2086
  const start = process.hrtime();
1382
2087
  let intent = "unknown";
1383
2088
  try {
1384
- const intentBytes = frame.headers.get(3);
2089
+ const intentBytes = frame.headers.get(constants_1.TLV_INTENT);
1385
2090
  if (!intentBytes)
1386
2091
  throw new Error("Missing intent");
1387
- intent = new TextDecoder().decode(intentBytes);
2092
+ intent = this.decoder.decode(intentBytes);
2093
+ const observerBindings = this.getObservers(intent);
2094
+ await this.emitIntentObservers(observerBindings, {
2095
+ event: "intent.received",
2096
+ timestamp: Date.now(),
2097
+ intent,
2098
+ frame
2099
+ });
1388
2100
  let effect;
1389
2101
  if (intent === "system.ping" || intent === "public.ping") {
1390
2102
  this.logger.debug("PING received");
@@ -1416,25 +2128,35 @@ var require_intent_router = __commonJS({
1416
2128
  effect: "echo",
1417
2129
  body: frame.body
1418
2130
  };
2131
+ } else if (intent === "CHAIN.EXEC" || intent === "axis.chain.exec") {
2132
+ const chainRequest = this.parseChainRequestBody(frame.body);
2133
+ effect = await this.executeChainRequest(frame, chainRequest);
1419
2134
  } else if (intent === "INTENT.EXEC" || intent === "axis.intent.exec") {
1420
- try {
1421
- const bodyJSON = JSON.parse(new TextDecoder().decode(frame.body));
1422
- const innerIntent = bodyJSON.intent;
1423
- const innerArgs = bodyJSON.args || {};
1424
- if (!innerIntent) {
1425
- throw new Error("INTENT.EXEC missing inner intent");
1426
- }
1427
- this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
1428
- const innerFrame = {
1429
- ...frame,
1430
- headers: new Map(frame.headers),
1431
- body: new TextEncoder().encode(JSON.stringify(innerArgs))
1432
- };
1433
- innerFrame.headers.set(3, new TextEncoder().encode(innerIntent));
1434
- return await this.route(innerFrame);
1435
- } catch (e) {
1436
- throw new Error(`INTENT.EXEC unwrapping failed: ${e.message}`);
2135
+ const execBody = this.parseIntentExecBody(frame.body);
2136
+ const innerIntent = execBody.intent;
2137
+ const innerArgs = execBody.args || {};
2138
+ if (!innerIntent) {
2139
+ throw new Error("INTENT.EXEC missing inner intent");
2140
+ }
2141
+ this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
2142
+ const innerHeaders = new Map(frame.headers);
2143
+ innerHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(innerIntent));
2144
+ const inlineCapsule = this.toInlineCapsuleRecord(execBody.capsule);
2145
+ const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2146
+ if (capsuleId) {
2147
+ innerHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2148
+ innerHeaders.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
1437
2149
  }
2150
+ const innerFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
2151
+ ...frame,
2152
+ headers: innerHeaders,
2153
+ body: this.encodeJson(innerArgs)
2154
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
2155
+ metaIntent: "INTENT.EXEC",
2156
+ actorId: this.getActorIdFromFrame(frame),
2157
+ inlineCapsule
2158
+ }) || {});
2159
+ effect = await this.route(innerFrame);
1438
2160
  } else {
1439
2161
  const handler = this.handlers.get(intent);
1440
2162
  if (!handler) {
@@ -1453,6 +2175,7 @@ var require_intent_router = __commonJS({
1453
2175
  throw new Error(`IntentBody decode failed for ${intent}: ${decodeErr.message}`);
1454
2176
  }
1455
2177
  }
2178
+ this.enforceCapsulePolicy(intent, frame, decodedBody, this.getEffectiveCapsulePolicy(intent, frame));
1456
2179
  if (typeof handler === "function") {
1457
2180
  const resultBody = decoder ? await handler(decodedBody, frame.headers) : await handler(frame.body, frame.headers);
1458
2181
  effect = {
@@ -1475,9 +2198,24 @@ var require_intent_router = __commonJS({
1475
2198
  }
1476
2199
  }
1477
2200
  }
2201
+ await this.emitIntentObservers(observerBindings, {
2202
+ event: "intent.completed",
2203
+ timestamp: Date.now(),
2204
+ intent,
2205
+ frame,
2206
+ effect,
2207
+ metadata: effect.metadata
2208
+ });
1478
2209
  this.logIntent(intent, start, true);
1479
2210
  return effect;
1480
2211
  } catch (e) {
2212
+ await this.emitIntentObservers(this.getObservers(intent), {
2213
+ event: "intent.failed",
2214
+ timestamp: Date.now(),
2215
+ intent,
2216
+ frame,
2217
+ error: e.message
2218
+ });
1481
2219
  this.logIntent(intent, start, false, e.message);
1482
2220
  throw e;
1483
2221
  }
@@ -1491,7 +2229,7 @@ var require_intent_router = __commonJS({
1491
2229
  this.logger.warn(`${intent} failed in ${ms}ms - ${error}`);
1492
2230
  }
1493
2231
  }
1494
- registerIntentMeta(intent, proto, methodName, handlerSensors) {
2232
+ registerIntentMeta(intent, proto, methodName, handlerSensors, handlerObservers) {
1495
2233
  const decoder = Reflect.getMetadata(intent_body_decorator_1.INTENT_BODY_KEY, proto, methodName);
1496
2234
  if (decoder) {
1497
2235
  this.intentDecoders.set(intent, decoder);
@@ -1504,14 +2242,38 @@ var require_intent_router = __commonJS({
1504
2242
  if (combined.length > 0) {
1505
2243
  this.intentSensors.set(intent, combined);
1506
2244
  }
2245
+ const methodObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, proto, methodName) || [];
2246
+ const observers = mergeObserverBindings([
2247
+ ...handlerObservers || [],
2248
+ ...methodObservers
2249
+ ]);
2250
+ if (observers.length > 0) {
2251
+ this.intentObservers.set(intent, observers);
2252
+ }
2253
+ const handlerCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto.constructor);
2254
+ const methodCapsulePolicy = Reflect.getMetadata(capsule_policy_decorator_1.CAPSULE_POLICY_METADATA_KEY, proto, methodName);
2255
+ const capsulePolicy = (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(handlerCapsulePolicy, methodCapsulePolicy);
2256
+ if (capsulePolicy) {
2257
+ this.intentCapsulePolicies.set(intent, capsulePolicy);
2258
+ }
1507
2259
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
1508
2260
  if (meta) {
1509
- this.storeSchema(meta);
2261
+ this.storeSchema({ ...meta, intent });
1510
2262
  if (meta.kind) {
1511
2263
  this.intentKinds.set(intent, meta.kind);
1512
2264
  }
2265
+ const chainMeta = Reflect.getMetadata(chain_decorator_1.CHAIN_METADATA_KEY, proto, methodName);
2266
+ const chainConfig = normalizeChainConfig(chainMeta, meta.chain);
2267
+ if (chainConfig) {
2268
+ this.intentChains.set(intent, chainConfig);
2269
+ }
1513
2270
  }
1514
2271
  }
2272
+ async emitIntentObservers(bindings, context) {
2273
+ if (!this.observerDispatcher || bindings.length === 0)
2274
+ return;
2275
+ await this.observerDispatcher.dispatch(bindings, context);
2276
+ }
1515
2277
  async runIntentSensors(sensorClasses, intent, frame) {
1516
2278
  if (!this.moduleRef)
1517
2279
  return;
@@ -1540,6 +2302,226 @@ var require_intent_router = __commonJS({
1540
2302
  }
1541
2303
  }
1542
2304
  }
2305
+ getEffectiveCapsulePolicy(intent, frame) {
2306
+ const registeredPolicy = this.intentCapsulePolicies.get(intent);
2307
+ const chainConfig = this.intentChains.get(intent);
2308
+ const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
2309
+ const derivedScopes = Array.from(/* @__PURE__ */ new Set([
2310
+ ...this.toScopeList(chainConfig?.capsuleScope),
2311
+ ...this.toScopeList(executionContext?.capsuleRef?.scope),
2312
+ ...this.toScopeList(executionContext?.chainStep?.capsuleScope)
2313
+ ]));
2314
+ const requiresCapsule = chainConfig?.proofRequired || executionContext?.capsuleRef?.proofRequired || executionContext?.chainStep?.proofRequired || executionContext?.chainEnvelope?.capsule?.proofRequired || derivedScopes.length > 0;
2315
+ const derivedPolicy = requiresCapsule ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)({
2316
+ required: true,
2317
+ scopes: derivedScopes.length > 0 ? derivedScopes : void 0
2318
+ }) : void 0;
2319
+ return (0, capsule_policy_decorator_1.mergeCapsulePolicyOptions)(registeredPolicy, derivedPolicy);
2320
+ }
2321
+ enforceCapsulePolicy(intent, frame, body, policy) {
2322
+ const executionContext = (0, axis_execution_context_1.getAxisExecutionContext)(frame);
2323
+ const inlineCapsuleRecord = this.toInlineCapsuleRecord(executionContext?.inlineCapsule);
2324
+ const inlineCapsule = (0, inline_capsule_1.normalizeInlineCapsule)(inlineCapsuleRecord);
2325
+ const normalizedPolicy = policy ? (0, capsule_policy_decorator_1.normalizeCapsulePolicyOptions)(policy) : void 0;
2326
+ if (!inlineCapsule) {
2327
+ if (normalizedPolicy?.required) {
2328
+ if (normalizedPolicy.allowCapsuleRef && this.hasCapsuleReference(frame) && this.toScopeList(normalizedPolicy.scopes).length === 0 && normalizedPolicy.intentBound === false) {
2329
+ return;
2330
+ }
2331
+ 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 });
2332
+ }
2333
+ return;
2334
+ }
2335
+ if ((0, inline_capsule_1.isInlineCapsuleExpired)(inlineCapsule)) {
2336
+ throw new axis_error_1.AxisError("CAPSULE_EXPIRED", `Capsule for ${intent} is expired`, 403, { intent, capsuleId: inlineCapsule.id });
2337
+ }
2338
+ const actorId = this.getActorIdFromFrame(frame) || executionContext?.actorId;
2339
+ if (actorId && inlineCapsule.actorId && !this.identifiersMatch(actorId, inlineCapsule.actorId)) {
2340
+ throw new axis_error_1.AxisError("CAPSULE_ACTOR_MISMATCH", `Capsule actor does not match request actor for ${intent}`, 403, {
2341
+ intent,
2342
+ actorId,
2343
+ capsuleActorId: inlineCapsule.actorId
2344
+ });
2345
+ }
2346
+ const proofRef = this.getProofRefFromFrame(frame);
2347
+ if (proofRef && inlineCapsule.id && !this.identifiersMatch(proofRef, inlineCapsule.id)) {
2348
+ throw new axis_error_1.AxisError("CAPSULE_REF_MISMATCH", `Capsule reference does not match request proof for ${intent}`, 403, {
2349
+ intent,
2350
+ proofRef,
2351
+ capsuleId: inlineCapsule.id
2352
+ });
2353
+ }
2354
+ const realm = this.getHeaderValue(frame, constants_1.TLV_REALM);
2355
+ if (realm && inlineCapsule.realm && realm !== inlineCapsule.realm) {
2356
+ throw new axis_error_1.AxisError("CAPSULE_REALM_MISMATCH", `Capsule realm does not match request realm for ${intent}`, 403, { intent, realm, capsuleRealm: inlineCapsule.realm });
2357
+ }
2358
+ const node = this.getHeaderValue(frame, constants_1.TLV_NODE);
2359
+ if (node && inlineCapsule.node && node !== inlineCapsule.node) {
2360
+ throw new axis_error_1.AxisError("CAPSULE_NODE_MISMATCH", `Capsule node does not match request node for ${intent}`, 403, { intent, node, capsuleNode: inlineCapsule.node });
2361
+ }
2362
+ const shouldCheckIntent = normalizedPolicy?.intentBound ?? true;
2363
+ if (shouldCheckIntent && !(0, inline_capsule_1.inlineCapsuleAllowsIntent)(inlineCapsule, intent)) {
2364
+ throw new axis_error_1.AxisError("CAPSULE_DENIED", `Capsule does not authorize ${intent}`, 403, {
2365
+ intent,
2366
+ capsuleId: inlineCapsule.id,
2367
+ allowedIntents: inlineCapsule.intents
2368
+ });
2369
+ }
2370
+ const requiredScopes = this.toScopeList(normalizedPolicy?.scopes);
2371
+ if (requiredScopes.length === 0) {
2372
+ return;
2373
+ }
2374
+ let resolvedScopes;
2375
+ try {
2376
+ resolvedScopes = (0, inline_capsule_1.resolvePolicyScopes)(requiredScopes, {
2377
+ body,
2378
+ intent,
2379
+ actorId,
2380
+ chainId: executionContext?.chainEnvelope?.chainId,
2381
+ stepId: executionContext?.chainStep?.stepId
2382
+ });
2383
+ } catch (error) {
2384
+ this.logger.error(`Scope template error for ${intent}: ${error.message}`);
2385
+ throw new axis_error_1.AxisError("CAPSULE_SCOPE_TEMPLATE_UNRESOLVED", "Scope policy validation failed", 400, { intent });
2386
+ }
2387
+ if (!(0, inline_capsule_1.inlineCapsuleSatisfiesScopes)(inlineCapsule, resolvedScopes, normalizedPolicy?.scopeMode ?? "all")) {
2388
+ throw new axis_error_1.AxisError("SCOPE_MISMATCH", `Capsule scopes do not satisfy ${intent}`, 403, {
2389
+ intent,
2390
+ requiredScopes: resolvedScopes,
2391
+ availableScopes: inlineCapsule.scopes || []
2392
+ });
2393
+ }
2394
+ }
2395
+ async executeChainRequest(frame, request) {
2396
+ const { AxisChainExecutor: AxisChainExecutor2 } = await Promise.resolve().then(() => __importStar(require_axis_chain_executor()));
2397
+ const headerActorId = this.getActorIdFromFrame(frame);
2398
+ if (request.actorId && headerActorId && !this.identifiersMatch(request.actorId, headerActorId)) {
2399
+ throw new axis_error_1.AxisError("ACTOR_MISMATCH", "CHAIN.EXEC actorId conflicts with authenticated frame identity", 403);
2400
+ }
2401
+ const actorId = headerActorId || request.actorId;
2402
+ const inlineCapsule = this.toInlineCapsuleRecord(request.capsule);
2403
+ const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2404
+ const headers = new Map(frame.headers);
2405
+ if (capsuleId) {
2406
+ headers.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2407
+ headers.set(constants_1.TLV_PROOF_REF, this.encoder.encode(capsuleId));
2408
+ }
2409
+ const baseFrame = (0, axis_execution_context_1.withAxisExecutionContext)({
2410
+ ...frame,
2411
+ headers
2412
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)((0, axis_execution_context_1.getAxisExecutionContext)(frame), {
2413
+ metaIntent: "CHAIN.EXEC",
2414
+ actorId,
2415
+ inlineCapsule,
2416
+ capsuleRef: request.envelope.capsule,
2417
+ chainEnvelope: request.envelope
2418
+ }) || {});
2419
+ const executor = new AxisChainExecutor2(this, this.observerDispatcher);
2420
+ const result = await executor.execute(request.envelope, {
2421
+ actorId,
2422
+ baseFrame
2423
+ });
2424
+ return {
2425
+ ok: result.status !== "FAILED",
2426
+ effect: "chain.complete",
2427
+ body: this.encodeJson(result),
2428
+ metadata: {
2429
+ chainId: result.chainId,
2430
+ status: result.status
2431
+ }
2432
+ };
2433
+ }
2434
+ parseIntentExecBody(bytes2) {
2435
+ try {
2436
+ return JSON.parse(this.decoder.decode(bytes2));
2437
+ } catch (error) {
2438
+ throw new Error(`INTENT.EXEC unwrapping failed: ${error.message}`);
2439
+ }
2440
+ }
2441
+ parseChainRequestBody(bytes2) {
2442
+ let jsonError;
2443
+ try {
2444
+ const parsed = JSON.parse(this.decoder.decode(bytes2));
2445
+ if (this.isChainRequestLike(parsed)) {
2446
+ return {
2447
+ envelope: parsed.envelope,
2448
+ capsule: this.toInlineCapsuleRecord(parsed.capsule),
2449
+ actorId: typeof parsed.actorId === "string" ? parsed.actorId : void 0
2450
+ };
2451
+ }
2452
+ if (this.isChainEnvelopeLike(parsed)) {
2453
+ return { envelope: parsed };
2454
+ }
2455
+ } catch (error) {
2456
+ jsonError = error;
2457
+ }
2458
+ try {
2459
+ const decoded = (0, axis_protocol_1.decodeChainRequest)(bytes2);
2460
+ return {
2461
+ envelope: decoded.envelope,
2462
+ capsule: this.toInlineCapsuleRecord(decoded.capsule),
2463
+ actorId: decoded.actorId
2464
+ };
2465
+ } catch (requestError) {
2466
+ try {
2467
+ return {
2468
+ envelope: (0, axis_protocol_1.decodeChainEnvelope)(bytes2)
2469
+ };
2470
+ } catch (envelopeError) {
2471
+ const reason = [jsonError?.message, requestError.message, envelopeError.message].filter(Boolean).join(" | ");
2472
+ throw new Error(`CHAIN.EXEC decode failed: ${reason}`);
2473
+ }
2474
+ }
2475
+ }
2476
+ isChainRequestLike(value) {
2477
+ return !!value && typeof value === "object" && "envelope" in value && this.isChainEnvelopeLike(value.envelope);
2478
+ }
2479
+ isChainEnvelopeLike(value) {
2480
+ return !!value && typeof value === "object" && typeof value.chainId === "string" && Array.isArray(value.steps);
2481
+ }
2482
+ encodeJson(value) {
2483
+ return this.encoder.encode(JSON.stringify(value));
2484
+ }
2485
+ getActorIdFromFrame(frame) {
2486
+ return this.getHeaderValue(frame, constants_1.TLV_ACTOR_ID);
2487
+ }
2488
+ getProofRefFromFrame(frame) {
2489
+ return this.getHeaderValue(frame, constants_1.TLV_PROOF_REF) || this.getHeaderValue(frame, constants_1.TLV_CAPSULE);
2490
+ }
2491
+ hasCapsuleReference(frame) {
2492
+ return !!this.getProofRefFromFrame(frame);
2493
+ }
2494
+ getHeaderValue(frame, tag) {
2495
+ const value = frame.headers.get(tag);
2496
+ if (!value || value.length === 0) {
2497
+ return void 0;
2498
+ }
2499
+ const decoded = this.decoder.decode(value);
2500
+ if (/^[\x20-\x7e]+$/.test(decoded)) {
2501
+ return decoded;
2502
+ }
2503
+ return Buffer.from(value).toString("hex");
2504
+ }
2505
+ identifiersMatch(left, right) {
2506
+ const normalize2 = (value) => /^[0-9a-f]+$/i.test(value) ? value.toLowerCase() : value;
2507
+ return normalize2(left) === normalize2(right);
2508
+ }
2509
+ extractInlineCapsuleId(capsule) {
2510
+ const id = capsule?.id;
2511
+ return typeof id === "string" && id.length > 0 ? id : void 0;
2512
+ }
2513
+ toInlineCapsuleRecord(value) {
2514
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
2515
+ return void 0;
2516
+ }
2517
+ return value;
2518
+ }
2519
+ toScopeList(value) {
2520
+ if (!value) {
2521
+ return [];
2522
+ }
2523
+ return Array.isArray(value) ? value : [value];
2524
+ }
1543
2525
  configureCce(config) {
1544
2526
  this.ccePipelineConfig = config;
1545
2527
  this.logger.log("CCE pipeline configured");
@@ -1622,17 +2604,454 @@ var require_intent_router = __commonJS({
1622
2604
  "public.ping",
1623
2605
  "system.time",
1624
2606
  "system.echo",
2607
+ "CHAIN.EXEC",
2608
+ "axis.chain.exec",
1625
2609
  "INTENT.EXEC",
1626
2610
  "axis.intent.exec"
1627
2611
  ]);
1628
2612
  exports2.IntentRouter = IntentRouter2 = IntentRouter_1 = __decorate([
1629
2613
  (0, common_1.Injectable)(),
1630
2614
  __param(0, (0, common_1.Optional)()),
1631
- __metadata("design:paramtypes", [typeof (_a = typeof core_1.ModuleRef !== "undefined" && core_1.ModuleRef) === "function" ? _a : Object])
2615
+ __param(1, (0, common_1.Optional)()),
2616
+ __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])
1632
2617
  ], IntentRouter2);
1633
2618
  }
1634
2619
  });
1635
2620
 
2621
+ // src/engine/axis-chain.executor.ts
2622
+ var require_axis_chain_executor = __commonJS({
2623
+ "src/engine/axis-chain.executor.ts"(exports2) {
2624
+ "use strict";
2625
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
2626
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2627
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2628
+ 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;
2629
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2630
+ };
2631
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
2632
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2633
+ };
2634
+ var __param = exports2 && exports2.__param || function(paramIndex, decorator) {
2635
+ return function(target, key) {
2636
+ decorator(target, key, paramIndex);
2637
+ };
2638
+ };
2639
+ var AxisChainExecutor_1;
2640
+ var _a;
2641
+ var _b;
2642
+ Object.defineProperty(exports2, "__esModule", { value: true });
2643
+ exports2.AxisChainExecutor = void 0;
2644
+ var crypto_1 = require("crypto");
2645
+ var common_1 = require("@nestjs/common");
2646
+ var constants_1 = (init_constants(), __toCommonJS(constants_exports));
2647
+ var axis_execution_context_1 = (init_axis_execution_context(), __toCommonJS(axis_execution_context_exports));
2648
+ var observer_dispatcher_service_1 = require_observer_dispatcher_service();
2649
+ var intent_router_1 = require_intent_router();
2650
+ var AxisChainExecutor2 = AxisChainExecutor_1 = class AxisChainExecutor {
2651
+ constructor(router, observerDispatcher) {
2652
+ this.router = router;
2653
+ this.observerDispatcher = observerDispatcher;
2654
+ this.logger = new common_1.Logger(AxisChainExecutor_1.name);
2655
+ this.encoder = new TextEncoder();
2656
+ this.decoder = new TextDecoder();
2657
+ }
2658
+ async execute(envelope, options = {}) {
2659
+ this.validateEnvelope(envelope);
2660
+ const startedAt = Date.now();
2661
+ const results = /* @__PURE__ */ new Map();
2662
+ const bindings = this.collectChainBindings(envelope);
2663
+ await this.dispatch(bindings, {
2664
+ event: "chain.received",
2665
+ timestamp: startedAt,
2666
+ chainId: envelope.chainId,
2667
+ envelope,
2668
+ observerTags: envelope.observerTags,
2669
+ capsule: envelope.capsule,
2670
+ keyExchange: envelope.keyExchange
2671
+ });
2672
+ await this.dispatch(bindings, {
2673
+ event: "chain.admitted",
2674
+ timestamp: Date.now(),
2675
+ chainId: envelope.chainId,
2676
+ envelope,
2677
+ observerTags: envelope.observerTags,
2678
+ capsule: envelope.capsule,
2679
+ keyExchange: envelope.keyExchange
2680
+ });
2681
+ const stepsById = new Map(envelope.steps.map((step) => [step.stepId, step]));
2682
+ const pending = new Set(stepsById.keys());
2683
+ while (pending.size > 0) {
2684
+ const ready = Array.from(pending).map((stepId) => stepsById.get(stepId)).filter((step) => this.canRun(step, results));
2685
+ if (ready.length === 0) {
2686
+ this.markUnresolvedSteps(pending, stepsById, results, "BLOCKED", "UNRESOLVED_DEPENDENCIES");
2687
+ break;
2688
+ }
2689
+ if (envelope.mode === "parallel") {
2690
+ const waveResults = await Promise.all(ready.map((step) => this.executeStep(step, envelope, results, options)));
2691
+ for (const result of waveResults) {
2692
+ results.set(result.stepId, result);
2693
+ pending.delete(result.stepId);
2694
+ }
2695
+ } else {
2696
+ for (const step of ready) {
2697
+ const result = await this.executeStep(step, envelope, results, options);
2698
+ results.set(result.stepId, result);
2699
+ pending.delete(result.stepId);
2700
+ if (result.status === "FAILED" && (envelope.mode === "strict" || envelope.mode === "atomic")) {
2701
+ this.markUnresolvedSteps(pending, stepsById, results, "SKIPPED", "CHAIN_HALTED");
2702
+ pending.clear();
2703
+ break;
2704
+ }
2705
+ }
2706
+ }
2707
+ this.blockStepsWithFailedDependencies(pending, stepsById, results);
2708
+ }
2709
+ const finishedAt = Date.now();
2710
+ const orderedResults = envelope.steps.map((step) => results.get(step.stepId));
2711
+ const summary = this.buildSummary(envelope.mode, orderedResults, startedAt, finishedAt, envelope.chainId);
2712
+ await this.dispatch(bindings, {
2713
+ event: summary.status === "SUCCEEDED" ? "chain.completed" : summary.status === "PARTIAL" ? "chain.partial" : "chain.failed",
2714
+ timestamp: finishedAt,
2715
+ chainId: envelope.chainId,
2716
+ envelope,
2717
+ result: summary,
2718
+ observerTags: envelope.observerTags,
2719
+ capsule: envelope.capsule,
2720
+ keyExchange: envelope.keyExchange
2721
+ });
2722
+ return summary;
2723
+ }
2724
+ async executeStep(step, envelope, results, options) {
2725
+ const stepBindings = this.router.getObservers(step.intent);
2726
+ const startedAt = Date.now();
2727
+ const input = this.resolveStepInput(step.input, results);
2728
+ await this.dispatch(stepBindings, {
2729
+ event: "step.started",
2730
+ timestamp: startedAt,
2731
+ chainId: envelope.chainId,
2732
+ stepId: step.stepId,
2733
+ intent: step.intent,
2734
+ envelope,
2735
+ step,
2736
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
2737
+ capsule: step.capsuleScope ? {
2738
+ ...envelope.capsule,
2739
+ scope: step.capsuleScope
2740
+ } : envelope.capsule,
2741
+ keyExchange: step.keyExchange || envelope.keyExchange
2742
+ });
2743
+ try {
2744
+ const frame = this.buildFrame(step, envelope, input, options);
2745
+ const effect = await this.router.route(frame);
2746
+ const finishedAt = Date.now();
2747
+ const output = this.decodeOutput(effect.body);
2748
+ const proofHash = this.computeProofHash(envelope.chainId, step.stepId, effect, output);
2749
+ const result = {
2750
+ stepId: step.stepId,
2751
+ intent: step.intent,
2752
+ status: "SUCCEEDED",
2753
+ effect: effect.effect,
2754
+ output,
2755
+ dependsOn: step.dependsOn,
2756
+ startedAt,
2757
+ finishedAt,
2758
+ proofHash,
2759
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []],
2760
+ metadata: effect.metadata
2761
+ };
2762
+ await this.dispatch(stepBindings, {
2763
+ event: "handler.completed",
2764
+ timestamp: finishedAt,
2765
+ chainId: envelope.chainId,
2766
+ stepId: step.stepId,
2767
+ intent: step.intent,
2768
+ effect,
2769
+ envelope,
2770
+ step,
2771
+ result,
2772
+ observerTags: result.observerTags,
2773
+ capsule: envelope.capsule,
2774
+ keyExchange: step.keyExchange || envelope.keyExchange
2775
+ });
2776
+ await this.dispatch(stepBindings, {
2777
+ event: "proof.recorded",
2778
+ timestamp: finishedAt,
2779
+ chainId: envelope.chainId,
2780
+ stepId: step.stepId,
2781
+ intent: step.intent,
2782
+ envelope,
2783
+ step,
2784
+ result,
2785
+ observerTags: result.observerTags,
2786
+ capsule: envelope.capsule,
2787
+ keyExchange: step.keyExchange || envelope.keyExchange,
2788
+ metadata: { proofHash }
2789
+ });
2790
+ await this.dispatch(stepBindings, {
2791
+ event: "step.completed",
2792
+ timestamp: finishedAt,
2793
+ chainId: envelope.chainId,
2794
+ stepId: step.stepId,
2795
+ intent: step.intent,
2796
+ effect,
2797
+ envelope,
2798
+ step,
2799
+ result,
2800
+ observerTags: result.observerTags,
2801
+ capsule: envelope.capsule,
2802
+ keyExchange: step.keyExchange || envelope.keyExchange
2803
+ });
2804
+ return result;
2805
+ } catch (error) {
2806
+ const finishedAt = Date.now();
2807
+ const result = {
2808
+ stepId: step.stepId,
2809
+ intent: step.intent,
2810
+ status: "FAILED",
2811
+ error: error.message,
2812
+ dependsOn: step.dependsOn,
2813
+ startedAt,
2814
+ finishedAt,
2815
+ observerTags: [...envelope.observerTags || [], ...step.observerTags || []]
2816
+ };
2817
+ this.logger.warn(`Chain ${envelope.chainId} step ${step.stepId} failed: ${error.message}`);
2818
+ await this.dispatch(stepBindings, {
2819
+ event: "step.failed",
2820
+ timestamp: finishedAt,
2821
+ chainId: envelope.chainId,
2822
+ stepId: step.stepId,
2823
+ intent: step.intent,
2824
+ error: error.message,
2825
+ envelope,
2826
+ step,
2827
+ result,
2828
+ observerTags: result.observerTags,
2829
+ capsule: envelope.capsule,
2830
+ keyExchange: step.keyExchange || envelope.keyExchange
2831
+ });
2832
+ return result;
2833
+ }
2834
+ }
2835
+ buildFrame(step, envelope, input, options) {
2836
+ const baseContext = (0, axis_execution_context_1.getAxisExecutionContext)(options.baseFrame);
2837
+ const baseHeaders = new Map(options.baseFrame?.headers || []);
2838
+ baseHeaders.set(constants_1.TLV_INTENT, this.encoder.encode(step.intent));
2839
+ baseHeaders.set(constants_1.TLV_TRACE_ID, this.encoder.encode(envelope.chainId));
2840
+ const capsuleId = envelope.capsule?.capsuleId;
2841
+ if (capsuleId) {
2842
+ baseHeaders.set(constants_1.TLV_CAPSULE, this.encoder.encode(capsuleId));
2843
+ }
2844
+ if (options.actorId) {
2845
+ baseHeaders.set(constants_1.TLV_ACTOR_ID, this.encoder.encode(options.actorId));
2846
+ }
2847
+ return (0, axis_execution_context_1.withAxisExecutionContext)({
2848
+ flags: (options.baseFrame?.flags || 0) | constants_1.FLAG_CHAIN_REQ,
2849
+ headers: baseHeaders,
2850
+ body: this.serializeInput(input),
2851
+ sig: options.baseFrame?.sig || new Uint8Array(0)
2852
+ }, (0, axis_execution_context_1.mergeAxisExecutionContext)(baseContext, {
2853
+ metaIntent: "CHAIN.EXEC",
2854
+ actorId: options.actorId || baseContext?.actorId,
2855
+ capsuleRef: step.capsuleScope ? {
2856
+ ...envelope.capsule || {},
2857
+ scope: step.capsuleScope
2858
+ } : envelope.capsule,
2859
+ chainEnvelope: envelope,
2860
+ chainStep: step
2861
+ }) || {});
2862
+ }
2863
+ validateEnvelope(envelope) {
2864
+ if (!envelope.chainId) {
2865
+ throw new Error("CHAIN_ID_REQUIRED");
2866
+ }
2867
+ if (!envelope.steps || envelope.steps.length === 0) {
2868
+ throw new Error("CHAIN_STEPS_REQUIRED");
2869
+ }
2870
+ const seen = /* @__PURE__ */ new Set();
2871
+ for (const step of envelope.steps) {
2872
+ if (!step.stepId) {
2873
+ throw new Error("CHAIN_STEP_ID_REQUIRED");
2874
+ }
2875
+ if (!step.intent) {
2876
+ throw new Error(`CHAIN_STEP_INTENT_REQUIRED:${step.stepId}`);
2877
+ }
2878
+ if (seen.has(step.stepId)) {
2879
+ throw new Error(`CHAIN_STEP_DUPLICATE:${step.stepId}`);
2880
+ }
2881
+ seen.add(step.stepId);
2882
+ }
2883
+ for (const step of envelope.steps) {
2884
+ for (const dependency of step.dependsOn || []) {
2885
+ if (!seen.has(dependency)) {
2886
+ throw new Error(`CHAIN_STEP_DEPENDENCY_UNKNOWN:${step.stepId}:${dependency}`);
2887
+ }
2888
+ }
2889
+ }
2890
+ }
2891
+ canRun(step, results) {
2892
+ return (step.dependsOn || []).every((dependency) => results.has(dependency));
2893
+ }
2894
+ blockStepsWithFailedDependencies(pending, stepsById, results) {
2895
+ for (const stepId of Array.from(pending)) {
2896
+ const step = stepsById.get(stepId);
2897
+ if (!step || !step.dependsOn || step.dependsOn.length === 0)
2898
+ continue;
2899
+ const dependencyResults = step.dependsOn.map((dependency) => results.get(dependency)).filter(Boolean);
2900
+ if (dependencyResults.length !== step.dependsOn.length)
2901
+ continue;
2902
+ const hasFailure = dependencyResults.some((dependency) => dependency.status !== "SUCCEEDED");
2903
+ if (!hasFailure)
2904
+ continue;
2905
+ results.set(step.stepId, {
2906
+ stepId: step.stepId,
2907
+ intent: step.intent,
2908
+ status: "BLOCKED",
2909
+ error: "DEPENDENCY_FAILED",
2910
+ dependsOn: step.dependsOn,
2911
+ startedAt: Date.now(),
2912
+ finishedAt: Date.now(),
2913
+ observerTags: step.observerTags
2914
+ });
2915
+ pending.delete(step.stepId);
2916
+ }
2917
+ }
2918
+ markUnresolvedSteps(pending, stepsById, results, status, error) {
2919
+ for (const stepId of pending) {
2920
+ const step = stepsById.get(stepId);
2921
+ if (!step)
2922
+ continue;
2923
+ results.set(stepId, {
2924
+ stepId,
2925
+ intent: step.intent,
2926
+ status,
2927
+ error,
2928
+ dependsOn: step.dependsOn,
2929
+ startedAt: Date.now(),
2930
+ finishedAt: Date.now(),
2931
+ observerTags: step.observerTags
2932
+ });
2933
+ }
2934
+ }
2935
+ buildSummary(mode, results, startedAt, finishedAt, chainId) {
2936
+ const completedSteps = results.filter((result) => result.status === "SUCCEEDED").length;
2937
+ const failedSteps = results.filter((result) => result.status === "FAILED").length;
2938
+ const blockedSteps = results.filter((result) => result.status === "BLOCKED").length;
2939
+ const skippedSteps = results.filter((result) => result.status === "SKIPPED").length;
2940
+ let status = "SUCCEEDED";
2941
+ if (failedSteps > 0 || blockedSteps > 0 || skippedSteps > 0) {
2942
+ status = mode === "best_effort" || mode === "parallel" ? completedSteps > 0 ? "PARTIAL" : "FAILED" : "FAILED";
2943
+ }
2944
+ return {
2945
+ chainId,
2946
+ mode,
2947
+ status,
2948
+ completedSteps,
2949
+ failedSteps,
2950
+ blockedSteps,
2951
+ skippedSteps,
2952
+ startedAt,
2953
+ finishedAt,
2954
+ results,
2955
+ rollback: mode === "atomic" ? {
2956
+ supported: false,
2957
+ attempted: false,
2958
+ reason: "AXIS handlers do not expose rollback semantics yet"
2959
+ } : void 0
2960
+ };
2961
+ }
2962
+ resolveStepInput(value, results) {
2963
+ if (typeof value === "string") {
2964
+ if (!value.startsWith("$"))
2965
+ return value;
2966
+ return this.lookupReference(value.slice(1), results);
2967
+ }
2968
+ if (Array.isArray(value)) {
2969
+ return value.map((entry) => this.resolveStepInput(entry, results));
2970
+ }
2971
+ if (value && typeof value === "object") {
2972
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
2973
+ key,
2974
+ this.resolveStepInput(entry, results)
2975
+ ]));
2976
+ }
2977
+ return value;
2978
+ }
2979
+ lookupReference(path2, results) {
2980
+ const [stepId, ...segments] = path2.split(".");
2981
+ const result = results.get(stepId);
2982
+ if (!result)
2983
+ return void 0;
2984
+ let current = result;
2985
+ for (const segment of segments) {
2986
+ if (current === void 0 || current === null)
2987
+ return void 0;
2988
+ if (typeof current !== "object")
2989
+ return void 0;
2990
+ current = current[segment];
2991
+ }
2992
+ return current;
2993
+ }
2994
+ serializeInput(input) {
2995
+ if (input instanceof Uint8Array)
2996
+ return input;
2997
+ if (typeof input === "string")
2998
+ return this.encoder.encode(input);
2999
+ if (input === void 0)
3000
+ return new Uint8Array(0);
3001
+ return this.encoder.encode(JSON.stringify(input));
3002
+ }
3003
+ decodeOutput(body) {
3004
+ if (!body || body.length === 0)
3005
+ return void 0;
3006
+ try {
3007
+ const text = this.decoder.decode(body);
3008
+ try {
3009
+ return JSON.parse(text);
3010
+ } catch {
3011
+ return /^[\x20-\x7E\s]+$/.test(text) ? text : body;
3012
+ }
3013
+ } catch {
3014
+ return body;
3015
+ }
3016
+ }
3017
+ computeProofHash(chainId, stepId, effect, output) {
3018
+ const hash = (0, crypto_1.createHash)("sha256");
3019
+ hash.update(chainId);
3020
+ hash.update(":");
3021
+ hash.update(stepId);
3022
+ hash.update(":");
3023
+ hash.update(effect.effect);
3024
+ hash.update(":");
3025
+ hash.update(JSON.stringify(output ?? null));
3026
+ return hash.digest("hex");
3027
+ }
3028
+ collectChainBindings(envelope) {
3029
+ const uniqueBindings = /* @__PURE__ */ new Map();
3030
+ for (const step of envelope.steps) {
3031
+ for (const binding of this.router.getObservers(step.intent)) {
3032
+ const key = binding.refs.map((ref) => String(ref)).sort().join("|");
3033
+ if (!uniqueBindings.has(key)) {
3034
+ uniqueBindings.set(key, binding);
3035
+ }
3036
+ }
3037
+ }
3038
+ return Array.from(uniqueBindings.values());
3039
+ }
3040
+ async dispatch(bindings, context) {
3041
+ if (!this.observerDispatcher)
3042
+ return;
3043
+ await this.observerDispatcher.dispatch(bindings, context);
3044
+ }
3045
+ };
3046
+ exports2.AxisChainExecutor = AxisChainExecutor2;
3047
+ exports2.AxisChainExecutor = AxisChainExecutor2 = AxisChainExecutor_1 = __decorate([
3048
+ (0, common_1.Injectable)(),
3049
+ __param(1, (0, common_1.Optional)()),
3050
+ __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])
3051
+ ], AxisChainExecutor2);
3052
+ }
3053
+ });
3054
+
1636
3055
  // src/engine/sensor-bands.ts
1637
3056
  var sensor_bands_exports = {};
1638
3057
  __export(sensor_bands_exports, {
@@ -1833,79 +3252,6 @@ var init_observation_hash = __esm({
1833
3252
  }
1834
3253
  });
1835
3254
 
1836
- // src/core/constants.ts
1837
- var constants_exports = {};
1838
- __export(constants_exports, {
1839
- AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
1840
- AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
1841
- BodyProfile: () => import_axis_protocol2.BodyProfile,
1842
- ERR_BAD_SIGNATURE: () => import_axis_protocol2.ERR_BAD_SIGNATURE,
1843
- ERR_CONTRACT_VIOLATION: () => import_axis_protocol2.ERR_CONTRACT_VIOLATION,
1844
- ERR_INVALID_PACKET: () => import_axis_protocol2.ERR_INVALID_PACKET,
1845
- ERR_REPLAY_DETECTED: () => import_axis_protocol2.ERR_REPLAY_DETECTED,
1846
- FLAG_BODY_TLV: () => import_axis_protocol2.FLAG_BODY_TLV,
1847
- FLAG_CHAIN_REQ: () => import_axis_protocol2.FLAG_CHAIN_REQ,
1848
- FLAG_HAS_WITNESS: () => import_axis_protocol2.FLAG_HAS_WITNESS,
1849
- MAX_BODY_LEN: () => import_axis_protocol2.MAX_BODY_LEN,
1850
- MAX_FRAME_LEN: () => import_axis_protocol2.MAX_FRAME_LEN,
1851
- MAX_HDR_LEN: () => import_axis_protocol2.MAX_HDR_LEN,
1852
- MAX_SIG_LEN: () => import_axis_protocol2.MAX_SIG_LEN,
1853
- NCERT_ALG: () => import_axis_protocol2.NCERT_ALG,
1854
- NCERT_EXP: () => import_axis_protocol2.NCERT_EXP,
1855
- NCERT_ISSUER_KID: () => import_axis_protocol2.NCERT_ISSUER_KID,
1856
- NCERT_KID: () => import_axis_protocol2.NCERT_KID,
1857
- NCERT_NBF: () => import_axis_protocol2.NCERT_NBF,
1858
- NCERT_NODE_ID: () => import_axis_protocol2.NCERT_NODE_ID,
1859
- NCERT_PAYLOAD: () => import_axis_protocol2.NCERT_PAYLOAD,
1860
- NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
1861
- NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
1862
- NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
1863
- PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
1864
- PROOF_JWT: () => import_axis_protocol2.PROOF_JWT,
1865
- PROOF_LOOM: () => import_axis_protocol2.PROOF_LOOM,
1866
- PROOF_MTLS: () => import_axis_protocol2.PROOF_MTLS,
1867
- PROOF_NONE: () => import_axis_protocol2.PROOF_NONE,
1868
- PROOF_WITNESS: () => import_axis_protocol2.PROOF_WITNESS,
1869
- ProofType: () => import_axis_protocol2.ProofType,
1870
- TLV_ACTOR_ID: () => import_axis_protocol2.TLV_ACTOR_ID,
1871
- TLV_AUD: () => import_axis_protocol2.TLV_AUD,
1872
- TLV_BODY_ARR: () => import_axis_protocol2.TLV_BODY_ARR,
1873
- TLV_BODY_OBJ: () => import_axis_protocol2.TLV_BODY_OBJ,
1874
- TLV_CAPSULE: () => import_axis_protocol2.TLV_CAPSULE,
1875
- TLV_EFFECT: () => import_axis_protocol2.TLV_EFFECT,
1876
- TLV_ERROR_CODE: () => import_axis_protocol2.TLV_ERROR_CODE,
1877
- TLV_ERROR_MSG: () => import_axis_protocol2.TLV_ERROR_MSG,
1878
- TLV_INDEX: () => import_axis_protocol2.TLV_INDEX,
1879
- TLV_INTENT: () => import_axis_protocol2.TLV_INTENT,
1880
- TLV_KID: () => import_axis_protocol2.TLV_KID,
1881
- TLV_LOOM_PRESENCE_ID: () => import_axis_protocol2.TLV_LOOM_PRESENCE_ID,
1882
- TLV_LOOM_THREAD_HASH: () => import_axis_protocol2.TLV_LOOM_THREAD_HASH,
1883
- TLV_LOOM_WRIT: () => import_axis_protocol2.TLV_LOOM_WRIT,
1884
- TLV_NODE: () => import_axis_protocol2.TLV_NODE,
1885
- TLV_NODE_CERT_HASH: () => import_axis_protocol2.TLV_NODE_CERT_HASH,
1886
- TLV_NODE_KID: () => import_axis_protocol2.TLV_NODE_KID,
1887
- TLV_NONCE: () => import_axis_protocol2.TLV_NONCE,
1888
- TLV_OFFSET: () => import_axis_protocol2.TLV_OFFSET,
1889
- TLV_OK: () => import_axis_protocol2.TLV_OK,
1890
- TLV_PID: () => import_axis_protocol2.TLV_PID,
1891
- TLV_PREV_HASH: () => import_axis_protocol2.TLV_PREV_HASH,
1892
- TLV_PROOF_REF: () => import_axis_protocol2.TLV_PROOF_REF,
1893
- TLV_PROOF_TYPE: () => import_axis_protocol2.TLV_PROOF_TYPE,
1894
- TLV_REALM: () => import_axis_protocol2.TLV_REALM,
1895
- TLV_RECEIPT_HASH: () => import_axis_protocol2.TLV_RECEIPT_HASH,
1896
- TLV_RID: () => import_axis_protocol2.TLV_RID,
1897
- TLV_SHA256_CHUNK: () => import_axis_protocol2.TLV_SHA256_CHUNK,
1898
- TLV_TRACE_ID: () => import_axis_protocol2.TLV_TRACE_ID,
1899
- TLV_TS: () => import_axis_protocol2.TLV_TS,
1900
- TLV_UPLOAD_ID: () => import_axis_protocol2.TLV_UPLOAD_ID
1901
- });
1902
- var import_axis_protocol2;
1903
- var init_constants = __esm({
1904
- "src/core/constants.ts"() {
1905
- import_axis_protocol2 = require("@nextera.one/axis-protocol");
1906
- }
1907
- });
1908
-
1909
3255
  // src/engine/observation/response-observer.ts
1910
3256
  function verifyResponse(ctx, response) {
1911
3257
  if (!response.effect || typeof response.effect !== "string") {
@@ -3427,37 +4773,6 @@ var init_packet = __esm({
3427
4773
  }
3428
4774
  });
3429
4775
 
3430
- // src/security/scopes.ts
3431
- function hasScope(scopes, required) {
3432
- if (!Array.isArray(scopes) || scopes.length === 0) {
3433
- return false;
3434
- }
3435
- if (scopes.includes(required)) {
3436
- return true;
3437
- }
3438
- const [resource, id] = required.split(":");
3439
- if (resource && id) {
3440
- const wildcard = `${resource}:*`;
3441
- if (scopes.includes(wildcard)) {
3442
- return true;
3443
- }
3444
- }
3445
- return false;
3446
- }
3447
- function parseScope(scope) {
3448
- const parts = scope.split(":");
3449
- if (parts.length !== 2) return null;
3450
- return { resource: parts[0], id: parts[1] };
3451
- }
3452
- function canAccessResource(scopes, resourceType, resourceId) {
3453
- const required = `${resourceType}:${resourceId}`;
3454
- return hasScope(scopes, required);
3455
- }
3456
- var init_scopes = __esm({
3457
- "src/security/scopes.ts"() {
3458
- }
3459
- });
3460
-
3461
4776
  // src/security/capabilities.ts
3462
4777
  var CAPABILITIES, PROOF_CAPABILITIES, INTENT_REQUIREMENTS;
3463
4778
  var init_capabilities = __esm({
@@ -4143,23 +5458,62 @@ var require_axis_request_decorator = __commonJS({
4143
5458
  }
4144
5459
  });
4145
5460
 
4146
- // src/core/axis-error.ts
4147
- var axis_error_exports = {};
4148
- __export(axis_error_exports, {
4149
- AxisError: () => AxisError
4150
- });
4151
- var AxisError;
4152
- var init_axis_error = __esm({
4153
- "src/core/axis-error.ts"() {
4154
- AxisError = class extends Error {
4155
- constructor(code, message, httpStatus = 400, details) {
4156
- super(message);
4157
- this.code = code;
4158
- this.httpStatus = httpStatus;
4159
- this.details = details;
4160
- this.name = "AxisError";
5461
+ // src/engine/observer-discovery.service.ts
5462
+ var require_observer_discovery_service = __commonJS({
5463
+ "src/engine/observer-discovery.service.ts"(exports2) {
5464
+ "use strict";
5465
+ var __decorate = exports2 && exports2.__decorate || function(decorators, target, key, desc) {
5466
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5467
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5468
+ 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;
5469
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5470
+ };
5471
+ var __metadata = exports2 && exports2.__metadata || function(k, v) {
5472
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5473
+ };
5474
+ var ObserverDiscoveryService_1;
5475
+ var _a;
5476
+ var _b;
5477
+ var _c;
5478
+ Object.defineProperty(exports2, "__esModule", { value: true });
5479
+ exports2.ObserverDiscoveryService = void 0;
5480
+ var common_1 = require("@nestjs/common");
5481
+ var core_1 = require("@nestjs/core");
5482
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
5483
+ var observer_registry_1 = require_observer_registry();
5484
+ var ObserverDiscoveryService2 = ObserverDiscoveryService_1 = class ObserverDiscoveryService {
5485
+ constructor(discovery, reflector, registry) {
5486
+ this.discovery = discovery;
5487
+ this.reflector = reflector;
5488
+ this.registry = registry;
5489
+ this.logger = new common_1.Logger(ObserverDiscoveryService_1.name);
5490
+ }
5491
+ onApplicationBootstrap() {
5492
+ const providers = this.discovery.getProviders();
5493
+ let count = 0;
5494
+ for (const wrapper of providers) {
5495
+ const { instance } = wrapper;
5496
+ if (!instance || !instance.constructor)
5497
+ continue;
5498
+ const meta = this.reflector.get(observer_decorator_1.OBSERVER_METADATA_KEY, instance.constructor);
5499
+ if (!meta)
5500
+ continue;
5501
+ const observer = instance;
5502
+ if (typeof observer.observe !== "function") {
5503
+ this.logger.warn(`@Observer on ${instance.constructor.name} is missing observe() and was skipped`);
5504
+ continue;
5505
+ }
5506
+ this.registry.register(observer, meta);
5507
+ count++;
5508
+ }
5509
+ this.logger.log(`Auto-registered ${count} observers via @Observer()`);
4161
5510
  }
4162
5511
  };
5512
+ exports2.ObserverDiscoveryService = ObserverDiscoveryService2;
5513
+ exports2.ObserverDiscoveryService = ObserverDiscoveryService2 = ObserverDiscoveryService_1 = __decorate([
5514
+ (0, common_1.Injectable)(),
5515
+ __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])
5516
+ ], ObserverDiscoveryService2);
4163
5517
  }
4164
5518
  });
4165
5519
 
@@ -4184,6 +5538,7 @@ var require_handler_discovery_service = __commonJS({
4184
5538
  exports2.HandlerDiscoveryService = void 0;
4185
5539
  var common_1 = require("@nestjs/common");
4186
5540
  var core_1 = require("@nestjs/core");
5541
+ var observer_decorator_1 = (init_observer_decorator(), __toCommonJS(observer_decorator_exports));
4187
5542
  var handler_sensors_decorator_1 = (init_handler_sensors_decorator(), __toCommonJS(handler_sensors_decorator_exports));
4188
5543
  var handler_decorator_1 = (init_handler_decorator(), __toCommonJS(handler_decorator_exports));
4189
5544
  var intent_decorator_1 = (init_intent_decorator(), __toCommonJS(intent_decorator_exports));
@@ -4206,20 +5561,36 @@ var require_handler_discovery_service = __commonJS({
4206
5561
  if (!handlerMeta)
4207
5562
  continue;
4208
5563
  const handlerName = handlerMeta.intent || metatype.name;
5564
+ const prefix = handlerMeta.intent || metatype.name;
4209
5565
  const proto = Object.getPrototypeOf(instance);
4210
5566
  const methods = this.scanner.getAllMethodNames(proto);
5567
+ const routes = Reflect.getMetadata(intent_decorator_1.INTENT_ROUTES_KEY, metatype) || [];
5568
+ const routedMethods = new Set(routes.map((route) => String(route.methodName)));
4211
5569
  let registered = 0;
4212
5570
  const handlerSensors = Reflect.getMetadata(handler_sensors_decorator_1.HANDLER_SENSORS_KEY, metatype) || [];
5571
+ const handlerObservers = Reflect.getMetadata(observer_decorator_1.OBSERVER_BINDINGS_KEY, metatype) || [];
5572
+ for (const route of routes) {
5573
+ const intentName = route.absolute ? route.action : `${prefix}.${route.action}`;
5574
+ if (!this.router.has(intentName)) {
5575
+ this.router.register(intentName, instance[route.methodName].bind(instance));
5576
+ registered++;
5577
+ totalIntents++;
5578
+ }
5579
+ this.router.registerIntentMeta(intentName, proto, String(route.methodName), handlerSensors, handlerObservers);
5580
+ }
4213
5581
  for (const methodName of methods) {
5582
+ if (routedMethods.has(methodName))
5583
+ continue;
4214
5584
  const meta = Reflect.getMetadata(intent_decorator_1.INTENT_METADATA_KEY, proto, methodName);
4215
5585
  if (!meta?.intent)
4216
5586
  continue;
4217
- if (!this.router.has(meta.intent)) {
4218
- this.router.register(meta.intent, instance[methodName].bind(instance));
5587
+ const intentName = meta.absolute ? meta.intent : `${prefix}.${meta.intent}`;
5588
+ if (!this.router.has(intentName)) {
5589
+ this.router.register(intentName, instance[methodName].bind(instance));
4219
5590
  registered++;
4220
5591
  totalIntents++;
4221
5592
  }
4222
- this.router.registerIntentMeta(meta.intent, proto, methodName, handlerSensors);
5593
+ this.router.registerIntentMeta(intentName, proto, methodName, handlerSensors, handlerObservers);
4223
5594
  }
4224
5595
  if (registered > 0) {
4225
5596
  this.logger.log(`Auto-registered ${registered} intents from ${handlerName}`);
@@ -5789,6 +7160,10 @@ var init_crypto = __esm({
5789
7160
  // src/decorators/index.ts
5790
7161
  var decorators_exports = {};
5791
7162
  __export(decorators_exports, {
7163
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
7164
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
7165
+ CapsulePolicy: () => CapsulePolicy,
7166
+ Chain: () => Chain,
5792
7167
  HANDLER_METADATA_KEY: () => HANDLER_METADATA_KEY,
5793
7168
  Handler: () => Handler,
5794
7169
  INTENT_BODY_KEY: () => INTENT_BODY_KEY,
@@ -5798,6 +7173,9 @@ __export(decorators_exports, {
5798
7173
  Intent: () => Intent,
5799
7174
  IntentBody: () => IntentBody,
5800
7175
  IntentSensors: () => IntentSensors,
7176
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
7177
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
7178
+ Observer: () => Observer,
5801
7179
  SENSOR_METADATA_KEY: () => SENSOR_METADATA_KEY,
5802
7180
  Sensor: () => Sensor,
5803
7181
  TLV_FIELDS_KEY: () => TLV_FIELDS_KEY,
@@ -5807,16 +7185,21 @@ __export(decorators_exports, {
5807
7185
  TlvMinLen: () => TlvMinLen,
5808
7186
  TlvRange: () => TlvRange,
5809
7187
  TlvUtf8Pattern: () => TlvUtf8Pattern,
5810
- TlvValidate: () => TlvValidate
7188
+ TlvValidate: () => TlvValidate,
7189
+ mergeCapsulePolicyOptions: () => mergeCapsulePolicyOptions,
7190
+ normalizeCapsulePolicyOptions: () => normalizeCapsulePolicyOptions
5811
7191
  });
5812
7192
  var init_decorators = __esm({
5813
7193
  "src/decorators/index.ts"() {
5814
7194
  __reExport(decorators_exports, __toESM(require_axis_request_decorator()));
7195
+ init_capsule_policy_decorator();
7196
+ init_chain_decorator();
5815
7197
  __reExport(decorators_exports, __toESM(require_dto_schema_util()));
5816
7198
  init_handler_decorator();
5817
7199
  init_intent_body_decorator();
5818
7200
  init_intent_sensors_decorator();
5819
7201
  init_intent_decorator();
7202
+ init_observer_decorator();
5820
7203
  init_sensor_decorator();
5821
7204
  init_tlv_field_decorator();
5822
7205
  }
@@ -5828,6 +7211,18 @@ var init_axis_decoded = __esm({
5828
7211
  }
5829
7212
  });
5830
7213
 
7214
+ // src/engine/axis-chain.types.ts
7215
+ var init_axis_chain_types = __esm({
7216
+ "src/engine/axis-chain.types.ts"() {
7217
+ }
7218
+ });
7219
+
7220
+ // src/engine/axis-observer.interface.ts
7221
+ var init_axis_observer_interface = __esm({
7222
+ "src/engine/axis-observer.interface.ts"() {
7223
+ }
7224
+ });
7225
+
5831
7226
  // src/engine/observation/observation-queue.types.ts
5832
7227
  var init_observation_queue_types = __esm({
5833
7228
  "src/engine/observation/observation-queue.types.ts"() {
@@ -5862,6 +7257,7 @@ var init_observation = __esm({
5862
7257
  // src/engine/index.ts
5863
7258
  var engine_exports = {};
5864
7259
  __export(engine_exports, {
7260
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
5865
7261
  BAND: () => BAND,
5866
7262
  PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
5867
7263
  ResponseObserver: () => ResponseObserver,
@@ -5873,24 +7269,34 @@ __export(engine_exports, {
5873
7269
  encodeQueueMessage: () => encodeQueueMessage,
5874
7270
  endStage: () => endStage,
5875
7271
  finalizeObservation: () => finalizeObservation,
7272
+ getAxisExecutionContext: () => getAxisExecutionContext,
5876
7273
  hashObservation: () => hashObservation,
7274
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
5877
7275
  observation: () => observation_exports,
5878
7276
  parseAutoClaimEntries: () => parseAutoClaimEntries,
5879
7277
  parseStreamEntries: () => parseStreamEntries,
5880
7278
  recordSensor: () => recordSensor,
5881
7279
  stableJsonStringify: () => stableJsonStringify,
5882
7280
  startStage: () => startStage,
5883
- verifyResponse: () => verifyResponse
7281
+ verifyResponse: () => verifyResponse,
7282
+ withAxisExecutionContext: () => withAxisExecutionContext
5884
7283
  });
5885
7284
  var init_engine = __esm({
5886
7285
  "src/engine/index.ts"() {
5887
7286
  init_axis_decoded();
7287
+ __reExport(engine_exports, __toESM(require_axis_chain_executor()));
7288
+ init_axis_chain_types();
7289
+ init_axis_execution_context();
5888
7290
  init_axis_observation();
7291
+ init_axis_observer_interface();
5889
7292
  __reExport(engine_exports, __toESM(require_handler_discovery_service()));
5890
7293
  __reExport(engine_exports, __toESM(require_intent_router()));
5891
7294
  init_observation();
7295
+ __reExport(engine_exports, __toESM(require_observer_discovery_service()));
7296
+ __reExport(engine_exports, __toESM(require_observer_dispatcher_service()));
5892
7297
  init_sensor_bands();
5893
7298
  __reExport(engine_exports, __toESM(require_sensor_discovery_service()));
7299
+ __reExport(engine_exports, __toESM(require_observer_registry()));
5894
7300
  __reExport(engine_exports, __toESM(require_sensor_registry()));
5895
7301
  init_observation();
5896
7302
  }
@@ -7928,6 +9334,7 @@ var index_exports = {};
7928
9334
  __export(index_exports, {
7929
9335
  ATS1_HDR: () => ATS1_HDR,
7930
9336
  ATS1_SCHEMA: () => ATS1_SCHEMA,
9337
+ AXIS_EXECUTION_CONTEXT_KEY: () => AXIS_EXECUTION_CONTEXT_KEY,
7931
9338
  AXIS_MAGIC: () => import_axis_protocol2.AXIS_MAGIC,
7932
9339
  AXIS_OPCODES: () => AXIS_OPCODES,
7933
9340
  AXIS_UPLOAD_FILE_STORE: () => AXIS_UPLOAD_FILE_STORE,
@@ -7935,6 +9342,7 @@ __export(index_exports, {
7935
9342
  AXIS_UPLOAD_SESSION_STORE: () => AXIS_UPLOAD_SESSION_STORE,
7936
9343
  AXIS_VERSION: () => import_axis_protocol2.AXIS_VERSION,
7937
9344
  Ats1Codec: () => ats1_exports,
9345
+ AxisChainExecutor: () => import_axis_chain.AxisChainExecutor,
7938
9346
  AxisContext: () => import_axis_request.AxisContext,
7939
9347
  AxisDemoPubkey: () => import_axis_request.AxisDemoPubkey,
7940
9348
  AxisEffect: () => import_intent2.AxisEffect,
@@ -7953,9 +9361,13 @@ __export(index_exports, {
7953
9361
  BAND: () => BAND,
7954
9362
  BodyProfile: () => import_axis_protocol2.BodyProfile,
7955
9363
  CAPABILITIES: () => CAPABILITIES,
9364
+ CAPSULE_POLICY_METADATA_KEY: () => CAPSULE_POLICY_METADATA_KEY,
7956
9365
  CCE_ERROR: () => CCE_ERROR,
7957
9366
  CCE_PROTOCOL_VERSION: () => CCE_PROTOCOL_VERSION,
9367
+ CHAIN_METADATA_KEY: () => CHAIN_METADATA_KEY,
9368
+ CapsulePolicy: () => CapsulePolicy,
7958
9369
  CceError: () => CceError,
9370
+ Chain: () => Chain,
7959
9371
  ContractViolationError: () => ContractViolationError,
7960
9372
  DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
7961
9373
  DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
@@ -8001,6 +9413,12 @@ __export(index_exports, {
8001
9413
  NCERT_PUB: () => import_axis_protocol2.NCERT_PUB,
8002
9414
  NCERT_SCOPE: () => import_axis_protocol2.NCERT_SCOPE,
8003
9415
  NCERT_SIG: () => import_axis_protocol2.NCERT_SIG,
9416
+ OBSERVER_BINDINGS_KEY: () => OBSERVER_BINDINGS_KEY,
9417
+ OBSERVER_METADATA_KEY: () => OBSERVER_METADATA_KEY,
9418
+ Observer: () => Observer,
9419
+ ObserverDiscoveryService: () => import_observer_discovery.ObserverDiscoveryService,
9420
+ ObserverDispatcherService: () => import_observer_dispatcher.ObserverDispatcherService,
9421
+ ObserverRegistry: () => import_observer2.ObserverRegistry,
8004
9422
  PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
8005
9423
  PROOF_CAPABILITIES: () => PROOF_CAPABILITIES,
8006
9424
  PROOF_CAPSULE: () => import_axis_protocol2.PROOF_CAPSULE,
@@ -8118,6 +9536,7 @@ __export(index_exports, {
8118
9536
  extractDtoSchema: () => import_dto_schema.extractDtoSchema,
8119
9537
  finalizeObservation: () => finalizeObservation,
8120
9538
  generateEd25519KeyPair: () => generateEd25519KeyPair,
9539
+ getAxisExecutionContext: () => getAxisExecutionContext,
8121
9540
  getSignTarget: () => getSignTarget,
8122
9541
  hasScope: () => hasScope,
8123
9542
  hashObservation: () => hashObservation,
@@ -8125,6 +9544,7 @@ __export(index_exports, {
8125
9544
  isKnownOpcode: () => isKnownOpcode,
8126
9545
  isTimestampValid: () => isTimestampValid,
8127
9546
  loom: () => loom_exports,
9547
+ mergeAxisExecutionContext: () => mergeAxisExecutionContext,
8128
9548
  nonce16: () => nonce16,
8129
9549
  normalizeSensorDecision: () => normalizeSensorDecision,
8130
9550
  packPasskeyLoginOptionsReq: () => packPasskeyLoginOptionsReq,
@@ -8156,16 +9576,20 @@ __export(index_exports, {
8156
9576
  varintLength: () => import_axis_protocol3.varintLength,
8157
9577
  varintU: () => varintU,
8158
9578
  verifyFrameSignature: () => verifyFrameSignature,
8159
- verifyResponse: () => verifyResponse
9579
+ verifyResponse: () => verifyResponse,
9580
+ withAxisExecutionContext: () => withAxisExecutionContext
8160
9581
  });
8161
9582
  module.exports = __toCommonJS(index_exports);
8162
- var 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;
9583
+ var 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;
8163
9584
  var init_index = __esm({
8164
9585
  "src/index.ts"() {
9586
+ init_chain_decorator();
9587
+ init_capsule_policy_decorator();
8165
9588
  init_handler_decorator();
8166
9589
  init_intent_decorator();
8167
9590
  init_intent_body_decorator();
8168
9591
  init_intent_sensors_decorator();
9592
+ init_observer_decorator();
8169
9593
  init_handler_sensors_decorator();
8170
9594
  init_sensor_decorator();
8171
9595
  init_tlv_field_decorator();
@@ -8174,6 +9598,8 @@ var init_index = __esm({
8174
9598
  import_axis_id = __toESM(require_axis_id_dto());
8175
9599
  init_axis_partial_type();
8176
9600
  import_axis_response = __toESM(require_axis_response_dto());
9601
+ import_axis_chain = __toESM(require_axis_chain_executor());
9602
+ init_axis_execution_context();
8177
9603
  import_intent2 = __toESM(require_intent_router());
8178
9604
  init_sensor_bands();
8179
9605
  init_stable_json();
@@ -8211,8 +9637,11 @@ var init_index = __esm({
8211
9637
  init_disk_upload_file_store();
8212
9638
  import_axis_request = __toESM(require_axis_request_decorator());
8213
9639
  init_axis_error();
9640
+ import_observer_discovery = __toESM(require_observer_discovery_service());
9641
+ import_observer_dispatcher = __toESM(require_observer_dispatcher_service());
8214
9642
  import_handler_discovery = __toESM(require_handler_discovery_service());
8215
9643
  import_sensor_discovery = __toESM(require_sensor_discovery_service());
9644
+ import_observer2 = __toESM(require_observer_registry());
8216
9645
  import_sensor2 = __toESM(require_sensor_registry());
8217
9646
  init_axis_observation();
8218
9647
  import_axis_sensor_chain = __toESM(require_axis_sensor_chain_service());
@@ -8237,6 +9666,7 @@ init_index();
8237
9666
  0 && (module.exports = {
8238
9667
  ATS1_HDR,
8239
9668
  ATS1_SCHEMA,
9669
+ AXIS_EXECUTION_CONTEXT_KEY,
8240
9670
  AXIS_MAGIC,
8241
9671
  AXIS_OPCODES,
8242
9672
  AXIS_UPLOAD_FILE_STORE,
@@ -8244,6 +9674,7 @@ init_index();
8244
9674
  AXIS_UPLOAD_SESSION_STORE,
8245
9675
  AXIS_VERSION,
8246
9676
  Ats1Codec,
9677
+ AxisChainExecutor,
8247
9678
  AxisContext,
8248
9679
  AxisDemoPubkey,
8249
9680
  AxisEffect,
@@ -8262,9 +9693,13 @@ init_index();
8262
9693
  BAND,
8263
9694
  BodyProfile,
8264
9695
  CAPABILITIES,
9696
+ CAPSULE_POLICY_METADATA_KEY,
8265
9697
  CCE_ERROR,
8266
9698
  CCE_PROTOCOL_VERSION,
9699
+ CHAIN_METADATA_KEY,
9700
+ CapsulePolicy,
8267
9701
  CceError,
9702
+ Chain,
8268
9703
  ContractViolationError,
8269
9704
  DEFAULT_CONTRACTS,
8270
9705
  DEFAULT_TIMEOUT,
@@ -8310,6 +9745,12 @@ init_index();
8310
9745
  NCERT_PUB,
8311
9746
  NCERT_SCOPE,
8312
9747
  NCERT_SIG,
9748
+ OBSERVER_BINDINGS_KEY,
9749
+ OBSERVER_METADATA_KEY,
9750
+ Observer,
9751
+ ObserverDiscoveryService,
9752
+ ObserverDispatcherService,
9753
+ ObserverRegistry,
8313
9754
  PRE_DECODE_BOUNDARY,
8314
9755
  PROOF_CAPABILITIES,
8315
9756
  PROOF_CAPSULE,
@@ -8427,6 +9868,7 @@ init_index();
8427
9868
  extractDtoSchema,
8428
9869
  finalizeObservation,
8429
9870
  generateEd25519KeyPair,
9871
+ getAxisExecutionContext,
8430
9872
  getSignTarget,
8431
9873
  hasScope,
8432
9874
  hashObservation,
@@ -8434,6 +9876,7 @@ init_index();
8434
9876
  isKnownOpcode,
8435
9877
  isTimestampValid,
8436
9878
  loom,
9879
+ mergeAxisExecutionContext,
8437
9880
  nonce16,
8438
9881
  normalizeSensorDecision,
8439
9882
  packPasskeyLoginOptionsReq,
@@ -8465,6 +9908,7 @@ init_index();
8465
9908
  varintLength,
8466
9909
  varintU,
8467
9910
  verifyFrameSignature,
8468
- verifyResponse
9911
+ verifyResponse,
9912
+ withAxisExecutionContext
8469
9913
  });
8470
9914
  //# sourceMappingURL=index.js.map