@hatchet-dev/typescript-sdk 1.26.0 → 1.26.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.
@@ -111,7 +111,7 @@ class AdminClient {
111
111
  limit,
112
112
  duration,
113
113
  });
114
- }), this.logger);
114
+ }), this.logger, this.config.retrier);
115
115
  }
116
116
  catch (e) {
117
117
  throw (0, hatchet_error_1.toHatchetError)(e);
@@ -11,6 +11,7 @@ export type ActionKey = `${string}/${number}`;
11
11
  export type Action = AssignedAction & {
12
12
  readonly key: ActionKey;
13
13
  };
14
+ export declare function workflowNameFromAction(action: Pick<AssignedAction, 'actionId' | 'jobName'>): string;
14
15
  export declare function createAction(assignedAction: AssignedAction): Action;
15
16
  export declare class ActionListener {
16
17
  config: ClientConfig;
@@ -66,6 +66,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
66
66
  };
67
67
  Object.defineProperty(exports, "__esModule", { value: true });
68
68
  exports.ActionListener = void 0;
69
+ exports.workflowNameFromAction = workflowNameFromAction;
69
70
  exports.createAction = createAction;
70
71
  const nice_grpc_1 = require("nice-grpc");
71
72
  const grpc_error_1 = require("../../util/grpc-error");
@@ -80,6 +81,10 @@ var ListenStrategy;
80
81
  ListenStrategy[ListenStrategy["LISTEN_STRATEGY_V1"] = 1] = "LISTEN_STRATEGY_V1";
81
82
  ListenStrategy[ListenStrategy["LISTEN_STRATEGY_V2"] = 2] = "LISTEN_STRATEGY_V2";
82
83
  })(ListenStrategy || (ListenStrategy = {}));
