From 7449708e800f447610c7f3dbdb526c477e0c1237 Mon Sep 17 00:00:00 2001 From: Rayan Pal Date: Sun, 11 Jan 2026 14:27:38 -0800 Subject: [PATCH] feat(runs): add clientConfig support to runs.retrieve() and runs.poll() - Change requestOptions type from ApiRequestOptions to TriggerApiRequestOptions - Pass clientConfig to apiClientManager.clientOrThrow() for per-request auth - Enables multi-project scenarios with different access tokens per request Fixes #2769 --- .changeset/runs-retrieve-request-options.md | 11 +++++++++++ packages/trigger-sdk/src/v3/runs.ts | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .changeset/runs-retrieve-request-options.md diff --git a/.changeset/runs-retrieve-request-options.md b/.changeset/runs-retrieve-request-options.md new file mode 100644 index 0000000000..55fb587091 --- /dev/null +++ b/.changeset/runs-retrieve-request-options.md @@ -0,0 +1,11 @@ +--- +"@trigger.dev/sdk": patch +--- + +feat(runs): add clientConfig support to runs.retrieve() and runs.poll() + +This change updates `runs.retrieve()` and `runs.poll()` to accept `TriggerApiRequestOptions` instead of `ApiRequestOptions`, enabling per-request client configuration via the `clientConfig` property. + +This aligns `runs.retrieve()` with other SDK methods like `tasks.trigger()` that already support `clientConfig` for multi-project scenarios where different access tokens are needed per request. + +Fixes #2769 diff --git a/packages/trigger-sdk/src/v3/runs.ts b/packages/trigger-sdk/src/v3/runs.ts index 7081c448d7..a6d38cae6e 100644 --- a/packages/trigger-sdk/src/v3/runs.ts +++ b/packages/trigger-sdk/src/v3/runs.ts @@ -16,6 +16,7 @@ import type { AsyncIterableStream, ApiPromise, RealtimeRunSkipColumns, + TriggerApiRequestOptions, } from "@trigger.dev/core/v3"; import { CanceledRunResponse, @@ -167,9 +168,9 @@ type RunId = TRunId extends AnyRunHandle | AnyBatchedRunHandle function retrieveRun( runId: RunId, - requestOptions?: ApiRequestOptions + requestOptions?: TriggerApiRequestOptions ): ApiPromise> { - const apiClient = apiClientManager.clientOrThrow(); + const apiClient = apiClientManager.clientOrThrow(requestOptions?.clientConfig); const $requestOptions = mergeRequestOptions( { @@ -316,7 +317,7 @@ const MAX_POLL_ATTEMPTS = 500; async function poll( runId: RunId, options?: { pollIntervalMs?: number }, - requestOptions?: ApiRequestOptions + requestOptions?: TriggerApiRequestOptions ) { let attempts = 0;