@mastra/duckdb 1.16.0-alpha.1 → 1.16.0-alpha.2

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.1"
6
+ version: "1.16.0-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.16.0-alpha.1",
2
+ "version": "1.16.0-alpha.2",
3
3
  "package": "@mastra/duckdb",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -245,11 +245,11 @@ const results = await store.query({
245
245
 
246
246
  ## Distance metrics
247
247
 
248
- | Metric | Description | Score Interpretation | Best For |
249
- | ------------ | ----------------- | ---------------------- | ----------------------------------- |
250
- | `cosine` | Cosine similarity | 0-1 (1 = most similar) | Text embeddings, normalized vectors |
251
- | `euclidean` | L2 distance | 0-∞ (0 = most similar) | Image embeddings, spatial data |
252
- | `dotproduct` | Inner product | Higher = more similar | When vector magnitude matters |
248
+ | Metric | Description | Score Interpretation | Best For |
249
+ | ------------ | ----------------- | ------------------------------------------------------------- | ----------------------------------- |
250
+ | `cosine` | Cosine similarity | -1 to 1, computed as `1 - cosine distance` (1 = most similar) | Text embeddings, normalized vectors |
251
+ | `euclidean` | L2 distance | 0-1, computed as `1 / (1 + distance)` (1 = most similar) | Image embeddings, spatial data |
252
+ | `dotproduct` | Inner product | Higher = more similar | When vector magnitude matters |
253
253
 
254
254
  ## Error handling
255
255
 
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-Dlt85fvH.cjs")).then(({ ObservabilityStorageDuckDB }) => {
567
+ if (!this.loadPromise) this.loadPromise = Promise.resolve().then(() => require("./observability-B-Vnz-ZL.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-Chrw9Di2.js").then(({ ObservabilityStorageDuckDB }) => {
566
+ if (!this.loadPromise) this.loadPromise = import("./observability-BWSYzhM2.js").then(({ ObservabilityStorageDuckDB }) => {
567
567
  const delegate = new ObservabilityStorageDuckDB({ db: this.db });
568
568
  this.delegate = delegate;
569
569
  return delegate;
@@ -4342,7 +4342,7 @@ async function queryThreadRows(db, plan, strategy = "auto") {
4342
4342
  return `${field} ${field === "organizationId" || field === "resourceId" ? "IS NOT DISTINCT FROM" : "="} ?`;
4343
4343
  }).join(" AND ")})`;
4344
4344
  }));
4345
- const payloads = await run(`SELECT organizationId, traceId, cursorId, spanType,
4345
+ const payloads = await run(`SELECT organizationId, traceId, cursorId,
4346
4346
  ${contextFields.map((field) => field === "executionSource" ? "source AS executionSource" : field).join(", ")},
4347
4347
  CASE WHEN spanType = 'agent_run' THEN timeToFirstChunkMs END AS timeToFirstChunkMs,
4348
4348
  CASE WHEN error IS NULL THEN 'success' ELSE 'error' END AS status,
@@ -4358,34 +4358,10 @@ async function queryThreadRows(db, plan, strategy = "auto") {
4358
4358
  String(version)
4359
4359
  ]);
4360
4360
  const byRoot = new Map(payloads.map((row) => [key(row.organizationId, row.traceId, row.cursorId), row]));
4361
- const agents = page.filter((row) => byRoot.get(key(row.organizationId, row.firstTraceId, row.firstCursorId))?.spanType === "agent_run");
4362
- const models = /* @__PURE__ */ new Map();
4363
- if (agents.length) {
4364
- const modelValues = [];
4365
- const rows = await run(`WITH generations AS (
4366
- SELECT organizationId, traceId, spanId, endedAt, cursorId, attributes,
4367
- min(timestamp) FILTER (WHERE eventType = 'start') OVER (PARTITION BY organizationId, traceId, spanId) AS startedAt
4368
- FROM span_events WHERE spanType = 'model_generation' AND (${agents.map((row) => `(${Object.entries({
4369
- organizationId: row.organizationId,
4370
- resourceId: row.resourceId,
4371
- traceId: row.firstTraceId,
4372
- parentSpanId: row.firstSpanId
4373
- }).map(([field, value]) => {
4374
- modelValues.push(value);
4375
- return `${field} ${field === "organizationId" || field === "resourceId" ? "IS NOT DISTINCT FROM" : "="} ?`;
4376
- }).join(" AND ")})`).join(" OR ")})
4377
- ) SELECT organizationId, traceId,
4378
- CASE WHEN json_type(attributes, '$.model') = 'VARCHAR' THEN json_extract_string(attributes, '$.model') END AS model,
4379
- CASE WHEN json_type(attributes, '$.provider') = 'VARCHAR' THEN json_extract_string(attributes, '$.provider') END AS provider
4380
- FROM generations WHERE endedAt IS NOT NULL
4381
- QUALIFY row_number() OVER (PARTITION BY organizationId, traceId ORDER BY startedAt, spanId, cursorId DESC) = 1`, modelValues);
4382
- for (const row of rows) models.set(JSON.stringify([row.organizationId, row.traceId]), row);
4383
- }
4384
4361
  const threads = page.flatMap((row) => {
4385
4362
  const first = byRoot.get(key(row.organizationId, row.firstTraceId, row.firstCursorId));
4386
4363
  const last = byRoot.get(key(row.organizationId, row.lastTraceId, row.lastCursorId));
4387
4364
  if (!first || !last) return [];
4388
- const model = models.get(JSON.stringify([row.organizationId, row.firstTraceId]));
4389
4365
  return [_mastra_core_storage.threadQueryRowSchema.parse({
4390
4366
  organizationId: row.organizationId,
4391
4367
  threadId: row.threadId,
@@ -4397,8 +4373,6 @@ async function queryThreadRows(db, plan, strategy = "auto") {
4397
4373
  endedAt: row.endedAt.toISOString(),
4398
4374
  traceCount: Number(row.traceCount),
4399
4375
  timeToFirstChunkMs: first.timeToFirstChunkMs,
4400
- model: model?.model ?? null,
4401
- provider: model?.provider ?? null,
4402
4376
  inputPreview: readPreview(first.inputPreview, first.input, true),
4403
4377
  outputPreview: readPreview(last.outputPreview, last.output, true),
4404
4378
  errorPreview: readPreview(last.errorPreview, last.error, true)
@@ -6482,4 +6456,4 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends _mastr
6482
6456
  };
6483
6457
  exports.ObservabilityStorageDuckDB = ObservabilityStorageDuckDB;
6484
6458
 
6485
- //# sourceMappingURL=observability-Dlt85fvH.cjs.map
6459
+ //# sourceMappingURL=observability-B-Vnz-ZL.cjs.map