84
+ function workflowNameFromAction(action) {
85
+ const separatorIndex = action.actionId.lastIndexOf(':');
86
+ return separatorIndex === -1 ? action.jobName : action.actionId.substring(0, separatorIndex);
87
+ }
83
88
  function createAction(assignedAction) {
84
89
  const action = assignedAction;
85
90
  Object.defineProperty(action, 'key', {
@@ -54,14 +54,14 @@ class EventClient {
54
54
  priority: options.priority,
55
55
  scope: options.scope,
56
56
  };
57
- try {
58
- const e = this.retrier(() => __awaiter(this, void 0, void 0, function* () { return this.client.push(req); }), this.logger);
57
+ return this.retrier(() => __awaiter(this, void 0, void 0, function* () { return this.client.push(req); }), this.logger, this.config.retrier)
58
+ .then((result) => {
59
59
  this.logger.info(`Event pushed: ${namespacedType}`);
60
- return e;
61
- }
62
- catch (e) {
60
+ return result;
61
+ })
62
+ .catch((e) => {
63
63
  throw (0, hatchet_error_1.toHatchetError)(e);
64
- }
64
+ });
65
65
  }
66
66
  /**
67
67
  * @important This method is instrumented by HatchetInstrumentor._patchBulkPushEvent.
@@ -85,14 +85,14 @@ class EventClient {
85
85
  const req = {
86
86
  events,
87
87
  };
88
- try {
89
- const res = this.retrier(() => __awaiter(this, void 0, void 0, function* () { return this.client.bulkPush(req); }), this.logger);
88
+ return this.retrier(() => __awaiter(this, void 0, void 0, function* () { return this.client.bulkPush(req); }), this.logger, this.config.retrier)
89
+ .then((result) => {
90
90
  this.logger.info(`Bulk events pushed for type: ${namespacedType}`);
91
- return res;
92
- }
93
- catch (e) {
91
+ return result;
92
+ })
93
+ .catch((e) => {
94
94
  throw (0, hatchet_error_1.toHatchetError)(e);
95
- }
95
+ });
96
96
  }
97
97
  putLog(taskRunExternalId, log, level, taskRetryCount, metadata) {
98
98
  return __awaiter(this, void 0, void 0, function* () {
@@ -2,6 +2,12 @@ import { ChannelCredentials } from 'nice-grpc';
2
2
  import { z } from 'zod/v4';
3
3
  import type { Context } from '../../v1/client/worker/context';
4
4
  import { Logger, LogLevel } from '../../util/logger';
5
+ export declare const RetrierConfigSchema: z.ZodObject<{
6
+ maxAttempts: z.ZodOptional<z.ZodNumber>;
7
+ initialInterval: z.ZodOptional<z.ZodNumber>;
8
+ maxJitter: z.ZodOptional<z.ZodNumber>;
9
+ }, z.core.$strip>;
10
+ export type RetrierConfig = z.infer<typeof RetrierConfigSchema>;
5
11
  declare const ClientTLSConfigSchema: z.ZodObject<{
6
12
  tls_strategy: z.ZodOptional<z.ZodEnum<{
7
13
  tls: "tls";
@@ -60,6 +66,11 @@ export declare const ClientConfigSchema: z.ZodObject<{
60
66
  cancellation_warning_threshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
61
67
  grpc_max_recv_message_length: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
62
68
  grpc_max_send_message_length: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
69
+ retrier: z.ZodOptional<z.ZodObject<{
70
+ maxAttempts: z.ZodOptional<z.ZodNumber>;
71
+ initialInterval: z.ZodOptional<z.ZodNumber>;
72
+ maxJitter: z.ZodOptional<z.ZodNumber>;
73
+ }, z.core.$strip>>;
63
74
  }, z.core.$strip>;
64
75
  export type LogConstructor = (context: string, logLevel?: LogLevel) => Logger;
65
76
  /**
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientConfigSchema = exports.OpenTelemetryConfigSchema = void 0;
3
+ exports.ClientConfigSchema = exports.OpenTelemetryConfigSchema = exports.RetrierConfigSchema = void 0;
4
4
  const v4_1 = require("zod/v4");
5
+ exports.RetrierConfigSchema = v4_1.z.object({
6
+ maxAttempts: v4_1.z.number().int().positive().optional(),
7
+ initialInterval: v4_1.z.number().positive().optional(),
8
+ maxJitter: v4_1.z.number().nonnegative().optional(),
9
+ });
5
10
  const ClientTLSConfigSchema = v4_1.z.object({
6
11
  tls_strategy: v4_1.z.enum(['tls', 'mtls', 'none']).optional(),
7
12
  cert_file: v4_1.z.string().optional(),
@@ -65,4 +70,5 @@ exports.ClientConfigSchema = v4_1.z.object({
65
70
  .positive()
66
71
  .optional()
67
72
  .default(4 * 1024 * 1024),
73
+ retrier: exports.RetrierConfigSchema.optional(),
68
74
  });
@@ -1,4 +1,4 @@
1
- import { APIErrors, APIMeta, AcceptInviteRequest, BulkCreateEventRequest, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, Events, FeatureFlagEvaluationResult, FeatureFlagId, ListAPIMetaIntegration, ListAPITokensResponse, ListSNSIntegrations, ListSlackWebhooks, OtelSpanList, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, SNSIntegration, ScheduleWorkflowRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsBulkDeleteRequest, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateRequest, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, StepRun, StepRunArchiveList, StepRunEventList, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateScheduledWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1BranchDurableTaskRequest, V1BranchDurableTaskResponse, V1CELDebugRequest, V1CELDebugResponse, V1CancelTaskRequest, V1CancelledTasks, V1CreateFilterRequest, V1CreateWebhookRequest, V1DagChildren, V1Event, V1EventList, V1Filter, V1FilterList, V1LogLineLevel, V1LogLineList, V1LogLineOrderByDirection, V1LogsPointMetrics, V1ReplayTaskRequest, V1ReplayedTasks, V1RestoreTaskResponse, V1RunningFilter, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookResponse, V1WebhookSourceName, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, WebhookWorkerCreateRequest, WebhookWorkerCreated, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunShape, WorkflowRunStatus, WorkflowRunStatusList, WorkflowRunsCancelRequest, WorkflowRunsMetrics, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
1
+ import { APIErrors, APIMeta, AcceptInviteRequest, BulkCreateEventRequest, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, Events, FeatureFlagEvaluationResult, FeatureFlagId, ListAPIMetaIntegration, ListAPITokensResponse, ListSNSIntegrations, ListSlackWebhooks, OtelSpanList, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, SNSIntegration, ScheduleWorkflowRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsBulkDeleteRequest, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateRequest, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, StepRun, StepRunArchiveList, StepRunEventList, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerRunResult, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateScheduledWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1AdditionalMetadataOperator, V1BranchDurableTaskRequest, V1BranchDurableTaskResponse, V1CELDebugRequest, V1CELDebugResponse, V1CancelTaskRequest, V1CancelledTasks, V1CreateFilterRequest, V1CreateWebhookRequest, V1DagChildren, V1DurableEventLogList, V1Event, V1EventList, V1Filter, V1FilterList, V1LogLineLevel, V1LogLineList, V1LogLineOrderByDirection, V1LogsPointMetrics, V1ReplayTaskRequest, V1ReplayedTasks, V1RestoreTaskResponse, V1RunningFilter, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookResponse, V1WebhookSourceName, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, WebhookWorkerCreateRequest, WebhookWorkerCreated, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, WorkerStatus, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunShape, WorkflowRunStatus, WorkflowRunStatusList, WorkflowRunsCancelRequest, WorkflowRunsMetrics, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
2
2
  import { HttpClient, RequestParams } from './http-client';
3
3
  export declare class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
4
4
  /**
@@ -224,6 +224,8 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
224
224
  until?: string;
225
225
  /** Additional metadata k-v pairs to filter by */
226
226
  additional_metadata?: string[];
227
+ /** How to combine multiple additional_metadata pairs. OR matches runs containing any pair, AND matches runs containing all pairs. Defaults to OR. */
228
+ additional_metadata_operator?: V1AdditionalMetadataOperator;
227
229
  /** The workflow ids to find runs for */
228
230
  workflow_ids?: string[];
229
231
  /**
@@ -253,6 +255,8 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
253
255
  include_payloads?: boolean;
254
256
  /** Filter within the RUNNING status bucket. ALL returns both on-worker and evicted tasks, ON_WORKER returns only tasks running on a worker, EVICTED returns only evicted tasks. Defaults to ALL. */
255
257
  running_filter?: V1RunningFilter;
258
+ /** The idempotency key(s) to filter for */
259
+ idempotency_keys?: string[];
256
260
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1TaskSummaryList, any, {}>>;
257
261
  /**
258
262
  * @description Lists displayable names of workflow runs for a tenant
@@ -316,6 +320,27 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
316
320
  * @secure
317
321
  */
318
322
  v1DurableTaskBranch: (tenant: string, data: V1BranchDurableTaskRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1BranchDurableTaskResponse, any, {}>>;
323
+ /**
324
+ * @description Lists all event log entries for a durable task.
325
+ *
326
+ * @tags Durable Tasks
327
+ * @name V1DurableTaskEventLogList
328
+ * @summary List durable event log
329
+ * @request GET:/api/v1/stable/tenants/{tenant}/durable-tasks/{durable-task}
330
+ * @secure
331
+ */
332
+ v1DurableTaskEventLogList: (tenant: string, durableTask: string, query?: {
333
+ /**
334
+ * The number of event log entries to skip
335
+ * @format int64
336
+ */
337
+ offset?: number;
338
+ /**
339
+ * The number of event log entries to limit by
340
+ * @format int64
341
+ */
342
+ limit?: number;
343
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1DurableEventLogList, any, {}>>;
319
344
  /**
320
345
  * @description Get a workflow run and its metadata to display on the "detail" page
321
346
  *
@@ -1216,6 +1241,19 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
1216
1241
  /** The order direction */
1217
1242
  orderByDirection?: RateLimitOrderByDirection;
1218
1243
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<RateLimitList, any, {}>>;
1244
+ /**
1245
+ * @description Delete a rate limit for a tenant.
1246
+ *
1247
+ * @tags Rate Limits
1248
+ * @name RateLimitDelete
1249
+ * @summary Delete rate limit
1250
+ * @request DELETE:/api/v1/tenants/{tenant}/rate-limits
1251
+ * @secure
1252
+ */
1253
+ rateLimitDelete: (tenant: string, query: {
1254
+ /** The limit key */
1255
+ key: string;
1256
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any, {}>>;
1219
1257
  /**
1220
1258
  * @description Gets a list of tenant members
1221
1259
  *
@@ -1404,6 +1442,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
1404
1442
  * @secure
1405
1443
  */
1406
1444
  workflowScheduledUpdate: (tenant: string, scheduledWorkflowRun: string, data: UpdateScheduledWorkflowRunRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<ScheduledWorkflows, any, {}>>;
1445
+ /**
1446
+ * @description Trigger a scheduled workflow run immediately for a tenant
1447
+ *
1448
+ * @tags Workflow
1449
+ * @name WorkflowScheduledTrigger
1450
+ * @summary Trigger scheduled workflow run
1451
+ * @request POST:/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}
1452
+ * @secure
1453
+ */
1454
+ workflowScheduledTrigger: (tenant: string, scheduledWorkflowRun: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<TriggerRunResult, any, {}>>;
1407
1455
  /**
1408
1456
  * @description Bulk delete scheduled workflow runs for a tenant
1409
1457
  *
@@ -1505,6 +1553,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
1505
1553
  * @secure
1506
1554
  */
1507
1555
  workflowCronUpdate: (tenant: string, cronWorkflow: string, data: UpdateCronWorkflowTriggerRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any, {}>>;
1556
+ /**
1557
+ * @description Trigger a cron workflow immediately for a tenant
1558
+ *
1559
+ * @tags Workflow
1560
+ * @name WorkflowCronTrigger
1561
+ * @summary Trigger cron job workflow run immediately
1562
+ * @request POST:/api/v1/tenants/{tenant}/workflows/crons/{cron-workflow}
1563
+ * @secure
1564
+ */
1565
+ workflowCronTrigger: (tenant: string, cronWorkflow: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<TriggerRunResult, any, {}>>;
1508
1566
  /**
1509
1567
  * @description Cancel a batch of workflow runs
1510
1568
  *
@@ -1887,7 +1945,20 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
1887
1945
  * @request GET:/api/v1/tenants/{tenant}/worker
1888
1946
  * @secure
1889
1947
  */
1890
- workerList: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkerList, any, {}>>;
1948
+ workerList: (tenant: string, query?: {
1949
+ /**
1950
+ * The number to skip
1951
+ * @format int64
1952
+ */
1953
+ offset?: number;
1954
+ /**
1955
+ * The number to limit by
1956
+ * @format int64
1957
+ */
1958
+ limit?: number;
1959
+ /** Filter by worker status */
1960
+ statuses?: WorkerStatus[];
1961
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkerList, any, {}>>;
1891
1962
  /**
1892
1963
  * @description Update a worker
1893
1964
  *
@@ -1993,7 +2064,10 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
1993
2064
  * @request GET:/api/v1/tenants/{tenant}/task-stats
1994
2065
  * @secure
1995
2066
  */
1996
- tenantGetTaskStats: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<TaskStats, any, {}>>;
2067
+ tenantGetTaskStats: (tenant: string, query?: {
2068
+ /** Task names that must appear in the response. Missing tasks are zero-filled so KEDA's metrics-api JSONPath always resolves. */
2069
+ taskNames?: string[];
2070
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<TaskStats, any, {}>>;
1997
2071
  /**
1998
2072
  * @description Evaluate a feature flag for a tenant
1999
2073
  *
@@ -156,6 +156,16 @@ class Api extends http_client_1.HttpClient {
156
156
  * @secure
157
157
  */
158
158
  this.v1DurableTaskBranch = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/durable-tasks/branch`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
159
+ /**
160
+ * @description Lists all event log entries for a durable task.
161
+ *
162
+ * @tags Durable Tasks
163
+ * @name V1DurableTaskEventLogList
164
+ * @summary List durable event log
165
+ * @request GET:/api/v1/stable/tenants/{tenant}/durable-tasks/{durable-task}
166
+ * @secure
167
+ */
168
+ this.v1DurableTaskEventLogList = (tenant, durableTask, query, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/durable-tasks/${durableTask}`, method: 'GET', query: query, secure: true, format: 'json' }, params));
159
169
  /**
160
170
  * @description Get a workflow run and its metadata to display on the "detail" page
161
171
  *
@@ -859,6 +869,16 @@ class Api extends http_client_1.HttpClient {
859
869
  * @secure
860
870
  */
861
871
  this.rateLimitList = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/rate-limits`, method: 'GET', query: query, secure: true, format: 'json' }, params));
872
+ /**
873
+ * @description Delete a rate limit for a tenant.
874
+ *
875
+ * @tags Rate Limits
876
+ * @name RateLimitDelete
877
+ * @summary Delete rate limit
878
+ * @request DELETE:/api/v1/tenants/{tenant}/rate-limits
879
+ * @secure
880
+ */
881
+ this.rateLimitDelete = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/rate-limits`, method: 'DELETE', query: query, secure: true }, params));
862
882
  /**
863
883
  * @description Gets a list of tenant members
864
884
  *
@@ -989,6 +1009,16 @@ class Api extends http_client_1.HttpClient {
989
1009
  * @secure
990
1010
  */
991
1011
  this.workflowScheduledUpdate = (tenant, scheduledWorkflowRun, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/scheduled/${scheduledWorkflowRun}`, method: 'PATCH', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
1012
+ /**
1013
+ * @description Trigger a scheduled workflow run immediately for a tenant
1014
+ *
1015
+ * @tags Workflow
1016
+ * @name WorkflowScheduledTrigger
1017
+ * @summary Trigger scheduled workflow run
1018
+ * @request POST:/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}
1019
+ * @secure
1020
+ */
1021
+ this.workflowScheduledTrigger = (tenant, scheduledWorkflowRun, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/scheduled/${scheduledWorkflowRun}`, method: 'POST', secure: true, format: 'json' }, params));
992
1022
  /**
993
1023
  * @description Bulk delete scheduled workflow runs for a tenant
994
1024
  *
@@ -1059,6 +1089,16 @@ class Api extends http_client_1.HttpClient {
1059
1089
  * @secure
1060
1090
  */
1061
1091
  this.workflowCronUpdate = (tenant, cronWorkflow, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/crons/${cronWorkflow}`, method: 'PATCH', body: data, secure: true, type: http_client_1.ContentType.Json }, params));
1092
+ /**
1093
+ * @description Trigger a cron workflow immediately for a tenant
1094
+ *
1095
+ * @tags Workflow
1096
+ * @name WorkflowCronTrigger
1097
+ * @summary Trigger cron job workflow run immediately
1098
+ * @request POST:/api/v1/tenants/{tenant}/workflows/crons/{cron-workflow}
1099
+ * @secure
1100
+ */
1101
+ this.workflowCronTrigger = (tenant, cronWorkflow, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/crons/${cronWorkflow}`, method: 'POST', secure: true, format: 'json' }, params));
1062
1102
  /**
1063
1103
  * @description Cancel a batch of workflow runs
1064
1104
  *
@@ -1268,7 +1308,7 @@ class Api extends http_client_1.HttpClient {
1268
1308
  * @request GET:/api/v1/tenants/{tenant}/worker
1269
1309
  * @secure
1270
1310
  */
1271
- this.workerList = (tenant, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/worker`, method: 'GET', secure: true, format: 'json' }, params));
1311
+ this.workerList = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/worker`, method: 'GET', query: query, secure: true, format: 'json' }, params));
1272
1312
  /**
1273
1313
  * @description Update a worker
1274
1314
  *
@@ -1371,7 +1411,7 @@ class Api extends http_client_1.HttpClient {
1371
1411
  * @request GET:/api/v1/tenants/{tenant}/task-stats
1372
1412
  * @secure
1373
1413
  */
1374
- this.tenantGetTaskStats = (tenant, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/task-stats`, method: 'GET', secure: true, format: 'json' }, params));
1414
+ this.tenantGetTaskStats = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/task-stats`, method: 'GET', query: query, secure: true, format: 'json' }, params));
1375
1415
  /**
1376
1416
  * @description Evaluate a feature flag for a tenant
1377
1417
  *
@@ -23,7 +23,9 @@ export declare enum PullRequestState {
23
23
  Closed = "closed"
24
24
  }
25
25
  export declare enum FeatureFlagId {
26
- TenantLogWorkflowFilterEnabled = "tenant-log-workflow-filter-enabled"
26
+ TenantLogWorkflowFilterEnabled = "tenant-log-workflow-filter-enabled",
27
+ TraceMinimapEnabled = "trace-minimap-enabled",
28
+ OrganizationSsoEnabled = "organization-sso-enabled"
27
29
  }
28
30
  export declare enum WebhookWorkerRequestMethod {
29
31
  GET = "GET",
@@ -41,6 +43,11 @@ export declare enum WorkerType {
41
43
  MANAGED = "MANAGED",
42
44
  WEBHOOK = "WEBHOOK"
43
45
  }
46
+ export declare enum WorkerStatus {
47
+ ACTIVE = "ACTIVE",
48
+ INACTIVE = "INACTIVE",
49
+ PAUSED = "PAUSED"
50
+ }
44
51
  export declare enum WorkflowRunOrderByField {
45
52
  CreatedAt = "createdAt",
46
53
  StartedAt = "startedAt",
@@ -224,11 +231,25 @@ export declare enum OtelSpanKind {
224
231
  PRODUCER = "PRODUCER",
225
232
  CONSUMER = "CONSUMER"
226
233
  }
234
+ export declare enum V1DurableWaitConditionKind {
235
+ SLEEP = "SLEEP",
236
+ USER_EVENT = "USER_EVENT",
237
+ CHILD_WORKFLOW = "CHILD_WORKFLOW"
238
+ }
239
+ export declare enum V1DurableEventLogKind {
240
+ RUN = "RUN",
241
+ WAIT_FOR = "WAIT_FOR",
242
+ MEMO = "MEMO"
243
+ }
227
244
  export declare enum V1RunningFilter {
228
245
  ALL = "ALL",
229
246
  EVICTED = "EVICTED",
230
247
  ON_WORKER = "ON_WORKER"
231
248
  }
249
+ export declare enum V1AdditionalMetadataOperator {
250
+ OR = "OR",
251
+ AND = "AND"
252
+ }
232
253
  export declare enum V1LogLineOrderByDirection {
233
254
  ASC = "ASC",
234
255
  DESC = "DESC"
@@ -317,6 +338,8 @@ export interface V1TaskSummary {
317
338
  displayName: string;
318
339
  /** The duration of the task run, in milliseconds. */
319
340
  duration?: number;
341
+ /** Whether this task was created as a durable task. */
342
+ isDurable?: boolean;
320
343
  /** The error message of the task run (for the latest run) */
321
344
  errorMessage?: string;
322
345
  /**
@@ -388,6 +411,8 @@ export interface V1TaskSummary {
388
411
  * @format uuid
389
412
  */
390
413
  parentTaskExternalId?: string;
414
+ /** The idempotency key that was claimed by the task run */
415
+ idempotencyKey?: string;
391
416
  }
