plures 1.15.0 → 1.18.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/dist/index.d.ts CHANGED
@@ -4,6 +4,93 @@ type Option = {
4
4
  };
5
5
  /** "verifiers" asks ID verified people first; "team" goes straight to your own people ($0.05 per internal vote live). */
6
6
  type Route = "verifiers" | "team";
7
+ type DriftDiagnosis = {
8
+ summary: string;
9
+ confidence: "high" | "medium" | "low";
10
+ causes: {
11
+ title: string;
12
+ detail: string;
13
+ files: {
14
+ file: string;
15
+ line?: number | null;
16
+ }[];
17
+ }[];
18
+ changes: {
19
+ file: string;
20
+ why: string;
21
+ }[];
22
+ evals_added: number;
23
+ };
24
+ type DriftCase = {
25
+ object: "drift_case";
26
+ id: string;
27
+ app: string;
28
+ mode: "live" | "test";
29
+ source: "rubric" | "answers";
30
+ key: string;
31
+ label: string;
32
+ status: "open" | "diagnosing" | "diagnosed" | "fix_open" | "verifying" | "recovered" | "dismissed" | "failed";
33
+ baseline: number | null;
34
+ at_open: number | null;
35
+ current: number | null;
36
+ points: number;
37
+ version_before: string | null;
38
+ version_after: string | null;
39
+ diagnosis: DriftDiagnosis | null;
40
+ pr_url: string | null;
41
+ merged_at: string | null;
42
+ post_n: number;
43
+ recovered_at: string | null;
44
+ opened_at: string;
45
+ };
46
+ type TurnParams = {
47
+ /** Which version of your assistant answered, like "prompt v15", so a drop can be traced to a change. */ version?: string;
48
+ /** What the user said or typed. */ question: string;
49
+ /** What the assistant replied ("" if it said nothing). */ answer: string;
50
+ /** Where your router sent it. */ intent?: string;
51
+ /** If the model corrected the router. */ rerouted_to?: string | null;
52
+ /** How it retrieved, like "full", "rerank" or "agentic". */ retrieval?: string;
53
+ /** What it used. [] means it answered with none. */ sources?: {
54
+ id?: string;
55
+ title?: string;
56
+ snippet?: string;
57
+ score?: number;
58
+ }[];
59
+ /** It said it didn't know. Plures guesses from the answer if you leave it out. */ refused?: boolean;
60
+ /** A conversation or call id, so Plures can tell when the user asks again. */ session?: string;
61
+ channel?: "voice" | "text";
62
+ /** A recording people can play, for voice. */ audio_url?: string;
63
+ /** Every intent your router can pick, so graders can choose the right one. */ intents?: string[];
64
+ /** Send this one for review whatever the sample says. */ review?: boolean;
65
+ app?: string;
66
+ metadata?: Record<string, unknown>;
67
+ };
68
+ type CheckOverrides = {
69
+ question?: string;
70
+ options?: string[];
71
+ instructions?: string;
72
+ verifiers?: number;
73
+ team?: string;
74
+ route?: "verifiers" | "team";
75
+ /** Check this one even if the sample or a condition would skip it. */ always?: boolean;
76
+ /** Share of calls people check, 0 to 1, for this call. */ sample?: number;
77
+ /** Seconds people have to answer. */ timeout?: number;
78
+ metadata?: Record<string, unknown>;
79
+ webhook_url?: string;
80
+ };
81
+ type CheckExtra = {
82
+ check: string;
83
+ on_timeout: "proceed" | "hold";
84
+ kept_private?: string[];
85
+ skipped_because?: string;
86
+ };
87
+ type CheckResult = Task & Omit<CheckExtra, "kept_private" | "skipped_because"> & {
88
+ /** The option to act on, by label. */ answer: string | null;
89
+ /** false when the check wasn't needed this time (a sample or a condition). */ checked: boolean;
90
+ timed_out: boolean;
91
+ kept_private: string[];
92
+ skipped_because: string | null;
93
+ };
7
94
  type TaskStatus = "pending" | "completed" | "expired" | "canceled" | "skipped";
