@vorim/sdk 3.6.0 → 3.6.1
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/CHANGELOG.md +35 -0
- package/dist/_runtime-gate-DZQTkw4J.d.cts +11 -0
- package/dist/_runtime-gate-DZQTkw4J.d.ts +11 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -233
- package/dist/index.d.ts +3 -233
- package/dist/index.js +1 -1
- package/dist/integrations/anthropic.cjs +38 -9
- package/dist/integrations/anthropic.cjs.map +1 -1
- package/dist/integrations/anthropic.d.cts +17 -1
- package/dist/integrations/anthropic.d.ts +17 -1
- package/dist/integrations/anthropic.js +38 -9
- package/dist/integrations/anthropic.js.map +1 -1
- package/dist/integrations/crewai.d.cts +2 -1
- package/dist/integrations/crewai.d.ts +2 -1
- package/dist/integrations/langchain.cjs +9 -10
- package/dist/integrations/langchain.cjs.map +1 -1
- package/dist/integrations/langchain.d.cts +9 -1
- package/dist/integrations/langchain.d.ts +9 -1
- package/dist/integrations/langchain.js +9 -10
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/integrations/langgraph.cjs +200 -0
- package/dist/integrations/langgraph.cjs.map +1 -0
- package/dist/integrations/langgraph.d.cts +20 -0
- package/dist/integrations/langgraph.d.ts +20 -0
- package/dist/integrations/langgraph.js +162 -0
- package/dist/integrations/langgraph.js.map +1 -0
- package/dist/integrations/llamaindex.d.cts +2 -1
- package/dist/integrations/llamaindex.d.ts +2 -1
- package/dist/integrations/openai.cjs +38 -9
- package/dist/integrations/openai.cjs.map +1 -1
- package/dist/integrations/openai.d.cts +17 -1
- package/dist/integrations/openai.d.ts +17 -1
- package/dist/integrations/openai.js +38 -9
- package/dist/integrations/openai.js.map +1 -1
- package/dist/integrations/siem.cjs +128 -0
- package/dist/integrations/siem.cjs.map +1 -0
- package/dist/integrations/siem.d.cts +57 -0
- package/dist/integrations/siem.d.ts +57 -0
- package/dist/integrations/siem.js +102 -0
- package/dist/integrations/siem.js.map +1 -0
- package/dist/integrations/stripe-acp.cjs +179 -0
- package/dist/integrations/stripe-acp.cjs.map +1 -0
- package/dist/integrations/stripe-acp.d.cts +69 -0
- package/dist/integrations/stripe-acp.d.ts +69 -0
- package/dist/integrations/stripe-acp.js +153 -0
- package/dist/integrations/stripe-acp.js.map +1 -0
- package/dist/integrations/vercel-ai.cjs +252 -0
- package/dist/integrations/vercel-ai.cjs.map +1 -0
- package/dist/integrations/vercel-ai.d.cts +67 -0
- package/dist/integrations/vercel-ai.d.ts +67 -0
- package/dist/integrations/vercel-ai.js +214 -0
- package/dist/integrations/vercel-ai.js.map +1 -0
- package/dist/types-B22WnXEW.d.cts +234 -0
- package/dist/types-B22WnXEW.d.ts +234 -0
- package/package.json +41 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog — @vorim/sdk
|
|
2
2
|
|
|
3
|
+
## 3.6.1
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Runtime `escalate` no longer fails closed silently.** The Vercel AI, OpenAI,
|
|
8
|
+
and Anthropic tool wrappers treated an `escalate` runtime verdict as a denial,
|
|
9
|
+
hard-failing every human-in-the-loop flow. They now resolve escalations via a
|
|
10
|
+
new `onEscalation` option:
|
|
11
|
+
- `wait` (default) — block and poll `waitForDecisionResolution`; proceed on a
|
|
12
|
+
human approval, fail **closed** on denial or timeout. Requires the
|
|
13
|
+
`runtime:decide` scope.
|
|
14
|
+
- `deny` — fail closed without waiting.
|
|
15
|
+
- `allow` — proceed (explicit fail-open; dev/trusted use only).
|
|
16
|
+
Add `escalationTimeoutMs` to bound the wait (default 300000).
|
|
17
|
+
- **SIEM forwarder no longer crashes on a malformed `timestamp`.** A bad ISO
|
|
18
|
+
string previously threw `BigInt(NaN)` on the OTLP path (killing the batch) and
|
|
19
|
+
produced null/garbage timestamps on Splunk/Elasticsearch. All sinks now fall
|
|
20
|
+
back to `now()` on a missing/invalid timestamp.
|
|
21
|
+
- **LangChain audit durability.** `emitAudit` honoured `asyncAudit` as a no-op
|
|
22
|
+
(always fire-and-forget); `asyncAudit: false` now actually awaits persistence.
|
|
23
|
+
- SIEM `auditEventToOtel` substitutes placeholders instead of emitting
|
|
24
|
+
`undefined` in the log body when a direct caller omits required fields.
|
|
25
|
+
|
|
26
|
+
## 3.6.0
|
|
27
|
+
|
|
28
|
+
### Added — new framework integrations
|
|
29
|
+
|
|
30
|
+
- **Vercel AI SDK** (`@vorim/sdk/integrations/vercel-ai`) — `wrapVercelTool` /
|
|
31
|
+
`wrapVercelTools` gate each tool call and sign the audit trail.
|
|
32
|
+
- **LangGraph** (`@vorim/sdk/integrations/langgraph`) — `wrapGraphTool` /
|
|
33
|
+
`wrapGraphTools`, framework-tagged `langgraph`.
|
|
34
|
+
- **SIEM forwarder** (`@vorim/sdk/integrations/siem`) — `createSiemForwarder`
|
|
35
|
+
ships audit events to OTLP/HTTP, Splunk HEC, or Elasticsearch.
|
|
36
|
+
- LangChain wrapper gained a configurable `framework` tag.
|
|
37
|
+
|
|
3
38
|
## 3.5.0
|
|
4
39
|
|
|
5
40
|
### Added — Runtime Control (gate actions before they happen)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a framework integration should treat a runtime `escalate` verdict.
|
|
3
|
+
* - `wait` — block and poll {@link VorimSDK.waitForDecisionResolution} until a
|
|
4
|
+
* human approves/denies (or the timeout elapses → deny). The correct
|
|
5
|
+
* default for human-in-the-loop: an escalation means "ask a human".
|
|
6
|
+
* - `deny` — treat escalate as a denial (fail closed without waiting).
|
|
7
|
+
* - `allow` — treat escalate as allowed (fail OPEN — only for trusted/dev use).
|
|
8
|
+
*/
|
|
9
|
+
type EscalationPolicy = 'wait' | 'deny' | 'allow';
|
|
10
|
+
|
|
11
|
+
export type { EscalationPolicy as E };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a framework integration should treat a runtime `escalate` verdict.
|
|
3
|
+
* - `wait` — block and poll {@link VorimSDK.waitForDecisionResolution} until a
|
|
4
|
+
* human approves/denies (or the timeout elapses → deny). The correct
|
|
5
|
+
* default for human-in-the-loop: an escalation means "ask a human".
|
|
6
|
+
* - `deny` — treat escalate as a denial (fail closed without waiting).
|
|
7
|
+
* - `allow` — treat escalate as allowed (fail OPEN — only for trusted/dev use).
|
|
8
|
+
*/
|
|
9
|
+
type EscalationPolicy = 'wait' | 'deny' | 'allow';
|
|
10
|
+
|
|
11
|
+
export type { EscalationPolicy as E };
|
package/dist/index.cjs
CHANGED
|
@@ -117,7 +117,7 @@ async function prepareReplayContext(inputs) {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// src/index.ts
|
|
120
|
-
var SDK_VERSION = true ? "3.6.
|
|
120
|
+
var SDK_VERSION = true ? "3.6.1" : "0.0.0";
|
|
121
121
|
var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
|
|
122
122
|
function sleep(ms) {
|
|
123
123
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
package/dist/index.d.cts
CHANGED
|
@@ -1,235 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
agent_id: string;
|
|
5
|
-
org_id: string;
|
|
6
|
-
owner_user_id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
status: AgentStatus;
|
|
10
|
-
key_fingerprint: string;
|
|
11
|
-
trust_score: number;
|
|
12
|
-
capabilities: string[];
|
|
13
|
-
metadata: Record<string, unknown>;
|
|
14
|
-
expires_at?: string;
|
|
15
|
-
created_at: string;
|
|
16
|
-
updated_at: string;
|
|
17
|
-
revoked_at?: string;
|
|
18
|
-
revoked_by?: string;
|
|
19
|
-
}
|
|
20
|
-
interface AgentRegistrationInput {
|
|
21
|
-
name: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
capabilities: string[];
|
|
24
|
-
scopes: PermissionScope[];
|
|
25
|
-
}
|
|
26
|
-
interface AgentRegistrationResult {
|
|
27
|
-
agent: Agent;
|
|
28
|
-
private_key: string;
|
|
29
|
-
public_key: string;
|
|
30
|
-
key_fingerprint: string;
|
|
31
|
-
}
|
|
32
|
-
type PermissionScope = 'agent:read' | 'agent:write' | 'agent:execute' | 'agent:transact' | 'agent:communicate' | 'agent:delegate' | 'agent:elevate';
|
|
33
|
-
interface PermissionCheckResult {
|
|
34
|
-
allowed: boolean;
|
|
35
|
-
scope: PermissionScope;
|
|
36
|
-
agent_id: string;
|
|
37
|
-
reason?: string;
|
|
38
|
-
remaining_quota?: number;
|
|
39
|
-
}
|
|
40
|
-
type AuditEventType = 'tool_call' | 'api_request' | 'message_sent' | 'permission_change' | 'status_change' | 'key_rotation' | 'login' | 'export';
|
|
41
|
-
type AuditResult = 'success' | 'denied' | 'error';
|
|
42
|
-
interface AuditEventInput {
|
|
43
|
-
agent_id: string;
|
|
44
|
-
event_type: AuditEventType;
|
|
45
|
-
action: string;
|
|
46
|
-
resource?: string;
|
|
47
|
-
input_hash?: string;
|
|
48
|
-
output_hash?: string;
|
|
49
|
-
permission?: PermissionScope;
|
|
50
|
-
result: AuditResult;
|
|
51
|
-
latency_ms?: number;
|
|
52
|
-
error_code?: string;
|
|
53
|
-
signature?: string;
|
|
54
|
-
metadata?: Record<string, unknown>;
|
|
55
|
-
/**
|
|
56
|
-
* Replayable agent decision evidence (VAIP -02 schema fields).
|
|
57
|
-
*
|
|
58
|
-
* Stored and exported but NOT covered by the v0 canonical signature
|
|
59
|
-
* form. They will enter canonical bytes in v1 (RFC 8785 JCS) in a
|
|
60
|
-
* follow-up release. Until then, advisory.
|
|
61
|
-
*
|
|
62
|
-
* Use the helpers from this package to compute the hashes:
|
|
63
|
-
* - {@link hashToolCatalogue}
|
|
64
|
-
* - {@link hashSystemPrompt}
|
|
65
|
-
*/
|
|
66
|
-
model_version?: string;
|
|
67
|
-
tool_catalogue_hash?: string;
|
|
68
|
-
system_prompt_hash?: string;
|
|
69
|
-
prev_event_hash?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Canonical-form recipe the `signature` was computed over.
|
|
72
|
-
* Absent/null ↔ 'v0' (pipe-joined six-field form). Set to 'v1' for
|
|
73
|
-
* RFC 8785 JCS over the full event minus signature and canonical_form.
|
|
74
|
-
* The SDK sets this automatically when {@link VorimConfig.canonicalForm}
|
|
75
|
-
* is `"v1"`; you can also pass it on a per-event basis.
|
|
76
|
-
*/
|
|
77
|
-
canonical_form?: 'v0' | 'v1';
|
|
78
|
-
/**
|
|
79
|
-
* Per-event delegation context (VAIP -02 § 6). Populated by the
|
|
80
|
-
* server when the emitting agent is acting via a delegation chain;
|
|
81
|
-
* callers may also set these manually for events recorded outside
|
|
82
|
-
* the standard delegation flow. v1 signatures cover these fields.
|
|
83
|
-
*/
|
|
84
|
-
on_behalf_of?: string;
|
|
85
|
-
delegator_agent_id?: string;
|
|
86
|
-
delegation_chain_id?: string;
|
|
87
|
-
delegation_depth?: number;
|
|
88
|
-
/**
|
|
89
|
-
* Runtime-control linkage. When this action was gated through
|
|
90
|
-
* {@link VorimSDK.beforeAction} before being performed, pass the
|
|
91
|
-
* returned `decisionId` here (the SDK maps it to `decision_id` on the
|
|
92
|
-
* wire) so the audit event links back to the runtime decision that
|
|
93
|
-
* authorised it.
|
|
94
|
-
*/
|
|
95
|
-
decision_id?: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Claims structure for one VAIP -02 § 5 delegation link.
|
|
99
|
-
*
|
|
100
|
-
* Each delegation step in a chain is one of these objects, RFC 8785 JCS
|
|
101
|
-
* canonicalised and Ed25519-signed by the delegator. Mirrors the same
|
|
102
|
-
* type in `@vorim/shared-types`; duplicated here so the SDK ships zero
|
|
103
|
-
* runtime dependencies. Byte-equivalence with the shared definition is
|
|
104
|
-
* enforced by the cross-language parity script.
|
|
105
|
-
*/
|
|
106
|
-
interface DelegationLinkClaims {
|
|
107
|
-
v: 0;
|
|
108
|
-
type: 'vaip-delegation-link';
|
|
109
|
-
chain_id: string;
|
|
110
|
-
depth: number;
|
|
111
|
-
delegator: string;
|
|
112
|
-
delegate: string;
|
|
113
|
-
scopes: string[];
|
|
114
|
-
max_chain_depth: number;
|
|
115
|
-
valid_from: string;
|
|
116
|
-
valid_until: string | null;
|
|
117
|
-
parent_link_hash: string | null;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* One step in an agent-to-agent identity delegation chain (VAIP -02 § 5).
|
|
121
|
-
*
|
|
122
|
-
* Returned by {@link VorimSDK.delegateToAgent} and the listing endpoints.
|
|
123
|
-
*/
|
|
124
|
-
interface AgentDelegationRecord {
|
|
125
|
-
/** Internal row id. */
|
|
126
|
-
id: string;
|
|
127
|
-
/** Public chain identifier (format `chain_<32hex>`). Stamped on
|
|
128
|
-
* every audit event in this chain. */
|
|
129
|
-
publicChainId: string;
|
|
130
|
-
/** Organisation id. */
|
|
131
|
-
orgId: string;
|
|
132
|
-
/** Internal DB id of the delegator agent. */
|
|
133
|
-
delegatorAgentId: string;
|
|
134
|
-
/** Internal DB id of the delegate agent. */
|
|
135
|
-
delegateAgentId: string;
|
|
136
|
-
/** Public agent_id of the delegator (e.g. agid_acme_abc). */
|
|
137
|
-
delegatorAgentPublicId: string;
|
|
138
|
-
/** Public agent_id of the delegate. */
|
|
139
|
-
delegateAgentPublicId: string;
|
|
140
|
-
/** Scopes the delegate may exercise. */
|
|
141
|
-
scopesDelegated: string[];
|
|
142
|
-
/** How many further hops the delegate is permitted. */
|
|
143
|
-
maxChainDepth: number;
|
|
144
|
-
/** This step's depth from the root (root delegator step = 1). */
|
|
145
|
-
currentDepth: number;
|
|
146
|
-
/** Active / suspended / revoked / expired. */
|
|
147
|
-
status: 'active' | 'suspended' | 'revoked' | 'expired';
|
|
148
|
-
/** Parent delegation row (null for the root of an identity chain). */
|
|
149
|
-
parentDelegationId: string | null;
|
|
150
|
-
/** Public agent_id of the root principal of this chain. */
|
|
151
|
-
onBehalfOf: string;
|
|
152
|
-
/** ISO8601 creation timestamp. */
|
|
153
|
-
createdAt: string;
|
|
154
|
-
/** Optional ISO8601 expiry. */
|
|
155
|
-
validUntil: string | null;
|
|
156
|
-
}
|
|
157
|
-
interface TrustRecord {
|
|
158
|
-
agent_id: string;
|
|
159
|
-
owner: {
|
|
160
|
-
org_name: string;
|
|
161
|
-
verified: boolean;
|
|
162
|
-
};
|
|
163
|
-
trust_score: number;
|
|
164
|
-
status: AgentStatus;
|
|
165
|
-
created_at: string;
|
|
166
|
-
active_scopes: PermissionScope[];
|
|
167
|
-
key_fingerprint: string;
|
|
168
|
-
revocation_status: boolean;
|
|
169
|
-
last_active?: string;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The verdict a runtime decision can carry.
|
|
173
|
-
*
|
|
174
|
-
* - `allow` — proceed with the action.
|
|
175
|
-
* - `deny` — do NOT perform the action. {@link VorimSDK.beforeAction}
|
|
176
|
-
* throws {@link VorimDeniedError} on this when `throwOnDeny`.
|
|
177
|
-
* - `modify` — proceed, but with `modifiedPayload` instead of the
|
|
178
|
-
* original payload (e.g. PII masked by a policy rule).
|
|
179
|
-
* - `escalate` — a human must approve. Poll
|
|
180
|
-
* {@link VorimSDK.waitForDecisionResolution} for the outcome.
|
|
181
|
-
* - `fallback` — the engine could not decide (timeout / error) and the
|
|
182
|
-
* org's fail-open/closed setting was applied. `isFallback`
|
|
183
|
-
* is true. The SDK also returns this shape locally when the
|
|
184
|
-
* decision API is unreachable and `runtimeFailOpen` is set.
|
|
185
|
-
*/
|
|
186
|
-
type DecisionVerdict = 'allow' | 'deny' | 'modify' | 'escalate' | 'fallback';
|
|
187
|
-
/** Input to {@link VorimSDK.beforeAction}. Always use the public `agid_*` id. */
|
|
188
|
-
interface BeforeActionInput {
|
|
189
|
-
/** Public agent identifier (`agid_*`). UUIDs are accepted but discouraged. */
|
|
190
|
-
agentId: string;
|
|
191
|
-
/** Coarse action category, e.g. `tool_call`, `api_request`. */
|
|
192
|
-
actionType: string;
|
|
193
|
-
/** Specific target, e.g. the tool name `sendEmail`. */
|
|
194
|
-
actionTarget?: string;
|
|
195
|
-
/** The action's arguments. Capped at 64KB serialised by the server. */
|
|
196
|
-
payload?: Record<string, unknown>;
|
|
197
|
-
/** Free-form context the policy engine may match on. */
|
|
198
|
-
context?: Record<string, unknown>;
|
|
199
|
-
/** Permission scope the action requires; checked against the agent's grants. */
|
|
200
|
-
requiredScope?: string;
|
|
201
|
-
/**
|
|
202
|
-
* Idempotency key. Pass the SAME key when retrying a failed request so
|
|
203
|
-
* the server returns the original decision instead of creating a new one.
|
|
204
|
-
*/
|
|
205
|
-
idempotencyKey?: string;
|
|
206
|
-
}
|
|
207
|
-
/** A runtime decision, as returned by {@link VorimSDK.beforeAction}. */
|
|
208
|
-
interface RuntimeDecision {
|
|
209
|
-
/** Server-assigned id. Carry into {@link AuditEventInput.decision_id}. */
|
|
210
|
-
decisionId: string;
|
|
211
|
-
decision: DecisionVerdict;
|
|
212
|
-
reason: string;
|
|
213
|
-
/** The policy rule that produced this decision, or null for defaults. */
|
|
214
|
-
decisionRuleId: string | null;
|
|
215
|
-
/** Present (object) when `decision === 'modify'`; null otherwise. */
|
|
216
|
-
modifiedPayload: Record<string, unknown> | null;
|
|
217
|
-
/** ISO8601 — after this the decision is stale and should not be relied on. */
|
|
218
|
-
expiresAt: string;
|
|
219
|
-
latencyMs: number;
|
|
220
|
-
/** True when the engine fell back (timeout/error/unreachable). */
|
|
221
|
-
isFallback: boolean;
|
|
222
|
-
policyVersion: number;
|
|
223
|
-
/**
|
|
224
|
-
* The human verdict on an escalation, once resolved by an operator:
|
|
225
|
-
* `'approved'`, `'denied'`, or `null` if not (yet) an escalation outcome.
|
|
226
|
-
*
|
|
227
|
-
* When this is set, {@link decision} is already translated for you
|
|
228
|
-
* (`approved` → `'allow'`, `denied` → `'deny'`) so the normal verdict
|
|
229
|
-
* checks work — this field is the raw resolution for callers who want it.
|
|
230
|
-
*/
|
|
231
|
-
escalationResolution: 'approved' | 'denied' | null;
|
|
232
|
-
}
|
|
1
|
+
import { R as RuntimeDecision, b as AgentRegistrationInput, A as AgentRegistrationResult, T as TrustRecord, c as Agent, P as PermissionScope, d as PermissionCheckResult, D as DelegationLinkClaims, e as AgentDelegationRecord, B as BeforeActionInput, a as AuditEventInput } from './types-B22WnXEW.cjs';
|
|
2
|
+
export { f as AgentStatus, g as AuditEventType, h as AuditResult, i as DecisionVerdict } from './types-B22WnXEW.cjs';
|
|
233
3
|
|
|
234
4
|
/**
|
|
235
5
|
* Replayable agent decision evidence helpers.
|
|
@@ -931,4 +701,4 @@ declare class VorimDeniedError extends VorimError {
|
|
|
931
701
|
}
|
|
932
702
|
declare function createVorim(config: VorimConfig): VorimSDK;
|
|
933
703
|
|
|
934
|
-
export {
|
|
704
|
+
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, DelegationLinkClaims, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, canonicalPayloadV0, canonicalPayloadV1, createVorim as default, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, jcsCanonicalise, prepareReplayContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,235 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
agent_id: string;
|
|
5
|
-
org_id: string;
|
|
6
|
-
owner_user_id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
status: AgentStatus;
|
|
10
|
-
key_fingerprint: string;
|
|
11
|
-
trust_score: number;
|
|
12
|
-
capabilities: string[];
|
|
13
|
-
metadata: Record<string, unknown>;
|
|
14
|
-
expires_at?: string;
|
|
15
|
-
created_at: string;
|
|
16
|
-
updated_at: string;
|
|
17
|
-
revoked_at?: string;
|
|
18
|
-
revoked_by?: string;
|
|
19
|
-
}
|
|
20
|
-
interface AgentRegistrationInput {
|
|
21
|
-
name: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
capabilities: string[];
|
|
24
|
-
scopes: PermissionScope[];
|
|
25
|
-
}
|
|
26
|
-
interface AgentRegistrationResult {
|
|
27
|
-
agent: Agent;
|
|
28
|
-
private_key: string;
|
|
29
|
-
public_key: string;
|
|
30
|
-
key_fingerprint: string;
|
|
31
|
-
}
|
|
32
|
-
type PermissionScope = 'agent:read' | 'agent:write' | 'agent:execute' | 'agent:transact' | 'agent:communicate' | 'agent:delegate' | 'agent:elevate';
|
|
33
|
-
interface PermissionCheckResult {
|
|
34
|
-
allowed: boolean;
|
|
35
|
-
scope: PermissionScope;
|
|
36
|
-
agent_id: string;
|
|
37
|
-
reason?: string;
|
|
38
|
-
remaining_quota?: number;
|
|
39
|
-
}
|
|
40
|
-
type AuditEventType = 'tool_call' | 'api_request' | 'message_sent' | 'permission_change' | 'status_change' | 'key_rotation' | 'login' | 'export';
|
|
41
|
-
type AuditResult = 'success' | 'denied' | 'error';
|
|
42
|
-
interface AuditEventInput {
|
|
43
|
-
agent_id: string;
|
|
44
|
-
event_type: AuditEventType;
|
|
45
|
-
action: string;
|
|
46
|
-
resource?: string;
|
|
47
|
-
input_hash?: string;
|
|
48
|
-
output_hash?: string;
|
|
49
|
-
permission?: PermissionScope;
|
|
50
|
-
result: AuditResult;
|
|
51
|
-
latency_ms?: number;
|
|
52
|
-
error_code?: string;
|
|
53
|
-
signature?: string;
|
|
54
|
-
metadata?: Record<string, unknown>;
|
|
55
|
-
/**
|
|
56
|
-
* Replayable agent decision evidence (VAIP -02 schema fields).
|
|
57
|
-
*
|
|
58
|
-
* Stored and exported but NOT covered by the v0 canonical signature
|
|
59
|
-
* form. They will enter canonical bytes in v1 (RFC 8785 JCS) in a
|
|
60
|
-
* follow-up release. Until then, advisory.
|
|
61
|
-
*
|
|
62
|
-
* Use the helpers from this package to compute the hashes:
|
|
63
|
-
* - {@link hashToolCatalogue}
|
|
64
|
-
* - {@link hashSystemPrompt}
|
|
65
|
-
*/
|
|
66
|
-
model_version?: string;
|
|
67
|
-
tool_catalogue_hash?: string;
|
|
68
|
-
system_prompt_hash?: string;
|
|
69
|
-
prev_event_hash?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Canonical-form recipe the `signature` was computed over.
|
|
72
|
-
* Absent/null ↔ 'v0' (pipe-joined six-field form). Set to 'v1' for
|
|
73
|
-
* RFC 8785 JCS over the full event minus signature and canonical_form.
|
|
74
|
-
* The SDK sets this automatically when {@link VorimConfig.canonicalForm}
|
|
75
|
-
* is `"v1"`; you can also pass it on a per-event basis.
|
|
76
|
-
*/
|
|
77
|
-
canonical_form?: 'v0' | 'v1';
|
|
78
|
-
/**
|
|
79
|
-
* Per-event delegation context (VAIP -02 § 6). Populated by the
|
|
80
|
-
* server when the emitting agent is acting via a delegation chain;
|
|
81
|
-
* callers may also set these manually for events recorded outside
|
|
82
|
-
* the standard delegation flow. v1 signatures cover these fields.
|
|
83
|
-
*/
|
|
84
|
-
on_behalf_of?: string;
|
|
85
|
-
delegator_agent_id?: string;
|
|
86
|
-
delegation_chain_id?: string;
|
|
87
|
-
delegation_depth?: number;
|
|
88
|
-
/**
|
|
89
|
-
* Runtime-control linkage. When this action was gated through
|
|
90
|
-
* {@link VorimSDK.beforeAction} before being performed, pass the
|
|
91
|
-
* returned `decisionId` here (the SDK maps it to `decision_id` on the
|
|
92
|
-
* wire) so the audit event links back to the runtime decision that
|
|
93
|
-
* authorised it.
|
|
94
|
-
*/
|
|
95
|
-
decision_id?: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Claims structure for one VAIP -02 § 5 delegation link.
|
|
99
|
-
*
|
|
100
|
-
* Each delegation step in a chain is one of these objects, RFC 8785 JCS
|
|
101
|
-
* canonicalised and Ed25519-signed by the delegator. Mirrors the same
|
|
102
|
-
* type in `@vorim/shared-types`; duplicated here so the SDK ships zero
|
|
103
|
-
* runtime dependencies. Byte-equivalence with the shared definition is
|
|
104
|
-
* enforced by the cross-language parity script.
|
|
105
|
-
*/
|
|
106
|
-
interface DelegationLinkClaims {
|
|
107
|
-
v: 0;
|
|
108
|
-
type: 'vaip-delegation-link';
|
|
109
|
-
chain_id: string;
|
|
110
|
-
depth: number;
|
|
111
|
-
delegator: string;
|
|
112
|
-
delegate: string;
|
|
113
|
-
scopes: string[];
|
|
114
|
-
max_chain_depth: number;
|
|
115
|
-
valid_from: string;
|
|
116
|
-
valid_until: string | null;
|
|
117
|
-
parent_link_hash: string | null;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* One step in an agent-to-agent identity delegation chain (VAIP -02 § 5).
|
|
121
|
-
*
|
|
122
|
-
* Returned by {@link VorimSDK.delegateToAgent} and the listing endpoints.
|
|
123
|
-
*/
|
|
124
|
-
interface AgentDelegationRecord {
|
|
125
|
-
/** Internal row id. */
|
|
126
|
-
id: string;
|
|
127
|
-
/** Public chain identifier (format `chain_<32hex>`). Stamped on
|
|
128
|
-
* every audit event in this chain. */
|
|
129
|
-
publicChainId: string;
|
|
130
|
-
/** Organisation id. */
|
|
131
|
-
orgId: string;
|
|
132
|
-
/** Internal DB id of the delegator agent. */
|
|
133
|
-
delegatorAgentId: string;
|
|
134
|
-
/** Internal DB id of the delegate agent. */
|
|
135
|
-
delegateAgentId: string;
|
|
136
|
-
/** Public agent_id of the delegator (e.g. agid_acme_abc). */
|
|
137
|
-
delegatorAgentPublicId: string;
|
|
138
|
-
/** Public agent_id of the delegate. */
|
|
139
|
-
delegateAgentPublicId: string;
|
|
140
|
-
/** Scopes the delegate may exercise. */
|
|
141
|
-
scopesDelegated: string[];
|
|
142
|
-
/** How many further hops the delegate is permitted. */
|
|
143
|
-
maxChainDepth: number;
|
|
144
|
-
/** This step's depth from the root (root delegator step = 1). */
|
|
145
|
-
currentDepth: number;
|
|
146
|
-
/** Active / suspended / revoked / expired. */
|
|
147
|
-
status: 'active' | 'suspended' | 'revoked' | 'expired';
|
|
148
|
-
/** Parent delegation row (null for the root of an identity chain). */
|
|
149
|
-
parentDelegationId: string | null;
|
|
150
|
-
/** Public agent_id of the root principal of this chain. */
|
|
151
|
-
onBehalfOf: string;
|
|
152
|
-
/** ISO8601 creation timestamp. */
|
|
153
|
-
createdAt: string;
|
|
154
|
-
/** Optional ISO8601 expiry. */
|
|
155
|
-
validUntil: string | null;
|
|
156
|
-
}
|
|
157
|
-
interface TrustRecord {
|
|
158
|
-
agent_id: string;
|
|
159
|
-
owner: {
|
|
160
|
-
org_name: string;
|
|
161
|
-
verified: boolean;
|
|
162
|
-
};
|
|
163
|
-
trust_score: number;
|
|
164
|
-
status: AgentStatus;
|
|
165
|
-
created_at: string;
|
|
166
|
-
active_scopes: PermissionScope[];
|
|
167
|
-
key_fingerprint: string;
|
|
168
|
-
revocation_status: boolean;
|
|
169
|
-
last_active?: string;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The verdict a runtime decision can carry.
|
|
173
|
-
*
|
|
174
|
-
* - `allow` — proceed with the action.
|
|
175
|
-
* - `deny` — do NOT perform the action. {@link VorimSDK.beforeAction}
|
|
176
|
-
* throws {@link VorimDeniedError} on this when `throwOnDeny`.
|
|
177
|
-
* - `modify` — proceed, but with `modifiedPayload` instead of the
|
|
178
|
-
* original payload (e.g. PII masked by a policy rule).
|
|
179
|
-
* - `escalate` — a human must approve. Poll
|
|
180
|
-
* {@link VorimSDK.waitForDecisionResolution} for the outcome.
|
|
181
|
-
* - `fallback` — the engine could not decide (timeout / error) and the
|
|
182
|
-
* org's fail-open/closed setting was applied. `isFallback`
|
|
183
|
-
* is true. The SDK also returns this shape locally when the
|
|
184
|
-
* decision API is unreachable and `runtimeFailOpen` is set.
|
|
185
|
-
*/
|
|
186
|
-
type DecisionVerdict = 'allow' | 'deny' | 'modify' | 'escalate' | 'fallback';
|
|
187
|
-
/** Input to {@link VorimSDK.beforeAction}. Always use the public `agid_*` id. */
|
|
188
|
-
interface BeforeActionInput {
|
|
189
|
-
/** Public agent identifier (`agid_*`). UUIDs are accepted but discouraged. */
|
|
190
|
-
agentId: string;
|
|
191
|
-
/** Coarse action category, e.g. `tool_call`, `api_request`. */
|
|
192
|
-
actionType: string;
|
|
193
|
-
/** Specific target, e.g. the tool name `sendEmail`. */
|
|
194
|
-
actionTarget?: string;
|
|
195
|
-
/** The action's arguments. Capped at 64KB serialised by the server. */
|
|
196
|
-
payload?: Record<string, unknown>;
|
|
197
|
-
/** Free-form context the policy engine may match on. */
|
|
198
|
-
context?: Record<string, unknown>;
|
|
199
|
-
/** Permission scope the action requires; checked against the agent's grants. */
|
|
200
|
-
requiredScope?: string;
|
|
201
|
-
/**
|
|
202
|
-
* Idempotency key. Pass the SAME key when retrying a failed request so
|
|
203
|
-
* the server returns the original decision instead of creating a new one.
|
|
204
|
-
*/
|
|
205
|
-
idempotencyKey?: string;
|
|
206
|
-
}
|
|
207
|
-
/** A runtime decision, as returned by {@link VorimSDK.beforeAction}. */
|
|
208
|
-
interface RuntimeDecision {
|
|
209
|
-
/** Server-assigned id. Carry into {@link AuditEventInput.decision_id}. */
|
|
210
|
-
decisionId: string;
|
|
211
|
-
decision: DecisionVerdict;
|
|
212
|
-
reason: string;
|
|
213
|
-
/** The policy rule that produced this decision, or null for defaults. */
|
|
214
|
-
decisionRuleId: string | null;
|
|
215
|
-
/** Present (object) when `decision === 'modify'`; null otherwise. */
|
|
216
|
-
modifiedPayload: Record<string, unknown> | null;
|
|
217
|
-
/** ISO8601 — after this the decision is stale and should not be relied on. */
|
|
218
|
-
expiresAt: string;
|
|
219
|
-
latencyMs: number;
|
|
220
|
-
/** True when the engine fell back (timeout/error/unreachable). */
|
|
221
|
-
isFallback: boolean;
|
|
222
|
-
policyVersion: number;
|
|
223
|
-
/**
|
|
224
|
-
* The human verdict on an escalation, once resolved by an operator:
|
|
225
|
-
* `'approved'`, `'denied'`, or `null` if not (yet) an escalation outcome.
|
|
226
|
-
*
|
|
227
|
-
* When this is set, {@link decision} is already translated for you
|
|
228
|
-
* (`approved` → `'allow'`, `denied` → `'deny'`) so the normal verdict
|
|
229
|
-
* checks work — this field is the raw resolution for callers who want it.
|
|
230
|
-
*/
|
|
231
|
-
escalationResolution: 'approved' | 'denied' | null;
|
|
232
|
-
}
|
|
1
|
+
import { R as RuntimeDecision, b as AgentRegistrationInput, A as AgentRegistrationResult, T as TrustRecord, c as Agent, P as PermissionScope, d as PermissionCheckResult, D as DelegationLinkClaims, e as AgentDelegationRecord, B as BeforeActionInput, a as AuditEventInput } from './types-B22WnXEW.js';
|
|
2
|
+
export { f as AgentStatus, g as AuditEventType, h as AuditResult, i as DecisionVerdict } from './types-B22WnXEW.js';
|
|
233
3
|
|
|
234
4
|
/**
|
|
235
5
|
* Replayable agent decision evidence helpers.
|
|
@@ -931,4 +701,4 @@ declare class VorimDeniedError extends VorimError {
|
|
|
931
701
|
}
|
|
932
702
|
declare function createVorim(config: VorimConfig): VorimSDK;
|
|
933
703
|
|
|
934
|
-
export {
|
|
704
|
+
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, DelegationLinkClaims, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, canonicalPayloadV0, canonicalPayloadV1, createVorim as default, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, jcsCanonicalise, prepareReplayContext };
|
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ async function prepareReplayContext(inputs) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// src/index.ts
|
|
72
|
-
var SDK_VERSION = true ? "3.6.
|
|
72
|
+
var SDK_VERSION = true ? "3.6.1" : "0.0.0";
|
|
73
73
|
var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
|
|
74
74
|
function sleep(ms) {
|
|
75
75
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -36,6 +36,36 @@ __export(anthropic_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(anthropic_exports);
|
|
38
38
|
|
|
39
|
+
// src/integrations/_runtime-gate.ts
|
|
40
|
+
function isAllowVerdict(decision) {
|
|
41
|
+
return decision === "allow" || decision === "modify" || decision === "fallback";
|
|
42
|
+
}
|
|
43
|
+
async function runtimeGate(vorim, agentId, actionTarget, scope, payload, opts = {}) {
|
|
44
|
+
const onEscalation = opts.onEscalation ?? "wait";
|
|
45
|
+
const d = await vorim.beforeAction(
|
|
46
|
+
{ agentId, actionType: "tool_call", actionTarget, requiredScope: scope, payload },
|
|
47
|
+
{ throwOnDeny: false }
|
|
48
|
+
);
|
|
49
|
+
if (d.decision !== "escalate") {
|
|
50
|
+
return { allowed: isAllowVerdict(d.decision), reason: d.reason, decisionId: d.decisionId || void 0 };
|
|
51
|
+
}
|
|
52
|
+
if (onEscalation === "allow") {
|
|
53
|
+
return { allowed: true, reason: d.reason ?? "escalated (auto-allowed)", decisionId: d.decisionId || void 0 };
|
|
54
|
+
}
|
|
55
|
+
if (onEscalation === "deny") {
|
|
56
|
+
return { allowed: false, reason: d.reason ?? "escalated (auto-denied \u2014 awaiting human)", decisionId: d.decisionId || void 0 };
|
|
57
|
+
}
|
|
58
|
+
if (!d.decisionId) {
|
|
59
|
+
return { allowed: false, reason: "escalated but no decisionId to poll", decisionId: void 0 };
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const resolved = await vorim.waitForDecisionResolution(d.decisionId, { timeoutMs: opts.escalationTimeoutMs });
|
|
63
|
+
return { allowed: isAllowVerdict(resolved.decision), reason: resolved.reason, decisionId: resolved.decisionId || d.decisionId };
|
|
64
|
+
} catch {
|
|
65
|
+
return { allowed: false, reason: "escalation not resolved before timeout", decisionId: d.decisionId };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
39
69
|
// src/replay.ts
|
|
40
70
|
function jcsCanonicalise(value) {
|
|
41
71
|
if (value === null) return "null";
|
|
@@ -108,6 +138,8 @@ var VorimToolRegistry = class {
|
|
|
108
138
|
defaultPermission;
|
|
109
139
|
asyncAudit;
|
|
110
140
|
useRuntimeControl;
|
|
141
|
+
onEscalation;
|
|
142
|
+
escalationTimeoutMs;
|
|
111
143
|
tools = /* @__PURE__ */ new Map();
|
|
112
144
|
replayInputs;
|
|
113
145
|
replayCache = null;
|
|
@@ -117,20 +149,17 @@ var VorimToolRegistry = class {
|
|
|
117
149
|
this.defaultPermission = config.defaultPermission ?? "agent:execute";
|
|
118
150
|
this.asyncAudit = config.asyncAudit ?? true;
|
|
119
151
|
this.useRuntimeControl = config.useRuntimeControl ?? false;
|
|
152
|
+
this.onEscalation = config.onEscalation;
|
|
153
|
+
this.escalationTimeoutMs = config.escalationTimeoutMs;
|
|
120
154
|
this.replayInputs = config.replay;
|
|
121
155
|
}
|
|
122
156
|
/** Gate a tool call: runtime decision (with decisionId) or permission check. */
|
|
123
157
|
async gate(scope, actionTarget, payload) {
|
|
124
158
|
if (this.useRuntimeControl) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
return {
|
|
130
|
-
allowed: d.decision === "allow" || d.decision === "modify" || d.decision === "fallback",
|
|
131
|
-
reason: d.reason,
|
|
132
|
-
decisionId: d.decisionId || void 0
|
|
133
|
-
};
|
|
159
|
+
return runtimeGate(this.vorim, this.agentId, actionTarget, scope, payload, {
|
|
160
|
+
onEscalation: this.onEscalation,
|
|
161
|
+
escalationTimeoutMs: this.escalationTimeoutMs
|
|
162
|
+
});
|
|
134
163
|
}
|
|
135
164
|
const { allowed, reason } = await this.vorim.check(this.agentId, scope);
|
|
136
165
|
return { allowed, reason };
|