@nextera.one/axis-server-sdk 2.3.12 → 2.3.13

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.
@@ -1,4 +1,4 @@
1
- export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-DZdmfbDZ.mjs';
1
+ export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-C5NXMEth.mjs';
2
2
  import '../axis-sensor-BLUemDiZ.mjs';
3
3
  import 'zod';
4
4
  import '@nextera.one/axis-protocol';
@@ -1,4 +1,4 @@
1
- export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-D_6djkZB.js';
1
+ export { n as AccessProfileResolverSensor, $ as BodyBudgetSensor, a2 as CapabilityEnforcementSensor, a7 as ChunkHashSensor, aa as EntropySensor, ac as ExecutionTimeoutSensor, ae as FrameBudgetSensor, af as FrameHeaderSanitySensor, ag as HeaderTLVLimitSensor, ak as IntentAllowlistSensor, an as IntentRegistrySensor, ap as LawArticlePresenceMode, aq as LawArticlePresenceSensor, ar as LawArticlePresenceSensorOptions, as as LawEvaluationSensor, ay as ProofPresenceSensor, az as ProtocolStrictSensor, aB as ReceiptPolicySensor, aG as RiskGateSensor, aH as RiskGateSensorOptions, aJ as RiskSignalCollector, aL as SchemaValidationSensor, aN as StreamScopeSensor, aO as TLVParseSensor, aR as TickAuthCapsuleRef, aS as TickAuthSensor, aT as TickAuthSensorOptions, aU as TickAuthVerifier, b3 as TpsSensor, b4 as TpsSensorOptions, b5 as VarintHardeningSensor } from '../index-B0HcQRif.js';
2
2
  import '../axis-sensor-BLUemDiZ.js';
3
3
  import 'zod';
4
4
  import '@nextera.one/axis-protocol';
@@ -2438,20 +2438,70 @@ var init_axis_error = __esm({
2438
2438
  }
2439
2439
  });
2440
2440
 
