@deliverd/sdk 0.27.0 → 0.29.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 CHANGED
@@ -363,6 +363,48 @@ A finding of kind `decision` is a suggestion until a person confirms it.
363
363
  `task.requestDecisionApproval(findingId)` puts it to somebody. Only a person
364
364
  changes what a task is for; an agent proposes that as a finding too.
365
365
 
366
+ ## Context
367
+
368
+ What your agents know, and how the job gets done, kept in Deliverd rather than
369
+ in any one agent's memory. An agent proposes knowledge; a person confirms it;
370
+ every agent after that reads it.
371
+
372
+ ```ts
373
+ const { entries } = await deliverd.knowledge.search({ q: "supplier bank details" });
374
+
375
+ await deliverd.knowledge.propose({
376
+ kind: "convention",
377
+ title: "Bank details are confirmed by phone",
378
+ body: "Call the number on file, never the one in the email asking for the change.",
379
+ tags: ["payments"],
380
+ });
381
+ ```
382
+
383
+ A task's context carries the confirmed entries relevant to it as
384
+ `context.knowledge`, so most agents never call `search()` at all. The
385
+ knowledge is yours to take anywhere: `deliverd.knowledge.exportMarkdown()`
386
+ returns Markdown that `import()` reads back, and `agentsMd()` writes an
387
+ AGENTS.md for a tool that reads files rather than calling APIs.
388
+
389
+ A playbook is a job written down as steps, each with the rule that applies
390
+ before it acts. A person puts it in force; running it starts an objective with
391
+ a side task per step:
392
+
393
+ ```ts
394
+ const [playbook] = await deliverd.playbooks.list();
395
+ const run = await deliverd.playbooks.start(playbook.inForce!.id, {
396
+ inputs: { supplier: "Northwind" },
397
+ externalId: "onboard-northwind",
398
+ });
399
+ run.steps; // [{ key, taskId, title, rule }], in order
400
+ ```
401
+
402
+ A step's context names the call its rule needs (`check_gate`,
403
+ `request_approval` or `request_review`). `deliverd.knowledge.given(taskId)`
404
+ says what a run was given, and who confirmed it. Confirming knowledge and
405
+ putting a playbook in force are a person's, in the app; a key can draft and
406
+ propose, never decide.
407
+
366
408
  ## Compliance Mode
367
409
 
368
410
  On Business and Enterprise, a task can be governed: the AI system doing the
