dyadic 1.3.1 → 1.7.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
@@ -1,5 +1,7 @@
1
- export declare const VERSION = "1.3.1";
1
+ export declare const VERSION = "1.7.0";
2
2
  export declare const DEFAULT_BASE_URL = "https://dyadic.app/api/openai/v1";
3
+ /** The Anthropic API version the `anthropic` calls speak (sent as anthropic-version, as Anthropic's SDKs do). */
4
+ export declare const ANTHROPIC_VERSION = "2023-06-01";
3
5
  export type Model = "iris" | "iris-think" | (string & {});
4
6
  export type Role = "system" | "developer" | "user" | "assistant" | "tool";
5
7
  export type ContentPart = {
@@ -192,6 +194,11 @@ export interface ResponseParams {
192
194
  instructions?: string;
193
195
  previous_response_id?: string;
194
196
  store?: boolean;
197
+ /** Continue a conversation (conversations.create): this response's input and output are added to it. */
198
+ conversation?: string | {
199
+ id: string;
200
+ };
201
+ background?: boolean;
195
202
  tools?: Record<string, unknown>[];
196
203
  tool_choice?: unknown;
197
204
  parallel_tool_calls?: boolean;
@@ -400,8 +407,9 @@ export interface Batch {
400
407
  expires_at: number | null;
401
408
  metadata: Record<string, string>;
402
409
  }
403
- /** Dyadic's built-in tools an application's run may use. */
404
- export type BuiltinTool = "data.web_search" | "data.web_fetch" | "image.generate" | "vision.describe_image";
410
+ /** Dyadic's built-in tools an application's run may use (the audio tools need the key's audio switch, the plan tools its
411
+ * plans switch; a run with planMode or planId has the plan tools anyway). */
412
+ export type BuiltinTool = "data.web_search" | "data.web_fetch" | "image.generate" | "vision.describe_image" | "audio.speak" | "audio.transcribe" | "plans.propose" | "plans.step" | "plans.get";
405
413
  /** Your own agent, sent with the run: its name and instructions, optional
406
414
  * behaviour overrides (tool_rules, safety, style, citations, research: text to
407
415
  * replace the default, or false to turn it off) and model choices. */
@@ -429,6 +437,15 @@ export interface RunParams {
429
437
  max_cost_usd?: number;
430
438
  /** Ask for up to four suggested follow-up questions (`followups` on the completed run). */
431
439
  followups?: boolean;
440
+ /** Plan Mode (the key's plans switch): investigate read-only and propose a plan for approval; nothing that changes anything
441
+ * runs. Sent as `plan_mode`. */
442
+ planMode?: boolean;
443
+ /** Carry out this plan of the key's, picking up where it left off; refused with `plan_not_runnable` unless a Plan Mode plan
444
+ * is approved at its current revision. Sent as `plan_id`. */
445
+ planId?: string;
446
+ /** As the API names them (the same as planMode and planId). */
447
+ plan_mode?: boolean;
448
+ plan_id?: string;
432
449
  }
433
450
  export interface Run {
434
451
  object: "run";
@@ -460,11 +477,114 @@ export interface Run {
460
477
  seconds: number;
461
478
  log_id?: string;
462
479
  followups?: string[];
480
+ /** The plans this run made or moved, as it left them (only when it touched any). */
481
+ plans?: {
482
+ id: string;
483
+ title: string;
484
+ status: PlanStatus;
485
+ revision: number;
486
+ }[];
463
487
  }
488
+ /** A streamed run's events; `plan.updated` carries a plan the run made or moved (`plan`). */
464
489
  export interface RunEvent {
465
490
  type: string;
491
+ plan?: Plan;
466
492
  [key: string]: unknown;
467
493
  }
494
+ export type PlanStatus = "draft" | "approved" | "running" | "paused" | "completed" | "failed" | "cancelled";
495
+ export type PlanStepStatus = "pending" | "in_progress" | "completed" | "failed" | "blocked" | "skipped";
496
+ /** A step as you write it: its title alone (numbered in order), or with its key (1, 2, or 2.1 inside 2), how it will be done
497
+ * and checked, and the keys it waits for. */
498
+ export type PlanStepInput = string | {
499
+ key?: string;
500
+ title: string;
501
+ detail?: string;
502
+ depends_on?: string[] | string;
503
+ };
504
+ export interface PlanStep {
505
+ key: string;
506
+ parent: string;
507
+ title: string;
508
+ detail: string;
509
+ status: PlanStepStatus;
510
+ depends_on: string[];
511
+ /** How completion was checked (a run must say it). */
512
+ verified_by: string;
513
+ note: string;
514
+ evidence: Record<string, unknown>[];
515
+ started_at: string | null;
516
+ finished_at: string | null;
517
+ updated_at: string | null;
518
+ }
519
+ export interface PlanEvent {
520
+ id: number;
521
+ object: "plan.event";
522
+ plan_id: string;
523
+ kind: "created" | "revised" | "edited" | "approved" | "started" | "resumed" | "step" | "interrupted" | "completed" | "cancelled";
524
+ type: string;
525
+ step: string | null;
526
+ status: string | null;
527
+ detail: Record<string, unknown>;
528
+ /** iris (an agent in a run), owner (the Workspace) or application (an API key). */
529
+ actor: string;
530
+ operation_id: string | null;
531
+ at: string;
532
+ }
533
+ /** A plan: work as Steps that waits for approval (origin "plan") or runs as the work goes (origin "live"). */
534
+ export interface Plan {
535
+ id: string;
536
+ object: "plan";
537
+ chat_id: string | null;
538
+ api_key_id: string | null;
539
+ conversation: string;
540
+ metadata: Record<string, string>;
541
+ title: string;
542
+ summary: string;
543
+ origin: "plan" | "live";
544
+ status: PlanStatus;
545
+ revision: number;
546
+ approved_revision: number | null;
547
+ approved_at: string | null;
548
+ created_at: string;
549
+ updated_at: string;
550
+ /** Over the steps with no sub-steps. */
551
+ progress: {
552
+ done: number;
553
+ total: number;
554
+ percent: number;
555
+ failed: number;
556
+ blocked: number;
557
+ };
558
+ steps: PlanStep[];
559
+ /** Its recent history, oldest first (not in lists). */
560
+ events?: PlanEvent[];
561
+ }
562
+ export interface PlanCreateParams {
563
+ title: string;
564
+ steps: PlanStepInput[];
565
+ summary?: string;
566
+ /** "plan" (the default) waits for approval; "live" is running from the start. */
567
+ mode?: "plan" | "live";
568
+ /** Your conversation it belongs to (a run's conversation_id). */
569
+ conversation?: string;
570
+ metadata?: Record<string, string>;
571
+ }
572
+ export interface PlanUpdateParams {
573
+ revision: number;
574
+ title?: string;
575
+ summary?: string;
576
+ steps?: PlanStepInput[];
577
+ metadata?: Record<string, string>;
578
+ }
579
+ export interface PlanListQuery {
580
+ conversation?: string;
581
+ status?: PlanStatus;
582
+ limit?: number;
583
+ after?: string;
584
+ }
585
+ /** One event of a plan's live stream: `plan.snapshot` (data: the Plan), `plan.<kind>` (data: the PlanEvent with `plan`, the
586
+ * plan as it is then) or `end` (data: { plan_id, status, last_id }). */
587
+ export type PlanStreamEvent = BlackBoxStreamEvent<any>;
468
588
  /** A function your application runs: its schema and the handler called with the parsed arguments. */
469
589
  export interface FunctionHandler {
470
590
  description?: string;
@@ -510,15 +630,273 @@ export interface WorkspaceSave {
510
630
  }
511
631
  /** `idempotent`: the call is safe to send twice, so it is retried like a GET. `idempotencyKey`: the Idempotency-Key every
512
632
  * attempt of this call carries (one is made for anything but GET, HEAD, DELETE and OPTIONS). `executes` is accepted for
513
- * compatibility; it is now the rule for every POST. */
633
+ * compatibility; it is now the rule for every POST. `headers` are sent too (never in place of the key); `content` is sent
634
+ * as the body as it is (give its Content-Type in `headers`); `signal` aborts the call (and a stream's reading). A query
635
+ * value that is an array is sent once per item. */
514
636
  export interface RequestOptions {
515
637
  form?: FormData;
516
- query?: Record<string, string | number | undefined>;
638
+ query?: Record<string, QueryValue>;
517
639
  raw?: boolean;
518
640
  executes?: boolean;
519
641
  idempotent?: boolean;
520
642
  idempotencyKey?: string;
643
+ headers?: Record<string, string>;
644
+ content?: Uint8Array | ArrayBuffer | Blob | string;
645
+ signal?: AbortSignal;
646
+ }
647
+ export type QueryValue = string | number | boolean | undefined | null | (string | number)[];
648
+ /** The Anthropic API's request: its own fields (system, tools, tool_choice, thinking, cache_control, ...) pass through. */
649
+ export interface AnthropicMessageParams {
650
+ model: string;
651
+ max_tokens: number;
652
+ messages: {
653
+ role: "user" | "assistant";
654
+ content: string | Record<string, unknown>[];
655
+ }[];
656
+ system?: string | Record<string, unknown>[];
657
+ tools?: Record<string, unknown>[];
658
+ tool_choice?: Record<string, unknown>;
659
+ thinking?: Record<string, unknown>;
660
+ stop_sequences?: string[];
661
+ metadata?: {
662
+ user_id?: string;
663
+ };
664
+ stream?: boolean;
665
+ [key: string]: unknown;
666
+ }
667
+ export interface AnthropicUsage {
668
+ input_tokens: number;
669
+ output_tokens: number;
670
+ cache_creation_input_tokens?: number | null;
671
+ cache_read_input_tokens?: number | null;
672
+ server_tool_use?: Record<string, number> | null;
673
+ [key: string]: unknown;
674
+ }
675
+ export interface AnthropicMessage {
676
+ id: string;
677
+ type: "message";
678
+ role: "assistant";
679
+ model: string;
680
+ content: {
681
+ type: string;
682
+ text?: string;
683
+ [key: string]: unknown;
684
+ }[];
685
+ stop_reason: string | null;
686
+ stop_sequence: string | null;
687
+ usage: AnthropicUsage;
688
+ [key: string]: unknown;
689
+ }
690
+ /** One event of a streamed message: message_start, content_block_start, content_block_delta, ..., message_stop, ping. */
691
+ export interface AnthropicStreamEvent {
692
+ type: string;
693
+ index?: number;
694
+ delta?: Record<string, any>;
695
+ [key: string]: any;
696
+ }
697
+ export interface AnthropicPage<T> {
698
+ data: T[];
699
+ has_more: boolean;
700
+ first_id: string | null;
701
+ last_id: string | null;
702
+ }
703
+ export interface AnthropicBatch {
704
+ id: string;
705
+ type: "message_batch";
706
+ processing_status: "in_progress" | "canceling" | "ended";
707
+ request_counts: {
708
+ processing: number;
709
+ succeeded: number;
710
+ errored: number;
711
+ canceled: number;
712
+ expired: number;
713
+ };
714
+ created_at: string;
715
+ ended_at: string | null;
716
+ expires_at: string;
717
+ cancel_initiated_at: string | null;
718
+ results_url: string | null;
719
+ [key: string]: unknown;
720
+ }
721
+ export interface AnthropicBatchResult {
722
+ custom_id: string;
723
+ result: {
724
+ type: "succeeded";
725
+ message: AnthropicMessage;
726
+ } | {
727
+ type: "errored";
728
+ error: Record<string, unknown>;
729
+ } | {
730
+ type: "canceled";
731
+ } | {
732
+ type: "expired";
733
+ };
734
+ }
735
+ export interface AnthropicFile {
736
+ id: string;
737
+ type: "file";
738
+ filename: string;
739
+ mime_type: string;
740
+ size_bytes: number;
741
+ created_at: string;
742
+ downloadable?: boolean;
743
+ }
744
+ export interface AnthropicModel {
745
+ id: string;
746
+ type: "model";
747
+ display_name: string;
748
+ created_at: string;
749
+ [key: string]: unknown;
750
+ }
751
+ /** OpenRouter's request, unchanged: its model ids ("anthropic/claude-haiku-5.5") and fields (models, provider, reasoning, plugins). */
752
+ export interface OpenRouterChatParams {
753
+ model: string;
754
+ messages: Record<string, unknown>[];
755
+ stream?: boolean;
756
+ [key: string]: unknown;
757
+ }
758
+ /** /key, answered by Dyadic: this key's usage and limits in dollars. */
759
+ export interface OpenRouterKeyInfo {
760
+ data: {
761
+ label: string;
762
+ usage: number;
763
+ limit: number | null;
764
+ limit_remaining: number | null;
765
+ limit_reset: "daily" | "weekly" | "monthly" | null;
766
+ is_free_tier: false;
767
+ is_provisioning_key: false;
768
+ rate_limit: {
769
+ requests: number;
770
+ interval: "1m";
771
+ };
772
+ };
773
+ }
774
+ /** /credits, answered by Dyadic: the account's allowance this week (null when unlimited) and what's used, in dollars. */
775
+ export interface OpenRouterCredits {
776
+ data: {
777
+ total_credits: number | null;
778
+ total_usage: number;
779
+ };
780
+ }
781
+ export interface Deleted {
782
+ id: string;
783
+ object: string;
784
+ deleted: boolean;
785
+ }
786
+ /** Completions created with store: true, kept 30 days. */
787
+ export interface StoredChatCompletion extends ChatCompletion {
788
+ metadata?: Record<string, string> | null;
789
+ request_id?: string;
790
+ [key: string]: unknown;
791
+ }
792
+ export interface Conversation {
793
+ id: string;
794
+ object: "conversation";
795
+ created_at: number;
796
+ metadata: Record<string, string> | null;
797
+ }
798
+ export interface ConversationItem {
799
+ id?: string;
800
+ type: string;
801
+ [key: string]: unknown;
802
+ }
803
+ export interface Container {
804
+ id: string;
805
+ object: "container";
806
+ name: string;
807
+ status: string;
808
+ created_at: number;
809
+ last_active_at: number;
810
+ expires_after: {
811
+ anchor: "last_active_at";
812
+ minutes: number;
813
+ };
814
+ memory_limit?: string | null;
815
+ }
816
+ export interface ContainerFile {
817
+ id: string;
818
+ object: "container.file";
819
+ container_id: string;
820
+ path: string;
821
+ bytes: number;
822
+ created_at: number;
823
+ source: string;
824
+ }
825
+ export interface VectorStore {
826
+ id: string;
827
+ object: "vector_store";
828
+ name: string;
829
+ status: "expired" | "in_progress" | "completed";
830
+ created_at: number;
831
+ usage_bytes: number;
832
+ file_counts: {
833
+ in_progress: number;
834
+ completed: number;
835
+ failed: number;
836
+ cancelled: number;
837
+ total: number;
838
+ };
839
+ expires_after: {
840
+ anchor: "last_active_at";
841
+ days: number;
842
+ } | null;
843
+ expires_at: number | null;
844
+ last_active_at: number;
845
+ metadata: Record<string, string>;
521
846
  }
847
+ export interface VectorStoreFile {
848
+ id: string;
849
+ object: "vector_store.file";
850
+ vector_store_id: string;
851
+ status: "in_progress" | "completed" | "failed" | "cancelled";
852
+ usage_bytes: number;
853
+ created_at: number;
854
+ last_error: {
855
+ code: string;
856
+ message: string;
857
+ } | null;
858
+ attributes: Record<string, string | number | boolean>;
859
+ chunking_strategy: Record<string, unknown>;
860
+ filename?: string;
861
+ }
862
+ export interface VectorStoreSearchPage {
863
+ object: "vector_store.search_results.page";
864
+ search_query: string;
865
+ has_more: boolean;
866
+ next_page: string | null;
867
+ data: {
868
+ file_id: string;
869
+ filename: string;
870
+ score: number;
871
+ attributes?: Record<string, unknown>;
872
+ content: {
873
+ type: "text";
874
+ text: string;
875
+ }[];
876
+ }[];
877
+ }
878
+ export interface Skill {
879
+ id: string;
880
+ object: "skill";
881
+ name: string;
882
+ description: string;
883
+ created_at: number;
884
+ default_version: string;
885
+ latest_version: string;
886
+ }
887
+ export interface SkillVersion {
888
+ id: string;
889
+ object: "skill.version";
890
+ skill_id: string;
891
+ version: string;
892
+ name: string;
893
+ description: string;
894
+ created_at: number;
895
+ bytes: number;
896
+ files: string[];
897
+ }
898
+ /** A file in a skill: its path in the skill as the name (or one zip). */
899
+ export type SkillFile = Uploadable;
522
900
  /** Bytes from the API (speech audio, file downloads). */
523
901
  export declare class Binary {
524
902
  readonly data: ArrayBuffer;
@@ -555,13 +933,25 @@ export declare class DyadicError extends Error {
555
933
  body?: unknown;
556
934
  });
557
935
  }
936
+ /** A Black Box run this key made was deleted by the account's owner or the application (HTTP 410, code run_deleted).
937
+ * `deletion` is the signed record of the deletion when the service sends one. */
938
+ export declare class RunDeletedError extends DyadicError {
939
+ constructor(message: string, init?: ConstructorParameters<typeof DyadicError>[1]);
940
+ get deletion(): Record<string, unknown> | null;
941
+ }
942
+ /** One server-sent event of a Black Box live stream. */
943
+ export interface BlackBoxStreamEvent<T = any> {
944
+ event: string;
945
+ id: string | null;
946
+ data: T;
947
+ }
558
948
  /** A streamed completion: `for await (const chunk of stream)`. `text` and `usage` fill in as it goes. */
559
- export declare class Stream<T> implements AsyncIterable<T> {
949
+ export declare class Stream<T, U = Usage> implements AsyncIterable<T> {
560
950
  private http;
561
951
  readonly controller: AbortController;
562
952
  private onDone;
563
953
  text: string;
564
- usage: Usage | undefined;
954
+ usage: U | undefined;
565
955
  /** Responses streams: the final Response once response.completed arrives. */
566
956
  response: ResponseObject | undefined;
567
957
  /** Run streams: the completed run once run.completed arrives. */
@@ -573,6 +963,10 @@ export declare class Stream<T> implements AsyncIterable<T> {
573
963
  finalText(): Promise<string>;
574
964
  abort(): void;
575
965
  }
966
+ /** Start (or join, given a 32-hex trace id) the trace the following requests carry; returns its id. */
967
+ export declare function useTrace(traceId?: string): string;
968
+ /** The current trace's traceparent header (a new span each call), or {} when none was started. */
969
+ export declare function currentTraceparent(): Record<string, string>;
576
970
  export declare class Dyadic {
577
971
  readonly apiKey: string;
578
972
  readonly baseURL: string;
@@ -587,15 +981,28 @@ export declare class Dyadic {
587
981
  * origin. The key goes with every request, so it must never reach another host, a plain-http downgrade, or a URL with
588
982
  * credentials in it. */
589
983
  private url;
590
- /** Low-level request: JSON (or multipart `options.form`) in; JSON, text, Binary (`options.raw`) or a Stream out. `path` is
591
- * relative to the base URL; an absolute URL must be on its origin. GET, HEAD, DELETE and OPTIONS are retried on busy or
592
- * failing servers; anything else only if it provably never started, unless `options.idempotent`. */
984
+ /** Low-level request: JSON (or multipart `options.form`, or raw `options.content`) in; JSON, text, Binary (`options.raw`)
985
+ * or a Stream out. `path` is relative to the base URL; an absolute URL must be on its origin. GET, HEAD, DELETE and OPTIONS
986
+ * are retried on busy or failing servers; anything else only if it provably never started, unless `options.idempotent`. */
593
987
  request<T>(method: string, path: string, body?: unknown, stream?: boolean, options?: RequestOptions): Promise<T>;
988
+ /** The successful response to a call, after its retries; any other answer throws. A stream's timeout and abort link
989
+ * stay until `release`. */
990
+ private open;
991
+ /** A Black Box live stream: server-sent events as `{ event, id, data }`, connecting again when the service asks
992
+ * (`reconnect`) or the connection drops (resuming after the last event when `after` is given), until a `terminal` event,
993
+ * the signal aborts, or the consumer stops iterating. */
994
+ private live;
594
995
  /** Dyadic's own endpoints sit beside the OpenAI-compatible base: .../api/openai/v1 -> .../api/v1. */
595
996
  platformURL(path: string): string;
997
+ /** So do its other compatible APIs: .../api/openai/v1 -> .../api/anthropic/v1 or .../api/openrouter/v1. */
998
+ private apiURL;
999
+ private anthropicCall;
1000
+ /** A run's body as the API names its fields (planMode and planId as plan_mode and plan_id). */
1001
+ private runBody;
596
1002
  /** An agent answers a conversation: one of the account's agents by id ("iris") or your own agent inline,
597
1003
  * with Dyadic's built-in tools and your own functions. A run that calls your functions ends with status
598
- * "requires_action": run `function_calls`, append `messages` and your results, and run again (or use `run`). */
1004
+ * "requires_action": run `function_calls`, append `messages` and your results, and run again (or use `run`).
1005
+ * With the key's plans switch, `planMode` proposes a plan and `planId` carries out an approved one. */
599
1006
  readonly runs: {
600
1007
  create: {
601
1008
  (params: RunParams & {
@@ -630,6 +1037,27 @@ export declare class Dyadic {
630
1037
  }): Promise<ChatCompletion>;
631
1038
  (params: ChatCompletionParams): Promise<ChatCompletion | Stream<ChatCompletionChunk>>;
632
1039
  };
1040
+ /** Completions created with store: true (kept 30 days), newest first; `metadata` matches key/values. */
1041
+ list: (query?: {
1042
+ model?: string;
1043
+ metadata?: Record<string, string>;
1044
+ after?: string;
1045
+ limit?: number;
1046
+ order?: "asc" | "desc";
1047
+ }) => Promise<Page<StoredChatCompletion>>;
1048
+ retrieve: (id: string) => Promise<StoredChatCompletion>;
1049
+ /** Replace a stored completion's metadata. */
1050
+ update: (id: string, params: {
1051
+ metadata: Record<string, string> | null;
1052
+ }) => Promise<StoredChatCompletion>;
1053
+ delete: (id: string) => Promise<Deleted>;
1054
+ messages: {
1055
+ list: (id: string, query?: {
1056
+ after?: string;
1057
+ limit?: number;
1058
+ order?: "asc" | "desc";
1059
+ }) => Promise<Page<Record<string, unknown>>>;
1060
+ };
633
1061
  };
634
1062
  };
635
1063
  readonly completions: {
@@ -663,6 +1091,60 @@ export declare class Dyadic {
663
1091
  order?: "asc" | "desc";
664
1092
  }) => Promise<Page<Record<string, unknown>>>;
665
1093
  cancel: (id: string) => Promise<ResponseObject>;
1094
+ /** How many input tokens a Responses request would use: an estimate, free (no model runs). */
1095
+ inputTokens: {
1096
+ count: (params: Omit<ResponseParams, "stream" | "store" | "background">) => Promise<{
1097
+ object: "response.input_tokens";
1098
+ input_tokens: number;
1099
+ }>;
1100
+ };
1101
+ /** Your user messages and one compaction item summarising everything else; send its output as the next request's input. */
1102
+ compact: (params: {
1103
+ model: Model;
1104
+ input?: string | Record<string, unknown>[];
1105
+ instructions?: string;
1106
+ previous_response_id?: string;
1107
+ }) => Promise<{
1108
+ [key: string]: unknown;
1109
+ id: string;
1110
+ object: "response.compaction";
1111
+ output: Record<string, unknown>[];
1112
+ usage?: Record<string, unknown>;
1113
+ }>;
1114
+ };
1115
+ /** Conversations for the Responses API: pass `conversation` to responses.create and each response's input and output
1116
+ * are added to it. */
1117
+ readonly conversations: {
1118
+ create: (params?: {
1119
+ items?: Record<string, unknown>[];
1120
+ metadata?: Record<string, string>;
1121
+ }) => Promise<Conversation>;
1122
+ retrieve: (id: string) => Promise<Conversation>;
1123
+ update: (id: string, params: {
1124
+ metadata: Record<string, string> | null;
1125
+ }) => Promise<Conversation>;
1126
+ /** Deletes the conversation and its items. */
1127
+ delete: (id: string) => Promise<Deleted>;
1128
+ items: {
1129
+ create: (conversationId: string, params: {
1130
+ items: Record<string, unknown>[];
1131
+ include?: string[];
1132
+ }) => Promise<Page<ConversationItem>>;
1133
+ list: (conversationId: string, query?: {
1134
+ after?: string;
1135
+ limit?: number;
1136
+ order?: "asc" | "desc";
1137
+ include?: string[];
1138
+ }) => Promise<Page<ConversationItem>>;
1139
+ retrieve: (itemId: string, params: {
1140
+ conversation_id: string;
1141
+ include?: string[];
1142
+ }) => Promise<ConversationItem>;
1143
+ /** Removes the item; answers with the conversation. */
1144
+ delete: (itemId: string, params: {
1145
+ conversation_id: string;
1146
+ }) => Promise<Conversation>;
1147
+ };
666
1148
  };
667
1149
  readonly embeddings: {
668
1150
  create: (params: EmbeddingParams) => Promise<EmbeddingList>;
@@ -737,6 +1219,311 @@ export declare class Dyadic {
737
1219
  retrieve: (id: string) => Promise<Batch>;
738
1220
  cancel: (id: string) => Promise<Batch>;
739
1221
  };
1222
+ /** Containers (cntr_...) for the code interpreter and shell tools; needs the key's code interpreter switch. */
1223
+ readonly containers: {
1224
+ create: (params?: {
1225
+ name?: string;
1226
+ expires_after?: {
1227
+ anchor: "last_active_at";
1228
+ minutes: number;
1229
+ };
1230
+ memory_limit?: string;
1231
+ file_ids?: string[];
1232
+ skills?: Record<string, unknown>[];
1233
+ }) => Promise<Container>;
1234
+ list: (query?: {
1235
+ after?: string;
1236
+ limit?: number;
1237
+ order?: "asc" | "desc";
1238
+ }) => Promise<Page<Container>>;
1239
+ retrieve: (id: string) => Promise<Container>;
1240
+ delete: (id: string) => Promise<Deleted>;
1241
+ files: {
1242
+ /** Put a file in the container (at /mnt/data/<name>): upload `file`, or copy an uploaded `file_id`. */
1243
+ create: (containerId: string, params: {
1244
+ file?: Uploadable;
1245
+ file_id?: string;
1246
+ }) => Promise<ContainerFile>;
1247
+ list: (containerId: string, query?: {
1248
+ after?: string;
1249
+ limit?: number;
1250
+ order?: "asc" | "desc";
1251
+ }) => Promise<Page<ContainerFile>>;
1252
+ retrieve: (fileId: string, params: {
1253
+ container_id: string;
1254
+ }) => Promise<ContainerFile>;
1255
+ delete: (fileId: string, params: {
1256
+ container_id: string;
1257
+ }) => Promise<Deleted>;
1258
+ content: {
1259
+ retrieve: (fileId: string, params: {
1260
+ container_id: string;
1261
+ }) => Promise<Binary>;
1262
+ };
1263
+ };
1264
+ };
1265
+ /** Vector stores (vs_...) for the file search tool, and searching them directly; needs the key's file search switch.
1266
+ * Indexing and search cost no credits. */
1267
+ readonly vectorStores: {
1268
+ create: (params?: {
1269
+ name?: string;
1270
+ file_ids?: string[];
1271
+ chunking_strategy?: Record<string, unknown>;
1272
+ metadata?: Record<string, string>;
1273
+ expires_after?: {
1274
+ anchor: "last_active_at";
1275
+ days: number;
1276
+ };
1277
+ }) => Promise<VectorStore>;
1278
+ list: (query?: {
1279
+ after?: string;
1280
+ limit?: number;
1281
+ order?: "asc" | "desc";
1282
+ }) => Promise<Page<VectorStore>>;
1283
+ retrieve: (id: string) => Promise<VectorStore>;
1284
+ update: (id: string, params: {
1285
+ name?: string;
1286
+ metadata?: Record<string, string> | null;
1287
+ expires_after?: {
1288
+ anchor: "last_active_at";
1289
+ days: number;
1290
+ } | null;
1291
+ }) => Promise<VectorStore>;
1292
+ delete: (id: string) => Promise<Deleted>;
1293
+ search: (id: string, params: {
1294
+ query: string | string[];
1295
+ max_num_results?: number;
1296
+ filters?: Record<string, unknown>;
1297
+ ranking_options?: Record<string, unknown>;
1298
+ rewrite_query?: boolean;
1299
+ }) => Promise<VectorStoreSearchPage>;
1300
+ files: {
1301
+ /** Add an uploaded file; it is read and indexed in the background. */
1302
+ create: (vectorStoreId: string, params: {
1303
+ file_id: string;
1304
+ attributes?: Record<string, string | number | boolean>;
1305
+ chunking_strategy?: Record<string, unknown>;
1306
+ }) => Promise<VectorStoreFile>;
1307
+ list: (vectorStoreId: string, query?: {
1308
+ after?: string;
1309
+ limit?: number;
1310
+ order?: "asc" | "desc";
1311
+ filter?: "in_progress" | "completed" | "failed" | "cancelled";
1312
+ }) => Promise<Page<VectorStoreFile>>;
1313
+ retrieve: (fileId: string, params: {
1314
+ vector_store_id: string;
1315
+ }) => Promise<VectorStoreFile>;
1316
+ update: (fileId: string, params: {
1317
+ vector_store_id: string;
1318
+ attributes: Record<string, string | number | boolean> | null;
1319
+ }) => Promise<VectorStoreFile>;
1320
+ delete: (fileId: string, params: {
1321
+ vector_store_id: string;
1322
+ }) => Promise<Deleted>;
1323
+ /** The file's parsed text, as indexed. */
1324
+ content: (fileId: string, params: {
1325
+ vector_store_id: string;
1326
+ }) => Promise<{
1327
+ [key: string]: unknown;
1328
+ object: string;
1329
+ data: {
1330
+ type: "text";
1331
+ text: string;
1332
+ }[];
1333
+ }>;
1334
+ };
1335
+ fileBatches: {
1336
+ create: (vectorStoreId: string, params: {
1337
+ file_ids?: string[];
1338
+ files?: Record<string, unknown>[];
1339
+ attributes?: Record<string, unknown>;
1340
+ chunking_strategy?: Record<string, unknown>;
1341
+ }) => Promise<Record<string, unknown>>;
1342
+ retrieve: (batchId: string, params: {
1343
+ vector_store_id: string;
1344
+ }) => Promise<Record<string, unknown>>;
1345
+ cancel: (batchId: string, params: {
1346
+ vector_store_id: string;
1347
+ }) => Promise<Record<string, unknown>>;
1348
+ listFiles: (batchId: string, params: {
1349
+ vector_store_id: string;
1350
+ after?: string;
1351
+ limit?: number;
1352
+ order?: "asc" | "desc";
1353
+ filter?: string;
1354
+ }) => Promise<Page<VectorStoreFile>>;
1355
+ };
1356
+ };
1357
+ /** Skills (skill_...): a SKILL.md and its files, mounted into containers; needs the key's skills switch. Upload the files
1358
+ * with their paths in the skill as names ({ name: "scripts/run.py", data }), or one zip. */
1359
+ readonly skills: {
1360
+ create: (params: {
1361
+ files: SkillFile | SkillFile[];
1362
+ }) => Promise<Skill>;
1363
+ list: (query?: {
1364
+ after?: string;
1365
+ limit?: number;
1366
+ order?: "asc" | "desc";
1367
+ }) => Promise<Page<Skill>>;
1368
+ retrieve: (id: string) => Promise<Skill>;
1369
+ /** Choose the default version. */
1370
+ update: (id: string, params: {
1371
+ default_version: string | number;
1372
+ }) => Promise<Skill>;
1373
+ delete: (id: string) => Promise<Deleted>;
1374
+ /** The default version's files as a zip. */
1375
+ content: {
1376
+ retrieve: (id: string) => Promise<Binary>;
1377
+ };
1378
+ versions: {
1379
+ create: (skillId: string, params: {
1380
+ files: SkillFile | SkillFile[];
1381
+ default?: boolean;
1382
+ }) => Promise<SkillVersion>;
1383
+ list: (skillId: string, query?: {
1384
+ after?: string;
1385
+ limit?: number;
1386
+ order?: "asc" | "desc";
1387
+ }) => Promise<Page<SkillVersion>>;
1388
+ retrieve: (version: string | number, params: {
1389
+ skill_id: string;
1390
+ }) => Promise<SkillVersion>;
1391
+ delete: (version: string | number, params: {
1392
+ skill_id: string;
1393
+ }) => Promise<Deleted>;
1394
+ content: {
1395
+ retrieve: (version: string | number, params: {
1396
+ skill_id: string;
1397
+ }) => Promise<Binary>;
1398
+ };
1399
+ };
1400
+ };
1401
+ /** The Anthropic API through Dyadic (/api/anthropic/v1, with this client's key): Claude's own request and answer shapes,
1402
+ * behaving as Anthropic's do, with Dyadic's billing, limits, activity log and Black Box. Anthropic's own SDKs work there
1403
+ * too (baseURL https://dyadic.app/api/anthropic). */
1404
+ readonly anthropic: {
1405
+ messages: {
1406
+ /** A message, or with `stream: true` Anthropic's events; the stream's `text` and `usage` fill in as they come. */
1407
+ create: {
1408
+ (params: AnthropicMessageParams & {
1409
+ stream: true;
1410
+ }): Promise<Stream<AnthropicStreamEvent, AnthropicUsage>>;
1411
+ (params: AnthropicMessageParams & {
1412
+ stream?: false;
1413
+ }): Promise<AnthropicMessage>;
1414
+ };
1415
+ /** A request's input tokens (free; no model runs). */
1416
+ countTokens: (params: Omit<AnthropicMessageParams, "max_tokens" | "stream">) => Promise<{
1417
+ input_tokens: number;
1418
+ }>;
1419
+ /** Up to 100,000 requests at half price; poll `retrieve` until processing_status is "ended", then read `results`. */
1420
+ batches: {
1421
+ create: (params: {
1422
+ requests: {
1423
+ custom_id: string;
1424
+ params: AnthropicMessageParams;
1425
+ }[];
1426
+ }) => Promise<AnthropicBatch>;
1427
+ list: (query?: {
1428
+ limit?: number;
1429
+ before_id?: string;
1430
+ after_id?: string;
1431
+ }) => Promise<AnthropicPage<AnthropicBatch>>;
1432
+ retrieve: (id: string) => Promise<AnthropicBatch>;
1433
+ cancel: (id: string) => Promise<AnthropicBatch>;
1434
+ /** Each request's result once the batch has ended, in order. */
1435
+ results: (id: string) => Promise<AnthropicBatchResult[]>;
1436
+ delete: (id: string) => Promise<{
1437
+ id: string;
1438
+ type: "message_batch_deleted";
1439
+ }>;
1440
+ };
1441
+ };
1442
+ /** The Claude models this key may call. */
1443
+ models: {
1444
+ list: (query?: {
1445
+ limit?: number;
1446
+ before_id?: string;
1447
+ after_id?: string;
1448
+ }) => Promise<AnthropicPage<AnthropicModel>>;
1449
+ retrieve: (id: string) => Promise<AnthropicModel>;
1450
+ };
1451
+ /** Files to reference from a message ({ type: "document", source: { type: "file", file_id } }). */
1452
+ files: {
1453
+ create: (params: {
1454
+ file: Uploadable;
1455
+ }) => Promise<AnthropicFile>;
1456
+ list: (query?: {
1457
+ limit?: number;
1458
+ before_id?: string;
1459
+ after_id?: string;
1460
+ }) => Promise<AnthropicPage<AnthropicFile>>;
1461
+ retrieve: (id: string) => Promise<AnthropicFile>;
1462
+ content: (id: string) => Promise<Binary>;
1463
+ delete: (id: string) => Promise<{
1464
+ id: string;
1465
+ type: "file_deleted";
1466
+ }>;
1467
+ };
1468
+ };
1469
+ /** OpenRouter's API through Dyadic's gateway (/api/openrouter/v1, with this client's key). It needs the key's AI gateway,
1470
+ * which Dyadic turns on for an app on request (the key's owner can turn it off; a key without it is answered 403
1471
+ * gateway_not_allowed). Every call counts against the key's limits and is billed and logged by Dyadic. */
1472
+ readonly openrouter: {
1473
+ chat: {
1474
+ completions: {
1475
+ create: {
1476
+ (params: OpenRouterChatParams & {
1477
+ stream: true;
1478
+ }): Promise<Stream<ChatCompletionChunk>>;
1479
+ (params: OpenRouterChatParams & {
1480
+ stream?: false;
1481
+ }): Promise<ChatCompletion & Record<string, unknown>>;
1482
+ };
1483
+ };
1484
+ };
1485
+ completions: {
1486
+ create: {
1487
+ (params: {
1488
+ model: string;
1489
+ prompt: string;
1490
+ stream: true;
1491
+ [key: string]: unknown;
1492
+ }): Promise<Stream<TextCompletion>>;
1493
+ (params: {
1494
+ model: string;
1495
+ prompt: string;
1496
+ stream?: false;
1497
+ [key: string]: unknown;
1498
+ }): Promise<TextCompletion>;
1499
+ };
1500
+ };
1501
+ /** Embeddings (the key's Embeddings switch). */
1502
+ embeddings: {
1503
+ create: (params: {
1504
+ model: string;
1505
+ input: string | string[];
1506
+ [key: string]: unknown;
1507
+ }) => Promise<EmbeddingList>;
1508
+ };
1509
+ models: {
1510
+ list: (query?: Record<string, QueryValue>) => Promise<{
1511
+ data: Record<string, unknown>[];
1512
+ }>;
1513
+ /** A model's providers and their prices. */
1514
+ endpoints: (author: string, slug: string) => Promise<{
1515
+ data: Record<string, unknown>;
1516
+ }>;
1517
+ };
1518
+ /** A generation's cost and tokens (this key's own requests only). */
1519
+ generation: (id: string) => Promise<{
1520
+ data: Record<string, unknown>;
1521
+ }>;
1522
+ /** This Dyadic key's usage and limits, as OpenRouter's /key answers (answered by Dyadic). */
1523
+ key: () => Promise<OpenRouterKeyInfo>;
1524
+ /** The account's allowance and use this week, in dollars (answered by Dyadic). */
1525
+ credits: () => Promise<OpenRouterCredits>;
1526
+ };
740
1527
  /** Connected apps. Show the person `authorize_url` when `authorized` is false. */
741
1528
  readonly connections: {
742
1529
  discord: (discordId: string | number) => Promise<Connection>;
@@ -749,12 +1536,309 @@ export declare class Dyadic {
749
1536
  create: ({ discord_id, ...fields }: WorkspaceSaveParams) => Promise<WorkspaceSave>;
750
1537
  };
751
1538
  };
1539
+ /** Agent Black Box: send what your agent does (or record it with BlackBoxRecorder), read the runs this key made (also
1540
+ * live), export and verify evidence, simulate (nothing ever runs: not the chat's Replay from here, which asks again for
1541
+ * real), triage findings, route records to webhooks and collectors. A run of the key's that was deleted throws
1542
+ * RunDeletedError (HTTP 410). */
1543
+ readonly blackbox: {
1544
+ send: (batch: Record<string, unknown>, options?: {
1545
+ idempotencyKey?: string;
1546
+ }) => Promise<BlackBoxBatchResult>;
1547
+ /** OTLP/HTTP traces: an object is sent as OTLP/JSON, bytes as OTLP protobuf (application/x-protobuf; the answer is then
1548
+ * the protobuf ExportTraceServiceResponse, as Binary). */
1549
+ sendOtlp: (request: Record<string, unknown> | Uint8Array | ArrayBuffer) => Promise<Record<string, unknown>> | Promise<Binary>;
1550
+ /** Counts for this key's runs: by status and outcome, open findings, recording gaps. */
1551
+ overview: () => Promise<Record<string, unknown>>;
1552
+ /** What the account keeps (recording, capture by kind) and for how long. */
1553
+ settings: () => Promise<Record<string, unknown>>;
1554
+ runs: {
1555
+ list: (query?: Record<string, string | number | undefined>) => Promise<{
1556
+ runs: BlackBoxRunSummary[];
1557
+ next: string | null;
1558
+ }>;
1559
+ retrieve: (id: string) => Promise<BlackBoxRunSummary>;
1560
+ /** The run's events in chain order; `types` keeps only those types (up to 20). */
1561
+ events: (id: string, query?: {
1562
+ after?: number;
1563
+ limit?: number;
1564
+ types?: string[] | string;
1565
+ }) => Promise<{
1566
+ run_id: string;
1567
+ events: Record<string, unknown>[];
1568
+ has_more: boolean;
1569
+ }>;
1570
+ graph: (id: string) => Promise<Record<string, unknown>>;
1571
+ verify: (id: string) => Promise<VerifyReport>;
1572
+ /** The run's signed checkpoints and the anchor (an RFC 3161 timestamp over a Merkle root) that fixes them in time. */
1573
+ checkpoints: (id: string) => Promise<{
1574
+ run_id: string;
1575
+ tenant: string;
1576
+ checkpoints: Record<string, unknown>[];
1577
+ anchors: Record<string, unknown>[];
1578
+ }>;
1579
+ /** The run's kept content, opened (all of it, or `refs`); needs the key's content permission and is logged. */
1580
+ content: (id: string, options?: {
1581
+ refs?: string[];
1582
+ }) => Promise<{
1583
+ run_id: string;
1584
+ content: {
1585
+ ref: string;
1586
+ kind: string;
1587
+ value: unknown;
1588
+ }[];
1589
+ erased: boolean;
1590
+ }>;
1591
+ export: (id: string, options?: {
1592
+ format?: "json" | "zip";
1593
+ content?: boolean;
1594
+ }) => Promise<Record<string, unknown> | Binary>;
1595
+ otlp: (id: string, options?: {
1596
+ content?: boolean;
1597
+ }) => Promise<Record<string, unknown>>;
1598
+ simulate: (id: string, params: {
1599
+ mode: "reconstruct" | "simulate" | "counterfactual";
1600
+ [key: string]: unknown;
1601
+ }) => Promise<Record<string, unknown>>;
1602
+ /** Erase the run's content, keeping a signed erasure record (the key's manage permission; a running run answers 409). */
1603
+ erase: (id: string, options?: {
1604
+ reason?: string;
1605
+ }) => Promise<Record<string, unknown>>;
1606
+ /** Delete the run, leaving a signed deletion record (the key's manage permission); later reads throw RunDeletedError. */
1607
+ delete: (id: string, options?: {
1608
+ reason?: string;
1609
+ }) => Promise<Record<string, unknown>>;
1610
+ /** The run's events live (server-sent events): `event` events (`id` the sequence number, `data` the envelope) from `after`
1611
+ * on, then `end` ({ status, outcome, events }) or `deleted`, after which it stops. It connects again by itself when asked
1612
+ * to or when the connection drops, resuming after the last event; `signal` (or leaving the loop) ends it. */
1613
+ stream: (id: string, options?: {
1614
+ after?: number;
1615
+ signal?: AbortSignal;
1616
+ maxReconnects?: number;
1617
+ }) => AsyncGenerator<BlackBoxStreamEvent<any>, void, undefined>;
1618
+ };
1619
+ bookmarks: {
1620
+ list: (runId: string) => Promise<{
1621
+ bookmarks: Record<string, unknown>[];
1622
+ }>;
1623
+ /** Mark event `seq` of a run with a note (the key's write permission). */
1624
+ create: (runId: string, params: {
1625
+ seq: number;
1626
+ note?: string;
1627
+ }) => Promise<Record<string, unknown>>;
1628
+ delete: (bookmarkId: string | number) => Promise<{
1629
+ deleted: boolean;
1630
+ }>;
1631
+ };
1632
+ /** What the detection rules noticed in this key's runs (hypotheses with evidence). Call it, or use `list`; `update` triages. */
1633
+ findings: ((query?: BlackBoxFindingsQuery) => Promise<{
1634
+ findings: Record<string, unknown>[];
1635
+ }>) & {
1636
+ list: (query?: BlackBoxFindingsQuery) => Promise<{
1637
+ findings: Record<string, unknown>[];
1638
+ }>;
1639
+ update: (id: string | number, params: {
1640
+ status: "open" | "dismissed" | "confirmed";
1641
+ note?: string;
1642
+ }) => Promise<{
1643
+ id: number;
1644
+ status: string;
1645
+ triaged_by: string;
1646
+ }>;
1647
+ };
1648
+ rules: {
1649
+ /** The detection rules and the account's configuration of them. */
1650
+ list: () => Promise<{
1651
+ rules: Record<string, unknown>[];
1652
+ configured: Record<string, unknown>;
1653
+ }>;
1654
+ /** What detection would raise with these settings over this key's recent runs; nothing is saved. */
1655
+ preview: (params: {
1656
+ rules: Record<string, unknown>;
1657
+ runs?: number;
1658
+ days?: number;
1659
+ }) => Promise<Record<string, unknown>>;
1660
+ };
1661
+ /** Where this key's records go as they happen: webhooks (signed; check them with verifyWebhook) and OpenTelemetry
1662
+ * collectors. Needs the key's manage permission; a key sees only its own sinks and runs. */
1663
+ sinks: {
1664
+ list: () => Promise<{
1665
+ sinks: BlackBoxSink[];
1666
+ events: string[];
1667
+ protocols: string[];
1668
+ }>;
1669
+ /** A webhook's `secret` (whsec_...) is in this answer only. */
1670
+ create: (params: BlackBoxSinkParams & {
1671
+ kind: "webhook" | "otlp";
1672
+ url: string;
1673
+ }) => Promise<BlackBoxSink>;
1674
+ retrieve: (id: string) => Promise<BlackBoxSink>;
1675
+ update: (id: string, params: BlackBoxSinkParams) => Promise<BlackBoxSink>;
1676
+ delete: (id: string) => Promise<{
1677
+ deleted: boolean;
1678
+ }>;
1679
+ /** Queue a test message (a ping). */
1680
+ test: (id: string) => Promise<Record<string, unknown>>;
1681
+ /** A webhook's new secret (in this answer only); the old one stops working. */
1682
+ rotate: (id: string) => Promise<BlackBoxSink>;
1683
+ deliveries: (id: string, query?: {
1684
+ limit?: number;
1685
+ }) => Promise<{
1686
+ deliveries: Record<string, unknown>[];
1687
+ }>;
1688
+ /** Send a delivery again. */
1689
+ retryDelivery: (deliveryId: string | number) => Promise<{
1690
+ queued: boolean;
1691
+ }>;
1692
+ };
1693
+ diff: (a: string, b: string) => Promise<Record<string, unknown>>;
1694
+ keys: () => Promise<{
1695
+ keys: {
1696
+ key_id: string;
1697
+ alg: string;
1698
+ public_key: string;
1699
+ }[];
1700
+ }>;
1701
+ verify: (bundle: Record<string, unknown>) => Promise<VerifyReport>;
1702
+ /** This key's runs live (server-sent events): `ready` on each connection, then a `run` event (`data`: the run's summary)
1703
+ * whenever one starts, changes status or grows. It connects again by itself and never ends on its own: leave the loop
1704
+ * or abort `signal`. */
1705
+ watch: (options?: {
1706
+ signal?: AbortSignal;
1707
+ maxReconnects?: number;
1708
+ }) => AsyncGenerator<BlackBoxStreamEvent<any>, void, undefined>;
1709
+ };
1710
+ /** Plans (the key's plans switch): a piece of work as Steps that waits for approval and is carried out step by step, the
1711
+ * same engine the Workspace's Plans use. A run with `planMode` proposes one; one with `planId` carries out an approved one
1712
+ * (runs.create). Approval and what may run are checked by the service. A key sees only the plans it made. */
1713
+ readonly plans: {
1714
+ /** This key's plans, newest change first (without their history); `after` (a plan id, `last_id`) pages on. */
1715
+ list: (query?: PlanListQuery) => Promise<Page<Plan>>;
1716
+ /** A plan: mode "plan" (the default) waits for approval; "live" is running from the start. */
1717
+ create: (params: PlanCreateParams) => Promise<Plan>;
1718
+ /** The plan, its steps and progress, and its recent history (`events`). */
1719
+ retrieve: (id: string) => Promise<Plan>;
1720
+ /** Revise the plan from `revision`, the one you saw (409 if it moved on since). Steps keeping their key keep their progress;
1721
+ * an approved plan goes back to draft and is approved again before it runs. */
1722
+ update: (id: string, params: PlanUpdateParams) => Promise<Plan>;
1723
+ /** Approve `revision`, the one you reviewed (409 if it was revised since). A run with `planId` then carries it out. */
1724
+ approve: (id: string, params: {
1725
+ revision: number;
1726
+ }) => Promise<Plan>;
1727
+ /** Cancel the plan: no run carries it out after this. */
1728
+ cancel: (id: string) => Promise<Plan>;
1729
+ /** Move a step by hand. A step with sub-steps follows them (move those); one can't be completed before what it depends on.
1730
+ * Returns the plan. */
1731
+ moveStep: (id: string, key: string, params: {
1732
+ status: PlanStepStatus;
1733
+ note?: string;
1734
+ verified_by?: string;
1735
+ }) => Promise<Plan>;
1736
+ /** The plan's changes after event `after`, oldest first. */
1737
+ events: (id: string, query?: {
1738
+ after?: number;
1739
+ limit?: number;
1740
+ }) => Promise<{
1741
+ object: "list";
1742
+ data: PlanEvent[];
1743
+ has_more: boolean;
1744
+ last_id: number | null;
1745
+ }>;
1746
+ /** The plan live (server-sent events): `plan.snapshot` (the plan as it is) on each connection, then each change from `after`
1747
+ * on (`id` the event's id, `data` the event with `plan` as it is then), and `end` once the plan is completed, cancelled or
1748
+ * failed, after which it stops. It connects again by itself when asked to or when the connection drops, resuming after the
1749
+ * last event (Last-Event-ID); `signal` (or leaving the loop) ends it. */
1750
+ stream: (id: string, options?: {
1751
+ after?: number;
1752
+ signal?: AbortSignal;
1753
+ maxReconnects?: number;
1754
+ }) => AsyncGenerator<PlanStreamEvent, void, undefined>;
1755
+ };
752
1756
  /** One question, one answer: the reply's text. */
753
1757
  ask(prompt: string, options?: Omit<ChatCompletionParams, "messages" | "model" | "stream"> & {
754
1758
  model?: Model;
755
1759
  system?: string;
756
1760
  }): Promise<string>;
1761
+ private findingsList;
757
1762
  /** The API's OpenAPI description. */
758
1763
  openapi(): Promise<Record<string, unknown>>;
759
1764
  }
760
1765
  export default Dyadic;
1766
+ export interface BlackBoxBatchResult {
1767
+ run_id: string;
1768
+ trace_id: string;
1769
+ accepted: number;
1770
+ duplicates: number;
1771
+ rejected: {
1772
+ index: number;
1773
+ reason: string;
1774
+ }[];
1775
+ head: {
1776
+ seq: number;
1777
+ hash: string;
1778
+ } | null;
1779
+ status: string | null;
1780
+ ended: boolean;
1781
+ }
1782
+ export interface BlackBoxRunSummary {
1783
+ id: string;
1784
+ title: string;
1785
+ agent_id: string;
1786
+ status: string;
1787
+ outcome: string;
1788
+ started_at: string;
1789
+ ended_at: string | null;
1790
+ trace_id: string;
1791
+ events: number;
1792
+ signed_through: number;
1793
+ findings: number;
1794
+ max_severity: string | null;
1795
+ [key: string]: unknown;
1796
+ }
1797
+ /** Findings: status open (the default), dismissed, confirmed or all (the default for a run); severity; a rule (BB-R001...). */
1798
+ export interface BlackBoxFindingsQuery {
1799
+ run_id?: string;
1800
+ status?: "open" | "dismissed" | "confirmed" | "all";
1801
+ severity?: string;
1802
+ rule?: string;
1803
+ limit?: number;
1804
+ }
1805
+ export interface BlackBoxSinkParams {
1806
+ kind?: "webhook" | "otlp";
1807
+ url?: string;
1808
+ name?: string;
1809
+ /** Webhooks: finding.created, run.completed, run.failed, run.cancelled, run.interrupted, run.abandoned, run.requires_action. */
1810
+ events?: string[];
1811
+ min_severity?: "info" | "low" | "medium" | "high" | "critical";
1812
+ environments?: ("production" | "staging" | "development" | "test" | "simulation")[];
1813
+ /** OpenTelemetry sinks: how runs are sent, whether content goes too (needs the content permission), the collector's headers. */
1814
+ protocol?: "http/json" | "http/protobuf";
1815
+ content?: boolean;
1816
+ headers?: Record<string, string>;
1817
+ enabled?: boolean;
1818
+ }
1819
+ export interface BlackBoxSink {
1820
+ id: string;
1821
+ kind: "webhook" | "otlp";
1822
+ name: string;
1823
+ url: string;
1824
+ events: string[];
1825
+ min_severity: string;
1826
+ environments: string[];
1827
+ protocol: string;
1828
+ content: boolean;
1829
+ enabled: boolean;
1830
+ header_names: string[];
1831
+ api_key_id: string | null;
1832
+ created_by: string;
1833
+ failures: number;
1834
+ last_success_at: string | null;
1835
+ last_failure_at: string | null;
1836
+ last_error: string | null;
1837
+ created_at: string | null;
1838
+ updated_at: string | null;
1839
+ /** A new webhook's, or a rotated one's, signing secret: shown once. */
1840
+ secret?: string;
1841
+ }
1842
+ export * from "./blackbox.js";
1843
+ import type { VerifyReport } from "./blackbox.js";
1844
+ export * from "./otel.js";