@trigger.dev/sdk 4.8.5 → 4.8.7
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/v3/ai.d.ts +34 -8
- package/dist/commonjs/v3/ai.js +304 -168
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +4 -4
- package/dist/commonjs/v3/auth.js +21 -75
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chat-client.d.ts +1 -1
- package/dist/commonjs/v3/chat.d.ts +1 -1
- package/dist/commonjs/v3/prompt.js +6 -8
- package/dist/commonjs/v3/prompt.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +5 -1
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/v3/sessions.js +10 -7
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +2 -2
- package/dist/commonjs/v3/shared.js +16 -15
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/steeringContext.d.ts +35 -10
- package/dist/commonjs/v3/steeringContext.js +86 -14
- package/dist/commonjs/v3/steeringContext.js.map +1 -1
- package/dist/commonjs/v3/streams.js +10 -8
- package/dist/commonjs/v3/streams.js.map +1 -1
- package/dist/commonjs/v3/tasks.d.ts +2 -2
- package/dist/commonjs/v3/tasks.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.js +24 -13
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/toolOutputJson.d.ts +17 -0
- package/dist/commonjs/v3/toolOutputJson.js +241 -0
- package/dist/commonjs/v3/toolOutputJson.js.map +1 -0
- package/dist/commonjs/v3/webhooks.d.ts +8 -2
- package/dist/commonjs/v3/webhooks.js +20 -11
- package/dist/commonjs/v3/webhooks.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +34 -8
- package/dist/esm/v3/ai.js +306 -171
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +4 -4
- package/dist/esm/v3/auth.js +22 -76
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chat-client.d.ts +1 -1
- package/dist/esm/v3/chat.d.ts +1 -1
- package/dist/esm/v3/prompt.js +6 -8
- package/dist/esm/v3/prompt.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +5 -1
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/v3/sessions.js +10 -7
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +2 -2
- package/dist/esm/v3/shared.js +16 -15
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/steeringContext.d.ts +35 -10
- package/dist/esm/v3/steeringContext.js +85 -14
- package/dist/esm/v3/steeringContext.js.map +1 -1
- package/dist/esm/v3/streams.js +10 -8
- package/dist/esm/v3/streams.js.map +1 -1
- package/dist/esm/v3/tasks.d.ts +2 -2
- package/dist/esm/v3/tasks.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.js +25 -14
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/toolOutputJson.d.ts +17 -0
- package/dist/esm/v3/toolOutputJson.js +238 -0
- package/dist/esm/v3/toolOutputJson.js.map +1 -0
- package/dist/esm/v3/webhooks.d.ts +8 -2
- package/dist/esm/v3/webhooks.js +20 -11
- package/dist/esm/v3/webhooks.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai/observability.mdx +25 -19
- package/docs/ai/prompts.mdx +25 -19
- package/docs/ai-chat/actions.mdx +1 -1
- package/docs/ai-chat/anatomy.mdx +1 -1
- package/docs/ai-chat/backend.mdx +24 -24
- package/docs/ai-chat/background-injection.mdx +5 -5
- package/docs/ai-chat/chat-local.mdx +2 -2
- package/docs/ai-chat/compaction.mdx +47 -18
- package/docs/ai-chat/custom-agents.mdx +4 -4
- package/docs/ai-chat/error-handling.mdx +4 -4
- package/docs/ai-chat/fast-starts.mdx +8 -7
- package/docs/ai-chat/frontend.mdx +6 -2
- package/docs/ai-chat/lifecycle-hooks.mdx +11 -11
- package/docs/ai-chat/migrating-from-a-route-handler.mdx +4 -4
- package/docs/ai-chat/migrating-from-hydrate-messages.mdx +1 -1
- package/docs/ai-chat/overview.mdx +1 -1
- package/docs/ai-chat/patterns/branching-conversations.mdx +1 -1
- package/docs/ai-chat/patterns/database-persistence.mdx +2 -2
- package/docs/ai-chat/patterns/human-in-the-loop.mdx +1 -1
- package/docs/ai-chat/patterns/native-compaction.mdx +29 -9
- package/docs/ai-chat/patterns/persistence-and-replay.mdx +1 -1
- package/docs/ai-chat/patterns/redacting-telemetry.mdx +2 -2
- package/docs/ai-chat/patterns/skills.mdx +2 -2
- package/docs/ai-chat/patterns/sub-agents.mdx +1 -1
- package/docs/ai-chat/patterns/tool-result-auditing.mdx +1 -1
- package/docs/ai-chat/patterns/trusted-edge-signals.mdx +2 -2
- package/docs/ai-chat/patterns/version-upgrades.mdx +2 -2
- package/docs/ai-chat/pending-messages.mdx +5 -5
- package/docs/ai-chat/prompt-caching.mdx +7 -7
- package/docs/ai-chat/quick-start.mdx +2 -2
- package/docs/ai-chat/testing.mdx +9 -9
- package/docs/ai-chat/tools.mdx +9 -5
- package/docs/ai-chat/transcript-storage.mdx +2 -2
- package/docs/ai-chat/types.mdx +10 -3
- package/docs/apikeys.mdx +2 -1
- package/docs/cli-login-commands.mdx +12 -0
- package/docs/concurrency.mdx +40 -0
- package/docs/database-connections.mdx +1 -1
- package/docs/deploy-environment-variables.mdx +84 -2
- package/docs/deployment/trusted-publishing.mdx +4 -0
- package/docs/errors-retrying.mdx +25 -18
- package/docs/github-actions.mdx +1 -1
- package/docs/github-integration.mdx +32 -1
- package/docs/how-it-works.mdx +4 -2
- package/docs/introduction.mdx +1 -1
- package/docs/mcp-introduction.mdx +7 -1
- package/docs/mcp-remote.mdx +90 -0
- package/docs/oidc/azure.mdx +81 -0
- package/docs/oidc/databricks.mdx +99 -0
- package/docs/oidc/doppler.mdx +60 -0
- package/docs/oidc/gcp.mdx +109 -0
- package/docs/oidc/hugging-face.mdx +90 -0
- package/docs/oidc/openrouter.mdx +91 -0
- package/docs/oidc/snowflake.mdx +91 -0
- package/docs/oidc/vault.mdx +71 -0
- package/docs/oidc.mdx +2 -0
- package/docs/runs/metadata.mdx +1 -1
- package/docs/self-hosting/docker.mdx +2 -0
- package/docs/self-hosting/env/webapp.mdx +4 -1
- package/docs/self-hosting/kubernetes.mdx +2 -0
- package/docs/tasks/schemaTask.mdx +26 -13
- package/docs/tasks/streams.mdx +2 -2
- package/docs/troubleshooting.mdx +7 -0
- package/docs/webhooks/channels.mdx +6 -6
- package/docs/webhooks/connect.mdx +9 -75
- package/docs/webhooks/custom-providers.mdx +87 -0
- package/docs/webhooks/deliveries.mdx +7 -7
- package/docs/webhooks/filters.mdx +2 -2
- package/docs/webhooks/how-it-works.mdx +58 -0
- package/docs/webhooks/human-in-the-loop.mdx +3 -3
- package/docs/webhooks/linear.mdx +5 -3
- package/docs/webhooks/overview.mdx +20 -71
- package/docs/webhooks/own-handler.mdx +62 -0
- package/docs/webhooks/pricing-and-limits.mdx +13 -0
- package/docs/webhooks/providers/attio.mdx +38 -0
- package/docs/webhooks/providers/autumn.mdx +40 -0
- package/docs/webhooks/providers/cal-com.mdx +41 -0
- package/docs/webhooks/providers/calendly.mdx +41 -0
- package/docs/webhooks/providers/clerk.mdx +40 -0
- package/docs/webhooks/providers/discord.mdx +45 -0
- package/docs/webhooks/providers/docusign.mdx +41 -0
- package/docs/webhooks/providers/elevenlabs.mdx +41 -0
- package/docs/webhooks/providers/firecrawl.mdx +54 -0
- package/docs/webhooks/providers/github.mdx +46 -0
- package/docs/webhooks/providers/gitlab.mdx +41 -0
- package/docs/webhooks/providers/granola.mdx +44 -0
- package/docs/webhooks/providers/hookdeck.mdx +98 -0
- package/docs/webhooks/providers/infisical.mdx +41 -0
- package/docs/webhooks/providers/jira.mdx +41 -0
- package/docs/webhooks/providers/langfuse.mdx +40 -0
- package/docs/webhooks/providers/linear.mdx +45 -0
- package/docs/webhooks/providers/loops.mdx +40 -0
- package/docs/webhooks/providers/metronome.mdx +42 -0
- package/docs/webhooks/providers/mux.mdx +40 -0
- package/docs/webhooks/providers/openai.mdx +40 -0
- package/docs/webhooks/providers/pagerduty.mdx +40 -0
- package/docs/webhooks/providers/plain.mdx +41 -0
- package/docs/webhooks/providers/planetscale.mdx +40 -0
- package/docs/webhooks/providers/recall-ai.mdx +54 -0
- package/docs/webhooks/providers/replicate.mdx +41 -0
- package/docs/webhooks/providers/resend.mdx +44 -0
- package/docs/webhooks/providers/retell.mdx +41 -0
- package/docs/webhooks/providers/sentry.mdx +41 -0
- package/docs/webhooks/providers/shopify.mdx +49 -0
- package/docs/webhooks/providers/slack.mdx +48 -0
- package/docs/webhooks/providers/square.mdx +40 -0
- package/docs/webhooks/providers/stripe.mdx +86 -0
- package/docs/webhooks/providers/supabase.mdx +41 -0
- package/docs/webhooks/providers/tailscale.mdx +43 -0
- package/docs/webhooks/providers/typeform.mdx +42 -0
- package/docs/webhooks/providers/vapi.mdx +47 -0
- package/docs/webhooks/providers/vercel.mdx +40 -0
- package/docs/webhooks/providers/whatsapp.mdx +45 -0
- package/docs/webhooks/providers/workos.mdx +41 -0
- package/docs/webhooks/providers/zendesk.mdx +41 -0
- package/docs/webhooks/providers.mdx +53 -0
- package/docs/webhooks/quick-start.mdx +131 -0
- package/docs/webhooks/session-routing.mdx +6 -6
- package/docs/webhooks/signing-secrets.mdx +80 -0
- package/docs/webhooks/slack.mdx +11 -2
- package/docs/webhooks/verification.mdx +139 -0
- package/docs/webhooks/waiters.mdx +2 -2
- package/docs/webhooks/webhook-tasks.mdx +46 -0
- package/package.json +4 -5
- package/docs/migrating-from-v3.mdx +0 -332
- package/docs/webhooks/public-beta.mdx +0 -70
- package/docs/webhooks/sources.mdx +0 -252
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Connect to Google Cloud"
|
|
3
|
+
sidebarTitle: "Google Cloud"
|
|
4
|
+
description: "Authenticate to Google Cloud from your tasks with workload identity federation instead of a service account key."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use Google Cloud [workload identity federation](https://docs.cloud.google.com/iam/docs/workload-identity-federation-with-other-providers) to exchange a Trigger.dev OIDC token for a short-lived Google access token. Your tasks call Google Cloud APIs with no service account key in `GOOGLE_APPLICATION_CREDENTIALS` or `GOOGLE_CREDENTIALS`.
|
|
8
|
+
|
|
9
|
+
Follow the [OIDC prerequisites](/oidc#prerequisites), then go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment and copy the issuer URL and subject.
|
|
10
|
+
|
|
11
|
+
## Configure Google Cloud
|
|
12
|
+
|
|
13
|
+
### Create a pool and provider
|
|
14
|
+
|
|
15
|
+
Create a workload identity pool, then an OIDC provider in it. Replace the IDs, your organization slug, and your project number:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
gcloud iam workload-identity-pools create trigger-dev \
|
|
19
|
+
--location="global" \
|
|
20
|
+
--display-name="Trigger.dev"
|
|
21
|
+
|
|
22
|
+
gcloud iam workload-identity-pools providers create-oidc trigger-dev \
|
|
23
|
+
--location="global" \
|
|
24
|
+
--workload-identity-pool="trigger-dev" \
|
|
25
|
+
--issuer-uri="https://oidc.trigger.dev/YOUR_ORG_SLUG" \
|
|
26
|
+
--allowed-audiences="https://iam.googleapis.com/projects/YOUR_PROJECT_NUMBER/locations/global/workloadIdentityPools/trigger-dev/providers/trigger-dev" \
|
|
27
|
+
--attribute-mapping="google.subject=assertion.sub"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The allowed audience is the provider's own resource URL, which your task requests below. The mapping makes each Trigger.dev environment subject a distinct Google principal.
|
|
31
|
+
|
|
32
|
+
<Warning>
|
|
33
|
+
Google limits `google.subject` to [127 characters](https://docs.cloud.google.com/iam/docs/workload-identity-federation).
|
|
34
|
+
Production and Staging subjects are well under that. A Preview subject ends with the branch's
|
|
35
|
+
slug, so a long branch name can push it over the limit and Google rejects the token. Check the
|
|
36
|
+
length of the subject you copy before using it for a Preview environment.
|
|
37
|
+
</Warning>
|
|
38
|
+
|
|
39
|
+
### Grant access to the subject
|
|
40
|
+
|
|
41
|
+
Grant roles to the principal for the **complete subject copied from the dashboard**. For the example below, allow reading objects in a bucket:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
gcloud storage buckets add-iam-policy-binding gs://YOUR_BUCKET \
|
|
45
|
+
--role="roles/storage.objectViewer" \
|
|
46
|
+
--member="principal://iam.googleapis.com/projects/YOUR_PROJECT_NUMBER/locations/global/workloadIdentityPools/trigger-dev/subject/YOUR_ENVIRONMENT_SUBJECT"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Some Google APIs don't accept federated principals directly. For those, grant the principal `roles/iam.workloadIdentityUser` on a service account and impersonate it (see `service_account_impersonation_url` below).
|
|
50
|
+
|
|
51
|
+
## Use the identity in your task
|
|
52
|
+
|
|
53
|
+
<CodeGroup>
|
|
54
|
+
|
|
55
|
+
```bash npm
|
|
56
|
+
npm i @trigger.dev/sdk@latest google-auth-library @google-cloud/storage
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```bash pnpm
|
|
60
|
+
pnpm add @trigger.dev/sdk@latest google-auth-library @google-cloud/storage
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```bash bun
|
|
64
|
+
bun add @trigger.dev/sdk@latest google-auth-library @google-cloud/storage
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</CodeGroup>
|
|
68
|
+
|
|
69
|
+
`IdentityPoolClient` from `google-auth-library` asks a [subject token supplier](https://github.com/googleapis/google-auth-library-nodejs#accessing-resources-from-an-oidc-or-saml20-identity-provider-using-a-custom-supplier) for a token whenever it needs a new Google access token. Return a fresh Trigger.dev OIDC token from it:
|
|
70
|
+
|
|
71
|
+
```ts /trigger/read-from-gcs.ts
|
|
72
|
+
import { auth, task } from "@trigger.dev/sdk";
|
|
73
|
+
import { IdentityPoolClient } from "google-auth-library";
|
|
74
|
+
import { Storage } from "@google-cloud/storage";
|
|
75
|
+
|
|
76
|
+
const providerUrl =
|
|
77
|
+
"//iam.googleapis.com/projects/YOUR_PROJECT_NUMBER/locations/global/workloadIdentityPools/trigger-dev/providers/trigger-dev";
|
|
78
|
+
|
|
79
|
+
export const readFromGcs = task({
|
|
80
|
+
id: "read-from-gcs",
|
|
81
|
+
run: async () => {
|
|
82
|
+
const authClient = new IdentityPoolClient({
|
|
83
|
+
audience: providerUrl,
|
|
84
|
+
subject_token_type: "urn:ietf:params:oauth:token-type:jwt",
|
|
85
|
+
subject_token_supplier: {
|
|
86
|
+
getSubjectToken: async () =>
|
|
87
|
+
(await auth.getOIDCToken({ audience: `https:${providerUrl}` })).token,
|
|
88
|
+
},
|
|
89
|
+
// To impersonate a service account instead of using the principal directly:
|
|
90
|
+
// service_account_impersonation_url: "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/YOUR_SA_EMAIL:generateAccessToken",
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const storage = new Storage({ projectId: "YOUR_PROJECT_ID", authClient });
|
|
94
|
+
const [contents] = await storage.bucket("YOUR_BUCKET").file("example.txt").download();
|
|
95
|
+
|
|
96
|
+
return { contents: contents.toString() };
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The STS `audience` is the provider URL without a scheme; the OIDC token's audience is the same URL with `https:`, matching `--allowed-audiences`.
|
|
102
|
+
|
|
103
|
+
Create the client inside `run` so one run's tokens are never reused by another. Redeploy and start a new run on that deployment.
|
|
104
|
+
|
|
105
|
+
## Remove the old credential
|
|
106
|
+
|
|
107
|
+
Once runs in every deployed environment authenticate this way, delete `GOOGLE_APPLICATION_CREDENTIALS` and `GOOGLE_CREDENTIALS` from those environments on the Environment Variables page, then [delete the service account key](https://docs.cloud.google.com/iam/docs/keys-create-delete#deleting) in Google Cloud.
|
|
108
|
+
|
|
109
|
+
Local Development runs can't mint OIDC tokens. Use your own credentials there, such as `gcloud auth application-default login`, when `ctx.environment.type === "DEVELOPMENT"`.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Connect to Hugging Face"
|
|
3
|
+
sidebarTitle: "Hugging Face"
|
|
4
|
+
description: "Exchange a Trigger.dev OIDC token for a short-lived Hugging Face token to run inference, download gated models or read one repo, without storing an HF_TOKEN."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use Hugging Face [Trusted Publishers](https://huggingface.co/docs/hub/trusted-publishers) to exchange a Trigger.dev OIDC token for a Hugging Face token that lasts one hour. Your tasks call Inference Providers, download gated models, or read and write one repo with no `HF_TOKEN` stored anywhere.
|
|
8
|
+
|
|
9
|
+
The exchanged token covers less than a user access token. Pick the flavor that matches what your task does:
|
|
10
|
+
|
|
11
|
+
| Configure | On | The token can |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| CI/CD identity | Your account's [Authentication settings](https://huggingface.co/settings/authentication#ci-cd-access), CI/CD Access | Read gated repos you have access to, and call Inference Providers if you tick **Allow Inference Providers calls** (billed to your account) |
|
|
14
|
+
| Repo trusted publisher | A repo's **Settings**, Trusted Publishers | Write to that one repo, or only read it if you tick **Read-only** |
|
|
15
|
+
|
|
16
|
+
A CI/CD identity token can't read your private repos or write anything; use a repo publisher for those ([security model](https://huggingface.co/docs/hub/trusted-publishers#security-model)).
|
|
17
|
+
|
|
18
|
+
Follow the [OIDC prerequisites](/oidc#prerequisites), then go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment and copy the issuer URL and subject.
|
|
19
|
+
|
|
20
|
+
## Configure Hugging Face
|
|
21
|
+
|
|
22
|
+
Add a CI/CD identity or a repo trusted publisher, as in the table above. The settings list presets for CI providers, but [any OIDC-compliant provider works](https://huggingface.co/docs/hub/trusted-publishers#supported-ci-providers):
|
|
23
|
+
|
|
24
|
+
- **Issuer**: the issuer URL copied from the dashboard.
|
|
25
|
+
- **Claims**: `sub` set to the **complete subject copied from the dashboard**. Hugging Face matches claims exactly, so each environment needs its own identity or publisher.
|
|
26
|
+
|
|
27
|
+
The audience is fixed: Hugging Face only accepts tokens whose `aud` is `https://huggingface.co`.
|
|
28
|
+
|
|
29
|
+
## Call Hugging Face in your task
|
|
30
|
+
|
|
31
|
+
<CodeGroup>
|
|
32
|
+
|
|
33
|
+
```bash npm
|
|
34
|
+
npm i @trigger.dev/sdk@latest @huggingface/inference
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```bash pnpm
|
|
38
|
+
pnpm add @trigger.dev/sdk@latest @huggingface/inference
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```bash bun
|
|
42
|
+
bun add @trigger.dev/sdk@latest @huggingface/inference
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
</CodeGroup>
|
|
46
|
+
|
|
47
|
+
Exchange the OIDC token at Hugging Face's [token endpoint](https://huggingface.co/docs/hub/trusted-publishers#api-reference), then use the access token wherever you used `HF_TOKEN`. `resource` is your Hugging Face username for a CI/CD identity, or the repo (`namespace/name`, `datasets/namespace/name`) for a repo publisher:
|
|
48
|
+
|
|
49
|
+
```ts /trigger/hugging-face-inference.ts
|
|
50
|
+
import { auth, task } from "@trigger.dev/sdk";
|
|
51
|
+
import { InferenceClient } from "@huggingface/inference";
|
|
52
|
+
|
|
53
|
+
export const huggingFaceInference = task({
|
|
54
|
+
id: "hugging-face-inference",
|
|
55
|
+
run: async (payload: { prompt: string }) => {
|
|
56
|
+
const { token: subjectToken } = await auth.getOIDCToken({
|
|
57
|
+
audience: "https://huggingface.co",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const exchange = await fetch("https://huggingface.co/oauth/token", {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: { "Content-Type": "application/json" },
|
|
63
|
+
body: JSON.stringify({
|
|
64
|
+
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
65
|
+
subject_token_type: "urn:ietf:params:oauth:token-type:id_token",
|
|
66
|
+
subject_token: subjectToken,
|
|
67
|
+
resource: "YOUR_HF_USERNAME",
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
if (!exchange.ok) throw new Error(`Hugging Face exchange failed: ${exchange.status}`);
|
|
71
|
+
const { access_token } = await exchange.json();
|
|
72
|
+
|
|
73
|
+
const client = new InferenceClient(access_token);
|
|
74
|
+
const result = await client.chatCompletion({
|
|
75
|
+
model: "meta-llama/Llama-3.1-8B-Instruct",
|
|
76
|
+
messages: [{ role: "user", content: payload.prompt }],
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return { reply: result.choices[0].message.content };
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A failed exchange returns `400` with `invalid_grant` when the issuer, subject or audience doesn't match the identity or publisher. The token lasts 60 minutes with no refresh token, so exchange again for longer work.
|
|
85
|
+
|
|
86
|
+
## Remove the old credential
|
|
87
|
+
|
|
88
|
+
Once runs in every deployed environment authenticate this way, delete `HF_TOKEN`, `HUGGING_FACE_HUB_TOKEN` and `HUGGINGFACEHUB_API_TOKEN` from those environments on the Environment Variables page, then revoke the access token in your Hugging Face [token settings](https://huggingface.co/settings/tokens).
|
|
89
|
+
|
|
90
|
+
Local Development runs can't mint OIDC tokens. Use your own Hugging Face token there when `ctx.environment.type === "DEVELOPMENT"`.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Connect to OpenRouter"
|
|
3
|
+
sidebarTitle: "OpenRouter"
|
|
4
|
+
description: "Exchange a Trigger.dev OIDC token for a short-lived OpenRouter access token, so your tasks call models without an OPENROUTER_API_KEY."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use OpenRouter [workload identity federation](https://openrouter.ai/docs/guides/overview/auth/workload-identity-federation) to exchange a Trigger.dev OIDC token for an OpenRouter access token. Your tasks call models with no `OPENROUTER_API_KEY` stored anywhere, and usage is billed to the API key the federation policy acts as, as if that key made the request.
|
|
8
|
+
|
|
9
|
+
<Note>
|
|
10
|
+
Workload identity federation is available on OpenRouter's Business and Enterprise plans, under
|
|
11
|
+
**Settings**, Workload identity.
|
|
12
|
+
</Note>
|
|
13
|
+
|
|
14
|
+
Follow the [OIDC prerequisites](/oidc#prerequisites), then go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment and copy the issuer URL and subject.
|
|
15
|
+
|
|
16
|
+
## Configure OpenRouter
|
|
17
|
+
|
|
18
|
+
An organization admin sets this up under **Settings**, Workload identity ([set up trust](https://openrouter.ai/docs/guides/overview/auth/workload-identity-federation#set-up-trust)):
|
|
19
|
+
|
|
20
|
+
1. **Add an issuer.** Set **Issuer URL** to the issuer URL copied from the dashboard and leave **JWKS URL** empty: OpenRouter reads the keys from the issuer's discovery document.
|
|
21
|
+
2. **Add a policy** for that issuer:
|
|
22
|
+
- **Subject**: the **complete subject copied from the dashboard**. It must match exactly.
|
|
23
|
+
- **Audience**: any value, for example `https://openrouter.ai`. It's required, and your task must request the same one.
|
|
24
|
+
- **Acts as API key**: the workspace API key your tasks use today. A workspace key grants the `inference` scope.
|
|
25
|
+
|
|
26
|
+
Copy the policy's id, shown under its name. Your task sends it with every exchange.
|
|
27
|
+
|
|
28
|
+
## Call OpenRouter in your task
|
|
29
|
+
|
|
30
|
+
<CodeGroup>
|
|
31
|
+
|
|
32
|
+
```bash npm
|
|
33
|
+
npm i @trigger.dev/sdk@latest openai
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```bash pnpm
|
|
37
|
+
pnpm add @trigger.dev/sdk@latest openai
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```bash bun
|
|
41
|
+
bun add @trigger.dev/sdk@latest openai
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
</CodeGroup>
|
|
45
|
+
|
|
46
|
+
Exchange the OIDC token at OpenRouter's [token endpoint](https://openrouter.ai/docs/api/api-reference/oauth/exchange-a-workload-identity-token), then pass the access token as the API key to the OpenAI SDK pointed at [OpenRouter's base URL](https://openrouter.ai/docs/quickstart):
|
|
47
|
+
|
|
48
|
+
```ts /trigger/openrouter-chat.ts
|
|
49
|
+
import { auth, task } from "@trigger.dev/sdk";
|
|
50
|
+
import OpenAI from "openai";
|
|
51
|
+
|
|
52
|
+
export const openrouterChat = task({
|
|
53
|
+
id: "openrouter-chat",
|
|
54
|
+
run: async (payload: { prompt: string }) => {
|
|
55
|
+
const { token: subjectToken } = await auth.getOIDCToken({
|
|
56
|
+
audience: "https://openrouter.ai",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const exchange = await fetch("https://openrouter.ai/api/v1/oauth/token", {
|
|
60
|
+
method: "POST",
|
|
61
|
+
body: new URLSearchParams({
|
|
62
|
+
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
63
|
+
subject_token_type: "urn:ietf:params:oauth:token-type:jwt",
|
|
64
|
+
subject_token: subjectToken,
|
|
65
|
+
federation_policy_id: "YOUR_FEDERATION_POLICY_ID",
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
if (!exchange.ok) throw new Error(`OpenRouter exchange failed: ${exchange.status}`);
|
|
69
|
+
const { access_token } = await exchange.json();
|
|
70
|
+
|
|
71
|
+
const openrouter = new OpenAI({
|
|
72
|
+
baseURL: "https://openrouter.ai/api/v1",
|
|
73
|
+
apiKey: access_token,
|
|
74
|
+
});
|
|
75
|
+
const completion = await openrouter.chat.completions.create({
|
|
76
|
+
model: "openai/gpt-6-luna",
|
|
77
|
+
messages: [{ role: "user", content: payload.prompt }],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return { reply: completion.choices[0].message.content };
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The access token never outlives the OIDC token it was exchanged for, which is five minutes for Trigger.dev tokens. For longer work, request a new OIDC token and exchange it again. A rejected exchange returns `400` with `invalid_grant` whichever claim failed, so compare the issuer, subject and audience with the policy when it does.
|
|
86
|
+
|
|
87
|
+
## Remove the old credential
|
|
88
|
+
|
|
89
|
+
Once runs in every deployed environment authenticate this way, delete `OPENROUTER_API_KEY` from those environments on the Environment Variables page. The key itself stays: the policy acts as it. To stop anyone using it directly, create a new workspace key for the policy and delete the old one in OpenRouter.
|
|
90
|
+
|
|
91
|
+
Local Development runs can't mint OIDC tokens. Use your own OpenRouter API key there when `ctx.environment.type === "DEVELOPMENT"`.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Connect to Snowflake"
|
|
3
|
+
sidebarTitle: "Snowflake"
|
|
4
|
+
description: "Connect to Snowflake from your tasks with workload identity federation instead of a password or private key."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use Snowflake [workload identity federation](https://docs.snowflake.com/en/user-guide/workload-identity-federation) to connect as a service user that trusts your Trigger.dev environment. The Snowflake driver sends the OIDC token itself, so there's no exchange step and no `SNOWFLAKE_PASSWORD` or private key stored anywhere.
|
|
8
|
+
|
|
9
|
+
Follow the [OIDC prerequisites](/oidc#prerequisites), then go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment and copy the issuer URL and subject.
|
|
10
|
+
|
|
11
|
+
## Configure Snowflake
|
|
12
|
+
|
|
13
|
+
Create a service user for each environment. Replace the issuer and subject with the values from the dashboard:
|
|
14
|
+
|
|
15
|
+
```sql
|
|
16
|
+
CREATE USER trigger_production
|
|
17
|
+
WORKLOAD_IDENTITY = (
|
|
18
|
+
TYPE = OIDC
|
|
19
|
+
ISSUER = 'https://oidc.trigger.dev/YOUR_ORG_SLUG'
|
|
20
|
+
SUBJECT = 'YOUR_ENVIRONMENT_SUBJECT'
|
|
21
|
+
)
|
|
22
|
+
TYPE = SERVICE
|
|
23
|
+
DEFAULT_ROLE = analytics_reader;
|
|
24
|
+
|
|
25
|
+
GRANT ROLE analytics_reader TO USER trigger_production;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
With no `OIDC_AUDIENCE_LIST`, Snowflake expects the audience `snowflakecomputing.com`, which the task requests below. `SUBJECT` can be up to 255 characters, which fits every Trigger.dev subject in practice.
|
|
29
|
+
|
|
30
|
+
## Connect in your task
|
|
31
|
+
|
|
32
|
+
Workload identity needs the Snowflake Node.js driver with `WORKLOAD_IDENTITY` support:
|
|
33
|
+
|
|
34
|
+
<CodeGroup>
|
|
35
|
+
|
|
36
|
+
```bash npm
|
|
37
|
+
npm i @trigger.dev/sdk@latest snowflake-sdk@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```bash pnpm
|
|
41
|
+
pnpm add @trigger.dev/sdk@latest snowflake-sdk@latest
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```bash bun
|
|
45
|
+
bun add @trigger.dev/sdk@latest snowflake-sdk@latest
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</CodeGroup>
|
|
49
|
+
|
|
50
|
+
Set the [authentication options](https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver-authenticate) `authenticator`, `workloadIdentityProvider`, and `token`:
|
|
51
|
+
|
|
52
|
+
```ts /trigger/query-snowflake.ts
|
|
53
|
+
import { auth, task } from "@trigger.dev/sdk";
|
|
54
|
+
import snowflake from "snowflake-sdk";
|
|
55
|
+
|
|
56
|
+
export const querySnowflake = task({
|
|
57
|
+
id: "query-snowflake",
|
|
58
|
+
run: async () => {
|
|
59
|
+
const { token } = await auth.getOIDCToken({ audience: "snowflakecomputing.com" });
|
|
60
|
+
|
|
61
|
+
const connection = snowflake.createConnection({
|
|
62
|
+
account: "YOUR_ACCOUNT_IDENTIFIER",
|
|
63
|
+
authenticator: "WORKLOAD_IDENTITY",
|
|
64
|
+
workloadIdentityProvider: "OIDC",
|
|
65
|
+
token,
|
|
66
|
+
});
|
|
67
|
+
// connect reports a failed login through its callback, so reject on it
|
|
68
|
+
await new Promise((resolve, reject) =>
|
|
69
|
+
connection.connect((err, conn) => (err ? reject(err) : resolve(conn)))
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const rows = await new Promise((resolve, reject) =>
|
|
73
|
+
connection.execute({
|
|
74
|
+
sqlText: "SELECT CURRENT_USER()",
|
|
75
|
+
complete: (err, _stmt, rows) => (err ? reject(err) : resolve(rows)),
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
await new Promise((resolve) => connection.destroy(resolve));
|
|
80
|
+
return { rows };
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The token is only used to open the connection, so request it right before connecting. Open the connection inside `run` and close it before the run ends.
|
|
86
|
+
|
|
87
|
+
## Remove the old credential
|
|
88
|
+
|
|
89
|
+
Once runs in every deployed environment connect this way, delete `SNOWFLAKE_PASSWORD`, `SNOWFLAKE_PRIVATE_KEY`, `SNOWFLAKE_PRIVATE_KEY_PATH`, and `SNOWFLAKE_PRIVATE_KEY_PASSPHRASE` from those environments on the Environment Variables page, then remove the password or key from the old Snowflake user. `SNOWFLAKE_ACCOUNT` isn't a secret and can stay.
|
|
90
|
+
|
|
91
|
+
Local Development runs can't mint OIDC tokens. Use your own Snowflake login there when `ctx.environment.type === "DEVELOPMENT"`.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Connect to HashiCorp Vault"
|
|
3
|
+
sidebarTitle: "Vault"
|
|
4
|
+
description: "Log in to Vault from your tasks with JWT auth instead of a long-lived Vault token."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use Vault's [JWT auth method](https://developer.hashicorp.com/vault/docs/auth/jwt) to exchange a Trigger.dev OIDC token for a short-lived Vault token. Your tasks read secrets with no `VAULT_TOKEN` stored anywhere. This works with self-managed Vault and HCP Vault.
|
|
8
|
+
|
|
9
|
+
Follow the [OIDC prerequisites](/oidc#prerequisites), then go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment and copy the issuer URL and subject.
|
|
10
|
+
|
|
11
|
+
## Configure Vault
|
|
12
|
+
|
|
13
|
+
Enable the JWT auth method and point it at your issuer's discovery document:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
vault auth enable -path=trigger jwt
|
|
17
|
+
|
|
18
|
+
vault write auth/trigger/config \
|
|
19
|
+
oidc_discovery_url="https://oidc.trigger.dev/YOUR_ORG_SLUG" \
|
|
20
|
+
bound_issuer="https://oidc.trigger.dev/YOUR_ORG_SLUG"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Create a role for each environment. Replace the subject with the **complete subject copied from the dashboard**, and the policy with one that allows only the paths your task reads:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
vault write auth/trigger/role/trigger-production \
|
|
27
|
+
role_type="jwt" \
|
|
28
|
+
bound_audiences="vault" \
|
|
29
|
+
bound_subject="YOUR_ENVIRONMENT_SUBJECT" \
|
|
30
|
+
user_claim="sub" \
|
|
31
|
+
token_policies="trigger-production" \
|
|
32
|
+
token_ttl="15m"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`bound_audiences` is the audience your task requests; `vault` is an example, any value works if both sides match. See the [JWT auth API](https://developer.hashicorp.com/vault/api-docs/auth/jwt#create-update-role) for every role option.
|
|
36
|
+
|
|
37
|
+
## Read a secret in your task
|
|
38
|
+
|
|
39
|
+
```ts /trigger/read-from-vault.ts
|
|
40
|
+
import { auth, task } from "@trigger.dev/sdk";
|
|
41
|
+
|
|
42
|
+
const vaultAddr = "https://vault.example.com:8200";
|
|
43
|
+
|
|
44
|
+
export const readFromVault = task({
|
|
45
|
+
id: "read-from-vault",
|
|
46
|
+
run: async () => {
|
|
47
|
+
const { token: jwt } = await auth.getOIDCToken({ audience: "vault" });
|
|
48
|
+
|
|
49
|
+
const login = await fetch(`${vaultAddr}/v1/auth/trigger/login`, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: JSON.stringify({ role: "trigger-production", jwt }),
|
|
52
|
+
});
|
|
53
|
+
if (!login.ok) throw new Error(`Vault login failed: ${login.status}`);
|
|
54
|
+
const { auth: vaultAuth } = await login.json();
|
|
55
|
+
|
|
56
|
+
const secret = await fetch(`${vaultAddr}/v1/secret/data/my-app`, {
|
|
57
|
+
headers: { "X-Vault-Token": vaultAuth.client_token },
|
|
58
|
+
});
|
|
59
|
+
const { data } = await secret.json();
|
|
60
|
+
// Use data.data here. Never log or return it.
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The login response holds the Vault token at `auth.client_token`. On HCP Vault or Vault Enterprise, add an `X-Vault-Namespace` header to both requests. Log in inside `run`, and log in again if the run outlives `token_ttl`.
|
|
66
|
+
|
|
67
|
+
## Remove the old credential
|
|
68
|
+
|
|
69
|
+
Once runs in every deployed environment log in this way, delete `VAULT_TOKEN` from those environments on the Environment Variables page and revoke the old token with `vault token revoke`.
|
|
70
|
+
|
|
71
|
+
Local Development runs can't mint OIDC tokens. Use your own Vault login there when `ctx.environment.type === "DEVELOPMENT"`.
|
package/docs/oidc.mdx
CHANGED
|
@@ -34,6 +34,8 @@ Choose an official integration, or connect a service that supports external OIDC
|
|
|
34
34
|
|
|
35
35
|
For other services, follow [Custom integrations](/oidc/custom) to request a token and implement the service's authentication flow.
|
|
36
36
|
|
|
37
|
+
The OIDC page in the dashboard lists the environment variables in your project that hold credentials OIDC could replace, such as `AWS_ACCESS_KEY_ID` or `ANTHROPIC_API_KEY`, grouped by service with a link to each service's guide. The same keys are listed under **Replace with OIDC** on the environment variables [Needs attention page](/deploy-environment-variables#values-that-need-attention).
|
|
38
|
+
|
|
37
39
|
## Prerequisites
|
|
38
40
|
|
|
39
41
|
- Use `@trigger.dev/sdk` and the Trigger.dev CLI (`trigger.dev`) **4.8.3 or later**, including the CLI used in CI.
|
package/docs/runs/metadata.mdx
CHANGED
|
@@ -347,7 +347,7 @@ export const myTask = task({
|
|
|
347
347
|
run: async (payload: { prompt: string }) => {
|
|
348
348
|
const completion = await openai.chat.completions.create({
|
|
349
349
|
messages: [{ role: "user", content: payload.prompt }],
|
|
350
|
-
model: "gpt-
|
|
350
|
+
model: "gpt-6-luna",
|
|
351
351
|
stream: true,
|
|
352
352
|
});
|
|
353
353
|
|
|
@@ -364,6 +364,8 @@ We patch the latest released version line only, so keep an eye on new releases t
|
|
|
364
364
|
|
|
365
365
|
You can also lock the versions of the bundled services, for example with `CLICKHOUSE_IMAGE_TAG`. If you do, or if you bring your own ClickHouse via `CLICKHOUSE_URL`, note that Trigger.dev requires ClickHouse 25.8 or newer.
|
|
366
366
|
|
|
367
|
+
The optional `LOGS_SEARCH_INSERT_ASYNC` setting defaults to `false` and requires ClickHouse 26.2 or newer when enabled. Leave it disabled on ClickHouse 25.8.
|
|
368
|
+
|
|
367
369
|
<Note>
|
|
368
370
|
The bundled ClickHouse uses the official `clickhouse/clickhouse-server` image, and your existing
|
|
369
371
|
data volume carries over automatically on upgrade. If you pinned `CLICKHOUSE_IMAGE_TAG` to a
|
|
@@ -11,6 +11,8 @@ mode: "wide"
|
|
|
11
11
|
| `SESSION_SECRET` | Yes | — | Session encryption secret. Run: `openssl rand -hex 16` |
|
|
12
12
|
| `MAGIC_LINK_SECRET` | Yes | — | Magic link encryption secret. Run: `openssl rand -hex 16` |
|
|
13
13
|
| `ENCRYPTION_KEY` | Yes | — | Secret store encryption key. Run: `openssl rand -hex 16` |
|
|
14
|
+
| `ENVIRONMENT_ENCRYPTION_ENABLED` | No | false | Master gate for automatic per-environment encryption enrollment. Also requires `environmentEncryptionEnabled` in organization feature flags or the global feature flag (organization overrides global; unset is false). Enable only after all instances have been upgraded. Existing encrypted environments continue using their keys if any rollout gate is later disabled. |
|
|
15
|
+
| `ENVIRONMENT_ENCRYPTION_KMS_KEY_ARN` | No | unset | Resolved symmetric AWS KMS key ARN for wrapping new environments' keys. Unset uses `ENCRYPTION_KEYRING` (or the legacy `ENCRYPTION_KEY`) locally, without AWS access. Changing this does not alter existing environment-key versions. |
|
|
14
16
|
| `MANAGED_WORKER_SECRET` | Yes | — | Managed worker secret. Must be set and match supervisor. Run: `openssl rand -hex 32` |
|
|
15
17
|
| `PUBLIC_TOKEN_SUBJECT_SECRET` | No | `ENCRYPTION_KEY` | Key that encrypts the environment id inside public access tokens. Set it to keep this separate from the secret store key. Run: `openssl rand -hex 32` |
|
|
16
18
|
| `PUBLIC_TOKEN_SEALED_SUBJECT_ENABLED` | No | false | Encrypt the environment id inside newly minted public access tokens. Turn on only once every webapp instance runs a version that can read them. |
|
|
@@ -47,7 +49,7 @@ mode: "wide"
|
|
|
47
49
|
| `BLOCKED_EMAIL_DOMAINS` | No | — | Comma-separated email domains that can't sign in or sign up, including their subdomains. |
|
|
48
50
|
| `LOGIN_RATE_LIMITS_ENABLED` | No | true | Enable rate limiting on magic-link login. |
|
|
49
51
|
| `MAGIC_LINK_SAME_BROWSER_REQUIRED` | No | true | Only accept a magic link opened in the browser that requested it. Set to false to allow opening it on another device.|
|
|
50
|
-
| `PERSONAL_ACCESS_TOKEN_EXPIRY_DAYS` | No | 30,90,365 | Lifetimes, in days (1 to 3650), offered when creating a personal access token on the dashboard. Comma-separated.
|
|
52
|
+
| `PERSONAL_ACCESS_TOKEN_EXPIRY_DAYS` | No | 30,90,365 | Lifetimes, in days (1 to 3650), offered when creating a personal access token on the dashboard. Comma-separated. The longest is also the furthest a custom expiry date can be. |
|
|
51
53
|
| `PERSONAL_ACCESS_TOKEN_DEFAULT_EXPIRY_DAYS` | No | 90 | The lifetime preselected when creating a personal access token. If it isn't one of the offered lifetimes, the shortest is preselected. |
|
|
52
54
|
| `CLI_LOGIN_IDLE_TIMEOUT_DAYS` | No | 7 | A token minted by a CLI or MCP login stops working after this many days without use. Set to 0 to turn this off. Each token keeps the value it was minted with. |
|
|
53
55
|
| `PERSONAL_ACCESS_TOKEN_EXPIRY_EMAILS_ENABLED` | No | true | Email the owner 7 days before a dashboard-created personal access token expires, and again when it has. Only runs when `EMAIL_TRANSPORT` is set. |
|
|
@@ -168,6 +170,7 @@ mode: "wide"
|
|
|
168
170
|
| `STREAMING_BATCH_MAX_ITEMS` | No | 1000 | Max items in streaming batch (v3 API, requires SDK 4.3.1+). |
|
|
169
171
|
| `STREAMING_BATCH_ITEM_MAXIMUM_SIZE` | No | 3145728 (3MB) | Max size per item in streaming batch. |
|
|
170
172
|
| `STREAMING_BATCH_INGEST_CONCURRENCY` | No | 10 | Items ingested concurrently per streaming batch request. Peak memory ≈ this × item size. Set to 1 for sequential. |
|
|
173
|
+
| `ENVIRONMENT_VARIABLES_COMPARE_MAX_KEYS` | No | 1000 | Most keys one environment variables comparison compares, and most values the Needs attention page checks for empty ones. Above it the dashboard asks to search or pick fewer keys. |
|
|
171
174
|
| **OTel limits** | | | |
|
|
172
175
|
| `TRIGGER_OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT` | No | 1024 | OTel span attribute count limit. |
|
|
173
176
|
| `TRIGGER_OTEL_LOG_ATTRIBUTE_COUNT_LIMIT` | No | 1024 | OTel log attribute count limit. |
|
|
@@ -320,6 +320,8 @@ Migration from the old Bitnami subchart to the official `clickhouse/clickhouse-s
|
|
|
320
320
|
ClickHouse externally for a clustered or replicated setup.
|
|
321
321
|
</Note>
|
|
322
322
|
|
|
323
|
+
The optional `LOGS_SEARCH_INSERT_ASYNC` setting defaults to `false` and requires ClickHouse 26.2 or newer when enabled. Leave it disabled on ClickHouse 25.8.
|
|
324
|
+
|
|
323
325
|
**Direct configuration:**
|
|
324
326
|
|
|
325
327
|
```yaml
|
|
@@ -87,7 +87,7 @@ Prefer building the tool with the AI SDK’s [`tool()`](https://sdk.vercel.ai/do
|
|
|
87
87
|
```ts
|
|
88
88
|
import { ai } from "@trigger.dev/sdk/ai";
|
|
89
89
|
import { schemaTask } from "@trigger.dev/sdk";
|
|
90
|
-
import { tool, generateText } from "ai";
|
|
90
|
+
import { tool, generateText, stepCountIs } from "ai";
|
|
91
91
|
import { openai } from "@ai-sdk/openai";
|
|
92
92
|
import { z } from "zod";
|
|
93
93
|
|
|
@@ -115,24 +115,25 @@ export const myAiTask = schemaTask({
|
|
|
115
115
|
run: async ({ text }) => {
|
|
116
116
|
const { text: reply } = await generateText({
|
|
117
117
|
prompt: text,
|
|
118
|
-
model: openai("gpt-
|
|
118
|
+
model: openai("gpt-6-luna"),
|
|
119
119
|
tools: {
|
|
120
120
|
myTool,
|
|
121
121
|
},
|
|
122
|
+
stopWhen: stepCountIs(5),
|
|
122
123
|
});
|
|
123
124
|
return reply;
|
|
124
125
|
},
|
|
125
126
|
});
|
|
126
127
|
```
|
|
127
128
|
|
|
128
|
-
`
|
|
129
|
+
`toModelOutput` and other tool-level options belong on **`tool({ ... })`**, not on `ai.toolExecute`:
|
|
129
130
|
|
|
130
131
|
```ts
|
|
131
132
|
import { openai } from "@ai-sdk/openai";
|
|
132
133
|
import { Sandbox } from "@e2b/code-interpreter";
|
|
133
134
|
import { ai } from "@trigger.dev/sdk/ai";
|
|
134
135
|
import { schemaTask } from "@trigger.dev/sdk";
|
|
135
|
-
import {
|
|
136
|
+
import { generateText, Output, tool } from "ai";
|
|
136
137
|
import { z } from "zod";
|
|
137
138
|
|
|
138
139
|
const chartTask = schemaTask({
|
|
@@ -142,17 +143,19 @@ const chartTask = schemaTask({
|
|
|
142
143
|
input: z.string().describe("The chart to generate"),
|
|
143
144
|
}),
|
|
144
145
|
run: async ({ input }) => {
|
|
145
|
-
const
|
|
146
|
-
model: openai("gpt-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
const { output } = await generateText({
|
|
147
|
+
model: openai("gpt-6-luna"),
|
|
148
|
+
output: Output.object({
|
|
149
|
+
schema: z.object({
|
|
150
|
+
code: z.string().describe("The Python code to execute"),
|
|
151
|
+
}),
|
|
149
152
|
}),
|
|
150
153
|
system: `You are a helpful assistant that generates matplotlib code. End with plt.show().`,
|
|
151
154
|
prompt: input,
|
|
152
155
|
});
|
|
153
156
|
|
|
154
157
|
const sandbox = await Sandbox.create();
|
|
155
|
-
const execution = await sandbox.runCode(
|
|
158
|
+
const execution = await sandbox.runCode(output.code);
|
|
156
159
|
const firstResult = execution.results[0];
|
|
157
160
|
|
|
158
161
|
if (firstResult.png) {
|
|
@@ -162,16 +165,26 @@ const chartTask = schemaTask({
|
|
|
162
165
|
},
|
|
163
166
|
});
|
|
164
167
|
|
|
168
|
+
// Keep the executor in its own const so `output` below is typed from the task
|
|
169
|
+
const executeChart = ai.toolExecute(chartTask);
|
|
170
|
+
|
|
165
171
|
export const chartTool = tool({
|
|
166
172
|
description: chartTask.description ?? "",
|
|
167
173
|
inputSchema: chartTask.schema!,
|
|
168
|
-
execute:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
execute: executeChart,
|
|
175
|
+
toModelOutput: ({ output }) => ({
|
|
176
|
+
type: "content",
|
|
177
|
+
value: [
|
|
178
|
+
{ type: "file", mediaType: "image/png", data: { type: "data", data: output.chart } },
|
|
179
|
+
],
|
|
180
|
+
}),
|
|
172
181
|
});
|
|
173
182
|
```
|
|
174
183
|
|
|
184
|
+
<Note>
|
|
185
|
+
This sample uses AI SDK 7. On AI SDK 6, use `{ type: "image-data", data: output.chart, mediaType: "image/png" }` as the item in `value` instead of the `file` part. On AI SDK 5, pass `experimental_output: Output.object(...)` instead of `output` and read the result from `experimental_output`, and use `toModelOutput: (output) => ({ type: "content", value: [{ type: "media", data: output.chart, mediaType: "image/png" }] })`.
|
|
186
|
+
</Note>
|
|
187
|
+
|
|
175
188
|
Inside the task run, you can read tool execution context with **`ai.currentToolOptions()`** (and helpers like `ai.toolCallId()`, `ai.chatContext()` when running inside a [`chat.agent`](/ai-chat/overview)):
|
|
176
189
|
|
|
177
190
|
```ts
|
package/docs/tasks/streams.mdx
CHANGED
|
@@ -402,7 +402,7 @@ export async function POST(req: Request) {
|
|
|
402
402
|
const { messages, runId } = await req.json();
|
|
403
403
|
|
|
404
404
|
const result = streamText({
|
|
405
|
-
model: openai("gpt-
|
|
405
|
+
model: openai("gpt-6-luna"),
|
|
406
406
|
messages,
|
|
407
407
|
});
|
|
408
408
|
|
|
@@ -686,7 +686,7 @@ export const generateAI = task({
|
|
|
686
686
|
id: "generate-ai",
|
|
687
687
|
run: async (payload: { prompt: string }) => {
|
|
688
688
|
const result = streamText({
|
|
689
|
-
model: openai("gpt-
|
|
689
|
+
model: openai("gpt-6-luna"),
|
|
690
690
|
prompt: payload.prompt,
|
|
691
691
|
});
|
|
692
692
|
|
package/docs/troubleshooting.mdx
CHANGED
|
@@ -53,6 +53,13 @@ If you see "Connection error" when running `trigger login` (or "Failed to create
|
|
|
53
53
|
2. **VPN or firewall:** Disconnect from VPN or check firewall/proxy; try `npx trigger.dev@latest login --log-level debug` for more detail.
|
|
54
54
|
3. **TLS / certificate store:** Node may use a different CA store than your OS (e.g. `curl` works but the CLI fails). Try `export NODE_EXTRA_CA_CERTS=/etc/ssl/cert.pem` (macOS/Linux) then login again, or reinstall Node so it gets updated certs. Behind a corporate proxy or custom CA? Set `NODE_EXTRA_CA_CERTS` to that CA file.
|
|
55
55
|
|
|
56
|
+
### `personal_access_token_expired` or `cli_login_expired`
|
|
57
|
+
|
|
58
|
+
If a request fails with `401` and one of these codes, the token has expired:
|
|
59
|
+
|
|
60
|
+
- **`personal_access_token_expired`**: a personal access token from the dashboard reached the expiry date chosen when it was created. Create a new one on the [Personal Access Tokens](https://cloud.trigger.dev/account/tokens) page and replace the old one wherever it's stored. See [PAT expiry](/management/authentication#pat-expiry).
|
|
61
|
+
- **`cli_login_expired`**: a CLI or MCP login went unused for 7 days. Run `npx trigger.dev@latest login`. With a CLI version before 4.8.4, `login` can't replace an expired login, so run `trigger.dev logout` first. See [CLI login expiry](/cli-login-commands#login-expiry).
|
|
62
|
+
|
|
56
63
|
### Runs never dequeue in dev
|
|
57
64
|
|
|
58
65
|
If runs sit in the queue and never start while running `trigger.dev dev`, check whether you have more than one local instance running against the same project. Each project has a single dev environment, and only one `trigger.dev dev` instance can consume from it at a time, so a second instance causes runs to be split between them and some appear stuck. Keep a single `trigger.dev dev` running per project. [Upvote isolated dev sessions](https://triggerdev.featurebase.app/p/isolated-dev-sessions-for-multiple-local-trigger-dev-instances) if you need to run multiple local instances.
|