braintrust 0.0.196 → 0.0.198

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/Makefile CHANGED
@@ -1,9 +1,9 @@
1
1
  .PHONY: prune test-anthropic test-anthropic-@0.39.0 test-anthropic-@0.38.0 test-anthropic-latest test
2
2
 
3
- prune:
4
- pnpm prune
3
+ # ------------------------------------------------------------------------------------------------- #
4
+ # Anthropic testing
5
+ # -------------------------------------------------------------------------------------------------
5
6
 
6
- # A workaround to test with an without optional dependencies. There may be snazzier ways to do this.
7
7
  test-anthropic: test-anthropic-latest test-anthropic-0.39.0 test-anthropic-0.38.0
8
8
 
9
9
  test-anthropic-latest:
@@ -16,16 +16,47 @@ test-anthropic-%:
16
16
  $(call pnpm_install_no_save,@anthropic-ai/sdk@$*)
17
17
  pnpm test:anthropic
18
18
 
19
+ # -------------------------------------------------------------------------------------------------
20
+ # OpenAI testing
21
+ # -------------------------------------------------------------------------------------------------
22
+
23
+ .PHONY: test-openai test-openai-latest test-openai-%
24
+
25
+ test-openai: test-openai-latest test-openai-4.92.1 test-openai-4.91.0 test-openai-4.86.0
26
+ test-openai-latest:
27
+ pnpm prune
28
+ $(call pnpm_install_no_save,openai)
29
+ pnpm test:openai
30
+
31
+ test-openai-%:
32
+ pnpm prune
33
+ $(call pnpm_install_no_save,openai@$*)
34
+ pnpm test:openai
35
+
36
+
37
+ # -------------------------------------------------------------------------------------------------
38
+ # common things
39
+ # -------------------------------------------------------------------------------------------------
40
+
41
+ .PHONY: test-pnpm test test-latest prune installing-optional-deps
42
+
43
+ install-optional-deps:
44
+ npm_config_save=false npm_config_lockfile=false pnpm add "openai" "@anthropic-ai/sdk"
45
+
46
+
19
47
  # Test everything but the wrappers.
20
48
  test-pnpm:
21
49
  pnpm prune
22
50
  pnpm test
23
51
 
24
52
  # Test everything
25
- test: test-anthropic test-pnpm
53
+ test: test-anthropic test-pnpm test-openai
26
54
 
27
55
  # Test the core and the latest versions of wrappers.
28
- test-latest: test-pnpm test-anthropic-latest
56
+ test-latest: test-pnpm test-anthropic-latest test-openai-latest
57
+
58
+ prune:
59
+ pnpm prune
29
60
 
30
61
 
31
62
 
@@ -1,5 +1,5 @@
1
1
  import { TRANSACTION_ID_FIELD, TransactionId, ExperimentEvent, DEFAULT_IS_LEGACY_DATASET, DatasetRecord, ExperimentLogFullArgs, ExperimentLogPartialArgs, LogFeedbackFullArgs, SpanType, IdField, BackgroundLogEvent, SpanComponentsV3, SpanObjectTypeV3 } from '@braintrust/core';
2
- import { GitMetadataSettings, Prompt as Prompt$1, PromptSessionEvent, PromptData, AnyModelParam, OpenAIMessage, Tools, Message, AttachmentReference, AttachmentStatus, BraintrustAttachmentReference, ExternalAttachmentReference, RepoInfo, ModelParams, CallEventSchema, StreamingMode } from '@braintrust/core/typespecs';
2
+ import { GitMetadataSettings, Prompt as Prompt$1, PromptSessionEvent, PromptData, AnyModelParam, OpenAIMessage, Tools, Message, PromptBlockData, AttachmentReference, AttachmentStatus, BraintrustAttachmentReference, ExternalAttachmentReference, RepoInfo, ModelParams, CallEventSchema, StreamingMode } from '@braintrust/core/typespecs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  interface IsoAsyncLocalStorage<T> {
@@ -309,9 +309,9 @@ interface Span extends Exportable {
309
309
  */
310
310
  setAttributes(args: Omit<StartSpanArgs, "event">): void;
311
311
  /**
312
- * Gets the span's `state` value, which is usually the global logging state (this is
313
- * for very advanced purposes only)
312
+ * Start a span with a specific id and parent span ids.
314
313
  */
314
+ startSpanWithParents(spanId: string, spanParents: string[], args?: StartSpanArgs): Span;
315
315
  state(): BraintrustState;
316
316
  kind: "span";
317
317
  }
