@deliverd/sdk 0.25.1 → 0.27.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/README.md +104 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/mastra.d.ts +81 -0
- package/dist/adapters/mastra.d.ts.map +1 -0
- package/dist/adapters/mastra.js +54 -0
- package/dist/adapters/muse-spark.d.ts +79 -0
- package/dist/adapters/muse-spark.d.ts.map +1 -0
- package/dist/adapters/muse-spark.js +59 -0
- package/dist/adapters/shared.d.ts +2 -1
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/data-screen.d.ts +233 -0
- package/dist/data-screen.d.ts.map +1 -0
- package/dist/data-screen.js +395 -0
- package/dist/decision-token.d.ts +102 -0
- package/dist/decision-token.d.ts.map +1 -0
- package/dist/decision-token.js +139 -0
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +57 -2
- package/dist/gates.d.ts +2 -0
- package/dist/gates.d.ts.map +1 -1
- package/dist/gates.js +3 -0
- package/dist/governance.d.ts +94 -0
- package/dist/governance.d.ts.map +1 -0
- package/dist/governance.js +166 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +4 -0
- package/dist/released.d.ts +1 -1
- package/dist/released.d.ts.map +1 -1
- package/dist/released.js +3803 -0
- package/dist/screen.d.ts +85 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +69 -0
- package/dist/tasks.d.ts +38 -1
- package/dist/tasks.d.ts.map +1 -1
- package/dist/tasks.js +67 -0
- package/dist/types.d.ts +656 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/index.ts +11 -0
- package/src/adapters/mastra.ts +118 -0
- package/src/adapters/muse-spark.ts +147 -0
- package/src/adapters/shared.ts +2 -1
- package/src/data-screen.ts +536 -0
- package/src/decision-token.ts +184 -0
- package/src/dev.ts +63 -2
- package/src/gates.ts +3 -0
- package/src/governance.ts +204 -0
- package/src/index.ts +60 -0
- package/src/messages.ts +4 -0
- package/src/released.ts +3804 -0
- package/src/screen.ts +144 -0
- package/src/tasks.ts +88 -0
- package/src/types.ts +646 -4
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type KeyObject } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Checking a decision token where the action happens.
|
|
4
|
+
*
|
|
5
|
+
* A gate that may be acted on carries `decisionToken`: the yes, signed with
|
|
6
|
+
* the deployment's Ed25519 evidence key. Hand it to the service that performs
|
|
7
|
+
* the action — the one that issues the refund or merges the change — and that
|
|
8
|
+
* service checks it against what it is about to do before it does it:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const check = await deliverd.decisionTokens.verify(req.headers["deliverd-decision"], {
|
|
12
|
+
* action: "finance.refund",
|
|
13
|
+
* input: { customer_id, amount, currency },
|
|
14
|
+
* });
|
|
15
|
+
* if (!check.ok) return res.status(403).send(check.reason);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* It fails when the token was not signed by your Deliverd, has expired, is for
|
|
19
|
+
* another action, or was agreed for a different input: a refund of £1240
|
|
20
|
+
* against a yes for £1200 is refused. It needs no API key and makes no call
|
|
21
|
+
* beyond fetching the public key once.
|
|
22
|
+
*
|
|
23
|
+
* What it does not check is how many times the yes has been used. Record the
|
|
24
|
+
* execution against the gate (`gate.recordExecution`) to spend the use; the
|
|
25
|
+
* server refuses a second.
|
|
26
|
+
*
|
|
27
|
+
* Kept byte-for-byte with the server's `lib/governance/decision-token.ts`;
|
|
28
|
+
* `decision-token.test.ts` on the server signs there and verifies here.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DECISION_TOKEN_PREFIX = "dlv_dt1";
|
|
31
|
+
export declare const DECISION_TOKEN_CONTEXT = "deliverd-decision-token:v1:";
|
|
32
|
+
/** Where a deployment publishes the key that signs its tokens and evidence packs. */
|
|
33
|
+
export declare const EVIDENCE_KEY_PATH = "/.well-known/deliverd-evidence-key";
|
|
34
|
+
export interface DecisionTokenClaims {
|
|
35
|
+
v: 1;
|
|
36
|
+
kid: string;
|
|
37
|
+
iss: string;
|
|
38
|
+
org: string;
|
|
39
|
+
gate: string;
|
|
40
|
+
action: string;
|
|
41
|
+
/** Hex SHA-256 of the approved input in canonical JSON. */
|
|
42
|
+
input: string;
|
|
43
|
+
dest: {
|
|
44
|
+
type: string;
|
|
45
|
+
id: string;
|
|
46
|
+
} | null;
|
|
47
|
+
artifact: string | null;
|
|
48
|
+
iat: number;
|
|
49
|
+
exp: number;
|
|
50
|
+
}
|
|
51
|
+
export interface DecisionTokenExpectation {
|
|
52
|
+
/** The action you are about to perform. */
|
|
53
|
+
action: string;
|
|
54
|
+
/** The input you are about to perform it with. */
|
|
55
|
+
input: unknown;
|
|
56
|
+
/** Where it lands, when the gate named a destination. */
|
|
57
|
+
destination?: {
|
|
58
|
+
type: string;
|
|
59
|
+
id: string;
|
|
60
|
+
} | null;
|
|
61
|
+
/** The SHA-256 of what you are sending, when the gate named an artifact. */
|
|
62
|
+
artifactSha256?: string | null;
|
|
63
|
+
}
|
|
64
|
+
export type DecisionTokenFailure = "missing" | "malformed" | "bad_signature" | "wrong_issuer" | "expired" | "wrong_action" | "input_mismatch" | "destination_mismatch" | "artifact_mismatch";
|
|
65
|
+
export type DecisionTokenResult = {
|
|
66
|
+
ok: true;
|
|
67
|
+
claims: DecisionTokenClaims;
|
|
68
|
+
} | {
|
|
69
|
+
ok: false;
|
|
70
|
+
reason: DecisionTokenFailure;
|
|
71
|
+
};
|
|
72
|
+
/** Keys sorted at every depth, undefined dropped: the server's `canonicalJson`. */
|
|
73
|
+
export declare function canonicalJson(value: unknown): string;
|
|
74
|
+
export declare function decisionInputHash(input: unknown): string;
|
|
75
|
+
/**
|
|
76
|
+
* Verify with a key you already hold: a PEM string or a `KeyObject`. `issuer`
|
|
77
|
+
* is the origin of the deployment you trust, such as `https://deliverd.dev`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function verifyDecisionToken(token: string | null | undefined, expected: DecisionTokenExpectation, key: {
|
|
80
|
+
publicKey: string | KeyObject;
|
|
81
|
+
issuer: string;
|
|
82
|
+
now?: Date;
|
|
83
|
+
skewSeconds?: number;
|
|
84
|
+
}): DecisionTokenResult;
|
|
85
|
+
/**
|
|
86
|
+
* `deliverd.decisionTokens`: verification against the deployment this client
|
|
87
|
+
* talks to. The key comes from that deployment's own well-known address and
|
|
88
|
+
* the issuer must be that deployment, never whatever the token names, so a
|
|
89
|
+
* token signed by somebody else's Deliverd does not pass.
|
|
90
|
+
*/
|
|
91
|
+
export declare class DecisionTokens {
|
|
92
|
+
private readonly baseUrl;
|
|
93
|
+
private readonly doFetch;
|
|
94
|
+
private key;
|
|
95
|
+
constructor(baseUrl: string, doFetch?: typeof globalThis.fetch);
|
|
96
|
+
verify(token: string | null | undefined, expected: DecisionTokenExpectation, options?: {
|
|
97
|
+
now?: Date;
|
|
98
|
+
skewSeconds?: number;
|
|
99
|
+
}): Promise<DecisionTokenResult>;
|
|
100
|
+
private publicKey;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=decision-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-token.d.ts","sourceRoot":"","sources":["../src/decision-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAGlF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AACpE,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,uCAAuC,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,CAAC,EAAE,CAAC,CAAC;IACL,GAAG,EAAE,MAAM,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AS,EAChC,QAAQ,EAAE,wBAAwB,EAClC,GAAG,EAAE;IAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACvF,mBAAmB,CAmCrB;AAED;;;;;GAKG;AACH,qBAAa,cAAc;IAIvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,GAAG,CAAmC;gBAG3B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,OAAO,UAAU,CAAC,KAAwB;IAGhE,MAAM,CACV,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ,EAAE,wBAAwB,EAClC,OAAO,GAAE;QAAE,GAAG,CAAC,EAAE,IAAI,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GACjD,OAAO,CAAC,mBAAmB,CAAC;IAM/B,OAAO,CAAC,SAAS;CAelB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { createHash, createPublicKey, verify } from "node:crypto";
|
|
2
|
+
import { DeliverdError } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checking a decision token where the action happens.
|
|
5
|
+
*
|
|
6
|
+
* A gate that may be acted on carries `decisionToken`: the yes, signed with
|
|
7
|
+
* the deployment's Ed25519 evidence key. Hand it to the service that performs
|
|
8
|
+
* the action — the one that issues the refund or merges the change — and that
|
|
9
|
+
* service checks it against what it is about to do before it does it:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const check = await deliverd.decisionTokens.verify(req.headers["deliverd-decision"], {
|
|
13
|
+
* action: "finance.refund",
|
|
14
|
+
* input: { customer_id, amount, currency },
|
|
15
|
+
* });
|
|
16
|
+
* if (!check.ok) return res.status(403).send(check.reason);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* It fails when the token was not signed by your Deliverd, has expired, is for
|
|
20
|
+
* another action, or was agreed for a different input: a refund of £1240
|
|
21
|
+
* against a yes for £1200 is refused. It needs no API key and makes no call
|
|
22
|
+
* beyond fetching the public key once.
|
|
23
|
+
*
|
|
24
|
+
* What it does not check is how many times the yes has been used. Record the
|
|
25
|
+
* execution against the gate (`gate.recordExecution`) to spend the use; the
|
|
26
|
+
* server refuses a second.
|
|
27
|
+
*
|
|
28
|
+
* Kept byte-for-byte with the server's `lib/governance/decision-token.ts`;
|
|
29
|
+
* `decision-token.test.ts` on the server signs there and verifies here.
|
|
30
|
+
*/
|
|
31
|
+
export const DECISION_TOKEN_PREFIX = "dlv_dt1";
|
|
32
|
+
export const DECISION_TOKEN_CONTEXT = "deliverd-decision-token:v1:";
|
|
33
|
+
/** Where a deployment publishes the key that signs its tokens and evidence packs. */
|
|
34
|
+
export const EVIDENCE_KEY_PATH = "/.well-known/deliverd-evidence-key";
|
|
35
|
+
/** Keys sorted at every depth, undefined dropped: the server's `canonicalJson`. */
|
|
36
|
+
export function canonicalJson(value) {
|
|
37
|
+
if (value === null || typeof value !== "object")
|
|
38
|
+
return JSON.stringify(value ?? null);
|
|
39
|
+
if (Array.isArray(value))
|
|
40
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
41
|
+
const entries = Object.entries(value)
|
|
42
|
+
.filter(([, v]) => v !== undefined)
|
|
43
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
44
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
|
|
45
|
+
}
|
|
46
|
+
export function decisionInputHash(input) {
|
|
47
|
+
return createHash("sha256").update(canonicalJson(input ?? {}), "utf8").digest("hex");
|
|
48
|
+
}
|
|
49
|
+
/** The server's `sameDestination`: addresses and domains ignore case, ids do not. */
|
|
50
|
+
function sameDestination(a, b) {
|
|
51
|
+
if (a.type !== b.type)
|
|
52
|
+
return false;
|
|
53
|
+
const fold = a.type === "email" || a.type === "domain";
|
|
54
|
+
return fold ? a.id.trim().toLowerCase() === b.id.trim().toLowerCase() : a.id.trim() === b.id.trim();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Verify with a key you already hold: a PEM string or a `KeyObject`. `issuer`
|
|
58
|
+
* is the origin of the deployment you trust, such as `https://deliverd.dev`.
|
|
59
|
+
*/
|
|
60
|
+
export function verifyDecisionToken(token, expected, key) {
|
|
61
|
+
if (!token)
|
|
62
|
+
return { ok: false, reason: "missing" };
|
|
63
|
+
const parts = token.split(".");
|
|
64
|
+
if (parts.length !== 3 || parts[0] !== DECISION_TOKEN_PREFIX)
|
|
65
|
+
return { ok: false, reason: "malformed" };
|
|
66
|
+
let claims;
|
|
67
|
+
try {
|
|
68
|
+
claims = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return { ok: false, reason: "malformed" };
|
|
72
|
+
}
|
|
73
|
+
if (claims?.v !== 1)
|
|
74
|
+
return { ok: false, reason: "malformed" };
|
|
75
|
+
let good = false;
|
|
76
|
+
try {
|
|
77
|
+
const publicKey = typeof key.publicKey === "string" ? createPublicKey(key.publicKey) : key.publicKey;
|
|
78
|
+
good = verify(null, Buffer.from(DECISION_TOKEN_CONTEXT + parts[1], "utf8"), publicKey, Buffer.from(parts[2], "base64url"));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
good = false;
|
|
82
|
+
}
|
|
83
|
+
if (!good)
|
|
84
|
+
return { ok: false, reason: "bad_signature" };
|
|
85
|
+
if (claims.iss !== key.issuer.replace(/\/+$/, ""))
|
|
86
|
+
return { ok: false, reason: "wrong_issuer" };
|
|
87
|
+
const now = Math.floor((key.now ?? new Date()).getTime() / 1000);
|
|
88
|
+
if (claims.exp + (key.skewSeconds ?? 30) <= now)
|
|
89
|
+
return { ok: false, reason: "expired" };
|
|
90
|
+
if (claims.action !== expected.action)
|
|
91
|
+
return { ok: false, reason: "wrong_action" };
|
|
92
|
+
if (claims.input !== decisionInputHash(expected.input))
|
|
93
|
+
return { ok: false, reason: "input_mismatch" };
|
|
94
|
+
if (claims.dest) {
|
|
95
|
+
const d = expected.destination;
|
|
96
|
+
if (!d || !sameDestination(d, claims.dest))
|
|
97
|
+
return { ok: false, reason: "destination_mismatch" };
|
|
98
|
+
}
|
|
99
|
+
if (claims.artifact && expected.artifactSha256 !== claims.artifact)
|
|
100
|
+
return { ok: false, reason: "artifact_mismatch" };
|
|
101
|
+
return { ok: true, claims };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* `deliverd.decisionTokens`: verification against the deployment this client
|
|
105
|
+
* talks to. The key comes from that deployment's own well-known address and
|
|
106
|
+
* the issuer must be that deployment, never whatever the token names, so a
|
|
107
|
+
* token signed by somebody else's Deliverd does not pass.
|
|
108
|
+
*/
|
|
109
|
+
export class DecisionTokens {
|
|
110
|
+
baseUrl;
|
|
111
|
+
doFetch;
|
|
112
|
+
key = null;
|
|
113
|
+
constructor(baseUrl, doFetch = globalThis.fetch) {
|
|
114
|
+
this.baseUrl = baseUrl;
|
|
115
|
+
this.doFetch = doFetch;
|
|
116
|
+
}
|
|
117
|
+
async verify(token, expected, options = {}) {
|
|
118
|
+
if (!token)
|
|
119
|
+
return { ok: false, reason: "missing" };
|
|
120
|
+
const publicKey = await this.publicKey();
|
|
121
|
+
return verifyDecisionToken(token, expected, { publicKey, issuer: new URL(this.baseUrl).origin, ...options });
|
|
122
|
+
}
|
|
123
|
+
publicKey() {
|
|
124
|
+
this.key ??= (async () => {
|
|
125
|
+
const res = await this.doFetch(`${this.baseUrl.replace(/\/+$/, "")}${EVIDENCE_KEY_PATH}`);
|
|
126
|
+
if (!res.ok) {
|
|
127
|
+
throw new DeliverdError(res.status, "no_signing_key", "This deployment does not publish a signing key.");
|
|
128
|
+
}
|
|
129
|
+
const body = (await res.json());
|
|
130
|
+
if (!body.publicKey)
|
|
131
|
+
throw new DeliverdError(0, "no_signing_key", "The signing key response had no public key.");
|
|
132
|
+
return createPublicKey(body.publicKey);
|
|
133
|
+
})().catch((err) => {
|
|
134
|
+
this.key = null;
|
|
135
|
+
throw err;
|
|
136
|
+
});
|
|
137
|
+
return this.key;
|
|
138
|
+
}
|
|
139
|
+
}
|
package/dist/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAYb,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7F,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,kBAAkB,CAAC,CAAC;IAC/E,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,UAAU,CAAC,KAAK,CAwnB1F"}
|
package/dist/dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assessCounts, DEFAULT_SCREEN_POLICY, describeCounts } from "./data-screen.js";
|
|
1
2
|
const DEFAULT_QUESTION = "Has this been through staging?";
|
|
2
3
|
let counter = 0;
|
|
3
4
|
/**
|
|
@@ -14,7 +15,7 @@ export function developmentFetch(options = {}) {
|
|
|
14
15
|
const collectionStore = new Map();
|
|
15
16
|
const flowStore = new Map();
|
|
16
17
|
const tasks = developmentTasks(options);
|
|
17
|
-
|
|
18
|
+
const handle = (async (input, init) => {
|
|
18
19
|
const url = new URL(String(input));
|
|
19
20
|
const path = url.pathname.replace(/^\/api\/v1/, "");
|
|
20
21
|
const method = (init?.method ?? "GET").toUpperCase();
|
|
@@ -44,6 +45,7 @@ export function developmentFetch(options = {}) {
|
|
|
44
45
|
changes: [],
|
|
45
46
|
concerns: [],
|
|
46
47
|
requestedBy: "You (development mode)",
|
|
48
|
+
...declaredOf(body),
|
|
47
49
|
approvers: body.approvers ?? [],
|
|
48
50
|
/*
|
|
49
51
|
* One, always. A standing rule could raise it on a real organisation,
|
|
@@ -135,6 +137,7 @@ export function developmentFetch(options = {}) {
|
|
|
135
137
|
externalId: body.externalId ?? null,
|
|
136
138
|
metadata: body.metadata ?? {},
|
|
137
139
|
requestedBy: "You (development mode)",
|
|
140
|
+
...declaredOf(body),
|
|
138
141
|
requiredApprovals: body.requiredApprovals ?? 1,
|
|
139
142
|
reviewers,
|
|
140
143
|
verdicts: [],
|
|
@@ -381,6 +384,7 @@ export function developmentFetch(options = {}) {
|
|
|
381
384
|
externalId: body.externalId ?? null,
|
|
382
385
|
metadata: body.metadata ?? {},
|
|
383
386
|
requestedBy: "You (development mode)",
|
|
387
|
+
...declaredOf(body),
|
|
384
388
|
requiredResponses: body.requiredResponses ?? (asked.length || 1),
|
|
385
389
|
questions,
|
|
386
390
|
responses: asked.map((who) => ({
|
|
@@ -540,6 +544,44 @@ export function developmentFetch(options = {}) {
|
|
|
540
544
|
if (method === "GET" && path === "/tasks") {
|
|
541
545
|
return json({ tasks: tasks.list(url.searchParams), nextCursor: null });
|
|
542
546
|
}
|
|
547
|
+
/*
|
|
548
|
+
* Screening with no organisation behind it: no register record and no
|
|
549
|
+
* policy, so the defaults decide — internal data and no personal data
|
|
550
|
+
* approved — and an `ask` files an ordinary development approval, which
|
|
551
|
+
* the imaginary approver decides like any other.
|
|
552
|
+
*/
|
|
553
|
+
if (method === "POST" && path === "/screen") {
|
|
554
|
+
const counts = (body.counts ?? {});
|
|
555
|
+
const termClassification = body.termClassification === "restricted" ? "restricted" : "confidential";
|
|
556
|
+
const assessment = assessCounts(counts, null, DEFAULT_SCREEN_POLICY, termClassification);
|
|
557
|
+
let approval = null;
|
|
558
|
+
if (assessment.verdict === "ask" && body.ask !== false) {
|
|
559
|
+
const created = (await (await handle(`${url.origin}/api/v1/approvals`, {
|
|
560
|
+
method: "POST",
|
|
561
|
+
body: JSON.stringify({
|
|
562
|
+
title: `Send ${describeCounts(counts)} to an AI model?`,
|
|
563
|
+
description: assessment.reasons.join("\n"),
|
|
564
|
+
risk: assessment.classification === "restricted" ? "high" : "medium",
|
|
565
|
+
externalId: body.externalId,
|
|
566
|
+
}),
|
|
567
|
+
})).json());
|
|
568
|
+
approval = { id: created.id, url: created.url, status: created.status };
|
|
569
|
+
}
|
|
570
|
+
return json({
|
|
571
|
+
verdict: assessment.verdict,
|
|
572
|
+
allowed: assessment.verdict === "allow" || assessment.verdict === "redact",
|
|
573
|
+
classification: assessment.classification,
|
|
574
|
+
personalData: assessment.personalData,
|
|
575
|
+
categories: assessment.categories,
|
|
576
|
+
counts,
|
|
577
|
+
offending: assessment.offending,
|
|
578
|
+
reasons: assessment.reasons,
|
|
579
|
+
target: null,
|
|
580
|
+
findings: null,
|
|
581
|
+
redactedText: null,
|
|
582
|
+
approval,
|
|
583
|
+
});
|
|
584
|
+
}
|
|
543
585
|
const taskMatch = /^\/tasks\/([^/]+)(?:\/(context|graph|side-tasks|findings|complete|apply|reopen|cancel|links))?$/.exec(path);
|
|
544
586
|
if (taskMatch) {
|
|
545
587
|
const [status, payload] = tasks.act(method, taskMatch[1], taskMatch[2] ?? null, body);
|
|
@@ -548,10 +590,23 @@ export function developmentFetch(options = {}) {
|
|
|
548
590
|
return json({
|
|
549
591
|
error: {
|
|
550
592
|
code: "not_in_development_mode",
|
|
551
|
-
message: `Development mode simulates approvals, reviews, collections, flows and
|
|
593
|
+
message: `Development mode simulates approvals, reviews, collections, flows, tasks and screening only, and something called ${method} ${path}. Use a real API key for the rest of the API.`,
|
|
552
594
|
},
|
|
553
595
|
}, 501);
|
|
554
596
|
});
|
|
597
|
+
return handle;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* The agent and model a request declared, as the API echoes them: what was
|
|
601
|
+
* sent, every field present, null when nothing was. Development mode stores
|
|
602
|
+
* nothing, so this is the whole of it.
|
|
603
|
+
*/
|
|
604
|
+
function declaredOf(body) {
|
|
605
|
+
const a = body.agent;
|
|
606
|
+
const agent = a && (a.name || a.provider || a.externalId)
|
|
607
|
+
? { name: a.name ?? null, provider: a.provider ?? null, externalId: a.externalId ?? null }
|
|
608
|
+
: null;
|
|
609
|
+
return { agent, model: typeof body.model === "string" && body.model ? body.model : null };
|
|
555
610
|
}
|
|
556
611
|
function resolveOutcome(outcome, body) {
|
|
557
612
|
const fromEnv = process.env.DELIVERD_DEV_OUTCOME;
|
package/dist/gates.d.ts
CHANGED
|
@@ -73,6 +73,8 @@ export declare class Gate {
|
|
|
73
73
|
get scope(): GateData["scope"];
|
|
74
74
|
/** How long it lasts and how many uses are left. */
|
|
75
75
|
get authorisation(): GateData["authorisation"];
|
|
76
|
+
/** The signed yes to hand the code that performs the action. Null unless `canExecute`. */
|
|
77
|
+
get decisionToken(): string | null;
|
|
76
78
|
/** A person sent it back. Revise and ask again with `supersedesGateId: gate.id`. */
|
|
77
79
|
get changesRequested(): boolean;
|
|
78
80
|
/**
|
package/dist/gates.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gates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.scope; }
|
|
99
99
|
/** How long it lasts and how many uses are left. */
|
|
100
100
|
get authorisation() { return this.data.authorisation; }
|
|
101
|
+
/** The signed yes to hand the code that performs the action. Null unless `canExecute`. */
|
|
102
|
+
get decisionToken() { return this.data.decisionToken ?? null; }
|
|
101
103
|
/** A person sent it back. Revise and ask again with `supersedesGateId: gate.id`. */
|
|
102
104
|
get changesRequested() { return this.data.status === "changes_requested"; }
|
|
103
105
|
/**
|
|
@@ -133,6 +135,7 @@ export class Gate {
|
|
|
133
135
|
changes: this.data.changes ?? [],
|
|
134
136
|
id: this.data.id,
|
|
135
137
|
approvalUrl: this.data.approvalUrl,
|
|
138
|
+
decisionToken: this.data.decisionToken ?? null,
|
|
136
139
|
gate: this,
|
|
137
140
|
};
|
|
138
141
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.js";
|
|
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";
|
|
4
|
+
/**
|
|
5
|
+
* The organisation's register of AI systems. A governed task names one by
|
|
6
|
+
* `aiSystemId` instead of describing it again, and a change of model is
|
|
7
|
+
* recorded here so every task using it is reassessed.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AiSystems {
|
|
10
|
+
private readonly http;
|
|
11
|
+
constructor(http: HttpClient);
|
|
12
|
+
/** The register, active and retired, or only one of them. */
|
|
13
|
+
list(input?: {
|
|
14
|
+
status?: AiSystem["status"];
|
|
15
|
+
}, signal?: AbortSignal): Promise<AiSystem[]>;
|
|
16
|
+
/** One system, and the governed tasks that name it. */
|
|
17
|
+
get(id: string, signal?: AbortSignal): Promise<AiSystemDetail>;
|
|
18
|
+
/** Add a system to the register. Digests of its prompt and guardrails, never the text. */
|
|
19
|
+
register(input: RegisterAiSystemInput, signal?: AbortSignal): Promise<AiSystem>;
|
|
20
|
+
/** Change a system's record. An agent may raise its risk but not lower it, and may not retire it. */
|
|
21
|
+
update(id: string, input: UpdateAiSystemInput, signal?: AbortSignal): Promise<AiSystem>;
|
|
22
|
+
/**
|
|
23
|
+
* Record a new provider, model, version, prompt or guardrails (Enterprise).
|
|
24
|
+
* Every governed task using the system is reassessed, and evidence of the
|
|
25
|
+
* old release stops counting.
|
|
26
|
+
*/
|
|
27
|
+
recordModelChange(id: string, input: ModelChangeInput, signal?: AbortSignal): Promise<ModelChangeResult>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* AI incidents, and the DORA reports on the major ones. A high or critical
|
|
31
|
+
* incident closes its task's governance gate until a person resolves it in
|
|
32
|
+
* Deliverd; classifying it, and submitting a report, are a person's too.
|
|
33
|
+
*/
|
|
34
|
+
export declare class Incidents {
|
|
35
|
+
private readonly http;
|
|
36
|
+
constructor(http: HttpClient);
|
|
37
|
+
/** Report an incident against a governed task, an AI system, or both. */
|
|
38
|
+
report(input: ReportIncidentInput, signal?: AbortSignal): Promise<AiIncident>;
|
|
39
|
+
/** One incident: its DORA classification, its reports and their sign-off, and which report is due next. */
|
|
40
|
+
get(id: string, signal?: AbortSignal): Promise<AiIncidentDetail>;
|
|
41
|
+
/**
|
|
42
|
+
* Newest first. With no `limit` this is every incident; with a `limit` it is
|
|
43
|
+
* one page of that size, and `listPage` hands back the cursor to continue from.
|
|
44
|
+
*/
|
|
45
|
+
list(input?: ListIncidentsInput, signal?: AbortSignal): Promise<AiIncident[]>;
|
|
46
|
+
/** One page, and the cursor to continue from — null when it is the end. */
|
|
47
|
+
listPage(input?: ListIncidentsInput, signal?: AbortSignal): Promise<PageOf<AiIncident>>;
|
|
48
|
+
/**
|
|
49
|
+
* Draft a DORA report on a major incident and put it to a person to sign
|
|
50
|
+
* off. Reports follow in order: initial, intermediate, final. Needs
|
|
51
|
+
* `approvals:write` as well as `tasks:write`.
|
|
52
|
+
*/
|
|
53
|
+
draftReport(id: string, input: DraftIncidentReportInput, signal?: AbortSignal): Promise<DraftedIncidentReport>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Compliance Mode across the organisation (Business and Enterprise): the AI
|
|
57
|
+
* system register, incidents, what an agent may do, the frameworks and the
|
|
58
|
+
* ICT register. A governed task's own governance is on `deliverd.tasks`.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* const { mode } = await deliverd.governance.checkAuthority({ action: "send" });
|
|
62
|
+
* if (mode === "denied") return;
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Every answer records governance and certifies nothing.
|
|
66
|
+
*/
|
|
67
|
+
export declare class AiGovernance {
|
|
68
|
+
private readonly http;
|
|
69
|
+
readonly aiSystems: AiSystems;
|
|
70
|
+
readonly incidents: Incidents;
|
|
71
|
+
constructor(http: HttpClient);
|
|
72
|
+
/**
|
|
73
|
+
* May this agent take this kind of action: on its own (`allowed`), only
|
|
74
|
+
* with a person's approval (`approval`), or not at all (`denied`)? By the
|
|
75
|
+
* organisation's policy and the agent's own, which can only be stricter
|
|
76
|
+
* (Enterprise). Reads; records nothing.
|
|
77
|
+
*/
|
|
78
|
+
checkAuthority(input: CheckAuthorityInput, signal?: AbortSignal): Promise<AuthorityDecision>;
|
|
79
|
+
/** The frameworks the organisation can see: the built-in packs and its own, and which are applied. */
|
|
80
|
+
frameworks(signal?: AbortSignal): Promise<FrameworkCatalogue>;
|
|
81
|
+
/**
|
|
82
|
+
* How framework requirements map onto the common controls and, with
|
|
83
|
+
* `taskId`, how far that task's controls cover each one. A mapping, never
|
|
84
|
+
* a compliance verdict.
|
|
85
|
+
*/
|
|
86
|
+
frameworkMapping(input?: FrameworkMappingInput, signal?: AbortSignal): Promise<FrameworkMapping>;
|
|
87
|
+
/** Draft the organisation's own framework (Enterprise). It adds nothing until a person publishes and applies it. */
|
|
88
|
+
createCustomFramework(input: CreateCustomFrameworkInput, signal?: AbortSignal): Promise<CustomFramework>;
|
|
89
|
+
/** The ICT third-party register: providers, contracts, the AI systems under each, gaps and concentration. */
|
|
90
|
+
ictRegister(signal?: AbortSignal): Promise<IctRegister>;
|
|
91
|
+
/** The organisation's AI governance in counts, optionally narrowed. Never a compliance percentage. */
|
|
92
|
+
summary(input?: GovernanceSummaryInput, signal?: AbortSignal): Promise<GovernanceSummary>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +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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