392
417
  export interface APIError {
393
418
  /**
@@ -557,6 +582,8 @@ export interface V1TriggerWorkflowRunRequest {
557
582
  additionalMetadata?: object;
558
583
  /** The priority of the workflow run. */
559
584
  priority?: number;
585
+ /** A boolean flag indicating whether to only return the id of the created run. */
586
+ return_only_id?: boolean;
560
587
  }
561
588
  export interface V1WorkflowRun {
562
589
  metadata: APIResourceMeta;
@@ -673,6 +700,60 @@ export interface V1BranchDurableTaskResponse {
673
700
  */
674
701
  branchId: number;
675
702
  }
703
+ export interface V1DurableWaitCondition {
704
+ kind: V1DurableWaitConditionKind;
705
+ /** @format int64 */
706
+ sleepDurationMs?: number;
707
+ eventKey?: string;
708
+ workflowName?: string;
709
+ }
710
+ export interface V1WaitItem {
711
+ kind?: V1DurableWaitConditionKind;
712
+ /** @format int64 */
713
+ sleepDurationMs?: number;
714
+ eventKey?: string;
715
+ workflowName?: string;
716
+ or?: V1DurableWaitCondition[];
717
+ }
718
+ export type V1WaitData = V1WaitItem[];
719
+ export interface V1DurableEventLogEntry {
720
+ /**
721
+ * The monotonically increasing node id in the event log.
722
+ * @format int64
723
+ */
724
+ nodeId: number;
725
+ /**
726
+ * The branch id when this entry was first seen.
727
+ * @format int64
728
+ */
729
+ branchId: number;
730
+ kind: V1DurableEventLogKind;
731
+ waitData?: V1WaitData;
732
+ /** Whether this entry has been satisfied. */
733
+ isSatisfied: boolean;
734
+ /**
735
+ * When this entry was satisfied, if it has been satisfied.
736
+ * @format date-time
737
+ */
738
+ satisfiedAt?: string;
739
+ /**
740
+ * When this entry was inserted.
741
+ * @format date-time
742
+ */
743
+ insertedAt: string;
744
+ /** A user-provided message or label, sent when establishing a durable wait. */
745
+ userMessage?: string;
746
+ /**
747
+ * The external id of the durable task this event log entry is associated with.
748
+ * @format uuid
749
+ * @minLength 36
750
+ * @maxLength 36
751
+ */
752
+ taskExternalId: string;
753
+ /** The display name of the durable task this event log entry is associated with. */
754
+ taskDisplayName: string;
755
+ }
756
+ export type V1DurableEventLogList = V1DurableEventLogEntry[];
676
757
  export interface OtelSpan {
677
758
  traceId: string;
678
759
  spanId: string;
@@ -803,6 +884,10 @@ export interface Tenant {
803
884
  version: TenantVersion;
804
885
  /** The environment type of the tenant. */
805
886
  environment?: TenantEnvironment;
887
+ /** The server URL for the tenant (includes scheme) */
888
+ serverUrl?: string;
889
+ /** Control-plane shard region for the tenant (e.g. aws:us-west-2). */
890
+ region?: string;
806
891
  }
807
892
  export interface V1EventWorkflowRunSummary {
808
893
  /**
@@ -942,6 +1027,8 @@ export interface V1Webhook {
942
1027
  staticPayload?: object;
943
1028
  /** The type of authentication to use for the webhook */
944
1029
  authType: V1WebhookAuthType;
1030
+ /** Whether to return the triggered event as the response payload when this webhook is triggered */
1031
+ returnEventAsResponsePayload?: boolean;
945
1032
  }
946
1033
  export interface V1WebhookList {
947
1034
  pagination?: PaginationResponse;
@@ -958,6 +1045,8 @@ export interface V1CreateWebhookRequestBase {
958
1045
  scopeExpression?: string;
959
1046
  /** The static payload to use for the webhook. This is used to send a static payload with the webhook. */
960
1047
  staticPayload?: object;
1048
+ /** Whether to return the triggered event as the response payload when this webhook is triggered */
1049
+ returnEventAsResponsePayload?: boolean;
961
1050
  }
962
1051
  export interface V1WebhookBasicAuth {
963
1052
  /** The username for basic auth */
@@ -1010,6 +1099,8 @@ export interface V1UpdateWebhookRequest {
1010
1099
  scopeExpression?: string;
1011
1100
  /** The static payload to use for the webhook. This is used to send a static payload with the webhook. */
1012
1101
  staticPayload?: object;
1102
+ /** Whether to return the triggered event as the response payload when this webhook is triggered */
1103
+ returnEventAsResponsePayload?: boolean;
1013
1104
  }
1014
1105
  export interface V1CELDebugRequest {
1015
1106
  /** The CEL expression to evaluate */
@@ -1076,6 +1167,26 @@ export interface APIMeta {
1076
1167
  * @example true
1077
1168
  */
1078
1169
  allowChangePassword?: boolean;
1170
+ /**
1171
+ * whether or not observability (trace collection) is enabled on this instance
1172
+ * @example false
1173
+ */
1174
+ observabilityEnabled?: boolean;
1175
+ /**
1176
+ * whether or not a Prometheus federation server is configured (SERVER_PROMETHEUS_SERVER_URL) on this instance
1177
+ * @example false
1178
+ */
1179
+ prometheusServerEnabled?: boolean;
1180
+ /**
1181
+ * whether or not authentication is disabled (authdisabled build) on this instance
1182
+ * @example false
1183
+ */
1184
+ authDisabled?: boolean;
1185
+ /**
1186
+ * the embedded worker API token, only set on authdisabled builds
1187
+ * @example "eyJhbGciOiJFUzI1NiIs..."
1188
+ */
1189
+ authDisabledToken?: string;
1079
1190
  }
1080
1191
  export interface APIMetaIntegration {
1081
1192
  /**
@@ -1225,6 +1336,8 @@ export interface TenantMember {
1225
1336
  role: TenantMemberRole;
1226
1337
  /** The tenant associated with this tenant member. */
1227
1338
  tenant?: Tenant;
1339
+ /** Whether this membership was explicitly granted (as opposed to synced via user-group tags). Only explicit members can have their role edited or be removed. */
1340
+ manually_added?: boolean;
1228
1341
  }
1229
1342
  export interface UserTenantMembershipsList {
1230
1343
  pagination?: PaginationResponse;
@@ -1595,6 +1708,15 @@ export interface ScheduledWorkflowsList {
1595
1708
  rows?: ScheduledWorkflows[];
1596
1709
  pagination?: PaginationResponse;
1597
1710
  }
1711
+ export interface TriggerRunResult {
1712
+ /**
1713
+ * The external ID of the triggered workflow run
1714
+ * @format uuid
1715
+ * @minLength 36
1716
+ * @maxLength 36
1717
+ */
1718
+ externalId: string;
1719
+ }
1598
1720
  export interface UpdateScheduledWorkflowRunRequest {
1599
1721
  /** @format date-time */
1600
1722
  triggerAt: string;
@@ -2087,7 +2209,7 @@ export interface Worker {
2087
2209
  /** The recent step runs for the worker. */
2088
2210
  recentStepRuns?: RecentStepRuns[];
2089
2211
  /** The status of the worker. */
2090
- status?: 'ACTIVE' | 'INACTIVE' | 'PAUSED';
2212
+ status?: WorkerStatus;
2091
2213
  /** Slot availability and limits for this worker (slot_type -> { available, limit }). */
2092
2214
  slotConfig?: Record<string, WorkerSlotConfig>;
2093
2215
  /**
@@ -2175,6 +2297,8 @@ export interface TaskStatusStat {
2175
2297
  concurrency?: ConcurrencyStat[];
2176
2298
  /** @format date-time */
2177
2299
  oldest?: string;
2300
+ /** @format date-time */
2301
+ oldestExcludingRetries?: string;
2178
2302
  }
2179
2303
  export interface TaskStat {
2180
2304
  queued?: TaskStatusStat;
@@ -11,7 +11,7 @@
11
11
  * ---------------------------------------------------------------
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.V1TaskStatus = exports.V1WorkflowType = exports.V1TaskEventType = exports.V1LogLineLevel = exports.V1LogLineOrderByDirection = exports.V1RunningFilter = exports.OtelSpanKind = exports.OtelStatusCode = exports.TenantVersion = exports.TenantEnvironment = exports.V1WebhookSourceName = exports.V1WebhookAuthType = exports.V1WebhookHMACAlgorithm = exports.V1WebhookHMACEncoding = exports.V1CELDebugResponseStatus = exports.TenantResource = exports.TenantMemberRole = exports.WorkflowRunStatus = exports.EventOrderByField = exports.EventOrderByDirection = exports.RateLimitOrderByField = exports.RateLimitOrderByDirection = exports.ScheduledWorkflowsMethod = exports.ScheduledWorkflowsOrderByField = exports.WorkflowRunOrderByDirection = exports.ScheduledRunStatus = exports.CronWorkflowsMethod = exports.CronWorkflowsOrderByField = exports.ConcurrencyLimitStrategy = exports.ConcurrencyScope = exports.StepRunStatus = exports.JobRunStatus = exports.StepRunEventReason = exports.StepRunEventSeverity = exports.WorkflowKind = exports.WorkflowRunOrderByField = exports.WorkerType = exports.WorkerRuntimeSDKs = exports.WebhookWorkerRequestMethod = exports.FeatureFlagId = exports.PullRequestState = exports.LogLineLevel = exports.LogLineOrderByField = exports.LogLineOrderByDirection = exports.V1TaskRunStatus = void 0;
14
+ exports.V1TaskStatus = exports.V1WorkflowType = exports.V1TaskEventType = exports.V1LogLineLevel = exports.V1LogLineOrderByDirection = exports.V1AdditionalMetadataOperator = exports.V1RunningFilter = exports.V1DurableEventLogKind = exports.V1DurableWaitConditionKind = exports.OtelSpanKind = exports.OtelStatusCode = exports.TenantVersion = exports.TenantEnvironment = exports.V1WebhookSourceName = exports.V1WebhookAuthType = exports.V1WebhookHMACAlgorithm = exports.V1WebhookHMACEncoding = exports.V1CELDebugResponseStatus = exports.TenantResource = exports.TenantMemberRole = exports.WorkflowRunStatus = exports.EventOrderByField = exports.EventOrderByDirection = exports.RateLimitOrderByField = exports.RateLimitOrderByDirection = exports.ScheduledWorkflowsMethod = exports.ScheduledWorkflowsOrderByField = exports.WorkflowRunOrderByDirection = exports.ScheduledRunStatus = exports.CronWorkflowsMethod = exports.CronWorkflowsOrderByField = exports.ConcurrencyLimitStrategy = exports.ConcurrencyScope = exports.StepRunStatus = exports.JobRunStatus = exports.StepRunEventReason = exports.StepRunEventSeverity = exports.WorkflowKind = exports.WorkflowRunOrderByField = exports.WorkerStatus = exports.WorkerType = exports.WorkerRuntimeSDKs = exports.WebhookWorkerRequestMethod = exports.FeatureFlagId = exports.PullRequestState = exports.LogLineLevel = exports.LogLineOrderByField = exports.LogLineOrderByDirection = exports.V1TaskRunStatus = void 0;
15
15
  var V1TaskRunStatus;
16
16
  (function (V1TaskRunStatus) {
17
17
  V1TaskRunStatus["PENDING"] = "PENDING";
@@ -44,6 +44,8 @@ var PullRequestState;
44
44
  var FeatureFlagId;
45
45
  (function (FeatureFlagId) {
46
46
  FeatureFlagId["TenantLogWorkflowFilterEnabled"] = "tenant-log-workflow-filter-enabled";
47
+ FeatureFlagId["TraceMinimapEnabled"] = "trace-minimap-enabled";
48
+ FeatureFlagId["OrganizationSsoEnabled"] = "organization-sso-enabled";
47
49
  })(FeatureFlagId || (exports.FeatureFlagId = FeatureFlagId = {}));
48
50
  var WebhookWorkerRequestMethod;
49
51
  (function (WebhookWorkerRequestMethod) {
@@ -64,6 +66,12 @@ var WorkerType;
64
66
  WorkerType["MANAGED"] = "MANAGED";
65
67
  WorkerType["WEBHOOK"] = "WEBHOOK";
66
68
  })(WorkerType || (exports.WorkerType = WorkerType = {}));
69
+ var WorkerStatus;
70
+ (function (WorkerStatus) {
71
+ WorkerStatus["ACTIVE"] = "ACTIVE";
72
+ WorkerStatus["INACTIVE"] = "INACTIVE";
73
+ WorkerStatus["PAUSED"] = "PAUSED";
74
+ })(WorkerStatus || (exports.WorkerStatus = WorkerStatus = {}));
67
75
  var WorkflowRunOrderByField;
68
76
  (function (WorkflowRunOrderByField) {
69
77
  WorkflowRunOrderByField["CreatedAt"] = "createdAt";
@@ -277,12 +285,29 @@ var OtelSpanKind;
277
285
  OtelSpanKind["PRODUCER"] = "PRODUCER";
278
286
  OtelSpanKind["CONSUMER"] = "CONSUMER";
279
287
  })(OtelSpanKind || (exports.OtelSpanKind = OtelSpanKind = {}));
288
+ var V1DurableWaitConditionKind;
289
+ (function (V1DurableWaitConditionKind) {
290
+ V1DurableWaitConditionKind["SLEEP"] = "SLEEP";
291
+ V1DurableWaitConditionKind["USER_EVENT"] = "USER_EVENT";
292
+ V1DurableWaitConditionKind["CHILD_WORKFLOW"] = "CHILD_WORKFLOW";
293
+ })(V1DurableWaitConditionKind || (exports.V1DurableWaitConditionKind = V1DurableWaitConditionKind = {}));
294
+ var V1DurableEventLogKind;
295
+ (function (V1DurableEventLogKind) {
296
+ V1DurableEventLogKind["RUN"] = "RUN";
297
+ V1DurableEventLogKind["WAIT_FOR"] = "WAIT_FOR";
298
+ V1DurableEventLogKind["MEMO"] = "MEMO";
299
+ })(V1DurableEventLogKind || (exports.V1DurableEventLogKind = V1DurableEventLogKind = {}));
280
300
  var V1RunningFilter;
281
301
  (function (V1RunningFilter) {
282
302
  V1RunningFilter["ALL"] = "ALL";
283
303
  V1RunningFilter["EVICTED"] = "EVICTED";
284
304
  V1RunningFilter["ON_WORKER"] = "ON_WORKER";
285
305
  })(V1RunningFilter || (exports.V1RunningFilter = V1RunningFilter = {}));
306
+ var V1AdditionalMetadataOperator;
307
+ (function (V1AdditionalMetadataOperator) {
308
+ V1AdditionalMetadataOperator["OR"] = "OR";
309
+ V1AdditionalMetadataOperator["AND"] = "AND";
310
+ })(V1AdditionalMetadataOperator || (exports.V1AdditionalMetadataOperator = V1AdditionalMetadataOperator = {}));
286
311
  var V1LogLineOrderByDirection;
287
312
  (function (V1LogLineOrderByDirection) {
288
313
  V1LogLineOrderByDirection["ASC"] = "ASC";
@@ -20,6 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.HatchetInstrumentor = void 0;
22
22
  const version_1 = require("../version");
23
+ const action_listener_1 = require("../clients/dispatcher/action-listener");
23
24
  const opentelemetry_1 = require("../util/opentelemetry");
24
25
  const parse_1 = require("../util/parse");
25
26
  const types_1 = require("./types");
@@ -69,7 +70,7 @@ function getActionOtelAttributes(action, excludedAttributes = [], workerId) {
69
70
  [opentelemetry_1.OTelAttribute.CHILD_WORKFLOW_INDEX]: action.childWorkflowIndex,
70
71
  [opentelemetry_1.OTelAttribute.CHILD_WORKFLOW_KEY]: action.childWorkflowKey,
71
72
  [opentelemetry_1.OTelAttribute.ACTION_PAYLOAD]: action.actionPayload,
72
- [opentelemetry_1.OTelAttribute.WORKFLOW_NAME]: action.jobName,
73
+ [opentelemetry_1.OTelAttribute.WORKFLOW_NAME]: (0, action_listener_1.workflowNameFromAction)(action),
73
74
  [opentelemetry_1.OTelAttribute.ACTION_NAME]: action.actionId,
74
75
  [opentelemetry_1.OTelAttribute.STEP_NAME]: action.taskName,
75
76
  [opentelemetry_1.OTelAttribute.WORKFLOW_ID]: action.workflowId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.26.0",
3
+ "version": "1.26.2",
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.12.1",
62
+ "@openai/agents": "0.13.2",
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.12.1",
94
+ "@openai/agents": "0.13.2",
95
95
  "@opentelemetry/api": "^1.9.0",
96
96
  "@opentelemetry/core": "^2.0.0",
97
97
  "@opentelemetry/exporter-trace-otlp-grpc": "^0.220.0",
@@ -6,6 +6,7 @@ interface LoadClientConfigOptions {
6
6
  export declare class ConfigLoader {
7
7
  static loadClientConfig(override?: Partial<ClientConfig>, config?: LoadClientConfigOptions): Partial<ClientConfig>;
8
8
  private static parseIntEnv;
9
+ private static parseFloatEnv;
9
10
  private static parseJsonArray;
10
11
  static get default_yaml_config_path(): string;
11
12
  static createCredentials(config: ClientConfig['tls_config']): ChannelCredentials;
@@ -44,7 +44,7 @@ const token_1 = require("./token");
44
44
  const DEFAULT_CONFIG_FILE = '.hatchet.yaml';
45
45
  class ConfigLoader {
46
46
  static loadClientConfig(override, config) {
47
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30;
48
48
  const yaml = this.loadYamlConfig(config === null || config === void 0 ? void 0 : config.path);
49
49
  const tlsConfig = (_a = override === null || override === void 0 ? void 0 : override.tls_config) !== null && _a !== void 0 ? _a : {
50
50
  tls_strategy: (_d = (_c = (_b = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _b === void 0 ? void 0 : _b.tls_strategy) !== null && _c !== void 0 ? _c : this.env('HATCHET_CLIENT_TLS_STRATEGY')) !== null && _d !== void 0 ? _d : 'tls',
@@ -74,7 +74,7 @@ class ConfigLoader {
74
74
  apiUrl =
75
75
  (_x = (_w = (_v = override === null || override === void 0 ? void 0 : override.api_url) !== null && _v !== void 0 ? _v : yaml === null || yaml === void 0 ? void 0 : yaml.api_url) !== null && _w !== void 0 ? _w : this.env('HATCHET_CLIENT_API_URL')) !== null && _x !== void 0 ? _x : addresses.serverUrl;
76
76
  }
77
- catch (_19) {
77
+ catch (_31) {
78
78
  grpcBroadcastAddress =
79
79
  (_z = (_y = override === null || override === void 0 ? void 0 : override.host_port) !== null && _y !== void 0 ? _y : yaml === null || yaml === void 0 ? void 0 : yaml.host_port) !== null && _z !== void 0 ? _z : this.env('HATCHET_CLIENT_HOST_PORT');
80
80
  apiUrl = (_1 = (_0 = override === null || override === void 0 ? void 0 : override.api_url) !== null && _0 !== void 0 ? _0 : yaml === null || yaml === void 0 ? void 0 : yaml.api_url) !== null && _1 !== void 0 ? _1 : this.env('HATCHET_CLIENT_API_URL');
@@ -90,21 +90,13 @@ class ConfigLoader {
90
90
  };
91
91
  const grpcMaxRecvMessageLength = (_8 = (_7 = (_6 = override === null || override === void 0 ? void 0 : override.grpc_max_recv_message_length) !== null && _6 !== void 0 ? _6 : yaml === null || yaml === void 0 ? void 0 : yaml.grpc_max_recv_message_length) !== null && _7 !== void 0 ? _7 : this.parseIntEnv('HATCHET_CLIENT_GRPC_MAX_RECV_MESSAGE_LENGTH')) !== null && _8 !== void 0 ? _8 : 4 * 1024 * 1024;
92
92
  const grpcMaxSendMessageLength = (_11 = (_10 = (_9 = override === null || override === void 0 ? void 0 : override.grpc_max_send_message_length) !== null && _9 !== void 0 ? _9 : yaml === null || yaml === void 0 ? void 0 : yaml.grpc_max_send_message_length) !== null && _10 !== void 0 ? _10 : this.parseIntEnv('HATCHET_CLIENT_GRPC_MAX_SEND_MESSAGE_LENGTH')) !== null && _11 !== void 0 ? _11 : 4 * 1024 * 1024;
93
- return {
94
- token: (_13 = (_12 = override === null || override === void 0 ? void 0 : override.token) !== null && _12 !== void 0 ? _12 : yaml === null || yaml === void 0 ? void 0 : yaml.token) !== null && _13 !== void 0 ? _13 : this.env('HATCHET_CLIENT_TOKEN'),
95
- host_port: grpcBroadcastAddress,
96
- api_url: apiUrl,
97
- tls_config: tlsConfig,
98
- healthcheck: healthCheckConfig,
99
- log_level: (_16 = (_15 = (_14 = override === null || override === void 0 ? void 0 : override.log_level) !== null && _14 !== void 0 ? _14 : yaml === null || yaml === void 0 ? void 0 : yaml.log_level) !== null && _15 !== void 0 ? _15 : this.env('HATCHET_CLIENT_LOG_LEVEL')) !== null && _16 !== void 0 ? _16 : 'INFO',
100
- tenant_id: tenantId,
101
- namespace: namespace ? `${namespace}`.toLowerCase() : '',
102
- otel: otelConfig,
103
- grpc_max_recv_message_length: grpcMaxRecvMessageLength,
104
- grpc_max_send_message_length: grpcMaxSendMessageLength,
105
- cancellation_grace_period: (_17 = override === null || override === void 0 ? void 0 : override.cancellation_grace_period) !== null && _17 !== void 0 ? _17 : yaml === null || yaml === void 0 ? void 0 : yaml.cancellation_grace_period,
106
- cancellation_warning_threshold: (_18 = override === null || override === void 0 ? void 0 : override.cancellation_warning_threshold) !== null && _18 !== void 0 ? _18 : yaml === null || yaml === void 0 ? void 0 : yaml.cancellation_warning_threshold,
93
+ const retrierConfig = {
94
+ maxAttempts: (_15 = (_13 = (_12 = override === null || override === void 0 ? void 0 : override.retrier) === null || _12 === void 0 ? void 0 : _12.maxAttempts) !== null && _13 !== void 0 ? _13 : (_14 = yaml === null || yaml === void 0 ? void 0 : yaml.retrier) === null || _14 === void 0 ? void 0 : _14.maxAttempts) !== null && _15 !== void 0 ? _15 : this.parseIntEnv('HATCHET_CLIENT_RETRIER_MAX_ATTEMPTS'),
95
+ initialInterval: (_19 = (_17 = (_16 = override === null || override === void 0 ? void 0 : override.retrier) === null || _16 === void 0 ? void 0 : _16.initialInterval) !== null && _17 !== void 0 ? _17 : (_18 = yaml === null || yaml === void 0 ? void 0 : yaml.retrier) === null || _18 === void 0 ? void 0 : _18.initialInterval) !== null && _19 !== void 0 ? _19 : this.parseFloatEnv('HATCHET_CLIENT_RETRIER_INITIAL_INTERVAL'),
96
+ maxJitter: (_23 = (_21 = (_20 = override === null || override === void 0 ? void 0 : override.retrier) === null || _20 === void 0 ? void 0 : _20.maxJitter) !== null && _21 !== void 0 ? _21 : (_22 = yaml === null || yaml === void 0 ? void 0 : yaml.retrier) === null || _22 === void 0 ? void 0 : _22.maxJitter) !== null && _23 !== void 0 ? _23 : this.parseIntEnv('HATCHET_CLIENT_RETRIER_MAX_JITTER'),
107
97
  };
98
+ const hasRetrier = Object.values(retrierConfig).some((v) => v !== undefined);
99
+ return Object.assign({ token: (_25 = (_24 = override === null || override === void 0 ? void 0 : override.token) !== null && _24 !== void 0 ? _24 : yaml === null || yaml === void 0 ? void 0 : yaml.token) !== null && _25 !== void 0 ? _25 : this.env('HATCHET_CLIENT_TOKEN'), host_port: grpcBroadcastAddress, api_url: apiUrl, tls_config: tlsConfig, healthcheck: healthCheckConfig, log_level: (_28 = (_27 = (_26 = override === null || override === void 0 ? void 0 : override.log_level) !== null && _26 !== void 0 ? _26 : yaml === null || yaml === void 0 ? void 0 : yaml.log_level) !== null && _27 !== void 0 ? _27 : this.env('HATCHET_CLIENT_LOG_LEVEL')) !== null && _28 !== void 0 ? _28 : 'INFO', tenant_id: tenantId, namespace: namespace ? `${namespace}`.toLowerCase() : '', otel: otelConfig, grpc_max_recv_message_length: grpcMaxRecvMessageLength, grpc_max_send_message_length: grpcMaxSendMessageLength, cancellation_grace_period: (_29 = override === null || override === void 0 ? void 0 : override.cancellation_grace_period) !== null && _29 !== void 0 ? _29 : yaml === null || yaml === void 0 ? void 0 : yaml.cancellation_grace_period, cancellation_warning_threshold: (_30 = override === null || override === void 0 ? void 0 : override.cancellation_warning_threshold) !== null && _30 !== void 0 ? _30 : yaml === null || yaml === void 0 ? void 0 : yaml.cancellation_warning_threshold }, (hasRetrier ? { retrier: retrierConfig } : {}));
108
100
  }
109
101
  static parseIntEnv(envName) {
110
102
  const value = this.env(envName);
@@ -115,6 +107,16 @@ class ConfigLoader {
115
107
  }
116
108
  return parseInt(value, 10);
117
109
  }
110
+ static parseFloatEnv(envName) {
111
+ const value = this.env(envName);
112
+ if (value === undefined || value === '')
113
+ return undefined;
114
+ const parsed = parseFloat(value.trim());
115
+ if (isNaN(parsed) || parsed <= 0) {
116
+ throw new Error(`Invalid value for ${envName}: "${value}". Expected a positive number.`);
117
+ }
118
+ return parsed;
119
+ }
118
120
  static parseJsonArray(value) {
119
121
  try {
120
122
  const parsed = JSON.parse(value);
package/util/retrier.d.ts CHANGED
@@ -1,2 +1,11 @@
1
1
  import { Logger } from './logger';
2
- export declare function retrier<T>(fn: () => Promise<T>, logger: Logger, retries?: number, interval?: number, shouldRetry?: (e: unknown) => boolean): Promise<T>;
2
+ export declare const DEFAULT_RETRY_INTERVAL = 0.1;
3
+ export declare const DEFAULT_RETRY_COUNT = 8;
4
+ export declare const DEFAULT_MAX_JITTER = 100;
5
+ export interface RetrierConfig {
6
+ maxAttempts?: number;
7
+ initialInterval?: number;
8
+ maxJitter?: number;
9
+ shouldRetry?: (e: unknown) => boolean;
10
+ }
11
+ export declare function retrier<T>(fn: () => Promise<T>, logger: Logger, config?: RetrierConfig): Promise<T>;
package/util/retrier.js CHANGED
@@ -12,13 +12,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DEFAULT_MAX_JITTER = exports.DEFAULT_RETRY_COUNT = exports.DEFAULT_RETRY_INTERVAL = void 0;
15
16
  exports.retrier = retrier;
16
17
  const sleep_1 = __importDefault(require("./sleep"));
17
- const DEFAULT_RETRY_INTERVAL = 0.1; // seconds
18
- const DEFAULT_RETRY_COUNT = 8;
19
- const MAX_JITTER = 100; // milliseconds
20
- function retrier(fn_1, logger_1) {
21
- return __awaiter(this, arguments, void 0, function* (fn, logger, retries = DEFAULT_RETRY_COUNT, interval = DEFAULT_RETRY_INTERVAL, shouldRetry = () => true) {
18
+ exports.DEFAULT_RETRY_INTERVAL = 0.1; // seconds
19
+ exports.DEFAULT_RETRY_COUNT = 8;
20
+ exports.DEFAULT_MAX_JITTER = 100; // milliseconds
21
+ function retrier(fn, logger, config) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ var _a, _b, _c, _d;
24
+ const retries = Math.max(1, (_a = config === null || config === void 0 ? void 0 : config.maxAttempts) !== null && _a !== void 0 ? _a : exports.DEFAULT_RETRY_COUNT);
25
+ const interval = (_b = config === null || config === void 0 ? void 0 : config.initialInterval) !== null && _b !== void 0 ? _b : exports.DEFAULT_RETRY_INTERVAL;
26
+ const maxJitter = (_c = config === null || config === void 0 ? void 0 : config.maxJitter) !== null && _c !== void 0 ? _c : exports.DEFAULT_MAX_JITTER;
27
+ const shouldRetry = (_d = config === null || config === void 0 ? void 0 : config.shouldRetry) !== null && _d !== void 0 ? _d : (() => true);
22
28
  let lastError;
23
29
  for (let i = 0; i < retries; i++) {
24
30
  try {
@@ -30,11 +36,11 @@ function retrier(fn_1, logger_1) {
30
36
  }
31
37
  lastError = e instanceof Error ? e : new Error(String(e));
32
38
  logger.error(`Error: ${lastError.message}`);
33
- // Calculate exponential backoff with random jitter
34
- const exponentialDelay = interval * 2 ** i * 1000;
35
- const jitter = Math.random() * MAX_JITTER;
36
- const totalDelay = exponentialDelay + jitter;
37
- yield (0, sleep_1.default)(totalDelay);
39
+ if (i < retries - 1) {
40
+ const exponentialDelay = interval * 2 ** i * 1000;
41
+ const jitter = Math.random() * maxJitter;
42
+ yield (0, sleep_1.default)(exponentialDelay + jitter);
43
+ }
38
44
  }
39
45
  }
40
46
  throw lastError;
@@ -184,7 +184,7 @@ class AdminClient {
184
184
  trailerMetadata = trailer;
185
185
  },
186
186
  });
187
- }), this.logger, undefined, undefined, (e) => !isNiceGrpcAlreadyExists(e));
187
+ }), this.logger, Object.assign(Object.assign({}, this.config.retrier), { shouldRetry: (e) => !isNiceGrpcAlreadyExists(e) }));
188
188
  const id = resp.workflowRunId;
189
189
  const ref = new workflow_run_ref_1.default(id, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId, options === null || options === void 0 ? void 0 : options._standaloneTaskName);
190
190
  yield ref.getWorkflowRunId();
@@ -242,8 +242,8 @@ class AdminClient {
242
242
  bulkTrailerMetadata = trailer;
243
243
  },
244
244
  });
245
- }), this.logger, undefined, undefined, (e) => !isNiceGrpcAlreadyExists(e) &&
246
- !(isGrpcServiceError(e) && e.code === grpc_js_1.status.ALREADY_EXISTS));
245
+ }), this.logger, Object.assign(Object.assign({}, this.config.retrier), { shouldRetry: (e) => !isNiceGrpcAlreadyExists(e) &&
246
+ !(isGrpcServiceError(e) && e.code === grpc_js_1.status.ALREADY_EXISTS) }));
247
247
  this.logger.debug(`batch ${batchIndex + 1} of ${batches.length}`);
248
248
  // Map the results back to their original indices
249
249
  const batchResults = bulkTriggerWorkflowResponse.workflowRunIds.map((resp, index) => {
@@ -277,7 +277,7 @@ class AdminClient {
277
277
  limit,
278
278
  duration,
279
279
  };
280
- yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.workflowsGrpc.putRateLimit(request); }), this.logger);
280
+ yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.workflowsGrpc.putRateLimit(request); }), this.logger, this.config.retrier);
281
281
  });
282
282
  }
283
283
  }
@@ -8,7 +8,7 @@
8
8
  * @module Context
9
9
  */
10
10
  import { Priority, RunOpts, TaskWorkflowDeclaration, BaseWorkflowDeclaration as WorkflowV1 } from '../../declaration';
11
- import { Action } from '../../../clients/dispatcher/action-listener';
11
+ import type { Action } from '../../../clients/dispatcher/action-listener';
12
12
  import { Logger, LogLevel } from '../../../util/logger';
13
13
  import WorkflowRunRef from '../../../util/workflow-run-ref';
14
14
  import { Conditions } from '../../conditions';
@@ -144,8 +144,15 @@ export declare class Context<T, K = {}> {
144
144
  /**
145
145
  * Gets the name of the current workflow.
146
146
  * @returns The name of the workflow.
147
+ * @deprecated This method returns the task name. Use {@link workflowNameV1} for the workflow
148
+ * name or {@link taskName} for the task name.
147
149
  */
148
150
  workflowName(): string;
151
+ /**
152
+ * Gets the name of the current workflow.
153
+ * @returns The name of the workflow.
154
+ */
155
+ workflowNameV1(): string;
149
156
  /**
150
157
  * Gets the user data associated with the workflow.
151
158
  * @returns The user data.
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.DurableContext = exports.Context = exports.ContextWorker = void 0;
25
25
  const declaration_1 = require("../../declaration");
26
26
  const hatchet_error_1 = __importDefault(require("../../../util/errors/hatchet-error"));
27
+ const action_listener_1 = require("../../../clients/dispatcher/action-listener");
27
28
  const parse_1 = require("../../../util/parse");
28
29
  const conditions_1 = require("../../conditions");
29
30
  const transformer_1 = require("../../conditions/transformer");
@@ -210,10 +211,19 @@ class Context {
210
211
  /**
211
212
  * Gets the name of the current workflow.
212
213
  * @returns The name of the workflow.
214
+ * @deprecated This method returns the task name. Use {@link workflowNameV1} for the workflow
215
+ * name or {@link taskName} for the task name.
213
216
  */
214
217
  workflowName() {
215
218
  return this.action.jobName;
216
219
  }
220
+ /**
221
+ * Gets the name of the current workflow.
222
+ * @returns The name of the workflow.
223
+ */
224
+ workflowNameV1() {
225
+ return (0, action_listener_1.workflowNameFromAction)(this.action);
226
+ }
217
227
  /**
218
228
  * Gets the user data associated with the workflow.
219
229
  * @returns The user data.
@@ -288,7 +298,7 @@ class Context {
288
298
  return Promise.resolve();
289
299
  }
290
300
  const logger = this.v1.config.logger('ctx', this.v1.config.log_level);
291
- const contextExtra = Object.assign({ workflowRunId: this.action.workflowRunId, taskRunExternalId: this.action.taskRunExternalId, retryCount: this.action.retryCount, workflowName: this.action.jobName }, extra === null || extra === void 0 ? void 0 : extra.extra);
301
+ const contextExtra = Object.assign({ workflowRunId: this.action.workflowRunId, taskRunExternalId: this.action.taskRunExternalId, retryCount: this.action.retryCount, workflowName: this.workflowNameV1() }, extra === null || extra === void 0 ? void 0 : extra.extra);
292
302
  const promises = [];
293
303
  if (!level || level === 'INFO') {
294
304
  promises.push(logger.info(message, contextExtra));
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.26.0";
1
+ export declare const HATCHET_VERSION = "1.26.2";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HATCHET_VERSION = void 0;
4
- exports.HATCHET_VERSION = '1.26.0';
4
+ exports.HATCHET_VERSION = '1.26.2';