@@ -335,6 +335,7 @@ declare class NoopSpan implements Span {
335
335
  flush(): Promise<void>;
336
336
  close(args?: EndSpanArgs): number;
337
337
  setAttributes(_args: Omit<StartSpanArgs, "event">): void;
338
+ startSpanWithParents(_spanId: string, _spanParents: string[], _args?: StartSpanArgs): Span;
338
339
  state(): BraintrustState;
339
340
  }
340
341
  declare const NOOP_SPAN: NoopSpan;
@@ -422,8 +423,10 @@ declare class BraintrustState {
422
423
  apiConn(): HTTPConnection;
423
424
  proxyConn(): HTTPConnection;
424
425
  bgLogger(): BackgroundLogger;
426
+ httpLogger(): HTTPBackgroundLogger;
425
427
  setOverrideBgLogger(logger: BackgroundLogger | null): void;
426
428
  loginReplaceApiConn(apiConn: HTTPConnection): void;
429
+ disable(): void;
427
430
  }
428
431
  declare function useTestBackgroundLogger(): TestBackgroundLogger;
429
432
  declare function clearTestBackgroundLogger(): void;
@@ -691,6 +694,10 @@ interface ParentSpanIds {
691
694
  spanId: string;
692
695
  rootSpanId: string;
693
696
  }
697
+ interface MultiParentSpanIds {
698
+ parentSpanIds: string[];
699
+ rootSpanId: string;
700
+ }
694
701
  declare function spanComponentsToObjectId({ components, state, }: {
695
702
  components: SpanComponentsV3;
696
703
  state?: BraintrustState;
@@ -806,6 +813,37 @@ declare class TestBackgroundLogger implements BackgroundLogger {
806
813
  flush(): Promise<void>;
807
814
  drain(): Promise<BackgroundLogEvent[]>;
808
815
  }
816
+ declare class HTTPBackgroundLogger implements BackgroundLogger {
817
+ private apiConn;
818
+ private items;
819
+ private activeFlush;
820
+ private activeFlushResolved;
821
+ private activeFlushError;
822
+ private onFlushError?;
823
+ syncFlush: boolean;
824
+ maxRequestSize: number;
825
+ defaultBatchSize: number;
826
+ numTries: number;
827
+ queueDropExceedingMaxsize: number | undefined;
828
+ queueDropLoggingPeriod: number;
829
+ failedPublishPayloadsDir: string | undefined;
830
+ allPublishPayloadsDir: string | undefined;
831
+ private _disabled;
832
+ private queueDropLoggingState;
833
+ constructor(apiConn: LazyValue<HTTPConnection>, opts?: BackgroundLoggerOpts);
834
+ log(items: LazyValue<BackgroundLogEvent>[]): void;
835
+ flush(): Promise<void>;
836
+ private flushOnce;
837
+ private unwrapLazyValues;
838
+ private submitLogsRequest;
839
+ private registerDroppedItemCount;
840
+ private dumpDroppedEvents;
841
+ private static writePayloadToDir;
842
+ private triggerActiveFlush;
843
+ private logFailedPayloadsDir;
844
+ internalReplaceApiConn(apiConn: HTTPConnection): void;
845
+ disable(): void;
846
+ }
809
847
  type InitOpenOption<IsOpen extends boolean> = {
810
848
  open?: IsOpen;
811
849
  };
@@ -1327,19 +1365,22 @@ declare class SpanImpl implements Span {
1327
1365
  parentObjectType: SpanObjectTypeV3;
1328
1366
  parentObjectId: LazyValue<string>;
1329
1367
  parentComputeObjectMetadataArgs: Record<string, any> | undefined;
1330
- parentSpanIds: ParentSpanIds | undefined;
1368
+ parentSpanIds: ParentSpanIds | MultiParentSpanIds | undefined;
1331
1369
  defaultRootType?: SpanType;
1370
+ spanId?: string;
1332
1371
  } & Omit<StartSpanArgs, "parent">);
1333
1372
  get id(): string;
1334
1373
  get spanId(): string;
1335
1374
  get rootSpanId(): string;
1336
1375
  get spanParents(): string[];
1337
1376
  setAttributes(args: Omit<StartSpanArgs, "event">): void;
1377
+ setSpanParents(parents: string[]): void;
1338
1378
  log(event: ExperimentLogPartialArgs): void;
1339
1379
  private logInternal;
1340
1380
  logFeedback(event: Omit<LogFeedbackFullArgs, "id">): void;
1341
1381
  traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): R;