@@ -0,0 +1,50 @@
1
+ import type { HttpClient } from "./http.js";
2
+ import type { ContextGiven, DraftPlaybookInput, EditKnowledgeInput, ExportKnowledgeInput, ImportedKnowledge, ImportKnowledgeInput, KnowledgeDetail, KnowledgeEntryData, KnowledgeExport, KnowledgeSearchResult, PlaybookData, PlaybookDetail, PlaybookSummary, PromoteFindingInput, ProposedKnowledge, ProposeKnowledgeInput, RequestPlaybookApprovalInput, SearchKnowledgeInput, StartedPlaybook, StartPlaybookInput, PlaybookKind, UsedPrompt, UsePromptInput } from "./types.js";
3
+ export declare class Knowledge {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /** Ranked by relevance to `q`; confirmed entries unless `status` says otherwise. */
7
+ search(input?: SearchKnowledgeInput, signal?: AbortSignal): Promise<KnowledgeSearchResult>;
8
+ /** One entry, with the versions before and after it. */
9
+ get(id: string, signal?: AbortSignal): Promise<KnowledgeDetail>;
10
+ /** Propose an entry. It is a proposal until a person confirms it. */
11
+ propose(input: ProposeKnowledgeInput, signal?: AbortSignal): Promise<ProposedKnowledge>;
12
+ /** Change a proposal you made. A confirmed entry is changed by proposing a revision (`supersedesId`). */
13
+ edit(id: string, input: EditKnowledgeInput, signal?: AbortSignal): Promise<KnowledgeEntryData>;
14
+ /** Propose a task's finding as knowledge, keeping where it came from. */
15
+ promoteFinding(taskId: string, findingId: string, input?: PromoteFindingInput, signal?: AbortSignal): Promise<ProposedKnowledge>;
16
+ /** Bring in a Deliverd export or a notes file such as AGENTS.md. Each heading becomes a proposed entry. */
17
+ import(input: ImportKnowledgeInput, signal?: AbortSignal): Promise<ImportedKnowledge>;
18
+ /** Everything you may see, as Markdown that imports back. */
19
+ exportMarkdown(input?: ExportKnowledgeInput, signal?: AbortSignal): Promise<string>;
20
+ /** The same, as JSON. */
21
+ exportJson(input?: ExportKnowledgeInput, signal?: AbortSignal): Promise<KnowledgeExport>;
22
+ /** An AGENTS.md of the confirmed knowledge and the playbooks in force, for a tool that reads files. */
23
+ agentsMd(options?: {
24
+ workspaceId?: string;
25
+ }, signal?: AbortSignal): Promise<string>;
26
+ /** What a task and its side tasks were given, newest first: the record behind "what did it know?". */
27
+ given(taskId: string, signal?: AbortSignal): Promise<ContextGiven[]>;
28
+ }
29
+ export declare class Playbooks {
30
+ private readonly http;
31
+ constructor(http: HttpClient);
32
+ /** One row per playbook: its newest version, and the version in force. `kind: "prompt"` for approved prompts only. */
33
+ list(options?: {
34
+ kind?: PlaybookKind;
35
+ }, signal?: AbortSignal): Promise<PlaybookSummary[]>;
36
+ get(id: string, signal?: AbortSignal): Promise<PlaybookDetail>;
37
+ /** Draft a new playbook. Nobody runs a draft until a person puts it in force. */
38
+ draft(input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
39
+ /** Draft the next version of a playbook; the version in force keeps running until this one replaces it. */
40
+ draftVersion(id: string, input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
41
+ /** Change a draft that has not been put to anybody. */
42
+ updateDraft(id: string, input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
43
+ /** Put a draft to people as a Deliverd approval. Approved, it goes in force. Needs `approvals:write` and `tasks:write`. */
44
+ requestApproval(id: string, input?: RequestPlaybookApprovalInput, signal?: AbortSignal): Promise<PlaybookData>;
45
+ /** Take an approved prompt: the version in force, filled in with `inputs`. The use is recorded against the version. */
46
+ use(id: string, input?: UsePromptInput, signal?: AbortSignal): Promise<UsedPrompt>;
47
+ /** Run the version in force: an objective, and a side task per step. */
48
+ start(id: string, input?: StartPlaybookInput, signal?: AbortSignal): Promise<StartedPlaybook>;
49
+ }
50
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,oB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,GAAG,OAAO,CAAC,YAAY,CAAC;IAIlH,uHAAuH;IACvH,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAItF,wEAAwE;IACxE,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,kBAAuB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;CAGlG"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Context: what your agents know, and how the job gets done.
3
+ *
4
+ * Knowledge is the organisation's, not any one agent's: an agent proposes an
5
+ * entry, a person confirms it in Deliverd, and every agent after that reads
6
+ * it, through this SDK, the MCP tools, or an AGENTS.md exported from it. The
7
+ * export is Markdown and imports back, so none of it is locked to a tool.
8
+ *
9
+ * A playbook is a written-down job: steps, each with the rule that applies
10
+ * before it acts (a gate, an approval, a review). Running one starts an
11
+ * objective with a side task per step. A person puts a playbook in force; an
12
+ * agent's key can draft one and run one, never publish it, and never confirm
13
+ * knowledge.
14
+ *
15
+ * An approved prompt is a playbook of kind `prompt`: the organisation's agreed
16
+ * words for a piece of work, approved and versioned the same way. `use()`
17
+ * hands out the version in force, filled in, and records the use.
18
+ */
19
+ const enc = encodeURIComponent;
20
+ export class Knowledge {
21
+ http;
22
+ constructor(http) {
23
+ this.http = http;
24
+ }
25
+ /** Ranked by relevance to `q`; confirmed entries unless `status` says otherwise. */
26
+ search(input = {}, signal) {
27
+ return this.http.request({
28
+ method: "GET",
29
+ path: "/knowledge",
30
+ query: { q: input.q, kind: input.kind, status: input.status, workspaceId: input.workspaceId, flowId: input.flowId, limit: input.limit },
31
+ signal,
32
+ });
33
+ }
34
+ /** One entry, with the versions before and after it. */
35
+ get(id, signal) {
36
+ return this.http.request({ method: "GET", path: `/knowledge/${enc(id)}`, signal });
37
+ }
38
+ /** Propose an entry. It is a proposal until a person confirms it. */
39
+ propose(input, signal) {
40
+ return this.http.request({ method: "POST", path: "/knowledge", body: input, signal });
41
+ }
42
+ /** Change a proposal you made. A confirmed entry is changed by proposing a revision (`supersedesId`). */
43
+ edit(id, input, signal) {
44
+ return this.http.request({ method: "PATCH", path: `/knowledge/${enc(id)}`, body: input, signal });
45
+ }
46
+ /** Propose a task's finding as knowledge, keeping where it came from. */
47
+ promoteFinding(taskId, findingId, input = {}, signal) {
48
+ return this.http.request({
49
+ method: "POST",
50
+ path: `/tasks/${enc(taskId)}/findings/${enc(findingId)}/knowledge`,
51
+ body: input,
52
+ signal,
53
+ });
54
+ }
55
+ /** Bring in a Deliverd export or a notes file such as AGENTS.md. Each heading becomes a proposed entry. */
56
+ import(input, signal) {
57
+ return this.http.request({ method: "POST", path: "/knowledge/import", body: input, signal });
58
+ }
59
+ /** Everything you may see, as Markdown that imports back. */
60
+ exportMarkdown(input = {}, signal) {
61
+ return this.http.request({
62
+ method: "GET",
63
+ path: "/knowledge/export",
64
+ query: { format: "markdown", status: input.status, workspaceId: input.workspaceId },
65
+ responseType: "text",
66
+ signal,
67
+ });
68
+ }
69
+ /** The same, as JSON. */
70
+ exportJson(input = {}, signal) {
71
+ return this.http.request({
72
+ method: "GET",
73
+ path: "/knowledge/export",
74
+ query: { format: "json", status: input.status, workspaceId: input.workspaceId },
75
+ signal,
76
+ });
77
+ }
78
+ /** An AGENTS.md of the confirmed knowledge and the playbooks in force, for a tool that reads files. */
79
+ agentsMd(options = {}, signal) {
80
+ return this.http.request({
81
+ method: "GET",
82
+ path: "/knowledge/agents-md",
83
+ query: { workspaceId: options.workspaceId },
84
+ responseType: "text",
85
+ signal,
86
+ });
87
+ }
88
+ /** What a task and its side tasks were given, newest first: the record behind "what did it know?". */
89
+ async given(taskId, signal) {
90
+ const out = await this.http.request({ method: "GET", path: `/tasks/${enc(taskId)}/context-given`, signal });
91
+ return out.given;
92
+ }
93
+ }
94
+ export class Playbooks {
95
+ http;
96
+ constructor(http) {
97
+ this.http = http;
98
+ }
99
+ /** One row per playbook: its newest version, and the version in force. `kind: "prompt"` for approved prompts only. */
100
+ async list(options = {}, signal) {
101
+ const out = await this.http.request({ method: "GET", path: "/playbooks", query: { kind: options.kind }, signal });
102
+ return out.playbooks;
103
+ }
104
+ get(id, signal) {
105
+ return this.http.request({ method: "GET", path: `/playbooks/${enc(id)}`, signal });
106
+ }
107
+ /** Draft a new playbook. Nobody runs a draft until a person puts it in force. */
108
+ draft(input, signal) {
109
+ return this.http.request({ method: "POST", path: "/playbooks", body: input, signal });
110
+ }
111
+ /** Draft the next version of a playbook; the version in force keeps running until this one replaces it. */
112
+ draftVersion(id, input, signal) {
113
+ return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/versions`, body: input, signal });
114
+ }
115
+ /** Change a draft that has not been put to anybody. */
116
+ updateDraft(id, input, signal) {
117
+ return this.http.request({ method: "PATCH", path: `/playbooks/${enc(id)}`, body: input, signal });
118
+ }
119
+ /** Put a draft to people as a Deliverd approval. Approved, it goes in force. Needs `approvals:write` and `tasks:write`. */
120
+ requestApproval(id, input = {}, signal) {
121
+ return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/approval`, body: input, signal });
122
+ }
123
+ /** Take an approved prompt: the version in force, filled in with `inputs`. The use is recorded against the version. */
124
+ use(id, input = {}, signal) {
125
+ return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/use`, body: input, signal });
126
+ }
127
+ /** Run the version in force: an objective, and a side task per step. */
128
+ start(id, input = {}, signal) {
129
+ return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/start`, body: input, signal });
130
+ }
131
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"data-screen.d.ts","sourceRoot":"","sources":["../src/data-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,+DAAgE,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,M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" : String.fromCharCode(64 + r));
98
98
  }
