@agenticprimitives/tool-policy 1.0.0-alpha.4 → 1.0.0-alpha.41

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/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # @agenticprimitives/tool-policy
2
2
 
3
- Protocol-agnostic classification, risk tiers, and exact-call policy primitives. Consumable by MCP, A2A, LangGraph, Vercel AI — any tool runtime.
3
+ > Part of **[Agentic Primitives](https://agenticprimitives.dev)** — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. [Developer kit](https://github.com/agentictrustlabs/agentic-primitives) · [All packages](https://agenticprimitives.dev/developers)
4
4
 
5
- This package is **deliberately transport-free**: no MCP SDK, no LangChain, no Vercel imports. That's what lets a LangGraph user `pnpm add` it without buying into MCP middleware, and what lets `@agenticprimitives/mcp-runtime` use it without being the only consumer.
5
+ **One delegation model, everywhere — and this is the layer that decides.**
6
+
7
+ Agents are getting tool access faster than anyone is deciding what those tools should be allowed to do. The usual answer is an OAuth scope string or an API key with a prayer attached — coarse, transport-bound, and silent about risk. This package is the missing decision layer: a classification taxonomy (`@sa-tool`, `@sa-auth`, `@sa-validation`, `@sa-risk-tier` and friends), risk tiers with TTL clamps and required-caveat lookups, an exact-call DSL for byte-precise on-chain calls, and a deterministic decision engine — `evaluatePolicy(ctx)` returns `allow`, `deny`, or `requires-consent`, the same answer for the same input, every time. Unknown classification fields fail closed.
8
+
9
+ It is **deliberately transport-free**: no MCP SDK, no LangChain, no Vercel AI imports ([ADR-0003](../../docs/architecture/decisions/0003-tool-policy-protocol-agnostic.md)). A LangGraph user can `pnpm add` it without buying into MCP middleware, and `@agenticprimitives/mcp-runtime` consumes it without being the only consumer. This package decides; your runtime enforces.
10
+
11
+ > Part of [agenticprimitives](../../README.md) — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.
6
12
 
7
13
  See [`spec.md`](./spec.md) → [`specs/204-tool-policy.md`](../../specs/204-tool-policy.md).
8
14
 
@@ -34,6 +40,8 @@ if (decision.decision === 'requires-consent') /* prompt user */;
34
40
 
35
41
  ## Exact-call policy
36
42
 
43
+ When "roughly this kind of call" is not good enough, pin the exact one:
44
+
37
45
  ```ts
38
46
  import { exactCall, matchesExactCall } from '@agenticprimitives/tool-policy';
39
47
 
@@ -45,6 +53,19 @@ const policy = exactCall(safeAddress, '0xa9059cbb', {
45
53
  const ok = matchesExactCall({ to, data, value }, policy);
46
54
  ```
47
55
 
56
+ When `calldataHash` is set, matching is byte-identical — no partial-match shortcuts.
57
+
58
+ ## How it's different
59
+
60
+ OAuth scopes and general-purpose policy engines (OPA-style) are the incumbents here, and both have a gap this package targets. Scopes are static strings granted at consent time; they know nothing about risk tiers, value limits, or the delegation a caller actually holds. Policy engines are powerful but generic — you bring your own identity model, your own risk taxonomy, and your own integration glue per transport. This package ships the agent-tooling-specific layer pre-built: a risk taxonomy designed for tool calls, decisions that compose with `Delegation` objects from `@agenticprimitives/delegation` (consumed type-only — no runtime coupling), and a deterministic, side-effect-free engine you can golden-test. The decision an MCP server enforces is the same decision a LangGraph or A2A runtime would get, because the policy layer never learned what transport it lives in.
61
+
62
+ ## Validate
63
+
64
+ ```bash
65
+ pnpm --filter @agenticprimitives/tool-policy typecheck
66
+ pnpm --filter @agenticprimitives/tool-policy test
67
+ ```
68
+
48
69
  ## Status
49
70
 
50
- Pre-alpha. Spec stable.
71
+ **Alpha track — testnet-only.** Spec + API stable; do not deploy to production until the gates listed in the root [`README.md` Status section](../../README.md#status) are cleared — including third-party contract audit and governance key rotation. Track every security finding live in [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml).
@@ -0,0 +1,62 @@
1
+ import type { Hex } from '@agenticprimitives/types';
2
+ import type { RiskTier } from './types.js';
3
+ /** The three authority tiers. T0 communication (sender-proof only), T1 execution-fast (cached-verdict read),
4
+ * T2 execution-orchestrated (full delegation gate + async task). */
5
+ export type AuthorityTier = 'communication' | 'execution-fast' | 'execution-orchestrated';
6
+ /** The execution lane a tier rides. `fast` = the low-overhead warm path (T0/T1); `orchestrated` = the
7
+ * heavyweight async task path (T2). */
8
+ export type ExecLane = 'fast' | 'orchestrated';
9
+ /** What a surface DOES below the authority line. Only `read` is ever fast-lane eligible. */
10
+ export type SurfaceEffect = 'read' | 'write' | 'value' | 'admin';
11
+ /** Data sensitivity of a surface. Anything other than `public` is hard-T2 (L3), never fast-lane. */
12
+ export type SurfaceSensitivity = 'public' | 'confidential' | 'sensitive';
13
+ /** The server-owned authority facet of a SurfaceDescriptor — the ONLY source of effect / sensitivity / T1
14
+ * eligibility. Authored server-side; never derived from a request. */
15
+ export interface SurfaceAuthorityDescriptor {
16
+ /** 4-byte skill selector = `keccak256(skill)[:4]`, server-computed (`computeSkillSelector`). */
17
+ selector: Hex;
18
+ effect: SurfaceEffect;
19
+ sensitivity: SurfaceSensitivity;
20
+ /** Positive, deny-by-default T1 allowlist membership. `false`/absent ⇒ never fast-lane. */
21
+ t1Eligible: boolean;
22
+ /** Optional risk tier carried into the verdict for downstream caveat / consent requirements. */
23
+ risk?: RiskTier;
24
+ }
25
+ /** The authority class the gate acts on. */
26
+ export interface SkillAuthorityClass {
27
+ tier: AuthorityTier;
28
+ lane: ExecLane;
29
+ risk?: RiskTier;
30
+ /** For T1: the exact selector the cached verdict + per-call caveat pass are scoped to. */
31
+ toolScope?: Hex[];
32
+ /** Why the class was assigned (esp. why over-classified / hard-T2) — for the audit trail. */
33
+ reason?: string;
34
+ }
35
+ /** Classification input. `communication` = a message delivery (T0, no selector). `execution` = a skill/tool
36
+ * invocation carrying its server-computed selector. `effect`/`sensitivity` are NEVER accepted here — the
37
+ * fabric maps its closed `kind` set to `communication | execution` server-side before calling. */
38
+ export type ClassifyInput = {
39
+ kind: 'communication';
40
+ } | {
41
+ kind: 'execution';
42
+ skillSelector: Hex;
43
+ };
44
+ /** Server-owned registry: lowercased selector → authority descriptor. */
45
+ export type SkillAuthorityRegistry = ReadonlyMap<string, SurfaceAuthorityDescriptor>;
46
+ /** `keccak256(utf8(skill))[:4]` — the server-computed skill selector. The gate computes this ITSELF from the
47
+ * invoked skill name; it is never trusted from the client. */
48
+ export declare function computeSkillSelector(skill: string): Hex;
49
+ /** Build a registry from descriptors, keyed by lowercased selector. Validates selector shape (fail-closed). */
50
+ export declare function buildSkillAuthorityRegistry(descriptors: readonly SurfaceAuthorityDescriptor[]): SkillAuthorityRegistry;
51
+ /**
52
+ * Classify an exchange into its authority tier + execution lane. Pure, server-authoritative, fail-closed.
53
+ *
54
+ * - `communication` → T0 fast (sender-proof only; no selector, no delegation).
55
+ * - `execution` + registry HIT that is `t1Eligible ∧ read ∧ public` → T1 fast.
56
+ * - `execution` + registry HIT otherwise (write/value/admin, or `sensitivity != public`, or not allowlisted) → T2.
57
+ * - `execution` + registry MISS → T2 / critical (over-classified).
58
+ *
59
+ * `effect`/`sensitivity` are read from the server-owned `registry`, never from the caller.
60
+ */
61
+ export declare function classifyExchange(input: ClassifyInput, registry: SkillAuthorityRegistry): SkillAuthorityClass;
62
+ //# sourceMappingURL=authority-tier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-tier.d.ts","sourceRoot":"","sources":["../src/authority-tier.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;qEACqE;AACrE,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,gBAAgB,GAAG,wBAAwB,CAAC;AAE1F;wCACwC;AACxC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;AAE/C,4FAA4F;AAC5F,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjE,oGAAoG;AACpG,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzE;uEACuE;AACvE,MAAM,WAAW,0BAA0B;IACzC,gGAAgG;IAChG,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,kBAAkB,CAAC;IAChC,2FAA2F;IAC3F,UAAU,EAAE,OAAO,CAAC;IACpB,gGAAgG;IAChG,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;mGAEmG;AACnG,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,aAAa,EAAE,GAAG,CAAA;CAAE,CAAC;AAE9C,yEAAyE;AACzE,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;AAIrF;+DAC+D;AAC/D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAKvD;AAED,+GAA+G;AAC/G,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,SAAS,0BAA0B,EAAE,GACjD,sBAAsB,CASxB;AAUD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,sBAAsB,GAC/B,mBAAmB,CAqBrB"}
@@ -0,0 +1,78 @@
1
+ // Authority-tier classification — the ONE server-authoritative source that BOTH the fabric ingress gate and
2
+ // the mcp-runtime delegation gate read to decide which execution LANE an exchange rides (spec 316 §3a/§(c),
3
+ // Blocker 2 + L3). One table, two gates.
4
+ //
5
+ // Invariants (all fail-closed):
6
+ // - The tier is derived SERVER-SIDE from the skill SELECTOR looked up in a server-owned registry — NEVER
7
+ // from a client-supplied effect/sensitivity/kind. `classifyExchange` therefore accepts only a
8
+ // discriminated `{communication | execution+selector}` input; effect/sensitivity live in the registry.
9
+ // - Over-classify by default: a registry MISS returns the MOST RESTRICTIVE class (execution-orchestrated /
10
+ // critical), never a permissive default (ADR-0013 fail-closed; mirrors smart-agent `risk-tiers`
11
+ // "miss → the heavier tier, never the lighter").
12
+ // - L3 hard-T2: a surface with `sensitivity != 'public'` is NEVER fast-lane (T1) eligible regardless of its
13
+ // effect flag. T1 eligibility is a positive, deny-by-default allowlist AND `effect === 'read'` AND
14
+ // `sensitivity === 'public'`.
15
+ // - Communication (T0) is the delivery of a message; it carries no skill selector and can never reach an
16
+ // execution handler, so a mislabeled communication exchange is at most delivered, never executed.
17
+ import { keccak_256 } from '@noble/hashes/sha3.js';
18
+ const SELECTOR_RE = /^0x[0-9a-fA-F]{8}$/;
19
+ /** `keccak256(utf8(skill))[:4]` — the server-computed skill selector. The gate computes this ITSELF from the
20
+ * invoked skill name; it is never trusted from the client. */
21
+ export function computeSkillSelector(skill) {
22
+ const out = keccak_256(new TextEncoder().encode(skill));
23
+ let s = '0x';
24
+ for (let i = 0; i < 4; i++)
25
+ s += out[i].toString(16).padStart(2, '0');
26
+ return s;
27
+ }
28
+ /** Build a registry from descriptors, keyed by lowercased selector. Validates selector shape (fail-closed). */
29
+ export function buildSkillAuthorityRegistry(descriptors) {
30
+ const m = new Map();
31
+ for (const d of descriptors) {
32
+ if (!SELECTOR_RE.test(d.selector)) {
33
+ throw new Error(`buildSkillAuthorityRegistry: selector must be 4 bytes (0x + 8 hex); got "${d.selector}"`);
34
+ }
35
+ m.set(d.selector.toLowerCase(), d);
36
+ }
37
+ return m;
38
+ }
39
+ /** The MOST RESTRICTIVE class — the fail-closed default for a registry miss. */
40
+ const OVER_CLASSIFIED = Object.freeze({
41
+ tier: 'execution-orchestrated',
42
+ lane: 'orchestrated',
43
+ risk: 'critical',
44
+ reason: 'registry-miss:over-classified',
45
+ });
46
+ /**
47
+ * Classify an exchange into its authority tier + execution lane. Pure, server-authoritative, fail-closed.
48
+ *
49
+ * - `communication` → T0 fast (sender-proof only; no selector, no delegation).
50
+ * - `execution` + registry HIT that is `t1Eligible ∧ read ∧ public` → T1 fast.
51
+ * - `execution` + registry HIT otherwise (write/value/admin, or `sensitivity != public`, or not allowlisted) → T2.
52
+ * - `execution` + registry MISS → T2 / critical (over-classified).
53
+ *
54
+ * `effect`/`sensitivity` are read from the server-owned `registry`, never from the caller.
55
+ */
56
+ export function classifyExchange(input, registry) {
57
+ if (input.kind === 'communication') {
58
+ return { tier: 'communication', lane: 'fast' };
59
+ }
60
+ const d = registry.get(input.skillSelector.toLowerCase());
61
+ if (!d)
62
+ return { ...OVER_CLASSIFIED };
63
+ const fastEligible = d.t1Eligible && d.effect === 'read' && d.sensitivity === 'public';
64
+ if (fastEligible) {
65
+ return { tier: 'execution-fast', lane: 'fast', risk: d.risk, toolScope: [d.selector.toLowerCase()] };
66
+ }
67
+ return {
68
+ tier: 'execution-orchestrated',
69
+ lane: 'orchestrated',
70
+ risk: d.risk ?? 'critical',
71
+ reason: d.sensitivity !== 'public'
72
+ ? 'hard-T2:sensitivity'
73
+ : d.effect !== 'read'
74
+ ? 'hard-T2:effect'
75
+ : 'hard-T2:not-allowlisted',
76
+ };
77
+ }
78
+ //# sourceMappingURL=authority-tier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-tier.js","sourceRoot":"","sources":["../src/authority-tier.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,4GAA4G;AAC5G,yCAAyC;AACzC,EAAE;AACF,gCAAgC;AAChC,0GAA0G;AAC1G,iGAAiG;AACjG,0GAA0G;AAC1G,4GAA4G;AAC5G,mGAAmG;AACnG,oDAAoD;AACpD,6GAA6G;AAC7G,sGAAsG;AACtG,iCAAiC;AACjC,0GAA0G;AAC1G,q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AgC;IAEhC,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACnC,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACjD,CAAC;IACD,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1D,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,GAAG,eAAe,EAAE,CAAC;IACtC,MAAM,YAAY,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC;IACvF,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAS,CAAC,EAAE,CAAC;IAC9G,CAAC;IACD,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,UAAU;QAC1B,MAAM,EACJ,CAAC,CAAC,WAAW,KAAK,QAAQ;YACxB,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBACnB,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,yBAAyB;KAClC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ToolClassification } from './types';
1
+ import type { ToolClassification } from './types.js';
2
2
  export declare function declareTool<T>(def: T, classification: ToolClassification): T & {
3
3
  _classification: ToolClassification;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"classification.d.ts","sourceRoot":"","sources":["../src/classification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,CAAC,EACN,cAAc,EAAE,kBAAkB,GACjC,CAAC,GAAG;IAAE,eAAe,EAAE,kBAAkB,CAAA;CAAE,CAI7C"}
1
+ {"version":3,"file":"classification.d.ts","sourceRoot":"","sources":["../src/classification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,CAAC,EACN,cAAc,EAAE,kBAAkB,GACjC,CAAC,GAAG;IAAE,eAAe,EAAE,kBAAkB,CAAA;CAAE,CAI7C"}
@@ -1,3 +1,3 @@
1
- import type { PolicyContext, PolicyDecision } from './types';
1
+ import type { PolicyContext, PolicyDecision } from './types.js';
2
2
  export declare function evaluatePolicy(ctx: PolicyContext): PolicyDecision;
3
3
  //# sourceMappingURL=decision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../src/decision.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,SAAS,CAAC;AAsDjF,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA4CjE"}
1
+ {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../src/decision.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,YAAY,CAAC;AAsDpF,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA4CjE"}
@@ -1,5 +1,5 @@
1
1
  import type { Address, Hex } from '@agenticprimitives/types';
2
- import type { ExactCallPolicy } from './types';
2
+ import type { ExactCallPolicy } from './types.js';
3
3
  export declare function exactCall(target: Address, selector: Hex, opts?: {
4
4
  calldataHash?: Hex;
5
5
  valueLimit?: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"exact-call.d.ts","sourceRoot":"","sources":["../src/exact-call.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAY/C,wBAAgB,SAAS,CACvB,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,GAAG,EACb,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD,eAAe,CAajB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC/C,MAAM,EAAE,eAAe,GACtB,OAAO,CAeT"}
1
+ {"version":3,"file":"exact-call.d.ts","sourceRoot":"","sources":["../src/exact-call.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAYlD,wBAAgB,SAAS,CACvB,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,GAAG,EACb,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD,eAAe,CAajB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC/C,MAAM,EAAE,eAAe,GACtB,OAAO,CAeT"}
@@ -3,7 +3,7 @@
3
3
  //
4
4
  // Used for critical-tier operations where the user should authorize the
5
5
  // exact intent and nothing else.
6
- import { keccak_256 } from '@noble/hashes/sha3';
6
+ import { keccak_256 } from '@noble/hashes/sha3.js';
7
7
  function keccak256OfHex(hex) {
8
8
  const cleaned = hex.startsWith('0x') ? hex.slice(2) : hex;
9
9
  const bytes = new Uint8Array(cleaned.length / 2);
@@ -1 +1 @@
1
- {"version":3,"file":"exact-call.js","sourceRoot":"","sources":["../src/exact-call.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,qEAAqE;AACrE,EAAE;AACF,wEAAwE;AACxE,iCAAiC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,SAAS,cAAc,CAAC,GAAQ;IAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChG,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,IAAI,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,GAAG;QAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,OAAO,CAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,MAAe,EACf,QAAa,EACb,IAAkD;IAElD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ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
@@ -1,8 +1,12 @@
1
- export { declareTool } from './classification';
2
- export { exactCall, matchesExactCall } from './exact-call';
3
- export { evaluatePolicy } from './decision';
4
- export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier';
5
- export { lintClassification } from './lint';
6
- export { ThresholdTier } from './types';
7
- export type { Address, Hex, RiskTier, ToolClassification, ExactCallPolicy, CaveatLike, DelegationLike, CaveatContext, PolicyContext, PolicyDecision, ThresholdPolicyDecision, LintResult, } from './types';
1
+ export { declareTool } from './classification.js';
2
+ export { exactCall, matchesExactCall } from './exact-call.js';
3
+ export { evaluatePolicy } from './decision.js';
4
+ export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier.js';
5
+ export { lintClassification } from './lint.js';
6
+ export { ThresholdTier } from './types.js';
7
+ export { classifyExchange, computeSkillSelector, buildSkillAuthorityRegistry, } from './authority-tier.js';
8
+ export type { AuthorityTier, ExecLane, SurfaceEffect, SurfaceSensitivity, SurfaceAuthorityDescriptor, SkillAuthorityClass, ClassifyInput, SkillAuthorityRegistry, } from './authority-tier.js';
9
+ export type { Address, Hex, RiskTier, ToolClassification, ExactCallPolicy, CaveatLike, DelegationLike, CaveatContext, PolicyContext, PolicyDecision, ThresholdPolicyDecision, LintResult, } from './types.js';
10
+ export { MINIMUM_AUTHORITY, stepRiskClass, riskAtLeast } from './step-risk.js';
11
+ export type { StepRiskClass, MinimumAuthority } from './step-risk.js';
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAA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,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/E,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -6,11 +6,16 @@
6
6
  // transport SDK (see capability.manifest.json:forbiddenImports for the full
7
7
  // list and docs/architecture/decisions/0003-tool-policy-protocol-agnostic.md
8
8
  // for why).
9
- export { declareTool } from './classification';
10
- export { exactCall, matchesExactCall } from './exact-call';
11
- export { evaluatePolicy } from './decision';
12
- export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier';
13
- export { lintClassification } from './lint';
9
+ export { declareTool } from './classification.js';
10
+ export { exactCall, matchesExactCall } from './exact-call.js';
11
+ export { evaluatePolicy } from './decision.js';
12
+ export { clampTtlForRiskTier, requiredCaveatsForRiskTier, evaluateThresholdPolicy, RISK_TIER_REQUIREMENTS, } from './risk-tier.js';
13
+ export { lintClassification } from './lint.js';
14
14
  // ThresholdTier is an enum (value export, not type-only).
15
- export { ThresholdTier } from './types';
15
+ export { ThresholdTier } from './types.js';
16
+ // Authority-tier classification (spec 316 §3a/§(c)) — the ONE server-authoritative source the fabric
17
+ // ingress gate and the mcp-runtime delegation gate both read to pick the execution LANE. Fail-closed.
18
+ export { classifyExchange, computeSkillSelector, buildSkillAuthorityRegistry, } from './authority-tier.js';
19
+ // ─── Spec 350 §3.4 — per-step risk → minimum authority ───────────────────────────────────────────────
20
+ export { MINIMUM_AUTHORITY, stepRiskClass, riskAtLeast } from './step-risk.js';
16
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,4DAA4D;AAC5D,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,YAAY;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,4DAA4D;AAC5D,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,YAAY;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,qGAAqG;AACrG,sGAAsG;AACtG,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AA2B7B,wGAAwG;AACxG,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/lint.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { LintResult } from './types';
1
+ import type { LintResult } from './types.js';
2
2
  interface LintOpts {
3
3
  srcDir: string;
4
4
  requiredTags: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAgBD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CA4B5E"}
1
+ {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAgBD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CA4B5E"}
@@ -1,4 +1,4 @@
1
- import type { RiskTier, ToolClassification, ThresholdPolicyDecision } from './types';
1
+ import type { RiskTier, ToolClassification, ThresholdPolicyDecision } from './types.js';
2
2
  export declare function clampTtlForRiskTier(requestedTtlSec: number, risk: RiskTier): number;
3
3
  export declare function requiredCaveatsForRiskTier(risk: RiskTier): string[];
4
4
  export declare const RISK_TIER_REQUIREMENTS: Record<RiskTier, ThresholdPolicyDecision>;
@@ -1 +1 @@
1
- {"version":3,"file":"risk-tier.d.ts","sourceRoot":"","sources":["../src/risk-tier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAiBjB,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAMnF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAEnE;AAqBD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAyB5E,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,kBAAkB,GACjC,uBAAuB,CAGzB"}
1
+ {"version":3,"file":"risk-tier.d.ts","sourceRoot":"","sources":["../src/risk-tier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAiBpB,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAMnF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAEnE;AAqBD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAyB5E,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,kBAAkB,GACjC,uBAAuB,CAGzB"}
package/dist/risk-tier.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Risk-tier helpers. The taxonomy is the binding contract — these helpers
2
2
  // surface "what should issuance demand for this tier."
3
- import { ThresholdTier } from './types';
3
+ import { ThresholdTier } from './types.js';
4
4
  const TTL_CLAMP_SECONDS = {
5
5
  low: 7 * 24 * 60 * 60, // 7 days
6
6
  medium: 7 * 24 * 60 * 60, // 7 days
@@ -1 +1 @@
1
- {"version":3,"file":"risk-tier.js","sourceRoot":"","sources":["../src/risk-tier.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uDAAuD;AAOvD,OAAO,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K;QACzB,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,IAAI;QAChB,uBAAuB,EAAE,KAAK;KAC/B;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,aAAa,CAAC,KAAK;QACzB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,IAAI;QAChB,uBAAuB,EAAE,KAAK;KAC/B;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,aAAa,CAAC,KAAK;QACzB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,IAAI;QAChB,uBAAuB,EAAE,IAAI;KAC9B;CACF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CACrC,cAAkC;IAElC,MAAM,IAAI,GAAG,cAAc,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC;IACtD,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { RiskTier } from './types.js';
2
+ /** A step's risk: `informational` when it exercises no capability, else its tool's `RiskTier`. */
3
+ export type StepRiskClass = 'informational' | RiskTier;
4
+ /** The obligations a risk class imposes BEFORE execution, over and above a valid mandate. */
5
+ export interface MinimumAuthority {
6
+ /** Is a mandate required at all? False only for `informational`. */
7
+ mandate: boolean;
8
+ /** Must the step carry an idempotency key (a retry of a mutation is not a re-read)? */
9
+ idempotencyKey: boolean;
10
+ /** Obligation kinds the policy layer attaches. Names, not implementations — a `PolicyEvaluator`
11
+ * turns them into concrete `Obligation`s with who may discharge them. */
12
+ obligations: ReadonlyArray<'second-party-approval' | 'quorum' | 'fresh-authorization'>;
13
+ }
14
+ /**
15
+ * The DEFAULT ladder. A granting agent's own policy (an org's membership policy, a treasury's spend
16
+ * policy) may add to it and never subtract from it — the evaluator composes, it does not override.
17
+ *
18
+ * informational read; no consequence → nothing
19
+ * low reversible mutation → mandate
20
+ * medium significant mutation → mandate + idempotency key
21
+ * high financial / legal / external → + second-party approval
22
+ * critical irreversible / high-impact → + quorum + fresh authorization
23
+ */
24
+ export declare const MINIMUM_AUTHORITY: Readonly<Record<StepRiskClass, MinimumAuthority>>;
25
+ /** Derive a step's risk class from what its tool declares. No capability ⇒ informational, whatever the
26
+ * planner said — a plan cannot lower a risk, and it cannot raise one into needing authority either. */
27
+ export declare function stepRiskClass(tool: {
28
+ capability?: unknown;
29
+ risk?: RiskTier;
30
+ }): StepRiskClass;
31
+ /** Is `a` at least as risky as `b`? For "an irreversible step imposes at least what a high one does". */
32
+ export declare function riskAtLeast(a: StepRiskClass, b: StepRiskClass): boolean;
33
+ //# sourceMappingURL=step-risk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-risk.d.ts","sourceRoot":"","sources":["../src/step-risk.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,kGAAkG;AAClG,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEvD,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,uFAAuF;IACvF,cAAc,EAAE,OAAO,CAAC;IACxB;8EAC0E;IAC1E,WAAW,EAAE,aAAa,CAAC,uBAAuB,GAAG,QAAQ,GAAG,qBAAqB,CAAC,CAAC;CACxF;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAM/E,CAAC;AAEF;wGACwG;AACxG,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAE,GAAG,aAAa,CAG5F;AAGD,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAEvE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The DEFAULT ladder. A granting agent's own policy (an org's membership policy, a treasury's spend
3
+ * policy) may add to it and never subtract from it — the evaluator composes, it does not override.
4
+ *
5
+ * informational read; no consequence → nothing
6
+ * low reversible mutation → mandate
7
+ * medium significant mutation → mandate + idempotency key
8
+ * high financial / legal / external → + second-party approval
9
+ * critical irreversible / high-impact → + quorum + fresh authorization
10
+ */
11
+ export const MINIMUM_AUTHORITY = {
12
+ informational: { mandate: false, idempotencyKey: false, obligations: [] },
13
+ low: { mandate: true, idempotencyKey: false, obligations: [] },
14
+ medium: { mandate: true, idempotencyKey: true, obligations: [] },
15
+ high: { mandate: true, idempotencyKey: true, obligations: ['second-party-approval'] },
16
+ critical: { mandate: true, idempotencyKey: true, obligations: ['second-party-approval', 'quorum', 'fresh-authorization'] },
17
+ };
18
+ /** Derive a step's risk class from what its tool declares. No capability ⇒ informational, whatever the
19
+ * planner said — a plan cannot lower a risk, and it cannot raise one into needing authority either. */
20
+ export function stepRiskClass(tool) {
21
+ if (!tool.capability)
22
+ return 'informational';
23
+ return tool.risk ?? 'low';
24
+ }
25
+ const ORDER = ['informational', 'low', 'medium', 'high', 'critical'];
26
+ /** Is `a` at least as risky as `b`? For "an irreversible step imposes at least what a high one does". */
27
+ export function riskAtLeast(a, b) {
28
+ return ORDER.indexOf(a) >= ORDER.indexOf(b);
29
+ }
30
+ //# sourceMappingURL=step-risk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-risk.js","sourceRoot":"","sources":["../src/step-risk.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsD;IAClF,aAAa,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE;IACzE,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE;IAC9D,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE;IAChE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,uBAAuB,CAAC,EAAE;IACrF,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,uBAAuB,EAAE,QAAQ,EAAE,qBAAqB,CAAC,EAAE;CAC3H,CAAC;AAEF;wGACwG;AACxG,MAAM,UAAU,aAAa,CAAC,IAA+C;IAC3E,IAAI,CAAC,IAAI,CAAC,UAAU;QAAE,OAAO,eAAe,CAAC;IAC7C,OAAO,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC;AAC5B,CAAC;AAED,MAAM,KAAK,GAAoB,CAAC,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AACtF,yGAAyG;AACzG,MAAM,UAAU,WAAW,CAAC,CAAgB,EAAE,CAAgB;IAC5D,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC"}
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@agenticprimitives/tool-policy",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.41",
4
4
  "description": "Protocol-agnostic classification, risk tiers, and exact-call policy. Consumable by MCP, A2A, LangGraph, and Vercel AI tool runtimes.",
5
+ "homepage": "https://agenticprimitives.dev",
6
+ "bugs": {
7
+ "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
8
+ },
9
+ "author": {
10
+ "name": "Agentic Trust Labs",
11
+ "url": "https://agenticprimitives.dev"
12
+ },
5
13
  "license": "MIT",
6
14
  "repository": {
7
15
  "type": "git",
8
16
  "url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
9
17
  "directory": "packages/tool-policy"
10
18
  },
11
- "homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/tool-policy",
12
- "bugs": {
13
- "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
14
- },
15
19
  "type": "module",
16
20
  "main": "./dist/index.js",
17
21
  "types": "./dist/index.d.ts",
@@ -35,14 +39,14 @@
35
39
  "access": "public"
36
40
  },
37
41
  "dependencies": {
38
- "@noble/hashes": "^1.5.0"
42
+ "@noble/hashes": "^2.2.0"
39
43
  },
40
44
  "peerDependencies": {
41
- "@agenticprimitives/types": "1.0.0-alpha.4"
45
+ "@agenticprimitives/types": "^1.0.0-alpha.41"
42
46
  },
43
47
  "devDependencies": {
44
48
  "@types/node": "^22.7.0",
45
- "vitest": "^2.1.0"
49
+ "vitest": "^4.1.11"
46
50
  },
47
51
  "keywords": [
48
52
  "policy",
@@ -50,13 +54,18 @@
50
54
  "risk-tier",
51
55
  "exact-call",
52
56
  "agentic",
53
- "tool-policy"
57
+ "tool-policy",
58
+ "agentic-primitives",
59
+ "agenticprimitives",
60
+ "ai-agents",
61
+ "agent-authority",
62
+ "agentic-trust"
54
63
  ],
55
64
  "scripts": {
56
65
  "build": "tsc -p tsconfig.build.json",
57
66
  "typecheck": "tsc -p tsconfig.json --noEmit",
58
67
  "test": "vitest run",
59
- "test:unit": "vitest run test/unit",
68
+ "test:unit": "vitest run test/unit --passWithNoTests",
60
69
  "test:integration": "vitest run test/integration --passWithNoTests",
61
70
  "test:watch": "vitest",
62
71
  "clean": "rm -rf dist"