@deliverd/sdk 0.8.1 → 0.9.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.
Files changed (63) hide show
  1. package/README.md +92 -0
  2. package/dist/adapters/ai-sdk.d.ts +48 -0
  3. package/dist/adapters/ai-sdk.d.ts.map +1 -0
  4. package/dist/adapters/ai-sdk.js +12 -0
  5. package/dist/adapters/claude-agent-sdk.d.ts +55 -0
  6. package/dist/adapters/claude-agent-sdk.d.ts.map +1 -0
  7. package/dist/adapters/claude-agent-sdk.js +24 -0
  8. package/dist/adapters/index.d.ts +19 -0
  9. package/dist/adapters/index.d.ts.map +1 -0
  10. package/dist/adapters/index.js +13 -0
  11. package/dist/adapters/langgraph.d.ts +145 -0
  12. package/dist/adapters/langgraph.d.ts.map +1 -0
  13. package/dist/adapters/langgraph.js +69 -0
  14. package/dist/adapters/openai-agents.d.ts +68 -0
  15. package/dist/adapters/openai-agents.d.ts.map +1 -0
  16. package/dist/adapters/openai-agents.js +55 -0
  17. package/dist/adapters/shared.d.ts +91 -0
  18. package/dist/adapters/shared.d.ts.map +1 -0
  19. package/dist/adapters/shared.js +98 -0
  20. package/dist/approvals.d.ts +15 -1
  21. package/dist/approvals.d.ts.map +1 -1
  22. package/dist/approvals.js +19 -1
  23. package/dist/collections.d.ts +8 -0
  24. package/dist/collections.d.ts.map +1 -1
  25. package/dist/collections.js +11 -1
  26. package/dist/dev.d.ts +6 -0
  27. package/dist/dev.d.ts.map +1 -1
  28. package/dist/dev.js +11 -0
  29. package/dist/gates.d.ts.map +1 -1
  30. package/dist/gates.js +1 -0
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/messages.d.ts.map +1 -1
  35. package/dist/messages.js +84 -5
  36. package/dist/released.d.ts +1 -1
  37. package/dist/released.d.ts.map +1 -1
  38. package/dist/released.js +864 -0
  39. package/dist/reviews.d.ts +8 -0
  40. package/dist/reviews.d.ts.map +1 -1
  41. package/dist/reviews.js +11 -1
  42. package/dist/types.d.ts +73 -1
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/webhooks.d.ts +15 -1
  45. package/dist/webhooks.d.ts.map +1 -1
  46. package/dist/webhooks.js +13 -0
  47. package/package.json +5 -1
  48. package/src/adapters/ai-sdk.ts +59 -0
  49. package/src/adapters/claude-agent-sdk.ts +90 -0
  50. package/src/adapters/index.ts +23 -0
  51. package/src/adapters/langgraph.ts +202 -0
  52. package/src/adapters/openai-agents.ts +112 -0
  53. package/src/adapters/shared.ts +179 -0
  54. package/src/approvals.ts +21 -1
  55. package/src/collections.ts +12 -1
  56. package/src/dev.ts +19 -0
  57. package/src/gates.ts +1 -0
  58. package/src/index.ts +1 -0
  59. package/src/messages.ts +84 -5
  60. package/src/released.ts +865 -0
  61. package/src/reviews.ts +12 -1
  62. package/src/types.ts +84 -1
  63. package/src/webhooks.ts +20 -1
