@trigger.dev/core 4.8.0 → 4.8.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.
Files changed (157) hide show
  1. package/dist/commonjs/v3/apiClient/core.d.ts +2 -0
  2. package/dist/commonjs/v3/apiClient/core.js +16 -1
  3. package/dist/commonjs/v3/apiClient/core.js.map +1 -1
  4. package/dist/commonjs/v3/apiClient/index.d.ts +11 -2
  5. package/dist/commonjs/v3/apiClient/index.js +317 -230
  6. package/dist/commonjs/v3/apiClient/index.js.map +1 -1
  7. package/dist/commonjs/v3/apiClient/runStream.d.ts +3 -1
  8. package/dist/commonjs/v3/apiClient/runStream.js +12 -3
  9. package/dist/commonjs/v3/apiClient/runStream.js.map +1 -1
  10. package/dist/commonjs/v3/apiClientManager/index.js +38 -9
  11. package/dist/commonjs/v3/apiClientManager/index.js.map +1 -1
  12. package/dist/commonjs/v3/build/runtime.d.ts +11 -0
  13. package/dist/commonjs/v3/build/runtime.js +24 -1
  14. package/dist/commonjs/v3/build/runtime.js.map +1 -1
  15. package/dist/commonjs/v3/index.d.ts +2 -0
  16. package/dist/commonjs/v3/index.js +4 -1
  17. package/dist/commonjs/v3/index.js.map +1 -1
  18. package/dist/commonjs/v3/realtimeStreams/streamInstance.js +1 -1
  19. package/dist/commonjs/v3/realtimeStreams/streamInstance.js.map +1 -1
  20. package/dist/commonjs/v3/realtimeStreams/streamsWriterV1.d.ts +1 -0
  21. package/dist/commonjs/v3/realtimeStreams/streamsWriterV1.js +2 -0
  22. package/dist/commonjs/v3/realtimeStreams/streamsWriterV1.js.map +1 -1
  23. package/dist/commonjs/v3/runEngineWorker/index.d.ts +1 -0
  24. package/dist/commonjs/v3/runEngineWorker/index.js +1 -0
  25. package/dist/commonjs/v3/runEngineWorker/index.js.map +1 -1
  26. package/dist/commonjs/v3/runEngineWorker/runTokenRefresh.d.ts +50 -0
  27. package/dist/commonjs/v3/runEngineWorker/runTokenRefresh.js +41 -0
  28. package/dist/commonjs/v3/runEngineWorker/runTokenRefresh.js.map +1 -0
  29. package/dist/commonjs/v3/runEngineWorker/supervisor/http.d.ts +11 -3
  30. package/dist/commonjs/v3/runEngineWorker/supervisor/http.js +19 -1
  31. package/dist/commonjs/v3/runEngineWorker/supervisor/http.js.map +1 -1
  32. package/dist/commonjs/v3/runEngineWorker/supervisor/schemas.d.ts +42 -0
  33. package/dist/commonjs/v3/runEngineWorker/supervisor/schemas.js +18 -2
  34. package/dist/commonjs/v3/runEngineWorker/supervisor/schemas.js.map +1 -1
  35. package/dist/commonjs/v3/runEngineWorker/supervisor/session.d.ts +6 -0
  36. package/dist/commonjs/v3/runEngineWorker/supervisor/session.js +44 -6
  37. package/dist/commonjs/v3/runEngineWorker/supervisor/session.js.map +1 -1
  38. package/dist/commonjs/v3/runEngineWorker/workload/http.d.ts +1 -0
  39. package/dist/commonjs/v3/runEngineWorker/workload/schemas.d.ts +31 -0
  40. package/dist/commonjs/v3/runEngineWorker/workload/schemas.js +1 -1
  41. package/dist/commonjs/v3/runEngineWorker/workload/schemas.js.map +1 -1
  42. package/dist/commonjs/v3/runToken.d.ts +13 -0
  43. package/dist/commonjs/v3/runToken.js +81 -0
  44. package/dist/commonjs/v3/runToken.js.map +1 -0
  45. package/dist/commonjs/v3/runTokenOperations.d.ts +125 -0
  46. package/dist/commonjs/v3/runTokenOperations.js +136 -0
  47. package/dist/commonjs/v3/runTokenOperations.js.map +1 -0
  48. package/dist/commonjs/v3/runTokenTelemetry.d.ts +3 -0
  49. package/dist/commonjs/v3/runTokenTelemetry.js +30 -0
  50. package/dist/commonjs/v3/runTokenTelemetry.js.map +1 -0
  51. package/dist/commonjs/v3/schemas/api.d.ts +15 -0
  52. package/dist/commonjs/v3/schemas/build.d.ts +28 -0
  53. package/dist/commonjs/v3/schemas/build.js +14 -1
  54. package/dist/commonjs/v3/schemas/build.js.map +1 -1
  55. package/dist/commonjs/v3/schemas/checkpoints.d.ts +1 -0
  56. package/dist/commonjs/v3/schemas/common.d.ts +3 -2
  57. package/dist/commonjs/v3/schemas/common.js +4 -3
  58. package/dist/commonjs/v3/schemas/common.js.map +1 -1
  59. package/dist/commonjs/v3/schemas/messages.d.ts +21 -0
  60. package/dist/commonjs/v3/schemas/messages.js +10 -0
  61. package/dist/commonjs/v3/schemas/messages.js.map +1 -1
  62. package/dist/commonjs/v3/schemas/resources.d.ts +16 -0
  63. package/dist/commonjs/v3/schemas/runEngine.d.ts +1 -0
  64. package/dist/commonjs/v3/schemas/runEngine.js +2 -0
  65. package/dist/commonjs/v3/schemas/runEngine.js.map +1 -1
  66. package/dist/commonjs/v3/schemas/schemas.d.ts +16 -0
  67. package/dist/commonjs/v3/schemas/webhookConfig.d.ts +16 -0
  68. package/dist/commonjs/v3/schemas/webhookConfig.js +9 -3
  69. package/dist/commonjs/v3/schemas/webhookConfig.js.map +1 -1
  70. package/dist/commonjs/v3/sdkCredentialTelemetry.d.ts +8 -0
  71. package/dist/commonjs/v3/sdkCredentialTelemetry.js +147 -0
  72. package/dist/commonjs/v3/sdkCredentialTelemetry.js.map +1 -0
  73. package/dist/commonjs/v3/streams/asyncIterableStream.d.ts +1 -1
  74. package/dist/commonjs/v3/streams/asyncIterableStream.js +2 -1
  75. package/dist/commonjs/v3/streams/asyncIterableStream.js.map +1 -1
  76. package/dist/commonjs/v3/zodIpc.js +4 -2
  77. package/dist/commonjs/v3/zodIpc.js.map +1 -1
  78. package/dist/commonjs/version.js +1 -1
  79. package/dist/esm/v3/apiClient/core.d.ts +2 -0
  80. package/dist/esm/v3/apiClient/core.js +16 -1
  81. package/dist/esm/v3/apiClient/core.js.map +1 -1
  82. package/dist/esm/v3/apiClient/index.d.ts +11 -2
  83. package/dist/esm/v3/apiClient/index.js +317 -230
  84. package/dist/esm/v3/apiClient/index.js.map +1 -1
  85. package/dist/esm/v3/apiClient/runStream.d.ts +3 -1
  86. package/dist/esm/v3/apiClient/runStream.js +12 -3
  87. package/dist/esm/v3/apiClient/runStream.js.map +1 -1
  88. package/dist/esm/v3/apiClientManager/index.js +39 -10
  89. package/dist/esm/v3/apiClientManager/index.js.map +1 -1
  90. package/dist/esm/v3/build/runtime.d.ts +11 -0
  91. package/dist/esm/v3/build/runtime.js +22 -1
  92. package/dist/esm/v3/build/runtime.js.map +1 -1
  93. package/dist/esm/v3/index.d.ts +2 -0
  94. package/dist/esm/v3/index.js +2 -0
  95. package/dist/esm/v3/index.js.map +1 -1
  96. package/dist/esm/v3/realtimeStreams/streamInstance.js +1 -1
  97. package/dist/esm/v3/realtimeStreams/streamInstance.js.map +1 -1
  98. package/dist/esm/v3/realtimeStreams/streamsWriterV1.d.ts +1 -0
  99. package/dist/esm/v3/realtimeStreams/streamsWriterV1.js +2 -0
  100. package/dist/esm/v3/realtimeStreams/streamsWriterV1.js.map +1 -1
  101. package/dist/esm/v3/runEngineWorker/index.d.ts +1 -0
  102. package/dist/esm/v3/runEngineWorker/index.js +1 -0
  103. package/dist/esm/v3/runEngineWorker/index.js.map +1 -1
  104. package/dist/esm/v3/runEngineWorker/runTokenRefresh.d.ts +50 -0
  105. package/dist/esm/v3/runEngineWorker/runTokenRefresh.js +38 -0
  106. package/dist/esm/v3/runEngineWorker/runTokenRefresh.js.map +1 -0
  107. package/dist/esm/v3/runEngineWorker/supervisor/http.d.ts +11 -3
  108. package/dist/esm/v3/runEngineWorker/supervisor/http.js +20 -2
  109. package/dist/esm/v3/runEngineWorker/supervisor/http.js.map +1 -1
  110. package/dist/esm/v3/runEngineWorker/supervisor/schemas.d.ts +42 -0
  111. package/dist/esm/v3/runEngineWorker/supervisor/schemas.js +17 -1
  112. package/dist/esm/v3/runEngineWorker/supervisor/schemas.js.map +1 -1
  113. package/dist/esm/v3/runEngineWorker/supervisor/session.d.ts +6 -0
  114. package/dist/esm/v3/runEngineWorker/supervisor/session.js +44 -6
  115. package/dist/esm/v3/runEngineWorker/supervisor/session.js.map +1 -1
  116. package/dist/esm/v3/runEngineWorker/workload/http.d.ts +1 -0
  117. package/dist/esm/v3/runEngineWorker/workload/schemas.d.ts +31 -0
  118. package/dist/esm/v3/runEngineWorker/workload/schemas.js +2 -2
  119. package/dist/esm/v3/runEngineWorker/workload/schemas.js.map +1 -1
  120. package/dist/esm/v3/runToken.d.ts +13 -0
  121. package/dist/esm/v3/runToken.js +76 -0
  122. package/dist/esm/v3/runToken.js.map +1 -0
  123. package/dist/esm/v3/runTokenOperations.d.ts +125 -0
  124. package/dist/esm/v3/runTokenOperations.js +131 -0
  125. package/dist/esm/v3/runTokenOperations.js.map +1 -0
  126. package/dist/esm/v3/runTokenTelemetry.d.ts +3 -0
  127. package/dist/esm/v3/runTokenTelemetry.js +27 -0
  128. package/dist/esm/v3/runTokenTelemetry.js.map +1 -0
  129. package/dist/esm/v3/schemas/api.d.ts +15 -0
  130. package/dist/esm/v3/schemas/build.d.ts +28 -0
  131. package/dist/esm/v3/schemas/build.js +14 -1
  132. package/dist/esm/v3/schemas/build.js.map +1 -1
  133. package/dist/esm/v3/schemas/checkpoints.d.ts +1 -0
  134. package/dist/esm/v3/schemas/common.d.ts +3 -2
  135. package/dist/esm/v3/schemas/common.js +4 -3
  136. package/dist/esm/v3/schemas/common.js.map +1 -1
  137. package/dist/esm/v3/schemas/messages.d.ts +21 -0
  138. package/dist/esm/v3/schemas/messages.js +10 -0
  139. package/dist/esm/v3/schemas/messages.js.map +1 -1
  140. package/dist/esm/v3/schemas/resources.d.ts +16 -0
  141. package/dist/esm/v3/schemas/runEngine.d.ts +1 -0
  142. package/dist/esm/v3/schemas/runEngine.js +2 -0
  143. package/dist/esm/v3/schemas/runEngine.js.map +1 -1
  144. package/dist/esm/v3/schemas/schemas.d.ts +16 -0
  145. package/dist/esm/v3/schemas/webhookConfig.d.ts +16 -0
  146. package/dist/esm/v3/schemas/webhookConfig.js +9 -3
  147. package/dist/esm/v3/schemas/webhookConfig.js.map +1 -1
  148. package/dist/esm/v3/sdkCredentialTelemetry.d.ts +8 -0
  149. package/dist/esm/v3/sdkCredentialTelemetry.js +142 -0
  150. package/dist/esm/v3/sdkCredentialTelemetry.js.map +1 -0
  151. package/dist/esm/v3/streams/asyncIterableStream.d.ts +1 -1
  152. package/dist/esm/v3/streams/asyncIterableStream.js +2 -1
  153. package/dist/esm/v3/streams/asyncIterableStream.js.map +1 -1
  154. package/dist/esm/v3/zodIpc.js +4 -2
  155. package/dist/esm/v3/zodIpc.js.map +1 -1
  156. package/dist/esm/version.js +1 -1
  157. package/package.json +2 -2
