@trigger.dev/sdk 0.0.0-prerelease-20260911153544 → 0.0.0-prerelease-windows-bundle-fix-20260928100448
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 +37 -12
- package/dist/commonjs/v3/ai.js +349 -278
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.js +8 -2
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chat-client.js +7 -0
- package/dist/commonjs/v3/chat-client.js.map +1 -1
- package/dist/commonjs/v3/chat-server.d.ts +1 -0
- package/dist/commonjs/v3/chat-server.js +8 -0
- package/dist/commonjs/v3/chat-server.js.map +1 -1
- package/dist/commonjs/v3/chat.js +13 -9
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/compactionResponse.d.ts +9 -0
- package/dist/commonjs/v3/compactionResponse.js +37 -0
- package/dist/commonjs/v3/compactionResponse.js.map +1 -0
- package/dist/commonjs/v3/concurrency-shared.d.ts +13 -0
- package/dist/commonjs/v3/concurrency-shared.js +35 -0
- package/dist/commonjs/v3/concurrency-shared.js.map +1 -0
- package/dist/commonjs/v3/concurrencyLimits.d.ts +73 -0
- package/dist/commonjs/v3/concurrencyLimits.js +166 -0
- package/dist/commonjs/v3/concurrencyLimits.js.map +1 -0
- package/dist/commonjs/v3/index.d.ts +2 -1
- package/dist/commonjs/v3/index.js +3 -1
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/managedChatResponse.d.ts +44 -0
- package/dist/commonjs/v3/managedChatResponse.js +233 -0
- package/dist/commonjs/v3/managedChatResponse.js.map +1 -0
- package/dist/commonjs/v3/queues.d.ts +31 -0
- package/dist/commonjs/v3/queues.js +31 -0
- package/dist/commonjs/v3/queues.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +5 -0
- package/dist/commonjs/v3/sessionTracing.d.ts +7 -0
- package/dist/commonjs/v3/sessionTracing.js +44 -0
- package/dist/commonjs/v3/sessionTracing.js.map +1 -0
- package/dist/commonjs/v3/sessions.js +31 -34
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +18 -1
- package/dist/commonjs/v3/shared.js +145 -52
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/steeringContext.d.ts +41 -0
- package/dist/commonjs/v3/steeringContext.js +118 -0
- package/dist/commonjs/v3/steeringContext.js.map +1 -0
- package/dist/commonjs/v3/transcriptStorage.d.ts +4 -1
- package/dist/commonjs/v3/transcriptStorage.js +55 -4
- package/dist/commonjs/v3/transcriptStorage.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +37 -12
- package/dist/esm/v3/ai.js +350 -279
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.js +8 -2
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chat-client.js +7 -0
- package/dist/esm/v3/chat-client.js.map +1 -1
- package/dist/esm/v3/chat-server.d.ts +1 -0
- package/dist/esm/v3/chat-server.js +8 -0
- package/dist/esm/v3/chat-server.js.map +1 -1
- package/dist/esm/v3/chat.js +13 -9
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/compactionResponse.d.ts +9 -0
- package/dist/esm/v3/compactionResponse.js +34 -0
- package/dist/esm/v3/compactionResponse.js.map +1 -0
- package/dist/esm/v3/concurrency-shared.d.ts +13 -0
- package/dist/esm/v3/concurrency-shared.js +31 -0
- package/dist/esm/v3/concurrency-shared.js.map +1 -0
- package/dist/esm/v3/concurrencyLimits.d.ts +73 -0
- package/dist/esm/v3/concurrencyLimits.js +158 -0
- package/dist/esm/v3/concurrencyLimits.js.map +1 -0
- package/dist/esm/v3/index.d.ts +2 -1
- package/dist/esm/v3/index.js +2 -1
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/managedChatResponse.d.ts +44 -0
- package/dist/esm/v3/managedChatResponse.js +228 -0
- package/dist/esm/v3/managedChatResponse.js.map +1 -0
- package/dist/esm/v3/queues.d.ts +31 -0
- package/dist/esm/v3/queues.js +31 -0
- package/dist/esm/v3/queues.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +5 -0
- package/dist/esm/v3/sessionTracing.d.ts +7 -0
- package/dist/esm/v3/sessionTracing.js +40 -0
- package/dist/esm/v3/sessionTracing.js.map +1 -0
- package/dist/esm/v3/sessions.js +31 -34
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +18 -1
- package/dist/esm/v3/shared.js +145 -53
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/steeringContext.d.ts +41 -0
- package/dist/esm/v3/steeringContext.js +113 -0
- package/dist/esm/v3/steeringContext.js.map +1 -0
- package/dist/esm/v3/transcriptStorage.d.ts +4 -1
- package/dist/esm/v3/transcriptStorage.js +55 -5
- package/dist/esm/v3/transcriptStorage.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/anatomy.mdx +44 -24
- package/docs/ai-chat/client-protocol.mdx +2 -0
- package/docs/ai-chat/error-handling.mdx +44 -76
- package/docs/ai-chat/frontend.mdx +27 -21
- package/docs/ai-chat/lifecycle-hooks.mdx +4 -2
- package/docs/ai-chat/patterns/branching-conversations.mdx +95 -230
- package/docs/ai-chat/patterns/human-in-the-loop.mdx +166 -164
- package/docs/ai-chat/patterns/tool-result-auditing.mdx +28 -27
- package/docs/ai-chat/pending-messages.mdx +19 -5
- package/docs/ai-chat/quick-start.mdx +26 -20
- package/docs/ai-chat/reference.mdx +4 -2
- package/docs/ai-chat/testing.mdx +16 -4
- package/docs/cli-env-commands.mdx +114 -0
- package/docs/cli-projects-commands.mdx +62 -0
- package/docs/cli-runs-commands.mdx +94 -0
- package/docs/concurrency.mdx +384 -0
- package/docs/database-connections.mdx +3 -3
- package/docs/deploy-environment-variables.mdx +6 -0
- package/docs/idempotency.mdx +43 -5
- package/docs/introduction.mdx +58 -152
- package/docs/limits.mdx +16 -6
- package/docs/observability/query.mdx +25 -0
- package/docs/queues.mdx +248 -0
- package/docs/reports.mdx +1 -1
- package/docs/runs/priority.mdx +2 -25
- package/docs/self-hosting/env/webapp.mdx +7 -0
- package/docs/tasks/overview.mdx +3 -5
- package/docs/troubleshooting-alerts.mdx +124 -1
- package/docs/troubleshooting.mdx +12 -0
- package/docs/writing-tasks-introduction.mdx +2 -1
- package/package.json +2 -2
- package/docs/queue-concurrency.mdx +0 -358
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import { type ApiRequestOptions, type InitOutput, type Queue, type QueueOptions, type TaskFromIdentifier, type TaskRunContext, ApiError, SubtaskUnwrapError, TaskRunPromise, type AnyRunHandle, type AnyTask, type BatchByIdAndWaitItem, type BatchByIdItem, type BatchByIdResult, type BatchByTaskAndWaitItem, type BatchByTaskItem, type BatchByTaskResult, type BatchItem, type BatchItemNDJSON, type BatchResult, type BatchRunHandle, type BatchRunHandleFromTypes, type BatchTasksRunHandleFromTypes, type BatchTriggerAndWaitOptions, type BatchTriggerOptions, type InferRunTypes, type RunHandle, type RunHandleFromTypes, type Task, type TaskIdentifier, type TaskOptions, type TaskOptionsWithSchema, type TaskOutput, type TaskPayload, type TaskRunResult, type TaskSchema, type TaskWithSchema, type TaskWithSchemaOptions, type TaskWithToolOptions, type ToolTask, type ToolTaskParameters, type TriggerAndSubscribeOptions, type TriggerAndWaitOptions, type TriggerApiRequestOptions, type TriggerOptions } from "@trigger.dev/core/v3";
|
|
1
|
+
import { type ApiRequestOptions, type InitOutput, type Queue, type QueueOptions, type TaskFromIdentifier, type TaskRunContext, ApiError, SubtaskUnwrapError, TaskRunPromise, type AnyRunHandle, type AnyTask, type BatchByIdAndWaitItem, type BatchByIdItem, type BatchByIdResult, type BatchByTaskAndWaitItem, type BatchByTaskItem, type BatchByTaskResult, type BatchItem, type BatchItemNDJSON, type BatchResult, type BatchRunHandle, type BatchRunHandleFromTypes, type BatchTasksRunHandleFromTypes, type BatchTriggerAndWaitOptions, type BatchTriggerOptions, type InferRunTypes, type RunHandle, type RunHandleFromTypes, type Task, type TaskIdentifier, type TaskOptions, type TaskOptionsWithSchema, type TaskOutput, type TaskPayload, type TaskRunResult, type TaskSchema, type TaskWithSchema, type TaskWithSchemaOptions, type TaskWithToolOptions, type ToolTask, type ToolTaskParameters, type TriggerAndSubscribeOptions, type TriggerAndWaitOptions, type TriggerApiRequestOptions, type TriggerOptions, type ConcurrencyLimitOptions, type ConcurrencyLimit } from "@trigger.dev/core/v3";
|
|
2
2
|
export type { AnyRunHandle, AnyTask, BatchItem, BatchResult, BatchRunHandle, BatchTriggerOptions, Queue, RunHandle, Task, TaskFromIdentifier, TaskIdentifier, TaskOptions, TaskOptionsWithSchema, TaskOutput, TaskPayload, TaskRunResult, TaskSchema, TaskWithSchema, TaskWithSchemaOptions, TriggerOptions, };
|
|
3
3
|
export { SubtaskUnwrapError, TaskRunPromise };
|
|
4
4
|
export type Context = TaskRunContext;
|
|
5
5
|
export declare function queue(options: QueueOptions): Queue;
|
|
6
|
+
/**
|
|
7
|
+
* Declares a named, shareable concurrency limit. Tasks hold it via their `concurrency`
|
|
8
|
+
* option; every task holding the same limit draws from the same pools.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* export const openaiLimit = concurrencyLimit({ name: "openai", total: 25 });
|
|
14
|
+
*
|
|
15
|
+
* export const generateSummary = task({
|
|
16
|
+
* id: "generate-summary",
|
|
17
|
+
* concurrency: [{ total: 5 }, openaiLimit],
|
|
18
|
+
* run: async (payload) => {},
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function concurrencyLimit(options: ConcurrencyLimitOptions): ConcurrencyLimit;
|
|
6
23
|
export declare function createTask<TIdentifier extends string, TOutput = unknown, TInitOutput extends InitOutput = any>(params: TaskOptionsWithSchema<TIdentifier, TOutput, TInitOutput>): Task<TIdentifier, any, TOutput>;
|
|
7
24
|
export declare function createTask<TIdentifier extends string, TInput = void, TOutput = unknown, TInitOutput extends InitOutput = any>(params: TaskOptions<TIdentifier, TInput, TOutput, TInitOutput>): Task<TIdentifier, TInput, TOutput>;
|
|
8
25
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BatchTriggerError = exports.TaskRunPromise = exports.SubtaskUnwrapError = void 0;
|
|
4
4
|
exports.queue = queue;
|
|
5
|
+
exports.concurrencyLimit = concurrencyLimit;
|
|
5
6
|
exports.createTask = createTask;
|
|
6
7
|
exports.createToolTask = createToolTask;
|
|
7
8
|
exports.createSchemaTask = createSchemaTask;
|
|
@@ -23,30 +24,105 @@ Object.defineProperty(exports, "SubtaskUnwrapError", { enumerable: true, get: fu
|
|
|
23
24
|
Object.defineProperty(exports, "TaskRunPromise", { enumerable: true, get: function () { return v3_1.TaskRunPromise; } });
|
|
24
25
|
const externalDeploymentId_js_1 = require("./externalDeploymentId.js");
|
|
25
26
|
const tracer_js_1 = require("./tracer.js");
|
|
27
|
+
const concurrency_shared_js_1 = require("./concurrency-shared.js");
|
|
28
|
+
/** A task's `queue` is a queue object or a string reference to a queue defined elsewhere. */
|
|
29
|
+
function normalizeTaskQueue(queue) {
|
|
30
|
+
if (!queue) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
return { queue: typeof queue === "string" ? { name: queue } : queue };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates and normalizes the task `concurrency` option into its manifest shape:
|
|
37
|
+
* at most one inline limit (caps this task) plus up to two named limits (shared).
|
|
38
|
+
*/
|
|
39
|
+
function normalizeTaskConcurrency(taskId, concurrency) {
|
|
40
|
+
if (!concurrency) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const items = Array.isArray(concurrency) ? concurrency : [concurrency];
|
|
44
|
+
const inline = [];
|
|
45
|
+
const limits = [];
|
|
46
|
+
for (const item of items) {
|
|
47
|
+
if (typeof item === "string") {
|
|
48
|
+
limits.push(item);
|
|
49
|
+
}
|
|
50
|
+
else if (item &&
|
|
51
|
+
typeof item === "object" &&
|
|
52
|
+
"name" in item &&
|
|
53
|
+
typeof item.name === "string") {
|
|
54
|
+
(0, concurrency_shared_js_1.validateConcurrencyLimitName)(item.name);
|
|
55
|
+
v3_1.resourceCatalog.registerConcurrencyLimitMetadata(item);
|
|
56
|
+
limits.push(item.name);
|
|
57
|
+
}
|
|
58
|
+
else if (item && typeof item === "object") {
|
|
59
|
+
inline.push({ perKey: item.perKey, total: item.total });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (inline.length > 1) {
|
|
63
|
+
throw new Error(`Task "${taskId}": concurrency accepts at most one inline limit. Give shared limits a name with concurrencyLimit().`);
|
|
64
|
+
}
|
|
65
|
+
if (limits.length > 2) {
|
|
66
|
+
throw new Error(`Task "${taskId}": concurrency accepts at most two named limits.`);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
inline: inline[0],
|
|
70
|
+
limits: limits.length > 0 ? limits : undefined,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Builds the queue field of a trigger request body. */
|
|
74
|
+
function triggerQueueBody(queue, fallbackQueueName) {
|
|
75
|
+
const name = queue ?? fallbackQueueName;
|
|
76
|
+
return { queue: name ? { name } : undefined };
|
|
77
|
+
}
|
|
26
78
|
function queue(options) {
|
|
27
79
|
v3_1.resourceCatalog.registerQueueMetadata(options);
|
|
28
80
|
// @ts-expect-error
|
|
29
81
|
options[Symbol.for("trigger.dev/queue")] = true;
|
|
30
82
|
return options;
|
|
31
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Declares a named, shareable concurrency limit. Tasks hold it via their `concurrency`
|
|
86
|
+
* option; every task holding the same limit draws from the same pools.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* export const openaiLimit = concurrencyLimit({ name: "openai", total: 25 });
|
|
92
|
+
*
|
|
93
|
+
* export const generateSummary = task({
|
|
94
|
+
* id: "generate-summary",
|
|
95
|
+
* concurrency: [{ total: 5 }, openaiLimit],
|
|
96
|
+
* run: async (payload) => {},
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
function concurrencyLimit(options) {
|
|
101
|
+
(0, concurrency_shared_js_1.validateConcurrencyLimitName)(options.name);
|
|
102
|
+
v3_1.resourceCatalog.registerConcurrencyLimitMetadata(options);
|
|
103
|
+
// @ts-expect-error
|
|
104
|
+
options[Symbol.for("trigger.dev/concurrencyLimit")] = true;
|
|
105
|
+
return options;
|
|
106
|
+
}
|
|
32
107
|
function createTask(params) {
|
|
108
|
+
const normalizedQueue = normalizeTaskQueue(params.queue);
|
|
33
109
|
const task = {
|
|
34
110
|
id: params.id,
|
|
35
111
|
description: params.description,
|
|
36
112
|
jsonSchema: params.jsonSchema,
|
|
37
113
|
trigger: async (payload, options) => {
|
|
38
114
|
return await trigger_internal("trigger()", params.id, payload, undefined, {
|
|
39
|
-
queue:
|
|
115
|
+
queue: normalizedQueue.queue?.name,
|
|
40
116
|
...options,
|
|
41
117
|
});
|
|
42
118
|
},
|
|
43
119
|
batchTrigger: async (items, options) => {
|
|
44
|
-
return await batchTrigger_internal("batchTrigger()", params.id, items, options, undefined, undefined,
|
|
120
|
+
return await batchTrigger_internal("batchTrigger()", params.id, items, options, undefined, undefined, normalizedQueue.queue?.name);
|
|
45
121
|
},
|
|
46
122
|
triggerAndWait: (payload, options, requestOptions) => {
|
|
47
123
|
return new v3_1.TaskRunPromise((resolve, reject) => {
|
|
48
124
|
triggerAndWait_internal("triggerAndWait()", params.id, payload, undefined, {
|
|
49
|
-
queue:
|
|
125
|
+
queue: normalizedQueue.queue?.name,
|
|
50
126
|
...options,
|
|
51
127
|
}, requestOptions)
|
|
52
128
|
.then((result) => {
|
|
@@ -60,7 +136,7 @@ function createTask(params) {
|
|
|
60
136
|
triggerAndSubscribe: (payload, options) => {
|
|
61
137
|
return new v3_1.TaskRunPromise((resolve, reject) => {
|
|
62
138
|
triggerAndSubscribe_internal("triggerAndSubscribe()", params.id, payload, undefined, {
|
|
63
|
-
queue:
|
|
139
|
+
queue: normalizedQueue.queue?.name,
|
|
64
140
|
...options,
|
|
65
141
|
})
|
|
66
142
|
.then((result) => {
|
|
@@ -72,14 +148,15 @@ function createTask(params) {
|
|
|
72
148
|
}, params.id);
|
|
73
149
|
},
|
|
74
150
|
batchTriggerAndWait: async (items, options) => {
|
|
75
|
-
return await batchTriggerAndWait_internal("batchTriggerAndWait()", params.id, items, undefined, options, undefined,
|
|
151
|
+
return await batchTriggerAndWait_internal("batchTriggerAndWait()", params.id, items, undefined, options, undefined, normalizedQueue.queue?.name);
|
|
76
152
|
},
|
|
77
153
|
};
|
|
78
154
|
registerTaskLifecycleHooks(params.id, params);
|
|
79
155
|
v3_1.resourceCatalog.registerTaskMetadata({
|
|
80
156
|
id: params.id,
|
|
81
157
|
description: params.description,
|
|
82
|
-
queue:
|
|
158
|
+
queue: normalizedQueue.queue,
|
|
159
|
+
concurrency: normalizeTaskConcurrency(params.id, params.concurrency),
|
|
83
160
|
retry: params.retry ? { ...v3_1.defaultRetryOptions, ...params.retry } : undefined,
|
|
84
161
|
machine: typeof params.machine === "string" ? { preset: params.machine } : params.machine,
|
|
85
162
|
triggerSource: params.triggerSource,
|
|
@@ -91,8 +168,14 @@ function createTask(params) {
|
|
|
91
168
|
run: params.run,
|
|
92
169
|
},
|
|
93
170
|
});
|
|
94
|
-
const queue =
|
|
95
|
-
|
|
171
|
+
const queue = normalizedQueue.queue;
|
|
172
|
+
/**
|
|
173
|
+
* A string queue name (bare or as a tuple's first element) is a REFERENCE to a
|
|
174
|
+
* queue defined elsewhere; registering it would create an empty definition that
|
|
175
|
+
* can shadow the real one depending on module evaluation order.
|
|
176
|
+
*/
|
|
177
|
+
const homeIsReference = typeof params.queue === "string";
|
|
178
|
+
if (queue && typeof queue.name === "string" && !homeIsReference) {
|
|
96
179
|
v3_1.resourceCatalog.registerQueueMetadata({
|
|
97
180
|
name: queue.name,
|
|
98
181
|
concurrencyLimit: queue.concurrencyLimit,
|
|
@@ -125,23 +208,24 @@ function createSchemaTask(params) {
|
|
|
125
208
|
const parsePayload = params.schema
|
|
126
209
|
? (0, v3_1.getSchemaParseFn)(params.schema)
|
|
127
210
|
: undefined;
|
|
211
|
+
const normalizedQueue = normalizeTaskQueue(params.queue);
|
|
128
212
|
const task = {
|
|
129
213
|
id: params.id,
|
|
130
214
|
description: params.description,
|
|
131
215
|
schema: params.schema,
|
|
132
216
|
trigger: async (payload, options, requestOptions) => {
|
|
133
217
|
return await trigger_internal("trigger()", params.id, payload, parsePayload, {
|
|
134
|
-
queue:
|
|
218
|
+
queue: normalizedQueue.queue?.name,
|
|
135
219
|
...options,
|
|
136
220
|
}, requestOptions);
|
|
137
221
|
},
|
|
138
222
|
batchTrigger: async (items, options, requestOptions) => {
|
|
139
|
-
return await batchTrigger_internal("batchTrigger()", params.id, items, options, parsePayload, requestOptions,
|
|
223
|
+
return await batchTrigger_internal("batchTrigger()", params.id, items, options, parsePayload, requestOptions, normalizedQueue.queue?.name);
|
|
140
224
|
},
|
|
141
225
|
triggerAndWait: (payload, options) => {
|
|
142
226
|
return new v3_1.TaskRunPromise((resolve, reject) => {
|
|
143
227
|
triggerAndWait_internal("triggerAndWait()", params.id, payload, parsePayload, {
|
|
144
|
-
queue:
|
|
228
|
+
queue: normalizedQueue.queue?.name,
|
|
145
229
|
...options,
|
|
146
230
|
})
|
|
147
231
|
.then((result) => {
|
|
@@ -155,7 +239,7 @@ function createSchemaTask(params) {
|
|
|
155
239
|
triggerAndSubscribe: (payload, options) => {
|
|
156
240
|
return new v3_1.TaskRunPromise((resolve, reject) => {
|
|
157
241
|
triggerAndSubscribe_internal("triggerAndSubscribe()", params.id, payload, parsePayload, {
|
|
158
|
-
queue:
|
|
242
|
+
queue: normalizedQueue.queue?.name,
|
|
159
243
|
...options,
|
|
160
244
|
})
|
|
161
245
|
.then((result) => {
|
|
@@ -167,14 +251,15 @@ function createSchemaTask(params) {
|
|
|
167
251
|
}, params.id);
|
|
168
252
|
},
|
|
169
253
|
batchTriggerAndWait: async (items, options) => {
|
|
170
|
-
return await batchTriggerAndWait_internal("batchTriggerAndWait()", params.id, items, parsePayload, options, undefined,
|
|
254
|
+
return await batchTriggerAndWait_internal("batchTriggerAndWait()", params.id, items, parsePayload, options, undefined, normalizedQueue.queue?.name);
|
|
171
255
|
},
|
|
172
256
|
};
|
|
173
257
|
registerTaskLifecycleHooks(params.id, params);
|
|
174
258
|
v3_1.resourceCatalog.registerTaskMetadata({
|
|
175
259
|
id: params.id,
|
|
176
260
|
description: params.description,
|
|
177
|
-
queue:
|
|
261
|
+
queue: normalizedQueue.queue,
|
|
262
|
+
concurrency: normalizeTaskConcurrency(params.id, params.concurrency),
|
|
178
263
|
retry: params.retry ? { ...v3_1.defaultRetryOptions, ...params.retry } : undefined,
|
|
179
264
|
machine: typeof params.machine === "string" ? { preset: params.machine } : params.machine,
|
|
180
265
|
triggerSource: params.triggerSource,
|
|
@@ -187,8 +272,14 @@ function createSchemaTask(params) {
|
|
|
187
272
|
},
|
|
188
273
|
schema: params.schema,
|
|
189
274
|
});
|
|
190
|
-
const queue =
|
|
191
|
-
|
|
275
|
+
const queue = normalizedQueue.queue;
|
|
276
|
+
/**
|
|
277
|
+
* A string queue name (bare or as a tuple's first element) is a REFERENCE to a
|
|
278
|
+
* queue defined elsewhere; registering it would create an empty definition that
|
|
279
|
+
* can shadow the real one depending on module evaluation order.
|
|
280
|
+
*/
|
|
281
|
+
const homeIsReference = typeof params.queue === "string";
|
|
282
|
+
if (queue && typeof queue.name === "string" && !homeIsReference) {
|
|
192
283
|
v3_1.resourceCatalog.registerQueueMetadata({
|
|
193
284
|
name: queue.name,
|
|
194
285
|
concurrencyLimit: queue.concurrencyLimit,
|
|
@@ -327,7 +418,8 @@ async function batchTriggerById(...args) {
|
|
|
327
418
|
task: item.id,
|
|
328
419
|
payload: payloadPacket.data,
|
|
329
420
|
options: {
|
|
330
|
-
|
|
421
|
+
...triggerQueueBody(item.options?.queue),
|
|
422
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
331
423
|
concurrencyKey: item.options?.concurrencyKey,
|
|
332
424
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
333
425
|
payloadType: payloadPacket.dataType,
|
|
@@ -423,7 +515,8 @@ async function batchTriggerByIdAndWait(...args) {
|
|
|
423
515
|
payload: payloadPacket.data,
|
|
424
516
|
options: {
|
|
425
517
|
lockToVersion: v3_1.taskContext.worker?.version,
|
|
426
|
-
|
|
518
|
+
...triggerQueueBody(item.options?.queue),
|
|
519
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
427
520
|
concurrencyKey: item.options?.concurrencyKey,
|
|
428
521
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
429
522
|
payloadType: payloadPacket.dataType,
|
|
@@ -520,7 +613,8 @@ async function batchTriggerTasks(...args) {
|
|
|
520
613
|
task: item.task.id,
|
|
521
614
|
payload: payloadPacket.data,
|
|
522
615
|
options: {
|
|
523
|
-
|
|
616
|
+
...triggerQueueBody(item.options?.queue),
|
|
617
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
524
618
|
concurrencyKey: item.options?.concurrencyKey,
|
|
525
619
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
526
620
|
payloadType: payloadPacket.dataType,
|
|
@@ -617,7 +711,8 @@ async function batchTriggerAndWaitTasks(...args) {
|
|
|
617
711
|
payload: payloadPacket.data,
|
|
618
712
|
options: {
|
|
619
713
|
lockToVersion: v3_1.taskContext.worker?.version,
|
|
620
|
-
|
|
714
|
+
...triggerQueueBody(item.options?.queue),
|
|
715
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
621
716
|
concurrencyKey: item.options?.concurrencyKey,
|
|
622
717
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
623
718
|
payloadType: payloadPacket.dataType,
|
|
@@ -976,7 +1071,8 @@ async function* transformBatchItemsStream(items, options) {
|
|
|
976
1071
|
task: item.id,
|
|
977
1072
|
payload: payloadPacket.data,
|
|
978
1073
|
options: {
|
|
979
|
-
|
|
1074
|
+
...triggerQueueBody(item.options?.queue),
|
|
1075
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
980
1076
|
concurrencyKey: item.options?.concurrencyKey,
|
|
981
1077
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
982
1078
|
payloadType: payloadPacket.dataType,
|
|
@@ -1019,7 +1115,8 @@ async function* transformBatchItemsStreamForWait(items, options) {
|
|
|
1019
1115
|
payload: payloadPacket.data,
|
|
1020
1116
|
options: {
|
|
1021
1117
|
lockToVersion: v3_1.taskContext.worker?.version,
|
|
1022
|
-
|
|
1118
|
+
...triggerQueueBody(item.options?.queue),
|
|
1119
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
1023
1120
|
concurrencyKey: item.options?.concurrencyKey,
|
|
1024
1121
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1025
1122
|
payloadType: payloadPacket.dataType,
|
|
@@ -1058,7 +1155,8 @@ async function* transformBatchByTaskItemsStream(items, options) {
|
|
|
1058
1155
|
task: item.task.id,
|
|
1059
1156
|
payload: payloadPacket.data,
|
|
1060
1157
|
options: {
|
|
1061
|
-
|
|
1158
|
+
...triggerQueueBody(item.options?.queue),
|
|
1159
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
1062
1160
|
concurrencyKey: item.options?.concurrencyKey,
|
|
1063
1161
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1064
1162
|
payloadType: payloadPacket.dataType,
|
|
@@ -1100,7 +1198,8 @@ async function* transformBatchByTaskItemsStreamForWait(items, options) {
|
|
|
1100
1198
|
payload: payloadPacket.data,
|
|
1101
1199
|
options: {
|
|
1102
1200
|
lockToVersion: v3_1.taskContext.worker?.version,
|
|
1103
|
-
|
|
1201
|
+
...triggerQueueBody(item.options?.queue),
|
|
1202
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
1104
1203
|
concurrencyKey: item.options?.concurrencyKey,
|
|
1105
1204
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1106
1205
|
payloadType: payloadPacket.dataType,
|
|
@@ -1136,11 +1235,8 @@ async function* transformSingleTaskBatchItemsStream(taskIdentifier, items, parse
|
|
|
1136
1235
|
task: taskIdentifier,
|
|
1137
1236
|
payload: payloadPacket.data,
|
|
1138
1237
|
options: {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
: queue
|
|
1142
|
-
? { name: queue }
|
|
1143
|
-
: undefined,
|
|
1238
|
+
...triggerQueueBody(item.options?.queue, queue),
|
|
1239
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
1144
1240
|
concurrencyKey: item.options?.concurrencyKey,
|
|
1145
1241
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1146
1242
|
payloadType: payloadPacket.dataType,
|
|
@@ -1185,11 +1281,8 @@ async function* transformSingleTaskBatchItemsStreamForWait(taskIdentifier, items
|
|
|
1185
1281
|
payload: payloadPacket.data,
|
|
1186
1282
|
options: {
|
|
1187
1283
|
lockToVersion: v3_1.taskContext.worker?.version,
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
: queue
|
|
1191
|
-
? { name: queue }
|
|
1192
|
-
: undefined,
|
|
1284
|
+
...triggerQueueBody(item.options?.queue, queue),
|
|
1285
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
1193
1286
|
concurrencyKey: item.options?.concurrencyKey,
|
|
1194
1287
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1195
1288
|
payloadType: payloadPacket.dataType,
|
|
@@ -1222,7 +1315,8 @@ async function trigger_internal(name, id, payload, parsePayload, options, reques
|
|
|
1222
1315
|
const handle = await apiClient.triggerTask(id, {
|
|
1223
1316
|
payload: triggerPayloadPacket.data,
|
|
1224
1317
|
options: {
|
|
1225
|
-
|
|
1318
|
+
...triggerQueueBody(options?.queue),
|
|
1319
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(options?.concurrency),
|
|
1226
1320
|
concurrencyKey: options?.concurrencyKey,
|
|
1227
1321
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1228
1322
|
payloadType: triggerPayloadPacket.dataType,
|
|
@@ -1282,11 +1376,8 @@ async function batchTrigger_internal(name, taskIdentifier, items, options, parse
|
|
|
1282
1376
|
task: taskIdentifier,
|
|
1283
1377
|
payload: payloadPacket.data,
|
|
1284
1378
|
options: {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
: queue
|
|
1288
|
-
? { name: queue }
|
|
1289
|
-
: undefined,
|
|
1379
|
+
...triggerQueueBody(item.options?.queue, queue),
|
|
1380
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
1290
1381
|
concurrencyKey: item.options?.concurrencyKey,
|
|
1291
1382
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1292
1383
|
payloadType: payloadPacket.dataType,
|
|
@@ -1407,7 +1498,8 @@ async function triggerAndWait_internal(name, id, payload, parsePayload, options,
|
|
|
1407
1498
|
payload: triggerPayloadPacket.data,
|
|
1408
1499
|
options: {
|
|
1409
1500
|
lockToVersion: v3_1.taskContext.worker?.version, // Lock to current version because we're waiting for it to finish
|
|
1410
|
-
|
|
1501
|
+
...triggerQueueBody(options?.queue),
|
|
1502
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(options?.concurrency),
|
|
1411
1503
|
concurrencyKey: options?.concurrencyKey,
|
|
1412
1504
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1413
1505
|
payloadType: triggerPayloadPacket.dataType,
|
|
@@ -1468,7 +1560,8 @@ async function triggerAndSubscribe_internal(name, id, payload, parsePayload, opt
|
|
|
1468
1560
|
payload: triggerPayloadPacket.data,
|
|
1469
1561
|
options: {
|
|
1470
1562
|
lockToVersion: v3_1.taskContext.worker?.version,
|
|
1471
|
-
|
|
1563
|
+
...triggerQueueBody(options?.queue),
|
|
1564
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(options?.concurrency),
|
|
1472
1565
|
concurrencyKey: options?.concurrencyKey,
|
|
1473
1566
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1474
1567
|
payloadType: triggerPayloadPacket.dataType,
|
|
@@ -1535,13 +1628,16 @@ async function triggerAndSubscribe_internal(name, id, payload, parsePayload, opt
|
|
|
1535
1628
|
// INTERNAL_ERROR, STRING_ERROR) via the completion message and
|
|
1536
1629
|
// passes it through `createErrorTaskError` to preserve the
|
|
1537
1630
|
// discriminator. `subscribeToRun` only surfaces a
|
|
1538
|
-
// `SerializedError` (`{ name, message, stackTrace }`)
|
|
1539
|
-
// `createJsonErrorObject` strips the discriminator before
|
|
1540
|
-
// record hits the realtime stream. We can't reconstruct the
|
|
1631
|
+
// `SerializedError` (`{ name, message, stackTrace, causes }`)
|
|
1632
|
+
// because `createJsonErrorObject` strips the discriminator before
|
|
1633
|
+
// the record hits the realtime stream. We can't reconstruct the
|
|
1541
1634
|
// discriminator here without lossy guessing — callers that
|
|
1542
1635
|
// need exact error-type matching should use `triggerAndWait`
|
|
1543
|
-
// instead; subscribers get message
|
|
1544
|
-
const
|
|
1636
|
+
// instead; subscribers get message, name and the cause chain.
|
|
1637
|
+
const cause = run.error?.causes?.length
|
|
1638
|
+
? (0, v3_1.createErrorFromCauses)(run.error.causes)
|
|
1639
|
+
: undefined;
|
|
1640
|
+
const error = new Error(run.error?.message ?? `Task ${id} failed (${run.status})`, cause ? { cause } : undefined);
|
|
1545
1641
|
if (run.error?.name)
|
|
1546
1642
|
error.name = run.error.name;
|
|
1547
1643
|
return {
|
|
@@ -1600,11 +1696,8 @@ async function batchTriggerAndWait_internal(name, id, items, parsePayload, optio
|
|
|
1600
1696
|
payload: payloadPacket.data,
|
|
1601
1697
|
options: {
|
|
1602
1698
|
lockToVersion: v3_1.taskContext.worker?.version,
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
: queue
|
|
1606
|
-
? { name: queue }
|
|
1607
|
-
: undefined,
|
|
1699
|
+
...triggerQueueBody(item.options?.queue, queue),
|
|
1700
|
+
...(0, concurrency_shared_js_1.triggerConcurrencyBody)(item.options?.concurrency),
|
|
1608
1701
|
concurrencyKey: item.options?.concurrencyKey,
|
|
1609
1702
|
test: v3_1.taskContext.ctx?.run.isTest,
|
|
1610
1703
|
payloadType: payloadPacket.dataType,
|