2441
- // src/engine/intent.router.ts
2442
- var intent_router_exports = {};
2443
- __export(intent_router_exports, {
2444
- IntentRouter: () => IntentRouter
2445
- });
2446
- function observerRefKey(ref) {
2447
- return typeof ref === "string" ? ref : ref.name;
2441
+ // src/engine/intent-builtins.ts
2442
+ function isBuiltinIntent(intent) {
2443
+ return BUILTIN_INTENTS.has(intent);
2448
2444
  }
2449
- function sensorRefKey(ref) {
2450
- return typeof ref === "string" ? ref : ref.name;
2445
+ function isChainExecIntent(intent) {
2446
+ return intent === "CHAIN.EXEC" || intent === "axis.chain.exec";
2451
2447
  }
2452
- function sensorBindingKey(binding) {
2453
- return `${binding.when}:${sensorRefKey(binding.ref)}`;
2448
+ function isIntentExecIntent(intent) {
2449
+ return intent === "INTENT.EXEC" || intent === "axis.intent.exec";
2450
+ }
2451
+ function routeSystemBuiltinIntent(intent, body, encoder) {
2452
+ if (intent === "system.ping" || intent === "public.ping") {
2453
+ return {
2454
+ ok: true,
2455
+ effect: "pong",
2456
+ headers: /* @__PURE__ */ new Map([[100, encoder.encode("AXIS_BACKEND_V1")]]),
2457
+ body: encoder.encode(
2458
+ JSON.stringify({
2459
+ status: "ok",
2460
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2461
+ version: "1.0.0"
2462
+ })
2463
+ )
2464
+ };
2465
+ }
2466
+ if (intent === "system.time") {
2467
+ const ts = Date.now().toString();
2468
+ return {
2469
+ ok: true,
2470
+ effect: "time",
2471
+ body: encoder.encode(
2472
+ JSON.stringify({
2473
+ ts,
2474
+ iso: (/* @__PURE__ */ new Date()).toISOString()
2475
+ })
2476
+ )
2477
+ };
2478
+ }
2479
+ if (intent === "system.echo") {
2480
+ return {
2481
+ ok: true,
2482
+ effect: "echo",
2483
+ body
2484
+ };
2485
+ }
2486
+ return void 0;
2454
2487
  }
2488
+ var BUILTIN_INTENTS;
2489
+ var init_intent_builtins = __esm({
2490
+ "src/engine/intent-builtins.ts"() {
2491
+ BUILTIN_INTENTS = /* @__PURE__ */ new Set([
2492
+ "system.ping",
2493
+ "public.ping",
2494
+ "system.time",
2495
+ "system.echo",
2496
+ "CHAIN.EXEC",
2497
+ "axis.chain.exec",
2498
+ "INTENT.EXEC",
2499
+ "axis.intent.exec"
2500
+ ]);
2501
+ }
2502
+ });
2503
+
2504
+ // src/engine/intent-proof-policy.ts
2455
2505
  function mergeProofKinds(...proofGroups) {
2456
2506
  const merged = /* @__PURE__ */ new Set();
2457
2507
  for (const proofs of proofGroups) {
@@ -2468,6 +2518,81 @@ function accessProofKinds(isPublic, isAnonymous, isAuthorized) {
2468
2518
  if (isAuthorized) proofs.push("AUTHORIZED");
2469
2519
  return proofs;
2470
2520
  }
2521
+ function resolveIntentProofPolicy(proto, methodName) {
2522
+ const methodProof = Reflect.getMetadata(
2523
+ REQUIRED_PROOF_METADATA_KEY,
2524
+ proto,
2525
+ methodName
2526
+ );
2527
+ const classProof = Reflect.getMetadata(
2528
+ REQUIRED_PROOF_METADATA_KEY,
2529
+ proto.constructor
2530
+ );
2531
+ const isPublicMethod = Reflect.getMetadata(
2532
+ AXIS_PUBLIC_KEY,
2533
+ proto,
2534
+ methodName
2535
+ );
2536
+ const isPublicClass = Reflect.getMetadata(
2537
+ AXIS_PUBLIC_KEY,
2538
+ proto.constructor
2539
+ );
2540
+ const isAnonymousMethod = Reflect.getMetadata(
2541
+ AXIS_ANONYMOUS_KEY,
2542
+ proto,
2543
+ methodName
2544
+ );
2545
+ const isAnonymousClass = Reflect.getMetadata(
2546
+ AXIS_ANONYMOUS_KEY,
2547
+ proto.constructor
2548
+ );
2549
+ const isAuthorizedMethod = Reflect.getMetadata(
2550
+ AXIS_AUTHORIZED_KEY,
2551
+ proto,
2552
+ methodName
2553
+ );
2554
+ const isAuthorizedClass = Reflect.getMetadata(
2555
+ AXIS_AUTHORIZED_KEY,
2556
+ proto.constructor
2557
+ );
2558
+ const methodPolicyProof = mergeProofKinds(
2559
+ methodProof,
2560
+ accessProofKinds(isPublicMethod, isAnonymousMethod, isAuthorizedMethod)
2561
+ );
2562
+ const classPolicyProof = mergeProofKinds(
2563
+ classProof,
2564
+ accessProofKinds(isPublicClass, isAnonymousClass, isAuthorizedClass)
2565
+ );
2566
+ const requiredProof = methodPolicyProof.length ? methodPolicyProof : classPolicyProof;
2567
+ return {
2568
+ requiredProof,
2569
+ isPublic: requiredProof.includes("NONE"),
2570
+ isAnonymous: requiredProof.includes("ANONYMOUS"),
2571
+ isAuthorized: requiredProof.includes("AUTHORIZED")
2572
+ };
2573
+ }
2574
+ var import_reflect_metadata12;
2575
+ var init_intent_proof_policy = __esm({
2576
+ "src/engine/intent-proof-policy.ts"() {
2577
+ import_reflect_metadata12 = require("reflect-metadata");
2578
+ init_intent_policy_decorator();
2579
+ }
2580
+ });
2581
+
2582
+ // src/engine/intent.router.ts
2583
+ var intent_router_exports = {};
2584
+ __export(intent_router_exports, {
2585
+ IntentRouter: () => IntentRouter
2586
+ });
2587
+ function observerRefKey(ref) {
2588
+ return typeof ref === "string" ? ref : ref.name;
2589
+ }
2590
+ function sensorRefKey(ref) {
2591
+ return typeof ref === "string" ? ref : ref.name;
2592
+ }
2593
+ function sensorBindingKey(binding) {
2594
+ return `${binding.when}:${sensorRefKey(binding.ref)}`;
2595
+ }
2471
2596
  function mergeIntentSensorBindings(...sensorGroups) {
2472
2597
  const merged = /* @__PURE__ */ new Map();
2473
2598
  for (const group of sensorGroups) {
@@ -2523,7 +2648,7 @@ function normalizeChainConfig(decoratorConfig, intentConfig) {
2523
2648
  ...intentConfig
2524
2649
  };
2525
2650
  }
2526
- var import_axis_protocol4, import_dto_schema, _IntentRouter, IntentRouter;
2651
+ var import_axis_protocol4, import_dto_schema, IntentRouter;
2527
2652
  var init_intent_router = __esm({
2528
2653
  "src/engine/intent.router.ts"() {
2529
2654
  import_axis_protocol4 = require("@nextera.one/axis-protocol");
@@ -2544,7 +2669,9 @@ var init_intent_router = __esm({
2544
2669
  init_cce_pipeline();
2545
2670
  init_axis_error();
2546
2671
  init_constants();
2547
- _IntentRouter = class _IntentRouter {
2672
+ init_intent_builtins();
2673
+ init_intent_proof_policy();
2674
+ IntentRouter = class _IntentRouter {
2548
2675
  constructor(dependencyResolver, observerDispatcher, sensorRegistry) {
2549
2676
  this.logger = createAxisLogger(_IntentRouter.name);
2550
2677
  this.decoder = new TextDecoder();
@@ -2575,12 +2702,6 @@ var init_intent_router = __esm({
2575
2702
  this.intentContracts = /* @__PURE__ */ new Map();
2576
2703
  /** Per-intent required proof kinds */
2577
2704
  this.intentRequiredProof = /* @__PURE__ */ new Map();
2578
- /** Intents flagged as public (no auth required) */
2579
- this.publicIntents = /* @__PURE__ */ new Set();
2580
- /** Intents flagged as anonymous-session accessible */
2581
- this.anonymousIntents = /* @__PURE__ */ new Set();
2582
- /** Intents flagged as authorized-session accessible */
2583
- this.authorizedIntents = /* @__PURE__ */ new Set();
2584
2705
  /** Per-intent rate limit config */
2585
2706
  this.intentRateLimits = /* @__PURE__ */ new Map();
2586
2707
  /** CCE handler registry */
@@ -2611,10 +2732,10 @@ var init_intent_router = __esm({
2611
2732
  }
2612
2733
  has(intent) {
2613
2734
  const resolved = this.resolveIntentAlias(intent);
2614
- return this.handlers.has(resolved) || _IntentRouter.BUILTIN_INTENTS.has(resolved);
2735
+ return this.handlers.has(resolved) || isBuiltinIntent(resolved);
2615
2736
  }
2616
2737
  getRegisteredIntents() {
2617
- return [..._IntentRouter.BUILTIN_INTENTS, ...this.handlers.keys()];
2738
+ return [...BUILTIN_INTENTS, ...this.handlers.keys()];
2618
2739
  }
2619
2740
  getIntentEntry(intent) {
2620
2741
  const resolved = this.resolveIntentAlias(intent);
@@ -2623,7 +2744,7 @@ var init_intent_router = __esm({
2623
2744
  schema: this.intentSchemas.get(resolved),
2624
2745
  validators: this.intentValidators.get(resolved),
2625
2746
  hasSensors: this.intentSensors.has(resolved),
2626
- builtin: _IntentRouter.BUILTIN_INTENTS.has(resolved),
2747
+ builtin: isBuiltinIntent(resolved),
2627
2748
  kind: this.intentKinds.get(resolved),
2628
2749
  chain: this.intentChains.get(resolved),
2629
2750
  capsulePolicy: this.intentCapsulePolicies.get(resolved),
@@ -2645,6 +2766,9 @@ var init_intent_router = __esm({
2645
2766
  * @param {any} handler - The handler function or object
2646
2767
  */
2647
2768
  register(intent, handler) {
2769
+ if (this.handlers.has(intent)) {
2770
+ this.logger.warn(`Intent ${intent} is already registered; replacing handler`);
2771
+ }
2648
2772
  this.handlers.set(intent, handler);
2649
2773
  if (typeof handler === "function" && handler.name) {
2650
2774
  this.intentHandlerRefs.set(intent, handler.name);
@@ -2755,128 +2879,7 @@ var init_intent_router = __esm({
2755
2879
  frame
2756
2880
  });
2757
2881
  let effect;
2758
- if (intent === "system.ping" || intent === "public.ping") {
2759
- this.logger.debug("PING received");
2760
- effect = {
2761
- ok: true,
2762
- effect: "pong",
2763
- headers: /* @__PURE__ */ new Map([
2764
- [100, new TextEncoder().encode("AXIS_BACKEND_V1")]
2765
- ]),
2766
- body: new TextEncoder().encode(
2767
- JSON.stringify({
2768
- status: "ok",
2769
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2770
- version: "1.0.0"
2771
- })
2772
- )
2773
- };
2774
- } else if (intent === "system.time") {
2775
- const ts = Date.now().toString();
2776
- effect = {
2777
- ok: true,
2778
- effect: "time",
2779
- body: new TextEncoder().encode(
2780
- JSON.stringify({
2781
- ts,
2782
- iso: (/* @__PURE__ */ new Date()).toISOString()
2783
- })
2784
- )
2785
- };
2786
- } else if (intent === "system.echo") {
2787
- effect = {
2788
- ok: true,
2789
- effect: "echo",
2790
- body: frame.body
2791
- };
2792
- } else if (intent === "CHAIN.EXEC" || intent === "axis.chain.exec") {
2793
- const chainRequest = this.parseChainRequestBody(frame.body);
2794
- effect = await this.executeChainRequest(frame, chainRequest);
2795
- } else if (intent === "INTENT.EXEC" || intent === "axis.intent.exec") {
2796
- const execBody = this.parseIntentExecBody(frame.body);
2797
- const innerIntent = execBody.intent;
2798
- const innerArgs = execBody.args || {};
2799
- if (!innerIntent) {
2800
- throw new Error("INTENT.EXEC missing inner intent");
2801
- }
2802
- this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
2803
- const innerHeaders = new Map(frame.headers);
2804
- innerHeaders.set(import_axis_protocol.TLV_INTENT, this.encoder.encode(innerIntent));
2805
- const inlineCapsule = this.toInlineCapsuleRecord(execBody.capsule);
2806
- const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2807
- if (capsuleId) {
2808
- innerHeaders.set(import_axis_protocol.TLV_CAPSULE, this.encoder.encode(capsuleId));
2809
- innerHeaders.set(import_axis_protocol.TLV_PROOF_REF, this.encoder.encode(capsuleId));
2810
- }
2811
- const innerFrame = withAxisExecutionContext(
2812
- {
2813
- ...frame,
2814
- headers: innerHeaders,
2815
- body: this.encodeJson(innerArgs)
2816
- },
2817
- mergeAxisExecutionContext(getAxisExecutionContext(frame), {
2818
- metaIntent: "INTENT.EXEC",
2819
- actorId: this.getActorIdFromFrame(frame),
2820
- inlineCapsule
2821
- }) || {}
2822
- );
2823
- effect = await this.route(innerFrame);
2824
- } else {
2825
- const handler = this.handlers.get(intent);
2826
- if (!handler) {
2827
- throw new Error(`Intent not found: ${intent}`);
2828
- }
2829
- const sensorBindings = this.intentSensors.get(intent);
2830
- if (sensorBindings && sensorBindings.length > 0) {
2831
- await this.runIntentSensors(sensorBindings, intent, frame, "before");
2832
- }
2833
- const decoder = this.intentDecoders.get(intent);
2834
- let decodedBody = frame.body;
2835
- if (decoder) {
2836
- try {
2837
- decodedBody = decoder(Buffer.from(frame.body));
2838
- } catch (decodeErr) {
2839
- throw new Error(
2840
- `IntentBody decode failed for ${intent}: ${decodeErr.message}`
2841
- );
2842
- }
2843
- }
2844
- this.enforceCapsulePolicy(
2845
- intent,
2846
- frame,
2847
- decodedBody,
2848
- this.getEffectiveCapsulePolicy(intent, frame)
2849
- );
2850
- if (typeof handler === "function") {
2851
- const resultBody = decoder ? await handler(decodedBody, frame.headers) : await handler(frame.body, frame.headers);
2852
- effect = {
2853
- ok: true,
2854
- effect: "complete",
2855
- body: resultBody
2856
- };
2857
- } else {
2858
- if (typeof handler.handle === "function") {
2859
- effect = await handler.handle(frame);
2860
- } else if (typeof handler.execute === "function") {
2861
- const bodyRes = decoder ? await handler.execute(decodedBody, frame.headers) : await handler.execute(frame.body, frame.headers);
2862
- effect = {
2863
- ok: true,
2864
- effect: "complete",
2865
- body: bodyRes
2866
- };
2867
- } else {
2868
- throw new Error(
2869
- `Handler for ${intent} does not implement handle or execute`
2870
- );
2871
- }
2872
- }
2873
- if (sensorBindings && sensorBindings.length > 0) {
2874
- await this.runIntentSensors(sensorBindings, intent, frame, "after", {
2875
- decodedBody,
2876
- effect
2877
- });
2878
- }
2879
- }
2882
+ effect = await this.routeResolvedIntent(intent, frame);
2880
2883
  await this.emitIntentObservers(observerBindings, {
2881
2884
  event: "intent.completed",
2882
2885
  timestamp: Date.now(),
@@ -2901,6 +2904,134 @@ var init_intent_router = __esm({
2901
2904
  throw e;
2902
2905
  }
2903
2906
  }
2907
+ /**
2908
+ * Dispatches a resolved canonical intent to the correct execution path.
2909
+ * This keeps route() focused on observer/error lifecycle concerns.
2910
+ */
2911
+ async routeResolvedIntent(intent, frame) {
2912
+ const builtinEffect = routeSystemBuiltinIntent(
2913
+ intent,
2914
+ frame.body,
2915
+ this.encoder
2916
+ );
2917
+ if (builtinEffect) {
2918
+ if (intent === "system.ping" || intent === "public.ping") {
2919
+ this.logger.debug("PING received");
2920
+ }
2921
+ return builtinEffect;
2922
+ }
2923
+ if (isChainExecIntent(intent)) {
2924
+ const chainRequest = this.parseChainRequestBody(frame.body);
2925
+ return this.executeChainRequest(frame, chainRequest);
2926
+ }
2927
+ if (isIntentExecIntent(intent)) {
2928
+ return this.routeIntentExec(frame);
2929
+ }
2930
+ return this.routeRegisteredIntent(intent, frame);
2931
+ }
2932
+ /**
2933
+ * Handles INTENT.EXEC by building an inner frame and routing it normally.
2934
+ * The recursive route call is intentional so sensors/observers/policies for
2935
+ * the inner intent stay identical to a direct request.
2936
+ */
2937
+ async routeIntentExec(frame) {
2938
+ const execBody = this.parseIntentExecBody(frame.body);
2939
+ const innerIntent = execBody.intent;
2940
+ const innerArgs = execBody.args || {};
2941
+ if (!innerIntent) {
2942
+ throw new Error("INTENT.EXEC missing inner intent");
2943
+ }
2944
+ this.logger.debug(`EXEC: routing to inner intent '${innerIntent}'`);
2945
+ const innerHeaders = new Map(frame.headers);
2946
+ innerHeaders.set(import_axis_protocol.TLV_INTENT, this.encoder.encode(innerIntent));
2947
+ const inlineCapsule = this.toInlineCapsuleRecord(execBody.capsule);
2948
+ const capsuleId = this.extractInlineCapsuleId(inlineCapsule);
2949
+ if (capsuleId) {
2950
+ innerHeaders.set(import_axis_protocol.TLV_CAPSULE, this.encoder.encode(capsuleId));
2951
+ innerHeaders.set(import_axis_protocol.TLV_PROOF_REF, this.encoder.encode(capsuleId));
2952
+ }
2953
+ const innerFrame = withAxisExecutionContext(
2954
+ {
2955
+ ...frame,
2956
+ headers: innerHeaders,
2957
+ body: this.encodeJson(innerArgs)
2958
+ },
2959
+ mergeAxisExecutionContext(getAxisExecutionContext(frame), {
2960
+ metaIntent: "INTENT.EXEC",
2961
+ actorId: this.getActorIdFromFrame(frame),
2962
+ inlineCapsule
2963
+ }) || {}
2964
+ );
2965
+ return this.route(innerFrame);
2966
+ }
2967
+ /**
2968
+ * Executes an app-registered intent: before sensors, body decode, capsule
2969
+ * policy, handler invocation, then after sensors.
2970
+ */
2971
+ async routeRegisteredIntent(intent, frame) {
2972
+ const handler = this.handlers.get(intent);
2973
+ if (!handler) {
2974
+ throw new Error(`Intent not found: ${intent}`);
2975
+ }
2976
+ const sensorBindings = this.intentSensors.get(intent);
2977
+ if (sensorBindings && sensorBindings.length > 0) {
2978
+ await this.runIntentSensors(sensorBindings, intent, frame, "before");
2979
+ }
2980
+ const decoder = this.intentDecoders.get(intent);
2981
+ const decodedBody = this.decodeIntentBody(intent, frame, decoder);
2982
+ this.enforceCapsulePolicy(
2983
+ intent,
2984
+ frame,
2985
+ decodedBody,
2986
+ this.getEffectiveCapsulePolicy(intent, frame)
2987
+ );
2988
+ const effect = await this.invokeRegisteredHandler(
2989
+ intent,
2990
+ handler,
2991
+ frame,
2992
+ decoder,
2993
+ decodedBody
2994
+ );
2995
+ if (sensorBindings && sensorBindings.length > 0) {
2996
+ await this.runIntentSensors(sensorBindings, intent, frame, "after", {
2997
+ decodedBody,
2998
+ effect
2999
+ });
3000
+ }
3001
+ return effect;
3002
+ }
3003
+ decodeIntentBody(intent, frame, decoder) {
3004
+ if (!decoder) return frame.body;
3005
+ try {
3006
+ return decoder(Buffer.from(frame.body));
3007
+ } catch (decodeErr) {
3008
+ throw new Error(
3009
+ `IntentBody decode failed for ${intent}: ${decodeErr.message}`
3010
+ );
3011
+ }
3012
+ }
3013
+ async invokeRegisteredHandler(intent, handler, frame, decoder, decodedBody) {
3014
+ if (typeof handler === "function") {
3015
+ const resultBody = decoder ? await handler(decodedBody, frame.headers) : await handler(frame.body, frame.headers);
3016
+ return {
3017
+ ok: true,
3018
+ effect: "complete",
3019
+ body: resultBody
3020
+ };
3021
+ }
3022
+ if (typeof handler.handle === "function") {
3023
+ return handler.handle(frame);
3024
+ }
3025
+ if (typeof handler.execute === "function") {
3026
+ const bodyRes = decoder ? await handler.execute(decodedBody, frame.headers) : await handler.execute(frame.body, frame.headers);
3027
+ return {
3028
+ ok: true,
3029
+ effect: "complete",
3030
+ body: bodyRes
3031
+ };
3032
+ }
3033
+ throw new Error(`Handler for ${intent} does not implement handle or execute`);
3034
+ }
2904
3035
  logIntent(intent, start, ok, error) {
2905
3036
  const diff = process.hrtime(start);
2906
3037
  const ms = (diff[0] * 1e3 + diff[1] / 1e6).toFixed(2);
@@ -2994,62 +3125,9 @@ var init_intent_router = __esm({
2994
3125
  if (contract) {
2995
3126
  this.intentContracts.set(intent, contract);
2996
3127
  }
2997
- const methodProof = Reflect.getMetadata(
2998
- REQUIRED_PROOF_METADATA_KEY,
2999
- proto,
3000
- methodName
3001
- );
3002
- const classProof = Reflect.getMetadata(
3003
- REQUIRED_PROOF_METADATA_KEY,
3004
- proto.constructor
3005
- );
3006
- const isPublicMethod = Reflect.getMetadata(
3007
- AXIS_PUBLIC_KEY,
3008
- proto,
3009
- methodName
3010
- );
3011
- const isPublicClass = Reflect.getMetadata(
3012
- AXIS_PUBLIC_KEY,
3013
- proto.constructor
3014
- );
3015
- const isAnonMethod = Reflect.getMetadata(
3016
- AXIS_ANONYMOUS_KEY,
3017
- proto,
3018
- methodName
3019
- );
3020
- const isAnonClass = Reflect.getMetadata(
3021
- AXIS_ANONYMOUS_KEY,
3022
- proto.constructor
3023
- );
3024
- const isAuthorizedMethod = Reflect.getMetadata(
3025
- AXIS_AUTHORIZED_KEY,
3026
- proto,
3027
- methodName
3028
- );
3029
- const isAuthorizedClass = Reflect.getMetadata(
3030
- AXIS_AUTHORIZED_KEY,
3031
- proto.constructor
3032
- );
3033
- const methodPolicyProof = mergeProofKinds(
3034
- methodProof,
3035
- accessProofKinds(isPublicMethod, isAnonMethod, isAuthorizedMethod)
3036
- );
3037
- const classPolicyProof = mergeProofKinds(
3038
- classProof,
3039
- accessProofKinds(isPublicClass, isAnonClass, isAuthorizedClass)
3040
- );
3041
- const requiredProof = methodPolicyProof.length ? methodPolicyProof : classPolicyProof;
3042
- if (requiredProof.length > 0) {
3043
- this.intentRequiredProof.set(intent, requiredProof);
3044
- }
3045
- if (requiredProof.includes("NONE")) {
3046
- this.publicIntents.add(intent);
3047
- }
3048
- if (requiredProof.includes("ANONYMOUS")) {
3049
- this.anonymousIntents.add(intent);
3050
- }
3051
- if (requiredProof.includes("AUTHORIZED")) {
3052
- this.authorizedIntents.add(intent);
3128
+ const proofPolicy = resolveIntentProofPolicy(proto, methodName);
3129
+ if (proofPolicy.requiredProof.length > 0) {
3130
+ this.intentRequiredProof.set(intent, proofPolicy.requiredProof);
3053
3131
  }
3054
3132
  const rateLimit = Reflect.getMetadata(
3055
3133
  AXIS_RATE_LIMIT_KEY,
@@ -3071,13 +3149,13 @@ var init_intent_router = __esm({
3071
3149
  return this.intentRequiredProof.get(this.resolveIntentAlias(intent));
3072
3150
  }
3073
3151
  isPublic(intent) {
3074
- return this.publicIntents.has(this.resolveIntentAlias(intent));
3152
+ return this.getRequiredProof(intent)?.includes("NONE") ?? false;
3075
3153
  }
3076
3154
  isAnonymous(intent) {
3077
- return this.anonymousIntents.has(this.resolveIntentAlias(intent));
3155
+ return this.getRequiredProof(intent)?.includes("ANONYMOUS") ?? false;
3078
3156
  }
3079
3157
  isAuthorized(intent) {
3080
- return this.authorizedIntents.has(this.resolveIntentAlias(intent));
3158
+ return this.getRequiredProof(intent)?.includes("AUTHORIZED") ?? false;
3081
3159
  }
3082
3160
  getRateLimit(intent) {
3083
3161
  return this.intentRateLimits.get(this.resolveIntentAlias(intent));
@@ -3098,7 +3176,7 @@ var init_intent_router = __esm({
3098
3176
  }
3099
3177
  /** The system/builtin intents (ping, time, echo, chain, intent.exec). */
3100
3178
  getSystemIntents() {
3101
- return [..._IntentRouter.BUILTIN_INTENTS];
3179
+ return [...BUILTIN_INTENTS];
3102
3180
  }
3103
3181
  /** True if every intent in the handler is public, or any one is public — returns true if ANY intent is @AxisPublic. */
3104
3182
  isHandlerPublic(handlerName) {
@@ -3171,7 +3249,7 @@ var init_intent_router = __esm({
3171
3249
  * canonical intent. Existing exact intent names always win.
3172
3250
  */
3173
3251
  resolveIntentAlias(intent) {
3174
- if (this.handlers.has(intent) || _IntentRouter.BUILTIN_INTENTS.has(intent)) {
3252
+ if (this.handlers.has(intent) || isBuiltinIntent(intent)) {
3175
3253
  return intent;
3176
3254
  }
3177
3255
  const separator = "...";
@@ -3695,18 +3773,6 @@ var init_intent_router = __esm({
3695
3773
  this.intentSchemas.set(meta.intent, schema);
3696
3774
  }
3697
3775
  };
3698
- /** Intents handled inline in route() — not in `handlers` map */
3699
- _IntentRouter.BUILTIN_INTENTS = /* @__PURE__ */ new Set([
3700
- "system.ping",
3701
- "public.ping",
3702
- "system.time",
3703
- "system.echo",
3704
- "CHAIN.EXEC",
3705
- "axis.chain.exec",
3706
- "INTENT.EXEC",
3707
- "axis.intent.exec"
3708
- ]);
3709
- IntentRouter = _IntentRouter;
3710
3776
  }
3711
3777
  });
3712
3778