@mastra/duckdb 1.16.0-alpha.2 → 1.16.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.
@@ -3,7 +3,7 @@ name: mastra-duckdb
3
3
  description: Documentation for @mastra/duckdb. Use when working with @mastra/duckdb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/duckdb"
6
- version: "1.16.0-alpha.2"
6
+ version: "1.16.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.16.0-alpha.2",
2
+ "version": "1.16.0",
3
3
  "package": "@mastra/duckdb",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -564,7 +564,7 @@ var ObservabilityStorageDuckDB = class extends _mastra_core_storage.Observabilit
564
564
  async loadDelegate() {
565
565
  if (this.delegate) return this.delegate;
566
566
  if (this.unavailableError) return null;
567
- if (!this.loadPromise) this.loadPromise = Promise.resolve().then(() => require("./observability-B-Vnz-ZL.cjs")).then(({ ObservabilityStorageDuckDB }) => {
567
+ if (!this.loadPromise) this.loadPromise = Promise.resolve().then(() => require("./observability-BEdkwaeY.cjs")).then(({ ObservabilityStorageDuckDB }) => {
568
568
  const delegate = new ObservabilityStorageDuckDB({ db: this.db });
569
569
  this.delegate = delegate;
570
570
  return delegate;
package/dist/index.js CHANGED
@@ -563,7 +563,7 @@ var ObservabilityStorageDuckDB = class extends ObservabilityStorage {
563
563
  async loadDelegate() {
564
564
  if (this.delegate) return this.delegate;
565
565
  if (this.unavailableError) return null;
566
- if (!this.loadPromise) this.loadPromise = import("./observability-BWSYzhM2.js").then(({ ObservabilityStorageDuckDB }) => {
566
+ if (!this.loadPromise) this.loadPromise = import("./observability-B-Kt8vrw.js").then(({ ObservabilityStorageDuckDB }) => {
567
567
  const delegate = new ObservabilityStorageDuckDB({ db: this.db });
568
568
  this.delegate = delegate;
569
569
  return delegate;
@@ -1,7 +1,7 @@
1
1
  import { a as timeToFirstChunkSupported, i as timeToFirstChunkFeatures, n as spanQueryFeatures, o as DuckDBConnection, s as DuckDBQueryTimeoutError, t as spanAggregateFeatures } from "./features-B8gl38Ue.js";
2
2
  import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
3
3
  import * as coreStorage from "@mastra/core/storage";
4
- import { BRANCH_SPAN_TYPES, METRIC_DISTINCT_COLUMNS, ObservabilityStorage, computeTraceStatus, createStorageErrorId, executeRetentionPrune, feedbackRecordSchema, listBranchesArgsSchema, listFeedbackArgsSchema, listLogsArgsSchema, listMetricsArgsSchema, listScoresArgsSchema, listTracesArgsSchema, resolveRetentionTargets, retentionCutoffMs, toTraceSpans } from "@mastra/core/storage";
4
+ import { BRANCH_SPAN_TYPES, METRIC_DISTINCT_COLUMNS, ObservabilityStorage, computeTraceStatus, createStorageErrorId, executeRetentionPrune, feedbackRecordSchema, getStringAttribute, listBranchesArgsSchema, listFeedbackArgsSchema, listLogsArgsSchema, listMetricsArgsSchema, listScoresArgsSchema, listTracesArgsSchema, resolveRetentionTargets, retentionCutoffMs, toTraceSpans } from "@mastra/core/storage";
5
5
  import { coreFeatures } from "@mastra/core/features";
6
6
  import { EntityType } from "@mastra/core/observability";
7
7
  import { parseFieldKey } from "@mastra/core/utils";
@@ -106,6 +106,17 @@ CREATE TABLE IF NOT EXISTS span_events (
106
106
  endedAt TIMESTAMP,
107
107
  timeToFirstChunkMs DOUBLE,
108
108
 
109
+ -- Native span fields, stored as supplied (NULL when the producer set none)
110
+ externalParentSpanId VARCHAR,
111
+ resumedFromSpanId VARCHAR,
112
+ model VARCHAR,
113
+ provider VARCHAR,
114
+ outcome VARCHAR,
115
+ stopReason VARCHAR,
116
+ timeToFirstTokenMs DOUBLE,
117
+ errorCount INTEGER,
118
+ stopReasonContext JSON,
119
+
109
120
  -- JSON fields
110
121
  attributes JSON,
111
122
  metadata JSON,
@@ -377,6 +388,15 @@ const ALL_MIGRATIONS = [
377
388
  `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS hasOutputPayload BOOLEAN`,
378
389
  `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS hasErrorPayload BOOLEAN`,
379
390
  `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS timeToFirstChunkMs DOUBLE`,
391
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS externalParentSpanId VARCHAR`,
392
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS resumedFromSpanId VARCHAR`,
393
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS model VARCHAR`,
394
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS provider VARCHAR`,
395
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS outcome VARCHAR`,
396
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS stopReason VARCHAR`,
397
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS timeToFirstTokenMs DOUBLE`,
398
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS errorCount INTEGER`,
399
+ `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS stopReasonContext JSON`,
380
400
  `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS parentEntityType VARCHAR`,
381
401
  `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS parentEntityId VARCHAR`,
382
402
  `ALTER TABLE span_events ADD COLUMN IF NOT EXISTS parentEntityName VARCHAR`,
@@ -4782,6 +4802,15 @@ const COLUMNS_SQL = [
4782
4802
  "isEvent",
4783
4803
  "endedAt",
4784
4804
  "timeToFirstChunkMs",
4805
+ "externalParentSpanId",
4806
+ "resumedFromSpanId",
4807
+ "model",
4808
+ "provider",
4809
+ "outcome",
4810
+ "stopReason",
4811
+ "timeToFirstTokenMs",
4812
+ "errorCount",
4813
+ "stopReasonContext",
4785
4814
  "experimentId",
4786
4815
  "entityType",
4787
4816
  "entityId",
@@ -4897,7 +4926,16 @@ const SPAN_RECONSTRUCT_SELECT = `
4897
4926
  ${argMaxNonNull("input")},
4898
4927
  ${argMaxNonNull("output")},
4899
4928
  ${argMaxNonNull("error")},
4900
- ${argMaxNonNull("requestContext")}
4929
+ ${argMaxNonNull("requestContext")},
4930
+ ${argMaxNonNull("externalParentSpanId")},
4931
+ ${argMaxNonNull("resumedFromSpanId")},
4932
+ ${argMaxNonNull("model")},
4933
+ ${argMaxNonNull("provider")},
4934
+ ${argMaxNonNull("outcome")},
4935
+ ${argMaxNonNull("stopReason")},
4936
+ ${argMaxNonNull("timeToFirstTokenMs")},
4937
+ ${argMaxNonNull("errorCount")},
4938
+ ${argMaxNonNull("stopReasonContext")}
4901
4939
  FROM span_events
4902
4940
  `;
4903
4941
  /** Lightweight variant — only timeline-relevant columns. */
@@ -5093,6 +5131,7 @@ function rowToLightSpanRecordWithPreview(row) {
5093
5131
  };
5094
5132
  }
5095
5133
  function rowToSpanRecord(row) {
5134
+ const attributes = parseJson(row.attributes);
5096
5135
  return {
5097
5136
  traceId: row.traceId,
5098
5137
  spanId: row.spanId,
@@ -5102,6 +5141,15 @@ function rowToSpanRecord(row) {
5102
5141
  isEvent: row.isEvent,
5103
5142
  startedAt: toDate(row.startedAt),
5104
5143
  endedAt: rowEndedAt(row),
5144
+ externalParentSpanId: row.externalParentSpanId ?? null,
5145
+ resumedFromSpanId: row.resumedFromSpanId ?? null,
5146
+ model: row.model ?? getStringAttribute(attributes, "model"),
5147
+ provider: row.provider ?? getStringAttribute(attributes, "provider"),
5148
+ outcome: row.outcome ?? null,
5149
+ stopReason: row.stopReason ?? null,
5150
+ timeToFirstTokenMs: row.timeToFirstTokenMs ?? null,
5151
+ errorCount: row.errorCount ?? null,
5152
+ stopReasonContext: parseJson(row.stopReasonContext),
5105
5153
  experimentId: row.experimentId ?? null,
5106
5154
  entityType: row.entityType ?? null,
5107
5155
  entityId: row.entityId ?? null,
@@ -5125,7 +5173,7 @@ function rowToSpanRecord(row) {
5125
5173
  environment: row.environment ?? null,
5126
5174
  source: row.source ?? null,
5127
5175
  serviceName: row.serviceName ?? null,
5128
- attributes: parseJson(row.attributes),
5176
+ attributes,
5129
5177
  metadata: parseJson(row.metadata),
5130
5178
  tags: parseJsonArray(row.tags),
5131
5179
  scope: parseJson(row.scope),
@@ -5288,6 +5336,15 @@ function toValuesTuple(row) {
5288
5336
  v(row.isEvent),
5289
5337
  v(row.endedAt),
5290
5338
  v(row.timeToFirstChunkMs),
5339
+ v(row.externalParentSpanId),
5340
+ v(row.resumedFromSpanId),
5341
+ v(row.model),
5342
+ v(row.provider),
5343
+ v(row.outcome),
5344
+ v(row.stopReason),
5345
+ v(row.timeToFirstTokenMs),
5346
+ v(row.errorCount),
5347
+ jsonV(row.stopReasonContext),
5291
5348
  v(row.experimentId),
5292
5349
  v(row.entityType),
5293
5350
  v(row.entityId),
@@ -5333,6 +5390,24 @@ async function insertSpanEvents(db, rows) {
5333
5390
  const tuples = rows.map((row) => `(${toValuesTuple(row)})`).join(",\n");
5334
5391
  await db.execute(`INSERT INTO span_events (${COLUMNS_SQL}) VALUES ${tuples}`);
5335
5392
  }
5393
+ /**
5394
+ * Columns copied as supplied onto both event rows (NULL when unset). Previews
5395
+ * stay out: the start row derives them from the payload it keeps.
5396
+ */
5397
+ function copiedSpanColumns(s) {
5398
+ return {
5399
+ timeToFirstChunkMs: s.timeToFirstChunkMs ?? null,
5400
+ externalParentSpanId: s.externalParentSpanId ?? null,
5401
+ resumedFromSpanId: s.resumedFromSpanId ?? null,
5402
+ model: s.model ?? null,
5403
+ provider: s.provider ?? null,
5404
+ outcome: s.outcome ?? null,
5405
+ stopReason: s.stopReason ?? null,
5406
+ timeToFirstTokenMs: s.timeToFirstTokenMs ?? null,
5407
+ errorCount: s.errorCount ?? null,
5408
+ stopReasonContext: s.stopReasonContext ?? null
5409
+ };
5410
+ }
5336
5411
  function createStartSpanRow(s) {
5337
5412
  const payloadOnEndRow = !!s.endedAt && !s.isEvent;
5338
5413
  const input = previewOf(!payloadOnEndRow, s.input, s.inputPreview);
@@ -5346,7 +5421,7 @@ function createStartSpanRow(s) {
5346
5421
  spanType: s.spanType,
5347
5422
  isEvent: s.isEvent,
5348
5423
  endedAt: s.isEvent ? s.startedAt : null,
5349
- timeToFirstChunkMs: s.timeToFirstChunkMs ?? null,
5424
+ ...copiedSpanColumns(s),
5350
5425
  experimentId: s.experimentId ?? null,
5351
5426
  entityType: s.entityType ?? null,
5352
5427
  entityId: s.entityId ?? null,
@@ -5401,7 +5476,7 @@ function createEndSpanRow(s) {
5401
5476
  spanType: s.spanType,
5402
5477
  isEvent: s.isEvent,
5403
5478
  endedAt: s.endedAt ?? null,
5404
- timeToFirstChunkMs: s.timeToFirstChunkMs ?? null,
5479
+ ...copiedSpanColumns(s),
5405
5480
  experimentId: s.experimentId ?? null,
5406
5481
  entityType: s.entityType ?? null,
5407
5482
  entityId: s.entityId ?? null,
@@ -6456,4 +6531,4 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends Observ
6456
6531
  };
6457
6532
  export { ObservabilityStorageDuckDB };
6458
6533
 
6459
- //# sourceMappingURL=observability-BWSYzhM2.js.map
6534
+ //# sourceMappingURL=observability-B-Kt8vrw.js.map