@agenticprimitives/tool-policy 1.0.0-alpha.22 → 1.0.0-alpha.23
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/step-risk.d.ts +33 -0
- package/dist/step-risk.d.ts.map +1 -0
- package/dist/step-risk.js +30 -0
- package/dist/step-risk.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export { ThresholdTier } from './types.js';
|
|
|
7
7
|
export { classifyExchange, computeSkillSelector, buildSkillAuthorityRegistry, } from './authority-tier.js';
|
|
8
8
|
export type { AuthorityTier, ExecLane, SurfaceEffect, SurfaceSensitivity, SurfaceAuthorityDescriptor, SkillAuthorityClass, ClassifyInput, SkillAuthorityRegistry, } from './authority-tier.js';
|
|
9
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';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,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,gB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EAClB,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/E,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,4 +16,6 @@ export { ThresholdTier } from './types.js';
|
|
|
16
16
|
// Authority-tier classification (spec 316 §3a/§(c)) — the ONE server-authoritative source the fabric
|
|
17
17
|
// ingress gate and the mcp-runtime delegation gate both read to pick the execution LANE. Fail-closed.
|
|
18
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';
|
|
19
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,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"}
|
|
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"}
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticprimitives/tool-policy",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
4
|
"description": "Protocol-agnostic classification, risk tiers, and exact-call policy. Consumable by MCP, A2A, LangGraph, and Vercel AI tool runtimes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@noble/hashes": "^2.2.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@agenticprimitives/types": "1.0.0-alpha.
|
|
41
|
+
"@agenticprimitives/types": "1.0.0-alpha.23"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^22.7.0",
|