braintrust 3.23.0 → 3.24.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.
Files changed (51) hide show
  1. package/dev/dist/index.d.mts +6 -0
  2. package/dev/dist/index.d.ts +6 -0
  3. package/dev/dist/index.js +902 -588
  4. package/dev/dist/index.mjs +320 -6
  5. package/dist/apply-auto-instrumentation.js +211 -189
  6. package/dist/apply-auto-instrumentation.mjs +23 -1
  7. package/dist/auto-instrumentations/bundler/esbuild.cjs +40 -0
  8. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/next.cjs +40 -0
  10. package/dist/auto-instrumentations/bundler/next.mjs +3 -3
  11. package/dist/auto-instrumentations/bundler/rollup.cjs +40 -0
  12. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  13. package/dist/auto-instrumentations/bundler/vite.cjs +40 -0
  14. package/dist/auto-instrumentations/bundler/vite.d.mts +1 -1
  15. package/dist/auto-instrumentations/bundler/vite.d.ts +1 -1
  16. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  17. package/dist/auto-instrumentations/bundler/webpack-loader.cjs +40 -0
  18. package/dist/auto-instrumentations/bundler/webpack.cjs +40 -0
  19. package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
  20. package/dist/auto-instrumentations/{chunk-KIMLYPRW.mjs → chunk-BURMPO7L.mjs} +1 -1
  21. package/dist/auto-instrumentations/{chunk-YXLNSAMJ.mjs → chunk-F43DNLPD.mjs} +40 -0
  22. package/dist/auto-instrumentations/{chunk-EXY7QCJD.mjs → chunk-GSZHTAQW.mjs} +1 -1
  23. package/dist/auto-instrumentations/hook.mjs +150 -1
  24. package/dist/auto-instrumentations/index.cjs +40 -0
  25. package/dist/auto-instrumentations/index.mjs +1 -1
  26. package/dist/browser.d.mts +131 -9
  27. package/dist/browser.d.ts +131 -9
  28. package/dist/browser.js +703 -67
  29. package/dist/browser.mjs +703 -67
  30. package/dist/{chunk-CDIKAHDZ.js → chunk-7AUY2XWX.js} +21 -1
  31. package/dist/{chunk-36IPYKMG.mjs → chunk-7F6GCRHH.mjs} +20 -0
  32. package/dist/{chunk-FZWPFCVE.js → chunk-SU6EHKJV.js} +1085 -801
  33. package/dist/{chunk-IXL4PMY4.mjs → chunk-XE5FS7QY.mjs} +291 -7
  34. package/dist/cli.js +328 -10
  35. package/dist/edge-light.js +703 -67
  36. package/dist/edge-light.mjs +703 -67
  37. package/dist/index.d.mts +131 -9
  38. package/dist/index.d.ts +131 -9
  39. package/dist/index.js +891 -532
  40. package/dist/index.mjs +423 -64
  41. package/dist/instrumentation/index.d.mts +130 -9
  42. package/dist/instrumentation/index.d.ts +130 -9
  43. package/dist/instrumentation/index.js +601 -67
  44. package/dist/instrumentation/index.mjs +601 -67
  45. package/dist/vitest-evals-reporter.js +17 -16
  46. package/dist/vitest-evals-reporter.mjs +3 -2
  47. package/dist/workerd.js +703 -67
  48. package/dist/workerd.mjs +703 -67
  49. package/package.json +3 -3
  50. package/util/dist/index.js +4 -0
  51. package/util/dist/index.mjs +4 -0
