runwork 0.2.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/LICENSE +21 -0
- package/README.md +134 -0
- package/bin/runwork.js +2 -0
- package/bundled-types/agents.d.ts +3 -0
- package/bundled-types/ai.d.ts +2 -0
- package/bundled-types/app-registry.d.ts +74 -0
- package/bundled-types/channels.d.ts +2 -0
- package/bundled-types/components.d.ts +1 -0
- package/bundled-types/core-agent.d.ts +265 -0
- package/bundled-types/core-ai.d.ts +170 -0
- package/bundled-types/core-base-agent.d.ts +89 -0
- package/bundled-types/core-channels.d.ts +42 -0
- package/bundled-types/core-components.d.ts +21 -0
- package/bundled-types/core-endpoints.d.ts +198 -0
- package/bundled-types/core-entities.d.ts +276 -0
- package/bundled-types/core-entity-do.d.ts +119 -0
- package/bundled-types/core-events.d.ts +52 -0
- package/bundled-types/core-file-storage.d.ts +216 -0
- package/bundled-types/core-integration-entities.d.ts +147 -0
- package/bundled-types/core-integrations.d.ts +143 -0
- package/bundled-types/core-routes.d.ts +33 -0
- package/bundled-types/core-scheduler.d.ts +180 -0
- package/bundled-types/core-utils.d.ts +85 -0
- package/bundled-types/core-workflow-cloudflare.d.ts +85 -0
- package/bundled-types/core-workflow-config.d.ts +18 -0
- package/bundled-types/core-workflow-coordinator.d.ts +78 -0
- package/bundled-types/core-workflow-instance.d.ts +82 -0
- package/bundled-types/core-workflow-types.d.ts +251 -0
- package/bundled-types/core-workflows.d.ts +75 -0
- package/bundled-types/core-workspace.d.ts +454 -0
- package/bundled-types/create-app.d.ts +57 -0
- package/bundled-types/endpoints.d.ts +2 -0
- package/bundled-types/entities.d.ts +5 -0
- package/bundled-types/events.d.ts +2 -0
- package/bundled-types/index.d.ts +19 -0
- package/bundled-types/integrations.d.ts +2 -0
- package/bundled-types/routes.d.ts +2 -0
- package/bundled-types/scheduler.d.ts +2 -0
- package/bundled-types/storage.d.ts +2 -0
- package/bundled-types/test-entry.d.ts +21 -0
- package/bundled-types/types.d.ts +1 -0
- package/bundled-types/vite.d.ts +23 -0
- package/bundled-types/workflows.d.ts +14 -0
- package/bundled-types/workspace.d.ts +2 -0
- package/dist/__tests__/types-manager.test.d.ts +1 -0
- package/dist/__tests__/types-manager.test.js +85 -0
- package/dist/api/__tests__/client.test.d.ts +1 -0
- package/dist/api/__tests__/client.test.js +264 -0
- package/dist/api/client.d.ts +72 -0
- package/dist/api/client.js +144 -0
- package/dist/auth/__tests__/store.test.d.ts +1 -0
- package/dist/auth/__tests__/store.test.js +103 -0
- package/dist/auth/browser.d.ts +2 -0
- package/dist/auth/browser.js +7 -0
- package/dist/auth/store.d.ts +5 -0
- package/dist/auth/store.js +33 -0
- package/dist/commands/clone.d.ts +2 -0
- package/dist/commands/clone.js +90 -0
- package/dist/commands/deploy.d.ts +2 -0
- package/dist/commands/deploy.js +43 -0
- package/dist/commands/dev.d.ts +2 -0
- package/dist/commands/dev.js +188 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +87 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +32 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +13 -0
- package/dist/commands/logs.d.ts +2 -0
- package/dist/commands/logs.js +166 -0
- package/dist/generated/bundled-types.d.ts +1 -0
- package/dist/generated/bundled-types.js +44 -0
- package/dist/generated/version.d.ts +1 -0
- package/dist/generated/version.js +2 -0
- package/dist/git/__tests__/credentials.test.d.ts +1 -0
- package/dist/git/__tests__/credentials.test.js +128 -0
- package/dist/git/auto-commit.d.ts +3 -0
- package/dist/git/auto-commit.js +209 -0
- package/dist/git/credentials.d.ts +15 -0
- package/dist/git/credentials.js +65 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -0
- package/dist/logs/tailer.d.ts +13 -0
- package/dist/logs/tailer.js +135 -0
- package/dist/template/manifest.d.ts +17 -0
- package/dist/template/manifest.js +102 -0
- package/dist/types-manager.d.ts +1 -0
- package/dist/types-manager.js +35 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.js +1 -0
- package/dist/utils/__tests__/prompt.test.d.ts +1 -0
- package/dist/utils/__tests__/prompt.test.js +103 -0
- package/dist/utils/fs.d.ts +5 -0
- package/dist/utils/fs.js +23 -0
- package/dist/utils/prompt.d.ts +4 -0
- package/dist/utils/prompt.js +34 -0
- package/dist/utils/zip.d.ts +1 -0
- package/dist/utils/zip.js +17 -0
- package/package.json +66 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Workspace Context
|
|
3
|
+
* DO NOT MODIFY THIS FILE - You may break the workspace functionality
|
|
4
|
+
*
|
|
5
|
+
* This module provides cross-app data sharing and workspace registration.
|
|
6
|
+
* Apps in the same workspace can query each other's entities and register
|
|
7
|
+
* their capabilities (entities, components, endpoints, etc.).
|
|
8
|
+
*/
|
|
9
|
+
import type { Env } from './core-utils';
|
|
10
|
+
/**
|
|
11
|
+
* WorkspaceUser - Represents a member of the workspace
|
|
12
|
+
* Read-only data provided by the platform
|
|
13
|
+
*/
|
|
14
|
+
export interface WorkspaceUser {
|
|
15
|
+
id: string;
|
|
16
|
+
email: string;
|
|
17
|
+
name: string;
|
|
18
|
+
role: 'owner' | 'admin' | 'editor' | 'viewer';
|
|
19
|
+
avatarUrl: string | null;
|
|
20
|
+
joinedAt: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ListUsersOptions {
|
|
23
|
+
limit?: number;
|
|
24
|
+
cursor?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ListUsersResponse {
|
|
27
|
+
items: WorkspaceUser[];
|
|
28
|
+
next: string | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parameters for sending a notification to a workspace user
|
|
32
|
+
* The platform wraps your content in a standard notification template
|
|
33
|
+
*/
|
|
34
|
+
export interface NotifyUserParams {
|
|
35
|
+
/** User ID of the recipient (must be a workspace member) */
|
|
36
|
+
userId: string;
|
|
37
|
+
/** Notification title/subject */
|
|
38
|
+
title: string;
|
|
39
|
+
/** Plain text content (required) */
|
|
40
|
+
content: string;
|
|
41
|
+
/** Optional HTML content for rich formatting */
|
|
42
|
+
html?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result of sending a notification
|
|
46
|
+
*/
|
|
47
|
+
export interface NotifyUserResult {
|
|
48
|
+
success: boolean;
|
|
49
|
+
notificationId?: string;
|
|
50
|
+
error?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ListEntityRequest extends Record<string, unknown> {
|
|
53
|
+
entityName: string;
|
|
54
|
+
filters?: Record<string, unknown>;
|
|
55
|
+
limit?: number;
|
|
56
|
+
cursor?: string | null;
|
|
57
|
+
deploymentMode?: 'preview' | 'production';
|
|
58
|
+
}
|
|
59
|
+
export interface ListEntityResponse<T = unknown> {
|
|
60
|
+
items: T[];
|
|
61
|
+
next: string | null;
|
|
62
|
+
}
|
|
63
|
+
export interface GetEntityRequest extends Record<string, unknown> {
|
|
64
|
+
entityName: string;
|
|
65
|
+
id: string;
|
|
66
|
+
deploymentMode?: 'preview' | 'production';
|
|
67
|
+
}
|
|
68
|
+
export interface CreateEntityRequest extends Record<string, unknown> {
|
|
69
|
+
entityName: string;
|
|
70
|
+
data: Record<string, unknown>;
|
|
71
|
+
deploymentMode?: 'preview' | 'production';
|
|
72
|
+
}
|
|
73
|
+
export interface UpdateEntityRequest extends Record<string, unknown> {
|
|
74
|
+
entityName: string;
|
|
75
|
+
id: string;
|
|
76
|
+
data: Record<string, unknown>;
|
|
77
|
+
deploymentMode?: 'preview' | 'production';
|
|
78
|
+
}
|
|
79
|
+
export interface DeleteEntityRequest extends Record<string, unknown> {
|
|
80
|
+
entityName: string;
|
|
81
|
+
id: string;
|
|
82
|
+
deploymentMode?: 'preview' | 'production';
|
|
83
|
+
}
|
|
84
|
+
export interface RegisterEntityRequest extends Record<string, unknown> {
|
|
85
|
+
appId: string;
|
|
86
|
+
appName: string;
|
|
87
|
+
entityName: string;
|
|
88
|
+
schema?: Record<string, unknown>;
|
|
89
|
+
deploymentMode?: 'preview' | 'production';
|
|
90
|
+
}
|
|
91
|
+
export interface RegisterAppRequest extends Record<string, unknown> {
|
|
92
|
+
appId: string;
|
|
93
|
+
appName: string;
|
|
94
|
+
}
|
|
95
|
+
export interface RegisterComponentRequest extends Record<string, unknown> {
|
|
96
|
+
appId: string;
|
|
97
|
+
appName: string;
|
|
98
|
+
componentName: string;
|
|
99
|
+
metadata?: {
|
|
100
|
+
tag: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
attributes?: Record<string, string>;
|
|
103
|
+
};
|
|
104
|
+
deploymentMode?: 'preview' | 'production';
|
|
105
|
+
}
|
|
106
|
+
export interface RegisterScheduleRequest extends Record<string, unknown> {
|
|
107
|
+
appId: string;
|
|
108
|
+
appName: string;
|
|
109
|
+
scheduleName: string;
|
|
110
|
+
schedule: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
deploymentMode?: 'preview' | 'production';
|
|
113
|
+
}
|
|
114
|
+
export interface RegisterWorkflowRequest extends Record<string, unknown> {
|
|
115
|
+
appId: string;
|
|
116
|
+
appName: string;
|
|
117
|
+
workflowName: string;
|
|
118
|
+
description?: string;
|
|
119
|
+
enabled?: boolean;
|
|
120
|
+
deploymentMode?: 'preview' | 'production';
|
|
121
|
+
}
|
|
122
|
+
export interface RegisterEndpointRequest extends Record<string, unknown> {
|
|
123
|
+
appId: string;
|
|
124
|
+
appName: string;
|
|
125
|
+
path: string;
|
|
126
|
+
method: string;
|
|
127
|
+
authType: 'apiKey' | 'public';
|
|
128
|
+
name?: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
tags?: string[];
|
|
131
|
+
schema?: {
|
|
132
|
+
query?: Record<string, unknown>;
|
|
133
|
+
body?: Record<string, unknown>;
|
|
134
|
+
response?: Record<string, unknown>;
|
|
135
|
+
};
|
|
136
|
+
version?: string;
|
|
137
|
+
deploymentMode?: 'preview' | 'production';
|
|
138
|
+
}
|
|
139
|
+
export interface RegisterIntegrationRequest extends Record<string, unknown> {
|
|
140
|
+
appId: string;
|
|
141
|
+
appName: string;
|
|
142
|
+
integrationId: string;
|
|
143
|
+
reason: string;
|
|
144
|
+
required: boolean;
|
|
145
|
+
deploymentMode?: 'preview' | 'production';
|
|
146
|
+
}
|
|
147
|
+
export interface RegisterAgentRequest extends Record<string, unknown> {
|
|
148
|
+
appId: string;
|
|
149
|
+
appName: string;
|
|
150
|
+
agentName: string;
|
|
151
|
+
description: string;
|
|
152
|
+
type: 'conversational' | 'task';
|
|
153
|
+
integrations: string[];
|
|
154
|
+
entities: string[];
|
|
155
|
+
deploymentMode?: 'preview' | 'production';
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* WorkspaceContext - Helper for cross-app data queries
|
|
159
|
+
* Provides methods to query entities from other apps in the same workspace
|
|
160
|
+
*/
|
|
161
|
+
export declare class WorkspaceContext {
|
|
162
|
+
private env;
|
|
163
|
+
private workspaceId;
|
|
164
|
+
private appId;
|
|
165
|
+
private appName;
|
|
166
|
+
private deploymentMode;
|
|
167
|
+
constructor(env: Env, workspaceId: string, appId: string, appName: string);
|
|
168
|
+
private canUseHttpFallback;
|
|
169
|
+
private getWorkspaceStub;
|
|
170
|
+
private fetchViaDurableObject;
|
|
171
|
+
private fetchViaHttp;
|
|
172
|
+
private workspaceFetch;
|
|
173
|
+
/**
|
|
174
|
+
* List entities from another app in the workspace with optional filters
|
|
175
|
+
*/
|
|
176
|
+
list<T = unknown>(entityName: string, options?: {
|
|
177
|
+
filters?: Record<string, unknown>;
|
|
178
|
+
limit?: number;
|
|
179
|
+
cursor?: string | null;
|
|
180
|
+
}): Promise<ListEntityResponse<T>>;
|
|
181
|
+
/**
|
|
182
|
+
* Get a single entity by ID from another app in the workspace
|
|
183
|
+
*/
|
|
184
|
+
get<T = unknown>(entityName: string, id: string): Promise<T | null>;
|
|
185
|
+
/**
|
|
186
|
+
* Create an entity in another app in the workspace
|
|
187
|
+
*/
|
|
188
|
+
create<T = unknown>(entityName: string, data: Partial<T>): Promise<T>;
|
|
189
|
+
/**
|
|
190
|
+
* Update an entity in another app in the workspace
|
|
191
|
+
*/
|
|
192
|
+
update<T = unknown>(entityName: string, id: string, data: Partial<T>): Promise<T>;
|
|
193
|
+
/**
|
|
194
|
+
* Delete an entity in another app in the workspace
|
|
195
|
+
*/
|
|
196
|
+
deleteEntity(entityName: string, id: string): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Register an entity with the workspace so other apps can query it
|
|
199
|
+
*/
|
|
200
|
+
registerEntity(entityName: string, schema?: Record<string, unknown>): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Register this app with the workspace (safe to call multiple times)
|
|
203
|
+
*/
|
|
204
|
+
registerApp(): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Register a component with the workspace so it can be discovered by other apps
|
|
207
|
+
*/
|
|
208
|
+
registerComponent(componentName: string, metadata?: {
|
|
209
|
+
tag: string;
|
|
210
|
+
description?: string;
|
|
211
|
+
attributes?: Record<string, string>;
|
|
212
|
+
}): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Register a scheduled job with the workspace for visibility
|
|
215
|
+
*/
|
|
216
|
+
registerSchedule(scheduleName: string, config: {
|
|
217
|
+
schedule: string;
|
|
218
|
+
description?: string;
|
|
219
|
+
}): Promise<void>;
|
|
220
|
+
/**
|
|
221
|
+
* Register a workflow with the workspace for visibility and provisioning
|
|
222
|
+
*/
|
|
223
|
+
registerWorkflow(workflowName: string, config: {
|
|
224
|
+
description?: string;
|
|
225
|
+
enabled?: boolean;
|
|
226
|
+
}): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Register a public endpoint with the workspace for external access
|
|
229
|
+
*/
|
|
230
|
+
registerEndpoint(path: string, config: {
|
|
231
|
+
method: string;
|
|
232
|
+
authType: 'apiKey' | 'public';
|
|
233
|
+
name?: string;
|
|
234
|
+
description?: string;
|
|
235
|
+
tags?: string[];
|
|
236
|
+
schema?: {
|
|
237
|
+
query?: Record<string, unknown>;
|
|
238
|
+
body?: Record<string, unknown>;
|
|
239
|
+
response?: Record<string, unknown>;
|
|
240
|
+
};
|
|
241
|
+
version?: string;
|
|
242
|
+
}): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Register an integration requirement with the workspace
|
|
245
|
+
*/
|
|
246
|
+
registerIntegration(integrationId: string, config: {
|
|
247
|
+
reason?: string;
|
|
248
|
+
required?: boolean;
|
|
249
|
+
}): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Register an AI agent with the workspace for visibility
|
|
252
|
+
*/
|
|
253
|
+
registerAgent(agentName: string, config: {
|
|
254
|
+
description: string;
|
|
255
|
+
type: 'conversational' | 'task';
|
|
256
|
+
integrations: string[];
|
|
257
|
+
entities: string[];
|
|
258
|
+
}): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Register all scheduled jobs, removing any stale entries not in the list.
|
|
261
|
+
* This ensures schedules deleted from code are removed from the registry.
|
|
262
|
+
*/
|
|
263
|
+
registerAllSchedules(schedules: Array<{
|
|
264
|
+
name: string;
|
|
265
|
+
schedule: string;
|
|
266
|
+
description?: string;
|
|
267
|
+
}>): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* Register all workflows, removing any stale entries not in the list.
|
|
270
|
+
* This ensures workflows deleted from code are removed from the registry.
|
|
271
|
+
*/
|
|
272
|
+
registerAllWorkflows(workflows: Array<{
|
|
273
|
+
name: string;
|
|
274
|
+
description?: string;
|
|
275
|
+
enabled?: boolean;
|
|
276
|
+
}>): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Register all endpoints, removing any stale entries not in the list.
|
|
279
|
+
* This ensures endpoints deleted from code are removed from the registry.
|
|
280
|
+
*/
|
|
281
|
+
registerAllEndpoints(endpoints: Array<{
|
|
282
|
+
path: string;
|
|
283
|
+
method: string;
|
|
284
|
+
auth: 'apiKey' | 'public';
|
|
285
|
+
description?: string;
|
|
286
|
+
tags?: string[];
|
|
287
|
+
schema?: {
|
|
288
|
+
query?: Record<string, unknown>;
|
|
289
|
+
body?: Record<string, unknown>;
|
|
290
|
+
response?: Record<string, unknown>;
|
|
291
|
+
};
|
|
292
|
+
}>): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Register all integration requirements, removing any stale entries not in the list.
|
|
295
|
+
* This ensures integrations deleted from code are removed from the registry.
|
|
296
|
+
*/
|
|
297
|
+
registerAllIntegrations(integrations: Array<{
|
|
298
|
+
integrationId: string;
|
|
299
|
+
reason: string;
|
|
300
|
+
required: boolean;
|
|
301
|
+
}>): Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* Register all AI agents, removing any stale entries not in the list.
|
|
304
|
+
* This ensures agents deleted from code are removed from the registry.
|
|
305
|
+
*/
|
|
306
|
+
registerAllAgents(agents: Array<{
|
|
307
|
+
name: string;
|
|
308
|
+
description: string;
|
|
309
|
+
type: 'conversational' | 'task';
|
|
310
|
+
integrations?: string[];
|
|
311
|
+
entities?: string[];
|
|
312
|
+
}>): Promise<void>;
|
|
313
|
+
/**
|
|
314
|
+
* Register all components, removing any stale entries not in the list.
|
|
315
|
+
* This ensures components deleted from code are removed from the registry.
|
|
316
|
+
*/
|
|
317
|
+
registerAllComponents(components: Array<{
|
|
318
|
+
name: string;
|
|
319
|
+
metadata?: {
|
|
320
|
+
tag: string;
|
|
321
|
+
description?: string;
|
|
322
|
+
attributes?: Record<string, string>;
|
|
323
|
+
};
|
|
324
|
+
}>): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Connect object storage (R2 bucket) to signal the bucket is "alive"
|
|
327
|
+
*/
|
|
328
|
+
connectObjectStorage(): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Check if this app has an R2 bucket configured
|
|
331
|
+
*/
|
|
332
|
+
hasBucket(): boolean;
|
|
333
|
+
get id(): string;
|
|
334
|
+
/**
|
|
335
|
+
* List all users in this workspace
|
|
336
|
+
* Returns paginated list of workspace members
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* const workspace = getWorkspaceContext(env);
|
|
341
|
+
* const { items: users, next } = await workspace.listUsers();
|
|
342
|
+
* // users: WorkspaceUser[]
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
listUsers(options?: ListUsersOptions): Promise<ListUsersResponse>;
|
|
346
|
+
/**
|
|
347
|
+
* Get a specific user by ID
|
|
348
|
+
* Returns null if user is not found or not a workspace member
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* const workspace = getWorkspaceContext(env);
|
|
353
|
+
* const user = await workspace.getUser(userId);
|
|
354
|
+
* if (user) {
|
|
355
|
+
* console.log(user.name, user.email);
|
|
356
|
+
* }
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
getUser(userId: string): Promise<WorkspaceUser | null>;
|
|
360
|
+
/**
|
|
361
|
+
* Send a notification to a workspace user
|
|
362
|
+
* Can only send to verified workspace members
|
|
363
|
+
* The platform wraps your content in a standard notification template
|
|
364
|
+
* (e.g., "You have a new notification from [App Name]")
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const workspace = getWorkspaceContext(env);
|
|
369
|
+
* const result = await workspace.notifyUser({
|
|
370
|
+
* userId: assigneeId,
|
|
371
|
+
* title: 'Task assigned to you',
|
|
372
|
+
* content: 'You have been assigned a new task.',
|
|
373
|
+
* html: '<p>You have been assigned a new task.</p>',
|
|
374
|
+
* });
|
|
375
|
+
* if (!result.success) {
|
|
376
|
+
* console.error('Failed to send notification:', result.error);
|
|
377
|
+
* }
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
notifyUser(params: NotifyUserParams): Promise<NotifyUserResult>;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Get workspace context for cross-app queries
|
|
384
|
+
* Returns null if app is not part of a workspace
|
|
385
|
+
*/
|
|
386
|
+
export declare function getWorkspaceContext(env: Env): WorkspaceContext | null;
|
|
387
|
+
/**
|
|
388
|
+
* List entities from ANOTHER app in the workspace (cross-app queries ONLY)
|
|
389
|
+
*
|
|
390
|
+
* CRITICAL: This function is for cross-app data access ONLY. Use it to query entities
|
|
391
|
+
* that are defined in OTHER apps in the same workspace.
|
|
392
|
+
*
|
|
393
|
+
* DO NOT use this for local entities owned by this app. For local entities, use the
|
|
394
|
+
* Entity class methods directly (e.g., TodoEntity.list(ctx), UserEntity.list(ctx)).
|
|
395
|
+
*
|
|
396
|
+
* Filters are applied as equality matching on entity fields.
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* // CORRECT: List contacts from a separate CRM app in the workspace
|
|
400
|
+
* const contacts = await listWorkspaceEntity<Contact>(env, 'Contact', {
|
|
401
|
+
* filters: { isActive: true },
|
|
402
|
+
* limit: 50
|
|
403
|
+
* });
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* // WRONG: Don't use this for local entities!
|
|
407
|
+
* // const todos = await listWorkspaceEntity<Todo>(env, 'Todo', { limit: 50 });
|
|
408
|
+
* // CORRECT: Use Entity class for local data
|
|
409
|
+
* // const ctx = { env };
|
|
410
|
+
* // const todos = await TodoEntity.list(ctx, { limit: 50 });
|
|
411
|
+
*/
|
|
412
|
+
export declare function listWorkspaceEntity<T = unknown>(env: Env, entityName: string, options?: {
|
|
413
|
+
filters?: Record<string, unknown>;
|
|
414
|
+
limit?: number;
|
|
415
|
+
cursor?: string | null;
|
|
416
|
+
}): Promise<ListEntityResponse<T>>;
|
|
417
|
+
/**
|
|
418
|
+
* Get a single entity by ID from ANOTHER app in the workspace (cross-app ONLY)
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* const contact = await getWorkspaceEntity<Contact>(env, 'Contact', 'contact-123');
|
|
422
|
+
*/
|
|
423
|
+
export declare function getWorkspaceEntity<T = unknown>(env: Env, entityName: string, id: string): Promise<T | null>;
|
|
424
|
+
/**
|
|
425
|
+
* Create an entity in ANOTHER app in the workspace (cross-app ONLY)
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* const newContact = await createWorkspaceEntity<Contact>(env, 'Contact', {
|
|
429
|
+
* name: 'John Doe',
|
|
430
|
+
* email: 'john@example.com'
|
|
431
|
+
* });
|
|
432
|
+
*/
|
|
433
|
+
export declare function createWorkspaceEntity<T = unknown>(env: Env, entityName: string, data: Partial<T>): Promise<T>;
|
|
434
|
+
/**
|
|
435
|
+
* Update an entity in ANOTHER app in the workspace (cross-app ONLY)
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* const updated = await updateWorkspaceEntity<Contact>(env, 'Contact', 'contact-123', {
|
|
439
|
+
* status: 'inactive'
|
|
440
|
+
* });
|
|
441
|
+
*/
|
|
442
|
+
export declare function updateWorkspaceEntity<T = unknown>(env: Env, entityName: string, id: string, data: Partial<T>): Promise<T>;
|
|
443
|
+
/**
|
|
444
|
+
* Delete an entity in ANOTHER app in the workspace (cross-app ONLY)
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* await deleteWorkspaceEntity(env, 'Contact', 'contact-123');
|
|
448
|
+
*/
|
|
449
|
+
export declare function deleteWorkspaceEntity(env: Env, entityName: string, id: string): Promise<void>;
|
|
450
|
+
/**
|
|
451
|
+
* Register all entities, components, and schedules with the workspace
|
|
452
|
+
* Called once when the worker starts
|
|
453
|
+
*/
|
|
454
|
+
export declare function initializeWorkspace(env: Env): Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application entry point for Runwork apps.
|
|
3
|
+
*
|
|
4
|
+
* Users call createApp() in their worker entry file to register their
|
|
5
|
+
* application code (agents, entities, routes, etc.) and get back
|
|
6
|
+
* a Cloudflare Workers ExportedHandler.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // worker/index.ts
|
|
11
|
+
* import { createApp } from '@runworkai/framework';
|
|
12
|
+
* import { APP_AGENTS } from './agents';
|
|
13
|
+
* import { APP_ENTITIES } from './entities';
|
|
14
|
+
* import { APP_ROUTES } from './routes';
|
|
15
|
+
*
|
|
16
|
+
* export default createApp({
|
|
17
|
+
* agents: APP_AGENTS,
|
|
18
|
+
* entities: APP_ENTITIES,
|
|
19
|
+
* routes: APP_ROUTES,
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { type ComponentDefinition, type RouteEntry } from './app-registry';
|
|
24
|
+
import type { AgentDefinition } from './core-agent';
|
|
25
|
+
import type { EntityClass } from './core-entities';
|
|
26
|
+
import type { EndpointDefinition } from './core-endpoints';
|
|
27
|
+
import type { IntegrationRequirement } from './core-integrations';
|
|
28
|
+
import type { ScheduledJob } from './core-scheduler';
|
|
29
|
+
import type { Env } from './core-utils';
|
|
30
|
+
import type { WorkflowDefinition } from './core-workflow-types';
|
|
31
|
+
/**
|
|
32
|
+
* Options for createApp(). All fields are optional -- omitted fields
|
|
33
|
+
* default to empty arrays.
|
|
34
|
+
*/
|
|
35
|
+
export interface CreateAppOptions {
|
|
36
|
+
agents?: AgentDefinition[];
|
|
37
|
+
entities?: Array<EntityClass<{
|
|
38
|
+
id: string;
|
|
39
|
+
}>>;
|
|
40
|
+
routes?: RouteEntry[];
|
|
41
|
+
endpoints?: EndpointDefinition[];
|
|
42
|
+
workflows?: WorkflowDefinition[];
|
|
43
|
+
schedules?: ScheduledJob[];
|
|
44
|
+
integrationRequirements?: IntegrationRequirement[];
|
|
45
|
+
components?: ComponentDefinition[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Initialize a Runwork application with the given feature registrations.
|
|
49
|
+
*
|
|
50
|
+
* Registers user-defined agents, entities, routes, and other features
|
|
51
|
+
* into the global app registry so framework core files can access them
|
|
52
|
+
* without direct imports.
|
|
53
|
+
*
|
|
54
|
+
* Returns an ExportedHandler suitable for use as the default export
|
|
55
|
+
* of a Cloudflare Worker entry point.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createApp(options?: CreateAppOptions): ExportedHandler<Env>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { isEndpointDefinition, jsonResponse, errorResponse, zodToJsonSchema, EndpointRouter, mountEndpointAsHonoRoute, handleEndpointRequest, EndpointError, endpointToRegistration, } from './core-endpoints';
|
|
2
|
+
export type { EndpointAuthType, EndpointMethod, EndpointSchema, EndpointContext, EndpointAuthInfo, EndpointLogger, EndpointMeta, EndpointDefinition, EndpointHandler, ParsedEndpointRequest, } from './core-endpoints';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { entityRegistry, registerEntity, registerEntities, EntityBase, Entity, entityRoutes, } from './core-entities';
|
|
2
|
+
export type { EntityDOStub, EntityContext, ListOptions, PaginatedResult, EntityClass, Doc, EntityStatics, } from './core-entities';
|
|
3
|
+
export { EntityDO, SAFE_FIELD_NAME, QUERY_LIMITS, validateFieldName, escapeLikePattern } from './core-entity-do';
|
|
4
|
+
export { IntegrationEntity, isIntegrationEntity } from './core-integration-entities';
|
|
5
|
+
export type { OperationConfig, IntegrationEntityConfig, IntegrationEntityClass, } from './core-integration-entities';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { createApp } from './create-app';
|
|
2
|
+
export type { CreateAppOptions } from './create-app';
|
|
3
|
+
export type { AppConfig } from './app-registry';
|
|
4
|
+
export { ok, bad, notFound, isStr, safeClone, platformFetch, workspaceApiFetch } from './core-utils';
|
|
5
|
+
export type { Env } from './core-utils';
|
|
6
|
+
export type { ApiResponse } from './shared/core-types';
|
|
7
|
+
export * from './entities';
|
|
8
|
+
export * from './routes';
|
|
9
|
+
export * from './agents';
|
|
10
|
+
export * from './ai';
|
|
11
|
+
export * from './workflows';
|
|
12
|
+
export * from './scheduler';
|
|
13
|
+
export * from './endpoints';
|
|
14
|
+
export * from './storage';
|
|
15
|
+
export * from './integrations';
|
|
16
|
+
export * from './channels';
|
|
17
|
+
export * from './workspace';
|
|
18
|
+
export * from './events';
|
|
19
|
+
export * from './components';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { parseCronExpression, calculateNextRun, SchedulerDO, initializeScheduler, schedulerRoutes, } from './core-scheduler';
|
|
2
|
+
export type { ScheduledJob, JobContext, JobResult, JobLogger, JobRunRecord, ScheduleState, SchedulerRegistry, ScheduleStatusResponse, } from './core-scheduler';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Minimal entry point for vitest-pool-workers that exports only
|
|
5
|
+
* the DOs needed for testing, avoiding dependencies that don't work in
|
|
6
|
+
* the miniflare test environment (agents, ai SDK, MCP, etc.)
|
|
7
|
+
*/
|
|
8
|
+
export { EntityDO } from './core-entity-do';
|
|
9
|
+
export { SchedulerDO } from './core-scheduler';
|
|
10
|
+
export declare class BaseAgent {
|
|
11
|
+
state: DurableObjectState;
|
|
12
|
+
env: unknown;
|
|
13
|
+
constructor(state: DurableObjectState, env: unknown);
|
|
14
|
+
fetch(_request: Request): Promise<Response>;
|
|
15
|
+
}
|
|
16
|
+
export { WorkflowInstanceDO } from './core-workflow-instance';
|
|
17
|
+
export { WorkflowCoordinator } from './core-workflow-coordinator';
|
|
18
|
+
declare const _default: {
|
|
19
|
+
fetch(_request: Request): Promise<Response>;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ApiResponse, NangoActionResponse, NangoProxyOptions, FileMetadata, UploadOptions, DownloadOptions, ListFilesOptions, ListFilesResult, PresignedUrlRequest, PresignedUrlResponse, } from './shared/core-types';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineConfig, type Plugin } from "vite";
|
|
2
|
+
export interface RunworkPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Override the detected mode. By default, the plugin detects sandbox mode
|
|
5
|
+
* when DEPLOYMENT_MODE or WORKSPACE_ID environment variables are present.
|
|
6
|
+
*/
|
|
7
|
+
mode?: "sandbox" | "local";
|
|
8
|
+
/**
|
|
9
|
+
* Root directory of the project. Defaults to process.cwd().
|
|
10
|
+
*/
|
|
11
|
+
root?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Path aliases to configure. Defaults to { "@": "./src", "@shared": "./shared" }.
|
|
14
|
+
*/
|
|
15
|
+
aliases?: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to use JSON logging (pino) in sandbox mode.
|
|
18
|
+
* Defaults to true when VITE_LOGGER_TYPE=json.
|
|
19
|
+
*/
|
|
20
|
+
jsonLogger?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function runwork(options?: RunworkPluginOptions): ReturnType<typeof defineConfig>;
|
|
23
|
+
export type { Plugin };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WorkflowDefinition } from './core-workflow-types';
|
|
2
|
+
/**
|
|
3
|
+
* APP_WORKFLOWS - runtime accessor for registered workflow definitions.
|
|
4
|
+
* Used by internal dynamic imports in core-workflow-cloudflare and core-workflow-instance.
|
|
5
|
+
* This is a getter-backed constant so it always reflects the current registry state.
|
|
6
|
+
*/
|
|
7
|
+
export declare const APP_WORKFLOWS: WorkflowDefinition[];
|
|
8
|
+
export { triggerWorkflow, sendWorkflowEvent, getWorkflowStatus, workflowRoutes, } from './core-workflows';
|
|
9
|
+
export type { WorkflowResult, WorkflowStatus, WorkflowInstanceInfo, WorkflowDefinition, WorkflowContext, WorkflowStepUtilities, StepOptions, WaitEventOptions, WorkflowLogger, WorkflowState, WorkflowStatusResponse, } from './core-workflows';
|
|
10
|
+
export type { NativeWorkflowStatus, NativeStepStatus, NativeStepType, NativeWorkflowError, NativeStepAttempt, NativeStepExecution, NativeWorkflowInstance, NativeWorkflowConfig, NativeStepContext, WorkflowIndexEntry, ListWorkflowsOptions, ExecuteStepRequest, ExecuteStepResponse, PendingEvent, ReceivedEvent, WorkflowInstanceStub, WorkflowCoordinatorStub, } from './core-workflow-types';
|
|
11
|
+
export { DEFAULT_WORKFLOW_CONFIG } from './core-workflow-types';
|
|
12
|
+
export { WORKFLOW_INFRA_MODE } from './core-workflow-config';
|
|
13
|
+
export { WorkflowInstanceDO } from './core-workflow-instance';
|
|
14
|
+
export { WorkflowCoordinator } from './core-workflow-coordinator';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { WorkspaceContext, getWorkspaceContext, listWorkspaceEntity, getWorkspaceEntity, createWorkspaceEntity, updateWorkspaceEntity, deleteWorkspaceEntity, initializeWorkspace, } from './core-workspace';
|
|
2
|
+
export type { WorkspaceUser, ListUsersOptions, ListUsersResponse, NotifyUserParams, NotifyUserResult, ListEntityRequest, ListEntityResponse, GetEntityRequest, CreateEntityRequest, UpdateEntityRequest, DeleteEntityRequest, RegisterEntityRequest, RegisterAppRequest, RegisterComponentRequest, RegisterScheduleRequest, RegisterWorkflowRequest, RegisterEndpointRequest, RegisterIntegrationRequest, RegisterAgentRequest as WorkspaceRegisterAgentRequest, } from './core-workspace';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|