@aithorized/core 0.1.1 → 0.1.3
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 -2
- package/dist/index.js +1 -1
- package/dist/policy/browser.d.ts +2 -2
- package/dist/policy/browser.js +1 -1
- package/dist/policy/evaluate.js +4 -0
- package/dist/policy/pause.d.ts +3 -2
- package/dist/policy/pause.js +7 -0
- package/dist/policy/types.d.ts +11 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,12 +13,12 @@ export { DECISION_DOMAIN, ACTION_DOMAIN, HTTP_DOMAIN, WS_DOMAIN, ENROLL_DOMAIN,
|
|
|
13
13
|
export { RISK_ORDER, MIN_TTL_SECONDS, MAX_TTL_SECONDS, clampTtl, evaluatePolicy } from './policy/evaluate.js';
|
|
14
14
|
export { toolMatches, argMatches, ruleMatches, compilePolicyRegex } from './policy/match.js';
|
|
15
15
|
export { mergePolicies, strictnessOf } from './policy/merge.js';
|
|
16
|
-
export { activePause, assertPauseLimits, MAX_PAUSE_MS } from './policy/pause.js';
|
|
16
|
+
export { activePause, assertPauseLimits, MAX_PAUSE_MS, PAUSE_MODES } from './policy/pause.js';
|
|
17
17
|
export type { MergeOptions } from './policy/merge.js';
|
|
18
18
|
export { STALE_AFTER_MS, verifyBundle, pinnedKeyFor, bundleStateFromVerification, assertOk, bundleSigningContent } from './policy/bundle.js';
|
|
19
19
|
export type { BundleStatus, BundleVerification, PinnedPolicyKey, PinnedPolicyKeys } from './policy/bundle.js';
|
|
20
20
|
export { loadPolicyYaml, parsePolicyJson, validateRules } from './policy/load.js';
|
|
21
|
-
export type { RiskLevel, Effect, UnmatchedDefault, ArgPredicate, RuleMatch, PolicyRule, PolicyDefaults, PolicyDocument, AutoRule, Pause, PolicyBundle, EffectivePolicy, EvalInput, EvalFlags, EvalReason, EvalResult } from './policy/types.js';
|
|
21
|
+
export type { RiskLevel, Effect, UnmatchedDefault, ArgPredicate, RuleMatch, PolicyRule, PolicyDefaults, PolicyDocument, AutoRule, Pause, PauseMode, PolicyBundle, EffectivePolicy, EvalInput, EvalFlags, EvalReason, EvalResult } from './policy/types.js';
|
|
22
22
|
export { CLOCK_SKEW_ALLOWANCE_MS, MAX_CREATE_ATTEMPTS, createLocalDeadline, shouldRetryCreate, awaitResolutionBeforeDeadline } from './lifecycle/deadline.js';
|
|
23
23
|
export type { LocalDeadline } from './lifecycle/deadline.js';
|
|
24
24
|
export { verifyDecisionBundle, keyClassCanDecide, KEY_CLASSES, DIRECTORY_DOMAIN, directorySigningInput, verifyDirectory } from './lifecycle/verify.js';
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { DECISION_DOMAIN, ACTION_DOMAIN, HTTP_DOMAIN, WS_DOMAIN, ENROLL_DOMAIN,
|
|
|
12
12
|
export { RISK_ORDER, MIN_TTL_SECONDS, MAX_TTL_SECONDS, clampTtl, evaluatePolicy } from './policy/evaluate.js';
|
|
13
13
|
export { toolMatches, argMatches, ruleMatches, compilePolicyRegex } from './policy/match.js';
|
|
14
14
|
export { mergePolicies, strictnessOf } from './policy/merge.js';
|
|
15
|
-
export { activePause, assertPauseLimits, MAX_PAUSE_MS } from './policy/pause.js';
|
|
15
|
+
export { activePause, assertPauseLimits, MAX_PAUSE_MS, PAUSE_MODES } from './policy/pause.js';
|
|
16
16
|
export { STALE_AFTER_MS, verifyBundle, pinnedKeyFor, bundleStateFromVerification, assertOk, bundleSigningContent } from './policy/bundle.js';
|
|
17
17
|
export { loadPolicyYaml, parsePolicyJson, validateRules } from './policy/load.js';
|
|
18
18
|
export { CLOCK_SKEW_ALLOWANCE_MS, MAX_CREATE_ATTEMPTS, createLocalDeadline, shouldRetryCreate, awaitResolutionBeforeDeadline } from './lifecycle/deadline.js';
|
package/dist/policy/browser.d.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
export { loadPolicyYaml, parsePolicyJson, validateRules } from './load.js';
|
|
6
6
|
export { evaluatePolicy, clampTtl, MIN_TTL_SECONDS, MAX_TTL_SECONDS, RISK_ORDER } from './evaluate.js';
|
|
7
7
|
export { toolMatches, argMatches, ruleMatches } from './match.js';
|
|
8
|
-
export { activePause, MAX_PAUSE_MS } from './pause.js';
|
|
8
|
+
export { activePause, MAX_PAUSE_MS, PAUSE_MODES } from './pause.js';
|
|
9
9
|
export { PolicyError } from '../errors.js';
|
|
10
|
-
export type { ArgPredicate, AutoRule, Effect, EffectivePolicy, EvalFlags, EvalInput, EvalReason, EvalResult, Pause, PolicyDefaults, PolicyDocument, PolicyRule, RiskLevel, RuleMatch, UnmatchedDefault } from './types.js';
|
|
10
|
+
export type { ArgPredicate, AutoRule, Effect, EffectivePolicy, EvalFlags, EvalInput, EvalReason, EvalResult, Pause, PauseMode, PolicyDefaults, PolicyDocument, PolicyRule, RiskLevel, RuleMatch, UnmatchedDefault } from './types.js';
|
package/dist/policy/browser.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
export { loadPolicyYaml, parsePolicyJson, validateRules } from './load.js';
|
|
6
6
|
export { evaluatePolicy, clampTtl, MIN_TTL_SECONDS, MAX_TTL_SECONDS, RISK_ORDER } from './evaluate.js';
|
|
7
7
|
export { toolMatches, argMatches, ruleMatches } from './match.js';
|
|
8
|
-
export { activePause, MAX_PAUSE_MS } from './pause.js';
|
|
8
|
+
export { activePause, MAX_PAUSE_MS, PAUSE_MODES } from './pause.js';
|
|
9
9
|
export { PolicyError } from '../errors.js';
|
package/dist/policy/evaluate.js
CHANGED
|
@@ -115,6 +115,10 @@ export function evaluatePolicy(policy, input, flags = {}) {
|
|
|
115
115
|
if (observeRule) {
|
|
116
116
|
return { effect: 'OBSERVE', reason: 'OBSERVE_RULE', ruleId: observeRule.id, degraded };
|
|
117
117
|
}
|
|
118
|
+
const allowRule = firstMatchingRule(rules, (r) => r.effect === 'ALLOW' && ruleMatches(r.match, input));
|
|
119
|
+
if (allowRule) {
|
|
120
|
+
return { effect: 'ALLOW', reason: 'ALLOW_RULE', ruleId: allowRule.id, degraded };
|
|
121
|
+
}
|
|
118
122
|
const unmatched = policy.defaults.unmatched;
|
|
119
123
|
if (unmatched === 'ALLOW') {
|
|
120
124
|
return { effect: 'ALLOW', reason: 'DEFAULT', degraded };
|
package/dist/policy/pause.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { EffectivePolicy, Pause } from './types.js';
|
|
1
|
+
import type { EffectivePolicy, Pause, PauseMode } from './types.js';
|
|
2
2
|
/** A pause lasts at most this long after it is set (like a temporary auto-approval, docs/05 T-08). */
|
|
3
3
|
export declare const MAX_PAUSE_MS: number;
|
|
4
|
+
export declare const PAUSE_MODES: readonly PauseMode[];
|
|
4
5
|
/**
|
|
5
6
|
* The pause in force for `agentId` at `nowMs`, if any. Only a pause carried by a valid signed bundle counts: a
|
|
6
7
|
* degraded policy (stale, invalid or missing bundle) is never paused, and a pause scoped to agents does not
|
|
@@ -8,4 +9,4 @@ export declare const MAX_PAUSE_MS: number;
|
|
|
8
9
|
*/
|
|
9
10
|
export declare function activePause(policy: EffectivePolicy, agentId: string | undefined, nowMs: number): Pause | undefined;
|
|
10
11
|
/** Server-side limits on a new pause: a valid `until`, in the future and at most 24 h away. */
|
|
11
|
-
export declare function assertPauseLimits(pause: Pick<Pause, 'until' | 'agentIds'>, nowMs: number): void;
|
|
12
|
+
export declare function assertPauseLimits(pause: Pick<Pause, 'until' | 'agentIds' | 'mode' | 'includeCritical'>, nowMs: number): void;
|
package/dist/policy/pause.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PolicyError } from '../errors.js';
|
|
2
2
|
/** A pause lasts at most this long after it is set (like a temporary auto-approval, docs/05 T-08). */
|
|
3
3
|
export const MAX_PAUSE_MS = 24 * 60 * 60 * 1000;
|
|
4
|
+
export const PAUSE_MODES = ['PASSTHROUGH', 'AUTO_APPROVE', 'AUTO_DENY'];
|
|
4
5
|
/**
|
|
5
6
|
* The pause in force for `agentId` at `nowMs`, if any. Only a pause carried by a valid signed bundle counts: a
|
|
6
7
|
* degraded policy (stale, invalid or missing bundle) is never paused, and a pause scoped to agents does not
|
|
@@ -31,4 +32,10 @@ export function assertPauseLimits(pause, nowMs) {
|
|
|
31
32
|
if (pause.agentIds !== undefined && (!Array.isArray(pause.agentIds) || pause.agentIds.some((a) => typeof a !== 'string'))) {
|
|
32
33
|
throw new PolicyError('POLICY_INVALID', 'pause: agentIds must be a list of agent ids');
|
|
33
34
|
}
|
|
35
|
+
if (pause.mode !== undefined && !PAUSE_MODES.includes(pause.mode)) {
|
|
36
|
+
throw new PolicyError('POLICY_INVALID', `pause: invalid mode ${String(pause.mode)}`);
|
|
37
|
+
}
|
|
38
|
+
if (pause.includeCritical !== undefined && typeof pause.includeCritical !== 'boolean') {
|
|
39
|
+
throw new PolicyError('POLICY_INVALID', 'pause: includeCritical must be a boolean');
|
|
40
|
+
}
|
|
34
41
|
}
|
package/dist/policy/types.d.ts
CHANGED
|
@@ -65,11 +65,14 @@ export interface AutoRule {
|
|
|
65
65
|
/** Uses consumed so far (supplied by the caller; 0 by default). */
|
|
66
66
|
uses?: number;
|
|
67
67
|
}
|
|
68
|
+
export type PauseMode = 'PASSTHROUGH' | 'AUTO_APPROVE' | 'AUTO_DENY';
|
|
68
69
|
/**
|
|
69
|
-
* A human-signed pause of the guardrail (replaces the local kill-switch file of spec 005). Set only by a
|
|
70
|
+
* A human-signed pause or temporary override of the guardrail (replaces the local kill-switch file of spec 005). Set only by a
|
|
70
71
|
* STRONG-signed `pause.activate` from an OWNER or ADMIN phone, carried in the signed bundle, never in a policy
|
|
71
|
-
* document (so no YAML, dashboard edit or local policy can add one). While active for an agent,
|
|
72
|
-
*
|
|
72
|
+
* document (so no YAML, dashboard edit or local policy can add one). While active for an agent, `PASSTHROUGH`
|
|
73
|
+
* (the default) lets calls through ungated, `AUTO_APPROVE` approves `REQUIRE_APPROVAL` calls (respecting `DENY` and,
|
|
74
|
+
* unless `includeCritical` is true, `CRITICAL`), and `AUTO_DENY` blocks `REQUIRE_APPROVAL` calls without revoking keys.
|
|
75
|
+
* It ends at `until` (at most 24 h after it was set) or when resumed.
|
|
73
76
|
*/
|
|
74
77
|
export interface Pause {
|
|
75
78
|
id: string;
|
|
@@ -79,6 +82,10 @@ export interface Pause {
|
|
|
79
82
|
agentIds?: string[];
|
|
80
83
|
/** User who signed it. */
|
|
81
84
|
by?: string;
|
|
85
|
+
/** Temporary override mode. Absent means `'PASSTHROUGH'`. */
|
|
86
|
+
mode?: PauseMode;
|
|
87
|
+
/** Only for `mode === 'AUTO_APPROVE'`: whether CRITICAL calls are also auto-approved (default false). */
|
|
88
|
+
includeCritical?: boolean;
|
|
82
89
|
}
|
|
83
90
|
/** Signed policy bundle as returned by GET /v1/policies/bundle. */
|
|
84
91
|
export interface PolicyBundle extends PolicyDocument {
|
|
@@ -115,7 +122,7 @@ export interface EvalFlags {
|
|
|
115
122
|
/** Circuit breaker state of the agent. */
|
|
116
123
|
breakerState?: 'ACTIVE' | 'FROZEN';
|
|
117
124
|
}
|
|
118
|
-
export type EvalReason = 'KILL_SWITCH' | 'CIRCUIT_BREAKER' | 'DENY_RULE' | 'AUTO_RULE' | 'APPROVAL_RULE' | 'OBSERVE_RULE' | 'DEFAULT';
|
|
125
|
+
export type EvalReason = 'KILL_SWITCH' | 'CIRCUIT_BREAKER' | 'DENY_RULE' | 'AUTO_RULE' | 'APPROVAL_RULE' | 'OBSERVE_RULE' | 'ALLOW_RULE' | 'DEFAULT';
|
|
119
126
|
export interface EvalResult {
|
|
120
127
|
effect: Effect;
|
|
121
128
|
reason: EvalReason;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aithorized/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Deterministic crypto core and policy engine for aithorized (JCS RFC 8785, payload hashing, domain-separated ECDSA/Ed25519 signatures, fail-closed policy evaluation).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|