8
95
  type Result = {
9
96
  answer: string | null;
@@ -253,6 +340,30 @@ type MapKey = {
253
340
  created_at: string;
254
341
  last_used_at: string | null;
255
342
  };
343
+ type MapChanges = {
344
+ since: number | null;
345
+ added: {
346
+ id: string;
347
+ label: string;
348
+ score: number | null;
349
+ checked: boolean;
350
+ }[];
351
+ removed: {
352
+ id: string;
353
+ label: string;
354
+ }[];
355
+ renamed: {
356
+ from: string;
357
+ to: string;
358
+ label: string;
359
+ }[];
360
+ risky: {
361
+ id: string;
362
+ label: string;
363
+ score: number;
364
+ why: string[];
365
+ }[];
366
+ };
256
367
  type StoredAgentMap = AgentMap & {
257
368
  object: "agent_map";
258
369
  app: string;
@@ -260,6 +371,23 @@ type StoredAgentMap = AgentMap & {
260
371
  created_at?: string;
261
372
  via?: string;
262
373
  url?: string;
374
+ /** Set for a branch map: the branch, the main map version it's compared with, and its pull request. */
375
+ branch?: string;
376
+ main_version?: number | null;
377
+ pull_request?: string | null;
378
+ changes?: MapChanges;
379
+ engine?: {
380
+ version: string;
381
+ actions: Record<string, {
382
+ score: number;
383
+ factors: string[];
384
+ oversight: {
385
+ mode: string;
386
+ rate: number | null;
387
+ verifiers: number;
388
+ };
389
+ }>;
390
+ };
263
391
  };
264
392
  type Rubric = {
265
393
  object: "rubric";
@@ -352,7 +480,7 @@ type WebhookEvent = {
352
480
  created_at: string;
353
481
  data: Task;
354
482
  };
355
- declare const VERSION = "1.15.0";
483
+ declare const VERSION = "1.18.0";
356
484
  type GitHubLink = {
357
485
  object: "github_link";
358
486
  app: string;
@@ -469,7 +597,10 @@ declare class Plures {
469
597
  guide: () => Promise<string>;
470
598
  retrieve: (app: string) => Promise<StoredAgentMap>;
471
599
  /** Uploads a new version. Checks you already added or dismissed keep that. */
472
- upload: (app: string, map: AgentMap) => Promise<StoredAgentMap>;
600
+ /** A branch other than the main one gets its own map, compared with main, and noted on its pull request. */
601
+ upload: (app: string, map: AgentMap, opts?: {
602
+ branch?: string;
603
+ }) => Promise<StoredAgentMap>;
473
604
  setCheckpoint: (app: string, id: string, status: "added" | "dismissed" | "suggested") => Promise<StoredAgentMap>;
474
605
  /** A key that can only read and upload this app's map, for CI. The key is in the response once. */
475
606
  createKey: (app: string, opts?: {
@@ -525,6 +656,17 @@ declare class Plures {
525
656
  phase: string;
526
657
  received: number;
527
658
  }>;
659
+ /** After npx plures check add pushed a branch with the check in it: Plures opens the pull request. Pass error instead if adding it failed. */
660
+ checkPr: (app: string, id: string, p: {
661
+ branch: string;
662
+ } | {
663
+ error: string;
664
+ }) => Promise<{
665
+ object: "check_pr";
666
+ check: string;
667
+ opened: boolean;
668
+ pull_request?: string;
669
+ }>;
528
670
  /** The GitHub Actions workflow that maps a repo on every push to its main branch. */
529
671
  workflow: (app: string, branch?: string) => Promise<string>;
530
672
  };
@@ -652,8 +794,97 @@ declare class Plures {
652
794
  metadata: Record<string, unknown>;
653
795
  }[]>;
654
796
  };
797
+ /**
798
+ * Answer reviews: send each turn your assistant answers, with where it routed and what it
799
+ * retrieved. Plures picks the ones worth a look (rerouted, refused, empty, no sources, asked
800
+ * again, plus a few at random) and your team grades them. Free, and nothing waits on it: call
801
+ * it after the reply and don't await it in the user's path.
802
+ */
803
+ turns: {
804
+ log: (t: TurnParams) => Promise<{
805
+ object: "turn";
806
+ id: string;
807
+ app: string;
808
+ picked: boolean;
809
+ reason: string | null;
810
+ signals: string[];
811
+ asked_again_of?: string;
812
+ }>;
813
+ /** Grade a turn from your own tools. */
814
+ grade: (id: string, g: {
815
+ intent_ok?: boolean;
816
+ right_intent?: string;
817
+ grounded?: "yes" | "partly" | "no" | "should_refuse" | "should_answer";
818
+ complete?: boolean;
819
+ missed?: string;
820
+ fact?: string;
821
+ doc?: string;
822
+ note?: string;
823
+ email?: string;
824
+ }) => Promise<{
825
+ object: "turn_grade";
826
+ turn: string;
827
+ }>;
828
+ /** What the grades say: per intent, misroutes, retrieval misses and missed asks. */
829
+ insights: (app: string, opts?: {
830
+ days?: number;
831
+ }) => Promise<Record<string, unknown>>;
832
+ /** Graded turns as eval data: routes (routing examples), retrieval ({ query, doc, must_contain }), qa ({ question, fact } or { question, unanswerable }), missed. */
833
+ export: (app: string, kind: "routes" | "retrieval" | "qa" | "missed", opts?: {
834
+ since?: string;
835
+ }) => Promise<Record<string, unknown>[]>;
836
+ };
837
+ /**
838
+ * Drift: when a rubric's grades or an answer intent's grades fall, Plures opens a case, the repo's
839
+ * runner reads the code with the examples that got worse and opens a fix, and Plures checks the
840
+ * fix brings quality back. npx plures drift fix does the reading in your repo.
841
+ */
842
+ drift: {
843
+ list: (app: string) => Promise<{
844
+ object: "list";
845
+ data: DriftCase[];
846
+ }>;
847
+ /** Runs the fix on GitHub through the repo's Plures workflow. */
848
+ fix: (app: string, id: string) => Promise<{
849
+ object: "drift_fix";
850
+ case: string;
851
+ status: string;
852
+ session: string;
853
+ }>;
854
+ /** What got worse: graded examples, the change that started it, and the steps on the map. */
855
+ packet: (app: string, id: string) => Promise<Record<string, unknown> & {
856
+ case: string;
857
+ label: string;
858
+ session: string | null;
859
+ kind: "rubric" | "answers";
860
+ }>;
861
+ /** After reading the code: the diagnosis, and the branch with the fix if there is one. Plures opens the pull request. */
862
+ report: (app: string, id: string, p: {
863
+ diagnosis: DriftDiagnosis;
864
+ branch?: string | null;
865
+ } | {
866
+ error: string;
867
+ }) => Promise<{
868
+ object: "drift_fix";
869
+ case: string;
870
+ status: string;
871
+ pull_request?: string;
872
+ }>;
873
+ };
655
874
  /** Your prepaid credit. A live task that could cost more than available_cents is refused with a 402 insufficient_credits error. */
656
875
  balance: () => Promise<Balance>;
876
+ /**
877
+ * Runs a check from your app's map and waits for the decision. Send the data by name; the check
878
+ * saved on Plures supplies the question, options, guidance, which fields people see (the rest
879
+ * never leave Plures), who decides, how often and what happens on a timeout. Any of those can be
880
+ * overridden for this call. `answer` is the option to act on: what people chose, the first option
881
+ * when the check wasn't needed (a sample or a condition) or timed out set to go ahead, and null
882
+ * when it timed out set to hold.
883
+ */
884
+ check(id: string, data?: Record<string, unknown>, overrides?: CheckOverrides, opts?: {
885
+ timeoutMs?: number;
886
+ idempotencyKey?: string;
887
+ }): Promise<CheckResult>;
657
888
  /** Creates a task and waits for people to answer it. */
658
889
  verify(params: CreateTask, opts?: {
659
890
  timeoutMs?: number;
@@ -667,4 +898,4 @@ declare class Plures {
667
898
  static verifyWebhook(rawBody: string, signatureHeader: string | null, secret: string, toleranceSec?: number): Promise<WebhookEvent>;
668
899
  }
669
900
 
670
- export { type AgentMap, type App, type Balance, type Consensus, type CreateTask, type Escalation, type GitHubLink, type MapCheckpoint, type MapDraft, type MapKey, type MapNode, type Mix, type Option, Plures, PluresError, type Release, type Result, type Route, type Routing, type RoutingRule, type RoutingUpdate, type Rubric, type RubricParams, type Sample, type StoredAgentMap, type Task, type TaskStatus, type TeamTally, type TeamVote, type TestMix, VERSION, type WebhookEvent, Plures as default };
901
+ export { type AgentMap, type App, type Balance, type CheckOverrides, type CheckResult, type Consensus, type CreateTask, type DriftCase, type DriftDiagnosis, type Escalation, type GitHubLink, type MapChanges, type MapCheckpoint, type MapDraft, type MapKey, type MapNode, type Mix, type Option, Plures, PluresError, type Release, type Result, type Route, type Routing, type RoutingRule, type RoutingUpdate, type Rubric, type RubricParams, type Sample, type StoredAgentMap, type Task, type TaskStatus, type TeamTally, type TeamVote, type TestMix, type TurnParams, VERSION, type WebhookEvent, Plures as default };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  PluresError,
4
4
  VERSION,
5
5
  index_default
6
- } from "./chunk-JSR4MDEK.js";
6
+ } from "./chunk-RKIJTDS3.js";
7
7
  export {
8
8
  Plures,
9
9
  PluresError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plures",
3
- "version": "1.15.0",
3
+ "version": "1.18.0",
4
4
  "description": "Human judgment as an API for AI agents. Send a decision to ID verified people and get their consensus back.",
5
5
  "keywords": [
6
6
  "human-in-the-loop",