@io-orkes/conductor-javascript 2.4.1 → 3.0.0

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/index.d.mts CHANGED
@@ -322,6 +322,14 @@ type Any = {
322
322
  unknownFields?: UnknownFieldSet;
323
323
  value?: ByteString;
324
324
  };
325
+ type AuthorizationRequest = {
326
+ /**
327
+ * The set of access which is granted or removed
328
+ */
329
+ access: Array<'CREATE' | 'READ' | 'EXECUTE' | 'UPDATE' | 'DELETE'>;
330
+ subject: SubjectRef;
331
+ target: TargetRef;
332
+ };
325
333
  type BulkResponse = {
326
334
  bulkErrorResults?: {
327
335
  [key: string]: string;
@@ -345,6 +353,17 @@ type CircuitBreakerTransitionResponse = {
345
353
  service?: string;
346
354
  transitionTimestamp?: number;
347
355
  };
356
+ type ConductorUser = {
357
+ applicationUser?: boolean;
358
+ encryptedId?: boolean;
359
+ encryptedIdDisplayValue?: string;
360
+ groups?: Array<Group>;
361
+ id?: string;
362
+ name?: string;
363
+ orkesWorkersApp?: boolean;
364
+ roles?: Array<Role$1>;
365
+ uuid?: string;
366
+ };
348
367
  type Config = {
349
368
  circuitBreakerConfig?: OrkesCircuitBreakerConfig;
350
369
  };
@@ -359,6 +378,10 @@ type ConnectivityTestResult = {
359
378
  successful?: boolean;
360
379
  workflowId?: string;
361
380
  };
381
+ type CorrelationIdsSearchRequest = {
382
+ correlationIds: Array<string>;
383
+ workflowNames: Array<string>;
384
+ };
362
385
  type Declaration = {
363
386
  allFields?: {
364
387
  [key: string]: unknown;
@@ -399,8 +422,8 @@ type Descriptor = {
399
422
  containingType?: Descriptor;
400
423
  enumTypes?: Array<EnumDescriptor>;
401
424
  extendable?: boolean;
402
- extensions?: Array<FieldDescriptor>;
403
- fields?: Array<FieldDescriptor>;
425
+ extensions?: Array<FieldDescriptor$1>;
426
+ fields?: Array<FieldDescriptor$1>;
404
427
  file?: FileDescriptor;
405
428
  fullName?: string;
406
429
  index?: number;
@@ -966,7 +989,7 @@ type FeatureSetOrBuilder = {
966
989
  unknownFields?: UnknownFieldSet;
967
990
  utf8Validation?: 'UTF8_VALIDATION_UNKNOWN' | 'NONE' | 'VERIFY';
968
991
  };
969
- type FieldDescriptor = {
992
+ type FieldDescriptor$1 = {
970
993
  containingOneof?: OneofDescriptor;
971
994
  containingType?: Descriptor;
972
995
  defaultValue?: {
@@ -1120,7 +1143,7 @@ type FileDescriptor = {
1120
1143
  edition?: 'EDITION_UNKNOWN' | 'EDITION_PROTO2' | 'EDITION_PROTO3' | 'EDITION_2023' | 'EDITION_1_TEST_ONLY' | 'EDITION_2_TEST_ONLY' | 'EDITION_99997_TEST_ONLY' | 'EDITION_99998_TEST_ONLY' | 'EDITION_99999_TEST_ONLY';
1121
1144
  editionName?: string;
1122
1145
  enumTypes?: Array<EnumDescriptor>;
1123
- extensions?: Array<FieldDescriptor>;
1146
+ extensions?: Array<FieldDescriptor$1>;
1124
1147
  file?: FileDescriptor;
1125
1148
  fullName?: string;
1126
1149
  messageTypes?: Array<Descriptor>;
@@ -1282,6 +1305,22 @@ type GenerateTokenRequest = {
1282
1305
  keyId: string;
1283
1306
  keySecret: string;
1284
1307
  };
1308
+ type GrantedAccess = {
1309
+ access?: Array<'CREATE' | 'READ' | 'EXECUTE' | 'UPDATE' | 'DELETE'>;
1310
+ tag?: string;
1311
+ target?: TargetRef;
1312
+ };
1313
+ type GrantedAccessResponse = {
1314
+ grantedAccess?: Array<GrantedAccess>;
1315
+ };
1316
+ type Group = {
1317
+ defaultAccess?: {
1318
+ [key: string]: Array<'CREATE' | 'READ' | 'EXECUTE' | 'UPDATE' | 'DELETE'>;
1319
+ };
1320
+ description?: string;
1321
+ id?: string;
1322
+ roles?: Array<Role$1>;
1323
+ };
1285
1324
  type HandledEventResponse = {
1286
1325
  active?: boolean;
1287
1326
  event?: string;
@@ -1373,6 +1412,84 @@ type HumanTaskUser = {
1373
1412
  user?: string;
1374
1413
  userType?: 'EXTERNAL_USER' | 'EXTERNAL_GROUP' | 'CONDUCTOR_USER' | 'CONDUCTOR_GROUP';
1375
1414
  };
1415
+ type Integration = {
1416
+ apis?: Array<IntegrationApi>;
1417
+ category?: 'API' | 'AI_MODEL' | 'VECTOR_DB' | 'RELATIONAL_DB' | 'MESSAGE_BROKER' | 'GIT' | 'EMAIL' | 'MCP';
1418
+ configuration?: {
1419
+ [key: string]: unknown;
1420
+ };
1421
+ createTime?: number;
1422
+ createdBy?: string;
1423
+ description?: string;
1424
+ enabled?: boolean;
1425
+ modelsCount?: number;
1426
+ name?: string;
1427
+ ownerApp?: string;
1428
+ tags?: Array<Tag>;
1429
+ type?: string;
1430
+ updateTime?: number;
1431
+ updatedBy?: string;
1432
+ };
1433
+ type IntegrationApi = {
1434
+ api?: string;
1435
+ configuration?: {
1436
+ [key: string]: unknown;
1437
+ };
1438
+ createTime?: number;
1439
+ createdBy?: string;
1440
+ description?: string;
1441
+ enabled?: boolean;
1442
+ integrationName?: string;
1443
+ ownerApp?: string;
1444
+ tags?: Array<Tag>;
1445
+ updateTime?: number;
1446
+ updatedBy?: string;
1447
+ };
1448
+ type IntegrationApiUpdate = {
1449
+ configuration?: {
1450
+ [key: string]: unknown;
1451
+ };
1452
+ description?: string;
1453
+ enabled?: boolean;
1454
+ };
1455
+ type IntegrationDef = {
1456
+ apis?: Array<IntegrationDefApi>;
1457
+ category?: 'API' | 'AI_MODEL' | 'VECTOR_DB' | 'RELATIONAL_DB' | 'MESSAGE_BROKER' | 'GIT' | 'EMAIL' | 'MCP';
1458
+ categoryLabel?: string;
1459
+ configuration?: Array<IntegrationDefFormField>;
1460
+ description?: string;
1461
+ enabled?: boolean;
1462
+ iconName?: string;
1463
+ name?: string;
1464
+ tags?: Array<string>;
1465
+ type?: string;
1466
+ };
1467
+ type IntegrationDefApi = {
1468
+ api?: string;
1469
+ description?: string;
1470
+ inputSchema?: SchemaDef;
1471
+ integrationType?: string;
1472
+ outputSchema?: SchemaDef;
1473
+ };
1474
+ type IntegrationDefFormField = {
1475
+ defaultValue?: string;
1476
+ description?: string;
1477
+ fieldName?: 'api_key' | 'user' | 'endpoint' | 'authUrl' | 'environment' | 'projectName' | 'indexName' | 'publisher' | 'password' | 'namespace' | 'batchSize' | 'batchWaitTime' | 'visibilityTimeout' | 'connectionType' | 'connectionPoolSize' | 'consumer' | 'stream' | 'batchPollConsumersCount' | 'consumer_type' | 'region' | 'awsAccountId' | 'externalId' | 'roleArn' | 'protocol' | 'mechanism' | 'port' | 'schemaRegistryUrl' | 'schemaRegistryApiKey' | 'schemaRegistryApiSecret' | 'authenticationType' | 'truststoreAuthenticationType' | 'tls' | 'cipherSuite' | 'pubSubMethod' | 'keyStorePassword' | 'keyStoreLocation' | 'schemaRegistryAuthType' | 'valueSubjectNameStrategy' | 'datasourceURL' | 'jdbcDriver' | 'subscription' | 'serviceAccountCredentials' | 'file' | 'tlsFile' | 'queueManager' | 'groupId' | 'channel' | 'dimensions' | 'distance_metric' | 'indexing_method' | 'inverted_list_count' | 'pullPeriod' | 'pullBatchWaitMillis' | 'completionsPath' | 'betaVersion' | 'version';
1478
+ fieldType?: 'DROPDOWN' | 'TEXT' | 'PASSWORD' | 'FILE';
1479
+ label?: string;
1480
+ optional?: boolean;
1481
+ value?: string;
1482
+ valueOptions?: Array<Option>;
1483
+ };
1484
+ type IntegrationUpdate = {
1485
+ category?: 'API' | 'AI_MODEL' | 'VECTOR_DB' | 'RELATIONAL_DB' | 'MESSAGE_BROKER' | 'GIT' | 'EMAIL' | 'MCP';
1486
+ configuration?: {
1487
+ [key: string]: unknown;
1488
+ };
1489
+ description?: string;
1490
+ enabled?: boolean;
1491
+ type?: string;
1492
+ };
1376
1493
  type Location = {
1377
1494
  allFields?: {
1378
1495
  [key: string]: unknown;
@@ -1484,6 +1601,20 @@ type MessageOptionsOrBuilder = {
1484
1601
  uninterpretedOptionOrBuilderList?: Array<UninterpretedOptionOrBuilder>;
1485
1602
  unknownFields?: UnknownFieldSet;
1486
1603
  };
1604
+ type MessageTemplate = {
1605
+ createTime?: number;
1606
+ createdBy?: string;
1607
+ description?: string;
1608
+ integrations?: Array<string>;
1609
+ name?: string;
1610
+ ownerApp?: string;
1611
+ tags?: Array<Tag>;
1612
+ template?: string;
1613
+ updateTime?: number;
1614
+ updatedBy?: string;
1615
+ variables?: Array<string>;
1616
+ version?: number;
1617
+ };
1487
1618
  type MethodDescriptor = {
1488
1619
  clientStreaming?: boolean;
1489
1620
  file?: FileDescriptor;
@@ -1685,6 +1816,10 @@ type OneofOptionsOrBuilder = {
1685
1816
  uninterpretedOptionOrBuilderList?: Array<UninterpretedOptionOrBuilder>;
1686
1817
  unknownFields?: UnknownFieldSet;
1687
1818
  };
1819
+ type Option = {
1820
+ label?: string;
1821
+ value?: string;
1822
+ };
1688
1823
  type OrkesCircuitBreakerConfig = {
1689
1824
  automaticTransitionFromOpenToHalfOpenEnabled?: boolean;
1690
1825
  failureRateThreshold?: number;
@@ -1789,12 +1924,26 @@ type ParserSourceCodeInfo = {
1789
1924
  type ParserUninterpretedOption = {
1790
1925
  [key: string]: unknown;
1791
1926
  };
1927
+ type Permission = {
1928
+ name?: string;
1929
+ };
1792
1930
  type PollData = {
1793
1931
  domain?: string;
1794
1932
  lastPollTime?: number;
1795
1933
  queueName?: string;
1796
1934
  workerId?: string;
1797
1935
  };
1936
+ type PromptTemplateTestRequest = {
1937
+ llmProvider?: string;
1938
+ model?: string;
1939
+ prompt?: string;
1940
+ promptVariables?: {
1941
+ [key: string]: unknown;
1942
+ };
1943
+ stopWords?: Array<string>;
1944
+ temperature?: number;
1945
+ topP?: number;
1946
+ };
1798
1947
  type ProtoRegistryEntry = {
1799
1948
  data?: string;
1800
1949
  filename?: string;
@@ -1850,6 +1999,10 @@ type ReservedRangeOrBuilder = {
1850
1999
  type Response$1 = {
1851
2000
  [key: string]: unknown;
1852
2001
  };
2002
+ type Role$1 = {
2003
+ name?: string;
2004
+ permissions?: Array<Permission>;
2005
+ };
1853
2006
  type SaveScheduleRequest = {
1854
2007
  createdBy?: string;
1855
2008
  cronExpression: string;
@@ -2092,6 +2245,16 @@ type SubWorkflowParams = {
2092
2245
  [key: string]: unknown;
2093
2246
  };
2094
2247
  };
2248
+ /**
2249
+ * User, group or role which is granted/removed access
2250
+ */
2251
+ type SubjectRef = {
2252
+ id: string;
2253
+ /**
2254
+ * User, role or group
2255
+ */
2256
+ type?: 'USER' | 'ROLE' | 'GROUP';
2257
+ };
2095
2258
  type Tag = {
2096
2259
  key?: string;
2097
2260
  /**
@@ -2100,6 +2263,13 @@ type Tag = {
2100
2263
  type?: string;
2101
2264
  value?: string;
2102
2265
  };
2266
+ /**
2267
+ * The object over which access is being granted or removed
2268
+ */
2269
+ type TargetRef = {
2270
+ id: "Identifier of the target e.g. `name` in case it's a WORKFLOW_DEF";
2271
+ type: 'WORKFLOW' | 'WORKFLOW_DEF' | 'WORKFLOW_SCHEDULE' | 'EVENT_HANDLER' | 'TASK_DEF' | 'TASK_REF_NAME' | 'TASK_ID' | 'APPLICATION' | 'USER' | 'SECRET_NAME' | 'ENV_VARIABLE' | 'TAG' | 'DOMAIN' | 'INTEGRATION_PROVIDER' | 'INTEGRATION' | 'PROMPT' | 'USER_FORM_TEMPLATE' | 'SCHEMA' | 'CLUSTER_CONFIG' | 'WEBHOOK';
2272
+ };
2103
2273
  type Task = {
2104
2274
  callbackAfterSeconds?: number;
2105
2275
  callbackFromWorker?: boolean;
@@ -2203,6 +2373,14 @@ type TaskListSearchResultSummary = {
2203
2373
  };
2204
2374
  totalHits?: number;
2205
2375
  };
2376
+ type TaskMock = {
2377
+ executionTime?: number;
2378
+ output?: {
2379
+ [key: string]: unknown;
2380
+ };
2381
+ queueWaitTime?: number;
2382
+ status?: 'IN_PROGRESS' | 'FAILED' | 'FAILED_WITH_TERMINAL_ERROR' | 'COMPLETED';
2383
+ };
2206
2384
  type TaskResult = {
2207
2385
  callbackAfterSeconds?: number;
2208
2386
  extendLease?: boolean;
@@ -2302,6 +2480,30 @@ type UpdateWorkflowVariables = {
2302
2480
  };
2303
2481
  workflowId?: string;
2304
2482
  };
2483
+ type UpsertGroupRequest = {
2484
+ /**
2485
+ * a default Map<TargetType, Set<Access> to share permissions, allowed target types: WORKFLOW_DEF, TASK_DEF, WORKFLOW_SCHEDULE
2486
+ */
2487
+ defaultAccess?: {
2488
+ [key: string]: Array<'CREATE' | 'READ' | 'EXECUTE' | 'UPDATE' | 'DELETE'>;
2489
+ };
2490
+ /**
2491
+ * A general description of the group
2492
+ */
2493
+ description: string;
2494
+ roles?: 'ADMIN' | 'USER' | 'WORKER' | 'METADATA_MANAGER' | 'WORKFLOW_MANAGER';
2495
+ };
2496
+ type UpsertUserRequest = {
2497
+ /**
2498
+ * Ids of the groups this user belongs to
2499
+ */
2500
+ groups?: Array<string>;
2501
+ /**
2502
+ * User's full name
2503
+ */
2504
+ name: string;
2505
+ roles?: 'ADMIN' | 'USER' | 'WORKER' | 'METADATA_MANAGER' | 'WORKFLOW_MANAGER';
2506
+ };
2305
2507
  type UserFormTemplate = {
2306
2508
  name?: string;
2307
2509
  version?: number;
@@ -2461,6 +2663,13 @@ type WorkflowScheduleModel = {
2461
2663
  updatedTime?: number;
2462
2664
  zoneId?: string;
2463
2665
  };
2666
+ type WorkflowStateUpdate = {
2667
+ taskReferenceName?: string;
2668
+ taskResult?: TaskResult;
2669
+ variables?: {
2670
+ [key: string]: unknown;
2671
+ };
2672
+ };
2464
2673
  type WorkflowStatus = {
2465
2674
  correlationId?: string;
2466
2675
  output?: {
@@ -2549,6 +2758,29 @@ type WorkflowTask = {
2549
2758
  taskReferenceName: string;
2550
2759
  type?: string;
2551
2760
  };
2761
+ type WorkflowTestRequest = {
2762
+ correlationId?: string;
2763
+ createdBy?: string;
2764
+ externalInputPayloadStoragePath?: string;
2765
+ idempotencyKey?: string;
2766
+ idempotencyStrategy?: 'FAIL' | 'RETURN_EXISTING' | 'FAIL_ON_RUNNING';
2767
+ input?: {
2768
+ [key: string]: unknown;
2769
+ };
2770
+ name: string;
2771
+ priority?: number;
2772
+ subWorkflowTestRequest?: {
2773
+ [key: string]: WorkflowTestRequest;
2774
+ };
2775
+ taskRefToMockOutput?: {
2776
+ [key: string]: Array<TaskMock>;
2777
+ };
2778
+ taskToDomain?: {
2779
+ [key: string]: string;
2780
+ };
2781
+ version?: number;
2782
+ workflowDef?: WorkflowDef;
2783
+ };
2552
2784
 
2553
2785
  interface CommonTaskDef {
2554
2786
  name: string;
@@ -2582,10 +2814,14 @@ declare enum TaskType {
2582
2814
  JOIN = "JOIN",
2583
2815
  DO_WHILE = "DO_WHILE",
2584
2816
  SUB_WORKFLOW = "SUB_WORKFLOW",
2817
+ START_WORKFLOW = "START_WORKFLOW",
2585
2818
  EVENT = "EVENT",
2586
2819
  WAIT = "WAIT",
2820
+ WAIT_FOR_WEBHOOK = "WAIT_FOR_WEBHOOK",
2587
2821
  USER_DEFINED = "USER_DEFINED",
2588
2822
  HTTP = "HTTP",
2823
+ HTTP_POLL = "HTTP_POLL",
2824
+ HUMAN = "HUMAN",
2589
2825
  LAMBDA = "LAMBDA",
2590
2826
  INLINE = "INLINE",
2591
2827
  EXCLUSIVE_JOIN = "EXCLUSIVE_JOIN",
@@ -2593,7 +2829,20 @@ declare enum TaskType {
2593
2829
  TERMINATE = "TERMINATE",
2594
2830
  KAFKA_PUBLISH = "KAFKA_PUBLISH",
2595
2831
  JSON_JQ_TRANSFORM = "JSON_JQ_TRANSFORM",
2596
- SET_VARIABLE = "SET_VARIABLE"
2832
+ SET_VARIABLE = "SET_VARIABLE",
2833
+ GET_DOCUMENT = "GET_DOCUMENT",
2834
+ LLM_CHAT_COMPLETE = "LLM_CHAT_COMPLETE",
2835
+ LLM_TEXT_COMPLETE = "LLM_TEXT_COMPLETE",
2836
+ LLM_GENERATE_EMBEDDINGS = "LLM_GENERATE_EMBEDDINGS",
2837
+ LLM_INDEX_TEXT = "LLM_INDEX_TEXT",
2838
+ LLM_SEARCH_INDEX = "LLM_SEARCH_INDEX",
2839
+ LLM_SEARCH_EMBEDDINGS = "LLM_SEARCH_EMBEDDINGS",
2840
+ LLM_STORE_EMBEDDINGS = "LLM_STORE_EMBEDDINGS",
2841
+ LLM_GET_EMBEDDINGS = "LLM_GET_EMBEDDINGS",
2842
+ GENERATE_IMAGE = "GENERATE_IMAGE",
2843
+ GENERATE_AUDIO = "GENERATE_AUDIO",
2844
+ CALL_MCP_TOOL = "CALL_MCP_TOOL",
2845
+ LIST_MCP_TOOLS = "LIST_MCP_TOOLS"
2597
2846
  }
2598
2847
  declare enum ServiceType {
2599
2848
  HTTP = "HTTP",
@@ -2756,7 +3005,9 @@ interface SignalResponse extends SignalResponse$1 {
2756
3005
  referenceTaskName?: string;
2757
3006
  retryCount?: number;
2758
3007
  taskDefName?: string;
3008
+ retriedTaskId?: string;
2759
3009
  workflowType?: string;
3010
+ reasonForIncompletion?: string;
2760
3011
  }
2761
3012
  interface AccessKey {
2762
3013
  id: string;
@@ -2771,6 +3022,33 @@ type ApplicationRole = "ADMIN" | "UNRESTRICTED_WORKER" | "METADATA_MANAGER" | "W
2771
3022
  interface ExtendedConductorApplication extends Required<Omit<ExtendedConductorApplication$1, "tags">> {
2772
3023
  tags?: Tag[];
2773
3024
  }
3025
+ /** Extended ConductorUser with fields present in Python SDK but missing from OpenAPI spec */
3026
+ interface ExtendedConductorUser extends ConductorUser {
3027
+ contactInformation?: Record<string, string>;
3028
+ namespace?: string;
3029
+ }
3030
+ /** Extended Group with fields present in Python SDK but missing from OpenAPI spec */
3031
+ interface ExtendedGroup extends Group {
3032
+ contactInformation?: Record<string, string>;
3033
+ }
3034
+ /** Extended IntegrationApiUpdate with fields present in Python SDK but missing from OpenAPI spec */
3035
+ interface ExtendedIntegrationApiUpdate extends IntegrationApiUpdate {
3036
+ maxTokens?: number;
3037
+ frequency?: string;
3038
+ }
3039
+ /** Extended RateLimitConfig with fields present in Python SDK but missing from OpenAPI spec */
3040
+ interface ExtendedRateLimitConfig extends RateLimitConfig {
3041
+ tag?: string;
3042
+ concurrentExecutionLimit?: number;
3043
+ }
3044
+ /** Extended BulkResponse with fields present in Python SDK but missing from OpenAPI spec */
3045
+ interface ExtendedBulkResponse extends BulkResponse {
3046
+ message?: string;
3047
+ }
3048
+ /** Extended TaskSummary with fields present in Python SDK but missing from OpenAPI spec */
3049
+ interface ExtendedTaskSummary extends TaskSummary {
3050
+ domain?: string;
3051
+ }
2774
3052
 
2775
3053
  type TimeoutPolicy = {
2776
3054
  type: string;
@@ -2866,6 +3144,35 @@ declare abstract class BaseHttpRequest {
2866
3144
  abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
2867
3145
  }
2868
3146
 
3147
+ interface ConductorLogger {
3148
+ info(...args: unknown[]): void;
3149
+ error(...args: unknown[]): void;
3150
+ debug(...args: unknown[]): void;
3151
+ warn?(...args: unknown[]): void;
3152
+ }
3153
+ type ConductorLogLevel = keyof typeof LOG_LEVELS;
3154
+ interface DefaultLoggerConfig {
3155
+ level?: ConductorLogLevel;
3156
+ tags?: object[];
3157
+ }
3158
+ declare const LOG_LEVELS: {
3159
+ readonly DEBUG: 10;
3160
+ readonly INFO: 30;
3161
+ readonly WARN: 40;
3162
+ readonly ERROR: 60;
3163
+ };
3164
+ declare class DefaultLogger implements ConductorLogger {
3165
+ private readonly tags;
3166
+ private readonly level;
3167
+ constructor(config?: DefaultLoggerConfig);
3168
+ private log;
3169
+ info: (...args: unknown[]) => void;
3170
+ debug: (...args: unknown[]) => void;
3171
+ warn: (...args: unknown[]) => void;
3172
+ error: (...args: unknown[]) => void;
3173
+ }
3174
+ declare const noopLogger: ConductorLogger;
3175
+
2869
3176
  type TaskResultStatus = NonNullable<TaskResult["status"]>;
2870
3177
  type TaskResultOutputData = NonNullable<TaskResult["outputData"]>;
2871
3178
  interface OrkesApiConfig {
@@ -2875,6 +3182,15 @@ interface OrkesApiConfig {
2875
3182
  refreshTokenInterval?: number;
2876
3183
  useEnvVars?: boolean;
2877
3184
  maxHttp2Connections?: number;
3185
+ logger?: ConductorLogger;
3186
+ requestTimeoutMs?: number;
3187
+ connectTimeoutMs?: number;
3188
+ tlsCertPath?: string;
3189
+ tlsKeyPath?: string;
3190
+ tlsCaPath?: string;
3191
+ proxyUrl?: string;
3192
+ tlsInsecure?: boolean;
3193
+ disableHttp2?: boolean;
2878
3194
  }
2879
3195
 
2880
3196
  /**
@@ -3218,6 +3534,125 @@ declare class ApplicationClient {
3218
3534
  addApplicationTag(applicationId: string, tag: Tag): Promise<void>;
3219
3535
  }
3220
3536
 
3537
+ declare class AuthorizationClient {
3538
+ readonly _client: Client;
3539
+ constructor(client: Client);
3540
+ /**
3541
+ * Grant permissions to a subject for a target
3542
+ * @param request - The authorization request
3543
+ */
3544
+ grantPermissions(request: AuthorizationRequest): Promise<void>;
3545
+ /**
3546
+ * Get permissions for a resource
3547
+ * @param type - The resource type
3548
+ * @param id - The resource ID
3549
+ * @returns The permissions object
3550
+ */
3551
+ getPermissions(type: "WORKFLOW" | "WORKFLOW_DEF" | "WORKFLOW_SCHEDULE" | "EVENT_HANDLER" | "TASK_DEF" | "TASK_REF_NAME" | "TASK_ID" | "APPLICATION" | "USER" | "SECRET_NAME" | "ENV_VARIABLE" | "TAG" | "DOMAIN" | "INTEGRATION_PROVIDER" | "INTEGRATION" | "PROMPT" | "USER_FORM_TEMPLATE" | "SCHEMA" | "CLUSTER_CONFIG" | "WEBHOOK", id: string): Promise<Record<string, unknown>>;
3552
+ /**
3553
+ * Remove permissions from a subject for a target
3554
+ * @param request - The authorization request
3555
+ */
3556
+ removePermissions(request: AuthorizationRequest): Promise<void>;
3557
+ /**
3558
+ * Create or update a user
3559
+ * @param id - The user ID
3560
+ * @param request - The upsert user request
3561
+ * @returns The user object
3562
+ */
3563
+ upsertUser(id: string, request: UpsertUserRequest): Promise<ExtendedConductorUser>;
3564
+ /**
3565
+ * Get a user by ID
3566
+ * @param id - The user ID
3567
+ * @returns The user object
3568
+ */
3569
+ getUser(id: string): Promise<ExtendedConductorUser>;
3570
+ /**
3571
+ * List all users
3572
+ * @param apps - Whether to include application users
3573
+ * @returns Array of users
3574
+ */
3575
+ listUsers(apps?: boolean): Promise<ExtendedConductorUser[]>;
3576
+ /**
3577
+ * Delete a user
3578
+ * @param id - The user ID
3579
+ */
3580
+ deleteUser(id: string): Promise<void>;
3581
+ /**
3582
+ * Check permissions for a user
3583
+ * @param userId - The user ID
3584
+ * @param type - The resource type
3585
+ * @param id - The resource ID
3586
+ * @returns The permissions check result
3587
+ */
3588
+ checkPermissions(userId: string, type: string, id: string): Promise<Record<string, unknown>>;
3589
+ /**
3590
+ * Get granted permissions for a user
3591
+ * @param userId - The user ID
3592
+ * @returns The granted permissions
3593
+ */
3594
+ getGrantedPermissionsForUser(userId: string): Promise<GrantedAccessResponse>;
3595
+ /**
3596
+ * Create or update a group
3597
+ * @param id - The group ID
3598
+ * @param request - The upsert group request
3599
+ * @returns The group object
3600
+ */
3601
+ upsertGroup(id: string, request: UpsertGroupRequest): Promise<ExtendedGroup>;
3602
+ /**
3603
+ * Get a group by ID
3604
+ * @param id - The group ID
3605
+ * @returns The group object
3606
+ */
3607
+ getGroup(id: string): Promise<ExtendedGroup>;
3608
+ /**
3609
+ * List all groups
3610
+ * @returns Array of groups
3611
+ */
3612
+ listGroups(): Promise<ExtendedGroup[]>;
3613
+ /**
3614
+ * Delete a group
3615
+ * @param id - The group ID
3616
+ */
3617
+ deleteGroup(id: string): Promise<void>;
3618
+ /**
3619
+ * Add a user to a group
3620
+ * @param groupId - The group ID
3621
+ * @param userId - The user ID
3622
+ */
3623
+ addUserToGroup(groupId: string, userId: string): Promise<void>;
3624
+ /**
3625
+ * Add multiple users to a group
3626
+ * @param groupId - The group ID
3627
+ * @param userIds - Array of user IDs
3628
+ */
3629
+ addUsersToGroup(groupId: string, userIds: string[]): Promise<void>;
3630
+ /**
3631
+ * Get users in a group
3632
+ * @param id - The group ID
3633
+ * @returns The users in the group
3634
+ */
3635
+ getUsersInGroup(id: string): Promise<ExtendedConductorUser[]>;
3636
+ /**
3637
+ * Remove a user from a group
3638
+ * @param groupId - The group ID
3639
+ * @param userId - The user ID
3640
+ */
3641
+ removeUserFromGroup(groupId: string, userId: string): Promise<void>;
3642
+ /**
3643
+ * Remove multiple users from a group
3644
+ * @param groupId - The group ID
3645
+ * @param userIds - Array of user IDs
3646
+ */
3647
+ removeUsersFromGroup(groupId: string, userIds: string[]): Promise<void>;
3648
+ /**
3649
+ * Get granted permissions for a group
3650
+ * @param groupId - The group ID
3651
+ * @returns The granted access response
3652
+ */
3653
+ getGrantedPermissionsForGroup(groupId: string): Promise<GrantedAccessResponse>;
3654
+ }
3655
+
3221
3656
  declare class EventClient {
3222
3657
  readonly _client: Client;
3223
3658
  constructor(client: Client);
@@ -3384,166 +3819,14 @@ declare class EventClient {
3384
3819
  getEventMessages(event: string, from?: number): Promise<EventMessage[]>;
3385
3820
  }
3386
3821
 
3387
- interface ConductorLogger {
3388
- info(...args: unknown[]): void;
3389
- error(...args: unknown[]): void;
3390
- debug(...args: unknown[]): void;
3391
- }
3392
- type ConductorLogLevel = keyof typeof LOG_LEVELS;
3393
- interface DefaultLoggerConfig {
3394
- level?: ConductorLogLevel;
3395
- tags?: object[];
3822
+ type UserType = "EXTERNAL_USER" | "EXTERNAL_GROUP" | "CONDUCTOR_USER" | "CONDUCTOR_GROUP";
3823
+ interface PollIntervalOptions {
3824
+ pollInterval: number;
3825
+ maxPollTimes: number;
3396
3826
  }
3397
- declare const LOG_LEVELS: {
3398
- readonly DEBUG: 10;
3399
- readonly INFO: 30;
3400
- readonly ERROR: 60;
3401
- };
3402
- declare class DefaultLogger implements ConductorLogger {
3403
- private readonly tags;
3404
- private readonly level;
3405
- constructor(config?: DefaultLoggerConfig);
3406
- private log;
3407
- info: (...args: unknown[]) => void;
3408
- debug: (...args: unknown[]) => void;
3409
- error: (...args: unknown[]) => void;
3410
- }
3411
- declare const noopLogger: ConductorLogger;
3412
-
3413
- type TaskErrorHandler = (error: Error, task?: Task) => void;
3414
- interface ConductorWorker {
3415
- taskDefName: string;
3416
- execute: (task: Task) => Promise<Omit<TaskResult, "workflowInstanceId" | "taskId">>;
3417
- domain?: string;
3418
- concurrency?: number;
3419
- pollInterval?: number;
3420
- }
3421
- interface TaskRunnerOptions {
3422
- workerID: string;
3423
- domain: string | undefined;
3424
- pollInterval?: number;
3425
- concurrency?: number;
3426
- batchPollingTimeout?: number;
3427
- }
3428
- interface RunnerArgs {
3429
- worker: ConductorWorker;
3430
- client: Client;
3431
- options: TaskRunnerOptions;
3432
- logger?: ConductorLogger;
3433
- onError?: TaskErrorHandler;
3434
- concurrency?: number;
3435
- maxRetries?: number;
3436
- }
3437
- interface PollerOptions {
3438
- pollInterval?: number;
3439
- concurrency: number;
3440
- warnAtO?: number;
3441
- }
3442
- type TaskManagerOptions = TaskRunnerOptions;
3443
- interface TaskManagerConfig {
3444
- logger?: ConductorLogger;
3445
- options?: Partial<TaskManagerOptions>;
3446
- onError?: TaskErrorHandler;
3447
- maxRetries?: number;
3448
- }
3449
-
3450
- /**
3451
- * Responsible for initializing and managing the runners that poll and work different task queues.
3452
- */
3453
- declare class TaskManager {
3454
- private workerRunners;
3455
- private readonly client;
3456
- private readonly logger;
3457
- private readonly errorHandler;
3458
- private workers;
3459
- readonly options: Required<TaskManagerOptions>;
3460
- private polling;
3461
- private maxRetries;
3462
- constructor(client: Client, workers: ConductorWorker[], config?: TaskManagerConfig);
3463
- private workerManagerWorkerOptions;
3464
- get isPolling(): boolean;
3465
- updatePollingOptionForWorker: (workerTaskDefName: string, options: Partial<TaskManagerOptions>) => void;
3466
- /**
3467
- * new options will get merged to existing options
3468
- * @param options new options to update polling options
3469
- */
3470
- updatePollingOptions: (options: Partial<TaskManagerOptions>) => void;
3471
- sanityCheck: () => void;
3472
- /**
3473
- * Start polling for tasks
3474
- */
3475
- startPolling: () => void;
3476
- /**
3477
- * Stops polling for tasks
3478
- */
3479
- stopPolling: () => Promise<void>;
3480
- }
3481
-
3482
- /**
3483
- * Responsible for polling and executing tasks from a queue.
3484
- *
3485
- * Because a `poll` in conductor "pops" a task off of a conductor queue,
3486
- * each runner participates in the poll -> work -> update loop.
3487
- * We could potentially split this work into a separate "poller" and "worker" pools
3488
- * but that could lead to picking up more work than the pool of workers are actually able to handle.
3489
- *
3490
- */
3491
- declare class TaskRunner {
3492
- _client: Client;
3493
- worker: ConductorWorker;
3494
- private logger;
3495
- private options;
3496
- errorHandler: TaskErrorHandler;
3497
- private poller;
3498
- private maxRetries;
3499
- constructor({ worker, client, options, logger, onError: errorHandler, maxRetries, }: RunnerArgs);
3500
- get isPolling(): boolean;
3501
- /**
3502
- * Starts polling for work
3503
- */
3504
- startPolling: () => void;
3505
- /**
3506
- * Stops Polling for work
3507
- */
3508
- stopPolling: () => Promise<void>;
3509
- updateOptions(options: Partial<TaskRunnerOptions>): void;
3510
- get getOptions(): TaskRunnerOptions;
3511
- private batchPoll;
3512
- updateTaskWithRetry: (task: Task, taskResult: TaskResult) => Promise<void>;
3513
- private executeTask;
3514
- handleUnknownError: (unknownError: unknown) => void;
3515
- }
3516
-
3517
- declare class Poller<T> {
3518
- private timeoutHandler?;
3519
- private pollFunction;
3520
- private performWorkFunction;
3521
- private polling;
3522
- private _tasksInProcess;
3523
- private _counterAtO;
3524
- private _pollerId;
3525
- options: PollerOptions;
3526
- logger: ConductorLogger;
3527
- constructor(pollerId: string, pollFunction: (count: number) => Promise<T[] | undefined>, performWorkFunction: (work: T) => Promise<void>, pollerOptions?: Partial<PollerOptions>, logger?: ConductorLogger);
3528
- get isPolling(): boolean;
3529
- get tasksInProcess(): number;
3530
- /**
3531
- * Starts polling for work
3532
- */
3533
- startPolling: () => void;
3534
- /**
3535
- * Stops Polling for work
3536
- */
3537
- stopPolling: () => Promise<void>;
3538
- private performWork;
3539
- updateOptions(options: Partial<PollerOptions>): void;
3540
- private poll;
3541
- }
3542
-
3543
- type UserType = "EXTERNAL_USER" | "EXTERNAL_GROUP" | "CONDUCTOR_USER" | "CONDUCTOR_GROUP";
3544
- interface PollIntervalOptions {
3545
- pollInterval: number;
3546
- maxPollTimes: number;
3827
+ interface ClaimTaskOptions {
3828
+ overrideAssignment?: boolean;
3829
+ withTemplate?: boolean;
3547
3830
  }
3548
3831
 
3549
3832
  declare class HumanExecutor {
@@ -3598,13 +3881,13 @@ declare class HumanExecutor {
3598
3881
  * @param assignee
3599
3882
  * @returns
3600
3883
  */
3601
- claimTaskAsExternalUser(taskId: string, assignee: string, options?: Record<string, boolean>): Promise<HumanTaskEntry>;
3884
+ claimTaskAsExternalUser(taskId: string, assignee: string, options?: ClaimTaskOptions): Promise<HumanTaskEntry>;
3602
3885
  /**
3603
3886
  * Claim task as conductor user
3604
3887
  * @param taskId
3605
3888
  * @returns
3606
3889
  */
3607
- claimTaskAsConductorUser(taskId: string, options?: Record<string, boolean>): Promise<HumanTaskEntry>;
3890
+ claimTaskAsConductorUser(taskId: string, options?: ClaimTaskOptions): Promise<HumanTaskEntry>;
3608
3891
  /**
3609
3892
  * Claim task as conductor user
3610
3893
  * @param taskId
@@ -3639,6 +3922,137 @@ declare class HumanExecutor {
3639
3922
  completeTask(taskId: string, requestBody?: Record<string, Record<string, unknown>>): Promise<void>;
3640
3923
  }
3641
3924
 
3925
+ declare class IntegrationClient {
3926
+ readonly _client: Client;
3927
+ constructor(client: Client);
3928
+ /**
3929
+ * Save (create or update) an integration provider
3930
+ * @param name - The provider name
3931
+ * @param integration - The integration configuration
3932
+ */
3933
+ saveIntegrationProvider(name: string, integration: IntegrationUpdate): Promise<void>;
3934
+ /**
3935
+ * Get an integration provider by name
3936
+ * @param name - The provider name
3937
+ * @returns The integration provider
3938
+ */
3939
+ getIntegrationProvider(name: string): Promise<Integration>;
3940
+ /**
3941
+ * Get all integration providers
3942
+ * @returns Array of integrations representing providers
3943
+ */
3944
+ getIntegrationProviders(): Promise<Integration[]>;
3945
+ /**
3946
+ * Delete an integration provider
3947
+ * @param name - The provider name
3948
+ */
3949
+ deleteIntegrationProvider(name: string): Promise<void>;
3950
+ /**
3951
+ * Save (create or update) an integration API
3952
+ * @param providerName - The provider name
3953
+ * @param integrationName - The integration name
3954
+ * @param api - The integration API configuration
3955
+ */
3956
+ saveIntegrationApi(providerName: string, integrationName: string, api: ExtendedIntegrationApiUpdate): Promise<void>;
3957
+ /**
3958
+ * Get an integration API
3959
+ * @param providerName - The provider name
3960
+ * @param integrationName - The integration name
3961
+ * @returns The integration API
3962
+ */
3963
+ getIntegrationApi(providerName: string, integrationName: string): Promise<IntegrationApi>;
3964
+ /**
3965
+ * Get all integration APIs for a provider
3966
+ * @param providerName - The provider name
3967
+ * @returns Array of integration APIs
3968
+ */
3969
+ getIntegrationApis(providerName: string): Promise<IntegrationApi[]>;
3970
+ /**
3971
+ * Delete an integration API
3972
+ * @param providerName - The provider name
3973
+ * @param integrationName - The integration name
3974
+ */
3975
+ deleteIntegrationApi(providerName: string, integrationName: string): Promise<void>;
3976
+ /**
3977
+ * Get all integrations
3978
+ * @param category - Optional category filter
3979
+ * @param activeOnly - Whether to return only active integrations
3980
+ * @returns Array of integrations
3981
+ */
3982
+ getIntegrations(category?: string, activeOnly?: boolean): Promise<Integration[]>;
3983
+ /**
3984
+ * Get integration provider definitions
3985
+ * @returns Array of integration definitions
3986
+ */
3987
+ getIntegrationProviderDefs(): Promise<IntegrationDef[]>;
3988
+ /**
3989
+ * Get providers and integrations
3990
+ * @param type - Optional type filter
3991
+ * @param activeOnly - Whether to return only active
3992
+ * @returns Array of provider and integration info
3993
+ */
3994
+ getProvidersAndIntegrations(type?: string, activeOnly?: boolean): Promise<string[]>;
3995
+ /**
3996
+ * Get available APIs for a provider
3997
+ * @param providerName - The provider name
3998
+ * @returns Array of available APIs
3999
+ */
4000
+ getIntegrationAvailableApis(providerName: string): Promise<string[]>;
4001
+ /**
4002
+ * Associate a prompt with an integration
4003
+ * @param providerName - The integration provider name
4004
+ * @param integrationName - The integration name
4005
+ * @param promptName - The prompt template name
4006
+ */
4007
+ associatePromptWithIntegration(providerName: string, integrationName: string, promptName: string): Promise<void>;
4008
+ /**
4009
+ * Get prompts associated with an integration
4010
+ * @param providerName - The integration provider name
4011
+ * @param integrationName - The integration name
4012
+ * @returns Array of associated prompt templates
4013
+ */
4014
+ getPromptsWithIntegration(providerName: string, integrationName: string): Promise<MessageTemplate[]>;
4015
+ /**
4016
+ * Set tags for an integration
4017
+ * @param providerName - The provider name
4018
+ * @param integrationName - The integration name
4019
+ * @param tags - The tags to set
4020
+ */
4021
+ setIntegrationTags(providerName: string, integrationName: string, tags: Tag[]): Promise<void>;
4022
+ /**
4023
+ * Get tags for an integration
4024
+ * @param providerName - The provider name
4025
+ * @param integrationName - The integration name
4026
+ * @returns Array of tags
4027
+ */
4028
+ getIntegrationTags(providerName: string, integrationName: string): Promise<Tag[]>;
4029
+ /**
4030
+ * Delete tags from an integration
4031
+ * @param providerName - The provider name
4032
+ * @param integrationName - The integration name
4033
+ * @param tags - The tags to delete
4034
+ */
4035
+ deleteIntegrationTags(providerName: string, integrationName: string, tags: Tag[]): Promise<void>;
4036
+ /**
4037
+ * Set tags for an integration provider
4038
+ * @param providerName - The provider name
4039
+ * @param tags - The tags to set
4040
+ */
4041
+ setProviderTags(providerName: string, tags: Tag[]): Promise<void>;
4042
+ /**
4043
+ * Get tags for an integration provider
4044
+ * @param providerName - The provider name
4045
+ * @returns Array of tags
4046
+ */
4047
+ getProviderTags(providerName: string): Promise<Tag[]>;
4048
+ /**
4049
+ * Delete tags from an integration provider
4050
+ * @param providerName - The provider name
4051
+ * @param tags - The tags to delete
4052
+ */
4053
+ deleteProviderTags(providerName: string, tags: Tag[]): Promise<void>;
4054
+ }
4055
+
3642
4056
  declare class MetadataClient {
3643
4057
  readonly _client: Client;
3644
4058
  constructor(client: Client);
@@ -3701,6 +4115,142 @@ declare class MetadataClient {
3701
4115
  * @returns
3702
4116
  */
3703
4117
  unregisterWorkflow(workflowName: string, version?: number): Promise<void>;
4118
+ /**
4119
+ * Get all task definitions
4120
+ * @returns Array of all task definitions
4121
+ */
4122
+ getAllTaskDefs(): Promise<TaskDef[]>;
4123
+ /**
4124
+ * Get all workflow definitions
4125
+ * @returns Array of all workflow definitions
4126
+ */
4127
+ getAllWorkflowDefs(): Promise<WorkflowDef[]>;
4128
+ /**
4129
+ * Add a tag to a workflow definition
4130
+ * @param tag - The tag to add
4131
+ * @param name - The workflow definition name
4132
+ */
4133
+ addWorkflowTag(tag: Tag, name: string): Promise<void>;
4134
+ /**
4135
+ * Delete a tag from a workflow definition
4136
+ * @param tag - The tag to delete
4137
+ * @param name - The workflow definition name
4138
+ */
4139
+ deleteWorkflowTag(tag: Tag, name: string): Promise<void>;
4140
+ /**
4141
+ * Get all tags for a workflow definition
4142
+ * @param name - The workflow definition name
4143
+ * @returns Array of tags
4144
+ */
4145
+ getWorkflowTags(name: string): Promise<Tag[]>;
4146
+ /**
4147
+ * Set (replace all existing) tags for a workflow definition
4148
+ * @param tags - The tags to set
4149
+ * @param name - The workflow definition name
4150
+ */
4151
+ setWorkflowTags(tags: Tag[], name: string): Promise<void>;
4152
+ /**
4153
+ * Add a tag to a task definition
4154
+ * @param tag - The tag to add
4155
+ * @param taskName - The task definition name
4156
+ */
4157
+ addTaskTag(tag: Tag, taskName: string): Promise<void>;
4158
+ /**
4159
+ * Delete a tag from a task definition
4160
+ * @param tag - The tag to delete
4161
+ * @param taskName - The task definition name
4162
+ */
4163
+ deleteTaskTag(tag: Tag, taskName: string): Promise<void>;
4164
+ /**
4165
+ * Get all tags for a task definition
4166
+ * @param taskName - The task definition name
4167
+ * @returns Array of tags
4168
+ */
4169
+ getTaskTags(taskName: string): Promise<Tag[]>;
4170
+ /**
4171
+ * Set (replace all existing) tags for a task definition
4172
+ * @param tags - The tags to set
4173
+ * @param taskName - The task definition name
4174
+ */
4175
+ setTaskTags(tags: Tag[], taskName: string): Promise<void>;
4176
+ /**
4177
+ * Set the rate limit configuration for a workflow
4178
+ * @param rateLimitConfig - Rate limit configuration
4179
+ * @param name - Workflow definition name
4180
+ */
4181
+ setWorkflowRateLimit(rateLimitConfig: RateLimitConfig | ExtendedRateLimitConfig, name: string): Promise<void>;
4182
+ /**
4183
+ * Get the rate limit configuration for a workflow
4184
+ * @param name - Workflow definition name
4185
+ * @returns Rate limit configuration or undefined if not set
4186
+ */
4187
+ getWorkflowRateLimit(name: string): Promise<RateLimitConfig | ExtendedRateLimitConfig | undefined>;
4188
+ /**
4189
+ * Remove the rate limit configuration for a workflow
4190
+ * @param name - Workflow definition name
4191
+ */
4192
+ removeWorkflowRateLimit(name: string): Promise<void>;
4193
+ }
4194
+
4195
+ declare class PromptClient {
4196
+ readonly _client: Client;
4197
+ constructor(client: Client);
4198
+ /**
4199
+ * Save a prompt template
4200
+ * @param name - The prompt name
4201
+ * @param description - Description of the prompt
4202
+ * @param template - The prompt template text
4203
+ * @param models - Optional array of model names
4204
+ */
4205
+ savePrompt(name: string, description: string, template: string, models?: string[]): Promise<void>;
4206
+ /**
4207
+ * Update a prompt template
4208
+ * @param name - The prompt name
4209
+ * @param description - Description of the prompt
4210
+ * @param template - The prompt template text
4211
+ * @param models - Optional array of model names
4212
+ */
4213
+ updatePrompt(name: string, description: string, template: string, models?: string[]): Promise<void>;
4214
+ /**
4215
+ * Get a prompt template by name
4216
+ * @param name - The prompt name
4217
+ * @returns The message template
4218
+ */
4219
+ getPrompt(name: string): Promise<MessageTemplate>;
4220
+ /**
4221
+ * Get all prompt templates
4222
+ * @returns Array of message templates
4223
+ */
4224
+ getPrompts(): Promise<MessageTemplate[]>;
4225
+ /**
4226
+ * Delete a prompt template
4227
+ * @param name - The prompt name
4228
+ */
4229
+ deletePrompt(name: string): Promise<void>;
4230
+ /**
4231
+ * Test a prompt template against an LLM
4232
+ * @param testRequest - The test request containing prompt text, variables, model info, etc.
4233
+ * @returns The LLM response string
4234
+ */
4235
+ testPrompt(testRequest: PromptTemplateTestRequest): Promise<string>;
4236
+ /**
4237
+ * Get tags for a prompt template
4238
+ * @param name - The prompt name
4239
+ * @returns Array of tags
4240
+ */
4241
+ getPromptTags(name: string): Promise<Tag[]>;
4242
+ /**
4243
+ * Set tags for a prompt template
4244
+ * @param name - The prompt name
4245
+ * @param tags - The tags to set
4246
+ */
4247
+ setPromptTags(name: string, tags: Tag[]): Promise<void>;
4248
+ /**
4249
+ * Delete tags from a prompt template
4250
+ * @param name - The prompt name
4251
+ * @param tags - The tags to delete
4252
+ */
4253
+ deletePromptTags(name: string, tags: Tag[]): Promise<void>;
3704
4254
  }
3705
4255
 
3706
4256
  declare class SchedulerClient {
@@ -3783,6 +4333,120 @@ declare class SchedulerClient {
3783
4333
  * @throws ApiError
3784
4334
  */
3785
4335
  resumeAllSchedules(): Promise<void>;
4336
+ /**
4337
+ * Set tags for a schedule
4338
+ * @param tags - The tags to set
4339
+ * @param name - The schedule name
4340
+ */
4341
+ setSchedulerTags(tags: Tag[], name: string): Promise<void>;
4342
+ /**
4343
+ * Get tags for a schedule
4344
+ * @param name - The schedule name
4345
+ * @returns Array of tags
4346
+ */
4347
+ getSchedulerTags(name: string): Promise<Tag[]>;
4348
+ /**
4349
+ * Delete tags from a schedule
4350
+ * @param tags - The tags to delete
4351
+ * @param name - The schedule name
4352
+ */
4353
+ deleteSchedulerTags(tags: Tag[], name: string): Promise<void>;
4354
+ }
4355
+
4356
+ declare class SchemaClient {
4357
+ readonly _client: Client;
4358
+ constructor(client: Client);
4359
+ /**
4360
+ * Register (create or update) schemas
4361
+ * @param schemas - Array of schema definitions to register
4362
+ * @param newVersion - Whether to create a new version
4363
+ */
4364
+ registerSchema(schemas: SchemaDef[], newVersion?: boolean): Promise<void>;
4365
+ /**
4366
+ * Get a schema by name and version
4367
+ * @param name - The schema name
4368
+ * @param version - The schema version
4369
+ * @returns The schema definition
4370
+ */
4371
+ getSchema(name: string, version: number): Promise<SchemaDef>;
4372
+ /**
4373
+ * Get the latest version of a schema by name
4374
+ * @param name - The schema name
4375
+ * @returns The schema definition
4376
+ */
4377
+ getSchemaByName(name: string): Promise<SchemaDef>;
4378
+ /**
4379
+ * Get all schemas
4380
+ * @returns Array of all schema definitions
4381
+ */
4382
+ getAllSchemas(): Promise<SchemaDef[]>;
4383
+ /**
4384
+ * Delete a specific version of a schema
4385
+ * @param name - The schema name
4386
+ * @param version - The schema version
4387
+ */
4388
+ deleteSchema(name: string, version: number): Promise<void>;
4389
+ /**
4390
+ * Delete all versions of a schema by name
4391
+ * @param name - The schema name
4392
+ */
4393
+ deleteSchemaByName(name: string): Promise<void>;
4394
+ }
4395
+
4396
+ declare class SecretClient {
4397
+ readonly _client: Client;
4398
+ constructor(client: Client);
4399
+ /**
4400
+ * Store a secret value
4401
+ * @param key - The secret key
4402
+ * @param value - The secret value
4403
+ */
4404
+ putSecret(key: string, value: string): Promise<void>;
4405
+ /**
4406
+ * Get a secret value
4407
+ * @param key - The secret key
4408
+ * @returns The secret value
4409
+ */
4410
+ getSecret(key: string): Promise<string>;
4411
+ /**
4412
+ * Delete a secret
4413
+ * @param key - The secret key
4414
+ */
4415
+ deleteSecret(key: string): Promise<void>;
4416
+ /**
4417
+ * List all secret names
4418
+ * @returns Array of secret names
4419
+ */
4420
+ listAllSecretNames(): Promise<string[]>;
4421
+ /**
4422
+ * List secrets that the user can grant access to
4423
+ * @returns Array of secret names
4424
+ */
4425
+ listSecretsThatUserCanGrantAccessTo(): Promise<string[]>;
4426
+ /**
4427
+ * Check if a secret exists
4428
+ * @param key - The secret key
4429
+ * @returns Whether the secret exists
4430
+ */
4431
+ secretExists(key: string): Promise<boolean>;
4432
+ /**
4433
+ * Set tags for a secret
4434
+ * @param tags - The tags to set
4435
+ * @param key - The secret key
4436
+ */
4437
+ setSecretTags(tags: Tag[], key: string): Promise<void>;
4438
+ /**
4439
+ * Get tags for a secret
4440
+ * @param key - The secret key
4441
+ * @returns Array of tags
4442
+ */
4443
+ getSecretTags(key: string): Promise<Tag[]>;
4444
+ /**
4445
+ * Delete tags from a secret
4446
+ * @param tags - The tags to delete
4447
+ * @param key - The secret key
4448
+ */
4449
+ deleteSecretTags(tags: Tag[], key: string): Promise<void>;
3786
4450
  }
3787
4451
 
3788
4452
  /**
@@ -3916,6 +4580,40 @@ declare class TaskClient {
3916
4580
  * @returns
3917
4581
  */
3918
4582
  updateTaskResult(workflowId: string, taskRefName: string, status: TaskResultStatus, outputData: Record<string, unknown>): Promise<string>;
4583
+ /**
4584
+ * Add a log entry to a task
4585
+ * @param taskId - The task ID
4586
+ * @param message - The log message
4587
+ */
4588
+ addTaskLog(taskId: string, message: string): Promise<void>;
4589
+ /**
4590
+ * Get logs for a task
4591
+ * @param taskId - The task ID
4592
+ * @returns Array of task execution logs
4593
+ */
4594
+ getTaskLogs(taskId: string): Promise<TaskExecLog[]>;
4595
+ /**
4596
+ * Get queue sizes for task types
4597
+ * @param taskType - Optional array of task types to filter by
4598
+ * @returns Map of task type to queue size
4599
+ */
4600
+ getQueueSizeForTask(taskType?: string[]): Promise<Record<string, number>>;
4601
+ /**
4602
+ * Get poll data for a task type
4603
+ * @param taskType - The task type
4604
+ * @returns Array of poll data
4605
+ */
4606
+ getTaskPollData(taskType: string): Promise<PollData[]>;
4607
+ /**
4608
+ * Updates a task by reference name synchronously and returns the complete workflow
4609
+ * @param workflowId - The workflow instance ID
4610
+ * @param taskRefName - The task reference name
4611
+ * @param status - The task status
4612
+ * @param output - The task output data
4613
+ * @param workerId - Optional worker ID
4614
+ * @returns The updated workflow
4615
+ */
4616
+ updateTaskSync(workflowId: string, taskRefName: string, status: "IN_PROGRESS" | "FAILED" | "FAILED_WITH_TERMINAL_ERROR" | "COMPLETED", output: Record<string, unknown>, workerId?: string): Promise<Workflow>;
3919
4617
  }
3920
4618
 
3921
4619
  declare class TemplateClient {
@@ -4124,11 +4822,587 @@ declare class WorkflowExecutor {
4124
4822
  * @returns Promise<void>
4125
4823
  */
4126
4824
  signalAsync(workflowInstanceId: string, status: TaskResultStatusEnum, taskOutput: TaskResultOutputData): Promise<void>;
4825
+ /**
4826
+ * Deletes a workflow execution
4827
+ * @param workflowId - The workflow instance ID to delete
4828
+ * @param archiveWorkflow - Whether to archive the workflow before deletion
4829
+ */
4830
+ deleteWorkflow(workflowId: string, archiveWorkflow?: boolean): Promise<void>;
4831
+ /**
4832
+ * Gets workflows by correlation IDs
4833
+ * @param request - Correlation IDs search request containing workflow names and correlation IDs
4834
+ * @param includeClosed - Whether to include closed workflows
4835
+ * @param includeTasks - Whether to include task details
4836
+ * @returns Map of correlation ID to array of matching workflows
4837
+ */
4838
+ getByCorrelationIds(request: CorrelationIdsSearchRequest, includeClosed?: boolean, includeTasks?: boolean): Promise<Record<string, Workflow[]>>;
4839
+ /**
4840
+ * Tests a workflow execution with mock data
4841
+ * @param testRequest - The workflow test request containing workflow definition and mock task outputs
4842
+ * @returns The simulated workflow execution result
4843
+ */
4844
+ testWorkflow(testRequest: WorkflowTestRequest): Promise<Workflow>;
4845
+ /**
4846
+ * Updates workflow variables
4847
+ * @param workflowId - The workflow instance ID
4848
+ * @param variables - The variables to update
4849
+ * @returns The updated workflow
4850
+ */
4851
+ updateVariables(workflowId: string, variables: Record<string, unknown>): Promise<Workflow>;
4852
+ /**
4853
+ * Updates the workflow state (task result + variables) and optionally waits for further execution
4854
+ * @param workflowId - The workflow instance ID
4855
+ * @param updateRequest - The state update request containing task result and/or variables
4856
+ * @param requestId - A unique request ID for idempotency
4857
+ * @param waitUntilTaskRef - Optional task reference name to wait until
4858
+ * @param waitForSeconds - Optional number of seconds to wait
4859
+ * @returns The workflow run status after the update
4860
+ */
4861
+ updateState(workflowId: string, updateRequest: WorkflowStateUpdate, requestId: string, waitUntilTaskRef?: string, waitForSeconds?: number): Promise<WorkflowRun>;
4862
+ /**
4863
+ * Starts a workflow by name with input directly (without a StartWorkflowRequest object)
4864
+ * @param name - The workflow name
4865
+ * @param input - The workflow input data
4866
+ * @param version - Optional workflow version
4867
+ * @param correlationId - Optional correlation ID
4868
+ * @param priority - Optional priority
4869
+ * @returns The workflow instance ID
4870
+ */
4871
+ startWorkflowByName(name: string, input: Record<string, unknown>, version?: number, correlationId?: string, priority?: number): Promise<string>;
4872
+ }
4873
+
4874
+ /**
4875
+ * Factory class that provides access to all Conductor client instances.
4876
+ * Equivalent to Python SDK's `OrkesClients`.
4877
+ *
4878
+ * Usage:
4879
+ * ```typescript
4880
+ * const clients = await OrkesClients.from({ serverUrl, keyId, keySecret });
4881
+ * const workflowClient = clients.getWorkflowClient();
4882
+ * const metadataClient = clients.getMetadataClient();
4883
+ * ```
4884
+ */
4885
+ declare class OrkesClients {
4886
+ private readonly _client;
4887
+ constructor(client: Client);
4888
+ /**
4889
+ * Creates an OrkesClients instance from configuration.
4890
+ * Handles authentication and connection setup.
4891
+ */
4892
+ static from(config?: OrkesApiConfig): Promise<OrkesClients>;
4893
+ /** Returns the underlying HTTP client */
4894
+ getClient(): Client;
4895
+ getWorkflowClient(): WorkflowExecutor;
4896
+ getMetadataClient(): MetadataClient;
4897
+ getTaskClient(): TaskClient;
4898
+ getSchedulerClient(): SchedulerClient;
4899
+ getSecretClient(): SecretClient;
4900
+ getSchemaClient(): SchemaClient;
4901
+ getAuthorizationClient(): AuthorizationClient;
4902
+ getIntegrationClient(): IntegrationClient;
4903
+ getPromptClient(): PromptClient;
4904
+ getApplicationClient(): ApplicationClient;
4905
+ getEventClient(): EventClient;
4906
+ getHumanClient(): HumanExecutor;
4907
+ getTemplateClient(): TemplateClient;
4908
+ getServiceRegistryClient(): ServiceRegistryClient;
4909
+ }
4910
+
4911
+ /**
4912
+ * Event types for task runner lifecycle events.
4913
+ *
4914
+ * These events provide observability into the worker polling and execution lifecycle,
4915
+ * matching the Python SDK's event system architecture.
4916
+ */
4917
+ /**
4918
+ * Base interface for all task runner events.
4919
+ */
4920
+ interface TaskRunnerEvent {
4921
+ /** The task definition name */
4922
+ taskType: string;
4923
+ /** UTC timestamp when the event was created */
4924
+ timestamp: Date;
4925
+ }
4926
+ /**
4927
+ * Event published when task polling begins.
4928
+ */
4929
+ interface PollStarted extends TaskRunnerEvent {
4930
+ /** Identifier of the worker polling for tasks */
4931
+ workerId: string;
4932
+ /** Number of tasks requested in this poll */
4933
+ pollCount: number;
4934
+ }
4935
+ /**
4936
+ * Event published when task polling completes successfully.
4937
+ */
4938
+ interface PollCompleted extends TaskRunnerEvent {
4939
+ /** Time taken for the poll operation in milliseconds */
4940
+ durationMs: number;
4941
+ /** Number of tasks received from the poll */
4942
+ tasksReceived: number;
4943
+ }
4944
+ /**
4945
+ * Event published when task polling fails.
4946
+ */
4947
+ interface PollFailure extends TaskRunnerEvent {
4948
+ /** Time taken before the poll failed in milliseconds */
4949
+ durationMs: number;
4950
+ /** The error that caused the failure */
4951
+ cause: Error;
4952
+ }
4953
+ /**
4954
+ * Event published when task execution begins.
4955
+ */
4956
+ interface TaskExecutionStarted extends TaskRunnerEvent {
4957
+ /** Unique identifier of the task instance */
4958
+ taskId: string;
4959
+ /** Identifier of the worker executing the task */
4960
+ workerId: string;
4961
+ /** ID of the workflow instance this task belongs to */
4962
+ workflowInstanceId?: string;
4963
+ }
4964
+ /**
4965
+ * Event published when task execution completes successfully.
4966
+ */
4967
+ interface TaskExecutionCompleted extends TaskRunnerEvent {
4968
+ /** Unique identifier of the task instance */
4969
+ taskId: string;
4970
+ /** Identifier of the worker that executed the task */
4971
+ workerId: string;
4972
+ /** ID of the workflow instance this task belongs to */
4973
+ workflowInstanceId?: string;
4974
+ /** Time taken for task execution in milliseconds */
4975
+ durationMs: number;
4976
+ /** Size of the task output in bytes (if available) */
4977
+ outputSizeBytes?: number;
4978
+ }
4979
+ /**
4980
+ * Event published when task execution fails.
4981
+ */
4982
+ interface TaskExecutionFailure extends TaskRunnerEvent {
4983
+ /** Unique identifier of the task instance */
4984
+ taskId: string;
4985
+ /** Identifier of the worker that attempted execution */
4986
+ workerId: string;
4987
+ /** ID of the workflow instance this task belongs to */
4988
+ workflowInstanceId?: string;
4989
+ /** The error that caused the failure */
4990
+ cause: Error;
4991
+ /** Time taken before failure in milliseconds */
4992
+ durationMs: number;
4993
+ }
4994
+ /**
4995
+ * Event published when task update fails after all retry attempts.
4996
+ *
4997
+ * This is a CRITICAL event indicating that the worker successfully executed a task
4998
+ * but failed to communicate the result back to Conductor after multiple retries.
4999
+ *
5000
+ * The task result is lost from Conductor's perspective, and external intervention
5001
+ * may be required to reconcile the state.
5002
+ *
5003
+ * Use Cases:
5004
+ * - Alert operations team of critical update failures
5005
+ * - Log failed task results to external storage for recovery
5006
+ * - Implement custom retry logic with different backoff strategies
5007
+ * - Track update reliability metrics
5008
+ * - Trigger incident response workflows
5009
+ */
5010
+ interface TaskUpdateFailure extends TaskRunnerEvent {
5011
+ /** Unique identifier of the task instance */
5012
+ taskId: string;
5013
+ /** Identifier of the worker that executed the task */
5014
+ workerId: string;
5015
+ /** ID of the workflow instance this task belongs to */
5016
+ workflowInstanceId?: string;
5017
+ /** The error that caused the final update failure */
5018
+ cause: Error;
5019
+ /** Number of retry attempts made */
5020
+ retryCount: number;
5021
+ /** The TaskResult object that failed to update (for recovery/logging) */
5022
+ taskResult: unknown;
5023
+ }
5024
+ /**
5025
+ * Event published when task update completes successfully.
5026
+ */
5027
+ interface TaskUpdateCompleted extends TaskRunnerEvent {
5028
+ /** Unique identifier of the task instance */
5029
+ taskId: string;
5030
+ /** Identifier of the worker that executed the task */
5031
+ workerId: string;
5032
+ /** ID of the workflow instance this task belongs to */
5033
+ workflowInstanceId?: string;
5034
+ /** Time taken for the update API call in milliseconds */
5035
+ durationMs: number;
5036
+ }
5037
+ /**
5038
+ * Union type of all task runner events.
5039
+ */
5040
+ type TaskRunnerEventType = PollStarted | PollCompleted | PollFailure | TaskExecutionStarted | TaskExecutionCompleted | TaskExecutionFailure | TaskUpdateCompleted | TaskUpdateFailure;
5041
+
5042
+ /**
5043
+ * Interface for task runner event listeners.
5044
+ *
5045
+ * All methods are optional - implement only the events you need to handle.
5046
+ * Listener failures are isolated and will not affect task execution.
5047
+ */
5048
+ interface TaskRunnerEventsListener {
5049
+ /**
5050
+ * Called when task polling begins.
5051
+ */
5052
+ onPollStarted?(event: PollStarted): void | Promise<void>;
5053
+ /**
5054
+ * Called when task polling completes successfully.
5055
+ */
5056
+ onPollCompleted?(event: PollCompleted): void | Promise<void>;
5057
+ /**
5058
+ * Called when task polling fails.
5059
+ */
5060
+ onPollFailure?(event: PollFailure): void | Promise<void>;
5061
+ /**
5062
+ * Called when task execution begins.
5063
+ */
5064
+ onTaskExecutionStarted?(event: TaskExecutionStarted): void | Promise<void>;
5065
+ /**
5066
+ * Called when task execution completes successfully.
5067
+ */
5068
+ onTaskExecutionCompleted?(event: TaskExecutionCompleted): void | Promise<void>;
5069
+ /**
5070
+ * Called when task execution fails.
5071
+ */
5072
+ onTaskExecutionFailure?(event: TaskExecutionFailure): void | Promise<void>;
5073
+ /**
5074
+ * Called when task update completes successfully.
5075
+ */
5076
+ onTaskUpdateCompleted?(event: TaskUpdateCompleted): void | Promise<void>;
5077
+ /**
5078
+ * Called when task update fails after all retry attempts.
5079
+ * This is a CRITICAL event that may require operational intervention.
5080
+ */
5081
+ onTaskUpdateFailure?(event: TaskUpdateFailure): void | Promise<void>;
5082
+ }
5083
+ /**
5084
+ * Event dispatcher for task runner events.
5085
+ *
5086
+ * Provides a decoupled event system for observability and metrics collection.
5087
+ * Events are published asynchronously and listener failures are isolated.
5088
+ */
5089
+ declare class EventDispatcher {
5090
+ private listeners;
5091
+ private logger?;
5092
+ constructor(logger?: ConductorLogger);
5093
+ /**
5094
+ * Register an event listener.
5095
+ *
5096
+ * @param listener - The listener to register
5097
+ */
5098
+ register(listener: TaskRunnerEventsListener): void;
5099
+ /**
5100
+ * Unregister an event listener.
5101
+ *
5102
+ * @param listener - The listener to unregister
5103
+ */
5104
+ unregister(listener: TaskRunnerEventsListener): void;
5105
+ /**
5106
+ * Publish a PollStarted event.
5107
+ */
5108
+ publishPollStarted(event: PollStarted): Promise<void>;
5109
+ /**
5110
+ * Publish a PollCompleted event.
5111
+ */
5112
+ publishPollCompleted(event: PollCompleted): Promise<void>;
5113
+ /**
5114
+ * Publish a PollFailure event.
5115
+ */
5116
+ publishPollFailure(event: PollFailure): Promise<void>;
5117
+ /**
5118
+ * Publish a TaskExecutionStarted event.
5119
+ */
5120
+ publishTaskExecutionStarted(event: TaskExecutionStarted): Promise<void>;
5121
+ /**
5122
+ * Publish a TaskExecutionCompleted event.
5123
+ */
5124
+ publishTaskExecutionCompleted(event: TaskExecutionCompleted): Promise<void>;
5125
+ /**
5126
+ * Publish a TaskExecutionFailure event.
5127
+ */
5128
+ publishTaskExecutionFailure(event: TaskExecutionFailure): Promise<void>;
5129
+ /**
5130
+ * Publish a TaskUpdateCompleted event.
5131
+ */
5132
+ publishTaskUpdateCompleted(event: TaskUpdateCompleted): Promise<void>;
5133
+ /**
5134
+ * Publish a TaskUpdateFailure event.
5135
+ */
5136
+ publishTaskUpdateFailure(event: TaskUpdateFailure): Promise<void>;
5137
+ /**
5138
+ * Internal method to publish events to all registered listeners.
5139
+ * Listener failures are caught and logged to prevent affecting task execution.
5140
+ */
5141
+ private publishEvent;
5142
+ }
5143
+
5144
+ type TaskErrorHandler = (error: Error, task?: Task) => void;
5145
+ /**
5146
+ * Return type for long-running tasks.
5147
+ *
5148
+ * When a worker returns this, the task is sent to Conductor with IN_PROGRESS status
5149
+ * and Conductor will re-queue the task after `callbackAfterSeconds`.
5150
+ *
5151
+ * @example
5152
+ * ```typescript
5153
+ * @worker({ taskDefName: "long_running_task" })
5154
+ * async function longTask(task: Task): Promise<TaskInProgressResult | TaskResult> {
5155
+ * if (!isReady()) {
5156
+ * return { status: "IN_PROGRESS", callbackAfterSeconds: 30, outputData: { progress: 50 } };
5157
+ * }
5158
+ * return { status: "COMPLETED", outputData: { result: "done" } };
5159
+ * }
5160
+ * ```
5161
+ */
5162
+ interface TaskInProgressResult {
5163
+ status: "IN_PROGRESS";
5164
+ callbackAfterSeconds: number;
5165
+ outputData?: Record<string, unknown>;
5166
+ }
5167
+ /**
5168
+ * Type guard for TaskInProgressResult.
5169
+ */
5170
+ declare function isTaskInProgress(result: unknown): result is TaskInProgressResult;
5171
+ interface ConductorWorker {
5172
+ taskDefName: string;
5173
+ execute: (task: Task) => Promise<Omit<TaskResult, "workflowInstanceId" | "taskId"> | TaskInProgressResult>;
5174
+ domain?: string;
5175
+ /** Number of polling instances to run concurrently */
5176
+ concurrency?: number;
5177
+ pollInterval?: number;
5178
+ }
5179
+ interface TaskRunnerOptions {
5180
+ workerID: string;
5181
+ domain: string | undefined;
5182
+ pollInterval?: number;
5183
+ concurrency?: number;
5184
+ batchPollingTimeout?: number;
5185
+ }
5186
+ interface RunnerArgs {
5187
+ worker: ConductorWorker;
5188
+ client: Client;
5189
+ options: TaskRunnerOptions;
5190
+ logger?: ConductorLogger;
5191
+ onError?: TaskErrorHandler;
5192
+ concurrency?: number;
5193
+ maxRetries?: number;
5194
+ eventListeners?: TaskRunnerEventsListener[];
5195
+ }
5196
+ interface PollerOptions {
5197
+ pollInterval?: number;
5198
+ concurrency: number;
5199
+ warnAtO?: number;
5200
+ /** Enable adaptive backoff for empty polls (default: true) */
5201
+ adaptiveBackoff?: boolean;
5202
+ /** Whether this poller is paused (default: false) */
5203
+ paused?: boolean;
5204
+ }
5205
+ /**
5206
+ * Configuration for health monitoring of worker processes.
5207
+ */
5208
+ interface HealthMonitorConfig {
5209
+ /** Interval between health checks in ms (default: 5000) */
5210
+ healthCheckIntervalMs?: number;
5211
+ /** Maximum restart attempts, 0 = unlimited (default: 0) */
5212
+ maxRestartAttempts?: number;
5213
+ /** Whether health monitoring is enabled (default: true) */
5214
+ enabled?: boolean;
5215
+ }
5216
+ type TaskManagerOptions = TaskRunnerOptions;
5217
+ interface TaskManagerConfig {
5218
+ logger?: ConductorLogger;
5219
+ options?: Partial<TaskManagerOptions>;
5220
+ onError?: TaskErrorHandler;
5221
+ maxRetries?: number;
5222
+ eventListeners?: TaskRunnerEventsListener[];
5223
+ }
5224
+
5225
+ /**
5226
+ * Responsible for initializing and managing the runners that poll and work different task queues.
5227
+ */
5228
+ declare class TaskManager {
5229
+ private workerRunners;
5230
+ private readonly client;
5231
+ private readonly logger;
5232
+ private readonly errorHandler;
5233
+ private workers;
5234
+ readonly options: Required<TaskManagerOptions>;
5235
+ private polling;
5236
+ private maxRetries;
5237
+ private eventListeners;
5238
+ constructor(client: Client, workers: ConductorWorker[], config?: TaskManagerConfig);
5239
+ private workerManagerWorkerOptions;
5240
+ get isPolling(): boolean;
5241
+ updatePollingOptionForWorker: (workerTaskDefName: string, options: Partial<TaskManagerOptions>) => void;
5242
+ /**
5243
+ * new options will get merged to existing options
5244
+ * @param options new options to update polling options
5245
+ */
5246
+ updatePollingOptions: (options: Partial<TaskManagerOptions>) => void;
5247
+ sanityCheck: () => void;
5248
+ /**
5249
+ * Start polling for tasks
5250
+ */
5251
+ startPolling: () => void;
5252
+ /**
5253
+ * Stops polling for tasks
5254
+ */
5255
+ stopPolling: () => Promise<void>;
5256
+ }
5257
+
5258
+ /**
5259
+ * Responsible for polling and executing tasks from a queue.
5260
+ *
5261
+ * Because a `poll` in conductor "pops" a task off of a conductor queue,
5262
+ * each runner participates in the poll -> work -> update loop.
5263
+ * We could potentially split this work into a separate "poller" and "worker" pools
5264
+ * but that could lead to picking up more work than the pool of workers are actually able to handle.
5265
+ *
5266
+ */
5267
+ declare class TaskRunner {
5268
+ _client: Client;
5269
+ worker: ConductorWorker;
5270
+ private logger;
5271
+ private options;
5272
+ errorHandler: TaskErrorHandler;
5273
+ private poller;
5274
+ private maxRetries;
5275
+ private eventDispatcher;
5276
+ constructor({ worker, client, options, logger, onError: errorHandler, maxRetries, eventListeners, }: RunnerArgs);
5277
+ get isPolling(): boolean;
5278
+ /**
5279
+ * Starts polling for work
5280
+ */
5281
+ startPolling: () => void;
5282
+ /**
5283
+ * Stops Polling for work
5284
+ */
5285
+ stopPolling: () => Promise<void>;
5286
+ updateOptions(options: Partial<TaskRunnerOptions>): void;
5287
+ /** Pause or unpause the worker's polling */
5288
+ setPaused(paused: boolean): void;
5289
+ get isPaused(): boolean;
5290
+ get getOptions(): TaskRunnerOptions;
5291
+ private batchPoll;
5292
+ updateTaskWithRetry: (task: Task, taskResult: TaskResult) => Promise<Task | undefined>;
5293
+ private isValidTask;
5294
+ /**
5295
+ * Entry point for task execution with V2 chaining.
5296
+ *
5297
+ * When updateTaskV2 returns a next task in its response, we immediately
5298
+ * execute it without going back through the poll cycle. This eliminates
5299
+ * one HTTP round-trip + sleep per task when there is a backlog.
5300
+ */
5301
+ private executeTask;
5302
+ /**
5303
+ * Execute a single task and return the next task from V2 response (if any).
5304
+ */
5305
+ private executeOneTask;
5306
+ handleUnknownError: (unknownError: unknown) => void;
5307
+ }
5308
+
5309
+ declare class Poller<T> {
5310
+ private timeoutHandler?;
5311
+ private pollFunction;
5312
+ private performWorkFunction;
5313
+ private polling;
5314
+ private _tasksInProcess;
5315
+ private _counterAtO;
5316
+ private _pollerId;
5317
+ private _consecutiveEmptyPolls;
5318
+ private _lastPollTime;
5319
+ private _authFailures;
5320
+ private _lastAuthFailureAt;
5321
+ options: PollerOptions;
5322
+ logger: ConductorLogger;
5323
+ constructor(pollerId: string, pollFunction: (count: number) => Promise<T[] | undefined>, performWorkFunction: (work: T) => Promise<void>, pollerOptions?: Partial<PollerOptions>, logger?: ConductorLogger);
5324
+ get isPolling(): boolean;
5325
+ get tasksInProcess(): number;
5326
+ get consecutiveEmptyPolls(): number;
5327
+ get authFailures(): number;
5328
+ /**
5329
+ * Starts polling for work
5330
+ */
5331
+ startPolling: () => void;
5332
+ /**
5333
+ * Stops Polling for work
5334
+ */
5335
+ stopPolling: () => Promise<void>;
5336
+ private performWork;
5337
+ updateOptions(options: Partial<PollerOptions>): void;
5338
+ /**
5339
+ * Detect if an error is an authentication/authorization failure.
5340
+ */
5341
+ private isAuthError;
5342
+ /**
5343
+ * Calculate adaptive backoff delay for empty polls.
5344
+ *
5345
+ * Matches Python SDK: min(BASE_MS * 2^min(count, MAX_EXPONENT), pollInterval)
5346
+ * Sequence: 1ms, 2ms, 4ms, 8ms, 16ms, ... 1024ms, then capped at pollInterval
5347
+ */
5348
+ private calculateAdaptiveDelay;
5349
+ /**
5350
+ * Calculate auth failure backoff delay in milliseconds.
5351
+ *
5352
+ * Matches Python SDK: min(2^failures, 60) seconds
5353
+ */
5354
+ private calculateAuthBackoffMs;
5355
+ /** Promise-based sleep that resolves immediately if polling has stopped */
5356
+ private sleep;
5357
+ private poll;
5358
+ }
5359
+
5360
+ /**
5361
+ * Custom exception types for worker error handling.
5362
+ */
5363
+ /**
5364
+ * Exception indicating a non-retryable task failure.
5365
+ *
5366
+ * When thrown from a worker's execute function, the task will be marked as
5367
+ * FAILED_WITH_TERMINAL_ERROR and will NOT be retried, regardless of the
5368
+ * task definition's retry_count setting.
5369
+ *
5370
+ * Use this for permanent failures where retry would produce the same result:
5371
+ * - Business validation failures (invalid data format)
5372
+ * - Authorization failures (user lacks permission)
5373
+ * - Resource not found (entity doesn't exist)
5374
+ * - Configuration errors (missing required config)
5375
+ * - Data integrity violations (constraint violations)
5376
+ * - Unsupported operations (feature not available)
5377
+ *
5378
+ * @example
5379
+ * ```typescript
5380
+ * async function validateOrder(task: Task) {
5381
+ * const order = await getOrder(task.inputData.orderId);
5382
+ *
5383
+ * if (!order) {
5384
+ * // Order doesn't exist - retry won't help
5385
+ * throw new NonRetryableException(`Order ${task.inputData.orderId} not found`);
5386
+ * }
5387
+ *
5388
+ * if (order.status === 'CANCELLED') {
5389
+ * // Business rule - retry won't help
5390
+ * throw new NonRetryableException('Cannot process cancelled order');
5391
+ * }
5392
+ *
5393
+ * return { status: 'COMPLETED', outputData: { validated: true } };
5394
+ * }
5395
+ * ```
5396
+ */
5397
+ declare class NonRetryableException extends Error {
5398
+ constructor(message: string);
4127
5399
  }
4128
5400
 
4129
5401
  declare const doWhileTask: (taskRefName: string, terminationCondition: string, tasks: TaskDefTypes[], optional?: boolean) => DoWhileTaskDef;
4130
5402
  declare const newLoopTask: (taskRefName: string, iterations: number, tasks: TaskDefTypes[], optional?: boolean) => DoWhileTaskDef;
4131
5403
 
5404
+ declare const dynamicTask: (taskReferenceName: string, dynamicTaskName: string, dynamicTaskParam?: string, optional?: boolean) => WorkflowTask;
5405
+
4132
5406
  declare const dynamicForkTask: (taskReferenceName: string, preForkTasks?: TaskDefTypes[], dynamicTasksInput?: string, optional?: boolean) => ForkJoinDynamicDef;
4133
5407
 
4134
5408
  declare const eventTask: (taskReferenceName: string, eventPrefix: string, eventSuffix: string, optional?: boolean) => EventTaskDef;
@@ -4138,8 +5412,40 @@ declare const conductorEventTask: (taskReferenceName: string, eventName: string,
4138
5412
  declare const forkTask: (taskReferenceName: string, forkTasks: TaskDefTypes[]) => ForkJoinTaskDef;
4139
5413
  declare const forkTaskJoin: (taskReferenceName: string, forkTasks: TaskDefTypes[], optional?: boolean) => [ForkJoinTaskDef, JoinTaskDef];
4140
5414
 
5415
+ interface GetDocumentOptions {
5416
+ /** Media type of the document (e.g. "application/pdf") */
5417
+ mediaType?: string;
5418
+ optional?: boolean;
5419
+ }
5420
+ declare const getDocumentTask: (taskReferenceName: string, url: string, options?: GetDocumentOptions) => WorkflowTask;
5421
+
4141
5422
  declare const httpTask: (taskReferenceName: string, inputParameters: HttpInputParameters, asyncComplete?: boolean, optional?: boolean) => HttpTaskDef;
4142
5423
 
5424
+ interface HttpPollInputParameters {
5425
+ http_request: HttpInputParameters;
5426
+ /** Polling interval in seconds */
5427
+ pollingInterval?: number;
5428
+ /** Polling strategy: FIXED or LINEAR_BACKOFF */
5429
+ pollingStrategy?: "FIXED" | "LINEAR_BACKOFF";
5430
+ /** Condition expression to terminate polling (e.g. "$.status === 'COMPLETED'") */
5431
+ terminationCondition?: string;
5432
+ }
5433
+ declare const httpPollTask: (taskReferenceName: string, inputParameters: HttpPollInputParameters, optional?: boolean) => WorkflowTask;
5434
+
5435
+ type AssignmentCompletionStrategy = "LEAVE_OPEN" | "TERMINATE";
5436
+ interface HumanTaskOptions {
5437
+ displayName?: string;
5438
+ formTemplate?: string;
5439
+ formVersion?: number;
5440
+ assignmentCompletionStrategy?: AssignmentCompletionStrategy;
5441
+ assignee?: {
5442
+ userType: "EXTERNAL_USER" | "EXTERNAL_GROUP";
5443
+ user: string;
5444
+ };
5445
+ optional?: boolean;
5446
+ }
5447
+ declare const humanTask: (taskReferenceName: string, options?: HumanTaskOptions) => WorkflowTask;
5448
+
4143
5449
  declare const inlineTask: (taskReferenceName: string, script: string, evaluatorType?: "javascript" | "graaljs", optional?: boolean) => InlineTaskDef;
4144
5450
 
4145
5451
  declare const joinTask: (taskReferenceName: string, joinOn: string[], optional?: boolean) => JoinTaskDef;
@@ -4152,6 +5458,8 @@ declare const setVariableTask: (taskReferenceName: string, inputParameters: Reco
4152
5458
 
4153
5459
  declare const simpleTask: (taskReferenceName: string, name: string, inputParameters: Record<string, unknown>, optional?: boolean) => SimpleTaskDef;
4154
5460
 
5461
+ declare const startWorkflowTask: (taskReferenceName: string, workflowName: string, input?: Record<string, unknown>, version?: number, correlationId?: string, optional?: boolean) => WorkflowTask;
5462
+
4155
5463
  declare const subWorkflowTask: (taskReferenceName: string, workflowName: string, version?: number, optional?: boolean) => SubWorkflowTaskDef;
4156
5464
 
4157
5465
  declare const switchTask: (taskReferenceName: string, expression: string, decisionCases?: Record<string, TaskDefTypes[]>, defaultCase?: TaskDefTypes[], optional?: boolean) => SwitchTaskDef;
@@ -4161,10 +5469,338 @@ declare const terminateTask: (taskReferenceName: string, status: "COMPLETED" | "
4161
5469
  declare const waitTaskDuration: (taskReferenceName: string, duration: string, optional?: boolean) => WaitTaskDef;
4162
5470
  declare const waitTaskUntil: (taskReferenceName: string, until: string, optional?: boolean) => WaitTaskDef;
4163
5471
 
5472
+ interface WaitForWebhookOptions {
5473
+ /** Match conditions for incoming webhook (key-value pairs) */
5474
+ matches?: Record<string, unknown>;
5475
+ optional?: boolean;
5476
+ }
5477
+ declare const waitForWebhookTask: (taskReferenceName: string, options?: WaitForWebhookOptions) => WorkflowTask;
5478
+
5479
+ declare enum Role {
5480
+ USER = "user",
5481
+ ASSISTANT = "assistant",
5482
+ SYSTEM = "system",
5483
+ TOOL_CALL = "tool_call",
5484
+ TOOL = "tool"
5485
+ }
5486
+ /** LLM provider identifiers matching the Python SDK's LLMProvider enum. */
5487
+ declare enum LLMProvider {
5488
+ OPEN_AI = "openai",
5489
+ AZURE_OPEN_AI = "azure_openai",
5490
+ VERTEX_AI = "vertex_ai",
5491
+ HUGGING_FACE = "huggingface",
5492
+ ANTHROPIC = "anthropic",
5493
+ BEDROCK = "bedrock",
5494
+ COHERE = "cohere",
5495
+ GROK = "Grok",
5496
+ MISTRAL = "mistral",
5497
+ OLLAMA = "ollama",
5498
+ PERPLEXITY = "perplexity"
5499
+ }
5500
+ /** Vector database identifiers matching the Python SDK's VectorDB enum. */
5501
+ declare enum VectorDB {
5502
+ PINECONE_DB = "pineconedb",
5503
+ WEAVIATE_DB = "weaviatedb",
5504
+ POSTGRES_VECTOR_DB = "pgvectordb",
5505
+ MONGO_VECTOR_DB = "mongovectordb"
5506
+ }
5507
+ interface ToolCall {
5508
+ name: string;
5509
+ taskReferenceName?: string;
5510
+ type?: string;
5511
+ inputParameters?: Record<string, unknown>;
5512
+ output?: Record<string, unknown>;
5513
+ }
5514
+ interface ChatMessage {
5515
+ role: Role;
5516
+ message: string;
5517
+ media?: string[];
5518
+ mimeType?: string;
5519
+ toolCalls?: ToolCall[];
5520
+ }
5521
+ interface ToolSpec {
5522
+ name: string;
5523
+ type?: string;
5524
+ description?: string;
5525
+ inputSchema?: Record<string, unknown>;
5526
+ outputSchema?: Record<string, unknown>;
5527
+ }
5528
+ interface EmbeddingModel {
5529
+ provider: string;
5530
+ model: string;
5531
+ }
5532
+ interface LlmCompletionParams {
5533
+ temperature?: number;
5534
+ topP?: number;
5535
+ topK?: number;
5536
+ maxTokens?: number;
5537
+ frequencyPenalty?: number;
5538
+ presencePenalty?: number;
5539
+ stopWords?: string[];
5540
+ maxResults?: number;
5541
+ }
5542
+ /** Base configuration for AI integrations. */
5543
+ interface IntegrationConfig {
5544
+ provider: string;
5545
+ description?: string;
5546
+ [key: string]: unknown;
5547
+ }
5548
+ /** OpenAI integration configuration. */
5549
+ interface OpenAIConfig extends IntegrationConfig {
5550
+ provider: "openai";
5551
+ apiKey: string;
5552
+ organizationId?: string;
5553
+ }
5554
+ /** Azure OpenAI integration configuration. */
5555
+ interface AzureOpenAIConfig extends IntegrationConfig {
5556
+ provider: "azure_openai";
5557
+ apiKey: string;
5558
+ endpoint: string;
5559
+ deploymentName?: string;
5560
+ }
5561
+ /** Weaviate vector database configuration. */
5562
+ interface WeaviateConfig extends IntegrationConfig {
5563
+ provider: "weaviatedb";
5564
+ apiKey: string;
5565
+ endpoint: string;
5566
+ }
5567
+ /** Pinecone vector database configuration. */
5568
+ interface PineconeConfig extends IntegrationConfig {
5569
+ provider: "pineconedb";
5570
+ apiKey: string;
5571
+ environment?: string;
5572
+ projectName?: string;
5573
+ }
5574
+
5575
+ interface LlmChatCompleteOptions extends LlmCompletionParams {
5576
+ messages?: ChatMessage[];
5577
+ instructionsTemplate?: string;
5578
+ promptVariables?: Record<string, unknown>;
5579
+ promptVersion?: number;
5580
+ userInput?: string;
5581
+ tools?: ToolSpec[];
5582
+ jsonOutput?: boolean;
5583
+ outputSchema?: Record<string, unknown>;
5584
+ outputMimeType?: string;
5585
+ outputLocation?: string;
5586
+ googleSearchRetrieval?: boolean;
5587
+ inputSchema?: Record<string, unknown>;
5588
+ thinkingTokenLimit?: number;
5589
+ reasoningEffort?: string;
5590
+ voice?: string;
5591
+ participants?: string[];
5592
+ }
5593
+ declare const llmChatCompleteTask: (taskReferenceName: string, provider: string, model: string, options?: LlmChatCompleteOptions) => WorkflowTask;
5594
+
5595
+ interface LlmTextCompleteOptions extends LlmCompletionParams {
5596
+ promptVariables?: Record<string, unknown>;
5597
+ promptVersion?: number;
5598
+ jsonOutput?: boolean;
5599
+ }
5600
+ declare const llmTextCompleteTask: (taskReferenceName: string, provider: string, model: string, promptName: string, options?: LlmTextCompleteOptions) => WorkflowTask;
5601
+
5602
+ interface LlmGenerateEmbeddingsOptions {
5603
+ instructions?: string;
5604
+ dimensions?: number;
5605
+ }
5606
+ declare const llmGenerateEmbeddingsTask: (taskReferenceName: string, provider: string, model: string, text: string, options?: LlmGenerateEmbeddingsOptions) => WorkflowTask;
5607
+
5608
+ interface LlmIndexTextOptions {
5609
+ namespace?: string;
5610
+ metadata?: Record<string, unknown>;
5611
+ url?: string;
5612
+ chunkSize?: number;
5613
+ chunkOverlap?: number;
5614
+ dimensions?: number;
5615
+ }
5616
+ declare const llmIndexTextTask: (taskReferenceName: string, vectorDb: string, index: string, embeddingModel: EmbeddingModel, text: string, docId: string, options?: LlmIndexTextOptions) => WorkflowTask;
5617
+
5618
+ interface LlmIndexDocumentOptions {
5619
+ namespace?: string;
5620
+ chunkSize?: number;
5621
+ chunkOverlap?: number;
5622
+ docId?: string;
5623
+ metadata?: Record<string, unknown>;
5624
+ dimensions?: number;
5625
+ }
5626
+ declare const llmIndexDocumentTask: (taskReferenceName: string, vectorDb: string, index: string, embeddingModel: EmbeddingModel, url: string, mediaType: string, options?: LlmIndexDocumentOptions) => WorkflowTask;
5627
+
5628
+ interface LlmSearchIndexOptions {
5629
+ namespace?: string;
5630
+ maxResults?: number;
5631
+ dimensions?: number;
5632
+ }
5633
+ declare const llmSearchIndexTask: (taskReferenceName: string, vectorDb: string, index: string, embeddingModel: EmbeddingModel, query: string, options?: LlmSearchIndexOptions) => WorkflowTask;
5634
+
5635
+ interface LlmSearchEmbeddingsOptions {
5636
+ namespace?: string;
5637
+ maxResults?: number;
5638
+ }
5639
+ declare const llmSearchEmbeddingsTask: (taskReferenceName: string, vectorDb: string, index: string, embeddings: number[], options?: LlmSearchEmbeddingsOptions) => WorkflowTask;
5640
+
5641
+ interface LlmStoreEmbeddingsOptions {
5642
+ namespace?: string;
5643
+ docId?: string;
5644
+ metadata?: Record<string, unknown>;
5645
+ }
5646
+ declare const llmStoreEmbeddingsTask: (taskReferenceName: string, vectorDb: string, index: string, embeddings: number[], options?: LlmStoreEmbeddingsOptions) => WorkflowTask;
5647
+
5648
+ interface LlmQueryEmbeddingsOptions {
5649
+ namespace?: string;
5650
+ }
5651
+ declare const llmQueryEmbeddingsTask: (taskReferenceName: string, vectorDb: string, index: string, embeddings: number[], options?: LlmQueryEmbeddingsOptions) => WorkflowTask;
5652
+
5653
+ interface GenerateImageOptions {
5654
+ imageCount?: number;
5655
+ width?: number;
5656
+ height?: number;
5657
+ }
5658
+ declare const generateImageTask: (taskReferenceName: string, provider: string, model: string, prompt: string, options?: GenerateImageOptions) => WorkflowTask;
5659
+
5660
+ interface GenerateAudioOptions {
5661
+ text?: string;
5662
+ voice?: string;
5663
+ speed?: number;
5664
+ }
5665
+ declare const generateAudioTask: (taskReferenceName: string, provider: string, model: string, options?: GenerateAudioOptions) => WorkflowTask;
5666
+
5667
+ interface CallMcpToolOptions {
5668
+ inputParameters?: Record<string, unknown>;
5669
+ }
5670
+ declare const callMcpToolTask: (taskReferenceName: string, mcpServer: string, method: string, options?: CallMcpToolOptions) => WorkflowTask;
5671
+
5672
+ interface ListMcpToolsOptions {
5673
+ filter?: string;
5674
+ }
5675
+ declare const listMcpToolsTask: (taskReferenceName: string, mcpServer: string, options?: ListMcpToolsOptions) => WorkflowTask;
5676
+
5677
+ /**
5678
+ * Set a single prompt variable on an LLM task.
5679
+ * Returns a new task with the variable applied to inputParameters.promptVariables.
5680
+ *
5681
+ * @example
5682
+ * ```typescript
5683
+ * const task = withPromptVariable(
5684
+ * llmChatCompleteTask("ref", "openai", "gpt-4"),
5685
+ * "context",
5686
+ * "${workflow.input.context}"
5687
+ * );
5688
+ * ```
5689
+ */
5690
+ declare const withPromptVariable: (task: WorkflowTask, variable: string, value: unknown) => WorkflowTask;
5691
+ /**
5692
+ * Set multiple prompt variables on an LLM task at once.
5693
+ * Returns a new task with all variables merged into inputParameters.promptVariables.
5694
+ *
5695
+ * @example
5696
+ * ```typescript
5697
+ * const task = withPromptVariables(
5698
+ * llmTextCompleteTask("ref", "openai", "gpt-4", "my_prompt"),
5699
+ * {
5700
+ * context: "${workflow.input.context}",
5701
+ * query: "${workflow.input.query}",
5702
+ * }
5703
+ * );
5704
+ * ```
5705
+ */
5706
+ declare const withPromptVariables: (task: WorkflowTask, variables: Record<string, unknown>) => WorkflowTask;
5707
+
4164
5708
  declare const workflow: (name: string, tasks: TaskDefTypes[]) => WorkflowDef;
4165
5709
 
4166
5710
  declare const taskDefinition: ({ name, ownerApp, description, retryCount, timeoutSeconds, inputKeys, outputKeys, timeoutPolicy, retryLogic, retryDelaySeconds, responseTimeoutSeconds, concurrentExecLimit, inputTemplate, rateLimitPerFrequency, rateLimitFrequencyInSeconds, ownerEmail, pollTimeoutSeconds, backoffScaleFactor, }: ExtendedTaskDef) => TaskDef;
4167
5711
 
5712
+ /**
5713
+ * Fluent workflow builder matching the Python SDK's ConductorWorkflow pattern.
5714
+ *
5715
+ * Provides method chaining for building, configuring, registering, and
5716
+ * executing workflows.
5717
+ *
5718
+ * @example
5719
+ * ```typescript
5720
+ * const wf = new ConductorWorkflow(executor, "order_flow")
5721
+ * .add(simpleTask("validate_ref", "validate_order", {}))
5722
+ * .add(simpleTask("charge_ref", "charge_payment", {}))
5723
+ * .add(simpleTask("confirm_ref", "send_confirmation", {}))
5724
+ * .timeoutSeconds(3600)
5725
+ * .outputParameters({ orderId: "${workflow.input.orderId}" });
5726
+ *
5727
+ * await wf.register(true);
5728
+ * const run = await wf.execute({ orderId: "123" });
5729
+ * ```
5730
+ */
5731
+ declare class ConductorWorkflow {
5732
+ private readonly _executor;
5733
+ private readonly _name;
5734
+ private _version;
5735
+ private _description?;
5736
+ private _tasks;
5737
+ private _timeoutPolicy?;
5738
+ private _timeoutSeconds;
5739
+ private _ownerEmail?;
5740
+ private _failureWorkflow;
5741
+ private _restartable;
5742
+ private _inputParameters;
5743
+ private _inputTemplate;
5744
+ private _outputParameters;
5745
+ private _variables;
5746
+ private _workflowStatusListenerEnabled;
5747
+ private _workflowStatusListenerSink?;
5748
+ private _forkCounter;
5749
+ constructor(executor: WorkflowExecutor, name: string, version?: number, description?: string);
5750
+ /** Get the workflow name */
5751
+ getName(): string;
5752
+ /** Get the workflow version */
5753
+ getVersion(): number;
5754
+ /** Append one or more tasks sequentially */
5755
+ add(task: WorkflowTask | WorkflowTask[]): this;
5756
+ /** Add parallel fork branches with an auto-generated join */
5757
+ fork(branches: WorkflowTask[][]): this;
5758
+ /**
5759
+ * Convert this workflow into a SUB_WORKFLOW task with the full definition
5760
+ * embedded inline, matching Python SDK's `InlineSubWorkflowTask`.
5761
+ *
5762
+ * This allows composing workflows without pre-registering the child workflow.
5763
+ *
5764
+ * @param taskReferenceName - Reference name for the sub-workflow task
5765
+ */
5766
+ toSubWorkflowTask(taskReferenceName: string): WorkflowTask;
5767
+ description(desc: string): this;
5768
+ version(v: number): this;
5769
+ timeoutPolicy(policy: "TIME_OUT_WF" | "ALERT_ONLY"): this;
5770
+ timeoutSeconds(n: number): this;
5771
+ ownerEmail(email: string): this;
5772
+ failureWorkflow(name: string): this;
5773
+ restartable(val: boolean): this;
5774
+ /** Set the list of input parameter names */
5775
+ inputParameters(params: string[]): this;
5776
+ /** Set the input template (default values/expressions for inputs) */
5777
+ inputTemplate(template: Record<string, unknown>): this;
5778
+ /** Alias for inputTemplate — set workflow input defaults */
5779
+ workflowInput(input: Record<string, unknown>): this;
5780
+ /** Set all output parameters at once */
5781
+ outputParameters(params: Record<string, unknown>): this;
5782
+ /** Set a single output parameter */
5783
+ outputParameter(key: string, value: unknown): this;
5784
+ /** Set workflow variables */
5785
+ variables(vars: Record<string, unknown>): this;
5786
+ /** Enable workflow status listener with a sink name */
5787
+ enableStatusListener(sinkName: string): this;
5788
+ /** Disable workflow status listener */
5789
+ disableStatusListener(): this;
5790
+ /** Returns a workflow input reference expression */
5791
+ input(jsonPath: string): string;
5792
+ /** Returns a workflow output reference expression */
5793
+ output(jsonPath?: string): string;
5794
+ /** Convert to a WorkflowDef object */
5795
+ toWorkflowDef(): WorkflowDef;
5796
+ /** Register this workflow with the Conductor server */
5797
+ register(overwrite?: boolean): Promise<void>;
5798
+ /** Execute the workflow synchronously and wait for result */
5799
+ execute(input?: Record<string, unknown>, waitUntilTaskRef?: string, requestId?: string, idempotencyKey?: string, idempotencyStrategy?: "FAIL" | "RETURN_EXISTING" | "FAIL_ON_RUNNING", taskToDomain?: Record<string, string>): Promise<WorkflowRun>;
5800
+ /** Start the workflow asynchronously (returns workflow ID) */
5801
+ startWorkflow(input?: Record<string, unknown>, correlationId?: string, priority?: number, idempotencyKey?: string, idempotencyStrategy?: "FAIL" | "RETURN_EXISTING" | "FAIL_ON_RUNNING", taskToDomain?: Record<string, string>): Promise<string>;
5802
+ }
5803
+
4168
5804
  /**
4169
5805
  * Takes an optional partial SimpleTaskDef
4170
5806
  * generates a task replacing default values with provided overrides
@@ -4320,10 +5956,817 @@ declare const generateDoWhileTask: (overrides?: Partial<DoWhileTaskDefGen>, nest
4320
5956
  */
4321
5957
  declare const generateForkJoinTask: (overrides?: Partial<ForkJoinTaskDefGen>, nestedMapper?: NestedTaskMapper) => ForkJoinTaskDef;
4322
5958
 
5959
+ /**
5960
+ * Configuration for TaskHandler.
5961
+ */
5962
+ interface TaskHandlerConfig {
5963
+ /**
5964
+ * Conductor client instance.
5965
+ * Required for communicating with Conductor server.
5966
+ */
5967
+ client: Client;
5968
+ /**
5969
+ * Additional workers to register manually.
5970
+ * These will be added alongside auto-discovered decorated workers.
5971
+ * Default: []
5972
+ */
5973
+ workers?: ConductorWorker[];
5974
+ /**
5975
+ * Whether to scan for @worker decorated functions.
5976
+ * When true, automatically discovers all workers registered via @worker decorator.
5977
+ * Default: true
5978
+ */
5979
+ scanForDecorated?: boolean;
5980
+ /**
5981
+ * Modules to import for side-effect registration.
5982
+ * Importing these modules will trigger @worker decorator execution.
5983
+ * Useful when workers are defined in separate files.
5984
+ *
5985
+ * Example: ['./workers/orderWorkers', './workers/paymentWorkers']
5986
+ * Default: []
5987
+ */
5988
+ importModules?: string[];
5989
+ /**
5990
+ * Event listeners for worker lifecycle events.
5991
+ * Default: []
5992
+ */
5993
+ eventListeners?: TaskRunnerEventsListener[];
5994
+ /**
5995
+ * Logger instance for TaskHandler.
5996
+ * Default: DefaultLogger
5997
+ */
5998
+ logger?: ConductorLogger;
5999
+ /**
6000
+ * Health monitoring configuration.
6001
+ * Monitors worker polling loops and auto-restarts on failure.
6002
+ * Default: { enabled: true }
6003
+ */
6004
+ healthMonitor?: HealthMonitorConfig;
6005
+ }
6006
+ /**
6007
+ * TaskHandler orchestrates worker lifecycle and auto-discovery.
6008
+ *
6009
+ * This is the main entry point for the SDK-style worker framework,
6010
+ * matching the Python SDK's TaskHandler architecture.
6011
+ *
6012
+ * Features:
6013
+ * - Auto-discovers workers decorated with @worker
6014
+ * - Manages worker lifecycle (start/stop)
6015
+ * - Supports both decorated and manual worker registration
6016
+ * - Module import for side-effect registration
6017
+ * - Event listener support
6018
+ * - Health monitoring with auto-restart
6019
+ * - Automatic task definition registration
6020
+ * - Environment variable configuration override
6021
+ *
6022
+ * @example
6023
+ * Basic usage with auto-discovery:
6024
+ * ```typescript
6025
+ * const handler = new TaskHandler({
6026
+ * client: conductorClient,
6027
+ * scanForDecorated: true,
6028
+ * });
6029
+ *
6030
+ * await handler.startWorkers();
6031
+ *
6032
+ * // Later...
6033
+ * await handler.stopWorkers();
6034
+ * ```
6035
+ *
6036
+ * @example
6037
+ * With event listeners and health monitoring:
6038
+ * ```typescript
6039
+ * const handler = new TaskHandler({
6040
+ * client: conductorClient,
6041
+ * eventListeners: [metricsCollector],
6042
+ * healthMonitor: {
6043
+ * enabled: true,
6044
+ * healthCheckIntervalMs: 5000,
6045
+ * maxRestartAttempts: 10,
6046
+ * },
6047
+ * });
6048
+ *
6049
+ * await handler.startWorkers();
6050
+ * handler.printSummary();
6051
+ * ```
6052
+ */
6053
+ declare class TaskHandler {
6054
+ private client;
6055
+ private resolvedWorkers;
6056
+ private taskRunners;
6057
+ private config;
6058
+ private logger;
6059
+ private isRunning;
6060
+ private healthCheckTimer?;
6061
+ private restartAttempts;
6062
+ private healthMonitorConfig;
6063
+ /**
6064
+ * Create a TaskHandler instance with async module imports.
6065
+ * Use this instead of `new TaskHandler()` when using `importModules`.
6066
+ */
6067
+ static create(config: TaskHandlerConfig): Promise<TaskHandler>;
6068
+ constructor(config: TaskHandlerConfig);
6069
+ /**
6070
+ * Start all registered workers.
6071
+ *
6072
+ * Registers task definitions (if configured), creates a TaskRunner for each
6073
+ * worker, and begins polling for tasks.
6074
+ * This method is idempotent - calling it multiple times has no effect.
6075
+ */
6076
+ startWorkers(): Promise<void>;
6077
+ /**
6078
+ * Stop all running workers gracefully.
6079
+ *
6080
+ * Stops polling and waits for in-flight tasks to complete.
6081
+ * This method is idempotent - calling it multiple times has no effect.
6082
+ */
6083
+ stopWorkers(): Promise<void>;
6084
+ /**
6085
+ * Register task definitions for workers that have registerTaskDef=true.
6086
+ * Called automatically by startWorkers() before polling begins.
6087
+ *
6088
+ * Matches Python SDK behavior:
6089
+ * - If overwriteTaskDef=true: PUT /api/metadata/taskdefs (create or update)
6090
+ * - If overwriteTaskDef=false: GET first, then POST only if not found
6091
+ * - Uses taskDef template if provided, otherwise creates minimal definition
6092
+ */
6093
+ private registerTaskDefinitions;
6094
+ private startHealthMonitor;
6095
+ private stopHealthMonitor;
6096
+ private checkWorkerHealth;
6097
+ /**
6098
+ * Print a summary of all registered workers and their configurations.
6099
+ * Matches Python SDK's print_summary() function.
6100
+ */
6101
+ printSummary(): void;
6102
+ /**
6103
+ * Check if all workers are healthy (all polling).
6104
+ * Returns false if any worker has stopped unexpectedly.
6105
+ */
6106
+ isHealthy(): boolean;
6107
+ /**
6108
+ * Get detailed status of each worker.
6109
+ * Matches Python SDK's get_worker_process_status().
6110
+ */
6111
+ getWorkerStatus(): {
6112
+ taskDefName: string;
6113
+ domain?: string;
6114
+ polling: boolean;
6115
+ paused: boolean;
6116
+ workerId: string;
6117
+ restartCount: number;
6118
+ }[];
6119
+ /** Get the number of registered workers. */
6120
+ get workerCount(): number;
6121
+ /** Get the number of running workers. */
6122
+ get runningWorkerCount(): number;
6123
+ /** Check if workers are currently running. */
6124
+ get running(): boolean;
6125
+ /**
6126
+ * Context manager support (for TypeScript 5.2+ using keyword).
6127
+ * Automatically stops workers when disposed.
6128
+ */
6129
+ [Symbol.asyncDispose](): Promise<void>;
6130
+ }
6131
+
6132
+ /**
6133
+ * Options for the @worker decorator.
6134
+ */
6135
+ interface WorkerOptions {
6136
+ /**
6137
+ * Task definition name (must match workflow task name).
6138
+ * This is the only required parameter.
6139
+ */
6140
+ taskDefName: string;
6141
+ /**
6142
+ * Maximum concurrent tasks this worker can execute.
6143
+ * - Default: 1
6144
+ * - Controls concurrency level for task execution
6145
+ * - Choose based on workload:
6146
+ * * CPU-bound: 1-4
6147
+ * * I/O-bound: 10-50
6148
+ * * Mixed: 5-20
6149
+ */
6150
+ concurrency?: number;
6151
+ /**
6152
+ * Polling interval in milliseconds.
6153
+ * - Default: 100ms
6154
+ * - Lower values = more responsive but higher server load
6155
+ * - Higher values = less server load but slower task pickup
6156
+ * - Recommended: 100-500ms for most use cases
6157
+ */
6158
+ pollInterval?: number;
6159
+ /**
6160
+ * Task domain for multi-tenancy.
6161
+ * - Default: undefined (no domain isolation)
6162
+ * - Use when you need to partition tasks across different environments/tenants
6163
+ */
6164
+ domain?: string;
6165
+ /**
6166
+ * Unique worker identifier.
6167
+ * - Default: undefined (auto-generated)
6168
+ * - Useful for debugging and tracking which worker executed which task
6169
+ */
6170
+ workerId?: string;
6171
+ /**
6172
+ * Auto-register task definition on startup.
6173
+ * - Default: false
6174
+ * - When true: Task definition is created/updated on worker startup
6175
+ * - When false: Task definition must exist in Conductor already
6176
+ * - Recommended: false for production (manage task definitions separately)
6177
+ */
6178
+ registerTaskDef?: boolean;
6179
+ /**
6180
+ * Server-side long poll timeout in milliseconds.
6181
+ * - Default: 100ms
6182
+ * - How long the server will wait for a task before returning empty response
6183
+ * - Higher values reduce polling frequency when no tasks available
6184
+ * - Recommended: 100-500ms
6185
+ */
6186
+ pollTimeout?: number;
6187
+ /**
6188
+ * Task definition template for registration.
6189
+ * - Default: undefined
6190
+ * - Only used when registerTaskDef=true
6191
+ * - Allows specifying retry policies, timeouts, rate limits, etc.
6192
+ * - The taskDefName parameter takes precedence for the name field
6193
+ */
6194
+ taskDef?: TaskDef;
6195
+ /**
6196
+ * Overwrite existing task definitions on server.
6197
+ * - Default: true
6198
+ * - When true: Always updates task definition
6199
+ * - When false: Only creates if doesn't exist
6200
+ * - Can be overridden via env: CONDUCTOR_WORKER_<NAME>_OVERWRITE_TASK_DEF=false
6201
+ */
6202
+ overwriteTaskDef?: boolean;
6203
+ /**
6204
+ * Enforce strict JSON schema validation.
6205
+ * - Default: false
6206
+ * - When false: additionalProperties=true (allows extra fields)
6207
+ * - When true: additionalProperties=false (strict validation)
6208
+ * - Can be overridden via env: CONDUCTOR_WORKER_<NAME>_STRICT_SCHEMA=true
6209
+ */
6210
+ strictSchema?: boolean;
6211
+ /**
6212
+ * JSON Schema for task input validation.
6213
+ * - Registered alongside the task definition when registerTaskDef=true
6214
+ * - Use the `jsonSchema()` helper to generate from field descriptors
6215
+ */
6216
+ inputSchema?: Record<string, unknown>;
6217
+ /**
6218
+ * JSON Schema for task output validation.
6219
+ * - Registered alongside the task definition when registerTaskDef=true
6220
+ * - Use the `jsonSchema()` helper to generate from field descriptors
6221
+ */
6222
+ outputSchema?: Record<string, unknown>;
6223
+ /**
6224
+ * Class decorated with `@schemaField()` for auto-generating input schema.
6225
+ * - Alternative to `inputSchema` — schema is generated from class metadata
6226
+ * - Takes precedence over `inputSchema` if both are set
6227
+ */
6228
+ inputType?: new (...args: any[]) => unknown;
6229
+ /**
6230
+ * Class decorated with `@schemaField()` for auto-generating output schema.
6231
+ * - Alternative to `outputSchema` — schema is generated from class metadata
6232
+ * - Takes precedence over `outputSchema` if both are set
6233
+ */
6234
+ outputType?: new (...args: any[]) => unknown;
6235
+ }
6236
+ /**
6237
+ * Decorator to register a function as a Conductor worker.
6238
+ *
6239
+ * This decorator enables SDK-style worker registration with auto-discovery,
6240
+ * matching the Python SDK's @worker_task pattern.
6241
+ *
6242
+ * @param options - Worker configuration options
6243
+ *
6244
+ * @example
6245
+ * Basic usage:
6246
+ * ```typescript
6247
+ * @worker({ taskDefName: "process_order" })
6248
+ * async function processOrder(task: Task): Promise<TaskResult> {
6249
+ * const orderId = task.inputData.orderId;
6250
+ * // Process order logic
6251
+ * return {
6252
+ * status: "COMPLETED",
6253
+ * outputData: { orderId, processed: true },
6254
+ * };
6255
+ * }
6256
+ * ```
6257
+ *
6258
+ * @example
6259
+ * With concurrency:
6260
+ * ```typescript
6261
+ * @worker({ taskDefName: "send_email", concurrency: 10 })
6262
+ * async function sendEmail(task: Task): Promise<TaskResult> {
6263
+ * const { to, subject, body } = task.inputData;
6264
+ * await emailService.send(to, subject, body);
6265
+ * return { status: "COMPLETED", outputData: { sent: true } };
6266
+ * }
6267
+ * ```
6268
+ *
6269
+ * @example
6270
+ * With domain and custom polling:
6271
+ * ```typescript
6272
+ * @worker({
6273
+ * taskDefName: "validate_payment",
6274
+ * domain: "payments",
6275
+ * concurrency: 5,
6276
+ * pollInterval: 200,
6277
+ * })
6278
+ * async function validatePayment(task: Task): Promise<TaskResult> {
6279
+ * // Validation logic
6280
+ * return { status: "COMPLETED", outputData: { valid: true } };
6281
+ * }
6282
+ * ```
6283
+ *
6284
+ * @example
6285
+ * With task definition registration:
6286
+ * ```typescript
6287
+ * @worker({
6288
+ * taskDefName: "complex_task",
6289
+ * registerTaskDef: true,
6290
+ * taskDef: {
6291
+ * retryCount: 3,
6292
+ * retryLogic: "EXPONENTIAL_BACKOFF",
6293
+ * timeoutSeconds: 300,
6294
+ * },
6295
+ * })
6296
+ * async function complexTask(task: Task): Promise<TaskResult> {
6297
+ * // Complex logic
6298
+ * return { status: "COMPLETED", outputData: { result: "..." } };
6299
+ * }
6300
+ * ```
6301
+ *
6302
+ * @example
6303
+ * Non-retryable errors:
6304
+ * ```typescript
6305
+ * import { worker, NonRetryableException } from "@io-orkes/conductor-javascript/worker";
6306
+ *
6307
+ * @worker({ taskDefName: "validate_order" })
6308
+ * async function validateOrder(task: Task): Promise<TaskResult> {
6309
+ * const order = await getOrder(task.inputData.orderId);
6310
+ *
6311
+ * if (!order) {
6312
+ * // Order doesn't exist - retry won't help
6313
+ * throw new NonRetryableException(`Order ${task.inputData.orderId} not found`);
6314
+ * }
6315
+ *
6316
+ * return { status: "COMPLETED", outputData: { validated: true } };
6317
+ * }
6318
+ * ```
6319
+ */
6320
+ declare function worker(options: WorkerOptions): (target: unknown, propertyKey?: string, descriptor?: PropertyDescriptor) => PropertyDescriptor | ((this: unknown, ...args: unknown[]) => unknown);
6321
+
6322
+ /**
6323
+ * Registered worker metadata stored in the global registry.
6324
+ */
6325
+ interface RegisteredWorker {
6326
+ /** Task definition name (must match workflow task name) */
6327
+ taskDefName: string;
6328
+ /** Worker execution function */
6329
+ executeFunction: (task: Task) => Promise<Omit<TaskResult, "workflowInstanceId" | "taskId">>;
6330
+ /** Maximum concurrent tasks (default: 1) */
6331
+ concurrency?: number;
6332
+ /** Polling interval in milliseconds (default: 100) */
6333
+ pollInterval?: number;
6334
+ /** Task domain for multi-tenancy (default: undefined) */
6335
+ domain?: string;
6336
+ /** Unique worker identifier (default: auto-generated) */
6337
+ workerId?: string;
6338
+ /** Auto-register task definition on startup (default: false) */
6339
+ registerTaskDef?: boolean;
6340
+ /** Server-side long poll timeout in milliseconds (default: 100) */
6341
+ pollTimeout?: number;
6342
+ /** Task definition template for registration (optional) */
6343
+ taskDef?: TaskDef;
6344
+ /** Overwrite existing task definitions (default: true) */
6345
+ overwriteTaskDef?: boolean;
6346
+ /** Enforce strict JSON schema validation (default: false) */
6347
+ strictSchema?: boolean;
6348
+ /** JSON Schema for task input validation (registered alongside task def) */
6349
+ inputSchema?: Record<string, unknown>;
6350
+ /** JSON Schema for task output validation (registered alongside task def) */
6351
+ outputSchema?: Record<string, unknown>;
6352
+ /** Whether this worker should start in paused state (default: false) */
6353
+ paused?: boolean;
6354
+ }
6355
+ /**
6356
+ * Get all registered workers from the global registry.
6357
+ * Used by TaskHandler for auto-discovery.
6358
+ *
6359
+ * @returns Array of all registered workers
6360
+ */
6361
+ declare function getRegisteredWorkers(): RegisteredWorker[];
6362
+ /**
6363
+ * Get a specific registered worker.
6364
+ *
6365
+ * @param taskDefName - Task definition name
6366
+ * @param domain - Optional domain
6367
+ * @returns Registered worker or undefined
6368
+ */
6369
+ declare function getRegisteredWorker(taskDefName: string, domain?: string): RegisteredWorker | undefined;
6370
+ /**
6371
+ * Clear all registered workers.
6372
+ * Primarily for testing purposes.
6373
+ */
6374
+ declare function clearWorkerRegistry(): void;
6375
+ /**
6376
+ * Get the number of registered workers.
6377
+ */
6378
+ declare function getWorkerCount(): number;
6379
+
6380
+ /**
6381
+ * TaskContext provides async-local context during task execution.
6382
+ *
6383
+ * This is the JavaScript equivalent of Python's contextvars-based
6384
+ * `get_task_context()`. Each task execution runs in its own async context,
6385
+ * so `getTaskContext()` returns the context for the currently executing task.
6386
+ *
6387
+ * @example
6388
+ * ```typescript
6389
+ * @worker({ taskDefName: "my_task" })
6390
+ * async function myTask(task: Task) {
6391
+ * const ctx = getTaskContext();
6392
+ * ctx?.addLog("Starting processing");
6393
+ *
6394
+ * if (needsMoreTime) {
6395
+ * ctx?.setCallbackAfter(30);
6396
+ * return { status: "IN_PROGRESS", callbackAfterSeconds: 30 };
6397
+ * }
6398
+ *
6399
+ * return { status: "COMPLETED", outputData: { result: "done" } };
6400
+ * }
6401
+ * ```
6402
+ */
6403
+ declare class TaskContext {
6404
+ private _task;
6405
+ private _logs;
6406
+ private _callbackAfterSeconds?;
6407
+ private _output?;
6408
+ constructor(task: Task);
6409
+ /** Get the task ID */
6410
+ getTaskId(): string | undefined;
6411
+ /** Get the workflow instance ID */
6412
+ getWorkflowInstanceId(): string | undefined;
6413
+ /** Get the retry count for this task (0 for first attempt) */
6414
+ getRetryCount(): number;
6415
+ /** Get the poll count for this task */
6416
+ getPollCount(): number;
6417
+ /** Get the full task input data */
6418
+ getInput(): Record<string, unknown>;
6419
+ /** Get the task definition name */
6420
+ getTaskDefName(): string | undefined;
6421
+ /** Get the workflow task type (e.g., SIMPLE, HTTP, SUB_WORKFLOW) */
6422
+ getWorkflowTaskType(): string | undefined;
6423
+ /** Get the full task object */
6424
+ getTask(): Task;
6425
+ /**
6426
+ * Add an execution log entry.
6427
+ * Logs are merged into the task result when execution completes.
6428
+ */
6429
+ addLog(message: string): void;
6430
+ /** Get all accumulated logs */
6431
+ getLogs(): TaskExecLog[];
6432
+ /**
6433
+ * Set callback-after seconds.
6434
+ * Tells Conductor to re-queue the task after the specified number of seconds.
6435
+ */
6436
+ setCallbackAfter(seconds: number): void;
6437
+ /** Get the callback-after value (if set) */
6438
+ getCallbackAfterSeconds(): number | undefined;
6439
+ /**
6440
+ * Set intermediate output data.
6441
+ * Merged into the final task result.
6442
+ */
6443
+ setOutput(data: Record<string, unknown>): void;
6444
+ /** Get intermediate output data (if set) */
6445
+ getOutput(): Record<string, unknown> | undefined;
6446
+ }
6447
+ /**
6448
+ * Get the current task context.
6449
+ *
6450
+ * Must be called from within a task execution callback.
6451
+ * Returns `undefined` if called outside of a task execution.
6452
+ */
6453
+ declare function getTaskContext(): TaskContext | undefined;
6454
+
6455
+ /**
6456
+ * Configuration for MetricsCollector.
6457
+ */
6458
+ interface MetricsCollectorConfig {
6459
+ /** Prometheus metric name prefix (default: "conductor_worker") */
6460
+ prefix?: string;
6461
+ /** If set, auto-starts MetricsServer on this port */
6462
+ httpPort?: number;
6463
+ /** If set, periodically writes Prometheus metrics to this file path */
6464
+ filePath?: string;
6465
+ /** File write interval in milliseconds (default: 5000) */
6466
+ fileWriteIntervalMs?: number;
6467
+ /** Sliding window size for quantile calculations (default: 1000) */
6468
+ slidingWindowSize?: number;
6469
+ /**
6470
+ * Use prom-client for native Prometheus integration.
6471
+ * Requires `prom-client` to be installed (`npm install prom-client`).
6472
+ * When enabled, metrics are registered in prom-client's default registry
6473
+ * and `toPrometheusText()` delegates to `prom-client.register.metrics()`.
6474
+ * Falls back to custom text format if prom-client is not installed.
6475
+ */
6476
+ usePromClient?: boolean;
6477
+ }
6478
+ /**
6479
+ * Collected worker metrics.
6480
+ */
6481
+ interface WorkerMetrics {
6482
+ /** Total polls by taskType */
6483
+ pollTotal: Map<string, number>;
6484
+ /** Poll errors by taskType */
6485
+ pollErrorTotal: Map<string, number>;
6486
+ /** Task executions completed by taskType */
6487
+ taskExecutionTotal: Map<string, number>;
6488
+ /** Task execution errors by "taskType:exceptionName" */
6489
+ taskExecutionErrorTotal: Map<string, number>;
6490
+ /** Task update failures by taskType */
6491
+ taskUpdateFailureTotal: Map<string, number>;
6492
+ /** Task ack errors by taskType */
6493
+ taskAckErrorTotal: Map<string, number>;
6494
+ /** Task execution queue full by taskType */
6495
+ taskExecutionQueueFullTotal: Map<string, number>;
6496
+ /** Thread/process uncaught exceptions (global counter) */
6497
+ uncaughtExceptionTotal: number;
6498
+ /** Worker restart count (global counter) */
6499
+ workerRestartTotal: number;
6500
+ /** Task paused count by taskType */
6501
+ taskPausedTotal: Map<string, number>;
6502
+ /** Workflow start errors */
6503
+ workflowStartErrorTotal: number;
6504
+ /** External payload used count by type (workflow_input/task_output) */
6505
+ externalPayloadUsedTotal: Map<string, number>;
6506
+ /** Poll duration observations in ms by taskType */
6507
+ pollDurationMs: Map<string, number[]>;
6508
+ /** Execution duration observations in ms by taskType */
6509
+ executionDurationMs: Map<string, number[]>;
6510
+ /** Update duration observations in ms by taskType */
6511
+ updateDurationMs: Map<string, number[]>;
6512
+ /** Output size observations in bytes by taskType */
6513
+ outputSizeBytes: Map<string, number[]>;
6514
+ /** Workflow input size observations in bytes */
6515
+ workflowInputSizeBytes: Map<string, number[]>;
6516
+ /** API request duration observations in ms by "method:uri:status" */
6517
+ apiRequestDurationMs: Map<string, number[]>;
6518
+ }
6519
+ /**
6520
+ * Built-in metrics collector implementing TaskRunnerEventsListener.
6521
+ *
6522
+ * Collects 19 metric types matching the Python SDK's MetricsCollector,
6523
+ * with sliding-window quantile support (p50, p75, p90, p95, p99).
6524
+ *
6525
+ * @example
6526
+ * ```typescript
6527
+ * const metrics = new MetricsCollector({ httpPort: 9090 });
6528
+ *
6529
+ * const handler = new TaskHandler({
6530
+ * client,
6531
+ * eventListeners: [metrics],
6532
+ * });
6533
+ *
6534
+ * await handler.startWorkers();
6535
+ * // GET http://localhost:9090/metrics — Prometheus format
6536
+ * // GET http://localhost:9090/health — {"status":"UP"}
6537
+ * ```
6538
+ */
6539
+ declare class MetricsCollector implements TaskRunnerEventsListener {
6540
+ private metrics;
6541
+ private readonly _prefix;
6542
+ private readonly _slidingWindowSize;
6543
+ private _server?;
6544
+ private _fileTimer?;
6545
+ private _promRegistry?;
6546
+ constructor(config?: MetricsCollectorConfig);
6547
+ private initPromClient;
6548
+ private startServer;
6549
+ private startFileWriter;
6550
+ private createEmptyMetrics;
6551
+ private increment;
6552
+ private observe;
6553
+ private incrementCounter;
6554
+ private observeSummary;
6555
+ onPollStarted(event: PollStarted): void;
6556
+ onPollCompleted(event: PollCompleted): void;
6557
+ onPollFailure(event: PollFailure): void;
6558
+ onTaskExecutionStarted(_event: TaskExecutionStarted): void;
6559
+ onTaskExecutionCompleted(event: TaskExecutionCompleted): void;
6560
+ onTaskExecutionFailure(event: TaskExecutionFailure): void;
6561
+ onTaskUpdateCompleted(event: TaskUpdateCompleted): void;
6562
+ onTaskUpdateFailure(event: TaskUpdateFailure): void;
6563
+ /** Record a task execution queue full event */
6564
+ recordTaskExecutionQueueFull(taskType: string): void;
6565
+ /** Record an uncaught exception */
6566
+ recordUncaughtException(): void;
6567
+ /** Record a worker restart */
6568
+ recordWorkerRestart(): void;
6569
+ /** Record a task paused event */
6570
+ recordTaskPaused(taskType: string): void;
6571
+ /** Record a task ack error */
6572
+ recordTaskAckError(taskType: string): void;
6573
+ /** Record a workflow start error */
6574
+ recordWorkflowStartError(): void;
6575
+ /** Record external payload usage */
6576
+ recordExternalPayloadUsed(payloadType: string): void;
6577
+ /** Record workflow input size */
6578
+ recordWorkflowInputSize(workflowType: string, sizeBytes: number): void;
6579
+ /** Record API request duration */
6580
+ recordApiRequestTime(method: string, uri: string, status: number, durationMs: number): void;
6581
+ /** Get a snapshot of all collected metrics */
6582
+ getMetrics(): Readonly<WorkerMetrics>;
6583
+ /** Reset all collected metrics */
6584
+ reset(): void;
6585
+ /** Stop the auto-started metrics HTTP server and file writer (if any) */
6586
+ stop(): Promise<void>;
6587
+ /**
6588
+ * Get the content type for the Prometheus metrics endpoint.
6589
+ * Returns prom-client's content type when available, otherwise standard Prometheus text format.
6590
+ */
6591
+ getContentType(): string;
6592
+ /**
6593
+ * Render all collected metrics in Prometheus exposition format.
6594
+ * If prom-client is available and `usePromClient: true`, delegates to prom-client's registry.
6595
+ * Otherwise uses built-in rendering with p50/p75/p90/p95/p99 quantiles.
6596
+ *
6597
+ * @param prefix - Metric name prefix (defaults to constructor config or "conductor_worker")
6598
+ * @returns Prometheus text format string
6599
+ */
6600
+ /**
6601
+ * Async version of toPrometheusText.
6602
+ * When prom-client is available, returns its native registry output.
6603
+ * Otherwise falls back to the built-in text format.
6604
+ */
6605
+ toPrometheusTextAsync(): Promise<string>;
6606
+ toPrometheusText(prefix?: string): string;
6607
+ }
6608
+
6609
+ /**
6610
+ * Lightweight HTTP server exposing Prometheus metrics and a health check endpoint.
6611
+ *
6612
+ * Uses Node.js built-in `http` module — no external dependencies.
6613
+ *
6614
+ * Endpoints:
6615
+ * - `GET /metrics` — Prometheus text exposition format (`text/plain; version=0.0.4`)
6616
+ * - `GET /health` — JSON health check (`{"status":"UP"}`)
6617
+ *
6618
+ * @example
6619
+ * ```typescript
6620
+ * const collector = new MetricsCollector();
6621
+ * const server = new MetricsServer(collector, 9090);
6622
+ * await server.start();
6623
+ * // GET http://localhost:9090/metrics
6624
+ * // GET http://localhost:9090/health
6625
+ * await server.stop();
6626
+ * ```
6627
+ */
6628
+ declare class MetricsServer {
6629
+ private readonly _collector;
6630
+ private readonly _port;
6631
+ private _server?;
6632
+ constructor(collector: MetricsCollector, port: number);
6633
+ /** Start listening on the configured port */
6634
+ start(): Promise<void>;
6635
+ /** Stop the HTTP server */
6636
+ stop(): Promise<void>;
6637
+ }
6638
+
6639
+ /**
6640
+ * Lightweight JSON Schema (draft-07) generator from declarative field descriptions.
6641
+ *
6642
+ * TypeScript has no runtime type reflection, so this provides a practical
6643
+ * alternative: describe your fields declaratively and get a valid JSON Schema object.
6644
+ *
6645
+ * @example
6646
+ * ```typescript
6647
+ * const schema = jsonSchema({
6648
+ * orderId: { type: "string", required: true },
6649
+ * amount: { type: "number" },
6650
+ * items: { type: "array", items: { type: "string" } },
6651
+ * address: {
6652
+ * type: "object",
6653
+ * properties: {
6654
+ * street: { type: "string", required: true },
6655
+ * city: { type: "string" },
6656
+ * },
6657
+ * },
6658
+ * });
6659
+ * ```
6660
+ */
6661
+ type JsonSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
6662
+ interface FieldDescriptor {
6663
+ type: JsonSchemaType;
6664
+ required?: boolean;
6665
+ description?: string;
6666
+ /** For arrays: schema of array items */
6667
+ items?: FieldDescriptor;
6668
+ /** For objects: nested property descriptors */
6669
+ properties?: Record<string, FieldDescriptor>;
6670
+ /** Default value */
6671
+ default?: unknown;
6672
+ /** Enum values */
6673
+ enum?: unknown[];
6674
+ }
6675
+ interface JsonSchemaOutput {
6676
+ $schema: string;
6677
+ type: "object";
6678
+ properties: Record<string, unknown>;
6679
+ required?: string[];
6680
+ }
6681
+ /**
6682
+ * Generate a JSON Schema (draft-07) from declarative field descriptions.
6683
+ */
6684
+ declare function jsonSchema(fields: Record<string, FieldDescriptor>): JsonSchemaOutput;
6685
+
6686
+ declare global {
6687
+ namespace Reflect {
6688
+ function getMetadata(key: unknown, target: object, propertyKey?: string): unknown;
6689
+ function getOwnMetadata(key: unknown, target: object): unknown;
6690
+ function defineMetadata(key: unknown, value: unknown, target: object): void;
6691
+ }
6692
+ }
6693
+ /**
6694
+ * Options for the @schemaField property decorator.
6695
+ */
6696
+ interface SchemaFieldOptions {
6697
+ /** JSON Schema type. If omitted, inferred from TypeScript type metadata. */
6698
+ type?: JsonSchemaType;
6699
+ /** Whether this field is required (default: false) */
6700
+ required?: boolean;
6701
+ /** Field description */
6702
+ description?: string;
6703
+ /** For arrays: element type or schema */
6704
+ items?: {
6705
+ type: JsonSchemaType;
6706
+ } | SchemaFieldOptions;
6707
+ /** For objects: nested property definitions */
6708
+ properties?: Record<string, SchemaFieldOptions>;
6709
+ /** Default value */
6710
+ default?: unknown;
6711
+ /** Enum values */
6712
+ enum?: unknown[];
6713
+ }
6714
+ /**
6715
+ * Property decorator to define JSON Schema metadata on a class.
6716
+ *
6717
+ * When used with `generateSchemaFromClass()`, produces a JSON Schema draft-07
6718
+ * object from the decorated properties.
6719
+ *
6720
+ * If `emitDecoratorMetadata` is enabled in tsconfig.json, the TypeScript type
6721
+ * is automatically inferred for `string`, `number`, `boolean` — no need to
6722
+ * specify `type` explicitly for those.
6723
+ *
6724
+ * @example
6725
+ * ```typescript
6726
+ * class OrderInput {
6727
+ * @schemaField({ required: true })
6728
+ * orderId!: string;
6729
+ *
6730
+ * @schemaField()
6731
+ * amount!: number;
6732
+ *
6733
+ * @schemaField({ type: "array", items: { type: "string" } })
6734
+ * items!: string[];
6735
+ * }
6736
+ *
6737
+ * const schema = generateSchemaFromClass(OrderInput);
6738
+ * ```
6739
+ */
6740
+ declare function schemaField(options?: SchemaFieldOptions): (target: object, propertyKey: string) => void;
6741
+ /**
6742
+ * Generate a JSON Schema (draft-07) from a class decorated with `@schemaField()`.
6743
+ *
6744
+ * Uses `reflect-metadata` to read TypeScript type information when available,
6745
+ * falling back to explicit `type` in `@schemaField()` options.
6746
+ *
6747
+ * @param cls - A class constructor with `@schemaField()` decorated properties
6748
+ * @returns JSON Schema draft-07 object
6749
+ *
6750
+ * @example
6751
+ * ```typescript
6752
+ * class OrderInput {
6753
+ * @schemaField({ required: true })
6754
+ * orderId!: string;
6755
+ *
6756
+ * @schemaField()
6757
+ * amount!: number;
6758
+ * }
6759
+ *
6760
+ * const schema = generateSchemaFromClass(OrderInput);
6761
+ * // → { "$schema": "...", type: "object", properties: { orderId: { type: "string" }, ... }, required: ["orderId"] }
6762
+ * ```
6763
+ */
6764
+ declare function generateSchemaFromClass(cls: new (...args: any[]) => unknown): JsonSchemaOutput;
6765
+
4323
6766
  declare class ConductorSdkError extends Error {
4324
6767
  private _trace;
4325
6768
  private __proto__;
4326
6769
  constructor(message?: string, innerError?: Error);
4327
6770
  }
4328
6771
 
4329
- export { type AccessKey, type AccessKeyInfo, type Action, ApiError, type ApiRequestOptions, type ApiResult, ApplicationClient, type ApplicationRole, type Auth, BaseHttpRequest, CancelError, CancelablePromise, type CircuitBreakerTransitionResponse, type Client, type ClientOptions, type CommonTaskDef, type ConductorClient, type ConductorLogger, ConductorSdkError, type ConductorWorker, type Config$1 as Config, type ConnectivityTestInput, type ConnectivityTestResult, Consistency, DefaultLogger, type DoWhileTaskDef, type EnhancedSignalResponse, EventClient, type EventHandler, type EventMessage, type EventTaskDef, type ExtendedConductorApplication, type ExtendedEventExecution, type ExtendedTaskDef, type ExtendedWorkflowDef, type ExternalStorageLocation, type ForkJoinDynamicDef, type ForkJoinTaskDef, type GenerateTokenRequest, type HTScrollableSearchResultHumanTaskEntry, type HttpInputParameters, type HttpTaskDef, HumanExecutor, type HumanTaskAssignment, type HumanTaskDefinition, type HumanTaskEntry, type HumanTaskSearch, type HumanTaskSearchResult, type HumanTaskTemplate, type HumanTaskTrigger, type HumanTaskUser, type InlineTaskDef, type InlineTaskInputParameters, type JoinTaskDef, type JsonJQTransformTaskDef, type KafkaPublishInputParameters, type KafkaPublishTaskDef, MetadataClient, type Middleware, type OnCancel, type OpenAPIConfig, type OrkesApiConfig, type PollData, type PollIntervalOptions, Poller, type ProtoRegistryEntry, type QuerySerializerOptions, type RequestOptions, type RerunWorkflowRequest, type ResolvedRequestOptions, type Response$1 as Response, ReturnStrategy, type RunnerArgs, type SaveScheduleRequest, SchedulerClient, type ScrollableSearchResultWorkflowSummary, type SearchResultHandledEventResponse, type SearchResultTask, type SearchResultTaskSummary, type SearchResultWorkflow, type SearchResultWorkflowScheduleExecutionModel, type SearchResultWorkflowSummary, type ServiceMethod, type ServiceRegistry, ServiceRegistryClient, ServiceType, type SetVariableTaskDef, type SignalResponse, type SimpleTaskDef, type SkipTaskRequest, type StartWorkflow, type StartWorkflowRequest, type StreamEvent, type SubWorkflowParams, type SubWorkflowTaskDef, type SwitchTaskDef, type Tag, type Task, TaskClient, type TaskDef, type TaskDefTypes, type TaskDetails, type TaskErrorHandler, type TaskExecLog, type TaskFinderPredicate, type TaskListSearchResultSummary, TaskManager, type TaskResult, type TaskResultOutputData, type TaskResultStatus, TaskResultStatusEnum, TaskRunner, type TaskRunnerOptions, type TaskSummary, TaskType, TemplateClient, type Terminate, type TerminateTaskDef, type TimeoutPolicy, type UserFormTemplate, type UserType, type WaitTaskDef, type Workflow, type WorkflowDef, WorkflowExecutor, type WorkflowRun, type WorkflowSchedule, type WorkflowScheduleExecutionModel, type WorkflowScheduleModel, type WorkflowStatus, type WorkflowSummary, type WorkflowTask, conductorEventTask, createConductorClient, doWhileTask, dynamicForkTask, eventTask, forkTask, forkTaskJoin, generate, generateDoWhileTask, generateEventTask, generateForkJoinTask, generateHTTPTask, generateInlineTask, generateJQTransformTask, generateJoinTask, generateKafkaPublishTask, generateSetVariableTask, generateSimpleTask, generateSubWorkflowTask, generateSwitchTask, generateTerminateTask, generateWaitTask, httpTask, inlineTask, joinTask, jsonJqTask, kafkaPublishTask, newLoopTask, noopLogger, createConductorClient as orkesConductorClient, setVariableTask, simpleTask, sqsEventTask, subWorkflowTask, switchTask, taskDefinition, taskGenMapper, terminateTask, waitTaskDuration, waitTaskUntil, workflow };
6772
+ export { type AccessKey, type AccessKeyInfo, type Action, ApiError, type ApiRequestOptions, type ApiResult, ApplicationClient, type ApplicationRole, type AssignmentCompletionStrategy, type Auth, AuthorizationClient, type AuthorizationRequest, type AzureOpenAIConfig, BaseHttpRequest, type BulkResponse, type CallMcpToolOptions, CancelError, CancelablePromise, type ChatMessage, type CircuitBreakerTransitionResponse, type ClaimTaskOptions, type Client, type ClientOptions, type CommonTaskDef, type ConductorClient, type ConductorLogger, ConductorSdkError, type ConductorUser, type ConductorWorker, ConductorWorkflow, type Config$1 as Config, type ConnectivityTestInput, type ConnectivityTestResult, Consistency, type CorrelationIdsSearchRequest, DefaultLogger, type DoWhileTaskDef, type EmbeddingModel, type EnhancedSignalResponse, EventClient, EventDispatcher, type EventHandler, type EventMessage, type EventTaskDef, type ExtendedBulkResponse, type ExtendedConductorApplication, type ExtendedConductorUser, type ExtendedEventExecution, type ExtendedGroup, type ExtendedIntegrationApiUpdate, type ExtendedRateLimitConfig, type ExtendedTaskDef, type ExtendedTaskSummary, type ExtendedWorkflowDef, type ExternalStorageLocation, type FieldDescriptor, type ForkJoinDynamicDef, type ForkJoinTaskDef, type GenerateAudioOptions, type GenerateImageOptions, type GenerateTokenRequest, type GetDocumentOptions, type GrantedAccessResponse, type Group, type HTScrollableSearchResultHumanTaskEntry, type HealthMonitorConfig, type HttpInputParameters, type HttpPollInputParameters, type HttpTaskDef, HumanExecutor, type HumanTaskAssignment, type HumanTaskDefinition, type HumanTaskEntry, type HumanTaskOptions, type HumanTaskSearch, type HumanTaskSearchResult, type HumanTaskTemplate, type HumanTaskTrigger, type HumanTaskUser, type InlineTaskDef, type InlineTaskInputParameters, type Integration, type IntegrationApi, type IntegrationApiUpdate, IntegrationClient, type IntegrationConfig, type IntegrationDef, type IntegrationUpdate, type JoinTaskDef, type JsonJQTransformTaskDef, type JsonSchemaOutput, type JsonSchemaType, type KafkaPublishInputParameters, type KafkaPublishTaskDef, LLMProvider, type ListMcpToolsOptions, type LlmChatCompleteOptions, type LlmCompletionParams, type LlmGenerateEmbeddingsOptions, type LlmIndexDocumentOptions, type LlmIndexTextOptions, type LlmQueryEmbeddingsOptions, type LlmSearchEmbeddingsOptions, type LlmSearchIndexOptions, type LlmStoreEmbeddingsOptions, type LlmTextCompleteOptions, type MessageTemplate, MetadataClient, MetricsCollector, type MetricsCollectorConfig, MetricsServer, type Middleware, NonRetryableException, type OnCancel, type OpenAIConfig, type OpenAPIConfig, type OrkesApiConfig, OrkesClients, type PineconeConfig, type PollCompleted, type PollData, type PollFailure, type PollIntervalOptions, type PollStarted, Poller, PromptClient, type PromptTemplateTestRequest, type ProtoRegistryEntry, type QuerySerializerOptions, type RateLimitConfig, type RegisteredWorker, type RequestOptions, type RerunWorkflowRequest, type ResolvedRequestOptions, type Response$1 as Response, ReturnStrategy, Role, type RunnerArgs, type SaveScheduleRequest, SchedulerClient, SchemaClient, type SchemaDef, type SchemaFieldOptions, type ScrollableSearchResultWorkflowSummary, type SearchResultHandledEventResponse, type SearchResultTask, type SearchResultTaskSummary, type SearchResultWorkflow, type SearchResultWorkflowScheduleExecutionModel, type SearchResultWorkflowSummary, SecretClient, type ServiceMethod, type ServiceRegistry, ServiceRegistryClient, ServiceType, type SetVariableTaskDef, type SignalResponse, type SimpleTaskDef, type SkipTaskRequest, type StartWorkflow, type StartWorkflowRequest, type StreamEvent, type SubWorkflowParams, type SubWorkflowTaskDef, type SwitchTaskDef, type Tag, type Task, TaskClient, TaskContext, type TaskDef, type TaskDefTypes, type TaskDetails, type TaskErrorHandler, type TaskExecLog, type TaskExecutionCompleted, type TaskExecutionFailure, type TaskExecutionStarted, type TaskFinderPredicate, TaskHandler, type TaskHandlerConfig, type TaskInProgressResult, type TaskListSearchResultSummary, TaskManager, type TaskResult, type TaskResultOutputData, type TaskResultStatus, TaskResultStatusEnum, TaskRunner, type TaskRunnerEvent, type TaskRunnerEventType, type TaskRunnerEventsListener, type TaskRunnerOptions, type TaskSummary, TaskType, type TaskUpdateCompleted, type TaskUpdateFailure, TemplateClient, type Terminate, type TerminateTaskDef, type TimeoutPolicy, type ToolCall, type ToolSpec, type UpsertGroupRequest, type UpsertUserRequest, type UserFormTemplate, type UserType, VectorDB, type WaitForWebhookOptions, type WaitTaskDef, type WeaviateConfig, type WorkerMetrics, type WorkerOptions, type Workflow, type WorkflowDef, WorkflowExecutor, type WorkflowRun, type WorkflowSchedule, type WorkflowScheduleExecutionModel, type WorkflowScheduleModel, type WorkflowStateUpdate, type WorkflowStatus, type WorkflowSummary, type WorkflowTask, type WorkflowTestRequest, callMcpToolTask, clearWorkerRegistry, conductorEventTask, createConductorClient, doWhileTask, dynamicForkTask, dynamicTask, eventTask, forkTask, forkTaskJoin, generate, generateAudioTask, generateDoWhileTask, generateEventTask, generateForkJoinTask, generateHTTPTask, generateImageTask, generateInlineTask, generateJQTransformTask, generateJoinTask, generateKafkaPublishTask, generateSchemaFromClass, generateSetVariableTask, generateSimpleTask, generateSubWorkflowTask, generateSwitchTask, generateTerminateTask, generateWaitTask, getDocumentTask, getRegisteredWorker, getRegisteredWorkers, getTaskContext, getWorkerCount, httpPollTask, httpTask, humanTask, inlineTask, isTaskInProgress, joinTask, jsonJqTask, jsonSchema, kafkaPublishTask, listMcpToolsTask, llmChatCompleteTask, llmGenerateEmbeddingsTask, llmIndexDocumentTask, llmIndexTextTask, llmQueryEmbeddingsTask, llmSearchEmbeddingsTask, llmSearchIndexTask, llmStoreEmbeddingsTask, llmTextCompleteTask, newLoopTask, noopLogger, createConductorClient as orkesConductorClient, schemaField, setVariableTask, simpleTask, sqsEventTask, startWorkflowTask, subWorkflowTask, switchTask, taskDefinition, taskGenMapper, terminateTask, waitForWebhookTask, waitTaskDuration, waitTaskUntil, withPromptVariable, withPromptVariables, worker, workflow };