@hatchet-dev/typescript-sdk 1.27.0 → 1.28.1
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/clients/dispatcher/action-listener.js +11 -2
- package/clients/dispatcher/dispatcher-client.d.ts +6 -1
- package/clients/dispatcher/dispatcher-client.js +14 -0
- package/clients/dispatcher/heartbeat/heartbeat-controller.d.ts +13 -4
- package/clients/dispatcher/heartbeat/heartbeat-controller.js +11 -1
- package/clients/dispatcher/heartbeat/heartbeat-severity.d.ts +3 -0
- package/clients/dispatcher/heartbeat/heartbeat-severity.js +11 -0
- package/clients/dispatcher/heartbeat/heartbeat-worker.js +11 -4
- package/clients/dispatcher/listener-severity.d.ts +3 -0
- package/clients/dispatcher/listener-severity.js +11 -0
- package/clients/listeners/durable-listener/durable-listener-client.d.ts +1 -0
- package/clients/listeners/durable-listener/durable-listener-client.js +20 -2
- package/clients/rest/generated/Api.d.ts +2 -0
- package/clients/rest/generated/data-contracts.d.ts +2 -0
- package/clients/rest/generated/data-contracts.js +2 -0
- package/package.json +3 -3
- package/protoc/dispatcher/dispatcher.d.ts +67 -0
- package/protoc/dispatcher/dispatcher.js +495 -3
- package/protoc/events/events.js +1 -1
- package/protoc/google/protobuf/any.js +1 -1
- package/protoc/google/protobuf/timestamp.js +1 -1
- package/protoc/google/rpc/status.js +1 -1
- package/protoc/v1/dispatcher.js +1 -1
- package/protoc/v1/shared/condition.js +1 -1
- package/protoc/v1/shared/trigger.js +1 -1
- package/protoc/v1/workflows.d.ts +24 -7
- package/protoc/v1/workflows.js +218 -40
- package/protoc/workflows/workflows.js +1 -1
- package/util/failure-severity.d.ts +2 -0
- package/util/failure-severity.js +15 -0
- package/util/grpc-error.d.ts +6 -0
- package/util/grpc-error.js +11 -0
- package/util/workflow-run-ref.js +23 -9
- package/v1/client/client.d.ts +26 -1
- package/v1/client/client.js +6 -0
- package/v1/client/worker/context.js +23 -3
- package/v1/client/worker/worker-internal.d.ts +22 -1
- package/v1/client/worker/worker-internal.js +167 -2
- package/v1/declaration.d.ts +62 -2
- package/v1/declaration.js +56 -0
- package/v1/examples/batch_assign/workflow.d.ts +62 -0
- package/v1/examples/batch_assign/workflow.js +161 -0
- package/v1/examples/e2e-worker.js +35 -21
- package/v1/task.d.ts +50 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -74,6 +74,7 @@ const abort_controller_x_1 = require("abort-controller-x");
|
|
|
74
74
|
const sleep_1 = __importDefault(require("../../util/sleep"));
|
|
75
75
|
const hatchet_error_1 = __importStar(require("../../util/errors/hatchet-error"));
|
|
76
76
|
const heartbeat_controller_1 = require("./heartbeat/heartbeat-controller");
|
|
77
|
+
const listener_severity_1 = require("./listener-severity");
|
|
77
78
|
const DEFAULT_ACTION_LISTENER_RETRY_INTERVAL = 5000; // milliseconds
|
|
78
79
|
const DEFAULT_ACTION_LISTENER_RETRY_COUNT = 20;
|
|
79
80
|
var ListenStrategy;
|
|
@@ -145,7 +146,11 @@ class ActionListener {
|
|
|
145
146
|
client.setListenStrategy(ListenStrategy.LISTEN_STRATEGY_V1);
|
|
146
147
|
}
|
|
147
148
|
client.incrementRetries();
|
|
148
|
-
|
|
149
|
+
const message = `Listener encountered an error: ${(0, hatchet_error_1.getErrorMessage)(e)}`;
|
|
150
|
+
const severity = (0, listener_severity_1.classifyListenerFailure)(e, client.retries);
|
|
151
|
+
if (severity !== 'silent') {
|
|
152
|
+
client.logger[severity](message);
|
|
153
|
+
}
|
|
149
154
|
if (client.retries > 1) {
|
|
150
155
|
client.logger.info(`Retrying in ${client.retryInterval}ms...`);
|
|
151
156
|
yield __await((0, sleep_1.default)(client.retryInterval));
|
|
@@ -218,7 +223,11 @@ class ActionListener {
|
|
|
218
223
|
}
|
|
219
224
|
catch (e) {
|
|
220
225
|
this.retries += 1;
|
|
221
|
-
|
|
226
|
+
const message = `Attempt ${this.retries}: Failed to connect, retrying...`;
|
|
227
|
+
const severity = (0, listener_severity_1.classifyListenerFailure)(e, this.retries);
|
|
228
|
+
if (severity !== 'silent') {
|
|
229
|
+
this.logger[severity](message);
|
|
230
|
+
}
|
|
222
231
|
if ((0, grpc_error_1.getGrpcErrorCode)(e) === nice_grpc_1.Status.UNAVAILABLE) {
|
|
223
232
|
// Connection lost, reset heartbeat interval and retry connection
|
|
224
233
|
this.heartbeat.stop();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Channel, ClientFactory } from 'nice-grpc';
|
|
2
|
-
import { DispatcherClient as PbDispatcherClient, StepActionEvent, GroupKeyActionEvent, OverridesData, DeepPartial, WorkerLabels as PbWorkerAffinityConfig, RuntimeInfo } from '../../protoc/dispatcher';
|
|
2
|
+
import { DispatcherClient as PbDispatcherClient, StepActionEvent, BatchActionEvent, GroupKeyActionEvent, OverridesData, DeepPartial, WorkerLabels as PbWorkerAffinityConfig, RuntimeInfo } from '../../protoc/dispatcher';
|
|
3
3
|
import { ClientConfig } from '../hatchet-client/client-config';
|
|
4
4
|
import { Logger } from '../../util/logger';
|
|
5
5
|
import { SlotConfig } from '../../v1/slot-types';
|
|
@@ -37,6 +37,11 @@ export declare class DispatcherClient {
|
|
|
37
37
|
*/
|
|
38
38
|
getVersion(): Promise<string>;
|
|
39
39
|
sendStepActionEvent(in_: StepActionEventInput): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Reports a lifecycle event (STARTED, COMPLETED, or FAILED) covering one or more
|
|
42
|
+
* members of a batch task's execution.
|
|
43
|
+
*/
|
|
44
|
+
sendBatchActionEvent(in_: BatchActionEvent): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
|
|
40
45
|
sendGroupKeyActionEvent(in_: GroupKeyActionEvent): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
|
|
41
46
|
putOverridesData(in_: DeepPartial<OverridesData>): Promise<void | import("../../protoc/dispatcher").OverridesDataResponse>;
|
|
42
47
|
refreshTimeout(incrementTimeoutBy: string, taskRunExternalId: string): Promise<import("../../protoc/dispatcher").RefreshTimeoutResponse>;
|
|
@@ -83,6 +83,20 @@ class DispatcherClient {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Reports a lifecycle event (STARTED, COMPLETED, or FAILED) covering one or more
|
|
88
|
+
* members of a batch task's execution.
|
|
89
|
+
*/
|
|
90
|
+
sendBatchActionEvent(in_) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
try {
|
|
93
|
+
return yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.client.sendBatchActionEvent(in_); }), this.logger);
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
throw (0, hatchet_error_1.toHatchetError)(e);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
86
100
|
sendGroupKeyActionEvent(in_) {
|
|
87
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
102
|
try {
|
|
@@ -3,10 +3,18 @@ import { DispatcherClient as PbDispatcherClient } from '../../../protoc/dispatch
|
|
|
3
3
|
import { Worker } from 'worker_threads';
|
|
4
4
|
import { ClientConfig } from '../../hatchet-client';
|
|
5
5
|
import { DispatcherClient } from '../dispatcher-client';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { z } from 'zod/v4';
|
|
7
|
+
declare const HeartbeatMessageSchema: z.ZodObject<{
|
|
8
|
+
type: z.ZodEnum<{
|
|
9
|
+
error: "error";
|
|
10
|
+
warn: "warn";
|
|
11
|
+
info: "info";
|
|
12
|
+
debug: "debug";
|
|
13
|
+
}>;
|
|
14
|
+
message: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type HeartbeatMessage = z.infer<typeof HeartbeatMessageSchema>;
|
|
17
|
+
export declare const isHeartbeatMessage: (message: unknown) => message is HeartbeatMessage;
|
|
10
18
|
export declare const STOP_HEARTBEAT = "stop";
|
|
11
19
|
export declare class Heartbeat {
|
|
12
20
|
config: ClientConfig;
|
|
@@ -18,3 +26,4 @@ export declare class Heartbeat {
|
|
|
18
26
|
start(): Promise<void>;
|
|
19
27
|
stop(): Promise<void>;
|
|
20
28
|
}
|
|
29
|
+
export {};
|
|
@@ -23,9 +23,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Heartbeat = exports.STOP_HEARTBEAT = void 0;
|
|
26
|
+
exports.Heartbeat = exports.STOP_HEARTBEAT = exports.isHeartbeatMessage = void 0;
|
|
27
27
|
const path_1 = __importDefault(require("path"));
|
|
28
28
|
const thread_helper_1 = require("../../../util/thread-helper");
|
|
29
|
+
const v4_1 = require("zod/v4");
|
|
30
|
+
const HeartbeatMessageSchema = v4_1.z.object({
|
|
31
|
+
type: v4_1.z.enum(['info', 'warn', 'error', 'debug']),
|
|
32
|
+
message: v4_1.z.string(),
|
|
33
|
+
});
|
|
34
|
+
const isHeartbeatMessage = (message) => HeartbeatMessageSchema.safeParse(message).success;
|
|
35
|
+
exports.isHeartbeatMessage = isHeartbeatMessage;
|
|
29
36
|
exports.STOP_HEARTBEAT = 'stop';
|
|
30
37
|
class Heartbeat {
|
|
31
38
|
constructor(client, workerId) {
|
|
@@ -45,6 +52,9 @@ class Heartbeat {
|
|
|
45
52
|
},
|
|
46
53
|
});
|
|
47
54
|
this.heartbeatWorker.on('message', (message) => {
|
|
55
|
+
if (!(0, exports.isHeartbeatMessage)(message)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
48
58
|
this.logger[message.type](message.message);
|
|
49
59
|
});
|
|
50
60
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_MISSED_HEARTBEATS = void 0;
|
|
4
|
+
exports.classifyHeartbeatFailure = classifyHeartbeatFailure;
|
|
5
|
+
const grpc_error_1 = require("../../../util/grpc-error");
|
|
6
|
+
const failure_severity_1 = require("../../../util/failure-severity");
|
|
7
|
+
exports.MAX_MISSED_HEARTBEATS = 3;
|
|
8
|
+
// determines whether to immediately error log or wait for additional errors
|
|
9
|
+
function classifyHeartbeatFailure(code, missedHeartbeats) {
|
|
10
|
+
return (0, failure_severity_1.classifyRepeatedFailure)((0, grpc_error_1.isConnectionError)(code), missedHeartbeats, exports.MAX_MISSED_HEARTBEATS);
|
|
11
|
+
}
|
|
@@ -18,6 +18,7 @@ const grpc_error_1 = require("../../../util/grpc-error");
|
|
|
18
18
|
const grpc_helpers_1 = require("../../../util/grpc-helpers");
|
|
19
19
|
const dispatcher_client_1 = require("../dispatcher-client");
|
|
20
20
|
const heartbeat_controller_1 = require("./heartbeat-controller");
|
|
21
|
+
const heartbeat_severity_1 = require("./heartbeat-severity");
|
|
21
22
|
const HEARTBEAT_INTERVAL = 4000;
|
|
22
23
|
const postMessage = (message) => {
|
|
23
24
|
worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage(message);
|
|
@@ -25,6 +26,7 @@ const postMessage = (message) => {
|
|
|
25
26
|
class HeartbeatWorker {
|
|
26
27
|
constructor(config, workerId) {
|
|
27
28
|
this.timeLastHeartbeat = new Date().getTime();
|
|
29
|
+
this.missedHeartbeats = 0;
|
|
28
30
|
this.workerId = workerId;
|
|
29
31
|
this.logger = new hatchet_client_1.HatchetLogger(`HeartbeatThread`, config.log_level);
|
|
30
32
|
this.logger.debug('Heartbeat thread starting...');
|
|
@@ -69,6 +71,7 @@ class HeartbeatWorker {
|
|
|
69
71
|
message: `Heartbeat sent ${actualInterval}ms ago`,
|
|
70
72
|
});
|
|
71
73
|
this.timeLastHeartbeat = now;
|
|
74
|
+
this.missedHeartbeats = 0;
|
|
72
75
|
}
|
|
73
76
|
catch (e) {
|
|
74
77
|
if ((0, grpc_error_1.getGrpcErrorCode)(e) === nice_grpc_1.Status.UNIMPLEMENTED) {
|
|
@@ -82,12 +85,16 @@ class HeartbeatWorker {
|
|
|
82
85
|
this.stop();
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
88
|
+
this.missedHeartbeats += 1;
|
|
85
89
|
const message = `Failed to send heartbeat: ${(0, hatchet_error_1.getErrorMessage)(e)}`;
|
|
86
90
|
this.logger.debug(message);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
const severity = (0, heartbeat_severity_1.classifyHeartbeatFailure)((0, grpc_error_1.getGrpcErrorCode)(e), this.missedHeartbeats);
|
|
92
|
+
if (severity !== 'silent') {
|
|
93
|
+
postMessage({
|
|
94
|
+
type: severity,
|
|
95
|
+
message,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
91
98
|
}
|
|
92
99
|
});
|
|
93
100
|
// start with a heartbeat
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_TRANSIENT_LISTENER_RETRIES = void 0;
|
|
4
|
+
exports.classifyListenerFailure = classifyListenerFailure;
|
|
5
|
+
const grpc_error_1 = require("../../util/grpc-error");
|
|
6
|
+
const failure_severity_1 = require("../../util/failure-severity");
|
|
7
|
+
exports.MAX_TRANSIENT_LISTENER_RETRIES = 3;
|
|
8
|
+
function classifyListenerFailure(e, retries) {
|
|
9
|
+
const isTransient = e === undefined || (0, grpc_error_1.isConnectionError)((0, grpc_error_1.getGrpcErrorCode)(e));
|
|
10
|
+
return (0, failure_severity_1.classifyRepeatedFailure)(isTransient, retries, exports.MAX_TRANSIENT_LISTENER_RETRIES);
|
|
11
|
+
}
|
|
@@ -70,6 +70,7 @@ export declare class DurableListenerClient {
|
|
|
70
70
|
private _receiveAbort;
|
|
71
71
|
private _statusInterval;
|
|
72
72
|
private _startLock;
|
|
73
|
+
private _consecutiveFailures;
|
|
73
74
|
onServerEvict: ((durableTaskExternalId: string, invocationCount: number) => void) | undefined;
|
|
74
75
|
constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
|
|
75
76
|
get workerId(): string | undefined;
|
|
@@ -40,6 +40,7 @@ const dispatcher_1 = require("../../../protoc/v1/dispatcher");
|
|
|
40
40
|
const non_determinism_error_1 = require("../../../util/errors/non-determinism-error");
|
|
41
41
|
const abort_error_1 = require("../../../util/abort-error");
|
|
42
42
|
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
43
|
+
const listener_severity_1 = require("../../dispatcher/listener-severity");
|
|
43
44
|
class TTLMap {
|
|
44
45
|
constructor(ttlMs) {
|
|
45
46
|
this.ttlMs = ttlMs;
|
|
@@ -136,6 +137,7 @@ class DurableListenerClient {
|
|
|
136
137
|
// (e.g. an already-satisfied sleep delivered via polling).
|
|
137
138
|
this._bufferedCompletions = new TTLMap(10000);
|
|
138
139
|
this._pendingEvictionAcks = new Map();
|
|
140
|
+
this._consecutiveFailures = 0;
|
|
139
141
|
this.config = config;
|
|
140
142
|
this.client = factory.create(dispatcher_1.V1DispatcherDefinition, channel);
|
|
141
143
|
this.logger = config.logger(`DurableListener`, config.log_level);
|
|
@@ -159,6 +161,7 @@ class DurableListenerClient {
|
|
|
159
161
|
return;
|
|
160
162
|
this._workerId = workerId;
|
|
161
163
|
this._running = true;
|
|
164
|
+
this._consecutiveFailures = 0;
|
|
162
165
|
yield this._connect();
|
|
163
166
|
this._startStatusPolling();
|
|
164
167
|
});
|
|
@@ -209,11 +212,16 @@ class DurableListenerClient {
|
|
|
209
212
|
const stream = this.client.durableTask(this._requestIterator(), {
|
|
210
213
|
signal: (_d = this._receiveAbort) === null || _d === void 0 ? void 0 : _d.signal,
|
|
211
214
|
});
|
|
215
|
+
let receivedResponse = false;
|
|
212
216
|
try {
|
|
213
217
|
for (var _e = true, stream_1 = (e_1 = void 0, __asyncValues(stream)), stream_1_1; stream_1_1 = yield stream_1.next(), _a = stream_1_1.done, !_a; _e = true) {
|
|
214
218
|
_c = stream_1_1.value;
|
|
215
219
|
_e = false;
|
|
216
220
|
const response = _c;
|
|
221
|
+
if (!receivedResponse) {
|
|
222
|
+
receivedResponse = true;
|
|
223
|
+
this._consecutiveFailures = 0;
|
|
224
|
+
}
|
|
217
225
|
this._handleResponse(response);
|
|
218
226
|
}
|
|
219
227
|
}
|
|
@@ -225,7 +233,12 @@ class DurableListenerClient {
|
|
|
225
233
|
finally { if (e_1) throw e_1.error; }
|
|
226
234
|
}
|
|
227
235
|
if (this._running) {
|
|
228
|
-
this.
|
|
236
|
+
this._consecutiveFailures += 1;
|
|
237
|
+
const message = `durable event listener disconnected (EOF), reconnecting in ${DEFAULT_RECONNECT_INTERVAL}ms...`;
|
|
238
|
+
const eofSeverity = (0, listener_severity_1.classifyListenerFailure)(undefined, this._consecutiveFailures);
|
|
239
|
+
if (eofSeverity !== 'silent') {
|
|
240
|
+
this.logger[eofSeverity](message);
|
|
241
|
+
}
|
|
229
242
|
this._failPendingAcks(new Error('durable stream disconnected'));
|
|
230
243
|
yield (0, sleep_1.default)(DEFAULT_RECONNECT_INTERVAL);
|
|
231
244
|
yield this._connect();
|
|
@@ -237,7 +250,12 @@ class DurableListenerClient {
|
|
|
237
250
|
this.logger.debug('durable event listener aborted');
|
|
238
251
|
return;
|
|
239
252
|
}
|
|
240
|
-
this.
|
|
253
|
+
this._consecutiveFailures += 1;
|
|
254
|
+
const message = `error in durable event listener: ${(0, hatchet_error_1.getErrorMessage)(e)}`;
|
|
255
|
+
const errSeverity = (0, listener_severity_1.classifyListenerFailure)(e, this._consecutiveFailures);
|
|
256
|
+
if (errSeverity !== 'silent') {
|
|
257
|
+
this.logger[errSeverity](message);
|
|
258
|
+
}
|
|
241
259
|
if (this._running) {
|
|
242
260
|
this._failPendingAcks(new Error(`durable stream error: ${(0, hatchet_error_1.getErrorMessage)(e)}`));
|
|
243
261
|
yield (0, sleep_1.default)(DEFAULT_RECONNECT_INTERVAL);
|
|
@@ -1958,6 +1958,8 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
1958
1958
|
limit?: number;
|
|
1959
1959
|
/** Filter by worker status */
|
|
1960
1960
|
statuses?: WorkerStatus[];
|
|
1961
|
+
/** Filter by worker labels */
|
|
1962
|
+
labels?: string[];
|
|
1961
1963
|
}, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkerList, any, {}>>;
|
|
1962
1964
|
/**
|
|
1963
1965
|
* @description Update a worker
|
|
@@ -281,6 +281,8 @@ export declare enum V1TaskEventType {
|
|
|
281
281
|
CREATED = "CREATED",
|
|
282
282
|
QUEUED = "QUEUED",
|
|
283
283
|
SKIPPED = "SKIPPED",
|
|
284
|
+
WAITING_FOR_BATCH = "WAITING_FOR_BATCH",
|
|
285
|
+
BATCH_FLUSHED = "BATCH_FLUSHED",
|
|
284
286
|
COULD_NOT_SEND_TO_WORKER = "COULD_NOT_SEND_TO_WORKER",
|
|
285
287
|
DURABLE_EVICTED = "DURABLE_EVICTED",
|
|
286
288
|
DURABLE_RESTORING = "DURABLE_RESTORING"
|
|
@@ -342,6 +342,8 @@ var V1TaskEventType;
|
|
|
342
342
|
V1TaskEventType["CREATED"] = "CREATED";
|
|
343
343
|
V1TaskEventType["QUEUED"] = "QUEUED";
|
|
344
344
|
V1TaskEventType["SKIPPED"] = "SKIPPED";
|
|
345
|
+
V1TaskEventType["WAITING_FOR_BATCH"] = "WAITING_FOR_BATCH";
|
|
346
|
+
V1TaskEventType["BATCH_FLUSHED"] = "BATCH_FLUSHED";
|
|
345
347
|
V1TaskEventType["COULD_NOT_SEND_TO_WORKER"] = "COULD_NOT_SEND_TO_WORKER";
|
|
346
348
|
V1TaskEventType["DURABLE_EVICTED"] = "DURABLE_EVICTED";
|
|
347
349
|
V1TaskEventType["DURABLE_RESTORING"] = "DURABLE_RESTORING";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.1",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@anthropic-ai/claude-agent-sdk": "^0.3.148",
|
|
60
60
|
"@grpc/grpc-js": "^1.14.3",
|
|
61
61
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
62
|
-
"@openai/agents": "0.13.
|
|
62
|
+
"@openai/agents": "0.13.5",
|
|
63
63
|
"@opentelemetry/api": "^1.9.0",
|
|
64
64
|
"@opentelemetry/core": "^2.0.0",
|
|
65
65
|
"@opentelemetry/exporter-trace-otlp-grpc": "^0.220.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@anthropic-ai/claude-agent-sdk": "^0.3.148",
|
|
92
92
|
"@grpc/grpc-js": "^1.14.3",
|
|
93
93
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
94
|
-
"@openai/agents": "0.13.
|
|
94
|
+
"@openai/agents": "0.13.5",
|
|
95
95
|
"@opentelemetry/api": "^1.9.0",
|
|
96
96
|
"@opentelemetry/core": "^2.0.0",
|
|
97
97
|
"@opentelemetry/exporter-trace-otlp-grpc": "^0.220.0",
|
|
@@ -15,6 +15,7 @@ export declare enum ActionType {
|
|
|
15
15
|
START_STEP_RUN = 0,
|
|
16
16
|
CANCEL_STEP_RUN = 1,
|
|
17
17
|
START_GET_GROUP_KEY = 2,
|
|
18
|
+
START_BATCH = 3,
|
|
18
19
|
UNRECOGNIZED = -1
|
|
19
20
|
}
|
|
20
21
|
export declare function actionTypeFromJSON(object: any): ActionType;
|
|
@@ -34,6 +35,7 @@ export declare enum StepActionEventType {
|
|
|
34
35
|
STEP_EVENT_TYPE_COMPLETED = 2,
|
|
35
36
|
STEP_EVENT_TYPE_FAILED = 3,
|
|
36
37
|
STEP_EVENT_TYPE_ACKNOWLEDGED = 4,
|
|
38
|
+
STEP_EVENT_TYPE_CANCELLED = 5,
|
|
37
39
|
UNRECOGNIZED = -1
|
|
38
40
|
}
|
|
39
41
|
export declare function stepActionEventTypeFromJSON(object: any): StepActionEventType;
|
|
@@ -182,6 +184,21 @@ export interface AssignedAction {
|
|
|
182
184
|
triggeringEventExternalId?: string | undefined;
|
|
183
185
|
/** (optional) the key of the event that triggered this workflow run (if any) */
|
|
184
186
|
triggeringEventKey?: string | undefined;
|
|
187
|
+
/** (optional) the batch identifier if this task is part of a batch */
|
|
188
|
+
batchId?: string | undefined;
|
|
189
|
+
/** (optional) the total number of tasks in the batch */
|
|
190
|
+
batchSize?: number | undefined;
|
|
191
|
+
/** (optional) the index of the task within the batch */
|
|
192
|
+
batchIndex?: number | undefined;
|
|
193
|
+
/** (optional) payload for starting a batch execution */
|
|
194
|
+
batchStartPayload?: BatchStartPayload | undefined;
|
|
195
|
+
/** (optional) the partition key used for batching */
|
|
196
|
+
batchKey?: string | undefined;
|
|
197
|
+
}
|
|
198
|
+
export interface BatchStartPayload {
|
|
199
|
+
triggerReason: string;
|
|
200
|
+
triggerTime: Date | undefined;
|
|
201
|
+
expectedSize: number;
|
|
185
202
|
}
|
|
186
203
|
export interface WorkerListenRequest {
|
|
187
204
|
/** the id of the worker */
|
|
@@ -234,6 +251,31 @@ export interface StepActionEvent {
|
|
|
234
251
|
/** a flag indicating if the task should _not_ be retried */
|
|
235
252
|
shouldNotRetry?: boolean | undefined;
|
|
236
253
|
}
|
|
254
|
+
export interface BatchActionEventItem {
|
|
255
|
+
/** the task external run id */
|
|
256
|
+
taskRunExternalId: string;
|
|
257
|
+
/** the event payload (e.g. serialized error for FAILED; unused for STARTED/CANCELLED) */
|
|
258
|
+
eventPayload: string;
|
|
259
|
+
/** the retry count (falls back to the task's current retry count if unset) */
|
|
260
|
+
retryCount?: number | undefined;
|
|
261
|
+
/** a flag indicating if the task should _not_ be retried (FAILED only) */
|
|
262
|
+
shouldNotRetry?: boolean | undefined;
|
|
263
|
+
}
|
|
264
|
+
export interface BatchActionEvent {
|
|
265
|
+
/** the id of the worker */
|
|
266
|
+
workerId: string;
|
|
267
|
+
/** the id of the job (shared across all items in the batch) */
|
|
268
|
+
jobId: string;
|
|
269
|
+
/** the action id (shared across all items in the batch) */
|
|
270
|
+
actionId: string;
|
|
271
|
+
/** (optional) the batch identifier, for observability */
|
|
272
|
+
batchId?: string | undefined;
|
|
273
|
+
eventTimestamp: Date | undefined;
|
|
274
|
+
/** the task event type -- applies uniformly to every item in this batch */
|
|
275
|
+
eventType: StepActionEventType;
|
|
276
|
+
/** the items in this batch */
|
|
277
|
+
items: BatchActionEventItem[];
|
|
278
|
+
}
|
|
237
279
|
export interface ActionEventResponse {
|
|
238
280
|
/** the tenant id */
|
|
239
281
|
tenantId: string;
|
|
@@ -341,11 +383,14 @@ export declare const UpsertWorkerLabelsRequest: MessageFns<UpsertWorkerLabelsReq
|
|
|
341
383
|
export declare const UpsertWorkerLabelsRequest_LabelsEntry: MessageFns<UpsertWorkerLabelsRequest_LabelsEntry>;
|
|
342
384
|
export declare const UpsertWorkerLabelsResponse: MessageFns<UpsertWorkerLabelsResponse>;
|
|
343
385
|
export declare const AssignedAction: MessageFns<AssignedAction>;
|
|
386
|
+
export declare const BatchStartPayload: MessageFns<BatchStartPayload>;
|
|
344
387
|
export declare const WorkerListenRequest: MessageFns<WorkerListenRequest>;
|
|
345
388
|
export declare const WorkerUnsubscribeRequest: MessageFns<WorkerUnsubscribeRequest>;
|
|
346
389
|
export declare const WorkerUnsubscribeResponse: MessageFns<WorkerUnsubscribeResponse>;
|
|
347
390
|
export declare const GroupKeyActionEvent: MessageFns<GroupKeyActionEvent>;
|
|
348
391
|
export declare const StepActionEvent: MessageFns<StepActionEvent>;
|
|
392
|
+
export declare const BatchActionEventItem: MessageFns<BatchActionEventItem>;
|
|
393
|
+
export declare const BatchActionEvent: MessageFns<BatchActionEvent>;
|
|
349
394
|
export declare const ActionEventResponse: MessageFns<ActionEventResponse>;
|
|
350
395
|
export declare const SubscribeToWorkflowEventsRequest: MessageFns<SubscribeToWorkflowEventsRequest>;
|
|
351
396
|
export declare const SubscribeToWorkflowRunsRequest: MessageFns<SubscribeToWorkflowRunsRequest>;
|
|
@@ -430,6 +475,18 @@ export declare const DispatcherDefinition: {
|
|
|
430
475
|
readonly responseStream: false;
|
|
431
476
|
readonly options: {};
|
|
432
477
|
};
|
|
478
|
+
/**
|
|
479
|
+
* SendBatchActionEvent reports a single lifecycle event (STARTED, FAILED, or CANCELLED)
|
|
480
|
+
* for every task in a batch in one call, instead of one SendStepActionEvent call per task.
|
|
481
|
+
*/
|
|
482
|
+
readonly sendBatchActionEvent: {
|
|
483
|
+
readonly name: "SendBatchActionEvent";
|
|
484
|
+
readonly requestType: typeof BatchActionEvent;
|
|
485
|
+
readonly requestStream: false;
|
|
486
|
+
readonly responseType: typeof ActionEventResponse;
|
|
487
|
+
readonly responseStream: false;
|
|
488
|
+
readonly options: {};
|
|
489
|
+
};
|
|
433
490
|
readonly sendGroupKeyActionEvent: {
|
|
434
491
|
readonly name: "SendGroupKeyActionEvent";
|
|
435
492
|
readonly requestType: typeof GroupKeyActionEvent;
|
|
@@ -514,6 +571,11 @@ export interface DispatcherServiceImplementation<CallContextExt = {}> {
|
|
|
514
571
|
subscribeToWorkflowEvents(request: SubscribeToWorkflowEventsRequest, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<WorkflowEvent>>;
|
|
515
572
|
subscribeToWorkflowRuns(request: AsyncIterable<SubscribeToWorkflowRunsRequest>, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<WorkflowRunEvent>>;
|
|
516
573
|
sendStepActionEvent(request: StepActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
|
|
574
|
+
/**
|
|
575
|
+
* SendBatchActionEvent reports a single lifecycle event (STARTED, FAILED, or CANCELLED)
|
|
576
|
+
* for every task in a batch in one call, instead of one SendStepActionEvent call per task.
|
|
577
|
+
*/
|
|
578
|
+
sendBatchActionEvent(request: BatchActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
|
|
517
579
|
sendGroupKeyActionEvent(request: GroupKeyActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
|
|
518
580
|
putOverridesData(request: OverridesData, context: CallContext & CallContextExt): Promise<DeepPartial<OverridesDataResponse>>;
|
|
519
581
|
unsubscribe(request: WorkerUnsubscribeRequest, context: CallContext & CallContextExt): Promise<DeepPartial<WorkerUnsubscribeResponse>>;
|
|
@@ -541,6 +603,11 @@ export interface DispatcherClient<CallOptionsExt = {}> {
|
|
|
541
603
|
subscribeToWorkflowEvents(request: DeepPartial<SubscribeToWorkflowEventsRequest>, options?: CallOptions & CallOptionsExt): AsyncIterable<WorkflowEvent>;
|
|
542
604
|
subscribeToWorkflowRuns(request: AsyncIterable<DeepPartial<SubscribeToWorkflowRunsRequest>>, options?: CallOptions & CallOptionsExt): AsyncIterable<WorkflowRunEvent>;
|
|
543
605
|
sendStepActionEvent(request: DeepPartial<StepActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
|
|
606
|
+
/**
|
|
607
|
+
* SendBatchActionEvent reports a single lifecycle event (STARTED, FAILED, or CANCELLED)
|
|
608
|
+
* for every task in a batch in one call, instead of one SendStepActionEvent call per task.
|
|
609
|
+
*/
|
|
610
|
+
sendBatchActionEvent(request: DeepPartial<BatchActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
|
|
544
611
|
sendGroupKeyActionEvent(request: DeepPartial<GroupKeyActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
|
|
545
612
|
putOverridesData(request: DeepPartial<OverridesData>, options?: CallOptions & CallOptionsExt): Promise<OverridesDataResponse>;
|
|
546
613
|
unsubscribe(request: DeepPartial<WorkerUnsubscribeRequest>, options?: CallOptions & CallOptionsExt): Promise<WorkerUnsubscribeResponse>;
|