@@ -107,6 +107,7 @@ var DefaultChannel = class {
107
107
  constructor(name) {
108
108
  this.name = name;
109
109
  }
110
+ name;
110
111
  hasSubscribers = false;
111
112
  subscribe(_subscription) {
112
113
  }
@@ -1159,6 +1160,7 @@ var SpanComponentsV3 = class _SpanComponentsV3 {
1159
1160
  constructor(data) {
1160
1161
  this.data = data;
1161
1162
  }
1163
+ data;
1162
1164
  toStr() {
1163
1165
  const jsonObj = {
1164
1166
  compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
@@ -1576,6 +1578,7 @@ var SpanComponentsV4 = class _SpanComponentsV4 {
1576
1578
  constructor(data) {
1577
1579
  this.data = data;
1578
1580
  }
1581
+ data;
1579
1582
  toStr() {
1580
1583
  const jsonObj = {
1581
1584
  compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
@@ -4728,6 +4731,97 @@ var SpanCache = class {
4728
4731
  }
4729
4732
  };
4730
4733
 
4734
+ // src/span-origin.ts
4735
+ var SDK_VERSION = true ? "3.24.0" : "0.0.0";
4736
+ function detectSpanOriginEnvironment(explicit) {
4737
+ if (explicit) return explicit;
4738
+ const envType = isomorph_default.getEnv("BRAINTRUST_ENVIRONMENT_TYPE");
4739
+ const envName = isomorph_default.getEnv("BRAINTRUST_ENVIRONMENT_NAME");
4740
+ if (envType || envName) {
4741
+ return {
4742
+ ...envType ? { type: envType } : {},
4743
+ ...envName ? { name: envName } : {}
4744
+ };
4745
+ }
4746
+ const ci = firstPresent([
4747
+ ["GITHUB_ACTIONS", "github_actions"],
4748
+ ["GITLAB_CI", "gitlab_ci"],
4749
+ ["CIRCLECI", "circleci"],
4750
+ ["BUILDKITE", "buildkite"],
4751
+ ["JENKINS_URL", "jenkins"],
4752
+ ["JENKINS_HOME", "jenkins"],
4753
+ ["TF_BUILD", "azure_pipelines"],
4754
+ ["TEAMCITY_VERSION", "teamcity"],
4755
+ ["TRAVIS", "travis"],
4756
+ ["BITBUCKET_BUILD_NUMBER", "bitbucket"]
4757
+ ]);
4758
+ if (ci) return { type: "ci", name: ci };
4759
+ if (isomorph_default.getEnv("CI")) return { type: "ci", name: "ci" };
4760
+ const earlyServer = firstPresent([
4761
+ ["VERCEL", "vercel"],
4762
+ ["NETLIFY", "netlify"]
4763
+ ]);
4764
+ if (earlyServer) return { type: "server", name: earlyServer };
4765
+ if (isomorph_default.getEnv("ECS_CONTAINER_METADATA_URI") || isomorph_default.getEnv("ECS_CONTAINER_METADATA_URI_V4")) {
4766
+ return { type: "server", name: "ecs" };
4767
+ }
4768
+ const awsExecutionEnv = isomorph_default.getEnv("AWS_EXECUTION_ENV");
4769
+ if (awsExecutionEnv?.startsWith("AWS_ECS_")) {
4770
+ return { type: "server", name: "ecs" };
4771
+ }
4772
+ if (awsExecutionEnv?.startsWith("AWS_Lambda_")) {
4773
+ return { type: "server", name: "aws_lambda" };
4774
+ }
4775
+ if (isomorph_default.getEnv("AWS_LAMBDA_FUNCTION_NAME")) {
4776
+ return { type: "server", name: "aws_lambda" };
4777
+ }
4778
+ const server = firstPresent([
4779
+ ["K_SERVICE", "cloud_run"],
4780
+ ["FUNCTION_TARGET", "gcp_functions"],
4781
+ ["KUBERNETES_SERVICE_HOST", "kubernetes"],
4782
+ ["DYNO", "heroku"],
4783
+ ["FLY_APP_NAME", "fly"],
4784
+ ["RAILWAY_ENVIRONMENT", "railway"],
4785
+ ["RENDER_SERVICE_NAME", "render"]
4786
+ ]);
4787
+ if (server) return { type: "server", name: server };
4788
+ return deploymentModeEnvironment("NODE_ENV", isomorph_default.getEnv("NODE_ENV"));
4789
+ }
4790
+ function makeSpanOrigin(instrumentationName, environment) {
4791
+ return {
4792
+ name: "braintrust.sdk.javascript",
4793
+ version: SDK_VERSION,
4794
+ instrumentation: { name: instrumentationName },
4795
+ ...environment ? { environment } : {}
4796
+ };
4797
+ }
4798
+ function mergeSpanOriginContext(context, instrumentationName, environment) {
4799
+ const next = { ...context ?? {} };
4800
+ const current = isObject2(next.span_origin) ? { ...next.span_origin } : {};
4801
+ next.span_origin = {
4802
+ ...makeSpanOrigin(instrumentationName, environment),
4803
+ ...current
4804
+ };
4805
+ return next;
4806
+ }
4807
+ function firstPresent(entries) {
4808
+ return entries.find(([key]) => Boolean(isomorph_default.getEnv(key)))?.[1];
4809
+ }
4810
+ function deploymentModeEnvironment(_key, value) {
4811
+ if (!value) return void 0;
4812
+ const normalized = value.toLowerCase();
4813
+ if (normalized === "production" || normalized === "staging") {
4814
+ return { type: "server", name: normalized };
4815
+ }
4816
+ if (normalized === "development" || normalized === "local") {
4817
+ return { type: "local", name: normalized };
4818
+ }
4819
+ return { name: value };
4820
+ }
4821
+ function isObject2(value) {
4822
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4823
+ }
4824
+
4731
4825
  // src/logger.ts
4732
4826
  var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
4733
4827
  var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
@@ -4776,6 +4870,7 @@ var LoginInvalidOrgError = class extends Error {
4776
4870
  super(message);
4777
4871
  this.message = message;
4778
4872
  }
4873
+ message;
4779
4874
  };
4780
4875
  var REDACTION_FIELDS = [
4781
4876
  "input",
@@ -4791,6 +4886,8 @@ var MaskingError = class {
4791
4886
  this.fieldName = fieldName;
4792
4887
  this.errorType = errorType;
4793
4888
  }
4889
+ fieldName;
4890
+ errorType;
4794
4891
  get errorMsg() {
4795
4892
  return `ERROR: Failed to mask field '${this.fieldName}' - ${this.errorType}`;
4796
4893
  }
@@ -5000,7 +5097,9 @@ var BraintrustState = class _BraintrustState {
5000
5097
  diskCache: parametersDiskCache
5001
5098
  });
5002
5099
  this.spanCache = new SpanCache({ disabled: loginParams.disableSpanCache });
5100
+ this.spanOriginEnvironment = detectSpanOriginEnvironment();
5003
5101
  }
5102
+ loginParams;
5004
5103
  id;
5005
5104
  currentExperiment;
5006
5105
  // Note: the value of IsAsyncFlush doesn't really matter here, since we
@@ -5035,6 +5134,7 @@ var BraintrustState = class _BraintrustState {
5035
5134
  _idGenerator = null;
5036
5135
  _contextManager = null;
5037
5136
  _otelFlushCallback = null;
5137
+ spanOriginEnvironment;
5038
5138
  resetLoginInfo() {
5039
5139
  this.appUrl = null;
5040
5140
  this.appPublicUrl = null;
@@ -7539,6 +7639,11 @@ var ObjectFetcher = class {
7539
7639
  this._internal_btql = _internal_btql;
7540
7640
  this._internalBrainstoreRealtime = _internalBrainstoreRealtime;
7541
7641
  }
7642
+ objectType;
7643
+ pinnedVersion;
7644
+ mutateRecord;
7645
+ _internal_btql;
7646
+ _internalBrainstoreRealtime;
7542
7647
  _fetchedData = void 0;
7543
7648
  get id() {
7544
7649
  throw new Error("ObjectFetcher subclasses must have an 'id' attribute");
@@ -8058,7 +8163,11 @@ var SpanImpl = class _SpanImpl {
8058
8163
  metrics: {
8059
8164
  start: args.startTime ?? getCurrentUnixTimestamp()
8060
8165
  },
8061
- context: { ...callerLocation },
8166
+ context: mergeSpanOriginContext(
8167
+ { ...callerLocation },
8168
+ "braintrust-js-logger",
8169
+ this._state.spanOriginEnvironment
8170
+ ),
8062
8171
  span_attributes: {
8063
8172
  name,
8064
8173
  type,
@@ -8432,6 +8541,7 @@ var Dataset2 = class extends ObjectFetcher {
8432
8541
  this.pinnedEnvironment = pinState?.pinnedEnvironment;
8433
8542
  this.pinnedSnapshotName = pinState?.pinnedSnapshotName;
8434
8543
  }
8544
+ state;
8435
8545
  lazyMetadata;
8436
8546
  __braintrust_dataset_marker = true;
8437
8547
  newRecords = 0;
@@ -9104,9 +9214,48 @@ var aiSDKChannels = defineChannels("ai", {
9104
9214
  kind: "sync-stream"
9105
9215
  })
9106
9216
  });
9217
+ var harnessAgentChannels = defineChannels("@ai-sdk/harness", {
9218
+ generate: channel({
9219
+ channelName: "HarnessAgent.generate",
9220
+ kind: "async"
9221
+ }),
9222
+ stream: channel({
9223
+ channelName: "HarnessAgent.stream",
9224
+ kind: "async"
9225
+ }),
9226
+ continueGenerate: channel({
9227
+ channelName: "HarnessAgent.continueGenerate",
9228
+ kind: "async"
9229
+ }),
9230
+ continueStream: channel({
9231
+ channelName: "HarnessAgent.continueStream",
9232
+ kind: "async"
9233
+ })
9234
+ });
9107
9235
 
9108
9236
  // src/auto-instrumentations/configs/ai-sdk.ts
9109
9237
  var aiSDKConfigs = [
9238
+ // HarnessAgent turn methods are published only from the package's ESM
9239
+ // `./agent` entrypoint. The compiled class expression is anonymous, so match
9240
+ // the first async method with each public name instead of a class name.
9241
+ ...[
9242
+ ["generate", harnessAgentChannels.generate.channelName],
9243
+ ["stream", harnessAgentChannels.stream.channelName],
9244
+ ["continueGenerate", harnessAgentChannels.continueGenerate.channelName],
9245
+ ["continueStream", harnessAgentChannels.continueStream.channelName]
9246
+ ].map(([methodName, channelName]) => ({
9247
+ channelName,
9248
+ module: {
9249
+ name: "@ai-sdk/harness",
9250
+ versionRange: ">=1.0.0 <2.0.0",
9251
+ filePath: "dist/agent/index.js"
9252
+ },
9253
+ functionQuery: {
9254
+ methodName,
9255
+ kind: "Async",
9256
+ index: 0
9257
+ }
9258
+ })),
9110
9259
  // generateText - async function
9111
9260
  {
9112
9261
  channelName: aiSDKChannels.generateText.channelName,
@@ -61,6 +61,7 @@ var DefaultChannel = class {
61
61
  constructor(name) {
62
62
  this.name = name;
63
63
  }
64
+ name;
64
65
  hasSubscribers = false;
65
66
  subscribe(_subscription) {
66
67
  }
@@ -722,9 +723,48 @@ var aiSDKChannels = defineChannels("ai", {
722
723
  kind: "sync-stream"
723
724
  })
724
725
  });
726
+ var harnessAgentChannels = defineChannels("@ai-sdk/harness", {
727
+ generate: channel({
728
+ channelName: "HarnessAgent.generate",
729
+ kind: "async"
730
+ }),
731
+ stream: channel({
732
+ channelName: "HarnessAgent.stream",
733
+ kind: "async"
734
+ }),
735
+ continueGenerate: channel({
736
+ channelName: "HarnessAgent.continueGenerate",
737
+ kind: "async"
738
+ }),
739
+ continueStream: channel({
740
+ channelName: "HarnessAgent.continueStream",
741
+ kind: "async"
742
+ })
743
+ });
725
744
 
726
745
  // src/auto-instrumentations/configs/ai-sdk.ts
727
746
  var aiSDKConfigs = [
747
+ // HarnessAgent turn methods are published only from the package's ESM
748
+ // `./agent` entrypoint. The compiled class expression is anonymous, so match
749
+ // the first async method with each public name instead of a class name.
750
+ ...[
751
+ ["generate", harnessAgentChannels.generate.channelName],
752
+ ["stream", harnessAgentChannels.stream.channelName],
753
+ ["continueGenerate", harnessAgentChannels.continueGenerate.channelName],
754
+ ["continueStream", harnessAgentChannels.continueStream.channelName]
755
+ ].map(([methodName, channelName]) => ({
756
+ channelName,
757
+ module: {
758
+ name: "@ai-sdk/harness",
759
+ versionRange: ">=1.0.0 <2.0.0",
760
+ filePath: "dist/agent/index.js"
761
+ },
762
+ functionQuery: {
763
+ methodName,
764
+ kind: "Async",
765
+ index: 0
766
+ }
767
+ })),
728
768
  // generateText - async function
729
769
  {
730
770
  channelName: aiSDKChannels.generateText.channelName,
@@ -20,7 +20,7 @@ import {
20
20
  openRouterConfigs,
21
21
  openaiConfigs,
22
22
  piCodingAgentConfigs
23
- } from "./chunk-YXLNSAMJ.mjs";
23
+ } from "./chunk-F43DNLPD.mjs";
24
24
  export {
25
25
  aiSDKConfigs,
26
26
  anthropicConfigs,
@@ -20364,6 +20364,11 @@ type InferParameters<T extends EvalParameters> = {
20364
20364
  [K in keyof T]: InferParameterValue<T[K]>;
20365
20365
  };
20366
20366
 
20367
+ type SpanOriginEnvironment = {
20368
+ type?: string;
20369
+ name?: string;
20370
+ };
20371
+
20367
20372
  /// <reference lib="dom" />
20368
20373
 
20369
20374
  declare const LOGS3_OVERFLOW_REFERENCE_TYPE = "logs3_overflow";
@@ -20784,6 +20789,7 @@ declare class BraintrustState {
20784
20789
  private _idGenerator;
20785
20790
  private _contextManager;
20786
20791
  private _otelFlushCallback;
20792
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
20787
20793
  constructor(loginParams: LoginOptions);
20788
20794
  resetLoginInfo(): void;
20789
20795
  resetIdGenState(): void;
@@ -21564,6 +21570,7 @@ type AsyncFlushArg<IsAsyncFlush> = {
21564
21570
  type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
21565
21571
  projectName?: string;
21566
21572
  projectId?: string;
21573
+ environment?: SpanOriginEnvironment;
21567
21574
  setCurrent?: boolean;
21568
21575
  state?: BraintrustState;
21569
21576
  orgProjectMetadata?: OrgProjectMetadata;
@@ -23526,8 +23533,8 @@ type EveJsonObject = {
23526
23533
  readonly [key: string]: EveJsonValue;
23527
23534
  };
23528
23535
  interface EveHookContext {
23529
- readonly session?: {
23530
- readonly id?: string;
23536
+ readonly session: {
23537
+ readonly id: string;
23531
23538
  readonly parent?: {
23532
23539
  readonly callId?: string;
23533
23540
  readonly sessionId?: string;
@@ -23628,6 +23635,15 @@ type EveHandleMessageStreamEvent = {
23628
23635
  };
23629
23636
  readonly meta?: EveStreamEventMeta;
23630
23637
  readonly type: "message.completed";
23638
+ } | {
23639
+ readonly data: {
23640
+ readonly reasoning: string;
23641
+ readonly sequence: number;
23642
+ readonly stepIndex: number;
23643
+ readonly turnId: string;
23644
+ };
23645
+ readonly meta?: EveStreamEventMeta;
23646
+ readonly type: "reasoning.completed";
23631
23647
  } | {
23632
23648
  readonly data: {
23633
23649
  readonly result: EveJsonValue;
@@ -23761,22 +23777,128 @@ interface EveHookDefinition {
23761
23777
  interface EveInstrumentationSetupContext {
23762
23778
  readonly agentName: string;
23763
23779
  }
23780
+ type EveTextPart = {
23781
+ readonly text: string;
23782
+ readonly type: "text";
23783
+ };
23784
+ type EveImagePart = {
23785
+ readonly image: unknown;
23786
+ readonly mediaType?: string;
23787
+ readonly type: "image";
23788
+ };
23789
+ type EveFilePart = {
23790
+ readonly data: unknown;
23791
+ readonly filename?: string;
23792
+ readonly mediaType: string;
23793
+ readonly type: "file";
23794
+ };
23795
+ type EveReasoningPart = {
23796
+ readonly text: string;
23797
+ readonly type: "reasoning";
23798
+ };
23799
+ type EveReasoningFilePart = {
23800
+ readonly data: unknown;
23801
+ readonly mediaType: string;
23802
+ readonly type: "reasoning-file";
23803
+ };
23804
+ type EveCustomPart = {
23805
+ readonly kind: `${string}.${string}`;
23806
+ readonly type: "custom";
23807
+ };
23808
+ type EveToolCallPart = {
23809
+ readonly input: unknown;
23810
+ readonly providerExecuted?: boolean;
23811
+ readonly toolCallId: string;
23812
+ readonly toolName: string;
23813
+ readonly type: "tool-call";
23814
+ };
23815
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
23816
+ readonly data: string;
23817
+ readonly filename?: string;
23818
+ readonly mediaType: string;
23819
+ readonly type: "file-data";
23820
+ } | {
23821
+ readonly mediaType?: string;
23822
+ readonly type: "file-url";
23823
+ readonly url: string;
23824
+ } | {
23825
+ readonly fileId: string | Readonly<Record<string, string>>;
23826
+ readonly type: "file-id" | "image-file-id";
23827
+ } | {
23828
+ readonly providerReference: Readonly<Record<string, string>>;
23829
+ readonly type: "file-reference" | "image-file-reference";
23830
+ } | {
23831
+ readonly data: string;
23832
+ readonly mediaType: string;
23833
+ readonly type: "image-data";
23834
+ } | {
23835
+ readonly type: "image-url";
23836
+ readonly url: string;
23837
+ } | {
23838
+ readonly type: "custom";
23839
+ };
23840
+ type EveToolResultOutput = {
23841
+ readonly type: "text" | "error-text";
23842
+ readonly value: string;
23843
+ } | {
23844
+ readonly type: "json" | "error-json";
23845
+ readonly value: EveJsonValue;
23846
+ } | {
23847
+ readonly reason?: string;
23848
+ readonly type: "execution-denied";
23849
+ } | {
23850
+ readonly type: "content";
23851
+ readonly value: readonly EveToolResultContentPart[];
23852
+ };
23853
+ type EveToolResultPart = {
23854
+ readonly output: EveToolResultOutput;
23855
+ readonly toolCallId: string;
23856
+ readonly toolName: string;
23857
+ readonly type: "tool-result";
23858
+ };
23859
+ type EveToolApprovalRequest = {
23860
+ readonly approvalId: string;
23861
+ readonly isAutomatic?: boolean;
23862
+ readonly signature?: string;
23863
+ readonly toolCallId: string;
23864
+ readonly type: "tool-approval-request";
23865
+ };
23866
+ type EveToolApprovalResponse = {
23867
+ readonly approvalId: string;
23868
+ readonly approved: boolean;
23869
+ readonly providerExecuted?: boolean;
23870
+ readonly reason?: string;
23871
+ readonly type: "tool-approval-response";
23872
+ };
23873
+ type EveSystemModelMessage = {
23874
+ readonly content: string;
23875
+ readonly role: "system";
23876
+ };
23877
+ type EveModelMessage = EveSystemModelMessage | {
23878
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
23879
+ readonly role: "user";
23880
+ } | {
23881
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
23882
+ readonly role: "assistant";
23883
+ } | {
23884
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
23885
+ readonly role: "tool";
23886
+ };
23764
23887
  interface EveInstrumentationModelInput {
23765
- readonly instructions?: string | readonly EveJsonObject[];
23766
- readonly messages: readonly EveJsonObject[];
23888
+ readonly instructions?: string | readonly EveSystemModelMessage[];
23889
+ readonly messages: readonly EveModelMessage[];
23767
23890
  }
23768
23891
  interface EveInstrumentationStepStartedEventInput {
23769
- readonly channel?: unknown;
23770
23892
  readonly modelInput: EveInstrumentationModelInput;
23771
23893
  readonly session: {
23772
- readonly id?: string;
23894
+ readonly id: string;
23773
23895
  };
23774
23896
  readonly step: {
23775
- readonly index?: number;
23897
+ readonly index: number;
23776
23898
  };
23777
23899
  readonly turn: {
23778
- readonly id?: string;
23779
- readonly sequence?: number;
23900
+ readonly id: string;
23901
+ readonly sequence: number;
23780
23902
  };
23781
23903
  }
23782
23904
  interface EveInstrumentationDefinition {
package/dist/browser.d.ts CHANGED
@@ -20364,6 +20364,11 @@ type InferParameters<T extends EvalParameters> = {
20364
20364
  [K in keyof T]: InferParameterValue<T[K]>;
20365
20365
  };
20366
20366
 
20367
+ type SpanOriginEnvironment = {
20368
+ type?: string;
20369
+ name?: string;
20370
+ };
20371
+
20367
20372
  /// <reference lib="dom" />
20368
20373
 
20369
20374
  declare const LOGS3_OVERFLOW_REFERENCE_TYPE = "logs3_overflow";
@@ -20784,6 +20789,7 @@ declare class BraintrustState {
20784
20789
  private _idGenerator;
20785
20790
  private _contextManager;
20786
20791
  private _otelFlushCallback;
20792
+ spanOriginEnvironment: SpanOriginEnvironment | undefined;
20787
20793
  constructor(loginParams: LoginOptions);
20788
20794
  resetLoginInfo(): void;
20789
20795
  resetIdGenState(): void;
@@ -21564,6 +21570,7 @@ type AsyncFlushArg<IsAsyncFlush> = {
21564
21570
  type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
21565
21571
  projectName?: string;
21566
21572
  projectId?: string;
21573
+ environment?: SpanOriginEnvironment;
21567
21574
  setCurrent?: boolean;
21568
21575
  state?: BraintrustState;
21569
21576
  orgProjectMetadata?: OrgProjectMetadata;
@@ -23526,8 +23533,8 @@ type EveJsonObject = {
23526
23533
  readonly [key: string]: EveJsonValue;
23527
23534
  };
23528
23535
  interface EveHookContext {
23529
- readonly session?: {
23530
- readonly id?: string;
23536
+ readonly session: {
23537
+ readonly id: string;
23531
23538
  readonly parent?: {
23532
23539
  readonly callId?: string;
23533
23540
  readonly sessionId?: string;
@@ -23628,6 +23635,15 @@ type EveHandleMessageStreamEvent = {
23628
23635
  };
23629
23636
  readonly meta?: EveStreamEventMeta;
23630
23637
  readonly type: "message.completed";
23638
+ } | {
23639
+ readonly data: {
23640
+ readonly reasoning: string;
23641
+ readonly sequence: number;
23642
+ readonly stepIndex: number;
23643
+ readonly turnId: string;
23644
+ };
23645
+ readonly meta?: EveStreamEventMeta;
23646
+ readonly type: "reasoning.completed";
23631
23647
  } | {
23632
23648
  readonly data: {
23633
23649
  readonly result: EveJsonValue;
@@ -23761,22 +23777,128 @@ interface EveHookDefinition {
23761
23777
  interface EveInstrumentationSetupContext {
23762
23778
  readonly agentName: string;
23763
23779
  }
23780
+ type EveTextPart = {
23781
+ readonly text: string;
23782
+ readonly type: "text";
23783
+ };
23784
+ type EveImagePart = {
23785
+ readonly image: unknown;
23786
+ readonly mediaType?: string;
23787
+ readonly type: "image";
23788
+ };
23789
+ type EveFilePart = {
23790
+ readonly data: unknown;
23791
+ readonly filename?: string;
23792
+ readonly mediaType: string;
23793
+ readonly type: "file";
23794
+ };
23795
+ type EveReasoningPart = {
23796
+ readonly text: string;
23797
+ readonly type: "reasoning";
23798
+ };
23799
+ type EveReasoningFilePart = {
23800
+ readonly data: unknown;
23801
+ readonly mediaType: string;
23802
+ readonly type: "reasoning-file";
23803
+ };
23804
+ type EveCustomPart = {
23805
+ readonly kind: `${string}.${string}`;
23806
+ readonly type: "custom";
23807
+ };
23808
+ type EveToolCallPart = {
23809
+ readonly input: unknown;
23810
+ readonly providerExecuted?: boolean;
23811
+ readonly toolCallId: string;
23812
+ readonly toolName: string;
23813
+ readonly type: "tool-call";
23814
+ };
23815
+ type EveToolResultContentPart = EveTextPart | EveFilePart | {
23816
+ readonly data: string;
23817
+ readonly filename?: string;
23818
+ readonly mediaType: string;
23819
+ readonly type: "file-data";
23820
+ } | {
23821
+ readonly mediaType?: string;
23822
+ readonly type: "file-url";
23823
+ readonly url: string;
23824
+ } | {
23825
+ readonly fileId: string | Readonly<Record<string, string>>;
23826
+ readonly type: "file-id" | "image-file-id";
23827
+ } | {
23828
+ readonly providerReference: Readonly<Record<string, string>>;
23829
+ readonly type: "file-reference" | "image-file-reference";
23830
+ } | {
23831
+ readonly data: string;
23832
+ readonly mediaType: string;
23833
+ readonly type: "image-data";
23834
+ } | {
23835
+ readonly type: "image-url";
23836
+ readonly url: string;
23837
+ } | {
23838
+ readonly type: "custom";
23839
+ };
23840
+ type EveToolResultOutput = {
23841
+ readonly type: "text" | "error-text";
23842
+ readonly value: string;
23843
+ } | {
23844
+ readonly type: "json" | "error-json";
23845
+ readonly value: EveJsonValue;
23846
+ } | {
23847
+ readonly reason?: string;
23848
+ readonly type: "execution-denied";
23849
+ } | {
23850
+ readonly type: "content";
23851
+ readonly value: readonly EveToolResultContentPart[];
23852
+ };
23853
+ type EveToolResultPart = {
23854
+ readonly output: EveToolResultOutput;
23855
+ readonly toolCallId: string;
23856
+ readonly toolName: string;
23857
+ readonly type: "tool-result";
23858
+ };
23859
+ type EveToolApprovalRequest = {
23860
+ readonly approvalId: string;
23861
+ readonly isAutomatic?: boolean;
23862
+ readonly signature?: string;
23863
+ readonly toolCallId: string;
23864
+ readonly type: "tool-approval-request";
23865
+ };
23866
+ type EveToolApprovalResponse = {
23867
+ readonly approvalId: string;
23868
+ readonly approved: boolean;
23869
+ readonly providerExecuted?: boolean;
23870
+ readonly reason?: string;
23871
+ readonly type: "tool-approval-response";
23872
+ };
23873
+ type EveSystemModelMessage = {
23874
+ readonly content: string;
23875
+ readonly role: "system";
23876
+ };
23877
+ type EveModelMessage = EveSystemModelMessage | {
23878
+ readonly content: string | readonly (EveTextPart | EveImagePart | EveFilePart)[];
23879
+ readonly role: "user";
23880
+ } | {
23881
+ readonly content: string | readonly (EveTextPart | EveCustomPart | EveFilePart | EveReasoningPart | EveReasoningFilePart | EveToolCallPart | EveToolResultPart | EveToolApprovalRequest)[];
23882
+ readonly role: "assistant";
23883
+ } | {
23884
+ readonly content: readonly (EveToolResultPart | EveToolApprovalResponse)[];
23885
+ readonly role: "tool";
23886
+ };
23764
23887
  interface EveInstrumentationModelInput {
23765
- readonly instructions?: string | readonly EveJsonObject[];
23766
- readonly messages: readonly EveJsonObject[];
23888
+ readonly instructions?: string | readonly EveSystemModelMessage[];
23889
+ readonly messages: readonly EveModelMessage[];
23767
23890
  }
23768
23891
  interface EveInstrumentationStepStartedEventInput {
23769
- readonly channel?: unknown;
23770
23892
  readonly modelInput: EveInstrumentationModelInput;
23771
23893
  readonly session: {
23772
- readonly id?: string;
23894
+ readonly id: string;
23773
23895
  };
23774
23896
  readonly step: {
23775
- readonly index?: number;
23897
+ readonly index: number;
23776
23898
  };
23777
23899
  readonly turn: {
23778
- readonly id?: string;
23779
- readonly sequence?: number;
23900
+ readonly id: string;
23901
+ readonly sequence: number;
23780
23902
  };
23781
23903
  }
23782
23904
  interface EveInstrumentationDefinition {