1342
1382
  startSpan(args?: StartSpanArgs): Span;
1383
+ startSpanWithParents(spanId: string, spanParents: string[], args?: StartSpanArgs): Span;
1343
1384
  end(args?: EndSpanArgs): number;
1344
1385
  export(): Promise<string>;
1345
1386
  permalink(): Promise<string>;
@@ -1494,6 +1535,14 @@ declare class Prompt<HasId extends boolean = true, HasVersion extends boolean =
1494
1535
  strict?: boolean;
1495
1536
  }): CompiledPrompt<Flavor>;
1496
1537
  private runBuild;
1538
+ static renderPrompt({ prompt, buildArgs, options, }: {
1539
+ prompt: PromptBlockData;
1540
+ buildArgs: unknown;
1541
+ options: {
1542
+ strict?: boolean;
1543
+ messages?: Message[];
1544
+ };
1545
+ }): PromptBlockData;
1497
1546
  private getParsedPromptData;
1498
1547
  }
1499
1548
  type AnyDataset = Dataset<boolean>;
@@ -1645,7 +1694,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1645
1694
  type: z.ZodLiteral<"progress">;
1646
1695
  data: z.ZodObject<{
1647
1696
  id: z.ZodString;
1648
- object_type: z.ZodEnum<["prompt", "tool", "scorer", "task"]>;
1697
+ object_type: z.ZodEnum<["prompt", "tool", "scorer", "task", "agent"]>;
1649
1698
  origin: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1650
1699
  object_type: z.ZodUnion<[z.ZodEnum<["experiment", "dataset", "prompt", "function", "prompt_session"]>, z.ZodEnum<["project_logs"]>]>;
1651
1700
  object_id: z.ZodString;
@@ -1665,16 +1714,16 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1665
1714
  _xact_id: string;
1666
1715
  created?: string | null | undefined;
1667
1716
  }>>>;
1668
- format: z.ZodEnum<["llm", "code", "global"]>;
1717
+ format: z.ZodEnum<["llm", "code", "global", "graph"]>;
1669
1718
  output_type: z.ZodEnum<["completion", "score", "any"]>;
1670
1719
  name: z.ZodString;
1671
1720
  event: z.ZodEnum<["text_delta", "json_delta", "error", "console", "start", "done", "progress"]>;
1672
1721
  data: z.ZodString;
1673
1722
  }, "strip", z.ZodTypeAny, {
1674
- format: "code" | "global" | "llm";
1723
+ format: "code" | "global" | "graph" | "llm";
1675
1724
  data: string;
1676
1725
  name: string;
1677
- object_type: "prompt" | "tool" | "scorer" | "task";
1726
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1678
1727
  id: string;
1679
1728
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1680
1729
  output_type: "completion" | "score" | "any";
@@ -1686,10 +1735,10 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1686
1735
  created?: string | null | undefined;
1687
1736
  } | null | undefined;