99
99
  function ipv4Valid(raw) {
100
+ // "v1.2.3.4" and "version 1.2.3.4" are versions, and so is "1.2.3.4.5".
101
+ if (/[a-z]/i.test(raw))
102
+ return false;
100
103
  const parts = raw.split(".").map(Number);
101
104
  if (parts.length !== 4 || parts.some((p) => p > 255))
102
105
  return false;
103
106
  // Loopback and the unspecified address identify nobody.
104
107
  return parts[0] !== 127 && parts[0] !== 0;
105
108
  }
109
+ /** Eight groups, or a "::" and at least three, so "10:30:00" and a MAC address are not addresses. */
110
+ function ipv6Valid(raw) {
111
+ if (raw.includes(":::"))
112
+ return false;
113
+ const compressed = raw.split("::").length - 1;
114
+ const groups = raw.split(":").filter(Boolean).length;
115
+ return compressed === 0 ? groups === 8 : compressed === 1 && groups >= 3 && groups <= 7;
116
+ }
117
+ /** A value in a .env line that is a placeholder, not a credential. */
118
+ function envSecretValid(value) {
119
+ return !/^[<{%(]/.test(value) && !/your|example|placeholder|changeme|xxxx/i.test(value);
120
+ }
106
121
  /**
107
122
  * Credential patterns. The same set the publish scanner blocks a report for,
108
123
  * because a key that must not be published must not be sent to a model either.
109
124
  */
110
125
  const SECRET_PATTERNS = [
111
126
  /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
112
- /-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY(?: BLOCK)?-----/g,
127
+ // The whole block, or the header and the lines of key under it when the end was cut off.
128
+ /-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP |ENCRYPTED )?PRIVATE KEY(?: BLOCK)?-----(?:[\s\S]*?-----END (?:RSA |EC |DSA |OPENSSH |PGP |ENCRYPTED )?PRIVATE KEY(?: BLOCK)?-----|(?:\r?\n[A-Za-z0-9+\/=]{16,})*)/g,
113
129
  /\bgh[pousr]_[A-Za-z0-9]{36,255}\b/g,
114
130
  /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,
115
131
  /\b[sr]k_(?:live|test)_[A-Za-z0-9]{20,}\b/g,
@@ -129,6 +145,15 @@ const SECRET_PATTERNS = [
129
145
  const SPECIAL_PATTERN = /\b(?:diagnos(?:is|ed|es)|medical (?:record|history|condition)s?|mental health|prescri(?:bed|ption)s?|HIV|pregnan(?:t|cy)|disabilit(?:y|ies)|sexual orientation|religious belief|ethnic origin|racial origin|trade union member(?:ship)?|biometric|genetic data|criminal (?:record|conviction|offence)s?)\b/gi;
130
146
  const DETECTORS = [
131
147
  ...SECRET_PATTERNS.map((pattern) => ({ kind: "secret", pattern })),
148
+ // The user and password in a connection string: postgres://user:password@host.
149
+ { kind: "secret", pattern: /\b[A-Za-z][A-Za-z0-9+.-]{1,15}:\/\/([A-Za-z0-9._~%!$&'()*+,;=-]+:[A-Za-z0-9._~%!$&'()*+,;=:-]+)@/g, group: 1 },
150
+ // A credential in a .env line, quoted or not: DB_PASSWORD=..., OPENAI_API_KEY="...".
151
+ {
152
+ kind: "secret",
153
+ pattern: /\b(?:[A-Z0-9]+_)*(?:PASSWORD|PASSWD|SECRET|TOKEN|API_KEY|APIKEY|SECRET_KEY|ACCESS_KEY|PRIVATE_KEY|CLIENT_SECRET|AUTH_TOKEN)[ \t]*=[ \t]*["']?([!%&(-~]{6,})/g,
154
+ valid: envSecretValid,
155
+ group: 1,
156
+ },
132
157
  { kind: "iban", pattern: /\b[A-Z]{2}\d{2}(?: ?[A-Z0-9]{4}){2,7}(?: ?[A-Z0-9]{1,4})?\b/g, valid: ibanValid },
133
158
  {
134
159
  kind: "payment_card",
@@ -160,7 +185,13 @@ const DETECTORS = [
160
185
  return d.length >= 9 && d.length <= 15;
161
186
  },
162
187
  },
163
- { kind: "ip_address", pattern: /\b(?:\d{1,3}\.){3}\d{1,3}\b/g, valid: ipv4Valid },
188
+ {
189
+ kind: "phone",
190
+ // A North American number written the North American way: (415) 555-0132, 415-555-0132.
191
+ pattern: /(?:\+1[ .-]?)?\([2-9]\d{2}\)[ .-]?[2-9]\d{2}[ .-]\d{4}\b|\b[2-9]\d{2}[.-][2-9]\d{2}[.-]\d{4}\b/g,
192
+ },
193
+ { kind: "ip_address", pattern: /\b(?:(?:version|release|build|ver|v)[ \t:]*)?(?:\d{1,3}\.){3}\d{1,3}(?:\.\d+)*\b/gi, valid: ipv4Valid },
194
+ { kind: "ip_address", pattern: /\b[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{0,4}){2,7}\b/g, valid: ipv6Valid },
164
195
  { kind: "special_category", pattern: SPECIAL_PATTERN },
165
196
  ];
166
197
  /** Earlier wins an overlap: a card number is not also a phone number. */
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,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"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAYb,MAAM,YAAY,CAAC;AAIpB;;;;;;;;;;;;;;;;;;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,CAynB1F"}
package/dist/dev.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { assessCounts, DEFAULT_SCREEN_POLICY, describeCounts } from "./data-screen.js";
2
+ import { applyPurview } from "./purview-rules.js";
2
3
  const DEFAULT_QUESTION = "Has this been through staging?";
3
4
  let counter = 0;
4
5
  /**
@@ -553,13 +554,13 @@ export function developmentFetch(options = {}) {
553
554
  if (method === "POST" && path === "/screen") {
554
555
  const counts = (body.counts ?? {});
555
556
  const termClassification = body.termClassification === "restricted" ? "restricted" : "confidential";
556
- const assessment = assessCounts(counts, null, DEFAULT_SCREEN_POLICY, termClassification);
557
+ const assessment = applyPurview(assessCounts(counts, null, DEFAULT_SCREEN_POLICY, termClassification), (body.purview ?? null));
557
558
  let approval = null;
558
559
  if (assessment.verdict === "ask" && body.ask !== false) {
559
560
  const created = (await (await handle(`${url.origin}/api/v1/approvals`, {
560
561
  method: "POST",
561
562
  body: JSON.stringify({
562
- title: `Send ${describeCounts(counts)} to an AI model?`,
563
+ title: assessment.offending.length ? `Send ${describeCounts(counts)} to an AI model?` : "Send text Microsoft Purview flagged to an AI model?",
563
564
  description: assessment.reasons.join("\n"),
564
565
  risk: assessment.classification === "restricted" ? "high" : "medium",
565
566
  externalId: body.externalId,
@@ -580,6 +581,7 @@ export function developmentFetch(options = {}) {
580
581
  findings: null,
581
582
  redactedText: null,
582
583
  approval,
584
+ purview: body.purview ?? null,
583
585
  });
584
586
  }
585
587
  const taskMatch = /^\/tasks\/([^/]+)(?:\/(context|graph|side-tasks|findings|complete|apply|reopen|cancel|links))?$/.exec(path);
package/dist/http.d.ts CHANGED
@@ -37,6 +37,8 @@ interface RequestOptions {
37
37
  * knows how to derive.
38
38
  */
39
39
  idempotencyKey?: string;
40
+ /** `text` hands back the body as it came, for a route that returns a file. */
41
+ responseType?: "json" | "text";
40
42
  }
41
43
  export declare class HttpClient {
42
44
  readonly baseUrl: string;
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AAEvD,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,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,EAAE,WAAW,CAAC;IACrB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AA4BD,qBAAa,UAAU;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;gBAEtC,OAAO,EAAE,aAAa;IAW5B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;CAmFtD;AAED,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
package/dist/http.js CHANGED
@@ -70,7 +70,7 @@ export class HttpClient {
70
70
  method: options.method,
71
71
  headers: {
72
72
  Authorization: `Bearer ${this.apiKey}`,
73
- Accept: "application/json",
73
+ Accept: options.responseType === "text" ? "text/markdown, application/json" : "application/json",
74
74
  "User-Agent": USER_AGENT,
75
75
  // One id per logical request, kept across retries: it is the
76
76
  // thing to quote when something went wrong, and generating it
@@ -94,6 +94,8 @@ export class HttpClient {
94
94
  if (response.status === 204)
95
95
  return undefined;
96
96
  const text = await response.text();
97
+ if (options.responseType === "text" && response.ok)
98
+ return text;
97
99
  let json;
98
100
  try {
99
101
  json = text ? JSON.parse(text) : {};
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { Reviews, type ReviewWaitOptions } from "./reviews.js";
6
6
  import { Collections, type CollectWaitOptions } from "./collections.js";
7
7
  import { Flows } from "./flows.js";
8
8
  import { Tasks } from "./tasks.js";
9
+ import { Knowledge, Playbooks } from "./context.js";
9
10
  import { AiGovernance } from "./governance.js";
10
11
  import { Webhooks } from "./webhooks.js";
11
12
  import { DecisionTokens } from "./decision-token.js";
@@ -21,10 +22,12 @@ export { Review, Reviews, type ReviewWaitOptions } from "./reviews.js";
21
22
  export { Collection, Collections, type CollectWaitOptions } from "./collections.js";
22
23
  export { Flow, Flows, type FlowPrimitives } from "./flows.js";
23
24
  export { Task, Tasks } from "./tasks.js";
25
+ export { Knowledge, Playbooks } from "./context.js";
24
26
  export { AiGovernance, AiSystems, Incidents } from "./governance.js";
25
27
  export { WebhookEndpoints } from "./webhook-endpoints.js";
26
28
  export { canonicalJson, DECISION_TOKEN_CONTEXT, DECISION_TOKEN_PREFIX, decisionInputHash, DecisionTokens, EVIDENCE_KEY_PATH, verifyDecisionToken, type DecisionTokenClaims, type DecisionTokenExpectation, type DecisionTokenFailure, type DecisionTokenResult, } from "./decision-token.js";
27
29
  export { Screened, type ScreenOptions } from "./screen.js";
30
+ export { entraAppToken, purviewCheck, type EntraAppTokenOptions, type PurviewCheck, type PurviewCheckOptions, type PurviewOutcome, type PurviewOnUnavailable, type PurviewRestriction } from "./purview.js";
28
31
  export { DATA_KINDS, redact, restore, screenText, summarise, type DataKind, type DetectedSpan, type Redaction, type ScreenFinding, type ScreenTerm, type SpanDetector, } from "./data-screen.js";
29
32
  export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
30
33
  export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
@@ -128,6 +131,10 @@ export declare class Deliverd {
128
131
  readonly collections: Collections;
129
132
  readonly flows: Flows;
130
133
  readonly tasks: Tasks;
134
+ /** What your agents know: proposed by agents, confirmed by people, exported to anywhere. */
135
+ readonly knowledge: Knowledge;
136
+ /** Jobs written down as steps, each with the rule that applies before it acts. */
137
+ readonly playbooks: Playbooks;
131
138
  /** Compliance Mode across the organisation: AI systems, incidents, authority, frameworks, the ICT register. */
132
139
  readonly governance: AiGovernance;
133
140
  readonly reports: Reports;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources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} from "./reviews.js";
6
6
  import { Collections } from "./collections.js";
7
7
  import { Flows } from "./flows.js";
8
8
  import { Tasks } from "./tasks.js";
9
+ import { Knowledge, Playbooks } from "./context.js";
9
10
  import { AiGovernance } from "./governance.js";
10
11
  import { Webhooks } from "./webhooks.js";
11
12
  import { DecisionTokens } from "./decision-token.js";
@@ -20,10 +21,12 @@ export { Review, Reviews } from "./reviews.js";
20
21
  export { Collection, Collections } from "./collections.js";
21
22
  export { Flow, Flows } from "./flows.js";
22
23
  export { Task, Tasks } from "./tasks.js";
24
+ export { Knowledge, Playbooks } from "./context.js";
23
25
  export { AiGovernance, AiSystems, Incidents } from "./governance.js";
24
26
  export { WebhookEndpoints } from "./webhook-endpoints.js";
25
27
  export { canonicalJson, DECISION_TOKEN_CONTEXT, DECISION_TOKEN_PREFIX, decisionInputHash, DecisionTokens, EVIDENCE_KEY_PATH, verifyDecisionToken, } from "./decision-token.js";
26
28
  export { Screened } from "./screen.js";
29
+ export { entraAppToken, purviewCheck } from "./purview.js";
27
30
  export { DATA_KINDS, redact, restore, screenText, summarise, } from "./data-screen.js";
28
31
  export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
29
32
  export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
@@ -59,6 +62,10 @@ export class Deliverd {
59
62
  collections;
60
63
  flows;
61
64
  tasks;
65
+ /** What your agents know: proposed by agents, confirmed by people, exported to anywhere. */
66
+ knowledge;
67
+ /** Jobs written down as steps, each with the rule that applies before it acts. */
68
+ playbooks;
62
69
  /** Compliance Mode across the organisation: AI systems, incidents, authority, frameworks, the ICT register. */
63
70
  governance;
64
71
  reports;
@@ -93,6 +100,8 @@ export class Deliverd {
93
100
  */
94
101
  this.flows = new Flows(this.http, this);
95
102
  this.tasks = new Tasks(this.http);
103
+ this.knowledge = new Knowledge(this.http);
104
+ this.playbooks = new Playbooks(this.http);
96
105
  this.governance = new AiGovernance(this.http);
97
106
  this.reports = new Reports(this.http);
98
107
  this.comments = new Comments(this.http);
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Microsoft Purview's answer on a text, held beside Deliverd's own.
3
+ *
4
+ * An organisation that runs Microsoft Purview has already written its data
5
+ * loss prevention (DLP) policies there. An app can ask Purview about a text
6
+ * before it is sent to a model, through Microsoft Graph's `processContent`,
7
+ * and Purview answers with what the app must do: nothing, or a restricted
8
+ * access action whose `restrictionAction` is `audit`, `warn` or `block`.
9
+ *
10
+ * The SDKs make that call where the agent runs, with the organisation's own
11
+ * Entra app, so the text goes to Microsoft and never to Deliverd. Deliverd is
12
+ * sent only the outcome below, and holds it beside its own screening:
13
+ *
14
+ * - `block`: nothing is sent. The organisation's own policy said so, and it
15
+ * is honoured on every plan, report-only included.
16
+ * - `warn`: a person decides, through an ordinary approval. Purview's "warn"
17
+ * is an override a user may make; here the override is recorded, with who
18
+ * made it.
19
+ * - `audit`: no hold. Purview has recorded the activity itself.
20
+ *
21
+ * When Purview cannot be reached, the caller has already decided what that
22
+ * means (allow, ask or deny) and says so in `restriction`, with `unavailable`
23
+ * set, so the reason given is honest about it.
24
+ *
25
+ * Pure, with no imports. This file is copied verbatim into
26
+ * `packages/sdk/src/purview-rules.ts` and `packages/screen/src/purview-rules.ts`,
27
+ * and a test fails when they differ.
28
+ */
29
+ export declare const PURVIEW_RESTRICTIONS: readonly ["audit", "warn", "block"];
30
+ export type PurviewRestriction = (typeof PURVIEW_RESTRICTIONS)[number];
31
+ export interface PurviewOutcome {
32
+ /** The strictest restriction among Purview's policy actions; null when there were none. */
33
+ restriction: PurviewRestriction | null;
34
+ /** How many policy actions Purview returned. */
35
+ actions: number;
36
+ /** Purview said the organisation's policies changed since the caller last looked. */
37
+ scopeModified: boolean;
38
+ /** Purview could not be reached; `restriction` is what the caller chose for that case. */
39
+ unavailable: boolean;
40
+ }
41
+ /** What a caller does when Purview cannot be reached. */
42
+ export type PurviewOnUnavailable = "allow" | "ask" | "deny";
43
+ /**
44
+ * The outcome of a `processContent` response body. Anything unrecognised in
45
+ * a policy action counts as a block: a DLP rule the code does not understand
46
+ * is not a reason to send the text.
47
+ */
48
+ export declare function purviewOutcomeFromResponse(body: unknown): PurviewOutcome;
49
+ /** The outcome when Purview could not be reached, by the caller's choice. */
50
+ export declare function purviewUnavailable(onUnavailable: PurviewOnUnavailable): PurviewOutcome;
51
+ type Verdict = "allow" | "redact" | "ask" | "deny";
52
+ /**
53
+ * Deliverd's verdict with Purview's held beside it: the stricter wins, and
54
+ * the reason says it was Purview. `enforce` false is the report-only mode,
55
+ * where Deliverd holds nothing back of its own but a Purview block still
56
+ * stands, because it is the organisation's own policy, not Deliverd's.
57
+ */
58
+ export declare function applyPurview<T extends {
59
+ verdict: Verdict;
60
+ reasons: string[];
61
+ }>(assessment: T, outcome: PurviewOutcome | null | undefined, enforce?: boolean): T;
62
+ export {};
63
+ //# sourceMappingURL=purview-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purview-rules.d.ts","sourceRoot":"","sources":["../src/purview-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,eAAO,MAAM,oBAAoB,qCAAsC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACvC,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,aAAa,EAAE,OAAO,CAAC;IACvB,0FAA0F;IAC1F,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAI5D;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CAWxE;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,oBAAoB,GAAG,cAAc,CAGtF;AAED,KAAK,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAGnD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,EAC5E,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,EAC1C,OAAO,UAAO,GACb,CAAC,CA+BH"}