@vorim/sdk 3.11.0 → 3.15.0
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.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/cloudflare.cjs +134 -0
- package/dist/integrations/cloudflare.cjs.map +1 -0
- package/dist/integrations/cloudflare.d.cts +93 -0
- package/dist/integrations/cloudflare.d.ts +93 -0
- package/dist/integrations/cloudflare.js +108 -0
- package/dist/integrations/cloudflare.js.map +1 -0
- package/dist/integrations/coinbase-cdp.cjs +230 -0
- package/dist/integrations/coinbase-cdp.cjs.map +1 -0
- package/dist/integrations/coinbase-cdp.d.cts +169 -0
- package/dist/integrations/coinbase-cdp.d.ts +169 -0
- package/dist/integrations/coinbase-cdp.js +204 -0
- package/dist/integrations/coinbase-cdp.js.map +1 -0
- package/dist/integrations/fhir.cjs +304 -0
- package/dist/integrations/fhir.cjs.map +1 -0
- package/dist/integrations/fhir.d.cts +185 -0
- package/dist/integrations/fhir.d.ts +185 -0
- package/dist/integrations/fhir.js +278 -0
- package/dist/integrations/fhir.js.map +1 -0
- package/dist/integrations/guidewire.cjs +363 -0
- package/dist/integrations/guidewire.cjs.map +1 -0
- package/dist/integrations/guidewire.d.cts +258 -0
- package/dist/integrations/guidewire.d.ts +258 -0
- package/dist/integrations/guidewire.js +337 -0
- package/dist/integrations/guidewire.js.map +1 -0
- package/dist/integrations/legal.cjs +339 -0
- package/dist/integrations/legal.cjs.map +1 -0
- package/dist/integrations/legal.d.cts +225 -0
- package/dist/integrations/legal.d.ts +225 -0
- package/dist/integrations/legal.js +313 -0
- package/dist/integrations/legal.js.map +1 -0
- package/dist/integrations/life-sciences.cjs +335 -0
- package/dist/integrations/life-sciences.cjs.map +1 -0
- package/dist/integrations/life-sciences.d.cts +214 -0
- package/dist/integrations/life-sciences.d.ts +214 -0
- package/dist/integrations/life-sciences.js +309 -0
- package/dist/integrations/life-sciences.js.map +1 -0
- package/dist/integrations/lithic.cjs +290 -0
- package/dist/integrations/lithic.cjs.map +1 -0
- package/dist/integrations/lithic.d.cts +130 -0
- package/dist/integrations/lithic.d.ts +130 -0
- package/dist/integrations/lithic.js +264 -0
- package/dist/integrations/lithic.js.map +1 -0
- package/dist/integrations/marqeta.cjs +285 -0
- package/dist/integrations/marqeta.cjs.map +1 -0
- package/dist/integrations/marqeta.d.cts +121 -0
- package/dist/integrations/marqeta.d.ts +121 -0
- package/dist/integrations/marqeta.js +259 -0
- package/dist/integrations/marqeta.js.map +1 -0
- package/dist/integrations/ramp.cjs +206 -0
- package/dist/integrations/ramp.cjs.map +1 -0
- package/dist/integrations/ramp.d.cts +139 -0
- package/dist/integrations/ramp.d.ts +139 -0
- package/dist/integrations/ramp.js +180 -0
- package/dist/integrations/ramp.js.map +1 -0
- package/dist/integrations/shopify.cjs +203 -0
- package/dist/integrations/shopify.cjs.map +1 -0
- package/dist/integrations/shopify.d.cts +175 -0
- package/dist/integrations/shopify.d.ts +175 -0
- package/dist/integrations/shopify.js +177 -0
- package/dist/integrations/shopify.js.map +1 -0
- package/dist/integrations/stripe-issuing.cjs +316 -0
- package/dist/integrations/stripe-issuing.cjs.map +1 -0
- package/dist/integrations/stripe-issuing.d.cts +154 -0
- package/dist/integrations/stripe-issuing.d.ts +154 -0
- package/dist/integrations/stripe-issuing.js +290 -0
- package/dist/integrations/stripe-issuing.js.map +1 -0
- package/dist/integrations/web-bot-auth.cjs +143 -0
- package/dist/integrations/web-bot-auth.cjs.map +1 -0
- package/dist/integrations/web-bot-auth.d.cts +51 -0
- package/dist/integrations/web-bot-auth.d.ts +51 -0
- package/dist/integrations/web-bot-auth.js +108 -0
- package/dist/integrations/web-bot-auth.js.map +1 -0
- package/package.json +121 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/legal.ts
|
|
21
|
+
var legal_exports = {};
|
|
22
|
+
__export(legal_exports, {
|
|
23
|
+
VorimLegal: () => VorimLegal,
|
|
24
|
+
createVorimLegal: () => createVorimLegal
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(legal_exports);
|
|
27
|
+
var SECURITY_RANK = { private: 0, inherit: 0, view: 1, public: 2 };
|
|
28
|
+
var OPERATION_SCOPE = {
|
|
29
|
+
read: "agent:read",
|
|
30
|
+
upload: "agent:write",
|
|
31
|
+
"new-version": "agent:write",
|
|
32
|
+
// set-security is write when narrowing, elevate when widening (resolved live)
|
|
33
|
+
"set-security": "agent:write",
|
|
34
|
+
share: "agent:elevate",
|
|
35
|
+
// external share is privilege-sensitive by default
|
|
36
|
+
produce: "agent:elevate"
|
|
37
|
+
// discovery production always needs a lawyer
|
|
38
|
+
};
|
|
39
|
+
var VorimLegal = class {
|
|
40
|
+
sdk;
|
|
41
|
+
agentId;
|
|
42
|
+
dms;
|
|
43
|
+
workspace;
|
|
44
|
+
supervisorId;
|
|
45
|
+
minTrustScore;
|
|
46
|
+
escalatePrivilege;
|
|
47
|
+
escalationTimeoutMs;
|
|
48
|
+
onError;
|
|
49
|
+
constructor(sdk, config) {
|
|
50
|
+
if (!config?.agentId) throw new Error("[vorim] Legal integration requires an agentId.");
|
|
51
|
+
if (!config?.dms) throw new Error("[vorim] Legal integration requires a dms.");
|
|
52
|
+
if (!config?.workspace) throw new Error("[vorim] Legal integration requires a workspace.");
|
|
53
|
+
this.sdk = sdk;
|
|
54
|
+
this.agentId = config.agentId;
|
|
55
|
+
this.dms = config.dms;
|
|
56
|
+
this.workspace = config.workspace;
|
|
57
|
+
this.supervisorId = config.supervisorId;
|
|
58
|
+
this.minTrustScore = config.minTrustScore ?? 0;
|
|
59
|
+
this.escalatePrivilege = config.escalatePrivilege ?? true;
|
|
60
|
+
this.escalationTimeoutMs = config.escalationTimeoutMs ?? 3e5;
|
|
61
|
+
this.onError = config.onError ?? "closed";
|
|
62
|
+
}
|
|
63
|
+
/** Why (if at all) an action is privilege-sensitive. A set-security that
|
|
64
|
+
* widens the ladder or alters privilege, an external share, or a production
|
|
65
|
+
* are all escalation-class. Narrowing access is not. */
|
|
66
|
+
privilegeReason(action) {
|
|
67
|
+
if (action.operation === "produce") return "produce";
|
|
68
|
+
if (action.operation === "share" && action.external) return "external-share";
|
|
69
|
+
if (action.operation === "set-security") {
|
|
70
|
+
if (action.altersPrivilege) return "alter-privilege";
|
|
71
|
+
const from = SECURITY_RANK[action.currentSecurity ?? "inherit"] ?? 0;
|
|
72
|
+
const to = SECURITY_RANK[action.targetSecurity ?? "inherit"] ?? 0;
|
|
73
|
+
if (to > from) return "widen-access";
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
isPrivilegeSensitive(action) {
|
|
78
|
+
return this.privilegeReason(action) !== null;
|
|
79
|
+
}
|
|
80
|
+
/** The Vorim scope an action requires. Reads need read; a privilege-sensitive
|
|
81
|
+
* action is elevated; other writes need write. A share/produce map to elevate
|
|
82
|
+
* by default, but a non-external share is a plain write. */
|
|
83
|
+
scopeFor(action) {
|
|
84
|
+
if (action.operation === "read") return "agent:read";
|
|
85
|
+
if (this.isPrivilegeSensitive(action)) return "agent:elevate";
|
|
86
|
+
if (action.operation === "share" && !action.external) return "agent:write";
|
|
87
|
+
return OPERATION_SCOPE[action.operation] ?? "agent:write";
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Decide whether the acting agent may run this DMS operation, before it runs.
|
|
91
|
+
* Order: trust floor, then the privilege gate (escalate a widen/alter/external/
|
|
92
|
+
* produce to the supervising lawyer), then permission scope.
|
|
93
|
+
*/
|
|
94
|
+
async authorize(action) {
|
|
95
|
+
const priv = this.privilegeReason(action);
|
|
96
|
+
const scope = this.scopeFor(action);
|
|
97
|
+
try {
|
|
98
|
+
if (this.minTrustScore > 0) {
|
|
99
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
100
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
101
|
+
return {
|
|
102
|
+
authorized: false,
|
|
103
|
+
reason: `trust score below ${this.minTrustScore}`,
|
|
104
|
+
outcome: priv ? "privilege-denied" : "ordinary"
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (priv) {
|
|
109
|
+
if (!this.escalatePrivilege) {
|
|
110
|
+
return {
|
|
111
|
+
authorized: false,
|
|
112
|
+
reason: `${priv} requires a supervising lawyer and escalatePrivilege is off`,
|
|
113
|
+
outcome: "privilege-denied"
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (!this.supervisorId) {
|
|
117
|
+
return {
|
|
118
|
+
authorized: false,
|
|
119
|
+
reason: `${priv} requires a configured supervisorId (the supervising lawyer of record)`,
|
|
120
|
+
outcome: "privilege-denied"
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const esc = await this.escalate(action, scope, priv);
|
|
124
|
+
return {
|
|
125
|
+
authorized: esc.approved,
|
|
126
|
+
reason: esc.approved ? void 0 : esc.reason ?? "supervising lawyer did not approve",
|
|
127
|
+
outcome: esc.approved ? "approved-by-lawyer" : "privilege-denied",
|
|
128
|
+
supervisorId: esc.approved ? this.supervisorId : void 0,
|
|
129
|
+
decisionId: esc.decisionId
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const perm = await this.sdk.check(this.agentId, scope);
|
|
133
|
+
return perm.allowed ? { authorized: true, outcome: "ordinary", supervisorId: this.supervisorId } : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: "ordinary" };
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return this.onError === "open" ? {
|
|
136
|
+
authorized: true,
|
|
137
|
+
reason: "vorim unreachable, failed open",
|
|
138
|
+
outcome: priv ? "approved-by-lawyer" : "ordinary"
|
|
139
|
+
} : {
|
|
140
|
+
authorized: false,
|
|
141
|
+
reason: `vorim unreachable: ${e?.message ?? "error"}`,
|
|
142
|
+
outcome: priv ? "privilege-denied" : "ordinary"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Route a privilege-sensitive action through the runtime decision plane so the
|
|
148
|
+
* supervising lawyer can approve or refuse, and wait. The elevate scope marks
|
|
149
|
+
* the segregation-of-duties gate: the agent proposes, the lawyer authorizes.
|
|
150
|
+
*/
|
|
151
|
+
async escalate(action, scope, reason) {
|
|
152
|
+
const decision = await this.sdk.beforeAction(
|
|
153
|
+
{
|
|
154
|
+
agentId: this.agentId,
|
|
155
|
+
actionType: "api_request",
|
|
156
|
+
actionTarget: `${this.dms}:${action.operation}`,
|
|
157
|
+
requiredScope: scope,
|
|
158
|
+
payload: {
|
|
159
|
+
operation: action.operation,
|
|
160
|
+
matter_id: action.matterId,
|
|
161
|
+
document_id: action.documentId,
|
|
162
|
+
privilege_reason: reason,
|
|
163
|
+
current_security: action.currentSecurity,
|
|
164
|
+
target_security: action.targetSecurity
|
|
165
|
+
},
|
|
166
|
+
context: {
|
|
167
|
+
integration: `${this.dms}-legal`,
|
|
168
|
+
workspace: this.workspace,
|
|
169
|
+
requires_supervising_lawyer: true,
|
|
170
|
+
supervisor_hint: this.supervisorId
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{ throwOnDeny: false }
|
|
174
|
+
);
|
|
175
|
+
if (decision.decision === "escalate") {
|
|
176
|
+
const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, {
|
|
177
|
+
timeoutMs: this.escalationTimeoutMs
|
|
178
|
+
});
|
|
179
|
+
const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
|
|
180
|
+
return {
|
|
181
|
+
approved,
|
|
182
|
+
reason: approved ? void 0 : "supervising lawyer refused",
|
|
183
|
+
decisionId: decision.decisionId
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
|
|
187
|
+
if (decision.decision === "fallback")
|
|
188
|
+
return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
|
|
189
|
+
return { approved: false, reason: decision.reason ?? "denied", decisionId: decision.decisionId };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Emit a source-signed audit event for a DMS operation and return whether it
|
|
193
|
+
* was recorded. The event names the agent, the DMS, the matter/document, the
|
|
194
|
+
* supervising lawyer, and any privilege escalation — the attributable,
|
|
195
|
+
* supervised record that Rule 5.1/5.3 and e-discovery defensibility reward.
|
|
196
|
+
*/
|
|
197
|
+
async record(action, result, extra = {}) {
|
|
198
|
+
const scope = this.scopeFor(action);
|
|
199
|
+
const priv = this.privilegeReason(action);
|
|
200
|
+
const target = action.documentId || action.matterId || this.workspace;
|
|
201
|
+
try {
|
|
202
|
+
await this.sdk.emit(
|
|
203
|
+
{
|
|
204
|
+
agent_id: this.agentId,
|
|
205
|
+
event_type: "api_request",
|
|
206
|
+
action: `${this.dms}:${action.operation}${action.documentId ? " " + action.documentId : ""}`,
|
|
207
|
+
resource: target,
|
|
208
|
+
permission: scope,
|
|
209
|
+
result,
|
|
210
|
+
input_hash: action.inputHash,
|
|
211
|
+
metadata: {
|
|
212
|
+
integration: `${this.dms}-legal`,
|
|
213
|
+
dms: this.dms,
|
|
214
|
+
workspace: this.workspace,
|
|
215
|
+
operation: action.operation,
|
|
216
|
+
...action.matterId ? { matter_id: action.matterId } : {},
|
|
217
|
+
privilege_sensitive: this.isPrivilegeSensitive(action),
|
|
218
|
+
...priv ? { privilege_reason: priv } : {},
|
|
219
|
+
...extra.outcome ? { outcome: extra.outcome } : {},
|
|
220
|
+
// The supervising lawyer of record (Rule 5.1/5.3 evidence).
|
|
221
|
+
...extra.supervisorId ?? this.supervisorId ? { supervised_by: extra.supervisorId ?? this.supervisorId, supervised_at: (/* @__PURE__ */ new Date()).toISOString() } : {},
|
|
222
|
+
...extra.decisionId ? { decision_id: extra.decisionId } : {},
|
|
223
|
+
...extra.reason ? { reason: extra.reason } : {}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{ sign: true }
|
|
227
|
+
// source-signed: the agent's key signs the record
|
|
228
|
+
);
|
|
229
|
+
return true;
|
|
230
|
+
} catch {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The full flow for one DMS operation: authorize (trust, privilege gate,
|
|
236
|
+
* scope), run the DMS call if allowed, sign a receipt either way. If not
|
|
237
|
+
* authorized, `run` is never called. Rethrows a DMS error from `run` after
|
|
238
|
+
* recording it, with the receipt attached as `vorimReceipt`.
|
|
239
|
+
*/
|
|
240
|
+
async guard(action, run) {
|
|
241
|
+
const auth = await this.authorize(action);
|
|
242
|
+
if (!auth.authorized) {
|
|
243
|
+
const recorded = await this.record(action, "denied", {
|
|
244
|
+
reason: auth.reason,
|
|
245
|
+
outcome: auth.outcome,
|
|
246
|
+
supervisorId: auth.supervisorId,
|
|
247
|
+
decisionId: auth.decisionId
|
|
248
|
+
});
|
|
249
|
+
return { receipt: this.receipt(action, false, "denied", auth, recorded) };
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
const value = await run();
|
|
253
|
+
const recorded = await this.record(action, "success", {
|
|
254
|
+
outcome: auth.outcome,
|
|
255
|
+
supervisorId: auth.supervisorId,
|
|
256
|
+
decisionId: auth.decisionId
|
|
257
|
+
});
|
|
258
|
+
return { receipt: this.receipt(action, true, "success", auth, recorded), value };
|
|
259
|
+
} catch (e) {
|
|
260
|
+
const recorded = await this.record(action, "error", {
|
|
261
|
+
reason: e?.message,
|
|
262
|
+
outcome: auth.outcome,
|
|
263
|
+
supervisorId: auth.supervisorId,
|
|
264
|
+
decisionId: auth.decisionId
|
|
265
|
+
});
|
|
266
|
+
throw Object.assign(e ?? new Error("legal operation failed"), {
|
|
267
|
+
vorimReceipt: this.receipt(action, true, "error", { ...auth, reason: e?.message }, recorded)
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// --- Named helpers ---------------------------------------------------------
|
|
272
|
+
/** Guard a document upload to a matter. Requires agent:write. */
|
|
273
|
+
guardedUpload(meta, run) {
|
|
274
|
+
return this.guard({ operation: "upload", matterId: meta.matterId, documentId: meta.documentId, inputHash: meta.inputHash }, run);
|
|
275
|
+
}
|
|
276
|
+
/** Guard a new-version check-in. Requires agent:write. */
|
|
277
|
+
guardedNewVersion(meta, run) {
|
|
278
|
+
return this.guard({ operation: "new-version", matterId: meta.matterId, documentId: meta.documentId, inputHash: meta.inputHash }, run);
|
|
279
|
+
}
|
|
280
|
+
/** Guard a security/permissions change. Narrowing access is a write; WIDENING
|
|
281
|
+
* (targetSecurity above currentSecurity) or altering a privilege designation
|
|
282
|
+
* escalates to the supervising lawyer. */
|
|
283
|
+
guardedSetSecurity(meta, run) {
|
|
284
|
+
return this.guard(
|
|
285
|
+
{
|
|
286
|
+
operation: "set-security",
|
|
287
|
+
matterId: meta.matterId,
|
|
288
|
+
documentId: meta.documentId,
|
|
289
|
+
currentSecurity: meta.currentSecurity,
|
|
290
|
+
targetSecurity: meta.targetSecurity,
|
|
291
|
+
altersPrivilege: meta.altersPrivilege,
|
|
292
|
+
inputHash: meta.inputHash
|
|
293
|
+
},
|
|
294
|
+
run
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
/** Guard a share. An external share escalates to the supervising lawyer; an
|
|
298
|
+
* internal share is an ordinary write. */
|
|
299
|
+
guardedShare(meta, run) {
|
|
300
|
+
return this.guard(
|
|
301
|
+
{ operation: "share", matterId: meta.matterId, documentId: meta.documentId, external: meta.external, inputHash: meta.inputHash },
|
|
302
|
+
run
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
/** Guard a discovery production. Always escalates to the supervising lawyer
|
|
306
|
+
* and signs a full chain-of-custody record. */
|
|
307
|
+
guardedProduce(meta, run) {
|
|
308
|
+
return this.guard({ operation: "produce", matterId: meta.matterId, documentId: meta.documentId, inputHash: meta.inputHash }, run);
|
|
309
|
+
}
|
|
310
|
+
receipt(action, authorized, result, auth, recorded) {
|
|
311
|
+
return {
|
|
312
|
+
authorized,
|
|
313
|
+
agentId: this.agentId,
|
|
314
|
+
dms: this.dms,
|
|
315
|
+
workspace: this.workspace,
|
|
316
|
+
operation: action.operation,
|
|
317
|
+
matterId: action.matterId,
|
|
318
|
+
documentId: action.documentId,
|
|
319
|
+
privilegeSensitive: this.isPrivilegeSensitive(action),
|
|
320
|
+
privilegeReason: this.privilegeReason(action),
|
|
321
|
+
outcome: auth.outcome ?? "ordinary",
|
|
322
|
+
supervisorId: auth.supervisorId ?? this.supervisorId,
|
|
323
|
+
result,
|
|
324
|
+
scope: this.scopeFor(action),
|
|
325
|
+
reason: auth.reason,
|
|
326
|
+
decisionId: auth.decisionId,
|
|
327
|
+
recorded
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
function createVorimLegal(sdk, config) {
|
|
332
|
+
return new VorimLegal(sdk, config);
|
|
333
|
+
}
|
|
334
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
335
|
+
0 && (module.exports = {
|
|
336
|
+
VorimLegal,
|
|
337
|
+
createVorimLegal
|
|
338
|
+
});
|
|
339
|
+
//# sourceMappingURL=legal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/legal.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Legal (iManage Work / NetDocuments DMS) Integration\n//\n// This guards an AI agent that acts on a legal document management system (the\n// system of record for a matter) — iManage Work or NetDocuments — through their\n// REST APIs. Before each mutation runs it checks the acting agent holds the\n// right permission, and for the privilege-sensitive actions (changing document\n// security, sharing externally, producing in discovery) it enforces a one-\n// directional rule and escalates to the supervising lawyer of record. Every\n// action is signed as a tamper-evident record of which agent did what, on which\n// matter, supervised by whom.\n//\n// THE MONOTONIC ACCESS RULE (the wedge)\n// An agent may NARROW document access (e.g. -> private/view) but may NEVER WIDEN\n// it (-> public), never alter a privilege designation, and never share\n// externally or produce in discovery, without a named lawyer's approval.\n// Widening access on a privileged document can waive privilege — so that\n// direction is escalation-only. This maps to iManage's real default_security\n// ladder (inherit < view < public) and access_level on UpdatePermissions.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// read a document -> agent:read\n// file / version to a matter -> agent:write\n// narrow access -> agent:write\n// widen access / change privilege / -> agent:elevate (named-lawyer approval;\n// external share / produce segregation of duties)\n//\n// HONEST COMPLIANCE FRAMING\n// ABA Formal Opinion 512 treats AI as a nonlawyer assistant: Rules 5.1/5.3\n// require supervision, 1.1 review, 1.6 confidentiality. E-discovery\n// defensibility (FRCP 37(e), chain of custody) rewards a documented process.\n// A signed \"which agent did what, supervised by whom\" record is EVIDENCE of\n// attribution + supervision, and hardens chain of custody. No rule mandates a\n// cryptographic signature — Opinion 512 explicitly does not. Say \"produces\n// defensible evidence of attribution and supervision\", never \"required by the\n// rules\".\n//\n// This layer never holds a DMS token and never calls iManage/NetDocuments\n// itself. You pass the DMS call to run; it authorizes, escalates if needed, runs\n// it, signs the receipt.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimLegal } from '@vorim/sdk/integrations/legal';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const legal = createVorimLegal(vorim, {\n// agentId: 'agid_abc123',\n// dms: 'imanage',\n// workspace: 'acme-imanage',\n// supervisorId: 'lawyer_42', // the supervising lawyer of record\n// });\n//\n// const { receipt, value } = await legal.guardedUpload(\n// { matterId: 'M-1001', documentId: 'DOC-9' },\n// () => imanage.uploadDocument(input),\n// );\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** Which DMS this guard fronts. Configuration, not separate code paths. */\nexport type LegalDms = 'imanage' | 'netdocuments';\n\n/** The mutations this guard classifies. Upload/version/narrow are ordinary\n * writes; widen-access / change-privilege / external-share / produce are\n * escalation-gated to the supervising lawyer. Any other label defaults to the\n * 'write' tier. */\nexport type LegalOperation =\n | 'upload' // file / upload a document to a matter\n | 'new-version' // check-in a new version\n | 'set-security' // change default_security / permissions\n | 'share' // share a document\n | 'produce' // produce documents in discovery\n | 'read';\n\n/** iManage default_security ladder, lowest to highest exposure. Narrowing (a\n * lower or equal target) is a write; widening (a higher target) is escalation-\n * only. inherit is treated as the private baseline for direction purposes. */\nconst SECURITY_RANK: Record<string, number> = { private: 0, inherit: 0, view: 1, public: 2 };\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n read: 'agent:read',\n upload: 'agent:write',\n 'new-version': 'agent:write',\n // set-security is write when narrowing, elevate when widening (resolved live)\n 'set-security': 'agent:write',\n share: 'agent:elevate', // external share is privilege-sensitive by default\n produce: 'agent:elevate', // discovery production always needs a lawyer\n};\n\nexport interface LegalGuardConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** Which DMS this guard fronts. */\n dms: LegalDms;\n /** The workspace / library / vault, recorded on every receipt so an action is\n * attributable to one instance. */\n workspace: string;\n /** The supervising lawyer of record — the named approver for any privilege-\n * sensitive action, and the recorded supervisor on every action (Rule\n * 5.1/5.3). Required if any escalation-class action will be run. */\n supervisorId?: string;\n /** Minimum trust score the agent must hold before any mutation. Default 0. */\n minTrustScore?: number;\n /** For a privilege-sensitive action, escalate to the supervising lawyer and\n * wait for approval instead of denying. Requires the runtime decision plane.\n * Default true (an unsupervised privilege change is what we exist to\n * prevent). */\n escalatePrivilege?: boolean;\n /** Max time to wait for a lawyer's approval, ms. Default 300000 (5 min). */\n escalationTimeoutMs?: number;\n /** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */\n onError?: 'closed' | 'open';\n}\n\nexport interface LegalAction {\n /** The DMS operation, e.g. 'upload'. Drives the scope and whether the action\n * is privilege-sensitive. Unknown labels default to write. */\n operation: LegalOperation | string;\n /** The matter the action targets, e.g. 'M-1001'. Recorded for attribution. */\n matterId?: string;\n /** The document the action targets. */\n documentId?: string;\n /** For 'set-security': the current default_security, one of\n * private|inherit|view|public. */\n currentSecurity?: string;\n /** For 'set-security': the target default_security. Widening beyond\n * currentSecurity is escalation-only. */\n targetSecurity?: string;\n /** For 'set-security': true if this changes a privilege designation. Always\n * escalation-only regardless of direction. */\n altersPrivilege?: boolean;\n /** For 'share': true if the recipient is external to the firm. External\n * shares are escalation-only. */\n external?: boolean;\n /** Optional hash of the request body so the receipt covers the exact input\n * without the guard storing it. */\n inputHash?: string;\n}\n\n/** Why an action was treated as privilege-sensitive (escalation-class). */\nexport type PrivilegeReason = 'widen-access' | 'alter-privilege' | 'external-share' | 'produce' | null;\n\n/** How a privilege-sensitive action resolved. */\nexport type LegalOutcome = 'ordinary' | 'approved-by-lawyer' | 'privilege-denied';\n\n/** An offline-verifiable receipt for one DMS operation. */\nexport interface LegalReceipt {\n authorized: boolean;\n agentId: string;\n dms: LegalDms;\n workspace: string;\n operation: string;\n matterId?: string;\n documentId?: string;\n /** True when the action is privilege-sensitive (needs a lawyer). */\n privilegeSensitive: boolean;\n /** Why it was privilege-sensitive, if it was. */\n privilegeReason: PrivilegeReason;\n outcome: LegalOutcome;\n /** The supervising lawyer recorded on the action. */\n supervisorId?: string;\n result: 'success' | 'denied' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\nexport class VorimLegal {\n private sdk: VorimSDK;\n private agentId: string;\n private dms: LegalDms;\n private workspace: string;\n private supervisorId?: string;\n private minTrustScore: number;\n private escalatePrivilege: boolean;\n private escalationTimeoutMs: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: LegalGuardConfig) {\n if (!config?.agentId) throw new Error('[vorim] Legal integration requires an agentId.');\n if (!config?.dms) throw new Error('[vorim] Legal integration requires a dms.');\n if (!config?.workspace) throw new Error('[vorim] Legal integration requires a workspace.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.dms = config.dms;\n this.workspace = config.workspace;\n this.supervisorId = config.supervisorId;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.escalatePrivilege = config.escalatePrivilege ?? true;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 300_000;\n this.onError = config.onError ?? 'closed';\n }\n\n /** Why (if at all) an action is privilege-sensitive. A set-security that\n * widens the ladder or alters privilege, an external share, or a production\n * are all escalation-class. Narrowing access is not. */\n private privilegeReason(action: LegalAction): PrivilegeReason {\n if (action.operation === 'produce') return 'produce';\n if (action.operation === 'share' && action.external) return 'external-share';\n if (action.operation === 'set-security') {\n if (action.altersPrivilege) return 'alter-privilege';\n const from = SECURITY_RANK[action.currentSecurity ?? 'inherit'] ?? 0;\n const to = SECURITY_RANK[action.targetSecurity ?? 'inherit'] ?? 0;\n if (to > from) return 'widen-access'; // widening only\n }\n return null;\n }\n\n private isPrivilegeSensitive(action: LegalAction): boolean {\n return this.privilegeReason(action) !== null;\n }\n\n /** The Vorim scope an action requires. Reads need read; a privilege-sensitive\n * action is elevated; other writes need write. A share/produce map to elevate\n * by default, but a non-external share is a plain write. */\n private scopeFor(action: LegalAction): PermissionScope {\n if (action.operation === 'read') return 'agent:read';\n if (this.isPrivilegeSensitive(action)) return 'agent:elevate';\n // A non-external share is an ordinary write despite the default mapping.\n if (action.operation === 'share' && !action.external) return 'agent:write';\n return OPERATION_SCOPE[action.operation] ?? 'agent:write';\n }\n\n /**\n * Decide whether the acting agent may run this DMS operation, before it runs.\n * Order: trust floor, then the privilege gate (escalate a widen/alter/external/\n * produce to the supervising lawyer), then permission scope.\n */\n async authorize(\n action: LegalAction,\n ): Promise<{\n authorized: boolean;\n reason?: string;\n outcome: LegalOutcome;\n supervisorId?: string;\n decisionId?: string;\n }> {\n const priv = this.privilegeReason(action);\n const scope = this.scopeFor(action);\n\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n return {\n authorized: false,\n reason: `trust score below ${this.minTrustScore}`,\n outcome: priv ? 'privilege-denied' : 'ordinary',\n };\n }\n }\n\n if (priv) {\n if (!this.escalatePrivilege) {\n return {\n authorized: false,\n reason: `${priv} requires a supervising lawyer and escalatePrivilege is off`,\n outcome: 'privilege-denied',\n };\n }\n if (!this.supervisorId) {\n return {\n authorized: false,\n reason: `${priv} requires a configured supervisorId (the supervising lawyer of record)`,\n outcome: 'privilege-denied',\n };\n }\n const esc = await this.escalate(action, scope, priv);\n return {\n authorized: esc.approved,\n reason: esc.approved ? undefined : (esc.reason ?? 'supervising lawyer did not approve'),\n outcome: esc.approved ? 'approved-by-lawyer' : 'privilege-denied',\n supervisorId: esc.approved ? this.supervisorId : undefined,\n decisionId: esc.decisionId,\n };\n }\n\n const perm = await this.sdk.check(this.agentId, scope);\n return perm.allowed\n ? { authorized: true, outcome: 'ordinary', supervisorId: this.supervisorId }\n : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: 'ordinary' };\n } catch (e: any) {\n return this.onError === 'open'\n ? {\n authorized: true,\n reason: 'vorim unreachable, failed open',\n outcome: priv ? 'approved-by-lawyer' : 'ordinary',\n }\n : {\n authorized: false,\n reason: `vorim unreachable: ${e?.message ?? 'error'}`,\n outcome: priv ? 'privilege-denied' : 'ordinary',\n };\n }\n }\n\n /**\n * Route a privilege-sensitive action through the runtime decision plane so the\n * supervising lawyer can approve or refuse, and wait. The elevate scope marks\n * the segregation-of-duties gate: the agent proposes, the lawyer authorizes.\n */\n private async escalate(\n action: LegalAction,\n scope: PermissionScope,\n reason: Exclude<PrivilegeReason, null>,\n ): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: `${this.dms}:${action.operation}`,\n requiredScope: scope,\n payload: {\n operation: action.operation,\n matter_id: action.matterId,\n document_id: action.documentId,\n privilege_reason: reason,\n current_security: action.currentSecurity,\n target_security: action.targetSecurity,\n },\n context: {\n integration: `${this.dms}-legal`,\n workspace: this.workspace,\n requires_supervising_lawyer: true,\n supervisor_hint: this.supervisorId,\n },\n },\n { throwOnDeny: false },\n );\n\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, {\n timeoutMs: this.escalationTimeoutMs,\n });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return {\n approved,\n reason: approved ? undefined : 'supervising lawyer refused',\n decisionId: decision.decisionId,\n };\n }\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'denied', decisionId: decision.decisionId };\n }\n\n /**\n * Emit a source-signed audit event for a DMS operation and return whether it\n * was recorded. The event names the agent, the DMS, the matter/document, the\n * supervising lawyer, and any privilege escalation — the attributable,\n * supervised record that Rule 5.1/5.3 and e-discovery defensibility reward.\n */\n async record(\n action: LegalAction,\n result: 'success' | 'denied' | 'error',\n extra: { reason?: string; outcome?: LegalOutcome; supervisorId?: string; decisionId?: string } = {},\n ): Promise<boolean> {\n const scope = this.scopeFor(action);\n const priv = this.privilegeReason(action);\n const target = action.documentId || action.matterId || this.workspace;\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `${this.dms}:${action.operation}${action.documentId ? ' ' + action.documentId : ''}`,\n resource: target,\n permission: scope,\n result,\n input_hash: action.inputHash,\n metadata: {\n integration: `${this.dms}-legal`,\n dms: this.dms,\n workspace: this.workspace,\n operation: action.operation,\n ...(action.matterId ? { matter_id: action.matterId } : {}),\n privilege_sensitive: this.isPrivilegeSensitive(action),\n ...(priv ? { privilege_reason: priv } : {}),\n ...(extra.outcome ? { outcome: extra.outcome } : {}),\n // The supervising lawyer of record (Rule 5.1/5.3 evidence).\n ...(extra.supervisorId ?? this.supervisorId\n ? { supervised_by: extra.supervisorId ?? this.supervisorId, supervised_at: new Date().toISOString() }\n : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true }, // source-signed: the agent's key signs the record\n );\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * The full flow for one DMS operation: authorize (trust, privilege gate,\n * scope), run the DMS call if allowed, sign a receipt either way. If not\n * authorized, `run` is never called. Rethrows a DMS error from `run` after\n * recording it, with the receipt attached as `vorimReceipt`.\n */\n async guard<T>(action: LegalAction, run: () => Promise<T>): Promise<{ receipt: LegalReceipt; value?: T }> {\n const auth = await this.authorize(action);\n if (!auth.authorized) {\n const recorded = await this.record(action, 'denied', {\n reason: auth.reason,\n outcome: auth.outcome,\n supervisorId: auth.supervisorId,\n decisionId: auth.decisionId,\n });\n return { receipt: this.receipt(action, false, 'denied', auth, recorded) };\n }\n try {\n const value = await run();\n const recorded = await this.record(action, 'success', {\n outcome: auth.outcome,\n supervisorId: auth.supervisorId,\n decisionId: auth.decisionId,\n });\n return { receipt: this.receipt(action, true, 'success', auth, recorded), value };\n } catch (e: any) {\n const recorded = await this.record(action, 'error', {\n reason: e?.message,\n outcome: auth.outcome,\n supervisorId: auth.supervisorId,\n decisionId: auth.decisionId,\n });\n throw Object.assign(e ?? new Error('legal operation failed'), {\n vorimReceipt: this.receipt(action, true, 'error', { ...auth, reason: e?.message }, recorded),\n });\n }\n }\n\n // --- Named helpers ---------------------------------------------------------\n\n /** Guard a document upload to a matter. Requires agent:write. */\n guardedUpload<T>(meta: { matterId?: string; documentId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'upload', matterId: meta.matterId, documentId: meta.documentId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard a new-version check-in. Requires agent:write. */\n guardedNewVersion<T>(meta: { matterId?: string; documentId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'new-version', matterId: meta.matterId, documentId: meta.documentId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard a security/permissions change. Narrowing access is a write; WIDENING\n * (targetSecurity above currentSecurity) or altering a privilege designation\n * escalates to the supervising lawyer. */\n guardedSetSecurity<T>(\n meta: { matterId?: string; documentId?: string; currentSecurity?: string; targetSecurity?: string; altersPrivilege?: boolean; inputHash?: string },\n run: () => Promise<T>,\n ) {\n return this.guard(\n {\n operation: 'set-security',\n matterId: meta.matterId,\n documentId: meta.documentId,\n currentSecurity: meta.currentSecurity,\n targetSecurity: meta.targetSecurity,\n altersPrivilege: meta.altersPrivilege,\n inputHash: meta.inputHash,\n },\n run,\n );\n }\n\n /** Guard a share. An external share escalates to the supervising lawyer; an\n * internal share is an ordinary write. */\n guardedShare<T>(meta: { matterId?: string; documentId?: string; external?: boolean; inputHash?: string }, run: () => Promise<T>) {\n return this.guard(\n { operation: 'share', matterId: meta.matterId, documentId: meta.documentId, external: meta.external, inputHash: meta.inputHash },\n run,\n );\n }\n\n /** Guard a discovery production. Always escalates to the supervising lawyer\n * and signs a full chain-of-custody record. */\n guardedProduce<T>(meta: { matterId?: string; documentId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'produce', matterId: meta.matterId, documentId: meta.documentId, inputHash: meta.inputHash }, run);\n }\n\n private receipt(\n action: LegalAction,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n auth: { reason?: string; outcome?: LegalOutcome; supervisorId?: string; decisionId?: string },\n recorded: boolean,\n ): LegalReceipt {\n return {\n authorized,\n agentId: this.agentId,\n dms: this.dms,\n workspace: this.workspace,\n operation: action.operation,\n matterId: action.matterId,\n documentId: action.documentId,\n privilegeSensitive: this.isPrivilegeSensitive(action),\n privilegeReason: this.privilegeReason(action),\n outcome: auth.outcome ?? 'ordinary',\n supervisorId: auth.supervisorId ?? this.supervisorId,\n result,\n scope: this.scopeFor(action),\n reason: auth.reason,\n decisionId: auth.decisionId,\n recorded,\n };\n }\n}\n\n/**\n * Create a VorimLegal guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimLegal } from '@vorim/sdk/integrations/legal';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const legal = createVorimLegal(vorim, {\n * agentId: 'agid_abc123',\n * dms: 'imanage',\n * workspace: 'acme-imanage',\n * supervisorId: 'lawyer_42',\n * });\n *\n * // Widening access escalates to the supervising lawyer; narrowing does not:\n * const { receipt } = await legal.guardedSetSecurity(\n * { documentId: 'DOC-9', currentSecurity: 'private', targetSecurity: 'public' },\n * () => imanage.updateDefaultSecurity('DOC-9', 'public'),\n * );\n * ```\n */\nexport function createVorimLegal(sdk: VorimSDK, config: LegalGuardConfig): VorimLegal {\n return new VorimLegal(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgFA,IAAM,gBAAwC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,EAAE;AAE3F,IAAM,kBAAmD;AAAA,EACvD,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,eAAe;AAAA;AAAA,EAEf,gBAAgB;AAAA,EAChB,OAAO;AAAA;AAAA,EACP,SAAS;AAAA;AACX;AAiFO,IAAM,aAAN,MAAiB;AAAA,EACd;AAAA,EACA;AAA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K;AAAA,MACxC;AAAA,MACA,OAAO,KAAK,SAAS,MAAM;AAAA,MAC3B,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;AAyBO,SAAS,iBAAiB,KAAe,QAAsC;AACpF,SAAO,IAAI,WAAW,KAAK,MAAM;AACnC;","names":[]}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import { P as PermissionScope } from '../types-zzK9YOoa.cjs';
|
|
3
|
+
|
|
4
|
+
/** Which DMS this guard fronts. Configuration, not separate code paths. */
|
|
5
|
+
type LegalDms = 'imanage' | 'netdocuments';
|
|
6
|
+
/** The mutations this guard classifies. Upload/version/narrow are ordinary
|
|
7
|
+
* writes; widen-access / change-privilege / external-share / produce are
|
|
8
|
+
* escalation-gated to the supervising lawyer. Any other label defaults to the
|
|
9
|
+
* 'write' tier. */
|
|
10
|
+
type LegalOperation = 'upload' | 'new-version' | 'set-security' | 'share' | 'produce' | 'read';
|
|
11
|
+
interface LegalGuardConfig {
|
|
12
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
13
|
+
agentId: string;
|
|
14
|
+
/** Which DMS this guard fronts. */
|
|
15
|
+
dms: LegalDms;
|
|
16
|
+
/** The workspace / library / vault, recorded on every receipt so an action is
|
|
17
|
+
* attributable to one instance. */
|
|
18
|
+
workspace: string;
|
|
19
|
+
/** The supervising lawyer of record — the named approver for any privilege-
|
|
20
|
+
* sensitive action, and the recorded supervisor on every action (Rule
|
|
21
|
+
* 5.1/5.3). Required if any escalation-class action will be run. */
|
|
22
|
+
supervisorId?: string;
|
|
23
|
+
/** Minimum trust score the agent must hold before any mutation. Default 0. */
|
|
24
|
+
minTrustScore?: number;
|
|
25
|
+
/** For a privilege-sensitive action, escalate to the supervising lawyer and
|
|
26
|
+
* wait for approval instead of denying. Requires the runtime decision plane.
|
|
27
|
+
* Default true (an unsupervised privilege change is what we exist to
|
|
28
|
+
* prevent). */
|
|
29
|
+
escalatePrivilege?: boolean;
|
|
30
|
+
/** Max time to wait for a lawyer's approval, ms. Default 300000 (5 min). */
|
|
31
|
+
escalationTimeoutMs?: number;
|
|
32
|
+
/** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */
|
|
33
|
+
onError?: 'closed' | 'open';
|
|
34
|
+
}
|
|
35
|
+
interface LegalAction {
|
|
36
|
+
/** The DMS operation, e.g. 'upload'. Drives the scope and whether the action
|
|
37
|
+
* is privilege-sensitive. Unknown labels default to write. */
|
|
38
|
+
operation: LegalOperation | string;
|
|
39
|
+
/** The matter the action targets, e.g. 'M-1001'. Recorded for attribution. */
|
|
40
|
+
matterId?: string;
|
|
41
|
+
/** The document the action targets. */
|
|
42
|
+
documentId?: string;
|
|
43
|
+
/** For 'set-security': the current default_security, one of
|
|
44
|
+
* private|inherit|view|public. */
|
|
45
|
+
currentSecurity?: string;
|
|
46
|
+
/** For 'set-security': the target default_security. Widening beyond
|
|
47
|
+
* currentSecurity is escalation-only. */
|
|
48
|
+
targetSecurity?: string;
|
|
49
|
+
/** For 'set-security': true if this changes a privilege designation. Always
|
|
50
|
+
* escalation-only regardless of direction. */
|
|
51
|
+
altersPrivilege?: boolean;
|
|
52
|
+
/** For 'share': true if the recipient is external to the firm. External
|
|
53
|
+
* shares are escalation-only. */
|
|
54
|
+
external?: boolean;
|
|
55
|
+
/** Optional hash of the request body so the receipt covers the exact input
|
|
56
|
+
* without the guard storing it. */
|
|
57
|
+
inputHash?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Why an action was treated as privilege-sensitive (escalation-class). */
|
|
60
|
+
type PrivilegeReason = 'widen-access' | 'alter-privilege' | 'external-share' | 'produce' | null;
|
|
61
|
+
/** How a privilege-sensitive action resolved. */
|
|
62
|
+
type LegalOutcome = 'ordinary' | 'approved-by-lawyer' | 'privilege-denied';
|
|
63
|
+
/** An offline-verifiable receipt for one DMS operation. */
|
|
64
|
+
interface LegalReceipt {
|
|
65
|
+
authorized: boolean;
|
|
66
|
+
agentId: string;
|
|
67
|
+
dms: LegalDms;
|
|
68
|
+
workspace: string;
|
|
69
|
+
operation: string;
|
|
70
|
+
matterId?: string;
|
|
71
|
+
documentId?: string;
|
|
72
|
+
/** True when the action is privilege-sensitive (needs a lawyer). */
|
|
73
|
+
privilegeSensitive: boolean;
|
|
74
|
+
/** Why it was privilege-sensitive, if it was. */
|
|
75
|
+
privilegeReason: PrivilegeReason;
|
|
76
|
+
outcome: LegalOutcome;
|
|
77
|
+
/** The supervising lawyer recorded on the action. */
|
|
78
|
+
supervisorId?: string;
|
|
79
|
+
result: 'success' | 'denied' | 'error';
|
|
80
|
+
scope: PermissionScope;
|
|
81
|
+
reason?: string;
|
|
82
|
+
decisionId?: string;
|
|
83
|
+
recorded: boolean;
|
|
84
|
+
}
|
|
85
|
+
declare class VorimLegal {
|
|
86
|
+
private sdk;
|
|
87
|
+
private agentId;
|
|
88
|
+
private dms;
|
|
89
|
+
private workspace;
|
|
90
|
+
private supervisorId?;
|
|
91
|
+
private minTrustScore;
|
|
92
|
+
private escalatePrivilege;
|
|
93
|
+
private escalationTimeoutMs;
|
|
94
|
+
private onError;
|
|
95
|
+
constructor(sdk: VorimSDK, config: LegalGuardConfig);
|
|
96
|
+
/** Why (if at all) an action is privilege-sensitive. A set-security that
|
|
97
|
+
* widens the ladder or alters privilege, an external share, or a production
|
|
98
|
+
* are all escalation-class. Narrowing access is not. */
|
|
99
|
+
private privilegeReason;
|
|
100
|
+
private isPrivilegeSensitive;
|
|
101
|
+
/** The Vorim scope an action requires. Reads need read; a privilege-sensitive
|
|
102
|
+
* action is elevated; other writes need write. A share/produce map to elevate
|
|
103
|
+
* by default, but a non-external share is a plain write. */
|
|
104
|
+
private scopeFor;
|
|
105
|
+
/**
|
|
106
|
+
* Decide whether the acting agent may run this DMS operation, before it runs.
|
|
107
|
+
* Order: trust floor, then the privilege gate (escalate a widen/alter/external/
|
|
108
|
+
* produce to the supervising lawyer), then permission scope.
|
|
109
|
+
*/
|
|
110
|
+
authorize(action: LegalAction): Promise<{
|
|
111
|
+
authorized: boolean;
|
|
112
|
+
reason?: string;
|
|
113
|
+
outcome: LegalOutcome;
|
|
114
|
+
supervisorId?: string;
|
|
115
|
+
decisionId?: string;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Route a privilege-sensitive action through the runtime decision plane so the
|
|
119
|
+
* supervising lawyer can approve or refuse, and wait. The elevate scope marks
|
|
120
|
+
* the segregation-of-duties gate: the agent proposes, the lawyer authorizes.
|
|
121
|
+
*/
|
|
122
|
+
private escalate;
|
|
123
|
+
/**
|
|
124
|
+
* Emit a source-signed audit event for a DMS operation and return whether it
|
|
125
|
+
* was recorded. The event names the agent, the DMS, the matter/document, the
|
|
126
|
+
* supervising lawyer, and any privilege escalation — the attributable,
|
|
127
|
+
* supervised record that Rule 5.1/5.3 and e-discovery defensibility reward.
|
|
128
|
+
*/
|
|
129
|
+
record(action: LegalAction, result: 'success' | 'denied' | 'error', extra?: {
|
|
130
|
+
reason?: string;
|
|
131
|
+
outcome?: LegalOutcome;
|
|
132
|
+
supervisorId?: string;
|
|
133
|
+
decisionId?: string;
|
|
134
|
+
}): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* The full flow for one DMS operation: authorize (trust, privilege gate,
|
|
137
|
+
* scope), run the DMS call if allowed, sign a receipt either way. If not
|
|
138
|
+
* authorized, `run` is never called. Rethrows a DMS error from `run` after
|
|
139
|
+
* recording it, with the receipt attached as `vorimReceipt`.
|
|
140
|
+
*/
|
|
141
|
+
guard<T>(action: LegalAction, run: () => Promise<T>): Promise<{
|
|
142
|
+
receipt: LegalReceipt;
|
|
143
|
+
value?: T;
|
|
144
|
+
}>;
|
|
145
|
+
/** Guard a document upload to a matter. Requires agent:write. */
|
|
146
|
+
guardedUpload<T>(meta: {
|
|
147
|
+
matterId?: string;
|
|
148
|
+
documentId?: string;
|
|
149
|
+
inputHash?: string;
|
|
150
|
+
}, run: () => Promise<T>): Promise<{
|
|
151
|
+
receipt: LegalReceipt;
|
|
152
|
+
value?: T | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
/** Guard a new-version check-in. Requires agent:write. */
|
|
155
|
+
guardedNewVersion<T>(meta: {
|
|
156
|
+
matterId?: string;
|
|
157
|
+
documentId?: string;
|
|
158
|
+
inputHash?: string;
|
|
159
|
+
}, run: () => Promise<T>): Promise<{
|
|
160
|
+
receipt: LegalReceipt;
|
|
161
|
+
value?: T | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
/** Guard a security/permissions change. Narrowing access is a write; WIDENING
|
|
164
|
+
* (targetSecurity above currentSecurity) or altering a privilege designation
|
|
165
|
+
* escalates to the supervising lawyer. */
|
|
166
|
+
guardedSetSecurity<T>(meta: {
|
|
167
|
+
matterId?: string;
|
|
168
|
+
documentId?: string;
|
|
169
|
+
currentSecurity?: string;
|
|
170
|
+
targetSecurity?: string;
|
|
171
|
+
altersPrivilege?: boolean;
|
|
172
|
+
inputHash?: string;
|
|
173
|
+
}, run: () => Promise<T>): Promise<{
|
|
174
|
+
receipt: LegalReceipt;
|
|
175
|
+
value?: T | undefined;
|
|
176
|
+
}>;
|
|
177
|
+
/** Guard a share. An external share escalates to the supervising lawyer; an
|
|
178
|
+
* internal share is an ordinary write. */
|
|
179
|
+
guardedShare<T>(meta: {
|
|
180
|
+
matterId?: string;
|
|
181
|
+
documentId?: string;
|
|
182
|
+
external?: boolean;
|
|
183
|
+
inputHash?: string;
|
|
184
|
+
}, run: () => Promise<T>): Promise<{
|
|
185
|
+
receipt: LegalReceipt;
|
|
186
|
+
value?: T | undefined;
|
|
187
|
+
}>;
|
|
188
|
+
/** Guard a discovery production. Always escalates to the supervising lawyer
|
|
189
|
+
* and signs a full chain-of-custody record. */
|
|
190
|
+
guardedProduce<T>(meta: {
|
|
191
|
+
matterId?: string;
|
|
192
|
+
documentId?: string;
|
|
193
|
+
inputHash?: string;
|
|
194
|
+
}, run: () => Promise<T>): Promise<{
|
|
195
|
+
receipt: LegalReceipt;
|
|
196
|
+
value?: T | undefined;
|
|
197
|
+
}>;
|
|
198
|
+
private receipt;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Create a VorimLegal guard around a Vorim SDK instance.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* import createVorim from '@vorim/sdk';
|
|
206
|
+
* import { createVorimLegal } from '@vorim/sdk/integrations/legal';
|
|
207
|
+
*
|
|
208
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
209
|
+
* const legal = createVorimLegal(vorim, {
|
|
210
|
+
* agentId: 'agid_abc123',
|
|
211
|
+
* dms: 'imanage',
|
|
212
|
+
* workspace: 'acme-imanage',
|
|
213
|
+
* supervisorId: 'lawyer_42',
|
|
214
|
+
* });
|
|
215
|
+
*
|
|
216
|
+
* // Widening access escalates to the supervising lawyer; narrowing does not:
|
|
217
|
+
* const { receipt } = await legal.guardedSetSecurity(
|
|
218
|
+
* { documentId: 'DOC-9', currentSecurity: 'private', targetSecurity: 'public' },
|
|
219
|
+
* () => imanage.updateDefaultSecurity('DOC-9', 'public'),
|
|
220
|
+
* );
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
declare function createVorimLegal(sdk: VorimSDK, config: LegalGuardConfig): VorimLegal;
|
|
224
|
+
|
|
225
|
+
export { type LegalAction, type LegalDms, type LegalGuardConfig, type LegalOperation, type LegalOutcome, type LegalReceipt, type PrivilegeReason, VorimLegal, createVorimLegal };
|