1688
1737
  }, {
1689
- format: "code" | "global" | "llm";
1738
+ format: "code" | "global" | "graph" | "llm";
1690
1739
  data: string;
1691
1740
  name: string;
1692
- object_type: "prompt" | "tool" | "scorer" | "task";
1741
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1693
1742
  id: string;
1694
1743
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1695
1744
  output_type: "completion" | "score" | "any";
@@ -1703,10 +1752,10 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1703
1752
  }>;
1704
1753
  }, "strip", z.ZodTypeAny, {
1705
1754
  data: {
1706
- format: "code" | "global" | "llm";
1755
+ format: "code" | "global" | "graph" | "llm";
1707
1756
  data: string;
1708
1757
  name: string;
1709
- object_type: "prompt" | "tool" | "scorer" | "task";
1758
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1710
1759
  id: string;
1711
1760
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1712
1761
  output_type: "completion" | "score" | "any";
@@ -1721,10 +1770,10 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1721
1770
  type: "progress";
1722
1771
  }, {
1723
1772
  data: {
1724
- format: "code" | "global" | "llm";
1773
+ format: "code" | "global" | "graph" | "llm";
1725
1774
  data: string;
1726
1775
  name: string;
1727
- object_type: "prompt" | "tool" | "scorer" | "task";
1776
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1728
1777
  id: string;
1729
1778
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1730
1779
  output_type: "completion" | "score" | "any";
@@ -1768,9 +1817,16 @@ type BraintrustStreamChunk = z.infer<typeof braintrustStreamChunkSchema>;
1768
1817
  declare class BraintrustStream {
1769
1818
  private stream;
1770
1819
  private memoizedFinalValue;
1771
- constructor(baseStream: ReadableStream<Uint8Array>);
1772
- constructor(stream: ReadableStream<string>);
1773
- constructor(stream: ReadableStream<BraintrustStreamChunk>);
1820
+ private signal;
1821
+ constructor(baseStream: ReadableStream<Uint8Array>, opts?: {
1822
+ signal?: AbortSignal;
1823
+ });
1824
+ constructor(stream: ReadableStream<string>, opts?: {
1825
+ signal?: AbortSignal;
1826
+ });
1827
+ constructor(stream: ReadableStream<BraintrustStreamChunk>, opts?: {
1828
+ signal?: AbortSignal;
1829
+ });
1774
1830
  /**
1775
1831
  * Copy the stream. This returns a new stream that shares the same underlying
1776
1832
  * stream (via `tee`). Since streams are consumed in Javascript, use `copy()` if you
@@ -1808,6 +1864,7 @@ declare class BraintrustStream {
1808
1864
  */
1809
1865
  finalValue(): Promise<unknown>;
1810
1866
  static parseRawEvent(event: CallEventSchema): BraintrustStreamChunk;
1867
+ static serializeRawEvent(event: BraintrustStreamChunk): CallEventSchema;
1811
1868
  }
1812
1869
  /**
1813
1870
  * Create a stream that passes through the final value of the stream. This is
@@ -1961,6 +2018,7 @@ interface OpenAILike {
1961
2018
  embeddings: any;
1962
2019
  moderations: any;
1963
2020
  beta?: BetaLike;
2021
+ responses?: any;
1964
2022
  }
1965
2023
  declare global {
1966
2024
  var __inherited_braintrust_wrap_openai: ((openai: any) => any) | undefined;
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TRANSACTION_ID_FIELD, TransactionId, ExperimentEvent, DEFAULT_IS_LEGACY_DATASET, DatasetRecord, ExperimentLogFullArgs, ExperimentLogPartialArgs, LogFeedbackFullArgs, SpanType, IdField, BackgroundLogEvent, SpanComponentsV3, SpanObjectTypeV3 } from '@braintrust/core';
2
- import { GitMetadataSettings, Prompt as Prompt$1, PromptSessionEvent, PromptData, AnyModelParam, OpenAIMessage, Tools, Message, AttachmentReference, AttachmentStatus, BraintrustAttachmentReference, ExternalAttachmentReference, RepoInfo, ModelParams, CallEventSchema, StreamingMode } from '@braintrust/core/typespecs';
2
+ import { GitMetadataSettings, Prompt as Prompt$1, PromptSessionEvent, PromptData, AnyModelParam, OpenAIMessage, Tools, Message, PromptBlockData, AttachmentReference, AttachmentStatus, BraintrustAttachmentReference, ExternalAttachmentReference, RepoInfo, ModelParams, CallEventSchema, StreamingMode } from '@braintrust/core/typespecs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  interface IsoAsyncLocalStorage<T> {
@@ -309,9 +309,9 @@ interface Span extends Exportable {
309
309
  */
310
310
  setAttributes(args: Omit<StartSpanArgs, "event">): void;
311
311
  /**
312
- * Gets the span's `state` value, which is usually the global logging state (this is
313
- * for very advanced purposes only)
312
+ * Start a span with a specific id and parent span ids.
314
313
  */
314
+ startSpanWithParents(spanId: string, spanParents: string[], args?: StartSpanArgs): Span;
315
315
  state(): BraintrustState;
316
316
  kind: "span";
317
317
  }
@@ -335,6 +335,7 @@ declare class NoopSpan implements Span {
335
335
  flush(): Promise<void>;
336
336
  close(args?: EndSpanArgs): number;
337
337
  setAttributes(_args: Omit<StartSpanArgs, "event">): void;
338
+ startSpanWithParents(_spanId: string, _spanParents: string[], _args?: StartSpanArgs): Span;
338
339
  state(): BraintrustState;
339
340
  }
340
341
  declare const NOOP_SPAN: NoopSpan;
@@ -422,8 +423,10 @@ declare class BraintrustState {
422
423
  apiConn(): HTTPConnection;
423
424
  proxyConn(): HTTPConnection;
424
425
  bgLogger(): BackgroundLogger;
426
+ httpLogger(): HTTPBackgroundLogger;
425
427
  setOverrideBgLogger(logger: BackgroundLogger | null): void;
426
428
  loginReplaceApiConn(apiConn: HTTPConnection): void;
429
+ disable(): void;
427
430
  }
428
431
  declare function useTestBackgroundLogger(): TestBackgroundLogger;
429
432
  declare function clearTestBackgroundLogger(): void;
@@ -691,6 +694,10 @@ interface ParentSpanIds {
691
694
  spanId: string;
692
695
  rootSpanId: string;
693
696
  }
697
+ interface MultiParentSpanIds {
698
+ parentSpanIds: string[];
699
+ rootSpanId: string;
700
+ }
694
701
  declare function spanComponentsToObjectId({ components, state, }: {
695
702
  components: SpanComponentsV3;
696
703
  state?: BraintrustState;
@@ -806,6 +813,37 @@ declare class TestBackgroundLogger implements BackgroundLogger {
806
813
  flush(): Promise<void>;
807
814
  drain(): Promise<BackgroundLogEvent[]>;
808
815
  }
816
+ declare class HTTPBackgroundLogger implements BackgroundLogger {
817
+ private apiConn;
818
+ private items;
819
+ private activeFlush;
820
+ private activeFlushResolved;
821
+ private activeFlushError;
822
+ private onFlushError?;
823
+ syncFlush: boolean;
824
+ maxRequestSize: number;
825
+ defaultBatchSize: number;
826
+ numTries: number;
827
+ queueDropExceedingMaxsize: number | undefined;
828
+ queueDropLoggingPeriod: number;
829
+ failedPublishPayloadsDir: string | undefined;
830
+ allPublishPayloadsDir: string | undefined;
831
+ private _disabled;
832
+ private queueDropLoggingState;
833
+ constructor(apiConn: LazyValue<HTTPConnection>, opts?: BackgroundLoggerOpts);
834
+ log(items: LazyValue<BackgroundLogEvent>[]): void;
835
+ flush(): Promise<void>;
836
+ private flushOnce;
837
+ private unwrapLazyValues;
838
+ private submitLogsRequest;
839
+ private registerDroppedItemCount;
840
+ private dumpDroppedEvents;
841
+ private static writePayloadToDir;
842
+ private triggerActiveFlush;
843
+ private logFailedPayloadsDir;
844
+ internalReplaceApiConn(apiConn: HTTPConnection): void;
845
+ disable(): void;
846
+ }
809
847
  type InitOpenOption<IsOpen extends boolean> = {
810
848
  open?: IsOpen;
811
849
  };
@@ -1327,19 +1365,22 @@ declare class SpanImpl implements Span {
1327
1365
  parentObjectType: SpanObjectTypeV3;
1328
1366
  parentObjectId: LazyValue<string>;
1329
1367
  parentComputeObjectMetadataArgs: Record<string, any> | undefined;
1330
- parentSpanIds: ParentSpanIds | undefined;
1368
+ parentSpanIds: ParentSpanIds | MultiParentSpanIds | undefined;
1331
1369
  defaultRootType?: SpanType;
1370
+ spanId?: string;
1332
1371
  } & Omit<StartSpanArgs, "parent">);
1333
1372
  get id(): string;
1334
1373
  get spanId(): string;
1335
1374
  get rootSpanId(): string;
1336
1375
  get spanParents(): string[];
1337
1376
  setAttributes(args: Omit<StartSpanArgs, "event">): void;
1377
+ setSpanParents(parents: string[]): void;
1338
1378
  log(event: ExperimentLogPartialArgs): void;
1339
1379
  private logInternal;
1340
1380
  logFeedback(event: Omit<LogFeedbackFullArgs, "id">): void;
1341
1381
  traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): R;
1342
1382
  startSpan(args?: StartSpanArgs): Span;
1383
+ startSpanWithParents(spanId: string, spanParents: string[], args?: StartSpanArgs): Span;
1343
1384
  end(args?: EndSpanArgs): number;
1344
1385
  export(): Promise<string>;
1345
1386
  permalink(): Promise<string>;
@@ -1494,6 +1535,14 @@ declare class Prompt<HasId extends boolean = true, HasVersion extends boolean =
1494
1535
  strict?: boolean;
1495
1536
  }): CompiledPrompt<Flavor>;
