runwork 0.38.0 → 0.41.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/README.md +1 -1
- package/bundled-types/core-agent.d.ts +12 -25
- package/bundled-types/core-ai.d.ts +5 -3
- package/bundled-types/core-base-agent.d.ts +15 -8
- package/bundled-types/core-endpoints.d.ts +1 -1
- package/bundled-types/core-scheduler.d.ts +5 -4
- package/bundled-types/core-utils.d.ts +5 -0
- package/bundled-types/task-delegation/task-delegation/index.d.ts +2 -2
- package/bundled-types/task-delegation/task-delegation/types.d.ts +6 -31
- package/bundled-types/vite.d.ts +7 -0
- package/dist/index.js +4982 -4138
- package/package.json +10 -11
package/README.md
CHANGED
|
@@ -206,7 +206,7 @@ my-app/
|
|
|
206
206
|
## Requirements
|
|
207
207
|
|
|
208
208
|
- A [Runwork](https://www.runwork.ai) account
|
|
209
|
-
- Node.js
|
|
209
|
+
- Node.js 22.22 or newer (only required when installing via npm)
|
|
210
210
|
|
|
211
211
|
Git is not required: the CLI installs its own under `~/.runwork/git` the first time a command needs it.
|
|
212
212
|
|
|
@@ -26,6 +26,7 @@ import type { Env } from './core-utils';
|
|
|
26
26
|
import type { IntegrationClient } from './core-integrations';
|
|
27
27
|
import type { ExecutionLimits } from './task-delegation/types';
|
|
28
28
|
import type { $ZodType } from 'zod/v4/core';
|
|
29
|
+
import type { z as zod3 } from 'zod/v3';
|
|
29
30
|
/**
|
|
30
31
|
* Agent state persisted across conversations
|
|
31
32
|
*/
|
|
@@ -141,7 +142,7 @@ export declare function parseAppEndpointRef(ref: string): AppEndpointRef | null;
|
|
|
141
142
|
*/
|
|
142
143
|
export declare function appEndpointToolName(ref: AppEndpointRef): string;
|
|
143
144
|
/** A zod object schema, written with zod 3 or zod 4. */
|
|
144
|
-
export type AnyZodObject =
|
|
145
|
+
export type AnyZodObject = zod3.ZodObject<zod3.ZodRawShape> | $ZodType<Record<string, unknown>>;
|
|
145
146
|
/**
|
|
146
147
|
* Custom tool definition for agents
|
|
147
148
|
*/
|
|
@@ -225,42 +226,28 @@ export interface AgentToolDef {
|
|
|
225
226
|
export declare const entityListSchema: z.ZodObject<{
|
|
226
227
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
227
228
|
cursor: z.ZodOptional<z.ZodString>;
|
|
228
|
-
},
|
|
229
|
-
cursor?: string | undefined;
|
|
230
|
-
limit?: number | undefined;
|
|
231
|
-
}, {
|
|
232
|
-
cursor?: string | undefined;
|
|
233
|
-
limit?: number | undefined;
|
|
234
|
-
}>;
|
|
229
|
+
}, z.core.$strip>;
|
|
235
230
|
/** Zod schema for entity get tool */
|
|
236
231
|
export declare const entityGetSchema: z.ZodObject<{
|
|
237
232
|
id: z.ZodString;
|
|
238
|
-
},
|
|
239
|
-
id: string;
|
|
240
|
-
}, {
|
|
241
|
-
id: string;
|
|
242
|
-
}>;
|
|
233
|
+
}, z.core.$strip>;
|
|
243
234
|
/**
|
|
244
235
|
* Get tool definitions for entity access
|
|
245
236
|
*/
|
|
246
237
|
export declare function getEntityToolDefs(entities: string[]): AgentToolDef[];
|
|
247
238
|
/** Zod schema for integration API tool */
|
|
248
239
|
export declare const integrationApiSchema: z.ZodObject<{
|
|
249
|
-
method: z.ZodDefault<z.ZodEnum<
|
|
240
|
+
method: z.ZodDefault<z.ZodEnum<{
|
|
241
|
+
POST: "POST";
|
|
242
|
+
GET: "GET";
|
|
243
|
+
PUT: "PUT";
|
|
244
|
+
PATCH: "PATCH";
|
|
245
|
+
DELETE: "DELETE";
|
|
246
|
+
}>>;
|
|
250
247
|
endpoint: z.ZodString;
|
|
251
248
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
252
249
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
253
|
-
},
|
|
254
|
-
method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
|
|
255
|
-
endpoint: string;
|
|
256
|
-
data?: Record<string, unknown> | undefined;
|
|
257
|
-
headers?: Record<string, string> | undefined;
|
|
258
|
-
}, {
|
|
259
|
-
endpoint: string;
|
|
260
|
-
data?: Record<string, unknown> | undefined;
|
|
261
|
-
method?: "POST" | "GET" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
262
|
-
headers?: Record<string, string> | undefined;
|
|
263
|
-
}>;
|
|
250
|
+
}, z.core.$strip>;
|
|
264
251
|
/**
|
|
265
252
|
* Get tool definitions for integration access
|
|
266
253
|
*/
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
import { type ModelMessage, type UserContent, type ToolSet, type ToolChoice } from 'ai';
|
|
41
41
|
import type { Hono } from 'hono';
|
|
42
42
|
import type { z } from 'zod';
|
|
43
|
+
import type { z as zod3 } from 'zod/v3';
|
|
43
44
|
import { type Env } from './core-utils';
|
|
44
45
|
export { tool, type ModelMessage, type ModelMessage as CoreMessage, type Tool, type ToolSet, type ToolChoice, type TextPart, type ImagePart, type FilePart, type UserContent, type DataContent, } from 'ai';
|
|
45
46
|
/**
|
|
@@ -96,7 +97,8 @@ export interface GenerateObjectOptions<T> extends Omit<AICallSettings, 'stopSequ
|
|
|
96
97
|
/** System prompt for context/behavior */
|
|
97
98
|
system?: string;
|
|
98
99
|
/** Zod schema for structured output */
|
|
99
|
-
schema
|
|
100
|
+
/** A zod 4 or zod 3 schema. */
|
|
101
|
+
schema: z.ZodType<T> | zod3.ZodType<T>;
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
104
|
* Generate text completion using the AI proxy.
|
|
@@ -113,7 +115,7 @@ export interface GenerateObjectOptions<T> extends Omit<AICallSettings, 'stopSequ
|
|
|
113
115
|
* console.log(result.text);
|
|
114
116
|
* ```
|
|
115
117
|
*/
|
|
116
|
-
export declare function generateText(env: Env, options: GenerateTextOptions): Promise<import("ai").GenerateTextResult<ToolSet,
|
|
118
|
+
export declare function generateText(env: Env, options: GenerateTextOptions): Promise<import("ai").GenerateTextResult<ToolSet, any, import("ai").OutputInterface<string, string, any>>>;
|
|
117
119
|
/**
|
|
118
120
|
* Stream text generation using the AI proxy.
|
|
119
121
|
*
|
|
@@ -136,7 +138,7 @@ export declare function generateText(env: Env, options: GenerateTextOptions): Pr
|
|
|
136
138
|
* return result.toTextStreamResponse();
|
|
137
139
|
* ```
|
|
138
140
|
*/
|
|
139
|
-
export declare function streamText(env: Env, options: StreamTextOptions): Promise<import("ai").StreamTextResult<ToolSet, never
|
|
141
|
+
export declare function streamText(env: Env, options: StreamTextOptions): Promise<import("ai").StreamTextResult<ToolSet, any, import("ai").OutputInterface<string, string, never>>>;
|
|
140
142
|
/**
|
|
141
143
|
* Generate structured output (JSON) using the AI proxy.
|
|
142
144
|
* Uses Zod schema for type-safe structured generation.
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* Agent definitions are loaded from the APP_AGENTS registry based on
|
|
18
18
|
* the agent name stored in the DO's storage.
|
|
19
19
|
*/
|
|
20
|
-
import { AIChatAgent } from '
|
|
21
|
-
import { type
|
|
20
|
+
import { AIChatAgent } from '@cloudflare/ai-chat';
|
|
21
|
+
import { type GenerateTextOnFinishCallback, type ToolSet, type UIMessage } from 'ai';
|
|
22
22
|
import { type Env } from './core-utils';
|
|
23
23
|
import { type AgentDefinition, type AgentRuntimeStatus } from './core-agent';
|
|
24
24
|
/**
|
|
@@ -40,6 +40,11 @@ export declare class BaseAgent extends AIChatAgent<Env> {
|
|
|
40
40
|
* Load the agent definition from storage
|
|
41
41
|
*/
|
|
42
42
|
onStart(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Load the definition named in storage. A turn calls this rather than `onStart()`, which the chat base class
|
|
45
|
+
* wraps with its own start-up work (lifting stored history, hydrating messages).
|
|
46
|
+
*/
|
|
47
|
+
private loadDefinition;
|
|
43
48
|
/**
|
|
44
49
|
* Set the agent name and load its definition
|
|
45
50
|
* Called when initializing a new agent instance
|
|
@@ -49,17 +54,19 @@ export declare class BaseAgent extends AIChatAgent<Env> {
|
|
|
49
54
|
* Start a turn from the server rather than from a chat connection.
|
|
50
55
|
*
|
|
51
56
|
* `runRef` is the run reference of the request that asked for this turn
|
|
52
|
-
* (`internal/run-ref.ts`)
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
57
|
+
* (`internal/run-ref.ts`), and `visitToken` the visit token it held
|
|
58
|
+
* (`internal/visit-token.ts`). They are explicit arguments because the
|
|
59
|
+
* request's own stores do not cross into this Durable Object. The turn, and
|
|
60
|
+
* every model and tool call it makes, holds both; the agent keeps nothing, so
|
|
61
|
+
* a later turn holds only what its own caller hands it, and a chat message
|
|
62
|
+
* holds none.
|
|
56
63
|
*/
|
|
57
|
-
|
|
64
|
+
sendFromServer(messages: UIMessage[], runRef?: string, visitToken?: string): Promise<void>;
|
|
58
65
|
/**
|
|
59
66
|
* Handle incoming chat messages using AI SDK
|
|
60
67
|
* This is the main entry point called by AIChatAgent when a message arrives
|
|
61
68
|
*/
|
|
62
|
-
onChatMessage(onFinish:
|
|
69
|
+
onChatMessage(onFinish: GenerateTextOnFinishCallback<ToolSet>): Promise<Response>;
|
|
63
70
|
/**
|
|
64
71
|
* Build tools from agent definition using AI SDK tool() helper
|
|
65
72
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type Env } from './core-utils';
|
|
9
9
|
import type { Hono } from 'hono';
|
|
10
|
-
import type { z as zod3 } from 'zod';
|
|
10
|
+
import type { z as zod3 } from 'zod/v3';
|
|
11
11
|
import type { ZodType as Zod4Type } from 'zod/v4';
|
|
12
12
|
/**
|
|
13
13
|
* A schema an endpoint validates with: zod 3, or zod 4's classic API (which
|
|
@@ -171,11 +171,12 @@ export declare class SchedulerDO extends DurableObject<Env> {
|
|
|
171
171
|
/**
|
|
172
172
|
* Manually trigger a job (for testing/debugging)
|
|
173
173
|
*
|
|
174
|
-
* `runRef` is the run reference of the request that asked for this run
|
|
175
|
-
*
|
|
176
|
-
* this Durable Object, and the handler
|
|
174
|
+
* `runRef` is the run reference of the request that asked for this run, and
|
|
175
|
+
* `visitToken` the visit token it held. They arrive as plain strings because
|
|
176
|
+
* AsyncLocalStorage does not cross into this Durable Object, and the handler
|
|
177
|
+
* runs holding both.
|
|
177
178
|
*/
|
|
178
|
-
triggerJob(jobName: string, runRef?: string): Promise<JobResult>;
|
|
179
|
+
triggerJob(jobName: string, runRef?: string, visitToken?: string): Promise<JobResult>;
|
|
179
180
|
/**
|
|
180
181
|
* Pause a scheduled job
|
|
181
182
|
*/
|
|
@@ -183,6 +183,11 @@ export declare function getRunContext(): RunContext | undefined;
|
|
|
183
183
|
* One serialised header rather than several, so adding a field never needs a
|
|
184
184
|
* matching change in the platform's parsing. Never overwrites a header the
|
|
185
185
|
* caller set: a caller that knows its own context beats the ambient one.
|
|
186
|
+
*
|
|
187
|
+
* A held visit token (`internal/visit-token.ts`) rides in the same header as
|
|
188
|
+
* `visitToken`, so every platform call made on a visit can be attributed to
|
|
189
|
+
* its visitor with no change at the call site. It is not a `RunContext` field:
|
|
190
|
+
* it is held in its own store, so a nested run never drops it.
|
|
186
191
|
*/
|
|
187
192
|
export declare function withRunContextHeader(init?: HeadersInit): HeadersInit | undefined;
|
|
188
193
|
export declare function platformFetch(env: Env, url: string | URL, rawInit?: RequestInit): Promise<Response>;
|
|
@@ -17,7 +17,7 @@ export type { AgentTaskResult, AgentTaskUsage, AgentTaskInputFile, AgentTaskOutp
|
|
|
17
17
|
*
|
|
18
18
|
* @param agentName - Agent name. Use "appId:agentName" to target an agent in
|
|
19
19
|
* another app; otherwise the current app's APP_ID is used.
|
|
20
|
-
* @param env - Worker environment bindings (needs
|
|
20
|
+
* @param env - Worker environment bindings (needs APP_ID; reaches the platform through the platform binding when deployed, else WORKSPACE_API_URL and WORKSPACE_API_KEY)
|
|
21
21
|
* @param options - Optional prompt, input files, timeout, session resume, and await flag
|
|
22
22
|
*/
|
|
23
23
|
export declare function runAgentTask(agentName: string, env: Env, options?: RunAgentTaskOptions): Promise<AgentTaskExecution>;
|
|
@@ -25,6 +25,6 @@ export declare function runAgentTask(agentName: string, env: Env, options?: RunA
|
|
|
25
25
|
* Query the status of a task agent execution by its execution ID.
|
|
26
26
|
*
|
|
27
27
|
* @param executionId - The execution identifier returned by {@link runAgentTask}
|
|
28
|
-
* @param env - Worker environment bindings (
|
|
28
|
+
* @param env - Worker environment bindings (reaches the platform through the platform binding when deployed, else WORKSPACE_API_URL and WORKSPACE_API_KEY)
|
|
29
29
|
*/
|
|
30
30
|
export declare function getAgentTaskStatus(executionId: string, env: Env): Promise<AgentTaskExecution>;
|
|
@@ -130,40 +130,15 @@ export declare const agentTaskToolSchema: z.ZodObject<{
|
|
|
130
130
|
inputFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
131
131
|
name: z.ZodString;
|
|
132
132
|
content: z.ZodString;
|
|
133
|
-
encoding: z.ZodOptional<z.ZodEnum<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}, {
|
|
139
|
-
name: string;
|
|
140
|
-
content: string;
|
|
141
|
-
encoding?: "utf-8" | "base64" | undefined;
|
|
142
|
-
}>, "many">>;
|
|
133
|
+
encoding: z.ZodOptional<z.ZodEnum<{
|
|
134
|
+
"utf-8": "utf-8";
|
|
135
|
+
base64: "base64";
|
|
136
|
+
}>>;
|
|
137
|
+
}, z.core.$strip>>>;
|
|
143
138
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
144
139
|
timeout: z.ZodOptional<z.ZodString>;
|
|
145
140
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
146
|
-
},
|
|
147
|
-
prompt: string;
|
|
148
|
-
timeout?: string | undefined;
|
|
149
|
-
inputFiles?: {
|
|
150
|
-
name: string;
|
|
151
|
-
content: string;
|
|
152
|
-
encoding?: "utf-8" | "base64" | undefined;
|
|
153
|
-
}[] | undefined;
|
|
154
|
-
maxTurns?: number | undefined;
|
|
155
|
-
sessionId?: string | undefined;
|
|
156
|
-
}, {
|
|
157
|
-
prompt: string;
|
|
158
|
-
timeout?: string | undefined;
|
|
159
|
-
inputFiles?: {
|
|
160
|
-
name: string;
|
|
161
|
-
content: string;
|
|
162
|
-
encoding?: "utf-8" | "base64" | undefined;
|
|
163
|
-
}[] | undefined;
|
|
164
|
-
maxTurns?: number | undefined;
|
|
165
|
-
sessionId?: string | undefined;
|
|
166
|
-
}>;
|
|
141
|
+
}, z.core.$strip>;
|
|
167
142
|
/**
|
|
168
143
|
* Environment variable names that the platform always controls. Any values
|
|
169
144
|
* supplied for these keys are silently discarded to prevent callers from
|
package/bundled-types/vite.d.ts
CHANGED
|
@@ -19,5 +19,12 @@ export interface RunworkPluginOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
jsonLogger?: boolean;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Stop an app whose own `agents` or `ai` predates this framework, before it starts. Its chat client and AI code
|
|
24
|
+
* would otherwise meet a server and SDK they were not written for, and fail in ways nobody can trace. Apps made
|
|
25
|
+
* from templates before 5.0.0 ask for the framework on the `next` tag, which stays on 0.14, so they meet this
|
|
26
|
+
* only when the framework was changed by hand.
|
|
27
|
+
*/
|
|
28
|
+
export declare function assertAiStackMatchesFramework(root: string): void;
|
|
22
29
|
export declare function runwork(options?: RunworkPluginOptions): ReturnType<typeof defineConfig>;
|
|
23
30
|
export type { Plugin };
|