@deliverd/sdk 0.37.0 → 0.38.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.
@@ -0,0 +1,439 @@
1
+ import { DeliverdTimeoutError } from "../errors.js";
2
+ import { askAboutCall } from "./shared.js";
3
+ /**
4
+ * A `PermissionRequest` hook entry: each call OpenRouter would pause for is
5
+ * decided by a person in Deliverd, and the run carries on.
6
+ *
7
+ * A call `when` does not select is allowed, as with the other adapters.
8
+ * OpenRouter's payload carries no call id, so a call is keyed by the session
9
+ * (or, when the run names none, this hook), the tool, its input and how many
10
+ * times that same call has come up: the same call asked again in one run gets
11
+ * a request of its own, and another run never reuses this one's yes.
12
+ */
13
+ export function deliverdPermissionRequest(options) {
14
+ const seen = new Map();
15
+ // OpenRouter leaves the session id empty unless the run names one; a key
16
+ // without it would let one run reuse another's yes for the same input.
17
+ const instance = `run_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 10)}`;
18
+ return {
19
+ async handler(payload, context) {
20
+ const toolName = payload.toolName || "a tool";
21
+ const input = payload.toolInput ?? {};
22
+ if (options.when && !(await options.when(toolName, input)))
23
+ return { decision: "allow" };
24
+ const base = `openrouter:${context?.sessionId || instance}:${toolName}:${fingerprint(input)}`;
25
+ const occurrence = (seen.get(base) ?? 0) + 1;
26
+ seen.set(base, occurrence);
27
+ const outcome = await askAboutCall(toolName, input, occurrence === 1 ? base : `${base}:${occurrence}`, withRisk(options, payload.riskLevel), context?.signal);
28
+ return outcome.allowed ? { decision: "allow" } : { decision: "deny", reason: outcome.reason };
29
+ },
30
+ };
31
+ }
32
+ /**
33
+ * Ask about every call a paused run is waiting on, and return the decisions
34
+ * to resume it with. Calls `when` does not select are approved.
35
+ */
36
+ export async function resolveOpenRouterApprovals(result, options) {
37
+ const resume = { approveToolCalls: [], rejectToolCalls: [], reasons: {} };
38
+ const pending = await result.getPendingToolCalls();
39
+ if (pending.length === 0)
40
+ return resume;
41
+ const { id: conversationId } = await result.getState();
42
+ for (const call of pending) {
43
+ const toolName = String(call.name || "a tool");
44
+ const input = parseArguments(call.arguments);
45
+ if (options.when && !(await options.when(toolName, input))) {
46
+ resume.approveToolCalls.push(call.id);
47
+ continue;
48
+ }
49
+ const outcome = await askAboutCall(toolName, input, `openrouter:${conversationId}:${call.id}`, options);
50
+ if (outcome.allowed) {
51
+ resume.approveToolCalls.push(call.id);
52
+ }
53
+ else {
54
+ resume.rejectToolCalls.push(call.id);
55
+ resume.reasons[call.id] = outcome.reason;
56
+ }
57
+ }
58
+ return resume;
59
+ }
60
+ /** OpenRouter's own reading of the risk, when the caller did not describe the call. */
61
+ function withRisk(options, risk) {
62
+ if (options.describe || !risk)
63
+ return options;
64
+ return {
65
+ ...options,
66
+ describe: (toolName, input) => {
67
+ const rendered = safeJson(input);
68
+ return {
69
+ title: `Allow the agent to run ${toolName}`,
70
+ description: rendered ? `With this input:\n\n${rendered}` : undefined,
71
+ risk,
72
+ };
73
+ },
74
+ };
75
+ }
76
+ function parseArguments(raw) {
77
+ if (typeof raw !== "string")
78
+ return raw ?? {};
79
+ try {
80
+ return JSON.parse(raw);
81
+ }
82
+ catch {
83
+ return raw;
84
+ }
85
+ }
86
+ function safeJson(input) {
87
+ try {
88
+ const text = JSON.stringify(input, null, 2) ?? "";
89
+ return text.length > 3000 ? `${text.slice(0, 2999)}…` : text;
90
+ }
91
+ catch {
92
+ return String(input);
93
+ }
94
+ }
95
+ /** A short, stable key for an input: FNV-1a over its JSON with sorted keys. */
96
+ function fingerprint(input) {
97
+ const text = canonical(input);
98
+ let hash = 0x811c9dc5;
99
+ for (let i = 0; i < text.length; i++) {
100
+ hash ^= text.charCodeAt(i);
101
+ hash = Math.imul(hash, 0x01000193) >>> 0;
102
+ }
103
+ return hash.toString(16).padStart(8, "0");
104
+ }
105
+ function canonical(value) {
106
+ if (value === null || typeof value !== "object")
107
+ return JSON.stringify(value) ?? "null";
108
+ if (Array.isArray(value))
109
+ return `[${value.map(canonical).join(",")}]`;
110
+ const entries = Object.keys(value)
111
+ .sort()
112
+ .map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`);
113
+ return `{${entries.join(",")}}`;
114
+ }
115
+ const FIELDS = [
116
+ { key: "name", wire: "name", label: "Name" },
117
+ { key: "description", wire: "description", label: "Description" },
118
+ { key: "limitUsd", wire: "limit_usd", label: "Spend limit (USD)" },
119
+ { key: "resetInterval", wire: "reset_interval", label: "Limit resets" },
120
+ { key: "allowedModels", wire: "allowed_models", label: "Allowed models" },
121
+ { key: "ignoredModels", wire: "ignored_models", label: "Blocked models" },
122
+ { key: "allowedProviders", wire: "allowed_providers", label: "Allowed providers" },
123
+ { key: "ignoredProviders", wire: "ignored_providers", label: "Blocked providers" },
124
+ { key: "enforceZdr", wire: "enforce_zdr", label: "Zero data retention" },
125
+ { key: "allowedDataRegions", wire: "allowed_data_regions", label: "Data regions" },
126
+ { key: "enablePaidModelTraining", wire: "enable_paid_model_training", label: "Paid models may train on prompts" },
127
+ { key: "enableFreeModelTraining", wire: "enable_free_model_training", label: "Free models may train on prompts" },
128
+ { key: "enableFreeModelPublication", wire: "enable_free_model_publication", label: "Free models may publish prompts" },
129
+ ];
130
+ /**
131
+ * Change an OpenRouter guardrail only once a person says yes.
132
+ *
133
+ * The approver sees each setting that would change, before and after. A
134
+ * change that loosens anything (a higher or removed spend limit, zero data
135
+ * retention off, training on, more regions, models or providers) is asked as
136
+ * high risk. The same change to the same guardrail, asked again before it was
137
+ * applied, finds the same request; once the guardrail has changed, a new ask
138
+ * is a new request.
139
+ */
140
+ export async function changeOpenRouterGuardrail(guardrailId, change, options) {
141
+ const path = `/guardrails/${encodeURIComponent(guardrailId)}`;
142
+ const current = await openRouterRequest(options.openrouter, "GET", path);
143
+ const body = {};
144
+ const lines = [];
145
+ let loosens = false;
146
+ for (const { key, wire, label } of FIELDS) {
147
+ if (!(key in change))
148
+ continue;
149
+ const next = change[key] ?? null;
150
+ const before = current[wire] ?? null;
151
+ if (same(before, next))
152
+ continue;
153
+ body[wire] = next;
154
+ lines.push(`${label}: ${show(before)} → ${show(next)}`);
155
+ if (loosening(key, before, next))
156
+ loosens = true;
157
+ }
158
+ if (lines.length === 0) {
159
+ return { applied: false, reason: "The guardrail already has these settings, so nothing was asked or changed.", approvalId: null, changes: [] };
160
+ }
161
+ const name = typeof current.name === "string" ? current.name : guardrailId;
162
+ const outcome = await ask(options, {
163
+ title: `Change the OpenRouter guardrail “${name}”`,
164
+ description: [options.reason, lines.map((line) => `- ${line}`).join("\n")].filter(Boolean).join("\n\n"),
165
+ risk: loosens ? "high" : "medium",
166
+ externalId: `openrouter-guardrail:${guardrailId}:${String(current.updated_at ?? current.created_at ?? "")}:${digestOf(body)}`,
167
+ input: body,
168
+ metadata: { openrouterGuardrailId: guardrailId },
169
+ });
170
+ if (!outcome.allowed)
171
+ return { applied: false, reason: outcome.reason, approvalId: outcome.approvalId, changes: lines };
172
+ await openRouterRequest(options.openrouter, "PATCH", path, body);
173
+ return { applied: true, decidedBy: outcome.decidedBy, approvalId: outcome.approvalId, changes: lines };
174
+ }
175
+ /**
176
+ * Raise (or change, or remove) one OpenRouter key's credit limit only once a
177
+ * person says yes. The approver sees what the key has spent against its
178
+ * current limit. Removing a limit, or more than doubling it, is high risk.
179
+ */
180
+ export async function raiseOpenRouterKeyLimit(keyHash, next, options) {
181
+ const path = `/keys/${encodeURIComponent(keyHash)}`;
182
+ const key = await openRouterRequest(options.openrouter, "GET", path);
183
+ const before = typeof key.limit === "number" ? key.limit : null;
184
+ const body = { limit: next.limit };
185
+ if ("limitReset" in next)
186
+ body.limit_reset = next.limitReset ?? null;
187
+ const lines = [`Credit limit (USD): ${show(before)} → ${show(next.limit)}`];
188
+ if ("limitReset" in next && !same(key.limit_reset ?? null, next.limitReset ?? null)) {
189
+ lines.push(`Limit resets: ${show(key.limit_reset ?? null)} → ${show(next.limitReset ?? null)}`);
190
+ }
191
+ if (same(before, next.limit) && lines.length === 1) {
192
+ return { applied: false, reason: "The key already has this limit, so nothing was asked or changed.", approvalId: null, changes: [] };
193
+ }
194
+ const spent = typeof key.usage === "number" ? `It has spent $${key.usage.toFixed(2)} so far` : null;
195
+ const monthly = typeof key.usage_monthly === "number" ? `, $${key.usage_monthly.toFixed(2)} this month` : "";
196
+ const label = typeof key.name === "string" && key.name ? key.name : String(key.label ?? keyHash);
197
+ const outcome = await ask(options, {
198
+ title: next.limit === null ? `Remove the spend limit on OpenRouter key “${label}”` : `Set OpenRouter key “${label}” to a $${next.limit} limit`,
199
+ description: [options.reason, spent ? `${spent}${monthly}.` : null, lines.map((line) => `- ${line}`).join("\n")].filter(Boolean).join("\n\n"),
200
+ risk: next.limit === null || (before !== null && next.limit > before * 2) ? "high" : "medium",
201
+ externalId: `openrouter-key:${keyHash}:${String(key.updated_at ?? key.created_at ?? "")}:${digestOf(body)}`,
202
+ input: body,
203
+ metadata: { openrouterKeyHash: keyHash },
204
+ });
205
+ if (!outcome.allowed)
206
+ return { applied: false, reason: outcome.reason, approvalId: outcome.approvalId, changes: lines };
207
+ await openRouterRequest(options.openrouter, "PATCH", path, body);
208
+ return { applied: true, decidedBy: outcome.decidedBy, approvalId: outcome.approvalId, changes: lines };
209
+ }
210
+ const CLASS_ORDER = ["consumer", "enterprise", "private"];
211
+ /**
212
+ * Read the AI use policy for the data a key will carry.
213
+ *
214
+ * OpenRouter on its defaults is treated as a consumer tool. With zero data
215
+ * retention enforced and training and publication off, under your own
216
+ * agreement with OpenRouter, it is treated as an enterprise tenant. It is
217
+ * never a private deployment. Pass the policy from
218
+ * `deliverd.governance.aiUsePolicy()`.
219
+ */
220
+ export function openRouterGuardrailForData(policy, data, options = {}) {
221
+ let needed = 0;
222
+ const conditions = [];
223
+ for (const kind of data.length ? data : ["internal"]) {
224
+ const row = policy.grid[kind];
225
+ const first = CLASS_ORDER.findIndex((cls) => row?.[cls] && row[cls].rule !== "no");
226
+ if (first === -1) {
227
+ return {
228
+ allowed: false,
229
+ deploymentClass: null,
230
+ guardrail: {},
231
+ conditions: [],
232
+ explanation: `The AI use policy says ${labelOf(kind)} goes into no AI tool, so it may not go through OpenRouter.`,
233
+ };
234
+ }
235
+ needed = Math.max(needed, first);
236
+ }
237
+ const cls = CLASS_ORDER[needed];
238
+ for (const kind of data) {
239
+ const cell = policy.grid[kind]?.[cls];
240
+ if (cell?.rule === "conditional" && cell.condition)
241
+ conditions.push(`${labelOf(kind)}: ${cell.condition}`);
242
+ }
243
+ if (cls === "private") {
244
+ return {
245
+ allowed: false,
246
+ deploymentClass: cls,
247
+ guardrail: {},
248
+ conditions,
249
+ explanation: "The AI use policy keeps this data to a private deployment (your own cloud and region). OpenRouter is a hosted router, so it may not carry it.",
250
+ };
251
+ }
252
+ const guardrail = cls === "enterprise"
253
+ ? { enforceZdr: true, enablePaidModelTraining: false, enableFreeModelTraining: false, enableFreeModelPublication: false }
254
+ : {};
255
+ if (options.region)
256
+ guardrail.allowedDataRegions = [options.region];
257
+ return {
258
+ allowed: true,
259
+ deploymentClass: cls,
260
+ guardrail,
261
+ conditions,
262
+ explanation: cls === "enterprise"
263
+ ? "The AI use policy needs an enterprise tenant for this data. Enforce zero data retention and turn training and publication off, and make sure your agreement with OpenRouter covers it."
264
+ : "The AI use policy lets this data go into consumer tools, so no guardrail setting is needed for it.",
265
+ };
266
+ }
267
+ /** The models a management key's organisation used through OpenRouter, from its activity (the last 30 days), most requests first. */
268
+ export async function openRouterModelsInUse(openrouter) {
269
+ const { data } = await openRouterRequest(openrouter, "GET", "/activity", undefined, true);
270
+ const byModel = new Map();
271
+ for (const row of data ?? []) {
272
+ const model = typeof row.model === "string" ? row.model : null;
273
+ if (!model)
274
+ continue;
275
+ const date = typeof row.date === "string" ? row.date : "";
276
+ const entry = byModel.get(model) ?? { model, providers: [], requests: 0, usage: 0, firstSeen: date, lastSeen: date };
277
+ const provider = typeof row.provider_name === "string" ? row.provider_name : null;
278
+ if (provider && !entry.providers.includes(provider))
279
+ entry.providers.push(provider);
280
+ entry.requests += typeof row.requests === "number" ? row.requests : 0;
281
+ entry.usage += typeof row.usage === "number" ? row.usage : 0;
282
+ if (date && (!entry.firstSeen || date < entry.firstSeen))
283
+ entry.firstSeen = date;
284
+ if (date && date > entry.lastSeen)
285
+ entry.lastSeen = date;
286
+ byModel.set(model, entry);
287
+ }
288
+ return [...byModel.values()].sort((a, b) => b.requests - a.requests);
289
+ }
290
+ /**
291
+ * Add each model OpenRouter routed to, and nobody registered, to the AI
292
+ * register as found in use (`entryType: "discovered"`, supplier OpenRouter),
293
+ * for a person to triage. A model already on a record, active or retired, is
294
+ * left alone. Returns what it added and what it skipped.
295
+ */
296
+ export async function registerOpenRouterModels(options) {
297
+ const [models, records] = await Promise.all([openRouterModelsInUse(options.openrouter), options.deliverd.governance.aiSystems.list()]);
298
+ const known = new Set(records.map((record) => record.model).filter((model) => Boolean(model)));
299
+ const registered = [];
300
+ const skipped = [];
301
+ for (const use of models) {
302
+ if (known.has(use.model) || use.requests < (options.minRequests ?? 1)) {
303
+ skipped.push(use.model);
304
+ continue;
305
+ }
306
+ const record = await options.deliverd.governance.aiSystems.register({
307
+ name: `${use.model} via OpenRouter`,
308
+ provider: use.providers.join(", ") || null,
309
+ model: use.model,
310
+ supplier: "OpenRouter",
311
+ buildOrBuy: "buy",
312
+ entryType: "discovered",
313
+ purpose: `Found in OpenRouter activity: ${use.requests} request${use.requests === 1 ? "" : "s"} between ${use.firstSeen.slice(0, 10)} and ${use.lastSeen.slice(0, 10)}. Who uses it, and for what, is for a person to fill in.`,
314
+ ...options.defaults,
315
+ });
316
+ known.add(use.model);
317
+ registered.push({ id: record.id, model: use.model });
318
+ }
319
+ return { registered, skipped };
320
+ }
321
+ /* ── Plumbing ─────────────────────────────────────────────────────────── */
322
+ async function openRouterRequest(admin, method, path, body, whole = false) {
323
+ const doFetch = admin.fetch ?? fetch;
324
+ const base = (admin.baseUrl ?? "https://openrouter.ai/api/v1").replace(/\/+$/, "");
325
+ const response = await doFetch(`${base}${path}`, {
326
+ method,
327
+ headers: {
328
+ authorization: `Bearer ${admin.managementKey}`,
329
+ ...(body === undefined ? {} : { "content-type": "application/json" }),
330
+ },
331
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
332
+ });
333
+ const text = await response.text();
334
+ if (!response.ok) {
335
+ let message = text.slice(0, 300);
336
+ try {
337
+ const parsed = JSON.parse(text);
338
+ if (parsed.error?.message)
339
+ message = parsed.error.message;
340
+ }
341
+ catch {
342
+ /* keep the text */
343
+ }
344
+ throw new Error(`OpenRouter ${method} ${path} failed (${response.status}): ${message}`);
345
+ }
346
+ const json = text ? JSON.parse(text) : {};
347
+ return (whole ? json : (json.data ?? json));
348
+ }
349
+ async function ask(options, request) {
350
+ let decision;
351
+ try {
352
+ decision = await options.deliverd.approve({
353
+ title: request.title,
354
+ description: request.description,
355
+ risk: request.risk,
356
+ approvers: options.approvers,
357
+ externalId: request.externalId,
358
+ flowId: options.flowId,
359
+ input: request.input,
360
+ metadata: { ...options.metadata, ...request.metadata, source: "openrouter" },
361
+ expiresIn: options.expiresIn ?? "1d",
362
+ timeout: options.timeout,
363
+ });
364
+ }
365
+ catch (err) {
366
+ if (err instanceof DeliverdTimeoutError) {
367
+ return { allowed: false, reason: "Nobody decided in time, so nothing was changed.", approvalId: null };
368
+ }
369
+ throw err;
370
+ }
371
+ if (decision.approved)
372
+ return { allowed: true, decidedBy: decision.decidedBy, approvalId: decision.id };
373
+ const who = decision.decidedBy ? ` by ${decision.decidedBy}` : "";
374
+ const why = decision.note ? ` Their reason: ${decision.note}` : "";
375
+ const reason = decision.status === "rejected"
376
+ ? `A person declined the change${who}, so nothing was changed.${why}`
377
+ : decision.status === "expired"
378
+ ? "Nobody decided before the request expired, so nothing was changed."
379
+ : "The request was withdrawn, so nothing was changed.";
380
+ return { allowed: false, reason, approvalId: decision.id };
381
+ }
382
+ function show(value) {
383
+ if (value === null || value === undefined)
384
+ return "none";
385
+ if (Array.isArray(value))
386
+ return value.length ? value.join(", ") : "none";
387
+ if (typeof value === "boolean")
388
+ return value ? "on" : "off";
389
+ return String(value);
390
+ }
391
+ function same(a, b) {
392
+ const norm = (v) => (Array.isArray(v) ? JSON.stringify([...v].map(String).sort()) : JSON.stringify(v ?? null));
393
+ return norm(a) === norm(b);
394
+ }
395
+ /** Whether moving from `before` to `after` gives the key more room than it had. */
396
+ function loosening(key, before, after) {
397
+ switch (key) {
398
+ case "limitUsd":
399
+ return after === null || (typeof before === "number" && typeof after === "number" && after > before);
400
+ case "enforceZdr":
401
+ return before === true && after !== true;
402
+ case "enablePaidModelTraining":
403
+ case "enableFreeModelTraining":
404
+ case "enableFreeModelPublication":
405
+ return after === true;
406
+ case "allowedModels":
407
+ case "allowedProviders":
408
+ case "allowedDataRegions": {
409
+ // null or empty means "anything": widening from a list to anything, or adding to the list.
410
+ const was = Array.isArray(before) ? before.map(String) : null;
411
+ const now = Array.isArray(after) ? after.map(String) : null;
412
+ if (!now || now.length === 0)
413
+ return Boolean(was && was.length);
414
+ if (!was || was.length === 0)
415
+ return false;
416
+ return now.some((item) => !was.includes(item));
417
+ }
418
+ case "ignoredModels":
419
+ case "ignoredProviders": {
420
+ const was = Array.isArray(before) ? before.map(String) : [];
421
+ const now = Array.isArray(after) ? after.map(String) : [];
422
+ return was.some((item) => !now.includes(item));
423
+ }
424
+ default:
425
+ return false;
426
+ }
427
+ }
428
+ function labelOf(kind) {
429
+ return { public: "public data", internal: "internal data", confidential: "confidential data", restricted: "restricted data", personal: "personal data", special: "special-category data" }[kind];
430
+ }
431
+ function digestOf(value) {
432
+ const text = JSON.stringify(value, Object.keys((value ?? {})).sort());
433
+ let hash = 0x811c9dc5;
434
+ for (let i = 0; i < text.length; i++) {
435
+ hash ^= text.charCodeAt(i);
436
+ hash = Math.imul(hash, 0x01000193) >>> 0;
437
+ }
438
+ return hash.toString(16).padStart(8, "0");
439
+ }
@@ -7,7 +7,7 @@ import type { ApprovalFactor, ApprovalRisk, Decision, FieldChange } from "../typ
7
7
  * The adapters are written against each framework's own hook — the Claude
8
8
  * Agent SDK's `canUseTool`, the AI SDK's `toolApproval`, the OpenAI Agents
9
9
  * SDK's interruptions, LangGraph's `interrupt`, Mastra's suspended tool
10
- * approvals, the function calls in a Muse Spark response — by shape rather than by
10
+ * approvals, OpenRouter's `PermissionRequest` hook and paused calls, the function calls in a Muse Spark response — by shape rather than by
11
11
  * import, so `@deliverd/sdk` keeps its promise of no dependencies. Each
12
12
  * shape was taken from that framework's published type definitions and is
13
13
  * checked against them in this package's tests.
@@ -1,6 +1,6 @@
1
1
  import type { HttpClient } from "./http.js";
2
2
  import { type PageOf } from "./paging.js";
3
- import type { AiIncident, AiIncidentDetail, AiSystem, AiSystemDetail, AuthorityDecision, CheckAuthorityInput, CreateCustomFrameworkInput, CustomFramework, DraftedIncidentReport, DraftIncidentReportInput, FrameworkCatalogue, FrameworkMapping, FrameworkMappingInput, GovernanceSummary, GovernanceSummaryInput, IctRegister, ListIncidentsInput, ModelChangeInput, ModelChangeResult, RegisterAiSystemInput, ReportIncidentInput, UpdateAiSystemInput } from "./types.js";
3
+ import type { AiIncident, AiIncidentDetail, AiSystem, AiSystemDetail, AuthorityDecision, CheckAuthorityInput, CreateCustomFrameworkInput, CustomFramework, DraftedIncidentReport, DraftIncidentReportInput, FrameworkCatalogue, FrameworkMapping, FrameworkMappingInput, GovernanceSummary, GovernanceSummaryInput, IctRegister, ListIncidentsInput, UsePolicy, ModelChangeInput, ModelChangeResult, RegisterAiSystemInput, ReportIncidentInput, UpdateAiSystemInput } from "./types.js";
4
4
  /**
5
5
  * The organisation's register of AI systems. A governed task names one by
6
6
  * `aiSystemId` instead of describing it again, and a change of model is
@@ -88,6 +88,11 @@ export declare class AiGovernance {
88
88
  createCustomFramework(input: CreateCustomFrameworkInput, signal?: AbortSignal): Promise<CustomFramework>;
89
89
  /** The ICT third-party register: providers, contracts, the AI systems under each, gaps and concentration. */
90
90
  ictRegister(signal?: AbortSignal): Promise<IctRegister>;
91
+ /**
92
+ * The AI use policy: which data may go into which kind of AI tool. Read
93
+ * only; a person changes it in the app (Governance → AI use policy).
94
+ */
95
+ aiUsePolicy(signal?: AbortSignal): Promise<UsePolicy>;
91
96
  /** The organisation's AI governance in counts, optionally narrowed. Never a compliance percentage. */
92
97
  summary(input?: GovernanceSummaryInput, signal?: AbortSignal): Promise<GovernanceSummary>;
93
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../src/governance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAIpB;;;;GAIG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,6DAA6D;IACvD,IAAI,CAAC,KAAK,GAAE;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;KAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUlG,uDAAuD;IACvD,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;IAI9D,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,qBAAqB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IA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", path: "/governance/ict-register", signal });
156
156
  }
157
+ /**
158
+ * The AI use policy: which data may go into which kind of AI tool. Read
159
+ * only; a person changes it in the app (Governance → AI use policy).
160
+ */
161
+ async aiUsePolicy(signal) {
162
+ const { policy } = await this.http.request({ method: "GET", path: "/governance/ai-use-policy", signal });
163
+ return policy;
164
+ }
157
165
  /** The organisation's AI governance in counts, optionally narrowed. Never a compliance percentage. */
158
166
  summary(input = {}, signal) {
159
167
  return this.http.request({
@@ -43,7 +43,7 @@
43
43
  * **Add the version here when you publish it, not before.** An entry is a
44
44
  * claim that `npm install @deliverd/sdk@x` works today.
45
45
  */
46
- export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0", "0.13.0", "0.14.0", "0.15.0", "0.16.0", "0.17.0", "0.18.0", "0.19.0", "0.20.0", "0.21.0", "0.22.0", "0.23.0", "0.24.0", "0.24.1", "0.25.0", "0.25.1", "0.26.0", "0.27.0", "0.28.0", "0.29.0", "0.30.0", "0.31.0", "0.32.0", "0.33.0", "0.34.0", "0.35.0", "0.36.0"];
46
+ export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1", "0.12.0", "0.13.0", "0.14.0", "0.15.0", "0.16.0", "0.17.0", "0.18.0", "0.19.0", "0.20.0", "0.21.0", "0.22.0", "0.23.0", "0.24.0", "0.24.1", "0.25.0", "0.25.1", "0.26.0", "0.27.0", "0.28.0", "0.29.0", "0.30.0", "0.31.0", "0.32.0", "0.33.0", "0.34.0", "0.35.0", "0.36.0", "0.37.0"];
47
47
  /**
48
48
  * A fingerprint of what each *published* version recorded.
49
49
  *
@@ -1 +1 @@
1
- {"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,qbA6CnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuHzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAu7mCtD,CAAC"}
1
+ {"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,+bA8CnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyHzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CA+7pCtD,CAAC"}