1496
1537
  private runBuild;
1538
+ static renderPrompt({ prompt, buildArgs, options, }: {
1539
+ prompt: PromptBlockData;
1540
+ buildArgs: unknown;
1541
+ options: {
1542
+ strict?: boolean;
1543
+ messages?: Message[];
1544
+ };
1545
+ }): PromptBlockData;
1497
1546
  private getParsedPromptData;
1498
1547
  }
1499
1548
  type AnyDataset = Dataset<boolean>;
@@ -1645,7 +1694,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1645
1694
  type: z.ZodLiteral<"progress">;
1646
1695
  data: z.ZodObject<{
1647
1696
  id: z.ZodString;
1648
- object_type: z.ZodEnum<["prompt", "tool", "scorer", "task"]>;
1697
+ object_type: z.ZodEnum<["prompt", "tool", "scorer", "task", "agent"]>;
1649
1698
  origin: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1650
1699
  object_type: z.ZodUnion<[z.ZodEnum<["experiment", "dataset", "prompt", "function", "prompt_session"]>, z.ZodEnum<["project_logs"]>]>;
1651
1700
  object_id: z.ZodString;
@@ -1665,16 +1714,16 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1665
1714
  _xact_id: string;
1666
1715
  created?: string | null | undefined;
1667
1716
  }>>>;
