@trigger.dev/sdk 0.0.0-prerelease-20260908122921 → 0.0.0-prerelease-streamfix-20260909094302
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/dist/commonjs/imports/ai-runtime-cjs.cjs.map +1 -1
- package/dist/commonjs/imports/ai-runtime.js +0 -2
- package/dist/commonjs/v3/ai.d.ts +16 -199
- package/dist/commonjs/v3/ai.js +102 -983
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/chat-client.d.ts +2 -3
- package/dist/commonjs/v3/chat-client.js +5 -31
- package/dist/commonjs/v3/chat-client.js.map +1 -1
- package/dist/commonjs/v3/chat-react.d.ts +0 -34
- package/dist/commonjs/v3/chat-react.js +1 -47
- package/dist/commonjs/v3/chat-react.js.map +1 -1
- package/dist/commonjs/v3/chat-server.d.ts +6 -42
- package/dist/commonjs/v3/chat-server.js +7 -52
- package/dist/commonjs/v3/chat-server.js.map +1 -1
- package/dist/commonjs/v3/chat.d.ts +10 -81
- package/dist/commonjs/v3/chat.js +46 -292
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/sessions.d.ts +2 -15
- package/dist/commonjs/v3/sessions.js +1 -12
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.js +36 -30
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.d.ts +0 -43
- package/dist/commonjs/v3/test/mock-chat-agent.js +0 -90
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/test/test-session-handle.js +0 -6
- package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/imports/ai-runtime.d.ts +2 -2
- package/dist/esm/imports/ai-runtime.js +2 -2
- package/dist/esm/imports/ai-runtime.js.map +1 -1
- package/dist/esm/v3/ai.d.ts +16 -199
- package/dist/esm/v3/ai.js +103 -984
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/chat-client.d.ts +2 -3
- package/dist/esm/v3/chat-client.js +5 -31
- package/dist/esm/v3/chat-client.js.map +1 -1
- package/dist/esm/v3/chat-react.d.ts +0 -34
- package/dist/esm/v3/chat-react.js +1 -46
- package/dist/esm/v3/chat-react.js.map +1 -1
- package/dist/esm/v3/chat-server.d.ts +6 -42
- package/dist/esm/v3/chat-server.js +8 -53
- package/dist/esm/v3/chat-server.js.map +1 -1
- package/dist/esm/v3/chat.d.ts +10 -81
- package/dist/esm/v3/chat.js +47 -293
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/sessions.d.ts +2 -15
- package/dist/esm/v3/sessions.js +1 -11
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.js +23 -17
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.d.ts +0 -43
- package/dist/esm/v3/test/mock-chat-agent.js +2 -92
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/test/test-session-handle.js +0 -6
- package/dist/esm/v3/test/test-session-handle.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/actions.mdx +23 -55
- package/docs/ai-chat/anatomy.mdx +3 -3
- package/docs/ai-chat/backend.mdx +48 -125
- package/docs/ai-chat/background-injection.mdx +19 -67
- package/docs/ai-chat/client-protocol.mdx +4 -5
- package/docs/ai-chat/compaction.mdx +7 -11
- package/docs/ai-chat/custom-agents.mdx +0 -23
- package/docs/ai-chat/fast-starts.mdx +20 -27
- package/docs/ai-chat/frontend.mdx +14 -17
- package/docs/ai-chat/migrating-from-a-route-handler.mdx +14 -16
- package/docs/ai-chat/patterns/skills.mdx +10 -7
- package/docs/ai-chat/patterns/version-upgrades.mdx +6 -79
- package/docs/ai-chat/pending-messages.mdx +3 -3
- package/docs/ai-chat/prompt-caching.mdx +25 -23
- package/docs/ai-chat/quick-start.mdx +11 -11
- package/docs/ai-chat/reference.mdx +5 -12
- package/docs/ai-chat/sessions.mdx +1 -6
- package/docs/ai-chat/testing.mdx +1 -2
- package/docs/ai-chat/tools.mdx +13 -18
- package/docs/ai-chat/upgrade-guide.mdx +2 -2
- package/docs/apikeys.mdx +45 -27
- package/docs/deployment/overview.mdx +8 -4
- package/docs/deployment/preview-branches.mdx +4 -4
- package/docs/deployment/version-skew-protection.mdx +0 -62
- package/docs/manual-setup.mdx +7 -7
- package/docs/mcp-tools.mdx +0 -9
- package/docs/quick-start.mdx +3 -3
- package/docs/realtime/auth.mdx +1 -1
- package/docs/self-hosting/security.mdx +0 -5
- package/docs/tasks/scheduled.mdx +0 -24
- package/docs/triggering.mdx +1 -1
- package/package.json +4 -4
- package/skills/trigger-authoring-chat-agent/SKILL.md +27 -38
- package/skills/trigger-chat-agent-advanced/SKILL.md +12 -31
- package/dist/commonjs/v3/chatVersionSkew.d.ts +0 -12
- package/dist/commonjs/v3/chatVersionSkew.js +0 -30
- package/dist/commonjs/v3/chatVersionSkew.js.map +0 -1
- package/dist/commonjs/v3/externalDeploymentId.d.ts +0 -23
- package/dist/commonjs/v3/externalDeploymentId.js +0 -43
- package/dist/commonjs/v3/externalDeploymentId.js.map +0 -1
- package/dist/esm/v3/chatVersionSkew.d.ts +0 -12
- package/dist/esm/v3/chatVersionSkew.js +0 -27
- package/dist/esm/v3/chatVersionSkew.js.map +0 -1
- package/dist/esm/v3/externalDeploymentId.d.ts +0 -23
- package/dist/esm/v3/externalDeploymentId.js +0 -38
- package/dist/esm/v3/externalDeploymentId.js.map +0 -1
- package/docs/ai-chat/patterns/native-compaction.mdx +0 -310
- package/docs/reports.mdx +0 -157
- package/docs/troubleshooting-zod.mdx +0 -158
package/docs/reports.mdx
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Project health report"
|
|
3
|
-
sidebarTitle: "Health report"
|
|
4
|
-
description: "Get a deterministic verdict on your project's health — split into Flow, Execution, and Liveness — from the CLI, an MCP tool or prompt, or the HTTP API."
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
**The health report answers one question — "is my project healthy, and if not, is the problem my code or the platform?" — with a deterministic verdict, not a dashboard.** The server computes the verdict from your telemetry; no LLM interprets it, so the same numbers always produce the same answer.
|
|
8
|
-
|
|
9
|
-
Every report reads a live window of your project's data and returns a headline verdict, the evidence behind it, and a single suggested next action. The only report today is `health`.
|
|
10
|
-
|
|
11
|
-
## What the report measures
|
|
12
|
-
|
|
13
|
-
The report splits a project into three dimensions, each with its own verdict:
|
|
14
|
-
|
|
15
|
-
| Dimension | Question | What a bad verdict means |
|
|
16
|
-
| --- | --- | --- |
|
|
17
|
-
| **Flow** | Is work starting? | Runs are queuing but not being picked up — a concurrency limit, a throttle, or a trigger spike. |
|
|
18
|
-
| **Execution** | Are the runs that start succeeding? | Runs are failing or slowing more than your baseline — usually your code. |
|
|
19
|
-
| **Liveness** | Is the telemetry fresh? | The data behind the report is stale, so the verdict can't be trusted. |
|
|
20
|
-
|
|
21
|
-
Splitting Flow from Execution is the point: a project can be failing to _start_ work (Flow) while every run that does start _completes_ fine (Execution), or the reverse. The report names which one, so you know whether to look at your concurrency settings or your task code.
|
|
22
|
-
|
|
23
|
-
Each dimension carries a severity — healthy, degraded, or failing — and the report leads with the worst one as its headline. The headline finding is expanded with its supporting metrics; the others collapse to a one-line verdict.
|
|
24
|
-
|
|
25
|
-
## Reading the report
|
|
26
|
-
|
|
27
|
-
Here is `trigger report health` for a project whose runs are backing up against the environment concurrency limit:
|
|
28
|
-
|
|
29
|
-
```text
|
|
30
|
-
/report health prod · last 1h · vs 7d normal
|
|
31
|
-
|
|
32
|
-
✕ Flow stalled — at your env concurrency limit for the last 40 min
|
|
33
|
-
|
|
34
|
-
concurrency 100/100 ▄▅▆▇████ 40 min at limit
|
|
35
|
-
pending 1,240 ↑ 6× ▁▂▄▅▆▇██ (normal ~120)
|
|
36
|
-
start latency p95 8.2s ↑ 4× ▁▂▃▄▆▇██ (normal ~2s)
|
|
37
|
-
|
|
38
|
-
why: runs are finishing at ~90/min
|
|
39
|
-
nothing dead-lettered
|
|
40
|
-
|
|
41
|
-
✓ EXECUTION runs are executing normally
|
|
42
|
-
|
|
43
|
-
✓ LIVENESS fresh — telemetry current, updated 12s ago
|
|
44
|
-
|
|
45
|
-
read: limit saturated → incoming work exceeds capacity → backlog grows
|
|
46
|
-
|
|
47
|
-
→ Raise the env concurrency limit
|
|
48
|
-
Read concurrency docs
|
|
49
|
-
or do nothing — backlog drains in ~26.7 min once triggers ease
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
The verdict reads top to bottom:
|
|
53
|
-
|
|
54
|
-
- **Headline** — the worst finding, stated as a verdict with the breach window. Here Flow is stalled because concurrency has been pinned at its limit for 40 minutes.
|
|
55
|
-
- **Evidence** — the metrics behind the headline, each with a sparkline over the window, its movement against your baseline (`↑ 6×` means six times normal), and an annotation (`40 min at limit`) or baseline (`normal ~120`).
|
|
56
|
-
- **`why:`** — the facts that support the verdict, including what the problem _isn't_ (runs are still finishing, nothing is dead-lettered — so it's not your code).
|
|
57
|
-
- **Sibling findings** — Execution and Liveness, each a one-line verdict.
|
|
58
|
-
- **`read:`** — the causal chain in one line.
|
|
59
|
-
- **Next steps** — the primary action first (`→`), then any alternatives.
|
|
60
|
-
|
|
61
|
-
### The verdict vocabulary
|
|
62
|
-
|
|
63
|
-
Every surface carries meaning in glyphs, never color alone, so the report is legible in a monochrome terminal or a plain-text MCP host:
|
|
64
|
-
|
|
65
|
-
| Glyph | Meaning |
|
|
66
|
-
| --- | --- |
|
|
67
|
-
| `✓` | Healthy |
|
|
68
|
-
| `⚠` | Degraded |
|
|
69
|
-
| `✕` | Failing |
|
|
70
|
-
| `○` | Genuinely unknown — neither good nor bad |
|
|
71
|
-
| `⚑` | The data behind the report can't be trusted |
|
|
72
|
-
| `↑` `↓` `→` | Above, below, or flat against the baseline |
|
|
73
|
-
|
|
74
|
-
<Note>
|
|
75
|
-
The markdown surface swaps the status glyphs for traffic-light emoji (`🟢` `🟡` `🔴` `⚪` `🚩`) — the one color cue a chat host that renders neither ANSI nor HTML can show. The glyph and the emoji mean the same thing.
|
|
76
|
-
</Note>
|
|
77
|
-
|
|
78
|
-
## Surfaces
|
|
79
|
-
|
|
80
|
-
The same report renders four ways.
|
|
81
|
-
|
|
82
|
-
### CLI: `trigger report`
|
|
83
|
-
|
|
84
|
-
Print an interpreted report for an environment. The command defaults to the `health` report and the `prod` environment — a manual production check.
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npx trigger.dev@latest report health --env prod --period 24h
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
| Flag | Default | Description |
|
|
91
|
-
| --- | --- | --- |
|
|
92
|
-
| `[key]` | `health` | The report to render (positional argument). |
|
|
93
|
-
| `-e, --env` | `prod` | The environment: `dev`, `staging`, `prod`, or `preview`. |
|
|
94
|
-
| `-b, --branch` | — | The preview branch. Required when `--env preview`. |
|
|
95
|
-
| `--period` | `1h` | The live window: `30m`, `1h`, `24h`, `7d`. Minutes to weeks, max 90 days. |
|
|
96
|
-
| `-p, --project-ref` | from config | The project ref (`proj_…`). Required if there is no `trigger.config.ts`. |
|
|
97
|
-
| `-c, --config` | — | Path to the config file. |
|
|
98
|
-
|
|
99
|
-
The command prints only the report — no banner — so it pipes cleanly. Output is ANSI-colored in a real terminal and plain markdown when piped:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
trigger report health > health.md # markdown, no escape codes
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Color follows the [supports-color](https://github.com/chalk/supports-color) convention: `NO_COLOR` (any value) or `FORCE_COLOR=0` disables color outright; `FORCE_COLOR` set to anything else force-enables it. Both win over TTY detection — which matters for agents spawned on a PTY, where `isTTY` is `true` but escape codes would be garbled.
|
|
106
|
-
|
|
107
|
-
### MCP tool: `get_report`
|
|
108
|
-
|
|
109
|
-
Fetch the report from an AI coding tool through the [Trigger.dev MCP server](/mcp-introduction). The tool returns plain markdown by default, or ANSI when `color` is set (for hosts that display escapes in tool output). It is read-only.
|
|
110
|
-
|
|
111
|
-
| Parameter | Default | Description |
|
|
112
|
-
| --- | --- | --- |
|
|
113
|
-
| `key` | — | The report to render. Currently only `health`. |
|
|
114
|
-
| `environment` | `dev` | The environment. The MCP server is dev-centric, so an unspecified environment reports on `dev` — pass `environment` explicitly to report on production. |
|
|
115
|
-
| `period` | `1h` | Time window shorthand, e.g. `1h`, `24h`, `7d`. |
|
|
116
|
-
| `color` | `false` | Return ANSI-colored text instead of markdown. |
|
|
117
|
-
| `projectRef` | auto-detected | The project ref. Detected from `trigger.config.ts` if present. |
|
|
118
|
-
| `branch` | — | The preview branch, for preview or branchable dev environments. |
|
|
119
|
-
|
|
120
|
-
### MCP prompt: `/report`
|
|
121
|
-
|
|
122
|
-
The MCP server also registers a `report` prompt, which hosts that support MCP prompts surface as a slash command (Claude Code renders it as `/mcp__trigger__report`). Running `/report health` calls `get_report` for you and shows the result verbatim in a fenced code block, preserving the monospace alignment and sparklines.
|
|
123
|
-
|
|
124
|
-
### HTTP API: `GET /api/v1/reports/:key`
|
|
125
|
-
|
|
126
|
-
The endpoint behind every surface. It accepts a `period` and a `format`, and authenticates with a token scoped to read the report's query tables (`read:query`).
|
|
127
|
-
|
|
128
|
-
| Query param | Default | Description |
|
|
129
|
-
| --- | --- | --- |
|
|
130
|
-
| `period` | `1h` | The live window, same grammar as the CLI. |
|
|
131
|
-
| `format` | `markdown` | `markdown`, `ansi`, or `json`. |
|
|
132
|
-
|
|
133
|
-
`format=markdown` and `format=ansi` return the rendered text. `format=json` returns the `ReportViewModel` — the semantic payload behind the render, where verdicts are codes rather than prose, for building your own surface on top of the report.
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
curl "https://api.trigger.dev/api/v1/reports/health?period=24h&format=json" \
|
|
137
|
-
-H "Authorization: Bearer $TRIGGER_ACCESS_TOKEN"
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
An unknown report key returns `404` with the list of available keys.
|
|
141
|
-
|
|
142
|
-
## Next steps
|
|
143
|
-
|
|
144
|
-
<CardGroup cols={2}>
|
|
145
|
-
<Card title="MCP server" icon="plug" href="/mcp-introduction">
|
|
146
|
-
Connect your AI coding tool to Trigger.dev.
|
|
147
|
-
</Card>
|
|
148
|
-
<Card title="MCP tools" icon="wrench" href="/mcp-tools">
|
|
149
|
-
Every tool the MCP server exposes, including `get_report`.
|
|
150
|
-
</Card>
|
|
151
|
-
<Card title="Concurrency & queues" icon="layer-group" href="/queue-concurrency">
|
|
152
|
-
Configure the concurrency limits the Flow verdict checks against.
|
|
153
|
-
</Card>
|
|
154
|
-
<Card title="Query your data" icon="magnifying-glass" href="/observability/query">
|
|
155
|
-
Run TRQL queries against the same telemetry the report reads.
|
|
156
|
-
</Card>
|
|
157
|
-
</CardGroup>
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Zod"
|
|
3
|
-
description: "Resolve Zod typechecking, test, and deployment errors when upgrading to Trigger.dev v4.6."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
**Trigger.dev v4.6 uses Zod 4 by default. Zod 3.25.56 and later 3.x releases remain supported.**
|
|
7
|
-
|
|
8
|
-
Use this guide if typechecking, tests, or deployment fail after upgrading. The supported project dependency range is `^3.25.56 || ^4.0.0`.
|
|
9
|
-
|
|
10
|
-
| Your project's Zod dependency | What to do |
|
|
11
|
-
| --- | --- |
|
|
12
|
-
| No direct Zod dependency | No Zod-specific change is needed. Trigger.dev installs a compatible runtime dependency automatically. |
|
|
13
|
-
| Zod below 3.25.56 | Upgrade before using Trigger.dev v4.6. These versions are unsupported. |
|
|
14
|
-
| Zod 3.25.56 or later in the 3.x release line | Keep using your Zod 3 schemas with supported SDK APIs. Review the cross-major caveats below. |
|
|
15
|
-
| Zod 4.x | Supported and the recommended default. |
|
|
16
|
-
|
|
17
|
-
Passing your own supported Zod 3 schema to [`schemaTask`](/tasks/schemaTask) or `toolTask` remains supported. This does not make Zod 3 and Zod 4 schemas interchangeable when you compose or inspect them yourself.
|
|
18
|
-
|
|
19
|
-
## Typechecking, tests, or deployment fail after upgrading
|
|
20
|
-
|
|
21
|
-
An older Zod installation can be missing the entry points, types, or schema behavior that Trigger.dev v4.6 requires.
|
|
22
|
-
|
|
23
|
-
Expect TypeScript errors when an unsupported version is resolved, particularly with `skipLibCheck: false`. Tests may also fail when they import or execute schemas. Deployment loads your task code, so an incompatible runtime installation causes deployment errors even if your local tooling skips typechecking. A passing local test suite does not establish that an unsupported version is safe to deploy.
|
|
24
|
-
|
|
25
|
-
Symptoms include missing `zod/v4` or `zod/v4/core` exports, missing Zod types, incompatible generic parameters, and errors while loading tasks. The exact failure depends on the version and dependency tree; not every unsupported version fails at the same stage.
|
|
26
|
-
|
|
27
|
-
### Check the installed version
|
|
28
|
-
|
|
29
|
-
Inspect the resolved dependencies in the package that contains your tasks, not only the version range in `package.json`:
|
|
30
|
-
|
|
31
|
-
<CodeGroup>
|
|
32
|
-
```bash npm
|
|
33
|
-
npm ls zod
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
```bash pnpm
|
|
37
|
-
pnpm why zod
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
```bash bun
|
|
41
|
-
bun pm ls --all
|
|
42
|
-
```
|
|
43
|
-
</CodeGroup>
|
|
44
|
-
|
|
45
|
-
Check the lockfile and any dependency overrides or resolutions as well. An override can keep an old Zod version installed even after you update a direct dependency.
|
|
46
|
-
|
|
47
|
-
### Update Zod
|
|
48
|
-
|
|
49
|
-
Choose whether to move your application to Zod 4 or keep its existing Zod 3 schemas:
|
|
50
|
-
|
|
51
|
-
<Tabs>
|
|
52
|
-
<Tab title="Move to Zod 4">
|
|
53
|
-
Install the latest Zod 4 release:
|
|
54
|
-
|
|
55
|
-
<CodeGroup>
|
|
56
|
-
```bash npm
|
|
57
|
-
npm install zod@4
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```bash pnpm
|
|
61
|
-
pnpm add zod@4
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
```bash bun
|
|
65
|
-
bun add zod@4
|
|
66
|
-
```
|
|
67
|
-
</CodeGroup>
|
|
68
|
-
|
|
69
|
-
Review [Zod's migration guide](https://zod.dev/v4/changelog) for changes to your own schemas and error handling.
|
|
70
|
-
</Tab>
|
|
71
|
-
<Tab title="Stay on Zod 3">
|
|
72
|
-
Install the latest Zod 3 patch rather than pinning the minimum supported version:
|
|
73
|
-
|
|
74
|
-
<CodeGroup>
|
|
75
|
-
```bash npm
|
|
76
|
-
npm install zod@3
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
```bash pnpm
|
|
80
|
-
pnpm add zod@3
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
```bash bun
|
|
84
|
-
bun add zod@3
|
|
85
|
-
```
|
|
86
|
-
</CodeGroup>
|
|
87
|
-
|
|
88
|
-
Your existing `import { z } from "zod"` continues to use Zod 3. Trigger.dev's own schemas use the Zod 4 implementation included in the supported Zod 3 package.
|
|
89
|
-
</Tab>
|
|
90
|
-
</Tabs>
|
|
91
|
-
|
|
92
|
-
Other dependencies can require a higher minimum than Trigger.dev. For example, an AI SDK dependency may require Zod 3.25.76 or Zod 4. Meet those peer requirements too; do not force a lower version across every dependency.
|
|
93
|
-
|
|
94
|
-
### Verify the update
|
|
95
|
-
|
|
96
|
-
- Commit the updated manifest and lockfile, and make sure CI uses them.
|
|
97
|
-
- Recheck the installed Zod versions in your local and deployment environments.
|
|
98
|
-
- Run your project's TypeScript checks and tests, including code that constructs or inspects schemas.
|
|
99
|
-
- Keep the CLI and SDK versions aligned using the [package upgrade guide](/upgrading-packages), then retry deployment.
|
|
100
|
-
|
|
101
|
-
Do not use `skipLibCheck` or ignored peer-dependency warnings as a compatibility fix. They do not change the runtime package that deployment loads. You do not need to add Zod as a direct dependency if your application does not import it.
|
|
102
|
-
|
|
103
|
-
## Parsing still fails with a supported Zod 3 version
|
|
104
|
-
|
|
105
|
-
Supporting a Zod 3 schema as an SDK input is different from nesting a Trigger.dev-exported Zod 4 schema inside a Zod 3 object. Cross-major composition can fail during typechecking or parsing.
|
|
106
|
-
|
|
107
|
-
For example, this mixes a Zod 3 object with a Zod 4 `RetryOptions` schema:
|
|
108
|
-
|
|
109
|
-
```ts incompatible-schemas.ts
|
|
110
|
-
import { z } from "zod"; // Project dependency is Zod 3.
|
|
111
|
-
import { RetryOptions } from "@trigger.dev/core/v3";
|
|
112
|
-
|
|
113
|
-
const schema = z.object({ retry: RetryOptions });
|
|
114
|
-
schema.parse({ retry: {} });
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Use Zod 4 for every schema in the composed object. The `zod/v4` entry point is available in both supported Zod 3 packages and Zod 4 packages:
|
|
118
|
-
|
|
119
|
-
```ts compatible-schemas.ts
|
|
120
|
-
import { z } from "zod/v4";
|
|
121
|
-
import { RetryOptions } from "@trigger.dev/core/v3";
|
|
122
|
-
|
|
123
|
-
const schema = z.object({ retry: RetryOptions });
|
|
124
|
-
schema.parse({ retry: {} });
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Alternatively, keep the Zod 3 and Trigger.dev schemas separate and call each schema's parser independently. You do not need to migrate unrelated application schemas to use this approach.
|
|
128
|
-
|
|
129
|
-
## An `instanceof` check stops matching
|
|
130
|
-
|
|
131
|
-
A Zod 4 error is not an instance of the Zod 3 `ZodError` constructor. A constructor check against your project's Zod 3 import can stop matching errors produced by Trigger.dev's schemas:
|
|
132
|
-
|
|
133
|
-
```ts mismatched-error-check.ts
|
|
134
|
-
import { z } from "zod"; // Project dependency is Zod 3.
|
|
135
|
-
import { RetryOptions } from "@trigger.dev/core/v3";
|
|
136
|
-
|
|
137
|
-
const result = RetryOptions.safeParse({ maxAttempts: "invalid" });
|
|
138
|
-
|
|
139
|
-
if (!result.success) {
|
|
140
|
-
console.log(result.error instanceof z.ZodError); // false
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Use the result returned by the schema you called instead of a constructor from another Zod installation:
|
|
145
|
-
|
|
146
|
-
```ts schema-error-handling.ts
|
|
147
|
-
import { RetryOptions } from "@trigger.dev/core/v3";
|
|
148
|
-
|
|
149
|
-
const result = RetryOptions.safeParse({ maxAttempts: "invalid" });
|
|
150
|
-
|
|
151
|
-
if (!result.success) {
|
|
152
|
-
console.error(result.error.issues);
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
The same caveat applies to checks such as `schema instanceof z.ZodObject`. Multiple installed copies can also have different constructors, even within the same major version. Prefer parsing and the returned validation result over inspecting classes or private fields such as `_def`.
|
|
157
|
-
|
|
158
|
-
These examples are not an exhaustive list of cross-major differences. If errors remain after updating, check which Zod implementation creates each schema and which code composes, parses, or inspects it.
|