@upstash/workflow 0.2.12 → 0.2.14
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/astro.d.mts +2 -2
- package/astro.d.ts +2 -2
- package/astro.js +1254 -1072
- package/astro.mjs +1 -1
- package/{chunk-4GTHIL7S.mjs → chunk-RMS2NQ3K.mjs} +918 -734
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +1254 -1072
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +1270 -1088
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +1254 -1072
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +1255 -1073
- package/hono.mjs +2 -2
- package/index.d.mts +124 -15
- package/index.d.ts +124 -15
- package/index.js +1259 -1101
- package/index.mjs +32 -56
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +1254 -1072
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-DLguU9iR.d.mts → serve-many-BF71QZHQ.d.mts} +1 -1
- package/{serve-many-BdMq5rFX.d.ts → serve-many-BMlN2PAB.d.ts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +1220 -1038
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +1254 -1072
- package/svelte.mjs +1 -1
- package/{types-D1W0VOpy.d.ts → types-C1WIgVLA.d.mts} +58 -45
- package/{types-D1W0VOpy.d.mts → types-C1WIgVLA.d.ts} +58 -45
package/svelte.mjs
CHANGED
|
@@ -2,8 +2,47 @@ import { PublishRequest, FlowControl, Client, Receiver, HTTPMethods as HTTPMetho
|
|
|
2
2
|
import { ZodType, z } from 'zod';
|
|
3
3
|
import * as ai from 'ai';
|
|
4
4
|
import { CoreTool, generateText } from 'ai';
|
|
5
|
-
import
|
|
5
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
6
6
|
|
|
7
|
+
declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
|
|
8
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
9
|
+
type ChatLogEntry = {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
workflowRunId: string;
|
|
12
|
+
logLevel: LogLevel;
|
|
13
|
+
eventType: "ENDPOINT_START" | "SUBMIT_THIRD_PARTY_RESULT" | "CREATE_CONTEXT" | "SUBMIT_FIRST_INVOCATION" | "RUN_SINGLE" | "RUN_PARALLEL" | "SUBMIT_STEP" | "SUBMIT_CLEANUP" | "RESPONSE_WORKFLOW" | "RESPONSE_DEFAULT" | "ERROR";
|
|
14
|
+
details: unknown;
|
|
15
|
+
};
|
|
16
|
+
type WorkflowLoggerOptions = {
|
|
17
|
+
logLevel: LogLevel;
|
|
18
|
+
logOutput: "console";
|
|
19
|
+
};
|
|
20
|
+
declare class WorkflowLogger {
|
|
21
|
+
private logs;
|
|
22
|
+
private options;
|
|
23
|
+
private workflowRunId?;
|
|
24
|
+
constructor(options: WorkflowLoggerOptions);
|
|
25
|
+
log(level: LogLevel, eventType: ChatLogEntry["eventType"], details?: unknown): Promise<void>;
|
|
26
|
+
setWorkflowRunId(workflowRunId: string): void;
|
|
27
|
+
private writeToConsole;
|
|
28
|
+
private shouldLog;
|
|
29
|
+
static getLogger(verbose?: boolean | WorkflowLogger): WorkflowLogger | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type HeadersResponse = {
|
|
33
|
+
headers: Record<string, string>;
|
|
34
|
+
contentType: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type StepParams = {
|
|
38
|
+
context: WorkflowContext;
|
|
39
|
+
} & Pick<HeaderParams, "telemetry"> & Required<Pick<HeaderParams, "step" | "invokeCount">>;
|
|
40
|
+
type GetHeaderParams = StepParams;
|
|
41
|
+
type GetBodyParams = StepParams & Omit<HeadersResponse, "contentType">;
|
|
42
|
+
type SubmitStepParams = StepParams & Pick<HeadersResponse, "headers"> & {
|
|
43
|
+
body: string;
|
|
44
|
+
isParallel: boolean;
|
|
45
|
+
};
|
|
7
46
|
/**
|
|
8
47
|
* Base class outlining steps. Basically, each step kind (run/sleep/sleepUntil)
|
|
9
48
|
* should have two methods: getPlanStep & getResultStep.
|
|
@@ -44,31 +83,11 @@ declare abstract class BaseLazyStep<TResult = unknown> {
|
|
|
44
83
|
parseOut(out: unknown): TResult;
|
|
45
84
|
protected safeParseOut(out: string): TResult;
|
|
46
85
|
protected static tryParsing(stepOut: unknown): any;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
timestamp: number;
|
|
53
|
-
workflowRunId: string;
|
|
54
|
-
logLevel: LogLevel;
|
|
55
|
-
eventType: "ENDPOINT_START" | "SUBMIT_THIRD_PARTY_RESULT" | "CREATE_CONTEXT" | "SUBMIT_FIRST_INVOCATION" | "RUN_SINGLE" | "RUN_PARALLEL" | "SUBMIT_STEP" | "SUBMIT_CLEANUP" | "RESPONSE_WORKFLOW" | "RESPONSE_DEFAULT" | "ERROR";
|
|
56
|
-
details: unknown;
|
|
57
|
-
};
|
|
58
|
-
type WorkflowLoggerOptions = {
|
|
59
|
-
logLevel: LogLevel;
|
|
60
|
-
logOutput: "console";
|
|
61
|
-
};
|
|
62
|
-
declare class WorkflowLogger {
|
|
63
|
-
private logs;
|
|
64
|
-
private options;
|
|
65
|
-
private workflowRunId?;
|
|
66
|
-
constructor(options: WorkflowLoggerOptions);
|
|
67
|
-
log(level: LogLevel, eventType: ChatLogEntry["eventType"], details?: unknown): Promise<void>;
|
|
68
|
-
setWorkflowRunId(workflowRunId: string): void;
|
|
69
|
-
private writeToConsole;
|
|
70
|
-
private shouldLog;
|
|
71
|
-
static getLogger(verbose?: boolean | WorkflowLogger): WorkflowLogger | undefined;
|
|
86
|
+
getBody({ step }: GetBodyParams): string;
|
|
87
|
+
getHeaders({ context, telemetry, invokeCount, step }: GetHeaderParams): HeadersResponse;
|
|
88
|
+
submitStep({ context, body, headers }: SubmitStepParams): Promise<{
|
|
89
|
+
messageId: string;
|
|
90
|
+
}[]>;
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
declare class AutoExecutor {
|
|
@@ -156,12 +175,6 @@ declare class AutoExecutor {
|
|
|
156
175
|
* @returns parallel call state
|
|
157
176
|
*/
|
|
158
177
|
protected getParallelCallState(parallelStepCount: number, initialStepCount: number): ParallelCallState;
|
|
159
|
-
/**
|
|
160
|
-
* sends the steps to QStash as batch
|
|
161
|
-
*
|
|
162
|
-
* @param steps steps to send
|
|
163
|
-
*/
|
|
164
|
-
private submitStepsToQStash;
|
|
165
178
|
/**
|
|
166
179
|
* Get the promise by executing the lazt steps list. If there is a single
|
|
167
180
|
* step, we call `runSingle`. Otherwise `runParallel` is called.
|
|
@@ -446,17 +459,6 @@ declare class Agent {
|
|
|
446
459
|
asTool(): AISDKTool;
|
|
447
460
|
}
|
|
448
461
|
|
|
449
|
-
/**
|
|
450
|
-
* creates an AI SDK openai client with a custom
|
|
451
|
-
* fetch implementation which uses context.call.
|
|
452
|
-
*
|
|
453
|
-
* @param context workflow context
|
|
454
|
-
* @returns ai sdk openai
|
|
455
|
-
*/
|
|
456
|
-
declare const createWorkflowOpenAI: (context: WorkflowContext, config?: {
|
|
457
|
-
baseURL?: string;
|
|
458
|
-
apiKey?: string;
|
|
459
|
-
}) => _ai_sdk_openai.OpenAIProvider;
|
|
460
462
|
declare class WorkflowTool<TSchema extends ZodType = ZodType> implements LangchainTool {
|
|
461
463
|
/**
|
|
462
464
|
* description of the tool
|
|
@@ -582,10 +584,13 @@ type MultiAgentTaskParams = TaskParams & {
|
|
|
582
584
|
*/
|
|
583
585
|
background?: string;
|
|
584
586
|
};
|
|
585
|
-
type ModelParams = Parameters<ReturnType<typeof
|
|
587
|
+
type ModelParams = Parameters<ReturnType<typeof createOpenAI>>;
|
|
588
|
+
type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout">;
|
|
586
589
|
type CustomModelSettings = ModelParams["1"] & {
|
|
587
590
|
baseURL?: string;
|
|
588
591
|
apiKey?: string;
|
|
592
|
+
} & {
|
|
593
|
+
callSettings: AgentCallParams;
|
|
589
594
|
};
|
|
590
595
|
type CustomModelParams = [ModelParams[0], CustomModelSettings?];
|
|
591
596
|
type ProviderFunction = (params: {
|
|
@@ -703,10 +708,13 @@ declare class WorkflowAgents {
|
|
|
703
708
|
* creates an openai model for agents
|
|
704
709
|
*/
|
|
705
710
|
openai(...params: CustomModelParams): ai.LanguageModelV1;
|
|
706
|
-
AISDKModel: <TProvider extends ProviderFunction>({ context, provider, providerParams, }: {
|
|
711
|
+
AISDKModel: <TProvider extends ProviderFunction>({ context, provider, providerParams, agentCallParams, }: {
|
|
707
712
|
context: WorkflowContext;
|
|
708
713
|
provider: TProvider;
|
|
709
714
|
providerParams?: Omit<Required<Parameters<TProvider>>[0], "fetch">;
|
|
715
|
+
agentCallParams? /**
|
|
716
|
+
* creates an openai model for agents
|
|
717
|
+
*/: AgentCallParams;
|
|
710
718
|
}) => ReturnType<TProvider>;
|
|
711
719
|
}
|
|
712
720
|
|
|
@@ -942,6 +950,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
942
950
|
* }
|
|
943
951
|
*/
|
|
944
952
|
call<TResult = unknown, TBody = unknown>(stepName: string, settings: CallSettings<TBody>): Promise<CallResponse<TResult>>;
|
|
953
|
+
call<TResult extends {
|
|
954
|
+
workflowRunId: string;
|
|
955
|
+
} = {
|
|
956
|
+
workflowRunId: string;
|
|
957
|
+
}, TBody = unknown>(stepName: string, settings: LazyInvokeStepParams<TBody, unknown> & Pick<CallSettings, "timeout">): Promise<CallResponse<TResult>>;
|
|
945
958
|
/**
|
|
946
959
|
* Pauses workflow execution until a specific event occurs or a timeout is reached.
|
|
947
960
|
*
|
|
@@ -2,8 +2,47 @@ import { PublishRequest, FlowControl, Client, Receiver, HTTPMethods as HTTPMetho
|
|
|
2
2
|
import { ZodType, z } from 'zod';
|
|
3
3
|
import * as ai from 'ai';
|
|
4
4
|
import { CoreTool, generateText } from 'ai';
|
|
5
|
-
import
|
|
5
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
6
6
|
|
|
7
|
+
declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
|
|
8
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
9
|
+
type ChatLogEntry = {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
workflowRunId: string;
|
|
12
|
+
logLevel: LogLevel;
|
|
13
|
+
eventType: "ENDPOINT_START" | "SUBMIT_THIRD_PARTY_RESULT" | "CREATE_CONTEXT" | "SUBMIT_FIRST_INVOCATION" | "RUN_SINGLE" | "RUN_PARALLEL" | "SUBMIT_STEP" | "SUBMIT_CLEANUP" | "RESPONSE_WORKFLOW" | "RESPONSE_DEFAULT" | "ERROR";
|
|
14
|
+
details: unknown;
|
|
15
|
+
};
|
|
16
|
+
type WorkflowLoggerOptions = {
|
|
17
|
+
logLevel: LogLevel;
|
|
18
|
+
logOutput: "console";
|
|
19
|
+
};
|
|
20
|
+
declare class WorkflowLogger {
|
|
21
|
+
private logs;
|
|
22
|
+
private options;
|
|
23
|
+
private workflowRunId?;
|
|
24
|
+
constructor(options: WorkflowLoggerOptions);
|
|
25
|
+
log(level: LogLevel, eventType: ChatLogEntry["eventType"], details?: unknown): Promise<void>;
|
|
26
|
+
setWorkflowRunId(workflowRunId: string): void;
|
|
27
|
+
private writeToConsole;
|
|
28
|
+
private shouldLog;
|
|
29
|
+
static getLogger(verbose?: boolean | WorkflowLogger): WorkflowLogger | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type HeadersResponse = {
|
|
33
|
+
headers: Record<string, string>;
|
|
34
|
+
contentType: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type StepParams = {
|
|
38
|
+
context: WorkflowContext;
|
|
39
|
+
} & Pick<HeaderParams, "telemetry"> & Required<Pick<HeaderParams, "step" | "invokeCount">>;
|
|
40
|
+
type GetHeaderParams = StepParams;
|
|
41
|
+
type GetBodyParams = StepParams & Omit<HeadersResponse, "contentType">;
|
|
42
|
+
type SubmitStepParams = StepParams & Pick<HeadersResponse, "headers"> & {
|
|
43
|
+
body: string;
|
|
44
|
+
isParallel: boolean;
|
|
45
|
+
};
|
|
7
46
|
/**
|
|
8
47
|
* Base class outlining steps. Basically, each step kind (run/sleep/sleepUntil)
|
|
9
48
|
* should have two methods: getPlanStep & getResultStep.
|
|
@@ -44,31 +83,11 @@ declare abstract class BaseLazyStep<TResult = unknown> {
|
|
|
44
83
|
parseOut(out: unknown): TResult;
|
|
45
84
|
protected safeParseOut(out: string): TResult;
|
|
46
85
|
protected static tryParsing(stepOut: unknown): any;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
timestamp: number;
|
|
53
|
-
workflowRunId: string;
|
|
54
|
-
logLevel: LogLevel;
|
|
55
|
-
eventType: "ENDPOINT_START" | "SUBMIT_THIRD_PARTY_RESULT" | "CREATE_CONTEXT" | "SUBMIT_FIRST_INVOCATION" | "RUN_SINGLE" | "RUN_PARALLEL" | "SUBMIT_STEP" | "SUBMIT_CLEANUP" | "RESPONSE_WORKFLOW" | "RESPONSE_DEFAULT" | "ERROR";
|
|
56
|
-
details: unknown;
|
|
57
|
-
};
|
|
58
|
-
type WorkflowLoggerOptions = {
|
|
59
|
-
logLevel: LogLevel;
|
|
60
|
-
logOutput: "console";
|
|
61
|
-
};
|
|
62
|
-
declare class WorkflowLogger {
|
|
63
|
-
private logs;
|
|
64
|
-
private options;
|
|
65
|
-
private workflowRunId?;
|
|
66
|
-
constructor(options: WorkflowLoggerOptions);
|
|
67
|
-
log(level: LogLevel, eventType: ChatLogEntry["eventType"], details?: unknown): Promise<void>;
|
|
68
|
-
setWorkflowRunId(workflowRunId: string): void;
|
|
69
|
-
private writeToConsole;
|
|
70
|
-
private shouldLog;
|
|
71
|
-
static getLogger(verbose?: boolean | WorkflowLogger): WorkflowLogger | undefined;
|
|
86
|
+
getBody({ step }: GetBodyParams): string;
|
|
87
|
+
getHeaders({ context, telemetry, invokeCount, step }: GetHeaderParams): HeadersResponse;
|
|
88
|
+
submitStep({ context, body, headers }: SubmitStepParams): Promise<{
|
|
89
|
+
messageId: string;
|
|
90
|
+
}[]>;
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
declare class AutoExecutor {
|
|
@@ -156,12 +175,6 @@ declare class AutoExecutor {
|
|
|
156
175
|
* @returns parallel call state
|
|
157
176
|
*/
|
|
158
177
|
protected getParallelCallState(parallelStepCount: number, initialStepCount: number): ParallelCallState;
|
|
159
|
-
/**
|
|
160
|
-
* sends the steps to QStash as batch
|
|
161
|
-
*
|
|
162
|
-
* @param steps steps to send
|
|
163
|
-
*/
|
|
164
|
-
private submitStepsToQStash;
|
|
165
178
|
/**
|
|
166
179
|
* Get the promise by executing the lazt steps list. If there is a single
|
|
167
180
|
* step, we call `runSingle`. Otherwise `runParallel` is called.
|
|
@@ -446,17 +459,6 @@ declare class Agent {
|
|
|
446
459
|
asTool(): AISDKTool;
|
|
447
460
|
}
|
|
448
461
|
|
|
449
|
-
/**
|
|
450
|
-
* creates an AI SDK openai client with a custom
|
|
451
|
-
* fetch implementation which uses context.call.
|
|
452
|
-
*
|
|
453
|
-
* @param context workflow context
|
|
454
|
-
* @returns ai sdk openai
|
|
455
|
-
*/
|
|
456
|
-
declare const createWorkflowOpenAI: (context: WorkflowContext, config?: {
|
|
457
|
-
baseURL?: string;
|
|
458
|
-
apiKey?: string;
|
|
459
|
-
}) => _ai_sdk_openai.OpenAIProvider;
|
|
460
462
|
declare class WorkflowTool<TSchema extends ZodType = ZodType> implements LangchainTool {
|
|
461
463
|
/**
|
|
462
464
|
* description of the tool
|
|
@@ -582,10 +584,13 @@ type MultiAgentTaskParams = TaskParams & {
|
|
|
582
584
|
*/
|
|
583
585
|
background?: string;
|
|
584
586
|
};
|
|
585
|
-
type ModelParams = Parameters<ReturnType<typeof
|
|
587
|
+
type ModelParams = Parameters<ReturnType<typeof createOpenAI>>;
|
|
588
|
+
type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout">;
|
|
586
589
|
type CustomModelSettings = ModelParams["1"] & {
|
|
587
590
|
baseURL?: string;
|
|
588
591
|
apiKey?: string;
|
|
592
|
+
} & {
|
|
593
|
+
callSettings: AgentCallParams;
|
|
589
594
|
};
|
|
590
595
|
type CustomModelParams = [ModelParams[0], CustomModelSettings?];
|
|
591
596
|
type ProviderFunction = (params: {
|
|
@@ -703,10 +708,13 @@ declare class WorkflowAgents {
|
|
|
703
708
|
* creates an openai model for agents
|
|
704
709
|
*/
|
|
705
710
|
openai(...params: CustomModelParams): ai.LanguageModelV1;
|
|
706
|
-
AISDKModel: <TProvider extends ProviderFunction>({ context, provider, providerParams, }: {
|
|
711
|
+
AISDKModel: <TProvider extends ProviderFunction>({ context, provider, providerParams, agentCallParams, }: {
|
|
707
712
|
context: WorkflowContext;
|
|
708
713
|
provider: TProvider;
|
|
709
714
|
providerParams?: Omit<Required<Parameters<TProvider>>[0], "fetch">;
|
|
715
|
+
agentCallParams? /**
|
|
716
|
+
* creates an openai model for agents
|
|
717
|
+
*/: AgentCallParams;
|
|
710
718
|
}) => ReturnType<TProvider>;
|
|
711
719
|
}
|
|
712
720
|
|
|
@@ -942,6 +950,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
942
950
|
* }
|
|
943
951
|
*/
|
|
944
952
|
call<TResult = unknown, TBody = unknown>(stepName: string, settings: CallSettings<TBody>): Promise<CallResponse<TResult>>;
|
|
953
|
+
call<TResult extends {
|
|
954
|
+
workflowRunId: string;
|
|
955
|
+
} = {
|
|
956
|
+
workflowRunId: string;
|
|
957
|
+
}, TBody = unknown>(stepName: string, settings: LazyInvokeStepParams<TBody, unknown> & Pick<CallSettings, "timeout">): Promise<CallResponse<TResult>>;
|
|
945
958
|
/**
|
|
946
959
|
* Pauses workflow execution until a specific event occurs or a timeout is reached.
|
|
947
960
|
*
|