1668
- format: z.ZodEnum<["llm", "code", "global"]>;
1717
+ format: z.ZodEnum<["llm", "code", "global", "graph"]>;
1669
1718
  output_type: z.ZodEnum<["completion", "score", "any"]>;
1670
1719
  name: z.ZodString;
1671
1720
  event: z.ZodEnum<["text_delta", "json_delta", "error", "console", "start", "done", "progress"]>;
1672
1721
  data: z.ZodString;
1673
1722
  }, "strip", z.ZodTypeAny, {
1674
- format: "code" | "global" | "llm";
1723
+ format: "code" | "global" | "graph" | "llm";
1675
1724
  data: string;
1676
1725
  name: string;
1677
- object_type: "prompt" | "tool" | "scorer" | "task";
1726
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1678
1727
  id: string;
1679
1728
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1680
1729
  output_type: "completion" | "score" | "any";
@@ -1686,10 +1735,10 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1686
1735
  created?: string | null | undefined;
1687
1736
  } | null | undefined;
1688
1737
  }, {
1689
- format: "code" | "global" | "llm";
1738
+ format: "code" | "global" | "graph" | "llm";
1690
1739
  data: string;
1691
1740
  name: string;
1692
- object_type: "prompt" | "tool" | "scorer" | "task";
1741
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1693
1742
  id: string;
1694
1743
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1695
1744
  output_type: "completion" | "score" | "any";
@@ -1703,10 +1752,10 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1703
1752
  }>;