@@ -0,0 +1,91 @@
1
+ import type { Duration } from "../duration.js";
2
+ import type { ApprovalFactor, ApprovalRisk, Decision, FieldChange } from "../types.js";
3
+ /**
4
+ * What the framework adapters share: how a tool call becomes a request, and
5
+ * what the answer becomes.
6
+ *
7
+ * The adapters are written against each framework's own hook — the Claude
8
+ * Agent SDK's `canUseTool`, the AI SDK's `toolApproval`, the OpenAI Agents
9
+ * SDK's interruptions, LangGraph's `interrupt` — by shape rather than by
10
+ * import, so `@deliverd/sdk` keeps its promise of no dependencies. Each
11
+ * shape was taken from that framework's published type definitions and is
12
+ * checked against them in this package's tests.
13
+ */
14
+ /** Anything with Deliverd's `approve()`: the client, or a test double. */
15
+ export interface Approver {
16
+ approve(options: {
17
+ title: string;
18
+ description?: string;
19
+ risk?: ApprovalRisk;
20
+ factors?: ApprovalFactor[];
21
+ approvers?: string[];
22
+ externalId?: string;
23
+ flowId?: string;
24
+ metadata?: Record<string, unknown>;
25
+ callbackUrl?: string;
26
+ input?: Record<string, unknown>;
27
+ editableFields?: string[];
28
+ expiresIn?: Duration;
29
+ timeout?: Duration;
30
+ signal?: AbortSignal;
31
+ }): Promise<Decision>;
32
+ }
33
+ /** What a person is shown about one tool call. */
34
+ export interface CallDescription {
35
+ title: string;
36
+ description?: string;
37
+ risk?: ApprovalRisk;
38
+ factors?: ApprovalFactor[];
39
+ }
40
+ export interface ToolApprovalOptions {
41
+ /** The client: `new Deliverd()`. */
42
+ deliverd: Approver;
43
+ /**
44
+ * Which calls need a person. Every call when omitted — so name the few
45
+ * that matter: `when: (tool) => ["send_email", "refund"].includes(tool)`.
46
+ */
47
+ when?: (toolName: string, input: unknown) => boolean | Promise<boolean>;
48
+ /** Who may decide: people, teams, groups. The organisation's admins when omitted. */
49
+ approvers?: string[];
50
+ /** What the approver reads. A readable default is built from the tool and its input. */
51
+ describe?: (toolName: string, input: unknown) => CallDescription;
52
+ /** How long the request stays open. Default one hour: an agent is waiting. */
53
+ expiresIn?: Duration;
54
+ /** Give up waiting after this and refuse the call. Defaults to the request's own expiry. */
55
+ timeout?: Duration;
56
+ /** The flow this run belongs to, so every call it asked about is on one timeline. */
57
+ flowId?: string;
58
+ metadata?: Record<string, unknown>;
59
+ }
60
+ export declare function structuredInput(input: unknown): Record<string, unknown> | undefined;
61
+ export declare const DEFAULT_TOOL_EXPIRY: Duration;
62
+ /** A plain account of a call, for when the caller did not write one. */
63
+ export declare function defaultDescription(toolName: string, input: unknown): CallDescription;
64
+ /** The answer an adapter hands back to its framework. */
65
+ export type CallOutcome = {
66
+ allowed: true;
67
+ decidedBy: string | null;
68
+ note: string | null;
69
+ /** What to run with: the approver's correction, when they made one. */
70
+ input: Record<string, unknown> | null;
71
+ changes: FieldChange[];
72
+ } | {
73
+ allowed: false;
74
+ reason: string;
75
+ };
76
+ /**
77
+ * Ask about one call and wait.
78
+ *
79
+ * `externalId` makes the ask idempotent: a framework that retries a step, or
80
+ * a process that restarts mid-wait, finds the request it already made instead
81
+ * of filing a second one (`approve()` reuses by `externalId`).
82
+ *
83
+ * A refusal, an expiry and a wait that ran out are all "not allowed", each
84
+ * with a sentence the model can read and act on — never a thrown error, which
85
+ * most frameworks would turn into a crashed run rather than a declined call.
86
+ */
87
+ export declare function askAboutCall(toolName: string, input: unknown, externalId: string, options: ToolApprovalOptions, signal?: AbortSignal,
88
+ /** Fields a person may correct. Only for a framework that can run a corrected call. */
89
+ editableFields?: string[]): Promise<CallOutcome>;
90
+ export declare function refusalReason(toolName: string, decision: Pick<Decision, "status" | "note" | "decidedBy">): string;
91
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/adapters/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvF;;;;;;;;;;GAUG;AAEH,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,OAAO,EAAE;QACf,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,YAAY,CAAC;QACpB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,SAAS,CAAC,EAAE,QAAQ,CAAC;QACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;QACnB,MAAM,CAAC,E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AI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACtC,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,GACD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,mBAAmB,EAC5B,MAAM,CAAC,EAAE,WAAW;AACpB,uFAAuF;AACvF,cAAc,CAAC,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,WAAW,CAAC,CAmCtB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC,GAAG,MAAM,CAWjH"}
@@ -0,0 +1,98 @@
1
+ import { DeliverdTimeoutError } from "../errors.js";
2
+ /**
3
+ * The tool input as the approver sees it: its arguments, shown field by field
4
+ * on the approval page, when it is a plain object of a sensible size. Larger
5
+ * or odd-shaped input is still in the description, just not structured.
6
+ */
7
+ const INPUT_MAX = 8000;
8
+ export function structuredInput(input) {
9
+ if (typeof input !== "object" || input === null || Array.isArray(input))
10
+ return undefined;
11
+ try {
12
+ return JSON.stringify(input).length <= INPUT_MAX ? input : undefined;
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ }
18
+ export const DEFAULT_TOOL_EXPIRY = "1h";
19
+ const INPUT_PREVIEW_MAX = 3000;
20
+ /** A plain account of a call, for when the caller did not write one. */
21
+ export function defaultDescription(toolName, input) {
22
+ let rendered;
23
+ try {
24
+ rendered = typeof input === "string" ? input : JSON.stringify(input, null, 2);
25
+ }
26
+ catch {
27
+ rendered = String(input);
28
+ }
29
+ if (rendered && rendered.length > INPUT_PREVIEW_MAX)
30
+ rendered = `${rendered.slice(0, INPUT_PREVIEW_MAX - 1)}…`;
31
+ return {
32
+ title: `Allow the agent to run ${toolName}`,
33
+ description: rendered ? `With this input:\n\n${rendered}` : undefined,
34
+ risk: "medium",
35
+ };
36
+ }
37
+ /**
38
+ * Ask about one call and wait.
39
+ *
40
+ * `externalId` makes the ask idempotent: a framework that retries a step, or
41
+ * a process that restarts mid-wait, finds the request it already made instead
42
+ * of filing a second one (`approve()` reuses by `externalId`).
43
+ *
44
+ * A refusal, an expiry and a wait that ran out are all "not allowed", each
45
+ * with a sentence the model can read and act on — never a thrown error, which
46
+ * most frameworks would turn into a crashed run rather than a declined call.
47
+ */
48
+ export async function askAboutCall(toolName, input, externalId, options, signal,
49
+ /** Fields a person may correct. Only for a framework that can run a corrected call. */
50
+ editableFields) {
51
+ const described = (options.describe ?? defaultDescription)(toolName, input);
52
+ const structured = structuredInput(input);
53
+ let decision;
54
+ try {
55
+ decision = await options.deliverd.approve({
56
+ ...described,
57
+ approvers: options.approvers,
58
+ externalId,
59
+ flowId: options.flowId,
60
+ metadata: { ...options.metadata, tool: toolName },
61
+ ...(structured ? { input: structured } : {}),
62
+ ...(structured && editableFields?.length
63
+ ? { editableFields: editableFields.filter((field) => field in structured) }
64
+ : {}),
65
+ expiresIn: options.expiresIn ?? DEFAULT_TOOL_EXPIRY,
66
+ timeout: options.timeout,
67
+ signal,
68
+ });
69
+ }
70
+ catch (err) {
71
+ if (err instanceof DeliverdTimeoutError) {
72
+ return { allowed: false, reason: `Nobody decided whether to run ${toolName} in time, so it was not run.` };
73
+ }
74
+ throw err;
75
+ }
76
+ if (decision.approved) {
77
+ return {
78
+ allowed: true,
79
+ decidedBy: decision.decidedBy,
80
+ note: decision.note,
81
+ input: decision.input ?? null,
82
+ changes: decision.changes ?? [],
83
+ };
84
+ }
85
+ return { allowed: false, reason: refusalReason(toolName, decision) };
86
+ }
87
+ export function refusalReason(toolName, decision) {
88
+ const who = decision.decidedBy ? ` by ${decision.decidedBy}` : "";
89
+ const why = decision.note ? ` Their reason: ${decision.note}` : "";
90
+ switch (decision.status) {
91
+ case "rejected":
92
+ return `A person declined running ${toolName}${who}.${why} Do not retry it; change course or ask how to proceed.`;
93
+ case "expired":
94
+ return `Nobody decided whether to run ${toolName} before the request expired, so it was not run.`;
95
+ default:
96
+ return `The request to run ${toolName} was withdrawn, so it was not run.`;
97
+ }
98
+ }
@@ -1,6 +1,6 @@
1
1
  import { type PageOf } from "./paging.js";
2
2
  import type { HttpClient } from "./http.js";
3
- import type { ApprovalData, ApprovalQuestion, CreateApprovalInput, Decision, ListApprovalsInput } from "./types.js";
3
+ import type { ApprovalData, ApprovalQuestion, CreateApprovalInput, Decision, FieldChange, ListApprovalsInput } from "./types.js";
4
4
  /**
5
5
  * Ask a person before you act.
6
6
  *
@@ -59,6 +59,14 @@ export declare class Approval {
59
59
  private readonly http;
60
60
  private data;
61
61
  constructor(http: HttpClient, data: ApprovalData);
62
+ /**
63
+ * The secret this request's callbacks are signed with, when you gave a
64
+ * `callbackUrl`. Only on the handle `create()` returned — the API hands it
65
+ * over once and never again — so keep it with whatever will receive the
66
+ * callback, and check each one with
67
+ * `deliverd.webhooks.constructCallback(callbackSecret, rawBody, signature)`.
68
+ */
69
+ callbackSecret: string | null;
62
70
  get id(): string;
63
71
  get status(): ApprovalData["status"];
64
72
  /** The page the approver decides on. Put it in your own UI or logs. */
@@ -70,6 +78,12 @@ export declare class Approval {
70
78
  get decidedBy(): string | null;
71
79
  get decidedById(): string | null;
72
80
  get decidedAt(): string | null;
81
+ /** What you proposed to run with. */
82
+ get input(): Record<string, unknown> | null;
83
+ /** What to run with once approved, with any corrections. Null until then. */
84
+ get approvedInput(): Record<string, unknown> | null;
85
+ /** What the approver changed. */
86
+ get changes(): FieldChange[];
73
87
  get questions(): ApprovalQuestion[];
74
88
  /** Questions the approver is still waiting on you to answer. */
75
89
  get openQuestions(): ApprovalQuestion[];
@@ -1 +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AmB,EAC1B,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,QAAQ,CAAC;IAKpB;;;;;;;;;;OAUG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAI3F"}
package/dist/approvals.js CHANGED
@@ -43,6 +43,14 @@ export class Approval {
43
43
  this.http = http;
44
44
  this.data = data;
45
45
  }
46
+ /**
47
+ * The secret this request's callbacks are signed with, when you gave a
48
+ * `callbackUrl`. Only on the handle `create()` returned — the API hands it
49
+ * over once and never again — so keep it with whatever will receive the
50
+ * callback, and check each one with
51
+ * `deliverd.webhooks.constructCallback(callbackSecret, rawBody, signature)`.
52
+ */
53
+ callbackSecret = null;
46
54
  get id() { return this.data.id; }
47
55
  get status() { return this.data.status; }
48
56
  /** The page the approver decides on. Put it in your own UI or logs. */
@@ -54,6 +62,12 @@ export class Approval {
54
62
  get decidedBy() { return this.data.decidedBy; }
55
63
  get decidedById() { return this.data.decidedById; }
56
64
  get decidedAt() { return this.data.decidedAt; }
65
+ /** What you proposed to run with. */
66
+ get input() { return this.data.input ?? null; }
67
+ /** What to run with once approved, with any corrections. Null until then. */
68
+ get approvedInput() { return this.data.approvedInput ?? null; }
69
+ /** What the approver changed. */
70
+ get changes() { return this.data.changes ?? []; }
57
71
  get questions() { return this.data.questions; }
58
72
  /** Questions the approver is still waiting on you to answer. */
59
73
  get openQuestions() { return this.data.questions.filter((q) => !q.answer); }
@@ -83,6 +97,8 @@ export class Approval {
83
97
  decidedAt: this.data.decidedAt,
84
98
  id: this.data.id,
85
99
  url: this.data.url,
100
+ input: this.data.status === "approved" ? (this.data.approvedInput ?? this.data.input) : null,
101
+ changes: this.data.changes ?? [],
86
102
  approval: this,
87
103
  };
88
104
  }
@@ -198,7 +214,9 @@ export class Approvals {
198
214
  body: input,
199
215
  signal,
200
216
  });
201
- return new Approval(this.http, data);
217
+ const created = new Approval(this.http, data);
218
+ created.callbackSecret = data.callbackSecret ?? null;
219
+ return created;
202
220
  }
