@upstash/workflow 0.2.3 → 0.2.5-agents
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/agents.d.mts +5 -0
- package/agents.d.ts +5 -0
- package/agents.js +245 -0
- package/agents.mjs +12 -0
- package/astro.d.mts +4 -1
- package/astro.d.ts +4 -1
- package/astro.js +362 -78
- package/astro.mjs +8 -1
- package/chunk-PU5J4TNC.mjs +251 -0
- package/{chunk-QBJ3LQIO.mjs → chunk-RFX5YRRT.mjs} +148 -103
- package/cloudflare.d.mts +4 -1
- package/cloudflare.d.ts +4 -1
- package/cloudflare.js +368 -82
- package/cloudflare.mjs +14 -5
- package/express.d.mts +4 -1
- package/express.d.ts +4 -1
- package/express.js +363 -79
- package/express.mjs +12 -4
- package/h3.d.mts +4 -1
- package/h3.d.ts +4 -1
- package/h3.js +366 -79
- package/h3.mjs +12 -2
- package/hono.d.mts +4 -1
- package/hono.d.ts +4 -1
- package/hono.js +370 -84
- package/hono.mjs +16 -7
- package/index.d.mts +5 -2
- package/index.d.ts +5 -2
- package/index.js +376 -83
- package/index.mjs +11 -4
- package/nextjs.d.mts +4 -1
- package/nextjs.d.ts +4 -1
- package/nextjs.js +371 -79
- package/nextjs.mjs +17 -2
- package/package.json +1 -1
- package/solidjs.d.mts +4 -1
- package/solidjs.d.ts +4 -1
- package/solidjs.js +366 -79
- package/solidjs.mjs +12 -2
- package/svelte.d.mts +4 -1
- package/svelte.d.ts +4 -1
- package/svelte.js +368 -82
- package/svelte.mjs +14 -5
- package/{types-R9q4MUwl.d.mts → types-BEyIoCRe.d.mts} +164 -4
- package/{types-R9q4MUwl.d.ts → types-BEyIoCRe.d.ts} +164 -4
package/svelte.mjs
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SDK_TELEMETRY,
|
|
2
3
|
serveBase
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RFX5YRRT.mjs";
|
|
5
|
+
import "./chunk-PU5J4TNC.mjs";
|
|
4
6
|
|
|
5
7
|
// platforms/svelte.ts
|
|
6
8
|
var serve = (routeFunction, options) => {
|
|
7
9
|
const handler = async ({ request }) => {
|
|
8
|
-
const { handler: serveHandler } = serveBase(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const { handler: serveHandler } = serveBase(
|
|
11
|
+
routeFunction,
|
|
12
|
+
{
|
|
13
|
+
sdk: SDK_TELEMETRY,
|
|
14
|
+
framework: "svelte"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
...options,
|
|
18
|
+
useJSONContent: true
|
|
19
|
+
}
|
|
20
|
+
);
|
|
12
21
|
return await serveHandler(request);
|
|
13
22
|
};
|
|
14
23
|
return { POST: handler };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { PublishRequest, Client, Receiver, HTTPMethods as HTTPMethods$1 } from '@upstash/qstash';
|
|
2
|
+
import * as ai from 'ai';
|
|
3
|
+
import { CoreTool, generateText } from 'ai';
|
|
4
|
+
import * as _ai_sdk_openai from '@ai-sdk/openai';
|
|
5
|
+
import { Tool } from 'langchain/tools';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Base class outlining steps. Basically, each step kind (run/sleep/sleepUntil)
|
|
@@ -63,10 +67,11 @@ declare class AutoExecutor {
|
|
|
63
67
|
private readonly nonPlanStepCount;
|
|
64
68
|
private readonly steps;
|
|
65
69
|
private indexInCurrentList;
|
|
70
|
+
private telemetry?;
|
|
66
71
|
stepCount: number;
|
|
67
72
|
planStepCount: number;
|
|
68
73
|
protected executingStep: string | false;
|
|
69
|
-
constructor(context: WorkflowContext, steps: Step[], debug?: WorkflowLogger);
|
|
74
|
+
constructor(context: WorkflowContext, steps: Step[], telemetry?: Telemetry, debug?: WorkflowLogger);
|
|
70
75
|
/**
|
|
71
76
|
* Adds the step function to the list of step functions to run in
|
|
72
77
|
* parallel. After adding the function, defers the execution, so
|
|
@@ -386,6 +391,76 @@ declare class WorkflowApi extends BaseWorkflowApi {
|
|
|
386
391
|
get anthropic(): AnthropicAPI;
|
|
387
392
|
}
|
|
388
393
|
|
|
394
|
+
declare class Agent {
|
|
395
|
+
readonly name: AgentParameters["name"];
|
|
396
|
+
readonly tools: AgentParameters["tools"];
|
|
397
|
+
readonly maxSteps: AgentParameters["maxSteps"];
|
|
398
|
+
readonly background: AgentParameters["background"];
|
|
399
|
+
readonly model: AgentParameters["model"];
|
|
400
|
+
constructor({ tools, maxSteps, background, name, model }: AgentParameters);
|
|
401
|
+
call({ prompt }: {
|
|
402
|
+
prompt: string;
|
|
403
|
+
}): Promise<ai.GenerateTextResult<Record<string, AISDKTool>, never>>;
|
|
404
|
+
asTool(): AISDKTool;
|
|
405
|
+
}
|
|
406
|
+
type ManagerAgentParameters = {
|
|
407
|
+
agents: Agent[];
|
|
408
|
+
model: Model;
|
|
409
|
+
} & Pick<Partial<AgentParameters>, "name" | "background"> & Pick<AgentParameters, "maxSteps">;
|
|
410
|
+
declare class ManagerAgent extends Agent {
|
|
411
|
+
agents: ManagerAgentParameters["agents"];
|
|
412
|
+
constructor({ maxSteps, background, agents, model, name, }: ManagerAgentParameters);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
type AISDKTool = CoreTool;
|
|
416
|
+
type LangchainTool = Tool;
|
|
417
|
+
type GenerateTextParams = Parameters<typeof generateText>[0];
|
|
418
|
+
type Model = GenerateTextParams["model"];
|
|
419
|
+
type AgentParameters<TTool extends AISDKTool | LangchainTool = AISDKTool> = {
|
|
420
|
+
maxSteps: number;
|
|
421
|
+
background: string;
|
|
422
|
+
tools: Record<string, TTool>;
|
|
423
|
+
name: string;
|
|
424
|
+
model: Model;
|
|
425
|
+
};
|
|
426
|
+
type TaskParams = {
|
|
427
|
+
prompt: string;
|
|
428
|
+
};
|
|
429
|
+
type SingleAgentTaskParams = TaskParams & {
|
|
430
|
+
agent: Agent;
|
|
431
|
+
};
|
|
432
|
+
type MultiAgentTaskParams = TaskParams & {
|
|
433
|
+
agents: Agent[];
|
|
434
|
+
maxSteps: number;
|
|
435
|
+
model: Model;
|
|
436
|
+
background?: string;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
declare const createWorkflowOpenAI: (context: WorkflowContext) => _ai_sdk_openai.OpenAIProvider;
|
|
440
|
+
|
|
441
|
+
declare class Task {
|
|
442
|
+
private readonly context;
|
|
443
|
+
private readonly taskParameters;
|
|
444
|
+
constructor({ context, taskParameters, }: {
|
|
445
|
+
context: WorkflowContext;
|
|
446
|
+
taskParameters: SingleAgentTaskParams | MultiAgentTaskParams;
|
|
447
|
+
});
|
|
448
|
+
run(): Promise<{
|
|
449
|
+
text: string;
|
|
450
|
+
}>;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
declare class WorkflowAgents {
|
|
454
|
+
private context;
|
|
455
|
+
constructor({ context }: {
|
|
456
|
+
context: WorkflowContext;
|
|
457
|
+
});
|
|
458
|
+
agent(params: AgentParameters<AISDKTool | LangchainTool>): Agent;
|
|
459
|
+
task(taskParameters: SingleAgentTaskParams): Task;
|
|
460
|
+
task(taskParameters: MultiAgentTaskParams): Task;
|
|
461
|
+
openai(...params: Parameters<ReturnType<typeof createWorkflowOpenAI>>): ai.LanguageModelV1;
|
|
462
|
+
}
|
|
463
|
+
|
|
389
464
|
/**
|
|
390
465
|
* Upstash Workflow context
|
|
391
466
|
*
|
|
@@ -512,7 +587,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
512
587
|
* Number of retries
|
|
513
588
|
*/
|
|
514
589
|
readonly retries: number;
|
|
515
|
-
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, }: {
|
|
590
|
+
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, telemetry, }: {
|
|
516
591
|
qstashClient: WorkflowClient;
|
|
517
592
|
workflowRunId: string;
|
|
518
593
|
headers: Headers;
|
|
@@ -523,6 +598,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
523
598
|
initialPayload: TInitialPayload;
|
|
524
599
|
env?: Record<string, string | undefined>;
|
|
525
600
|
retries?: number;
|
|
601
|
+
telemetry?: Telemetry;
|
|
526
602
|
});
|
|
527
603
|
/**
|
|
528
604
|
* Executes a workflow step
|
|
@@ -680,6 +756,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
680
756
|
*/
|
|
681
757
|
protected addStep<TResult = unknown>(step: BaseLazyStep<TResult>): Promise<TResult>;
|
|
682
758
|
get api(): WorkflowApi;
|
|
759
|
+
get agents(): WorkflowAgents;
|
|
683
760
|
}
|
|
684
761
|
|
|
685
762
|
/**
|
|
@@ -838,7 +915,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
838
915
|
* @returns void
|
|
839
916
|
*/
|
|
840
917
|
failureFunction?: (failureData: {
|
|
841
|
-
context: Omit<WorkflowContext<TInitialPayload>, "run" | "sleepUntil" | "sleep" | "call" | "waitForEvent" | "notify">;
|
|
918
|
+
context: Omit<WorkflowContext<TInitialPayload>, "run" | "sleepUntil" | "sleep" | "call" | "waitForEvent" | "notify" | "cancel" | "api">;
|
|
842
919
|
failStatus: number;
|
|
843
920
|
failResponse: string;
|
|
844
921
|
failHeaders: Record<string, string[]>;
|
|
@@ -876,6 +953,26 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
876
953
|
* Not part of the public API. Only available in serveBase, which is not exported.
|
|
877
954
|
*/
|
|
878
955
|
useJSONContent?: boolean;
|
|
956
|
+
/**
|
|
957
|
+
* By default, Workflow SDK sends telemetry about SDK version, framework or runtime.
|
|
958
|
+
*
|
|
959
|
+
* Set `disableTelemetry` to disable this behavior.
|
|
960
|
+
*/
|
|
961
|
+
disableTelemetry?: boolean;
|
|
962
|
+
};
|
|
963
|
+
type Telemetry = {
|
|
964
|
+
/**
|
|
965
|
+
* sdk version
|
|
966
|
+
*/
|
|
967
|
+
sdk: string;
|
|
968
|
+
/**
|
|
969
|
+
* platform (such as nextjs/cloudflare)
|
|
970
|
+
*/
|
|
971
|
+
framework: string;
|
|
972
|
+
/**
|
|
973
|
+
* node version
|
|
974
|
+
*/
|
|
975
|
+
runtime?: string;
|
|
879
976
|
};
|
|
880
977
|
type PublicServeOptions<TInitialPayload = unknown, TResponse extends Response = Response> = Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "onStepFinish" | "useJSONContent">;
|
|
881
978
|
/**
|
|
@@ -971,5 +1068,68 @@ type CallSettings<TBody = unknown> = {
|
|
|
971
1068
|
retries?: number;
|
|
972
1069
|
timeout?: Duration | number;
|
|
973
1070
|
};
|
|
1071
|
+
type HeaderParams = {
|
|
1072
|
+
/**
|
|
1073
|
+
* whether the request is a first invocation request.
|
|
1074
|
+
*/
|
|
1075
|
+
initHeaderValue: "true" | "false";
|
|
1076
|
+
/**
|
|
1077
|
+
* run id of the workflow
|
|
1078
|
+
*/
|
|
1079
|
+
workflowRunId: string;
|
|
1080
|
+
/**
|
|
1081
|
+
* url where the workflow is hosted
|
|
1082
|
+
*/
|
|
1083
|
+
workflowUrl: string;
|
|
1084
|
+
/**
|
|
1085
|
+
* user headers which will be forwarded in the request
|
|
1086
|
+
*/
|
|
1087
|
+
userHeaders?: Headers;
|
|
1088
|
+
/**
|
|
1089
|
+
* failure url to call incase of failure
|
|
1090
|
+
*/
|
|
1091
|
+
failureUrl?: WorkflowServeOptions["failureUrl"];
|
|
1092
|
+
/**
|
|
1093
|
+
* retry setting of requests except context.call
|
|
1094
|
+
*/
|
|
1095
|
+
retries?: number;
|
|
1096
|
+
/**
|
|
1097
|
+
* telemetry to include in timeoutHeaders.
|
|
1098
|
+
*
|
|
1099
|
+
* Only needed/used when the step is a waitForEvent step
|
|
1100
|
+
*/
|
|
1101
|
+
telemetry?: Telemetry;
|
|
1102
|
+
} & ({
|
|
1103
|
+
/**
|
|
1104
|
+
* step to generate headers for
|
|
1105
|
+
*/
|
|
1106
|
+
step: Step;
|
|
1107
|
+
/**
|
|
1108
|
+
* number of retries in context.call
|
|
1109
|
+
*/
|
|
1110
|
+
callRetries?: number;
|
|
1111
|
+
/**
|
|
1112
|
+
* timeout duration in context.call
|
|
1113
|
+
*/
|
|
1114
|
+
callTimeout?: number | Duration;
|
|
1115
|
+
} | {
|
|
1116
|
+
/**
|
|
1117
|
+
* step not passed. Either first invocation or simply getting headers for
|
|
1118
|
+
* third party callack.
|
|
1119
|
+
*/
|
|
1120
|
+
step?: never;
|
|
1121
|
+
/**
|
|
1122
|
+
* number of retries in context.call
|
|
1123
|
+
*
|
|
1124
|
+
* set to never because this is not a context.call step
|
|
1125
|
+
*/
|
|
1126
|
+
callRetries?: never;
|
|
1127
|
+
/**
|
|
1128
|
+
* timeout duration in context.call
|
|
1129
|
+
*
|
|
1130
|
+
* set to never because this is not a context.call step
|
|
1131
|
+
*/
|
|
1132
|
+
callTimeout?: never;
|
|
1133
|
+
});
|
|
974
1134
|
|
|
975
|
-
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type FinishCondition as F, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type PublicServeOptions as j, type FailureFunctionPayload as k, type RequiredExceptFields as l, type WaitRequest as m, type WaitStepResponse as n, type NotifyStepResponse as o, type WaitEventOptions as p, type CallSettings as q, type WorkflowLoggerOptions as r, WorkflowLogger as s };
|
|
1135
|
+
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type FinishCondition as F, type HeaderParams as H, type LogLevel as L, ManagerAgent as M, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type Telemetry as T, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type PublicServeOptions as j, type FailureFunctionPayload as k, type RequiredExceptFields as l, type WaitRequest as m, type WaitStepResponse as n, type NotifyStepResponse as o, type WaitEventOptions as p, type CallSettings as q, type WorkflowLoggerOptions as r, WorkflowLogger as s, WorkflowAgents as t, createWorkflowOpenAI as u, Agent as v };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { PublishRequest, Client, Receiver, HTTPMethods as HTTPMethods$1 } from '@upstash/qstash';
|
|
2
|
+
import * as ai from 'ai';
|
|
3
|
+
import { CoreTool, generateText } from 'ai';
|
|
4
|
+
import * as _ai_sdk_openai from '@ai-sdk/openai';
|
|
5
|
+
import { Tool } from 'langchain/tools';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Base class outlining steps. Basically, each step kind (run/sleep/sleepUntil)
|
|
@@ -63,10 +67,11 @@ declare class AutoExecutor {
|
|
|
63
67
|
private readonly nonPlanStepCount;
|
|
64
68
|
private readonly steps;
|
|
65
69
|
private indexInCurrentList;
|
|
70
|
+
private telemetry?;
|
|
66
71
|
stepCount: number;
|
|
67
72
|
planStepCount: number;
|
|
68
73
|
protected executingStep: string | false;
|
|
69
|
-
constructor(context: WorkflowContext, steps: Step[], debug?: WorkflowLogger);
|
|
74
|
+
constructor(context: WorkflowContext, steps: Step[], telemetry?: Telemetry, debug?: WorkflowLogger);
|
|
70
75
|
/**
|
|
71
76
|
* Adds the step function to the list of step functions to run in
|
|
72
77
|
* parallel. After adding the function, defers the execution, so
|
|
@@ -386,6 +391,76 @@ declare class WorkflowApi extends BaseWorkflowApi {
|
|
|
386
391
|
get anthropic(): AnthropicAPI;
|
|
387
392
|
}
|
|
388
393
|
|
|
394
|
+
declare class Agent {
|
|
395
|
+
readonly name: AgentParameters["name"];
|
|
396
|
+
readonly tools: AgentParameters["tools"];
|
|
397
|
+
readonly maxSteps: AgentParameters["maxSteps"];
|
|
398
|
+
readonly background: AgentParameters["background"];
|
|
399
|
+
readonly model: AgentParameters["model"];
|
|
400
|
+
constructor({ tools, maxSteps, background, name, model }: AgentParameters);
|
|
401
|
+
call({ prompt }: {
|
|
402
|
+
prompt: string;
|
|
403
|
+
}): Promise<ai.GenerateTextResult<Record<string, AISDKTool>, never>>;
|
|
404
|
+
asTool(): AISDKTool;
|
|
405
|
+
}
|
|
406
|
+
type ManagerAgentParameters = {
|
|
407
|
+
agents: Agent[];
|
|
408
|
+
model: Model;
|
|
409
|
+
} & Pick<Partial<AgentParameters>, "name" | "background"> & Pick<AgentParameters, "maxSteps">;
|
|
410
|
+
declare class ManagerAgent extends Agent {
|
|
411
|
+
agents: ManagerAgentParameters["agents"];
|
|
412
|
+
constructor({ maxSteps, background, agents, model, name, }: ManagerAgentParameters);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
type AISDKTool = CoreTool;
|
|
416
|
+
type LangchainTool = Tool;
|
|
417
|
+
type GenerateTextParams = Parameters<typeof generateText>[0];
|
|
418
|
+
type Model = GenerateTextParams["model"];
|
|
419
|
+
type AgentParameters<TTool extends AISDKTool | LangchainTool = AISDKTool> = {
|
|
420
|
+
maxSteps: number;
|
|
421
|
+
background: string;
|
|
422
|
+
tools: Record<string, TTool>;
|
|
423
|
+
name: string;
|
|
424
|
+
model: Model;
|
|
425
|
+
};
|
|
426
|
+
type TaskParams = {
|
|
427
|
+
prompt: string;
|
|
428
|
+
};
|
|
429
|
+
type SingleAgentTaskParams = TaskParams & {
|
|
430
|
+
agent: Agent;
|
|
431
|
+
};
|
|
432
|
+
type MultiAgentTaskParams = TaskParams & {
|
|
433
|
+
agents: Agent[];
|
|
434
|
+
maxSteps: number;
|
|
435
|
+
model: Model;
|
|
436
|
+
background?: string;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
declare const createWorkflowOpenAI: (context: WorkflowContext) => _ai_sdk_openai.OpenAIProvider;
|
|
440
|
+
|
|
441
|
+
declare class Task {
|
|
442
|
+
private readonly context;
|
|
443
|
+
private readonly taskParameters;
|
|
444
|
+
constructor({ context, taskParameters, }: {
|
|
445
|
+
context: WorkflowContext;
|
|
446
|
+
taskParameters: SingleAgentTaskParams | MultiAgentTaskParams;
|
|
447
|
+
});
|
|
448
|
+
run(): Promise<{
|
|
449
|
+
text: string;
|
|
450
|
+
}>;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
declare class WorkflowAgents {
|
|
454
|
+
private context;
|
|
455
|
+
constructor({ context }: {
|
|
456
|
+
context: WorkflowContext;
|
|
457
|
+
});
|
|
458
|
+
agent(params: AgentParameters<AISDKTool | LangchainTool>): Agent;
|
|
459
|
+
task(taskParameters: SingleAgentTaskParams): Task;
|
|
460
|
+
task(taskParameters: MultiAgentTaskParams): Task;
|
|
461
|
+
openai(...params: Parameters<ReturnType<typeof createWorkflowOpenAI>>): ai.LanguageModelV1;
|
|
462
|
+
}
|
|
463
|
+
|
|
389
464
|
/**
|
|
390
465
|
* Upstash Workflow context
|
|
391
466
|
*
|
|
@@ -512,7 +587,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
512
587
|
* Number of retries
|
|
513
588
|
*/
|
|
514
589
|
readonly retries: number;
|
|
515
|
-
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, }: {
|
|
590
|
+
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, telemetry, }: {
|
|
516
591
|
qstashClient: WorkflowClient;
|
|
517
592
|
workflowRunId: string;
|
|
518
593
|
headers: Headers;
|
|
@@ -523,6 +598,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
523
598
|
initialPayload: TInitialPayload;
|
|
524
599
|
env?: Record<string, string | undefined>;
|
|
525
600
|
retries?: number;
|
|
601
|
+
telemetry?: Telemetry;
|
|
526
602
|
});
|
|
527
603
|
/**
|
|
528
604
|
* Executes a workflow step
|
|
@@ -680,6 +756,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
680
756
|
*/
|
|
681
757
|
protected addStep<TResult = unknown>(step: BaseLazyStep<TResult>): Promise<TResult>;
|
|
682
758
|
get api(): WorkflowApi;
|
|
759
|
+
get agents(): WorkflowAgents;
|
|
683
760
|
}
|
|
684
761
|
|
|
685
762
|
/**
|
|
@@ -838,7 +915,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
838
915
|
* @returns void
|
|
839
916
|
*/
|
|
840
917
|
failureFunction?: (failureData: {
|
|
841
|
-
context: Omit<WorkflowContext<TInitialPayload>, "run" | "sleepUntil" | "sleep" | "call" | "waitForEvent" | "notify">;
|
|
918
|
+
context: Omit<WorkflowContext<TInitialPayload>, "run" | "sleepUntil" | "sleep" | "call" | "waitForEvent" | "notify" | "cancel" | "api">;
|
|
842
919
|
failStatus: number;
|
|
843
920
|
failResponse: string;
|
|
844
921
|
failHeaders: Record<string, string[]>;
|
|
@@ -876,6 +953,26 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
876
953
|
* Not part of the public API. Only available in serveBase, which is not exported.
|
|
877
954
|
*/
|
|
878
955
|
useJSONContent?: boolean;
|
|
956
|
+
/**
|
|
957
|
+
* By default, Workflow SDK sends telemetry about SDK version, framework or runtime.
|
|
958
|
+
*
|
|
959
|
+
* Set `disableTelemetry` to disable this behavior.
|
|
960
|
+
*/
|
|
961
|
+
disableTelemetry?: boolean;
|
|
962
|
+
};
|
|
963
|
+
type Telemetry = {
|
|
964
|
+
/**
|
|
965
|
+
* sdk version
|
|
966
|
+
*/
|
|
967
|
+
sdk: string;
|
|
968
|
+
/**
|
|
969
|
+
* platform (such as nextjs/cloudflare)
|
|
970
|
+
*/
|
|
971
|
+
framework: string;
|
|
972
|
+
/**
|
|
973
|
+
* node version
|
|
974
|
+
*/
|
|
975
|
+
runtime?: string;
|
|
879
976
|
};
|
|
880
977
|
type PublicServeOptions<TInitialPayload = unknown, TResponse extends Response = Response> = Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "onStepFinish" | "useJSONContent">;
|
|
881
978
|
/**
|
|
@@ -971,5 +1068,68 @@ type CallSettings<TBody = unknown> = {
|
|
|
971
1068
|
retries?: number;
|
|
972
1069
|
timeout?: Duration | number;
|
|
973
1070
|
};
|
|
1071
|
+
type HeaderParams = {
|
|
1072
|
+
/**
|
|
1073
|
+
* whether the request is a first invocation request.
|
|
1074
|
+
*/
|
|
1075
|
+
initHeaderValue: "true" | "false";
|
|
1076
|
+
/**
|
|
1077
|
+
* run id of the workflow
|
|
1078
|
+
*/
|
|
1079
|
+
workflowRunId: string;
|
|
1080
|
+
/**
|
|
1081
|
+
* url where the workflow is hosted
|
|
1082
|
+
*/
|
|
1083
|
+
workflowUrl: string;
|
|
1084
|
+
/**
|
|
1085
|
+
* user headers which will be forwarded in the request
|
|
1086
|
+
*/
|
|
1087
|
+
userHeaders?: Headers;
|
|
1088
|
+
/**
|
|
1089
|
+
* failure url to call incase of failure
|
|
1090
|
+
*/
|
|
1091
|
+
failureUrl?: WorkflowServeOptions["failureUrl"];
|
|
1092
|
+
/**
|
|
1093
|
+
* retry setting of requests except context.call
|
|
1094
|
+
*/
|
|
1095
|
+
retries?: number;
|
|
1096
|
+
/**
|
|
1097
|
+
* telemetry to include in timeoutHeaders.
|
|
1098
|
+
*
|
|
1099
|
+
* Only needed/used when the step is a waitForEvent step
|
|
1100
|
+
*/
|
|
1101
|
+
telemetry?: Telemetry;
|
|
1102
|
+
} & ({
|
|
1103
|
+
/**
|
|
1104
|
+
* step to generate headers for
|
|
1105
|
+
*/
|
|
1106
|
+
step: Step;
|
|
1107
|
+
/**
|
|
1108
|
+
* number of retries in context.call
|
|
1109
|
+
*/
|
|
1110
|
+
callRetries?: number;
|
|
1111
|
+
/**
|
|
1112
|
+
* timeout duration in context.call
|
|
1113
|
+
*/
|
|
1114
|
+
callTimeout?: number | Duration;
|
|
1115
|
+
} | {
|
|
1116
|
+
/**
|
|
1117
|
+
* step not passed. Either first invocation or simply getting headers for
|
|
1118
|
+
* third party callack.
|
|
1119
|
+
*/
|
|
1120
|
+
step?: never;
|
|
1121
|
+
/**
|
|
1122
|
+
* number of retries in context.call
|
|
1123
|
+
*
|
|
1124
|
+
* set to never because this is not a context.call step
|
|
1125
|
+
*/
|
|
1126
|
+
callRetries?: never;
|
|
1127
|
+
/**
|
|
1128
|
+
* timeout duration in context.call
|
|
1129
|
+
*
|
|
1130
|
+
* set to never because this is not a context.call step
|
|
1131
|
+
*/
|
|
1132
|
+
callTimeout?: never;
|
|
1133
|
+
});
|
|
974
1134
|
|
|
975
|
-
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type FinishCondition as F, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type PublicServeOptions as j, type FailureFunctionPayload as k, type RequiredExceptFields as l, type WaitRequest as m, type WaitStepResponse as n, type NotifyStepResponse as o, type WaitEventOptions as p, type CallSettings as q, type WorkflowLoggerOptions as r, WorkflowLogger as s };
|
|
1135
|
+
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type FinishCondition as F, type HeaderParams as H, type LogLevel as L, ManagerAgent as M, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type Telemetry as T, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type PublicServeOptions as j, type FailureFunctionPayload as k, type RequiredExceptFields as l, type WaitRequest as m, type WaitStepResponse as n, type NotifyStepResponse as o, type WaitEventOptions as p, type CallSettings as q, type WorkflowLoggerOptions as r, WorkflowLogger as s, WorkflowAgents as t, createWorkflowOpenAI as u, Agent as v };
|