@mastra/pg 1.28.0-alpha.2 → 1.28.0-alpha.4

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-pg
3
3
  description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/pg"
6
- version: "1.28.0-alpha.2"
6
+ version: "1.28.0-alpha.4"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.28.0-alpha.2",
2
+ "version": "1.28.0-alpha.4",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -35,7 +35,10 @@ The orchestration worker requires a PubSub backend that supports pull mode (e.g.
35
35
 
36
36
  ### Scheduler worker
37
37
 
38
- Polls storage for due cron schedules and publishes `workflow.start` events. It's a producer only, meaning it creates work for the orchestration worker to pick up.
38
+ Polls storage for due cron schedules and publishes a `workflow.start` event for each fire. It's a producer only, meaning it creates work for the orchestration worker to pick up:
39
+
40
+ - **Split processes**: Scheduled workflows run on the evented engine, and the orchestration worker runs each fire step by step.
41
+ - **In-process mode**: Scheduled workflows run on the default engine. The orchestration worker in the same process runs each fire in-process, the same way a direct `run.start()` does.
39
42
 
40
43
  The scheduler reads declarative `schedule` fields from your workflow definitions automatically. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows) for how to declare schedules.
41
44
 
@@ -132,6 +135,8 @@ You can also pass a worker name to the CLI. The command sets `MASTRA_WORKERS` in
132
135
  mastra worker start orchestration
133
136
  ```
134
137
 
138
+ Set `MASTRA_WORKERS` on every process in a split deployment, including `false` on the API process. Any value switches workflows that declare `schedule` to the evented engine, and every process must run those workflows on the same engine. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows). `mastra worker start` without a worker name doesn't set `MASTRA_WORKERS`, so pass a name or set the variable in the process environment.
139
+
135
140
  ## Network architecture
136
141
 
137
142
  Workers are internal infrastructure. They're not exposed to end users and don't need their own subdomain or public URL, including an inbound HTTP route.
@@ -142,7 +147,7 @@ In a split deployment:
142
147
  - **Workers connect outbound only**: They pull events from the distributed PubSub backend and read/write to the shared storage database. They don't accept inbound traffic from clients.
143
148
  - **The orchestration worker calls the API internally**: It sends step execution requests to the API over the container network using `MASTRA_STEP_EXECUTION_URL`. This is internal service-to-service communication, not a public endpoint.
144
149
 
145
- All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients. HTTP routes for worker-related features run on the API server rather than the worker process. One example is token minting for a voice integration.
150
+ All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients. HTTP routes for worker-related features run on the API server rather than the worker process. One example is creating a token for a voice integration.
146
151
 
147
152
  ## Deploy split workers
148
153
 
@@ -202,7 +202,7 @@ async function retentionTick() {
202
202
  }
203
203
  ```
204
204
 
205
- You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`, so the next run resumes cleanly.
205
+ You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`. The next run resumes cleanly.
206
206
 
207
207
  ## ClickHouse native TTL
208
208
 
package/dist/index.cjs CHANGED
@@ -482,14 +482,8 @@ function buildDeleteFilterQuery(filter) {
482
482
  const joined = value.map((f) => {
483
483
  const entries = Object.entries(f || {});
484
484
  if (entries.length === 0) return "";
485
- const [firstKey, firstValue] = entries[0] || [];
486
- if ([
487
- "$and",
488
- "$or",
489
- "$not",
490
- "$nor"
491
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
492
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
485
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
486
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
493
487
  }).join(` ${joinOperator} `);
494
488
  const operatorFn = FILTER_OPERATORS[key];
495
489
  return operatorFn(joined, 0, value).sql;
@@ -573,14 +567,8 @@ function buildFilterQuery(filter, minScore, topK) {
573
567
  const joined = value.map((f) => {
574
568
  const entries = Object.entries(f || {});
575
569
  if (entries.length === 0) return "";
576
- const [firstKey, firstValue] = entries[0] || [];
577
- if ([
578
- "$and",
579
- "$or",
580
- "$not",
581
- "$nor"
582
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
583
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
570
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
571
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
584
572
  }).join(` ${joinOperator} `);
585
573
  const operatorFn = FILTER_OPERATORS[key];
586
574
  return operatorFn(joined, 0, value).sql;
@@ -17417,6 +17405,10 @@ const TRACE_FIELDS = {
17417
17405
  traceId: "r.\"traceId\"",
17418
17406
  threadId: "r.\"threadId\"",
17419
17407
  resourceId: "r.\"resourceId\"",
17408
+ runId: "r.\"runId\"",
17409
+ sessionId: "r.\"sessionId\"",
17410
+ userId: "r.\"userId\"",
17411
+ organizationId: "r.\"organizationId\"",
17420
17412
  startedAt: "r.\"startedAt\"",
17421
17413
  endedAt: "r.\"endedAt\"",
17422
17414
  durationMs: durationMsSql("r.\"startedAt\"", "r.\"endedAt\""),
@@ -17441,7 +17433,11 @@ const SPAN_FIELDS = {
17441
17433
  entityName: "s.\"entityName\"",
17442
17434
  entityVersionId: "s.\"entityVersionId\"",
17443
17435
  parentEntityVersionId: "s.\"parentEntityVersionId\"",
17444
- rootEntityVersionId: "s.\"rootEntityVersionId\""
17436
+ rootEntityVersionId: "s.\"rootEntityVersionId\"",
17437
+ runId: "s.\"runId\"",
17438
+ sessionId: "s.\"sessionId\"",
17439
+ userId: "s.\"userId\"",
17440
+ organizationId: "s.\"organizationId\""
17445
17441
  };
17446
17442
  const SCORE_FIELDS = {
17447
17443
  scorerId: "s.\"scorerId\"",
@@ -17757,7 +17753,11 @@ function compilePostgresTraceScope(schema, selection, relationCollections, scope
17757
17753
  s."entityName",
17758
17754
  s."entityVersionId",
17759
17755
  s."parentEntityVersionId",
17760
- s."rootEntityVersionId"
17756
+ s."rootEntityVersionId",
17757
+ s."runId",
17758
+ s."sessionId",
17759
+ s."userId",
17760
+ s."organizationId"
17761
17761
  FROM ${spanTable} s
17762
17762
  WHERE s."traceId" IS NOT NULL
17763
17763
  AND s."traceId" IN (SELECT "traceId" FROM root_scope)
@@ -19100,7 +19100,8 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
19100
19100
  "trace-query-discovery",
19101
19101
  "thread-query",
19102
19102
  "trace-query-tenant-scope",
19103
- "feedback"
19103
+ "feedback",
19104
+ "trace-query-context-ids"
19104
19105
  ];
19105
19106
  return [
19106
19107
  "metrics",
@@ -19117,7 +19118,8 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
19117
19118
  "trace-query-discovery",
19118
19119
  "thread-query",
19119
19120
  "trace-query-tenant-scope",
19120
- "feedback"
19121
+ "feedback",
19122
+ "trace-query-context-ids"
19121
19123
  ];
19122
19124
  }
19123
19125
  async #run(op, fn, details) {