203
221
  async get(id, signal) {
204
222
  const data = await this.http.request({
@@ -25,6 +25,14 @@ export declare class Collection {
25
25
  private readonly http;
26
26
  private data;
27
27
  constructor(http: HttpClient, data: CollectionData);
28
+ /**
29
+ * The secret this request's callbacks are signed with, when you gave a
30
+ * `callbackUrl`. Only on the handle `create()` returned — the API hands it
31
+ * over once and never again — so keep it with whatever will receive the
32
+ * callback, and check each one with
33
+ * `deliverd.webhooks.constructCallback(callbackSecret, rawBody, signature)`.
34
+ */
35
+ callbackSecret: string | null;
28
36
  get id(): string;
29
37
  get status(): CollectionData["status"];
30
38
  /** The page the people you asked will fill in. */
@@ -1 +1 @@
1
- {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AAEH,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAOD,0DAA0D;AAC1D,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,IAAI;gBADK,IAAI,EAAE,UAAU,EACzB,IAAI,EAAE,cAAc;IAG9B,IAAI,EAAE,IAAI,MAAM,CAAyB;IACzC,IAAI,MAAM,IAAI,cAAc,CAAC,QAA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AyB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAa9B,8EAA8E;IACxE,OAAO,CACX,KAAK,EAAE,qBAAqB,EAC5B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,UAAU,CAAC;IAKtB,wFAAwF;IAClF,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAI7F"}
@@ -13,6 +13,14 @@ export class Collection {
13
13
  this.http = http;
14
14
  this.data = data;
15
15
  }
16
+ /**
17
+ * The secret this request's callbacks are signed with, when you gave a
18
+ * `callbackUrl`. Only on the handle `create()` returned — the API hands it
19
+ * over once and never again — so keep it with whatever will receive the
20
+ * callback, and check each one with
21
+ * `deliverd.webhooks.constructCallback(callbackSecret, rawBody, signature)`.
22
+ */
23
+ callbackSecret = null;
16
24
  get id() { return this.data.id; }
17
25
  get status() { return this.data.status; }
18
26
  /** The page the people you asked will fill in. */
@@ -139,7 +147,9 @@ export class Collections {
139
147
  body: input,
140
148
  signal,
141
149
  });
142
- return new Collection(this.http, data);
150
+ const created = new Collection(this.http, data);
151
+ created.callbackSecret = data.callbackSecret ?? null;
152
+ return created;
143
153
  }
144
154
  async get(id, signal) {
145
155
  const data = await this.http.request({
package/dist/dev.d.ts CHANGED
@@ -41,6 +41,12 @@ export interface DevelopmentOptions {
41
41
  delay?: number;
42
42
  /** What they say. Defaults suit the outcome. */
43
43
  note?: string;
44
+ /**
45
+ * Corrections the imaginary approver makes when approving a request that
46
+ * sent an `input`, so the approve-with-changes path can be run offline.
47
+ * Only fields you named in `editableFields` are applied, as in production.
48
+ */
49
+ edits?: Record<string, unknown>;
44
50
  /** What they ask, when the outcome is `question`. */
45
51
  question?: string;
46
52
  /** Print what the approver would have seen. Default true. */
package/dist/dev.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.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AAK,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,CA0d1F"}
package/dist/dev.js CHANGED
@@ -37,6 +37,10 @@ export function developmentFetch(options = {}) {
37
37
  reportId: body.reportId ?? null,
38
38
  externalId: body.externalId ?? null,
39
39
  metadata: body.metadata ?? {},
40
+ input: body.input ?? null,
41
+ editableFields: body.editableFields ?? [],
42
+ approvedInput: null,
43
+ changes: [],
40
44
  requestedBy: "You (development mode)",
41
45
  approvers: body.approvers ?? [],
42
46
  /*
@@ -197,6 +201,7 @@ export function developmentFetch(options = {}) {
197
201
  status: byRule ? "denied" : "pending",
198
202
  allowed: false,
199
203
  input: body.input ?? {},
204
+ changes: [],
200
205
  basis: byRule ? "policy" : "human",
201
206
  reason: byRule
202
207
  ? "Development mode refused it. A real rule would say which one and why."
@@ -468,6 +473,12 @@ function settle(stored) {
468
473
  stored.data.note =
469
474
  stored.options.note ??
470
475
  (stored.data.status === "rejected" ? "Not yet — development mode says no." : null);
476
+ if (stored.data.status === "approved" && stored.data.input) {
477
+ const proposed = stored.data.input;
478
+ const edits = Object.entries(stored.options.edits ?? {}).filter(([field, value]) => stored.data.editableFields.includes(field) && !Object.is(proposed[field], value));
479
+ stored.data.approvedInput = { ...proposed, ...Object.fromEntries(edits) };
480
+ stored.data.changes = edits.map(([field, to]) => ({ field, from: proposed[field] ?? null, to }));
481
+ }
471
482
  }
472
483
  /**
473
484
  * What the approver would have seen, in the terminal.
@@ -1 +1 @@
1
- {"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../src/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,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,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IASlD;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAgCzD;AAyBD,qBAAa,KAAK;IACJ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBzE,8BAA8B;IACxB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ3D"}
package/dist/gates.js CHANGED
@@ -72,6 +72,7 @@ export class Gate {
72
72
  reason: this.data.reason,
73
73
  rule: this.data.rule,
74
74
  input: this.data.input,
75
+ changes: this.data.changes ?? [],
75
76
  id: this.data.id,
76
77
  approvalUrl: this.data.approvalUrl,
77
78
  gate: this,
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export { Comments, Reports, Schedules } from "./reports.js";
15
15
  export { Review, Reviews, type ReviewWaitOptions } from "./reviews.js";
16
16
  export { Collection, Collections, type CollectWaitOptions } from "./collections.js";
17
17
  export { Flow, Flows, type FlowPrimitives } from "./flows.js";
18
- export { constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
18
+ export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
19
19
  export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
20
20
  export { DEFAULT_BASE_URL, type ClientOptions } from "./http.js";
21
21
  export { durationMs, type Duration } from "./duration.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","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OAMG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAoC5D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkCjE,gFAAgF;IAChF,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAGjF;AAoBD,eAAO,MAAM,QAAQ,EAAE,QAMrB,CAAC;AAEH,eAAe,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ export { Comments, Reports, Schedules } from "./reports.js";
14
14
  export { Review, Reviews } from "./reviews.js";
15
15
  export { Collection, Collections } from "./collections.js";
16
16
  export { Flow, Flows } from "./flows.js";
17
- export { constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
17
+ export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
18
18
  export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
19
19
  export { DEFAULT_BASE_URL } from "./http.js";
20
20
  export { durationMs } from "./duration.js";
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAuDpD,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAI5F"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAsIpD,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAI5F"}
package/dist/messages.js CHANGED
@@ -16,14 +16,22 @@ export const EXPLANATIONS = {
16
16
  },
17
17
  auth_error: {
18
18
  message: "That credential was not accepted.",
19
- // Both families, because both work: a `dlv_` key somebody created, or a
20
- // `dlvo_` access token from an OAuth connector. Naming only the first is
21
- // how a connector's token gets thrown away and replaced with a key
22
- // nobody needed to create.
19
+ /*
20
+ * Both families, because both work: a `dlv_` key somebody created, or a
21
+ * `dlvo_` access token from an OAuth connector. Naming only the first is
22
+ * how a connector's token gets thrown away and replaced with a key
23
+ * nobody needed to create.
24
+ *
25
+ * Credentials only. A missing scope is `insufficient_scope` below and has
26
+ * been since `ApiScopeError` existed — the two shared this code before
27
+ * that, which is how somebody whose key was perfectly good came to be told
28
+ * to go and check their key.
29
+ */
23
30
  hint: "Check DELIVERD_API_KEY. An API key starts with dlv_ and is created in Settings → API tokens; an OAuth access token starts with dlvo_ and needs no setup.",
24
31
  },
25
32
  insufficient_scope: {
26
- hint: "Reissue the key with the scope named above, or re-consent the connector for it. A credential issued before a scope existed does not have it.",
33
+ message: "That credential is valid and does not carry the scope this call needs.",
34
+ hint: "Reissue the key with the scope named above, or re-consent the connector for it. A credential issued before a scope existed does not have it — nothing is wrong with the key itself, so replacing it with another of the same scopes will fail the same way.",
27
35
  },
28
36
  unknown_approver: {
29
37
  message: "No approver could be found for this request.",
@@ -61,6 +69,77 @@ export const EXPLANATIONS = {
61
69
  timeout: {
62
70
  hint: "You stopped waiting; the request is still open at the URL above until it expires. If an approver asked a question, answer it with an `onQuestion` handler — an unanswered question is the commonest reason a wait runs out.",
63
71
  },
72
+ /*
73
+ * The one code every namespace can return, and the only entry here that is
74
+ * about what a status *means* rather than about a particular call.
75
+ *
76
+ * It had none until a policy id that does not exist stopped answering 500,
77
+ * and the reason to write one is the half a reader does not expect: a 404
78
+ * is also what this API says when the thing is there and not theirs. It is
79
+ * one answer on purpose — telling the two apart would say whether the id
80
+ * exists for somebody else — so "it was deleted" is a guess, and a retry
81
+ * cannot turn it into anything else.
82
+ *
83
+ * No `message`: the server's own sentence names the resource, and this
84
+ * table cannot, being shared by approvals, reports and policies alike.
85
+ */
86
+ not_found: {
87
+ hint: "Nothing with that id, or nothing this key may see — the API does not say which, because saying would tell you whether it exists for somebody else. Check the id, and that the key belongs to the organisation that owns it. Retrying will not change the answer.",
88
+ },
89
+ /*
90
+ * The 404s that name their own resource. Each is here for a fact the
91
+ * server's sentence cannot carry, which is the only reason to add one —
92
+ * repeating "not found" under a longer name would be noise.
93
+ *
94
+ * `report_not_found` is deliberately absent. Placing and releasing a legal
95
+ * hold is web-only by design, so no route can send it and an entry would be
96
+ * advice nobody receives; `sdk-parity.test.ts` holds that omission to the
97
+ * reason the app already records, and fails if the code ever becomes
98
+ * reachable.
99
+ */
100
+ agent_not_found: {
101
+ message: "The agent identity this key acts as is not there any more.",
102
+ hint: "Nothing is wrong with the credential — it still authenticates, and what is gone is the identity it speaks as. Recreate the agent under Admin → Agents, or issue a key bound to one that exists. Every call this key makes fails the same way until then.",
103
+ },
104
+ upload_not_found: {
105
+ hint: "A publish consumes the bundle it reads, so this is what a *second* publish with the same `uploadId` gets — which means the first one may well have worked. Look at the report before uploading again, or you will publish it twice.",
106
+ },
107
+ question_not_found: {
108
+ hint: "Question ids belong to one approval, so this is usually an id from a different one. Take it from that approval's own questions — an `onQuestion` handler is handed it — rather than from anywhere you cached it. A question already answered is `already_answered`, not this.",
109
+ },
110
+ quote_not_found: {
111
+ hint: "The passage is not in the version the message names. A republish rewrites the text, so a quote taken before one stops matching: read the current version and quote what it says now. A quote that matches in several places is `quote_ambiguous` instead, and an empty one is `quote_empty`.",
112
+ },
113
+ /*
114
+ * The gate and its policy, which had no entries at all until the codes were
115
+ * told apart — the newest surface in the API and the one a reader is least
116
+ * likely to recognise, falling through to the server's own message with no
117
+ * next step.
118
+ *
119
+ * The first two are met through `deliverd.gate()`. The last three come from
120
+ * authoring, which no namespace covers, so a caller reaches them through
121
+ * `deliverd.http` — still the API's codes, still worth explaining, and the
122
+ * reason this table is keyed on what the API returns rather than on which
123
+ * namespace produced it.
124
+ */
125
+ unknown_action: {
126
+ message: "No action by that name is registered.",
127
+ hint: "Register it first — `deliverd actions push`, or POST /v1/actions — and use the same dotted id. A gate on an unregistered action is refused before any rule is read, so this is not a policy saying no.",
128
+ },
129
+ invalid_input: {
130
+ message: "The arguments do not match the action's registered schema.",
131
+ hint: "Read `details` for the field. The schema is the one your organisation registered for this action, so either the call is wrong or the registration is out of date.",
132
+ },
133
+ invalid_rules: {
134
+ message: "Those rules cannot be stored as written.",
135
+ hint: "Read `details` — it names each condition that could not be checked, usually a field no registered action declares. This is refused now rather than at evaluation, where the rule would match nothing and look like one that had simply not fired.",
136
+ },
137
+ duplicate: {
138
+ hint: "Something with that name is already there. Add a version to it rather than creating a second one.",
139
+ },
140
+ superseded: {
141
+ hint: "It was replaced while you were working. Read the current one and act on that; copy its contents into a new version rather than reviving the old, because a past decision points at what it said.",
142
+ },
64
143
  invalid_signature: {
65
144
  hint: "Check the endpoint's signing secret, and that you passed the raw request body rather than a re-encoded object.",
66
145
  },
@@ -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"];
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"];
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,8GAYnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAoiDtD,CAAC"}
1
+ {"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,gIAcnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAo3EtD,CAAC"}