@deliverd/sdk 0.28.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/src/screen.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  } from "./data-screen.js";
13
13
  import { durationMs, type Duration } from "./duration.js";
14
14
  import type { HttpClient } from "./http.js";
15
+ import type { PurviewCheck } from "./purview.js";
15
16
  import type { ScreenData, ScreenVerdict } from "./types.js";
16
17
 
17
18
  /**
@@ -65,6 +66,13 @@ export interface ScreenOptions {
65
66
  detectors?: readonly SpanDetector[];
66
67
  /** Spans another detector already found in this text. */
67
68
  spans?: readonly DetectedSpan[];
69
+ /**
70
+ * Your organisation's Microsoft Purview, asked about the text before
71
+ * Deliverd: build one with `purviewCheck()`. The text goes from here to
72
+ * Microsoft, never to Deliverd, and only Purview's answer is sent on. A
73
+ * Purview block stops the text; a warn puts it to a person.
74
+ */
75
+ purview?: PurviewCheck;
68
76
  /** Whether to wait for a person on an `ask`. Default true. */
69
77
  wait?: boolean;
70
78
  timeout?: Duration;
@@ -113,6 +121,7 @@ export async function screen(
113
121
  const spans = [...(options.spans ?? [])];
114
122
  for (const detect of options.detectors ?? []) spans.push(...(await detect(text)));
115
123
  const findings = screenText(text, options.terms ?? [], spans);
124
+ const purview = options.purview ? await options.purview(text) : null;
116
125
  const data = await http.request<ScreenData>({
117
126
  method: "POST",
118
127
  path: "/screen",
@@ -122,6 +131,7 @@ export async function screen(
122
131
  ...(options.aiSystemId ? { aiSystemId: options.aiSystemId } : {}),
123
132
  ...(options.purpose ? { purpose: options.purpose } : {}),
124
133
  ...(options.externalId ? { externalId: options.externalId } : {}),
134
+ ...(purview ? { purview } : {}),
125
135
  },
126
136
  signal: options.signal,
127
137
  });
package/src/types.ts CHANGED
@@ -2621,6 +2621,16 @@ export interface ScreenApprovalRef {
2621
2621
  status: string;
2622
2622
  }
2623
2623
 
2624
+ /** Microsoft Purview's answer, as the caller sent it. Never the text. */
2625
+ export interface ScreenPurviewData {
2626
+ /** `null` when Purview returned no restriction. */
2627
+ restriction: "audit" | "warn" | "block" | null;
2628
+ actions: number;
2629
+ scopeModified: boolean;
2630
+ /** Purview could not be reached; `restriction` is what the caller chose for that case. */
2631
+ unavailable: boolean;
2632
+ }
2633
+
2624
2634
  /** What `POST /screen` answers: the verdict, and why. */
2625
2635
  export interface ScreenData {
2626
2636
  verdict: ScreenVerdict;
@@ -2640,6 +2650,8 @@ export interface ScreenData {
2640
2650
  redactedText: string | null;
2641
2651
  /** The approval a person decides, for an `ask` verdict. */
2642
2652
  approval: ScreenApprovalRef | null;
2653
+ /** Microsoft Purview's answer, when `screen()` was given a `purview` check. */
2654
+ purview?: ScreenPurviewData | null;
2643
2655
  }
2644
2656
 
2645
2657
  // ── Context: knowledge and playbooks ────────────────────────────────────────
@@ -2843,6 +2855,30 @@ export interface PlaybookData {
2843
2855
  createdBy: string;
2844
2856
  createdAt: string;
2845
2857
  updatedAt: string;
2858
+ /** `procedure`: steps an agent runs. `prompt`: approved words people and agents use. */
2859
+ kind: PlaybookKind;
2860
+ /** An approved prompt's own fields; null on a procedure. */
2861
+ prompt: PromptFields | null;
2862
+ }
2863
+
2864
+ export type PlaybookKind = "procedure" | "prompt";
2865
+
2866
+ export interface PromptFields {
2867
+ /** The approved words, with `{input}` placeholders. */
2868
+ text: string;
2869
+ /** What it is not for, and how to check what it produces. */
2870
+ limitations: string | null;
2871
+ department: string | null;
2872
+ taskType: string | null;
2873
+ language: string | null;
2874
+ owner: string | null;
2875
+ ownerUserId: string | null;
2876
+ /** YYYY-MM-DD. */
2877
+ reviewDueOn: string | null;
2878
+ /** In force, and its review date has passed. */
2879
+ reviewOverdue: boolean;
2880
+ reviewedAt: string | null;
2881
+ reviewedBy: string | null;
2846
2882
  }
2847
2883
 
2848
2884
  /** A playbook's newest version, and which one is in force. */
@@ -2859,9 +2895,10 @@ export interface PlaybookDetail extends PlaybookData {
2859
2895
  export interface DraftPlaybookInput {
2860
2896
  /** The job, as people name it. */
2861
2897
  title: string;
2862
- /** The outcome. Becomes the objective of every run. */
2898
+ /** The outcome. Becomes the objective of every run; for a prompt, the one line people see. */
2863
2899
  purpose: string;
2864
- steps: {
2900
+ /** Required for a playbook; left out for a prompt, which has one step of its own. */
2901
+ steps?: {
2865
2902
  key?: string;
2866
2903
  title: string;
2867
2904
  instruction: string;
@@ -2873,6 +2910,39 @@ export interface DraftPlaybookInput {
2873
2910
  knowledgeIds?: string[];
2874
2911
  workspaceId?: string;
2875
2912
  note?: string;
2913
+ /** Send instead of `steps` to draft an approved prompt. */
2914
+ prompt?: {
2915
+ /** The words, with each input as `{input name}`. */
2916
+ text: string;
2917
+ limitations?: string;
2918
+ department?: string;
2919
+ /** Such as Analyze, Create or Edit. */
2920
+ taskType?: string;
2921
+ /** Such as en-GB. */
2922
+ language?: string;
2923
+ /** The member who owns it; whoever drafts it when omitted. */
2924
+ ownerEmail?: string;
2925
+ /** YYYY-MM-DD; six months on when omitted. */
2926
+ reviewDueOn?: string;
2927
+ /** Run as a playbook, a person reviews the output before it is used. */
2928
+ checkOutput?: boolean;
2929
+ };
2930
+ }
2931
+
2932
+ export interface UsePromptInput {
2933
+ /** The prompt's inputs, by name. A placeholder not given stays in the words. */
2934
+ inputs?: Record<string, string>;
2935
+ }
2936
+
2937
+ export interface UsedPrompt {
2938
+ prompt: { id: string; title: string; version: number; url: string };
2939
+ /** The approved words with the inputs put in. */
2940
+ text: string;
2941
+ /** Required inputs not given; their placeholders are still in `text`. */
2942
+ missingInputs: string[];
2943
+ limitations: string | null;
2944
+ /** True when you named an older version and the one in force was handed out instead. */
2945
+ ranOlderVersion: boolean;
2876
2946
  }
2877
2947
 
2878
2948
  export interface StartPlaybookInput {