@@ -23,7 +23,10 @@ const nanoid_1 = require("nanoid");
23
23
  const v4_1 = require("zod/v4");
24
24
  const version_js_1 = require("../../version.js");
25
25
  const apiKeys_js_1 = require("../apiKeys.js");
26
+ const runToken_js_1 = require("../runToken.js");
26
27
  const jwt_js_1 = require("../jwt.js");
28
+ const runTokenOperations_js_1 = require("../runTokenOperations.js");
29
+ const sdkCredentialTelemetry_js_1 = require("../sdkCredentialTelemetry.js");
27
30
  const index_js_1 = require("../schemas/index.js");
28
31
  const wireProtocol_js_1 = require("../sessionStreams/wireProtocol.js");
29
32
  const task_context_api_js_1 = require("../task-context-api.js");
@@ -56,7 +59,10 @@ const CreatePublicTokenResponseBody = v4_1.z.object({ token: v4_1.z.string() });
56
59
  * Trigger.dev v3 API client
57
60
  */
58
61
  class ApiClient {
62
+ resolveAccessToken;
59
63
  baseUrl;
64
+ // ponytail: the configured credential, so the root key while it is injected into runs.
65
+ // TRI-15076 decides this property's contract once runs only receive run tokens.
60
66
  accessToken;
61
67
  previewBranch;
62
68
  futureFlags;
@@ -66,7 +72,8 @@ class ApiClient {
66
72
  constructor(baseUrl, accessToken,
67
73
  // Carries the branch for any branchable env (preview or dev) — both ride the
68
74
  // x-trigger-branch header, and the server disambiguates by the token's env.
69
- previewBranch, requestOptions = {}, futureFlags = {}, refreshAccessToken) {
75
+ previewBranch, requestOptions = {}, futureFlags = {}, refreshAccessToken, resolveAccessToken) {
76
+ this.resolveAccessToken = resolveAccessToken;
70
77
  this.accessToken = accessToken;
71
78
  this.refreshAccessToken = refreshAccessToken;
72
79
  this.baseUrl = baseUrl.replace(/\/$/, "");
@@ -76,64 +83,106 @@ class ApiClient {
76
83
  this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, restRequestOptions);
77
84
  this.futureFlags = futureFlags;
78
85
  }
86
+ getAccessToken(operation, recordSelection = false) {
87
+ return this.getAuthenticationHeaders(operation, recordSelection).Authorization.slice("Bearer ".length);
88
+ }
89
+ getAuthenticationHeaders(operation, recordSelection = true) {
90
+ const selection = this.resolveAccessToken
91
+ ? this.resolveAccessToken(operation, recordSelection)
92
+ : this.accessToken;
93
+ const token = typeof selection === "object" ? selection.accessToken : selection;
94
+ if (!token)
95
+ throw new Error(`No API credential available for ${operation}`);
96
+ const headers = {
97
+ Authorization: `Bearer ${token}`,
98
+ };
99
+ if (typeof selection === "object" &&
100
+ task_context_api_js_1.taskContext.isInsideTask &&
101
+ selection.reason !== "outside_task" &&
102
+ !this.refreshAccessToken &&
103
+ (0, runTokenOperations_js_1.isRunTokenOperation)(operation)) {
104
+ headers["x-trigger-worker"] = "true";
105
+ headers[sdkCredentialTelemetry_js_1.SDK_CREDENTIAL_OPERATION_HEADER] = operation;
106
+ headers[sdkCredentialTelemetry_js_1.SDK_CREDENTIAL_REASON_HEADER] = selection.reason;
107
+ }
108
+ return headers;
109
+ }
79
110
  /**
80
111
  * Key for signing a public access token locally. Only root keys can do this —
81
112
  * an additional key isn't the environment's signing material, so a token
82
113
  * signed with one would never verify. Throw rather than return a dead token.
83
114
  */
84
115
  get #selfSigningKey() {
85
- if ((0, apiKeys_js_1.isAdditionalApiKey)(this.accessToken)) {
86
- throw new Error("This additional API key cannot self-sign public tokens, and the server did not return one. Upgrade the server or use the root API key.");
116
+ if ((0, apiKeys_js_1.isAdditionalApiKey)(this.accessToken) || (0, runToken_js_1.isRunToken)(this.accessToken)) {
117
+ throw new Error("This credential cannot self-sign public tokens, and the server did not return one. Upgrade the server or use the root API key.");
87
118
  }
88
119
  return this.accessToken;
89
120
  }
90
121
  get fetchClient() {
91
- const headers = this.#getHeaders(false);
92
122
  const fetchClient = (input, requestInit) => {
93
123
  const $requestInit = {
94
124
  ...requestInit,
95
125
  headers: {
96
126
  ...requestInit?.headers,
97
- ...headers,
127
+ ...this.#getHeaders(false, undefined, "default", true),
98
128
  },
99
129
  };
100
130
  return fetch(input, $requestInit);
101
131
  };
102
132
  return fetchClient;
103
133
  }
104
- getHeaders() {
105
- return this.#getHeaders(false);
134
+ getHeaders(operation = "unknown") {
135
+ return this.#getHeaders(false, undefined, operation, true);
136
+ }
137
+ #requestOptions(operation, options, defaults = this.defaultRequestOptions) {
138
+ return {
139
+ ...mergeRequestOptions(defaults, options),
140
+ resolveHeaders: () => this.getAuthenticationHeaders(operation),
141
+ };
142
+ }
143
+ #requestFetch(operation, fetchClient) {
144
+ if (!this.resolveAccessToken || this.refreshAccessToken)
145
+ return fetchClient;
146
+ return (input, init) => {
147
+ const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
148
+ headers.delete(sdkCredentialTelemetry_js_1.SDK_CREDENTIAL_OPERATION_HEADER);
149
+ headers.delete(sdkCredentialTelemetry_js_1.SDK_CREDENTIAL_REASON_HEADER);
150
+ for (const [key, value] of Object.entries(this.getAuthenticationHeaders(operation))) {
151
+ headers.set(key, value);
152
+ }
153
+ return (fetchClient ?? fetch)(input, { ...init, headers });
154
+ };
106
155
  }
107
156
  /**
108
157
  * Header resolver handed to stream subscriptions so a connection rejected with
109
158
  * a 401/403 can reconnect with a freshly minted token. `undefined` when no
110
159
  * `refreshAccessToken` was configured, which keeps auth errors terminal.
111
160
  */
112
- #resolveStreamHeaders() {
161
+ #resolveStreamHeaders(operation) {
113
162
  const refreshAccessToken = this.refreshAccessToken;
114
163
  if (!refreshAccessToken)
115
164
  return undefined;
116
165
  return async () => {
117
166
  const accessToken = await (0, refreshAccessToken_js_1.refreshAccessTokenOnce)(refreshAccessToken);
118
- return this.#getHeaders(false, { Authorization: `Bearer ${accessToken}` });
167
+ return this.#getHeaders(false, { Authorization: `Bearer ${accessToken}` }, operation);
119
168
  };
120
169
  }
121
170
  /** As {@link ApiClient.#resolveStreamHeaders}, for the leaner realtime header set. */
122
- #resolveRealtimeHeaders() {
171
+ #resolveRealtimeHeaders(operation) {
123
172
  const refreshAccessToken = this.refreshAccessToken;
124
173
  if (!refreshAccessToken)
125
174
  return undefined;
126
175
  return async () => {
127
176
  const accessToken = await (0, refreshAccessToken_js_1.refreshAccessTokenOnce)(refreshAccessToken);
128
- return { ...this.#getRealtimeHeaders(), Authorization: `Bearer ${accessToken}` };
177
+ return { ...this.#getRealtimeHeaders(operation), Authorization: `Bearer ${accessToken}` };
129
178
  };
130
179
  }
131
180
  async getRunResult(runId, requestOptions) {
132
181
  try {
133
182
  return await (0, core_js_1.zodfetch)(index_js_1.TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
134
183
  method: "GET",
135
- headers: this.#getHeaders(false),
136
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
184
+ headers: this.#getHeaders(false, undefined, "getRunResult"),
185
+ }, this.#requestOptions("getRunResult", requestOptions));
137
186
  }
138
187
  catch (error) {
139
188
  if (error instanceof errors_js_1.ApiError) {
@@ -147,16 +196,16 @@ class ApiClient {
147
196
  async getBatchResults(batchId, requestOptions) {
148
197
  return await (0, core_js_1.zodfetch)(index_js_1.BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
149
198
  method: "GET",
150
- headers: this.#getHeaders(false),
151
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
199
+ headers: this.#getHeaders(false, undefined, "getBatchResults"),
200
+ }, this.#requestOptions("getBatchResults", requestOptions));
152
201
  }
153
202
  triggerTask(taskId, body, clientOptions, requestOptions) {
154
203
  const encodedTaskId = (0, encodeTaskIdForPath_js_1.encodeTaskIdForPath)(taskId);
155
204
  return (0, core_js_1.zodfetch)(index_js_1.TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
156
205
  method: "POST",
157
- headers: this.#getHeaders(clientOptions?.spanParentAsLink ?? false),
206
+ headers: this.#getHeaders(clientOptions?.spanParentAsLink ?? false, undefined, "triggerTask"),
158
207
  body: JSON.stringify(body),
159
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions))
208
+ }, this.#requestOptions("triggerTask", requestOptions))
160
209
  .withResponse()
161
210
  .then(async ({ data, response }) => {
162
211
  const jwtHeader = response.headers.get("x-trigger-jwt");
@@ -187,9 +236,9 @@ class ApiClient {
187
236
  method: "POST",
188
237
  headers: this.#getHeaders(clientOptions?.spanParentAsLink ?? false, {
189
238
  "batch-processing-strategy": clientOptions?.processingStrategy,
190
- }),
239
+ }, "batchTriggerV3"),
191
240
  body: JSON.stringify(body),
192
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions))
241
+ }, this.#requestOptions("batchTriggerV3", requestOptions))
193
242
  .withResponse()
