braintrust 0.4.4 → 0.4.5

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/dev/dist/index.js CHANGED
@@ -5447,7 +5447,7 @@ async function permalink(slug, opts) {
5447
5447
  return state.appUrl;
5448
5448
  };
5449
5449
  try {
5450
- const components = SpanComponentsV3.fromStr(slug);
5450
+ const components = getSpanComponentsClass().fromStr(slug);
5451
5451
  const object_type = spanObjectTypeV3ToString(components.data.object_type);
5452
5452
  const [orgName, appUrl, object_id] = await Promise.all([
5453
5453
  getOrgName(),
@@ -5475,7 +5475,7 @@ function startSpanParentArgs(args) {
5475
5475
  if (args.parentSpanIds) {
5476
5476
  throw new Error("Cannot specify both parent and parentSpanIds");
5477
5477
  }
5478
- const parentComponents = SpanComponentsV3.fromStr(args.parent);
5478
+ const parentComponents = getSpanComponentsClass().fromStr(args.parent);
5479
5479
  if (args.parentObjectType !== parentComponents.data.object_type) {
5480
5480
  throw new Error(
5481
5481
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -5919,7 +5919,7 @@ function getSpanParentObject(options) {
5919
5919
  return parentSpan;
5920
5920
  }
5921
5921
  const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.parent]), () => ( state.currentParent.getStore()));
5922
- if (parentStr) return SpanComponentsV3.fromStr(parentStr);
5922
+ if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
5923
5923
  const experiment = currentExperiment();
5924
5924
  if (experiment) {
5925
5925
  return experiment;
@@ -5985,7 +5985,7 @@ function startSpanAndIsLogger(args) {
5985
5985
  parent: _optionalChain([args, 'optionalAccess', _47 => _47.parent]),
5986
5986
  state
5987
5987
  });
5988
- if (parentObject instanceof SpanComponentsV3) {
5988
+ if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
5989
5989
  const parentSpanIds = parentObject.data.row_id ? {
5990
5990
  spanId: parentObject.data.span_id,
5991
5991
  rootSpanId: parentObject.data.root_span_id
@@ -5447,7 +5447,7 @@ async function permalink(slug, opts) {
5447
5447
  return state.appUrl;
5448
5448
  };
5449
5449
  try {
5450
- const components = SpanComponentsV3.fromStr(slug);
5450
+ const components = getSpanComponentsClass().fromStr(slug);
5451
5451
  const object_type = spanObjectTypeV3ToString(components.data.object_type);
5452
5452
  const [orgName, appUrl, object_id] = await Promise.all([
5453
5453
  getOrgName(),
@@ -5475,7 +5475,7 @@ function startSpanParentArgs(args) {
5475
5475
  if (args.parentSpanIds) {
5476
5476
  throw new Error("Cannot specify both parent and parentSpanIds");
5477
5477
  }
5478
- const parentComponents = SpanComponentsV3.fromStr(args.parent);
5478
+ const parentComponents = getSpanComponentsClass().fromStr(args.parent);
5479
5479
  if (args.parentObjectType !== parentComponents.data.object_type) {
5480
5480
  throw new Error(
5481
5481
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -5919,7 +5919,7 @@ function getSpanParentObject(options) {
5919
5919
  return parentSpan;
5920
5920
  }
5921
5921
  const parentStr = options?.parent ?? state.currentParent.getStore();
5922
- if (parentStr) return SpanComponentsV3.fromStr(parentStr);
5922
+ if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
5923
5923
  const experiment = currentExperiment();
5924
5924
  if (experiment) {
5925
5925
  return experiment;
@@ -5985,7 +5985,7 @@ function startSpanAndIsLogger(args) {
5985
5985
  parent: args?.parent,
5986
5986
  state
5987
5987
  });
5988
- if (parentObject instanceof SpanComponentsV3) {
5988
+ if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
5989
5989
  const parentSpanIds = parentObject.data.row_id ? {
5990
5990
  spanId: parentObject.data.span_id,
5991
5991
  rootSpanId: parentObject.data.root_span_id
@@ -318,6 +318,69 @@ interface Score {
318
318
  error?: unknown;
319
319
  }
320
320
 
321
+ declare const spanComponentsV4Schema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
322
+ object_type: z.ZodNativeEnum<typeof SpanObjectTypeV3>;
323
+ propagated_event: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
324
+ }, "strip", z.ZodTypeAny, {
325
+ object_type: SpanObjectTypeV3;
326
+ propagated_event?: Record<string, unknown> | null | undefined;
327
+ }, {
328
+ object_type: SpanObjectTypeV3;
329
+ propagated_event?: Record<string, unknown> | null | undefined;
330
+ }>, z.ZodUnion<[z.ZodObject<{
331
+ object_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
332
+ compute_object_metadata_args: z.ZodOptional<z.ZodNull>;
333
+ }, "strip", z.ZodTypeAny, {
334
+ object_id?: string | null | undefined;
335
+ compute_object_metadata_args?: null | undefined;
336
+ }, {
337
+ object_id?: string | null | undefined;
338
+ compute_object_metadata_args?: null | undefined;
339
+ }>, z.ZodObject<{
340
+ object_id: z.ZodOptional<z.ZodNull>;
341
+ compute_object_metadata_args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
342
+ }, "strip", z.ZodTypeAny, {
343
+ compute_object_metadata_args: Record<string, unknown>;
344
+ object_id?: null | undefined;
345
+ }, {
346
+ compute_object_metadata_args: Record<string, unknown>;
347
+ object_id?: null | undefined;
348
+ }>]>>, z.ZodUnion<[z.ZodObject<{
349
+ row_id: z.ZodString;
350
+ span_id: z.ZodString;
351
+ root_span_id: z.ZodString;
352
+ }, "strip", z.ZodTypeAny, {
353
+ span_id: string;
354
+ root_span_id: string;
355
+ row_id: string;
356
+ }, {
357
+ span_id: string;
358
+ root_span_id: string;
359
+ row_id: string;
360
+ }>, z.ZodObject<{
361
+ row_id: z.ZodOptional<z.ZodNull>;
362
+ span_id: z.ZodOptional<z.ZodNull>;
363
+ root_span_id: z.ZodOptional<z.ZodNull>;
364
+ }, "strip", z.ZodTypeAny, {
365
+ span_id?: null | undefined;
366
+ root_span_id?: null | undefined;
367
+ row_id?: null | undefined;
368
+ }, {
369
+ span_id?: null | undefined;
370
+ root_span_id?: null | undefined;
371
+ row_id?: null | undefined;
372
+ }>]>>;
373
+ type SpanComponentsV4Data = z.infer<typeof spanComponentsV4Schema>;
374
+ declare class SpanComponentsV4 {
375
+ data: SpanComponentsV4Data;
376
+ constructor(data: SpanComponentsV4Data);
377
+ toStr(): string;
378
+ static fromStr(s: string): SpanComponentsV4;
379
+ objectIdFields(): ParentExperimentIds | ParentProjectLogIds | ParentPlaygroundLogIds;
380
+ export(): Promise<string>;
381
+ private static fromJsonObj;
382
+ }
383
+
321
384
  declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
322
385
  type SpanType = (typeof spanTypeAttributeValues)[number];
323
386
 
@@ -8919,7 +8982,7 @@ declare function currentSpan(options?: OptionalStateArg): Span;
8919
8982
  */
8920
8983
  declare function getSpanParentObject<IsAsyncFlush extends boolean>(options?: AsyncFlushArg<IsAsyncFlush> & OptionalStateArg & {
8921
8984
  parent?: string;
8922
- }): SpanComponentsV3 | Span | Experiment | Logger<IsAsyncFlush>;
8985
+ }): SpanComponentsV3 | SpanComponentsV4 | Span | Experiment | Logger<IsAsyncFlush>;
8923
8986
  declare function logError(span: Span, error: unknown): void;
8924
8987
  /**
8925
8988
  * Toplevel function for starting a span. It checks the following (in precedence order):
package/dist/browser.d.ts CHANGED
@@ -318,6 +318,69 @@ interface Score {
318
318
  error?: unknown;
319
319
  }
320
320
 
321
+ declare const spanComponentsV4Schema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
322
+ object_type: z.ZodNativeEnum<typeof SpanObjectTypeV3>;
323
+ propagated_event: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
324
+ }, "strip", z.ZodTypeAny, {
325
+ object_type: SpanObjectTypeV3;
326
+ propagated_event?: Record<string, unknown> | null | undefined;
327
+ }, {
328
+ object_type: SpanObjectTypeV3;
329
+ propagated_event?: Record<string, unknown> | null | undefined;
330
+ }>, z.ZodUnion<[z.ZodObject<{
331
+ object_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
332
+ compute_object_metadata_args: z.ZodOptional<z.ZodNull>;
333
+ }, "strip", z.ZodTypeAny, {
334
+ object_id?: string | null | undefined;
335
+ compute_object_metadata_args?: null | undefined;
336
+ }, {
337
+ object_id?: string | null | undefined;
338
+ compute_object_metadata_args?: null | undefined;
339
+ }>, z.ZodObject<{
340
+ object_id: z.ZodOptional<z.ZodNull>;
341
+ compute_object_metadata_args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
342
+ }, "strip", z.ZodTypeAny, {
343
+ compute_object_metadata_args: Record<string, unknown>;
344
+ object_id?: null | undefined;
345
+ }, {
346
+ compute_object_metadata_args: Record<string, unknown>;
347
+ object_id?: null | undefined;
348
+ }>]>>, z.ZodUnion<[z.ZodObject<{
349
+ row_id: z.ZodString;
350
+ span_id: z.ZodString;
351
+ root_span_id: z.ZodString;
352
+ }, "strip", z.ZodTypeAny, {
353
+ span_id: string;
354
+ root_span_id: string;
355
+ row_id: string;
356
+ }, {
357
+ span_id: string;
358
+ root_span_id: string;
359
+ row_id: string;
360
+ }>, z.ZodObject<{
361
+ row_id: z.ZodOptional<z.ZodNull>;
362
+ span_id: z.ZodOptional<z.ZodNull>;
363
+ root_span_id: z.ZodOptional<z.ZodNull>;
364
+ }, "strip", z.ZodTypeAny, {
365
+ span_id?: null | undefined;
366
+ root_span_id?: null | undefined;
367
+ row_id?: null | undefined;
368
+ }, {
369
+ span_id?: null | undefined;
370
+ root_span_id?: null | undefined;
371
+ row_id?: null | undefined;
372
+ }>]>>;
373
+ type SpanComponentsV4Data = z.infer<typeof spanComponentsV4Schema>;
374
+ declare class SpanComponentsV4 {
375
+ data: SpanComponentsV4Data;
376
+ constructor(data: SpanComponentsV4Data);
377
+ toStr(): string;
378
+ static fromStr(s: string): SpanComponentsV4;
379
+ objectIdFields(): ParentExperimentIds | ParentProjectLogIds | ParentPlaygroundLogIds;
380
+ export(): Promise<string>;
381
+ private static fromJsonObj;
382
+ }
383
+
321
384
  declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
322
385
  type SpanType = (typeof spanTypeAttributeValues)[number];
323
386
 
@@ -8919,7 +8982,7 @@ declare function currentSpan(options?: OptionalStateArg): Span;
8919
8982
  */
8920
8983
  declare function getSpanParentObject<IsAsyncFlush extends boolean>(options?: AsyncFlushArg<IsAsyncFlush> & OptionalStateArg & {
8921
8984
  parent?: string;
8922
- }): SpanComponentsV3 | Span | Experiment | Logger<IsAsyncFlush>;
8985
+ }): SpanComponentsV3 | SpanComponentsV4 | Span | Experiment | Logger<IsAsyncFlush>;
8923
8986
  declare function logError(span: Span, error: unknown): void;
8924
8987
  /**
8925
8988
  * Toplevel function for starting a span. It checks the following (in precedence order):
package/dist/browser.js CHANGED
@@ -5391,7 +5391,7 @@ function updateSpan({
5391
5391
  ...event
5392
5392
  }) {
5393
5393
  const resolvedState = _nullishCoalesce(state, () => ( _globalState));
5394
- const components = SpanComponentsV3.fromStr(exported);
5394
+ const components = getSpanComponentsClass().fromStr(exported);
5395
5395
  if (!components.data.row_id) {
5396
5396
  throw new Error("Exported span must have a row id");
5397
5397
  }
@@ -5474,7 +5474,7 @@ async function permalink(slug, opts) {
5474
5474
  return state.appUrl;
5475
5475
  };
5476
5476
  try {
5477
- const components = SpanComponentsV3.fromStr(slug);
5477
+ const components = getSpanComponentsClass().fromStr(slug);
5478
5478
  const object_type = spanObjectTypeV3ToString(components.data.object_type);
5479
5479
  const [orgName, appUrl, object_id] = await Promise.all([
5480
5480
  getOrgName(),
@@ -5502,7 +5502,7 @@ function startSpanParentArgs(args) {
5502
5502
  if (args.parentSpanIds) {
5503
5503
  throw new Error("Cannot specify both parent and parentSpanIds");
5504
5504
  }
5505
- const parentComponents = SpanComponentsV3.fromStr(args.parent);
5505
+ const parentComponents = getSpanComponentsClass().fromStr(args.parent);
5506
5506
  if (args.parentObjectType !== parentComponents.data.object_type) {
5507
5507
  throw new Error(
5508
5508
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -6164,7 +6164,7 @@ function getSpanParentObject(options) {
6164
6164
  return parentSpan;
6165
6165
  }
6166
6166
  const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.parent]), () => ( state.currentParent.getStore()));
6167
- if (parentStr) return SpanComponentsV3.fromStr(parentStr);
6167
+ if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
6168
6168
  const experiment = currentExperiment();
6169
6169
  if (experiment) {
6170
6170
  return experiment;
@@ -6385,7 +6385,7 @@ function startSpanAndIsLogger(args) {
6385
6385
  parent: _optionalChain([args, 'optionalAccess', _52 => _52.parent]),
6386
6386
  state
6387
6387
  });
6388
- if (parentObject instanceof SpanComponentsV3) {
6388
+ if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
6389
6389
  const parentSpanIds = parentObject.data.row_id ? {
6390
6390
  spanId: parentObject.data.span_id,
6391
6391
  rootSpanId: parentObject.data.root_span_id
package/dist/browser.mjs CHANGED
@@ -5391,7 +5391,7 @@ function updateSpan({
5391
5391
  ...event
5392
5392
  }) {
5393
5393
  const resolvedState = state ?? _globalState;
5394
- const components = SpanComponentsV3.fromStr(exported);
5394
+ const components = getSpanComponentsClass().fromStr(exported);
5395
5395
  if (!components.data.row_id) {
5396
5396
  throw new Error("Exported span must have a row id");
5397
5397
  }
@@ -5474,7 +5474,7 @@ async function permalink(slug, opts) {
5474
5474
  return state.appUrl;
5475
5475
  };
5476
5476
  try {
5477
- const components = SpanComponentsV3.fromStr(slug);
5477
+ const components = getSpanComponentsClass().fromStr(slug);
5478
5478
  const object_type = spanObjectTypeV3ToString(components.data.object_type);
5479
5479
  const [orgName, appUrl, object_id] = await Promise.all([
5480
5480
  getOrgName(),
@@ -5502,7 +5502,7 @@ function startSpanParentArgs(args) {
5502
5502
  if (args.parentSpanIds) {
5503
5503
  throw new Error("Cannot specify both parent and parentSpanIds");
5504
5504
  }
5505
- const parentComponents = SpanComponentsV3.fromStr(args.parent);
5505
+ const parentComponents = getSpanComponentsClass().fromStr(args.parent);
5506
5506
  if (args.parentObjectType !== parentComponents.data.object_type) {
5507
5507
  throw new Error(
5508
5508
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -6164,7 +6164,7 @@ function getSpanParentObject(options) {
6164
6164
  return parentSpan;
6165
6165
  }
6166
6166
  const parentStr = options?.parent ?? state.currentParent.getStore();
6167
- if (parentStr) return SpanComponentsV3.fromStr(parentStr);
6167
+ if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
6168
6168
  const experiment = currentExperiment();
6169
6169
  if (experiment) {
6170
6170
  return experiment;
@@ -6385,7 +6385,7 @@ function startSpanAndIsLogger(args) {
6385
6385
  parent: args?.parent,
6386
6386
  state
6387
6387
  });
6388
- if (parentObject instanceof SpanComponentsV3) {
6388
+ if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
6389
6389
  const parentSpanIds = parentObject.data.row_id ? {
6390
6390
  spanId: parentObject.data.span_id,
6391
6391
  rootSpanId: parentObject.data.root_span_id
package/dist/cli.js CHANGED
@@ -6686,7 +6686,7 @@ async function permalink(slug, opts) {
6686
6686
  return state.appUrl;
6687
6687
  };
6688
6688
  try {
6689
- const components = SpanComponentsV3.fromStr(slug);
6689
+ const components = getSpanComponentsClass().fromStr(slug);
6690
6690
  const object_type = spanObjectTypeV3ToString(components.data.object_type);
6691
6691
  const [orgName, appUrl, object_id] = await Promise.all([
6692
6692
  getOrgName(),
@@ -6714,7 +6714,7 @@ function startSpanParentArgs(args) {
6714
6714
  if (args.parentSpanIds) {
6715
6715
  throw new Error("Cannot specify both parent and parentSpanIds");
6716
6716
  }
6717
- const parentComponents = SpanComponentsV3.fromStr(args.parent);
6717
+ const parentComponents = getSpanComponentsClass().fromStr(args.parent);
6718
6718
  if (args.parentObjectType !== parentComponents.data.object_type) {
6719
6719
  throw new Error(
6720
6720
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -7158,7 +7158,7 @@ function getSpanParentObject(options) {
7158
7158
  return parentSpan;
7159
7159
  }
7160
7160
  const parentStr = options?.parent ?? state.currentParent.getStore();
7161
- if (parentStr) return SpanComponentsV3.fromStr(parentStr);
7161
+ if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
7162
7162
  const experiment = currentExperiment();
7163
7163
  if (experiment) {
7164
7164
  return experiment;
@@ -7224,7 +7224,7 @@ function startSpanAndIsLogger(args) {
7224
7224
  parent: args?.parent,
7225
7225
  state
7226
7226
  });
7227
- if (parentObject instanceof SpanComponentsV3) {
7227
+ if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
7228
7228
  const parentSpanIds = parentObject.data.row_id ? {
7229
7229
  spanId: parentObject.data.span_id,
7230
7230
  rootSpanId: parentObject.data.root_span_id
@@ -10228,7 +10228,7 @@ var require_package = __commonJS({
10228
10228
  "package.json"(exports2, module2) {
10229
10229
  module2.exports = {
10230
10230
  name: "braintrust",
10231
- version: "0.4.4",
10231
+ version: "0.4.5",
10232
10232
  description: "SDK for integrating Braintrust",
10233
10233
  repository: {
10234
10234
  type: "git",
package/dist/index.d.mts CHANGED
@@ -329,6 +329,69 @@ interface Score {
329
329
  error?: unknown;
330
330
  }
331
331
 
332
+ declare const spanComponentsV4Schema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
333
+ object_type: z.ZodNativeEnum<typeof SpanObjectTypeV3>;
334
+ propagated_event: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
335
+ }, "strip", z.ZodTypeAny, {
336
+ object_type: SpanObjectTypeV3;
337
+ propagated_event?: Record<string, unknown> | null | undefined;
338
+ }, {
339
+ object_type: SpanObjectTypeV3;
340
+ propagated_event?: Record<string, unknown> | null | undefined;
341
+ }>, z.ZodUnion<[z.ZodObject<{
342
+ object_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
343
+ compute_object_metadata_args: z.ZodOptional<z.ZodNull>;
344
+ }, "strip", z.ZodTypeAny, {
345
+ object_id?: string | null | undefined;
346
+ compute_object_metadata_args?: null | undefined;
347
+ }, {
348
+ object_id?: string | null | undefined;
349
+ compute_object_metadata_args?: null | undefined;
350
+ }>, z.ZodObject<{
351
+ object_id: z.ZodOptional<z.ZodNull>;
352
+ compute_object_metadata_args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
353
+ }, "strip", z.ZodTypeAny, {
354
+ compute_object_metadata_args: Record<string, unknown>;
355
+ object_id?: null | undefined;
356
+ }, {
357
+ compute_object_metadata_args: Record<string, unknown>;
358
+ object_id?: null | undefined;
359
+ }>]>>, z.ZodUnion<[z.ZodObject<{
360
+ row_id: z.ZodString;
361
+ span_id: z.ZodString;
362
+ root_span_id: z.ZodString;
363
+ }, "strip", z.ZodTypeAny, {
364
+ span_id: string;
365
+ root_span_id: string;
366
+ row_id: string;
367
+ }, {
368
+ span_id: string;
369
+ root_span_id: string;
370
+ row_id: string;
371
+ }>, z.ZodObject<{
372
+ row_id: z.ZodOptional<z.ZodNull>;
373
+ span_id: z.ZodOptional<z.ZodNull>;
374
+ root_span_id: z.ZodOptional<z.ZodNull>;
375
+ }, "strip", z.ZodTypeAny, {
376
+ span_id?: null | undefined;
377
+ root_span_id?: null | undefined;
378
+ row_id?: null | undefined;
379
+ }, {
380
+ span_id?: null | undefined;
381
+ root_span_id?: null | undefined;
382
+ row_id?: null | undefined;
383
+ }>]>>;
384
+ type SpanComponentsV4Data = z.infer<typeof spanComponentsV4Schema>;
385
+ declare class SpanComponentsV4 {
386
+ data: SpanComponentsV4Data;
387
+ constructor(data: SpanComponentsV4Data);
388
+ toStr(): string;
389
+ static fromStr(s: string): SpanComponentsV4;
390
+ objectIdFields(): ParentExperimentIds | ParentProjectLogIds | ParentPlaygroundLogIds;
391
+ export(): Promise<string>;
392
+ private static fromJsonObj;
393
+ }
394
+
332
395
  declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
333
396
  type SpanType = (typeof spanTypeAttributeValues)[number];
334
397
 
@@ -15368,7 +15431,7 @@ declare function currentSpan(options?: OptionalStateArg): Span$1;
15368
15431
  */
15369
15432
  declare function getSpanParentObject<IsAsyncFlush extends boolean>(options?: AsyncFlushArg<IsAsyncFlush> & OptionalStateArg & {
15370
15433
  parent?: string;
15371
- }): SpanComponentsV3 | Span$1 | Experiment | Logger<IsAsyncFlush>;
15434
+ }): SpanComponentsV3 | SpanComponentsV4 | Span$1 | Experiment | Logger<IsAsyncFlush>;
15372
15435
  declare function logError(span: Span$1, error: unknown): void;
15373
15436
  /**
15374
15437
  * Toplevel function for starting a span. It checks the following (in precedence order):
package/dist/index.d.ts CHANGED
@@ -329,6 +329,69 @@ interface Score {
329
329
  error?: unknown;
330
330
  }
331
331
 
332
+ declare const spanComponentsV4Schema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
333
+ object_type: z.ZodNativeEnum<typeof SpanObjectTypeV3>;
334
+ propagated_event: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
335
+ }, "strip", z.ZodTypeAny, {
336
+ object_type: SpanObjectTypeV3;
337
+ propagated_event?: Record<string, unknown> | null | undefined;
338
+ }, {
339
+ object_type: SpanObjectTypeV3;
340
+ propagated_event?: Record<string, unknown> | null | undefined;
341
+ }>, z.ZodUnion<[z.ZodObject<{
342
+ object_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
343
+ compute_object_metadata_args: z.ZodOptional<z.ZodNull>;
344
+ }, "strip", z.ZodTypeAny, {
345
+ object_id?: string | null | undefined;
346
+ compute_object_metadata_args?: null | undefined;
347
+ }, {
348
+ object_id?: string | null | undefined;
349
+ compute_object_metadata_args?: null | undefined;
350
+ }>, z.ZodObject<{
351
+ object_id: z.ZodOptional<z.ZodNull>;
352
+ compute_object_metadata_args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
353
+ }, "strip", z.ZodTypeAny, {
354
+ compute_object_metadata_args: Record<string, unknown>;
355
+ object_id?: null | undefined;
356
+ }, {
357
+ compute_object_metadata_args: Record<string, unknown>;
358
+ object_id?: null | undefined;
359
+ }>]>>, z.ZodUnion<[z.ZodObject<{
360
+ row_id: z.ZodString;
361
+ span_id: z.ZodString;
362
+ root_span_id: z.ZodString;
363
+ }, "strip", z.ZodTypeAny, {
364
+ span_id: string;
365
+ root_span_id: string;
366
+ row_id: string;
367
+ }, {
368
+ span_id: string;
369
+ root_span_id: string;
370
+ row_id: string;
371
+ }>, z.ZodObject<{
372
+ row_id: z.ZodOptional<z.ZodNull>;
373
+ span_id: z.ZodOptional<z.ZodNull>;
374
+ root_span_id: z.ZodOptional<z.ZodNull>;
375
+ }, "strip", z.ZodTypeAny, {
376
+ span_id?: null | undefined;
377
+ root_span_id?: null | undefined;
378
+ row_id?: null | undefined;
379
+ }, {
380
+ span_id?: null | undefined;
381
+ root_span_id?: null | undefined;
382
+ row_id?: null | undefined;
383
+ }>]>>;
384
+ type SpanComponentsV4Data = z.infer<typeof spanComponentsV4Schema>;
385
+ declare class SpanComponentsV4 {
386
+ data: SpanComponentsV4Data;
387
+ constructor(data: SpanComponentsV4Data);
388
+ toStr(): string;
389
+ static fromStr(s: string): SpanComponentsV4;
390
+ objectIdFields(): ParentExperimentIds | ParentProjectLogIds | ParentPlaygroundLogIds;
391
+ export(): Promise<string>;
392
+ private static fromJsonObj;
393
+ }
394
+
332
395
  declare const spanTypeAttributeValues: readonly ["llm", "score", "function", "eval", "task", "tool"];
333
396
  type SpanType = (typeof spanTypeAttributeValues)[number];
334
397
 
@@ -15368,7 +15431,7 @@ declare function currentSpan(options?: OptionalStateArg): Span$1;
15368
15431
  */
15369
15432
  declare function getSpanParentObject<IsAsyncFlush extends boolean>(options?: AsyncFlushArg<IsAsyncFlush> & OptionalStateArg & {
15370
15433
  parent?: string;
15371
- }): SpanComponentsV3 | Span$1 | Experiment | Logger<IsAsyncFlush>;
15434
+ }): SpanComponentsV3 | SpanComponentsV4 | Span$1 | Experiment | Logger<IsAsyncFlush>;
15372
15435
  declare function logError(span: Span$1, error: unknown): void;
15373
15436
  /**
15374
15437
  * Toplevel function for starting a span. It checks the following (in precedence order):
package/dist/index.js CHANGED
@@ -5412,7 +5412,7 @@ function updateSpan({
5412
5412
  ...event
5413
5413
  }) {
5414
5414
  const resolvedState = _nullishCoalesce(state, () => ( _globalState));
5415
- const components = SpanComponentsV3.fromStr(exported);
5415
+ const components = getSpanComponentsClass().fromStr(exported);
5416
5416
  if (!components.data.row_id) {
5417
5417
  throw new Error("Exported span must have a row id");
5418
5418
  }
@@ -5495,7 +5495,7 @@ async function permalink(slug, opts) {
5495
5495
  return state.appUrl;
5496
5496
  };
5497
5497
  try {
5498
- const components = SpanComponentsV3.fromStr(slug);
5498
+ const components = getSpanComponentsClass().fromStr(slug);
5499
5499
  const object_type = spanObjectTypeV3ToString(components.data.object_type);
5500
5500
  const [orgName, appUrl, object_id] = await Promise.all([
5501
5501
  getOrgName(),
@@ -5523,7 +5523,7 @@ function startSpanParentArgs(args) {
5523
5523
  if (args.parentSpanIds) {
5524
5524
  throw new Error("Cannot specify both parent and parentSpanIds");
5525
5525
  }
5526
- const parentComponents = SpanComponentsV3.fromStr(args.parent);
5526
+ const parentComponents = getSpanComponentsClass().fromStr(args.parent);
5527
5527
  if (args.parentObjectType !== parentComponents.data.object_type) {
5528
5528
  throw new Error(
5529
5529
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -6185,7 +6185,7 @@ function getSpanParentObject(options) {
6185
6185
  return parentSpan;
6186
6186
  }
6187
6187
  const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.parent]), () => ( state.currentParent.getStore()));
6188
- if (parentStr) return SpanComponentsV3.fromStr(parentStr);
6188
+ if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
6189
6189
  const experiment = currentExperiment();
6190
6190
  if (experiment) {
6191
6191
  return experiment;
@@ -6406,7 +6406,7 @@ function startSpanAndIsLogger(args) {
6406
6406
  parent: _optionalChain([args, 'optionalAccess', _52 => _52.parent]),
6407
6407
  state
6408
6408
  });
6409
- if (parentObject instanceof SpanComponentsV3) {
6409
+ if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
6410
6410
  const parentSpanIds = parentObject.data.row_id ? {
6411
6411
  spanId: parentObject.data.span_id,
6412
6412
  rootSpanId: parentObject.data.root_span_id
package/dist/index.mjs CHANGED
@@ -5412,7 +5412,7 @@ function updateSpan({
5412
5412
  ...event
5413
5413
  }) {
5414
5414
  const resolvedState = state ?? _globalState;
5415
- const components = SpanComponentsV3.fromStr(exported);
5415
+ const components = getSpanComponentsClass().fromStr(exported);
5416
5416
  if (!components.data.row_id) {
5417
5417
  throw new Error("Exported span must have a row id");
5418
5418
  }
@@ -5495,7 +5495,7 @@ async function permalink(slug, opts) {
5495
5495
  return state.appUrl;
5496
5496
  };
5497
5497
  try {
5498
- const components = SpanComponentsV3.fromStr(slug);
5498
+ const components = getSpanComponentsClass().fromStr(slug);
5499
5499
  const object_type = spanObjectTypeV3ToString(components.data.object_type);
5500
5500
  const [orgName, appUrl, object_id] = await Promise.all([
5501
5501
  getOrgName(),
@@ -5523,7 +5523,7 @@ function startSpanParentArgs(args) {
5523
5523
  if (args.parentSpanIds) {
5524
5524
  throw new Error("Cannot specify both parent and parentSpanIds");
5525
5525
  }
5526
- const parentComponents = SpanComponentsV3.fromStr(args.parent);
5526
+ const parentComponents = getSpanComponentsClass().fromStr(args.parent);
5527
5527
  if (args.parentObjectType !== parentComponents.data.object_type) {
5528
5528
  throw new Error(
5529
5529
  `Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
@@ -6185,7 +6185,7 @@ function getSpanParentObject(options) {
6185
6185
  return parentSpan;
6186
6186
  }
6187
6187
  const parentStr = options?.parent ?? state.currentParent.getStore();
6188
- if (parentStr) return SpanComponentsV3.fromStr(parentStr);
6188
+ if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
6189
6189
  const experiment = currentExperiment();
6190
6190
  if (experiment) {
6191
6191
  return experiment;
@@ -6406,7 +6406,7 @@ function startSpanAndIsLogger(args) {
6406
6406
  parent: args?.parent,
6407
6407
  state
6408
6408
  });
6409
- if (parentObject instanceof SpanComponentsV3) {
6409
+ if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
6410
6410
  const parentSpanIds = parentObject.data.row_id ? {
6411
6411
  spanId: parentObject.data.span_id,
6412
6412
  rootSpanId: parentObject.data.root_span_id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braintrust",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "SDK for integrating Braintrust",
5
5
  "repository": {
6
6
  "type": "git",