1704
1753
  }, "strip", z.ZodTypeAny, {
1705
1754
  data: {
1706
- format: "code" | "global" | "llm";
1755
+ format: "code" | "global" | "graph" | "llm";
1707
1756
  data: string;
1708
1757
  name: string;
1709
- object_type: "prompt" | "tool" | "scorer" | "task";
1758
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1710
1759
  id: string;
1711
1760
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1712
1761
  output_type: "completion" | "score" | "any";
@@ -1721,10 +1770,10 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
1721
1770
  type: "progress";
1722
1771
  }, {
1723
1772
  data: {
1724
- format: "code" | "global" | "llm";
1773
+ format: "code" | "global" | "graph" | "llm";
1725
1774
  data: string;
1726
1775
  name: string;
1727
- object_type: "prompt" | "tool" | "scorer" | "task";
1776
+ object_type: "prompt" | "tool" | "scorer" | "task" | "agent";
1728
1777
  id: string;
1729
1778
  event: "error" | "text_delta" | "json_delta" | "progress" | "console" | "start" | "done";
1730
1779
  output_type: "completion" | "score" | "any";
@@ -1768,9 +1817,16 @@ type BraintrustStreamChunk = z.infer<typeof braintrustStreamChunkSchema>;
1768
1817
  declare class BraintrustStream {
1769
1818
  private stream;
1770
1819
  private memoizedFinalValue;
1771
- constructor(baseStream: ReadableStream<Uint8Array>);
1772
- constructor(stream: ReadableStream<string>);
1773
- constructor(stream: ReadableStream<BraintrustStreamChunk>);
1820
+ private signal;
1821
+ constructor(baseStream: ReadableStream<Uint8Array>, opts?: {
1822
+ signal?: AbortSignal;
1823
+ });
1824
+ constructor(stream: ReadableStream<string>, opts?: {
1825
+ signal?: AbortSignal;
1826
+ });
1827
+ constructor(stream: ReadableStream<BraintrustStreamChunk>, opts?: {
1828
+ signal?: AbortSignal;
1829
+ });
1774
1830
  /**
1775
1831
  * Copy the stream. This returns a new stream that shares the same underlying
1776
1832
  * stream (via `tee`). Since streams are consumed in Javascript, use `copy()` if you
@@ -1808,6 +1864,7 @@ declare class BraintrustStream {
1808
1864
  */
1809
1865
  finalValue(): Promise<unknown>;
1810
1866
  static parseRawEvent(event: CallEventSchema): BraintrustStreamChunk;
1867
+ static serializeRawEvent(event: BraintrustStreamChunk): CallEventSchema;
1811
1868
  }
1812
1869
  /**
1813
1870
  * Create a stream that passes through the final value of the stream. This is
@@ -1961,6 +2018,7 @@ interface OpenAILike {
1961
2018
  embeddings: any;
1962
2019
  moderations: any;
1963
2020
  beta?: BetaLike;
2021
+ responses?: any;
1964
2022
  }
1965
2023
  declare global {
1966
2024
  var __inherited_braintrust_wrap_openai: ((openai: any) => any) | undefined;