194
243
  .then(async ({ data, response }) => {
195
244
  const jwtHeader = response.headers.get("x-trigger-jwt");
@@ -230,9 +279,9 @@ class ApiClient {
230
279
  createBatch(body, clientOptions, requestOptions) {
231
280
  return (0, core_js_1.zodfetch)(index_js_1.CreateBatchResponse, `${this.baseUrl}/api/v3/batches`, {
232
281
  method: "POST",
233
- headers: this.#getHeaders(clientOptions?.spanParentAsLink ?? false),
282
+ headers: this.#getHeaders(clientOptions?.spanParentAsLink ?? false, undefined, "createBatch"),
234
283
  body: JSON.stringify(body),
235
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions))
284
+ }, this.#requestOptions("createBatch", requestOptions))
236
285
  .withResponse()
237
286
  .then(async ({ data, response }) => {
238
287
  const jwtHeader = response.headers.get("x-trigger-jwt");
@@ -285,7 +334,7 @@ class ApiClient {
285
334
  return this.#streamBatchItemsWithRetry(batchId, stream, retryOptions);
286
335
  }
287
336
  async #streamBatchItemsWithRetry(batchId, stream, retryOptions, attempt = 1) {
288
- const headers = this.#getHeaders(false);
337
+ const headers = this.#getHeaders(false, undefined, "streamBatchItems", true);
289
338
  headers["Content-Type"] = "application/x-ndjson";
290
339
  // Tee the stream: one branch for this attempt, one for potential retry
291
340
  // tee() internally buffers data consumed from one branch for the other,
@@ -385,15 +434,15 @@ class ApiClient {
385
434
  const encoded = encodeURIComponent(filename);
386
435
  return (0, core_js_1.zodfetch)(index_js_1.CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v2/packets/${encoded}`, {
387
436
  method: "PUT",
388
- headers: this.#getHeaders(false),
389
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
437
+ headers: this.#getHeaders(false, undefined, "createUploadPayloadUrl"),
438
+ }, this.#requestOptions("createUploadPayloadUrl", requestOptions));
390
439
  }
391
440
  getPayloadUrl(filename, requestOptions) {
392
441
  const encoded = encodeURIComponent(filename);
393
442
  return (0, core_js_1.zodfetch)(index_js_1.CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${encoded}`, {
394
443
  method: "GET",
395
- headers: this.#getHeaders(false),
396
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
444
+ headers: this.#getHeaders(false, undefined, "getPayloadUrl"),
445
+ }, this.#requestOptions("getPayloadUrl", requestOptions));
397
446
  }
398
447
  /**
399
448
  * Presigned GET URL for a run's stored payload or output, authorized against the run.
@@ -403,8 +452,8 @@ class ApiClient {
403
452
  try {
404
453
  return await (0, core_js_1.zodfetch)(index_js_1.CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/runs/${encodeURIComponent(runId)}/packets/${field}`, {
405
454
  method: "GET",
406
- headers: this.#getHeaders(false),
407
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
455
+ headers: this.#getHeaders(false, undefined, "getRunPacketUrl"),
456
+ }, this.#requestOptions("getRunPacketUrl", requestOptions));
408
457
  }
409
458
  catch (error) {
410
459
  if (error instanceof errors_js_1.ApiError && error.status === 404) {
@@ -417,15 +466,15 @@ class ApiClient {
417
466
  createChatSnapshotUploadUrl(sessionId, requestOptions) {
418
467
  return (0, core_js_1.zodfetch)(index_js_1.CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(sessionId)}/snapshot-url`, {
419
468
  method: "PUT",
420
- headers: this.#getHeaders(false),
421
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
469
+ headers: this.#getHeaders(false, undefined, "createChatSnapshotUploadUrl"),
470
+ }, this.#requestOptions("createChatSnapshotUploadUrl", requestOptions));
422
471
  }
423
472
  /** Presigned GET URL for a `chat.agent` session snapshot. */
424
473
  getChatSnapshotUrl(sessionId, requestOptions) {
425
474
  return (0, core_js_1.zodfetch)(index_js_1.CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(sessionId)}/snapshot-url`, {
426
475
  method: "GET",
427
- headers: this.#getHeaders(false),
428
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
476
+ headers: this.#getHeaders(false, undefined, "getChatSnapshotUrl"),
477
+ }, this.#requestOptions("getChatSnapshotUrl", requestOptions));
429
478
  }
430
479
  /**
431
480
  * One page of a `chat.agent` session's persisted transcript, most recent
@@ -440,20 +489,20 @@ class ApiClient {
440
489
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
441
490
  return (0, core_js_1.zodfetch)(index_js_1.SessionTranscriptResponseBody, `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(sessionId)}/transcript${suffix}`, {
442
491
  method: "GET",
443
- headers: this.#getHeaders(false),
444
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
492
+ headers: this.#getHeaders(false, undefined, "getSessionTranscript"),
493
+ }, this.#requestOptions("getSessionTranscript", requestOptions));
445
494
  }
446
495
  retrieveRun(runId, requestOptions) {
447
496
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
448
497
  method: "GET",
449
- headers: this.#getHeaders(false),
450
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
498
+ headers: this.#getHeaders(false, undefined, "retrieveRun"),
499
+ }, this.#requestOptions("retrieveRun", requestOptions));
451
500
  }
452
501
  retrieveRunTrace(runId, requestOptions) {
453
502
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveRunTraceResponseBody, `${this.baseUrl}/api/v1/runs/${runId}/trace`, {
454
503
  method: "GET",
455
- headers: this.#getHeaders(false),
456
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
504
+ headers: this.#getHeaders(false, undefined, "retrieveRunTrace"),
505
+ }, this.#requestOptions("retrieveRunTrace", requestOptions));
457
506
  }
458
507
  /**
459
508
  * Retrieves one page of a root run's trace as flat spans. Omit `after` for the first
@@ -468,14 +517,14 @@ class ApiClient {
468
517
  query.set("page[after]", options.after);
469
518
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveRunTracePageResponseBody, `${this.baseUrl}/api/v1/runs/${encodeURIComponent(runId)}/trace?${query.toString()}`, {
470
519
  method: "GET",
471
- headers: this.#getHeaders(false),
472
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
520
+ headers: this.#getHeaders(false, undefined, "retrieveRunTracePage"),
521
+ }, this.#requestOptions("retrieveRunTracePage", requestOptions));
473
522
  }
474
523
  retrieveSpan(runId, spanId, requestOptions) {
475
524
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveSpanDetailResponseBody, `${this.baseUrl}/api/v1/runs/${runId}/spans/${spanId}`, {
476
525
  method: "GET",
477
- headers: this.#getHeaders(false),
478
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
526
+ headers: this.#getHeaders(false, undefined, "retrieveSpan"),
527
+ }, this.#requestOptions("retrieveSpan", requestOptions));
479
528
  }
480
529
  listRuns(query, requestOptions) {
481
530
  const searchParams = createSearchQueryForListRuns(query);
@@ -486,8 +535,8 @@ class ApiClient {
486
535
  before: query?.before,
487
536
  }, {
488
537
  method: "GET",
489
- headers: this.#getHeaders(false),
490
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
538
+ headers: this.#getHeaders(false, undefined, "listRuns"),
539
+ }, this.#requestOptions("listRuns", requestOptions));
491
540
  }
492
541
  listProjectRuns(projectRef, query, requestOptions) {
493
542
  const searchParams = createSearchQueryForListRuns(query);
@@ -501,8 +550,8 @@ class ApiClient {
501
550
  before: query?.before,
502
551
  }, {
503
552
  method: "GET",
504
- headers: this.#getHeaders(false),
505
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
553
+ headers: this.#getHeaders(false, undefined, "listProjectRuns"),
554
+ }, this.#requestOptions("listProjectRuns", requestOptions));
506
555
  }
507
556
  replayRun(runId, bodyOrRequestOptions, requestOptions) {
508
557
  const isBody = bodyOrRequestOptions !== undefined &&
@@ -513,22 +562,22 @@ class ApiClient {
513
562
  : (bodyOrRequestOptions ?? requestOptions);
514
563
  return (0, core_js_1.zodfetch)(index_js_1.ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
515
564
  method: "POST",
516
- headers: this.#getHeaders(false),
565
+ headers: this.#getHeaders(false, undefined, "replayRun"),
517
566
  body: body ? JSON.stringify(withSuperJsonPayload(body)) : undefined,
518
- }, mergeRequestOptions(this.defaultRequestOptions, $requestOptions));
567
+ }, this.#requestOptions("replayRun", $requestOptions));
519
568
  }
520
569
  cancelRun(runId, requestOptions) {
521
570
  return (0, core_js_1.zodfetch)(index_js_1.CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
522
571
  method: "POST",
523
- headers: this.#getHeaders(false),
524
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
572
+ headers: this.#getHeaders(false, undefined, "cancelRun"),
573
+ }, this.#requestOptions("cancelRun", requestOptions));
525
574
  }
526
575
  createBulkAction(options, requestOptions) {
527
576
  return (0, core_js_1.zodfetch)(index_js_1.CreateBulkActionResponseBody, `${this.baseUrl}/api/v1/bulk-actions`, {
528
577
  method: "POST",
529
- headers: this.#getHeaders(false),
578
+ headers: this.#getHeaders(false, undefined, "createBulkAction"),
530
579
  body: JSON.stringify(options),
531
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
580
+ }, this.#requestOptions("createBulkAction", requestOptions));
532
581
  }
533
582
  listBulkActions(query, requestOptions) {
534
583
  return (0, core_js_1.zodfetchCursorPage)(index_js_1.BulkActionObject, `${this.baseUrl}/api/v1/bulk-actions`, {
@@ -538,55 +587,55 @@ class ApiClient {
538
587
  before: query?.before,
539
588
  }, {
540
589
  method: "GET",
541
- headers: this.#getHeaders(false),
542
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
590
+ headers: this.#getHeaders(false, undefined, "listBulkActions"),
591
+ }, this.#requestOptions("listBulkActions", requestOptions));
543
592
  }
544
593
  retrieveBulkAction(bulkActionId, requestOptions) {
545
594
  return (0, core_js_1.zodfetch)(index_js_1.BulkActionObject, `${this.baseUrl}/api/v1/bulk-actions/${bulkActionId}`, {
546
595
  method: "GET",
547
- headers: this.#getHeaders(false),
548
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
596
+ headers: this.#getHeaders(false, undefined, "retrieveBulkAction"),
597
+ }, this.#requestOptions("retrieveBulkAction", requestOptions));
549
598
  }
550
599
  abortBulkAction(bulkActionId, requestOptions) {
551
600
  return (0, core_js_1.zodfetch)(index_js_1.AbortBulkActionResponseBody, `${this.baseUrl}/api/v1/bulk-actions/${bulkActionId}/abort`, {
552
601
  method: "POST",
553
- headers: this.#getHeaders(false),
554
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
602
+ headers: this.#getHeaders(false, undefined, "abortBulkAction"),
603
+ }, this.#requestOptions("abortBulkAction", requestOptions));
555
604
  }
556
605
  resetIdempotencyKey(taskIdentifier, idempotencyKey, requestOptions) {
557
606
  return (0, core_js_1.zodfetch)(index_js_1.ResetIdempotencyKeyResponse, `${this.baseUrl}/api/v1/idempotencyKeys/${encodeURIComponent(idempotencyKey)}/reset`, {
558
607
  method: "POST",
559
- headers: this.#getHeaders(false),
608
+ headers: this.#getHeaders(false, undefined, "resetIdempotencyKey"),
560
609
  body: JSON.stringify({ taskIdentifier }),
561
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
610
+ }, this.#requestOptions("resetIdempotencyKey", requestOptions));
562
611
  }
563
612
  rescheduleRun(runId, body, requestOptions) {
564
613
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
565
614
  method: "POST",
566
- headers: this.#getHeaders(false),
615
+ headers: this.#getHeaders(false, undefined, "rescheduleRun"),
567
616
  body: JSON.stringify(body),
568
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
617
+ }, this.#requestOptions("rescheduleRun", requestOptions));
569
618
  }
570
619
  listRunEvents(runId, requestOptions) {
571
620
  return (0, core_js_1.zodfetch)(v4_1.z.any(), // TODO: define a proper schema for this
572
621
  `${this.baseUrl}/api/v1/runs/${runId}/events`, {
573
622
  method: "GET",
574
- headers: this.#getHeaders(false),
575
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
623
+ headers: this.#getHeaders(false, undefined, "listRunEvents"),
624
+ }, this.#requestOptions("listRunEvents", requestOptions));
576
625
  }
577
626
  addTags(runId, body, requestOptions) {
578
627
  return (0, core_js_1.zodfetch)(v4_1.z.object({ message: v4_1.z.string() }), `${this.baseUrl}/api/v1/runs/${runId}/tags`, {
579
628
  method: "POST",
580
- headers: this.#getHeaders(false),
629
+ headers: this.#getHeaders(false, undefined, "addTags"),
581
630
  body: JSON.stringify(body),
582
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
631
+ }, this.#requestOptions("addTags", requestOptions));
583
632
  }
584
633
  createSchedule(options, requestOptions) {
585
634
  return (0, core_js_1.zodfetch)(index_js_1.ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
586
635
  method: "POST",
587
- headers: this.#getHeaders(false),
636
+ headers: this.#getHeaders(false, undefined, "createSchedule"),
588
637
  body: JSON.stringify(options),
589
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
638
+ }, this.#requestOptions("createSchedule", requestOptions));
590
639
  }
591
640
  listSchedules(options, requestOptions) {
592
641
  const searchParams = new URLSearchParams();
@@ -601,99 +650,99 @@ class ApiClient {
601
650
  limit: options?.perPage,
602
651
  }, {
603
652
  method: "GET",
604
- headers: this.#getHeaders(false),
605
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
653
+ headers: this.#getHeaders(false, undefined, "listSchedules"),
654
+ }, this.#requestOptions("listSchedules", requestOptions));
606
655
  }
607
656
  retrieveSchedule(scheduleId, requestOptions) {
608
657
  return (0, core_js_1.zodfetch)(index_js_1.ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
609
658
  method: "GET",
610
- headers: this.#getHeaders(false),
611
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
659
+ headers: this.#getHeaders(false, undefined, "retrieveSchedule"),
660
+ }, this.#requestOptions("retrieveSchedule", requestOptions));
612
661
  }
613
662
  updateSchedule(scheduleId, options, requestOptions) {
614
663
  return (0, core_js_1.zodfetch)(index_js_1.ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
615
664
  method: "PUT",
616
- headers: this.#getHeaders(false),
665
+ headers: this.#getHeaders(false, undefined, "updateSchedule"),
617
666
  body: JSON.stringify(options),
618
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
667
+ }, this.#requestOptions("updateSchedule", requestOptions));
619
668
  }
620
669
  deactivateSchedule(scheduleId, requestOptions) {
621
670
  return (0, core_js_1.zodfetch)(index_js_1.ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
622
671
  method: "POST",
623
- headers: this.#getHeaders(false),
624
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
672
+ headers: this.#getHeaders(false, undefined, "deactivateSchedule"),
673
+ }, this.#requestOptions("deactivateSchedule", requestOptions));
625
674
  }
626
675
  activateSchedule(scheduleId, requestOptions) {
627
676
  return (0, core_js_1.zodfetch)(index_js_1.ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
628
677
  method: "POST",
629
- headers: this.#getHeaders(false),
630
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
678
+ headers: this.#getHeaders(false, undefined, "activateSchedule"),
679
+ }, this.#requestOptions("activateSchedule", requestOptions));
631
680
  }
632
681
  deleteSchedule(scheduleId, requestOptions) {
633
682
  return (0, core_js_1.zodfetch)(index_js_1.DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
634
683
  method: "DELETE",
635
- headers: this.#getHeaders(false),
636
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
684
+ headers: this.#getHeaders(false, undefined, "deleteSchedule"),
685
+ }, this.#requestOptions("deleteSchedule", requestOptions));
637
686
  }
638
687
  listEnvVars(projectRef, slug, requestOptions) {
639
688
  return (0, core_js_1.zodfetch)(v4_1.z.array(index_js_1.EnvironmentVariableWithSecret), `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
640
689
  method: "GET",
641
- headers: this.#getHeaders(false),
642
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
690
+ headers: this.#getHeaders(false, undefined, "listEnvVars"),
691
+ }, this.#requestOptions("listEnvVars", requestOptions));
643
692
  }
644
693
  importEnvVars(projectRef, slug, body, requestOptions) {
645
694
  return (0, core_js_1.zodfetch)(index_js_1.EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
646
695
  method: "POST",
647
- headers: this.#getHeaders(false),
696
+ headers: this.#getHeaders(false, undefined, "importEnvVars"),
648
697
  body: JSON.stringify(body),
649
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
698
+ }, this.#requestOptions("importEnvVars", requestOptions));
650
699
  }
651
700
  retrieveEnvVar(projectRef, slug, key, requestOptions) {
652
701
  return (0, core_js_1.zodfetch)(index_js_1.EnvironmentVariableWithSecret, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
653
702
  method: "GET",
654
- headers: this.#getHeaders(false),
655
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
703
+ headers: this.#getHeaders(false, undefined, "retrieveEnvVar"),
704
+ }, this.#requestOptions("retrieveEnvVar", requestOptions));
656
705
  }
657
706
  createEnvVar(projectRef, slug, body, requestOptions) {
658
707
  return (0, core_js_1.zodfetch)(index_js_1.EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
659
708
  method: "POST",
660
- headers: this.#getHeaders(false),
709
+ headers: this.#getHeaders(false, undefined, "createEnvVar"),
661
710
  body: JSON.stringify(body),
662
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
711
+ }, this.#requestOptions("createEnvVar", requestOptions));
663
712
  }
664
713
  updateEnvVar(projectRef, slug, key, body, requestOptions) {
665
714
  return (0, core_js_1.zodfetch)(index_js_1.EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
666
715
  method: "PUT",
667
- headers: this.#getHeaders(false),
716
+ headers: this.#getHeaders(false, undefined, "updateEnvVar"),
668
717
  body: JSON.stringify(body),
669
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
718
+ }, this.#requestOptions("updateEnvVar", requestOptions));
670
719
  }
671
720
  deleteEnvVar(projectRef, slug, key, requestOptions) {
672
721
  return (0, core_js_1.zodfetch)(index_js_1.EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
673
722
  method: "DELETE",
674
- headers: this.#getHeaders(false),
675
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
723
+ headers: this.#getHeaders(false, undefined, "deleteEnvVar"),
724
+ }, this.#requestOptions("deleteEnvVar", requestOptions));
676
725
  }
677
726
  updateRunMetadata(runId, body, requestOptions) {
678
727
  return (0, core_js_1.zodfetch)(index_js_1.UpdateMetadataResponseBody, `${this.baseUrl}/api/v1/runs/${runId}/metadata`, {
679
728
  method: "PUT",
680
- headers: this.#getHeaders(false),
729
+ headers: this.#getHeaders(false, undefined, "updateRunMetadata"),
681
730
  body: JSON.stringify(body),
682
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
731
+ }, this.#requestOptions("updateRunMetadata", requestOptions));
683
732
  }
684
733
  getRunMetadata(runId, requestOptions) {
685
734
  return (0, core_js_1.zodfetch)(index_js_1.UpdateMetadataResponseBody, `${this.baseUrl}/api/v1/runs/${runId}/metadata`, {
686
735
  method: "GET",
687
- headers: this.#getHeaders(false),
688
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
736
+ headers: this.#getHeaders(false, undefined, "getRunMetadata"),
737
+ }, this.#requestOptions("getRunMetadata", requestOptions));
689
738
  }
690
739
  createWaitpointToken(options, requestOptions) {
691
740
  return (0, core_js_1.zodfetch)(index_js_1.CreateWaitpointTokenResponseBody, `${this.baseUrl}/api/v1/waitpoints/tokens`, {
692
741
  method: "POST",
693
- headers: this.#getHeaders(false),
742
+ headers: this.#getHeaders(false, undefined, "createWaitpointToken"),
694
743
  body: JSON.stringify(options),
695
744
  }, {
696
- ...mergeRequestOptions(this.defaultRequestOptions, requestOptions),
745
+ ...this.#requestOptions("createWaitpointToken", requestOptions),
697
746
  prepareData: async (data, response) => {
698
747
  const jwtHeader = response.headers.get("x-trigger-jwt");
699
748
  if (typeof jwtHeader === "string") {
@@ -728,29 +777,29 @@ class ApiClient {
728
777
  before: params?.before,
729
778
  }, {
730
779
  method: "GET",
731
- headers: this.#getHeaders(false),
732
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
780
+ headers: this.#getHeaders(false, undefined, "listWaitpointTokens"),
781
+ }, this.#requestOptions("listWaitpointTokens", requestOptions));
733
782
  }
734
783
  retrieveWaitpointToken(friendlyId, requestOptions) {
735
784
  return (0, core_js_1.zodfetch)(index_js_1.WaitpointRetrieveTokenResponse, `${this.baseUrl}/api/v1/waitpoints/tokens/${friendlyId}`, {
736
785
  method: "GET",
737
- headers: this.#getHeaders(false),
738
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
786
+ headers: this.#getHeaders(false, undefined, "retrieveWaitpointToken"),
787
+ }, this.#requestOptions("retrieveWaitpointToken", requestOptions));
739
788
  }
740
789
  completeWaitpointToken(friendlyId, options, requestOptions) {
741
790
  return (0, core_js_1.zodfetch)(index_js_1.CompleteWaitpointTokenResponseBody, `${this.baseUrl}/api/v1/waitpoints/tokens/${friendlyId}/complete`, {
742
791
  method: "POST",
743
- headers: this.#getHeaders(false),
792
+ headers: this.#getHeaders(false, undefined, "completeWaitpointToken"),
744
793
  body: JSON.stringify(options),
745
794
  }, {
746
- ...mergeRequestOptions(this.defaultRequestOptions, requestOptions),
795
+ ...this.#requestOptions("completeWaitpointToken", requestOptions),
747
796
  });
748
797
  }
749
798
  waitForWaitpointToken({ runFriendlyId, waitpointFriendlyId, }, requestOptions) {
750
799
  return (0, core_js_1.zodfetch)(index_js_1.WaitForWaitpointTokenResponseBody, `${this.baseUrl}/engine/v1/runs/${runFriendlyId}/waitpoints/tokens/${waitpointFriendlyId}/wait`, {
751
800
  method: "POST",
752
- headers: this.#getHeaders(false),
753
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
801
+ headers: this.#getHeaders(false, undefined, "waitForWaitpointToken"),
802
+ }, this.#requestOptions("waitForWaitpointToken", requestOptions));
754
803
  }
755
804
  // ========================================================================
756
805
  // Sessions
@@ -758,36 +807,36 @@ class ApiClient {
758
807
  createSession(body, requestOptions) {
759
808
  return (0, core_js_1.zodfetch)(index_js_1.CreatedSessionResponseBody, `${this.baseUrl}/api/v1/sessions`, {
760
809
  method: "POST",
761
- headers: this.#getHeaders(false),
810
+ headers: this.#getHeaders(false, undefined, "createSession"),
762
811
  body: JSON.stringify(body),
763
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
812
+ }, this.#requestOptions("createSession", requestOptions));
764
813
  }
765
814
  retrieveSession(sessionIdOrExternalId, requestOptions) {
766
815
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveSessionResponseBody, `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(sessionIdOrExternalId)}`, {
767
816
  method: "GET",
768
- headers: this.#getHeaders(false),
769
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
817
+ headers: this.#getHeaders(false, undefined, "retrieveSession"),
818
+ }, this.#requestOptions("retrieveSession", requestOptions));
770
819
  }
771
820
  updateSession(sessionIdOrExternalId, body, requestOptions) {
772
821
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveSessionResponseBody, `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(sessionIdOrExternalId)}`, {
773
822
  method: "PATCH",
774
- headers: this.#getHeaders(false),
823
+ headers: this.#getHeaders(false, undefined, "updateSession"),
775
824
  body: JSON.stringify(body),
776
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
825
+ }, this.#requestOptions("updateSession", requestOptions));
777
826
  }
778
827
  closeSession(sessionIdOrExternalId, body, requestOptions) {
779
828
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveSessionResponseBody, `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(sessionIdOrExternalId)}/close`, {
780
829
  method: "POST",
781
- headers: this.#getHeaders(false),
830
+ headers: this.#getHeaders(false, undefined, "closeSession"),
782
831
  body: JSON.stringify(body ?? {}),
783
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
832
+ }, this.#requestOptions("closeSession", requestOptions));
784
833
  }
785
834
  endAndContinueSession(sessionIdOrExternalId, body, requestOptions) {
786
835
  return (0, core_js_1.zodfetch)(index_js_1.EndAndContinueSessionResponseBody, `${this.baseUrl}/api/v1/sessions/${encodeURIComponent(sessionIdOrExternalId)}/end-and-continue`, {
787
836
  method: "POST",
788
- headers: this.#getHeaders(false),
837
+ headers: this.#getHeaders(false, undefined, "endAndContinueSession"),
789
838
  body: JSON.stringify(body),
790
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
839
+ }, this.#requestOptions("endAndContinueSession", requestOptions));
791
840
  }
792
841
  listSessions(options, requestOptions) {
793
842
  const searchParams = createSearchQueryForListSessions(options);
@@ -798,8 +847,8 @@ class ApiClient {
798
847
  before: options?.before,
799
848
  }, {
800
849
  method: "GET",
801
- headers: this.#getHeaders(false),
802
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
850
+ headers: this.#getHeaders(false, undefined, "listSessions"),
851
+ }, this.#requestOptions("listSessions", requestOptions));
803
852
  }
804
853
  // ========================================================================
805
854
  // Session realtime channels
@@ -813,8 +862,8 @@ class ApiClient {
813
862
  const url = channel ? `${base}/channels/${encodeURIComponent(channel)}/${io}` : `${base}/${io}`;
814
863
  return (0, core_js_1.zodfetch)(index_js_1.CreateStreamResponseBody, url, {
815
864
  method: "PUT",
816
- headers: this.#getHeaders(false),
817
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions))
865
+ headers: this.#getHeaders(false, undefined, "initializeSessionStream"),
866
+ }, this.#requestOptions("initializeSessionStream", requestOptions))
818
867
  .withResponse()
819
868
  .then(({ data, response }) => ({
820
869
  ...data,
@@ -833,9 +882,12 @@ class ApiClient {
833
882
  : `${base}/${io}/append`;
834
883
  return (0, core_js_1.zodfetch)(index_js_1.AppendToStreamResponseBody, appendUrl, {
835
884
  method: "POST",
836
- headers: { ...this.#getHeaders(false), "X-Part-Id": partId },
885
+ headers: {
886
+ ...this.#getHeaders(false, undefined, "appendToSessionStream"),
887
+ "X-Part-Id": partId,
888
+ },
837
889
  body: part,
838
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
890
+ }, this.#requestOptions("appendToSessionStream", requestOptions));
839
891
  }
840
892
  /**
841
893
  * Non-SSE drain of a Session channel's tail. Returns whatever records
@@ -860,8 +912,8 @@ class ApiClient {
860
912
  const url = `${recordsPath}${qs.toString() ? `?${qs.toString()}` : ""}`;
861
913
  return (0, core_js_1.zodfetch)(index_js_1.ReadSessionStreamRecordsResponseBody, url, {
862
914
  method: "GET",
863
- headers: this.#getHeaders(false),
864
- }, mergeRequestOptions(this.defaultRequestOptions, undefined));
915
+ headers: this.#getHeaders(false, undefined, "readSessionStreamRecords"),
916
+ }, this.#requestOptions("readSessionStreamRecords", undefined));
865
917
  }
866
918
  /**
867
919
  * Subscribe to SSE records on a Session channel. Reuses the same
@@ -874,8 +926,9 @@ class ApiClient {
874
926
  ? `${sessionSegment}/channels/${encodeURIComponent(options.channel)}/${io}`
875
927
  : `${sessionSegment}/${io}`;
876
928
  const subscription = new runStream_js_1.SSEStreamSubscription(url, {
877
- headers: this.getHeaders(),
878
- resolveHeaders: this.#resolveStreamHeaders(),
929
+ headers: this.#getHeaders(false, undefined, "subscribeToSessionStream"),
930
+ fetchClient: this.#requestFetch("subscribeToSessionStream"),
931
+ resolveHeaders: this.#resolveStreamHeaders("subscribeToSessionStream"),
879
932
  signal: options?.signal,
880
933
  onComplete: options?.onComplete,
881
934
  onError: options?.onError,
@@ -921,9 +974,9 @@ class ApiClient {
921
974
  async waitForDuration(runId, body, requestOptions) {
922
975
  return (0, core_js_1.zodfetch)(index_js_1.WaitForDurationResponseBody, `${this.baseUrl}/engine/v1/runs/${runId}/wait/duration`, {
923
976
  method: "POST",
924
- headers: this.#getHeaders(false),
977
+ headers: this.#getHeaders(false, undefined, "waitForDuration"),
925
978
  body: JSON.stringify(body),
926
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
979
+ }, this.#requestOptions("waitForDuration", requestOptions));
927
980
  }
928
981
  listQueues(options, requestOptions) {
929
982
  const searchParams = new URLSearchParams();
@@ -938,8 +991,8 @@ class ApiClient {
938
991
  limit: options?.perPage,
939
992
  }, {
940
993
  method: "GET",
941
- headers: this.#getHeaders(false),
942
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
994
+ headers: this.#getHeaders(false, undefined, "listQueues"),
995
+ }, this.#requestOptions("listQueues", requestOptions));
943
996
  }
944
997
  retrieveQueue(queue, requestOptions) {
945
998
  const type = typeof queue === "string" ? "id" : queue.type;
@@ -948,8 +1001,8 @@ class ApiClient {
948
1001
  const encodedValue = encodeURIComponent(value.replace(/\//g, "%2F"));
949
1002
  return (0, core_js_1.zodfetch)(index_js_1.QueueItem, `${this.baseUrl}/api/v1/queues/${encodedValue}?type=${type}`, {
950
1003
  method: "GET",
951
- headers: this.#getHeaders(false),
952
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1004
+ headers: this.#getHeaders(false, undefined, "retrieveQueue"),
1005
+ }, this.#requestOptions("retrieveQueue", requestOptions));
953
1006
  }
954
1007
  pauseQueue(queue, action, requestOptions) {
955
1008
  const type = typeof queue === "string" ? "id" : queue.type;
@@ -958,12 +1011,12 @@ class ApiClient {
958
1011
  const encodedValue = encodeURIComponent(value.replace(/\//g, "%2F"));
959
1012
  return (0, core_js_1.zodfetch)(index_js_1.QueueItem, `${this.baseUrl}/api/v1/queues/${encodedValue}/pause`, {
960
1013
  method: "POST",
961
- headers: this.#getHeaders(false),
1014
+ headers: this.#getHeaders(false, undefined, "pauseQueue"),
962
1015
  body: JSON.stringify({
963
1016
  type,
964
1017
  action,
965
1018
  }),
966
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1019
+ }, this.#requestOptions("pauseQueue", requestOptions));
967
1020
  }
968
1021
  overrideQueueConcurrencyLimit(queue, concurrencyLimit, requestOptions) {
969
1022
  const type = typeof queue === "string" ? "id" : queue.type;
@@ -972,12 +1025,12 @@ class ApiClient {
972
1025
  const encodedValue = encodeURIComponent(value.replace(/\//g, "%2F"));
973
1026
  return (0, core_js_1.zodfetch)(index_js_1.QueueItem, `${this.baseUrl}/api/v1/queues/${encodedValue}/concurrency/override`, {
974
1027
  method: "POST",
975
- headers: this.#getHeaders(false),
1028
+ headers: this.#getHeaders(false, undefined, "overrideQueueConcurrencyLimit"),
976
1029
  body: JSON.stringify({
977
1030
  type,
978
1031
  concurrencyLimit,
979
1032
  }),
980
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1033
+ }, this.#requestOptions("overrideQueueConcurrencyLimit", requestOptions));
981
1034
  }
982
1035
  resetQueueConcurrencyLimit(queue, requestOptions) {
983
1036
  const type = typeof queue === "string" ? "id" : queue.type;
@@ -986,11 +1039,11 @@ class ApiClient {
986
1039
  const encodedValue = encodeURIComponent(value.replace(/\//g, "%2F"));
987
1040
  return (0, core_js_1.zodfetch)(index_js_1.QueueItem, `${this.baseUrl}/api/v1/queues/${encodedValue}/concurrency/reset`, {
988
1041
  method: "POST",
989
- headers: this.#getHeaders(false),
1042
+ headers: this.#getHeaders(false, undefined, "resetQueueConcurrencyLimit"),
990
1043
  body: JSON.stringify({
991
1044
  type,
992
1045
  }),
993
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1046
+ }, this.#requestOptions("resetQueueConcurrencyLimit", requestOptions));
994
1047
  }
995
1048
  listConcurrencyLimits(options, requestOptions) {
996
1049
  return (0, core_js_1.zodfetchOffsetLimitPage)(index_js_1.ConcurrencyLimitItem, `${this.baseUrl}/api/v1/concurrency-limits`, {
@@ -998,58 +1051,58 @@ class ApiClient {
998
1051
  limit: options?.perPage,
999
1052
  }, {
1000
1053
  method: "GET",
1001
- headers: this.#getHeaders(false),
1002
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1054
+ headers: this.#getHeaders(false, undefined, "listConcurrencyLimits"),
1055
+ }, this.#requestOptions("listConcurrencyLimits", requestOptions));
1003
1056
  }
1004
1057
  retrieveConcurrencyLimit(name, requestOptions) {
1005
1058
  return (0, core_js_1.zodfetch)(index_js_1.ConcurrencyLimitItem, `${this.baseUrl}/api/v1/concurrency-limits/${encodeURIComponent(name)}`, {
1006
1059
  method: "GET",
1007
- headers: this.#getHeaders(false),
1008
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1060
+ headers: this.#getHeaders(false, undefined, "retrieveConcurrencyLimit"),
1061
+ }, this.#requestOptions("retrieveConcurrencyLimit", requestOptions));
1009
1062
  }
1010
1063
  retrieveConcurrencyLimitKey(name, concurrencyKey, requestOptions) {
1011
1064
  const query = new URLSearchParams({ concurrencyKey });
1012
1065
  return (0, core_js_1.zodfetch)(index_js_1.ConcurrencyLimitKeyItem, `${this.baseUrl}/api/v1/concurrency-limits/${encodeURIComponent(name)}?${query.toString()}`, {
1013
1066
  method: "GET",
1014
- headers: this.#getHeaders(false),
1015
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1067
+ headers: this.#getHeaders(false, undefined, "retrieveConcurrencyLimitKey"),
1068
+ }, this.#requestOptions("retrieveConcurrencyLimitKey", requestOptions));
1016
1069
  }
1017
1070
  overrideConcurrencyLimit(name, override, requestOptions) {
1018
1071
  return (0, core_js_1.zodfetch)(index_js_1.ConcurrencyLimitItem, `${this.baseUrl}/api/v1/concurrency-limits/${encodeURIComponent(name)}/override`, {
1019
1072
  method: "POST",
1020
- headers: this.#getHeaders(false),
1073
+ headers: this.#getHeaders(false, undefined, "overrideConcurrencyLimit"),
1021
1074
  body: JSON.stringify(override),
1022
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1075
+ }, this.#requestOptions("overrideConcurrencyLimit", requestOptions));
1023
1076
  }
1024
1077
  overrideConcurrencyLimitKey(name, override, requestOptions) {
1025
1078
  return (0, core_js_1.zodfetch)(index_js_1.ConcurrencyLimitKeyItem, `${this.baseUrl}/api/v1/concurrency-limits/${encodeURIComponent(name)}/override`, {
1026
1079
  method: "POST",
1027
- headers: this.#getHeaders(false),
1080
+ headers: this.#getHeaders(false, undefined, "overrideConcurrencyLimitKey"),
1028
1081
  body: JSON.stringify(override),
1029
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1082
+ }, this.#requestOptions("overrideConcurrencyLimitKey", requestOptions));
1030
1083
  }
1031
1084
  pauseConcurrencyLimit(name, action, requestOptions) {
1032
1085
  return (0, core_js_1.zodfetch)(index_js_1.ConcurrencyLimitItem, `${this.baseUrl}/api/v1/concurrency-limits/${encodeURIComponent(name)}/pause`, {
1033
1086
  method: "POST",
1034
- headers: this.#getHeaders(false),
1087
+ headers: this.#getHeaders(false, undefined, "pauseConcurrencyLimit"),
1035
1088
  body: JSON.stringify({
1036
1089
  action,
1037
1090
  }),
1038
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1091
+ }, this.#requestOptions("pauseConcurrencyLimit", requestOptions));
1039
1092
  }
1040
1093
  resetConcurrencyLimit(name, requestOptions) {
1041
1094
  return (0, core_js_1.zodfetch)(index_js_1.ConcurrencyLimitItem, `${this.baseUrl}/api/v1/concurrency-limits/${encodeURIComponent(name)}/reset`, {
1042
1095
  method: "POST",
1043
- headers: this.#getHeaders(false),
1096
+ headers: this.#getHeaders(false, undefined, "resetConcurrencyLimit"),
1044
1097
  body: JSON.stringify({}),
1045
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1098
+ }, this.#requestOptions("resetConcurrencyLimit", requestOptions));
1046
1099
  }
1047
1100
  resetConcurrencyLimitKey(name, body, requestOptions) {
1048
1101
  return (0, core_js_1.zodfetch)(index_js_1.ConcurrencyLimitKeyItem, `${this.baseUrl}/api/v1/concurrency-limits/${encodeURIComponent(name)}/reset`, {
1049
1102
  method: "POST",
1050
- headers: this.#getHeaders(false),
1103
+ headers: this.#getHeaders(false, undefined, "resetConcurrencyLimitKey"),
1051
1104
  body: JSON.stringify(body),
1052
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1105
+ }, this.#requestOptions("resetConcurrencyLimitKey", requestOptions));
1053
1106
  }
1054
1107
  subscribeToRun(runId, options) {
1055
1108
  const queryParams = new URLSearchParams();
@@ -1058,12 +1111,12 @@ class ApiClient {
1058
1111
  }
1059
1112
  return (0, runStream_js_1.runShapeStream)(`${this.baseUrl}/realtime/v1/runs/${runId}${queryParams ? `?${queryParams}` : ""}`, {
1060
1113
  closeOnComplete: typeof options?.closeOnComplete === "boolean" ? options.closeOnComplete : true,
1061
- headers: this.#getRealtimeHeaders(),
1062
- resolveHeaders: this.#resolveRealtimeHeaders(),
1114
+ headers: this.#getRealtimeHeaders("subscribeToRun"),
1115
+ resolveHeaders: this.#resolveRealtimeHeaders("subscribeToRun"),
1063
1116
  client: this,
1064
1117
  signal: options?.signal,
1065
1118
  onFetchError: options?.onFetchError,
1066
- fetchClient: options?.fetchClient,
1119
+ fetchClient: this.#requestFetch("subscribeToRun", options?.fetchClient),
1067
1120
  });
1068
1121
  }
1069
1122
  subscribeToRunsWithTag(tag, filters, options) {
@@ -1074,12 +1127,12 @@ class ApiClient {
1074
1127
  });
1075
1128
  return (0, runStream_js_1.runShapeStream)(`${this.baseUrl}/realtime/v1/runs${searchParams ? `?${searchParams}` : ""}`, {
1076
1129
  closeOnComplete: false,
1077
- headers: this.#getRealtimeHeaders(),
1078
- resolveHeaders: this.#resolveRealtimeHeaders(),
1130
+ headers: this.#getRealtimeHeaders("subscribeToRunsWithTag"),
1131
+ resolveHeaders: this.#resolveRealtimeHeaders("subscribeToRunsWithTag"),
1079
1132
  client: this,
1080
1133
  signal: options?.signal,
1081
1134
  onFetchError: options?.onFetchError,
1082
- fetchClient: options?.fetchClient,
1135
+ fetchClient: this.#requestFetch("subscribeToRunsWithTag", options?.fetchClient),
1083
1136
  });
1084
1137
  }
1085
1138
  subscribeToBatch(batchId, options) {
@@ -1089,12 +1142,12 @@ class ApiClient {
1089
1142
  }
1090
1143
  return (0, runStream_js_1.runShapeStream)(`${this.baseUrl}/realtime/v1/batches/${batchId}${queryParams ? `?${queryParams}` : ""}`, {
1091
1144
  closeOnComplete: false,
1092
- headers: this.#getRealtimeHeaders(),
1093
- resolveHeaders: this.#resolveRealtimeHeaders(),
1145
+ headers: this.#getRealtimeHeaders("subscribeToBatch"),
1146
+ resolveHeaders: this.#resolveRealtimeHeaders("subscribeToBatch"),
1094
1147
  client: this,
1095
1148
  signal: options?.signal,
1096
1149
  onFetchError: options?.onFetchError,
1097
- fetchClient: options?.fetchClient,
1150
+ fetchClient: this.#requestFetch("subscribeToBatch", options?.fetchClient),
1098
1151
  });
1099
1152
  }
1100
1153
  listDeployments(options, requestOptions) {
@@ -1117,20 +1170,21 @@ class ApiClient {
1117
1170
  limit: options?.limit,
1118
1171
  }, {
1119
1172
  method: "GET",
1120
- headers: this.#getHeaders(false),
1121
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1173
+ headers: this.#getHeaders(false, undefined, "listDeployments"),
1174
+ }, this.#requestOptions("listDeployments", requestOptions));
1122
1175
  }
1123
1176
  retrieveCurrentDeployment(requestOptions) {
1124
1177
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveCurrentDeploymentResponseBody, `${this.baseUrl}/api/v1/deployments/current`, {
1125
1178
  method: "GET",
1126
- headers: this.#getHeaders(false),
1127
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1179
+ headers: this.#getHeaders(false, undefined, "retrieveCurrentDeployment"),
1180
+ }, this.#requestOptions("retrieveCurrentDeployment", requestOptions));
1128
1181
  }
1129
1182
  async fetchStream(runId, streamKey, options) {
1130
1183
  const streamFactory = new runStream_js_1.SSEStreamSubscriptionFactory(options?.baseUrl ?? this.baseUrl, {
1131
- headers: this.getHeaders(),
1184
+ headers: this.#getHeaders(false, undefined, "fetchStream"),
1185
+ fetchClient: this.#requestFetch("fetchStream"),
1132
1186
  signal: options?.signal,
1133
- resolveHeaders: this.#resolveStreamHeaders(),
1187
+ resolveHeaders: this.#resolveStreamHeaders("fetchStream"),
1134
1188
  });
1135
1189
  const subscription = streamFactory.createSubscription(runId, streamKey, {
1136
1190
  onComplete: options?.onComplete,
@@ -1152,8 +1206,8 @@ class ApiClient {
1152
1206
  async createStream(runId, target, streamId, requestOptions) {
1153
1207
  return (0, core_js_1.zodfetch)(index_js_1.CreateStreamResponseBody, `${this.baseUrl}/realtime/v1/streams/${runId}/${target}/${streamId}`, {
1154
1208
  method: "PUT",
1155
- headers: this.#getHeaders(false),
1156
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions))
1209
+ headers: this.#getHeaders(false, undefined, "createStream"),
1210
+ }, this.#requestOptions("createStream", requestOptions))
1157
1211
  .withResponse()
1158
1212
  .then(async ({ data, response }) => {
1159
1213
  return {
@@ -1165,51 +1219,54 @@ class ApiClient {
1165
1219
  async appendToStream(runId, target, streamId, part, requestOptions) {
1166
1220
  return (0, core_js_1.zodfetch)(index_js_1.AppendToStreamResponseBody, `${this.baseUrl}/realtime/v1/streams/${runId}/${target}/${streamId}/append`, {
1167
1221
  method: "POST",
1168
- headers: this.#getHeaders(false),
1222
+ headers: this.#getHeaders(false, undefined, "appendToStream"),
1169
1223
  body: part,
1170
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1224
+ }, this.#requestOptions("appendToStream", requestOptions));
1171
1225
  }
1172
1226
  async sendInputStream(runId, streamId, data, requestOptions) {
1173
1227
  return (0, core_js_1.zodfetch)(index_js_1.SendInputStreamResponseBody, `${this.baseUrl}/realtime/v1/streams/${runId}/input/${streamId}`, {
1174
1228
  method: "POST",
1175
- headers: this.#getHeaders(false),
1229
+ headers: this.#getHeaders(false, undefined, "sendInputStream"),
1176
1230
  body: JSON.stringify({ data }),
1177
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1231
+ }, this.#requestOptions("sendInputStream", requestOptions));
1178
1232
  }
1179
1233
  async createInputStreamWaitpoint(runFriendlyId, body, requestOptions) {
1180
1234
  return (0, core_js_1.zodfetch)(index_js_1.CreateInputStreamWaitpointResponseBody, `${this.baseUrl}/api/v1/runs/${runFriendlyId}/input-streams/wait`, {
1181
1235
  method: "POST",
1182
- headers: this.#getHeaders(false),
1236
+ headers: this.#getHeaders(false, undefined, "createInputStreamWaitpoint"),
1183
1237
  body: JSON.stringify(body),
1184
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1238
+ }, this.#requestOptions("createInputStreamWaitpoint", requestOptions));
1185
1239
  }
1186
1240
  async createSessionStreamWaitpoint(runFriendlyId, body, requestOptions) {
1187
1241
  return (0, core_js_1.zodfetch)(index_js_1.CreateSessionStreamWaitpointResponseBody, `${this.baseUrl}/api/v1/runs/${runFriendlyId}/session-streams/wait`, {
1188
1242
  method: "POST",
1189
- headers: this.#getHeaders(false),
1243
+ headers: this.#getHeaders(false, undefined, "createSessionStreamWaitpoint"),
1190
1244
  body: JSON.stringify(body),
1191
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1245
+ }, this.#requestOptions("createSessionStreamWaitpoint", requestOptions));
1192
1246
  }
1193
1247
  async generateJWTClaims(requestOptions) {
1194
1248
  return (0, core_js_1.zodfetch)(v4_1.z.record(v4_1.z.string(), v4_1.z.any()), `${this.baseUrl}/api/v1/auth/jwt/claims`, {
1195
1249
  method: "POST",
1196
- headers: this.#getHeaders(false),
1197
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1250
+ headers: this.#getHeaders(false, undefined, "generateJWTClaims"),
1251
+ }, this.#requestOptions("generateJWTClaims", requestOptions));
1198
1252
  }
1199
1253
  async createPublicToken(body, requestOptions) {
1200
1254
  return (0, core_js_1.zodfetch)(CreatePublicTokenResponseBody, `${this.baseUrl}/api/v1/auth/public-tokens`, {
1201
1255
  method: "POST",
1202
- headers: this.#getHeaders(false),
1256
+ headers: this.#getHeaders(false, undefined, "createPublicToken"),
1203
1257
  body: JSON.stringify(body),
1204
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1258
+ }, this.#requestOptions("createPublicToken", requestOptions));
1205
1259
  }
1206
1260
  retrieveBatch(batchId, requestOptions) {
1207
1261
  return (0, core_js_1.zodfetch)(index_js_1.RetrieveBatchV2Response, `${this.baseUrl}/api/v2/batches/${batchId}`, {
1208
1262
  method: "GET",
1209
- headers: this.#getHeaders(false),
1210
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1263
+ headers: this.#getHeaders(false, undefined, "retrieveBatch"),
1264
+ }, this.#requestOptions("retrieveBatch", requestOptions));
1211
1265
  }
1212
1266
  async executeQuery(query, options, requestOptions) {
1267
+ const operation = !options?.scope || options.scope === "environment"
1268
+ ? "executeQuery"
1269
+ : "executeQueryProjectOrOrganization";
1213
1270
  const body = {
1214
1271
  query,
1215
1272
  scope: options?.scope ?? "environment",
@@ -1220,68 +1277,68 @@ class ApiClient {
1220
1277
  };
1221
1278
  return (0, core_js_1.zodfetch)(index_js_1.QueryExecuteResponseBody, `${this.baseUrl}/api/v1/query`, {
1222
1279
  method: "POST",
1223
- headers: this.#getHeaders(false),
1280
+ headers: this.#getHeaders(false, undefined, operation),
1224
1281
  body: JSON.stringify(body),
1225
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1282
+ }, this.#requestOptions(operation, requestOptions));
1226
1283
  }
1227
1284
  async getQuerySchema(requestOptions) {
1228
1285
  return (0, core_js_1.zodfetch)(index_js_1.QuerySchemaResponseBody, `${this.baseUrl}/api/v1/query/schema`, {
1229
1286
  method: "GET",
1230
- headers: this.#getHeaders(false),
1231
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1287
+ headers: this.#getHeaders(false, undefined, "getQuerySchema"),
1288
+ }, this.#requestOptions("getQuerySchema", requestOptions));
1232
1289
  }
1233
1290
  async listDashboards(requestOptions) {
1234
1291
  return (0, core_js_1.zodfetch)(index_js_1.ListDashboardsResponseBody, `${this.baseUrl}/api/v1/query/dashboards`, {
1235
1292
  method: "GET",
1236
- headers: this.#getHeaders(false),
1237
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1293
+ headers: this.#getHeaders(false, undefined, "listDashboards"),
1294
+ }, this.#requestOptions("listDashboards", requestOptions));
1238
1295
  }
1239
1296
  retrieveDashboard(dashboardId, requestOptions) {
1240
1297
  return (0, core_js_1.zodfetch)(index_js_1.DashboardObject, `${this.baseUrl}/api/v1/query/dashboards/${encodeURIComponent(dashboardId)}`, {
1241
1298
  method: "GET",
1242
- headers: this.#getHeaders(false),
1243
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1299
+ headers: this.#getHeaders(false, undefined, "retrieveDashboard"),
1300
+ }, this.#requestOptions("retrieveDashboard", requestOptions));
1244
1301
  }
1245
1302
  createDashboard(body, requestOptions) {
1246
1303
  return (0, core_js_1.zodfetch)(index_js_1.DashboardObject, `${this.baseUrl}/api/v1/query/dashboards`, {
1247
1304
  method: "POST",
1248
- headers: this.#getHeaders(false),
1305
+ headers: this.#getHeaders(false, undefined, "createDashboard"),
1249
1306
  body: JSON.stringify(body),
1250
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1307
+ }, this.#requestOptions("createDashboard", requestOptions));
1251
1308
  }
1252
1309
  updateDashboard(dashboardId, body, requestOptions) {
1253
1310
  return (0, core_js_1.zodfetch)(index_js_1.DashboardObject, `${this.baseUrl}/api/v1/query/dashboards/${encodeURIComponent(dashboardId)}`, {
1254
1311
  method: "PATCH",
1255
- headers: this.#getHeaders(false),
1312
+ headers: this.#getHeaders(false, undefined, "updateDashboard"),
1256
1313
  body: JSON.stringify(body),
1257
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1314
+ }, this.#requestOptions("updateDashboard", requestOptions));
1258
1315
  }
1259
1316
  replaceDashboard(dashboardId, body, requestOptions) {
1260
1317
  return (0, core_js_1.zodfetch)(index_js_1.DashboardObject, `${this.baseUrl}/api/v1/query/dashboards/${encodeURIComponent(dashboardId)}`, {
1261
1318
  method: "PUT",
1262
- headers: this.#getHeaders(false),
1319
+ headers: this.#getHeaders(false, undefined, "replaceDashboard"),
1263
1320
  body: JSON.stringify(body),
1264
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1321
+ }, this.#requestOptions("replaceDashboard", requestOptions));
1265
1322
  }
1266
1323
  deleteDashboard(dashboardId, requestOptions) {
1267
1324
  return (0, core_js_1.zodfetch)(index_js_1.DeleteDashboardResponseBody, `${this.baseUrl}/api/v1/query/dashboards/${encodeURIComponent(dashboardId)}`, {
1268
1325
  method: "DELETE",
1269
- headers: this.#getHeaders(false),
1270
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1326
+ headers: this.#getHeaders(false, undefined, "deleteDashboard"),
1327
+ }, this.#requestOptions("deleteDashboard", requestOptions));
1271
1328
  }
1272
1329
  addDashboardWidget(dashboardId, body, requestOptions) {
1273
1330
  return (0, core_js_1.zodfetch)(index_js_1.AddDashboardWidgetResponseBody, `${this.baseUrl}/api/v1/query/dashboards/${encodeURIComponent(dashboardId)}/widgets`, {
1274
1331
  method: "POST",
1275
- headers: this.#getHeaders(false),
1332
+ headers: this.#getHeaders(false, undefined, "addDashboardWidget"),
1276
1333
  body: JSON.stringify(body),
1277
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1334
+ }, this.#requestOptions("addDashboardWidget", requestOptions));
1278
1335
  }
1279
1336
  updateDashboardWidget(dashboardId, widgetId, body, requestOptions) {
1280
1337
  return (0, core_js_1.zodfetch)(index_js_1.DashboardObject, `${this.baseUrl}/api/v1/query/dashboards/${encodeURIComponent(dashboardId)}/widgets/${encodeURIComponent(widgetId)}`, {
1281
1338
  method: "PATCH",
1282
- headers: this.#getHeaders(false),
1339
+ headers: this.#getHeaders(false, undefined, "updateDashboardWidget"),
1283
1340
  body: JSON.stringify(body),
1284
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1341
+ }, this.#requestOptions("updateDashboardWidget", requestOptions));
1285
1342
  }
1286
1343
  deleteDashboardWidget(dashboardId, widgetId, options, requestOptions) {
1287
1344
  const search = options?.revision
@@ -1289,8 +1346,8 @@ class ApiClient {
1289
1346
  : "";
1290
1347
  return (0, core_js_1.zodfetch)(index_js_1.DashboardObject, `${this.baseUrl}/api/v1/query/dashboards/${encodeURIComponent(dashboardId)}/widgets/${encodeURIComponent(widgetId)}${search}`, {
1291
1348
  method: "DELETE",
1292
- headers: this.#getHeaders(false),
1293
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1349
+ headers: this.#getHeaders(false, undefined, "deleteDashboardWidget"),
1350
+ }, this.#requestOptions("deleteDashboardWidget", requestOptions));
1294
1351
  }
1295
1352
  async getReport(key, options) {
1296
1353
  const searchParams = new URLSearchParams({ format: options?.format ?? "markdown" });
@@ -1299,7 +1356,7 @@ class ApiClient {
1299
1356
  }
1300
1357
  const response = await fetch(`${this.baseUrl}/api/v1/reports/${encodeURIComponent(key)}?${searchParams.toString()}`, {
1301
1358
  method: "GET",
1302
- headers: this.#getHeaders(false),
1359
+ headers: this.#getHeaders(false, undefined, "getReport", true),
1303
1360
  });
1304
1361
  if (!response.ok) {
1305
1362
  const bodySnippet = await readBodySnippet(response);
@@ -1310,10 +1367,12 @@ class ApiClient {
1310
1367
  }
1311
1368
  return response.text();
1312
1369
  }
1313
- #getHeaders(spanParentAsLink, additionalHeaders) {
1370
+ #getHeaders(spanParentAsLink, additionalHeaders, operation = "unknown", recordSelection = false) {
1314
1371
  const headers = {
1315
1372
  "Content-Type": "application/json",
1316
- Authorization: `Bearer ${this.accessToken}`,
1373
+ ...(additionalHeaders?.Authorization
1374
+ ? { Authorization: additionalHeaders.Authorization }
1375
+ : this.getAuthenticationHeaders(operation, recordSelection)),
1317
1376
  "trigger-version": version_js_1.VERSION,
1318
1377
  ...Object.entries(additionalHeaders ?? {}).reduce((acc, [key, value]) => {
1319
1378
  if (value !== undefined) {
@@ -1364,27 +1423,39 @@ class ApiClient {
1364
1423
  resolvePrompt(slug, body, requestOptions) {
1365
1424
  return (0, core_js_1.zodfetch)(index_js_1.ResolvePromptResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}`, {
1366
1425
  method: "POST",
1367
- headers: this.#getHeaders(false),
1426
+ headers: this.#getHeaders(false, undefined, "resolvePrompt"),
1368
1427
  body: JSON.stringify(body),
1369
- }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1428
+ }, this.#requestOptions("resolvePrompt", requestOptions));
1370
1429
  }
1371
1430
  createWebhookWaiter(endpointId, body, requestOptions) {
1372
- return (0, core_js_1.zodfetch)(index_js_1.CreateWebhookWaiterResponseBody, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}/waiters`, { method: "POST", headers: this.#getHeaders(false), body: JSON.stringify(body) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1431
+ return (0, core_js_1.zodfetch)(index_js_1.CreateWebhookWaiterResponseBody, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}/waiters`, {
1432
+ method: "POST",
1433
+ headers: this.#getHeaders(false, undefined, "createWebhookWaiter"),
1434
+ body: JSON.stringify(body),
1435
+ }, this.#requestOptions("createWebhookWaiter", requestOptions));
1373
1436
  }
1374
1437
  cancelWebhookWaiter(waiterId, requestOptions) {
1375
- return (0, core_js_1.zodfetch)(index_js_1.CancelWebhookWaiterResponseBody, `${this.baseUrl}/api/v1/webhooks/waiters/${encodeURIComponent(waiterId)}/cancel`, { method: "POST", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1438
+ return (0, core_js_1.zodfetch)(index_js_1.CancelWebhookWaiterResponseBody, `${this.baseUrl}/api/v1/webhooks/waiters/${encodeURIComponent(waiterId)}/cancel`, { method: "POST", headers: this.#getHeaders(false, undefined, "cancelWebhookWaiter") }, this.#requestOptions("cancelWebhookWaiter", requestOptions));
1376
1439
  }
1377
1440
  listWebhookEndpoints(requestOptions) {
1378
- return (0, core_js_1.zodfetch)(index_js_1.ListWebhookEndpointsResponse, `${this.baseUrl}/api/v1/webhooks/endpoints`, { method: "GET", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1441
+ return (0, core_js_1.zodfetch)(index_js_1.ListWebhookEndpointsResponse, `${this.baseUrl}/api/v1/webhooks/endpoints`, { method: "GET", headers: this.#getHeaders(false, undefined, "listWebhookEndpoints") }, this.#requestOptions("listWebhookEndpoints", requestOptions));
1379
1442
  }
1380
1443
  retrieveWebhookEndpoint(endpointId, requestOptions) {
1381
- return (0, core_js_1.zodfetch)(index_js_1.WebhookEndpointDetailObject, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}`, { method: "GET", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1444
+ return (0, core_js_1.zodfetch)(index_js_1.WebhookEndpointDetailObject, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}`, { method: "GET", headers: this.#getHeaders(false, undefined, "retrieveWebhookEndpoint") }, this.#requestOptions("retrieveWebhookEndpoint", requestOptions));
1382
1445
  }
1383
1446
  generateWebhookEndpointSecret(endpointId, body = {}, requestOptions) {
1384
- return (0, core_js_1.zodfetch)(index_js_1.RotateWebhookEndpointSecretResponse, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}/rotate-secret`, { method: "POST", headers: this.#getHeaders(false), body: JSON.stringify(body) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1447
+ return (0, core_js_1.zodfetch)(index_js_1.RotateWebhookEndpointSecretResponse, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}/rotate-secret`, {
1448
+ method: "POST",
1449
+ headers: this.#getHeaders(false, undefined, "generateWebhookEndpointSecret"),
1450
+ body: JSON.stringify(body),
1451
+ }, this.#requestOptions("generateWebhookEndpointSecret", requestOptions));
1385
1452
  }
1386
1453
  setWebhookEndpointSecret(endpointId, body, requestOptions) {
1387
- return (0, core_js_1.zodfetch)(index_js_1.SetWebhookEndpointSecretResponse, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}/secret`, { method: "PUT", headers: this.#getHeaders(false), body: JSON.stringify(body) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1454
+ return (0, core_js_1.zodfetch)(index_js_1.SetWebhookEndpointSecretResponse, `${this.baseUrl}/api/v1/webhooks/endpoints/${encodeURIComponent(endpointId)}/secret`, {
1455
+ method: "PUT",
1456
+ headers: this.#getHeaders(false, undefined, "setWebhookEndpointSecret"),
1457
+ body: JSON.stringify(body),
1458
+ }, this.#requestOptions("setWebhookEndpointSecret", requestOptions));
1388
1459
  }
1389
1460
  listWebhookDeliveries(query = {}, requestOptions) {
1390
1461
  const searchParams = new URLSearchParams();
@@ -1406,40 +1477,56 @@ class ApiClient {
1406
1477
  if (query.after)
1407
1478
  searchParams.set("page[after]", query.after);
1408
1479
  const qs = searchParams.toString();
1409
- return (0, core_js_1.zodfetch)(index_js_1.ListWebhookDeliveriesResponse, `${this.baseUrl}/api/v1/webhooks/deliveries${qs ? `?${qs}` : ""}`, { method: "GET", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1480
+ return (0, core_js_1.zodfetch)(index_js_1.ListWebhookDeliveriesResponse, `${this.baseUrl}/api/v1/webhooks/deliveries${qs ? `?${qs}` : ""}`, { method: "GET", headers: this.#getHeaders(false, undefined, "listWebhookDeliveries") }, this.#requestOptions("listWebhookDeliveries", requestOptions));
1410
1481
  }
1411
1482
  retrieveWebhookDelivery(deliveryId, requestOptions) {
1412
- return (0, core_js_1.zodfetch)(index_js_1.WebhookDeliveryObject, `${this.baseUrl}/api/v1/webhooks/deliveries/${encodeURIComponent(deliveryId)}`, { method: "GET", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1483
+ return (0, core_js_1.zodfetch)(index_js_1.WebhookDeliveryObject, `${this.baseUrl}/api/v1/webhooks/deliveries/${encodeURIComponent(deliveryId)}`, { method: "GET", headers: this.#getHeaders(false, undefined, "retrieveWebhookDelivery") }, this.#requestOptions("retrieveWebhookDelivery", requestOptions));
1413
1484
  }
1414
1485
  /** Replay to every subscriber (re-checking filters), or to one `targetId` past its filter. */
1415
1486
  replayWebhookDelivery(deliveryId, options = {}, requestOptions) {
1416
1487
  const qs = options.targetId ? `?targetId=${encodeURIComponent(options.targetId)}` : "";
1417
- return (0, core_js_1.zodfetch)(index_js_1.ReplayWebhookDeliveryResponse, `${this.baseUrl}/api/v1/webhooks/deliveries/${encodeURIComponent(deliveryId)}/replay${qs}`, { method: "POST", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1488
+ return (0, core_js_1.zodfetch)(index_js_1.ReplayWebhookDeliveryResponse, `${this.baseUrl}/api/v1/webhooks/deliveries/${encodeURIComponent(deliveryId)}/replay${qs}`, { method: "POST", headers: this.#getHeaders(false, undefined, "replayWebhookDelivery") }, this.#requestOptions("replayWebhookDelivery", requestOptions));
1418
1489
  }
1419
1490
  listPrompts(requestOptions) {
1420
- return (0, core_js_1.zodfetch)(index_js_1.ListPromptsResponseBody, `${this.baseUrl}/api/v1/prompts`, { method: "GET", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1491
+ return (0, core_js_1.zodfetch)(index_js_1.ListPromptsResponseBody, `${this.baseUrl}/api/v1/prompts`, { method: "GET", headers: this.#getHeaders(false, undefined, "listPrompts") }, this.#requestOptions("listPrompts", requestOptions));
1421
1492
  }
1422
1493
  listPromptVersions(slug, requestOptions) {
1423
- return (0, core_js_1.zodfetch)(index_js_1.ListPromptVersionsResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/versions`, { method: "GET", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1494
+ return (0, core_js_1.zodfetch)(index_js_1.ListPromptVersionsResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/versions`, { method: "GET", headers: this.#getHeaders(false, undefined, "listPromptVersions") }, this.#requestOptions("listPromptVersions", requestOptions));
1424
1495
  }
1425
1496
  promotePromptVersion(slug, body, requestOptions) {
1426
- return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/promote`, { method: "POST", headers: this.#getHeaders(false), body: JSON.stringify(body) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1497
+ return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/promote`, {
1498
+ method: "POST",
1499
+ headers: this.#getHeaders(false, undefined, "promotePromptVersion"),
1500
+ body: JSON.stringify(body),
1501
+ }, this.#requestOptions("promotePromptVersion", requestOptions));
1427
1502
  }
1428
1503
  createPromptOverride(slug, body, requestOptions) {
1429
- return (0, core_js_1.zodfetch)(index_js_1.PromptOverrideCreatedResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override`, { method: "POST", headers: this.#getHeaders(false), body: JSON.stringify(body) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1504
+ return (0, core_js_1.zodfetch)(index_js_1.PromptOverrideCreatedResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override`, {
1505
+ method: "POST",
1506
+ headers: this.#getHeaders(false, undefined, "createPromptOverride"),
1507
+ body: JSON.stringify(body),
1508
+ }, this.#requestOptions("createPromptOverride", requestOptions));
1430
1509
  }
1431
1510
  updatePromptOverride(slug, body, requestOptions) {
1432
- return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override`, { method: "PUT", headers: this.#getHeaders(false), body: JSON.stringify(body) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1511
+ return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override`, {
1512
+ method: "PUT",
1513
+ headers: this.#getHeaders(false, undefined, "updatePromptOverride"),
1514
+ body: JSON.stringify(body),
1515
+ }, this.#requestOptions("updatePromptOverride", requestOptions));
1433
1516
  }
1434
1517
  removePromptOverride(slug, requestOptions) {
1435
- return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override`, { method: "DELETE", headers: this.#getHeaders(false) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1518
+ return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override`, { method: "DELETE", headers: this.#getHeaders(false, undefined, "removePromptOverride") }, this.#requestOptions("removePromptOverride", requestOptions));
1436
1519
  }
1437
1520
  reactivatePromptOverride(slug, body, requestOptions) {
1438
- return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override/reactivate`, { method: "POST", headers: this.#getHeaders(false), body: JSON.stringify(body) }, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
1521
+ return (0, core_js_1.zodfetch)(index_js_1.PromptOkResponseBody, `${this.baseUrl}/api/v1/prompts/${slug}/override/reactivate`, {
1522
+ method: "POST",
1523
+ headers: this.#getHeaders(false, undefined, "reactivatePromptOverride"),
1524
+ body: JSON.stringify(body),
1525
+ }, this.#requestOptions("reactivatePromptOverride", requestOptions));
1439
1526
  }
1440
- #getRealtimeHeaders() {
1527
+ #getRealtimeHeaders(operation = "unknown") {
1441
1528
  let headers = {
1442
- Authorization: `Bearer ${this.accessToken}`,
1529
+ Authorization: `Bearer ${this.getAccessToken(operation)}`,
1443
1530
  "trigger-version": version_js_1.VERSION,
1444
1531
  };
1445
1532
  if (this.previewBranch) {