dp-worker 0.1.1 → 0.1.3

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.
Files changed (58) hide show
  1. package/dist/agent/agent.d.ts +6 -13
  2. package/dist/agent/agent.js +9 -19
  3. package/dist/agent/agent.js.map +1 -1
  4. package/dist/browser/chrome-process.d.ts +3 -0
  5. package/dist/browser/chrome-process.js +174 -25
  6. package/dist/browser/chrome-process.js.map +1 -1
  7. package/dist/browser/manager.d.ts +4 -4
  8. package/dist/browser/manager.js +94 -44
  9. package/dist/browser/manager.js.map +1 -1
  10. package/dist/center/session-sync.d.ts +16 -77
  11. package/dist/center/session-sync.js +62 -302
  12. package/dist/center/session-sync.js.map +1 -1
  13. package/dist/chrome-extension/omni-flow/background.js +561 -0
  14. package/dist/chrome-extension/omni-flow/content.js +29 -0
  15. package/dist/chrome-extension/omni-flow/icon.png +0 -0
  16. package/dist/chrome-extension/omni-flow/inject.js +173 -0
  17. package/dist/chrome-extension/omni-flow/manifest.json +44 -0
  18. package/dist/chrome-extension/omni-flow/popup.css +819 -0
  19. package/dist/chrome-extension/omni-flow/popup.html +284 -0
  20. package/dist/chrome-extension/omni-flow/popup.js +1021 -0
  21. package/dist/chrome-extension/omni-flow/usage_guide.md +139 -0
  22. package/dist/index.js +15 -45
  23. package/dist/index.js.map +1 -1
  24. package/node_modules/dp-shared/dist/domain.d.ts +4 -4
  25. package/node_modules/dp-shared/dist/domain.d.ts.map +1 -1
  26. package/node_modules/dp-shared/dist/domain.js +4 -4
  27. package/node_modules/dp-shared/dist/domain.js.map +1 -1
  28. package/node_modules/dp-shared/dist/identities.d.ts +22 -0
  29. package/node_modules/dp-shared/dist/identities.d.ts.map +1 -1
  30. package/node_modules/dp-shared/dist/identities.js +3 -0
  31. package/node_modules/dp-shared/dist/identities.js.map +1 -1
  32. package/node_modules/dp-shared/dist/index.d.ts +1 -0
  33. package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
  34. package/node_modules/dp-shared/dist/index.js +1 -0
  35. package/node_modules/dp-shared/dist/index.js.map +1 -1
  36. package/node_modules/dp-shared/dist/omni-flow-session.d.ts +85 -0
  37. package/node_modules/dp-shared/dist/omni-flow-session.d.ts.map +1 -0
  38. package/node_modules/dp-shared/dist/omni-flow-session.js +59 -0
  39. package/node_modules/dp-shared/dist/omni-flow-session.js.map +1 -0
  40. package/node_modules/dp-shared/dist/rest-contracts.d.ts +12 -1
  41. package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
  42. package/node_modules/dp-shared/dist/rest-contracts.js +5 -3
  43. package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
  44. package/node_modules/dp-shared/dist/ws-protocol.d.ts +4 -4
  45. package/node_modules/dp-shared/src/admin-broadcast.ts +38 -0
  46. package/node_modules/dp-shared/src/audit-contracts.ts +33 -0
  47. package/node_modules/dp-shared/src/configs-contracts.ts +206 -0
  48. package/node_modules/dp-shared/src/db-rows.ts +280 -0
  49. package/node_modules/dp-shared/src/deploy-contracts.ts +38 -0
  50. package/node_modules/dp-shared/src/domain.ts +124 -0
  51. package/node_modules/dp-shared/src/identities.ts +36 -0
  52. package/node_modules/dp-shared/src/index.ts +25 -0
  53. package/node_modules/dp-shared/src/omni-flow-session.ts +80 -0
  54. package/node_modules/dp-shared/src/rest-contracts.ts +409 -0
  55. package/node_modules/dp-shared/src/task-history-contracts.ts +115 -0
  56. package/node_modules/dp-shared/src/worker-detail-contracts.ts +230 -0
  57. package/node_modules/dp-shared/src/ws-protocol.ts +435 -0
  58. package/package.json +2 -4
@@ -0,0 +1,409 @@
1
+ import { z } from "zod/v4";
2
+ import {
3
+ ConfigEtag,
4
+ ContentHash,
5
+ EffectiveWorkerStatus,
6
+ IanaTimezone,
7
+ LlmProtocol,
8
+ ProcessStatus,
9
+ ProxyProtocol,
10
+ RuntimeStatus,
11
+ SocialPlatform,
12
+ TaskRunStatus,
13
+ TaskSource,
14
+ Uuid,
15
+ } from "./domain.js";
16
+ import { OmniFlowSessionSummarySchema } from "./omni-flow-session.js";
17
+
18
+ /**
19
+ * REST contracts — request bodies and response shapes for the Workers HTTP API.
20
+ *
21
+ * Keep request types narrow (only what clients actually send); response types
22
+ * carry derived fields like timestamps and computed status.
23
+ */
24
+
25
+ /* ============================================================================
26
+ * Bootstrap (dp-worker → center at startup)
27
+ *
28
+ * dp-worker POSTs with Authorization: Bearer <worker_api_key>, no body required;
29
+ * center returns the full operational config + optional session blob pointer.
30
+ *
31
+ * [FIX from architecture.md §dp-worker-D] center must never include `org` in the response,
32
+ * even if the DB has it for some reason. The dp-worker config schema strips it.
33
+ * ============================================================================ */
34
+
35
+ export const SocialAccountSchema = z.object({
36
+ id: Uuid,
37
+ platform: SocialPlatform,
38
+ profile_name: z.string().default(""),
39
+ login_type: z.enum(["password", "oauth"]).default("password"),
40
+ /** Platform handle; was historically called `handle`. */
41
+ username: z.string().optional(),
42
+ email: z.string().optional(),
43
+ password: z.string().optional(),
44
+ /**
45
+ * Already resolved by center: when the row's persona_text is NULL the
46
+ * bootstrap fills it from `identity.persona_text`. dp-worker just uses
47
+ * this string directly.
48
+ */
49
+ persona_text: z.string().default(""),
50
+ persona_other_json: z.record(z.string(), z.unknown()).optional(),
51
+ enabled: z.boolean().default(true),
52
+ });
53
+ export type SocialAccount = z.infer<typeof SocialAccountSchema>;
54
+
55
+ export const ProxyConfigSchema = z.object({
56
+ protocol: ProxyProtocol,
57
+ host: z.string().min(1),
58
+ port: z.number().int().positive(),
59
+ username: z.string().min(1),
60
+ password: z.string().min(1),
61
+ /**
62
+ * IANA timezone of the proxy egress location. Required on creation in center.
63
+ * Bootstrap returns this on `config.proxy.timezone` and ALSO copies it to
64
+ * `config.timezone` so dp-worker can use it as the default scheduler timezone
65
+ * (so cron "0 15 * * *" on a NYC-proxy dp-worker
66
+ * fires at NYC 15:00 regardless of where the Worker runs).
67
+ */
68
+ timezone: IanaTimezone,
69
+ });
70
+ export type ProxyConfigShared = z.infer<typeof ProxyConfigSchema>;
71
+
72
+ export const LlmProfileSchema = z.object({
73
+ protocol: LlmProtocol,
74
+ base_url: z.string().min(1),
75
+ api_key: z.string().min(1),
76
+ model: z.string().min(1),
77
+ image_generation: z
78
+ .object({
79
+ api_key: z.string().min(1),
80
+ model: z.string().min(1),
81
+ size: z.string().default("1024x1024"),
82
+ timeout_ms: z.number().int().positive().default(120000),
83
+ })
84
+ .optional(),
85
+ });
86
+ export type LlmProfile = z.infer<typeof LlmProfileSchema>;
87
+
88
+ export const TelegramFrontendSchema = z.object({
89
+ bot_token: z.string().min(1),
90
+ allowed_users: z.array(z.number().int()),
91
+ });
92
+ export type TelegramFrontendConfig = z.infer<typeof TelegramFrontendSchema>;
93
+
94
+ export const SessionBlobSchema = z.object({
95
+ r2_get_url: z.string().url(),
96
+ content_hash: ContentHash,
97
+ uploaded_at: z.string().datetime(),
98
+ size_bytes: z.number().int().positive(),
99
+ });
100
+ export type SessionBlob = z.infer<typeof SessionBlobSchema>;
101
+
102
+ export const WorkerBootstrapResponseSchema = z.object({
103
+ config: z.object({
104
+ worker_id: Uuid,
105
+ name: z.string().min(1),
106
+ config_etag: ConfigEtag,
107
+ llm: LlmProfileSchema,
108
+ proxy: ProxyConfigSchema.optional(),
109
+ /**
110
+ * Effective timezone for this dp-worker. Derived from `proxy.timezone` —
111
+ * since v2.5 the dp-worker row no longer has its own timezone column, and
112
+ * proxy.timezone is the single source of truth. Undefined only
113
+ * when no proxy is bound (debug mode); dp-worker falls back to system tz
114
+ * in that case.
115
+ */
116
+ timezone: z.string().optional(),
117
+ /**
118
+ * Chrome headless flag (M6). center-managed: the Web UI controls this
119
+ * per dp-worker. The host CLI flag `--headless` is now only a fallback
120
+ * for local-mode dp-workers that don't go through center bootstrap.
121
+ */
122
+ headless: z.boolean().default(false),
123
+ social_accounts: z.array(SocialAccountSchema).default([]),
124
+ telegram: TelegramFrontendSchema.optional(),
125
+ /**
126
+ * Limits that center enforces but dp-worker also caches for runtime decisions
127
+ * (max iterations, task timeout, etc.).
128
+ */
129
+ limits: z
130
+ .object({
131
+ max_iterations: z.number().int().positive().default(90),
132
+ task_timeout_ms: z.number().int().positive().default(30 * 60 * 1000),
133
+ chrome_max_runtime_ms: z
134
+ .number()
135
+ .int()
136
+ .positive()
137
+ .default(24 * 60 * 60 * 1000),
138
+ })
139
+ .default(() => ({
140
+ max_iterations: 90,
141
+ task_timeout_ms: 30 * 60 * 1000,
142
+ chrome_max_runtime_ms: 24 * 60 * 60 * 1000,
143
+ })),
144
+ }),
145
+ session_blob: SessionBlobSchema.optional(),
146
+ });
147
+ export type WorkerBootstrapResponse = z.infer<typeof WorkerBootstrapResponseSchema>;
148
+
149
+ /* ============================================================================
150
+ * dp-director register handshake
151
+ * ============================================================================ */
152
+
153
+ export const DirectorRegisterHandshakeRequestSchema = z.object({
154
+ version: z.string().min(1),
155
+ host_label: z.string().min(1),
156
+ });
157
+
158
+ export const DirectorRegisterHandshakeResponseSchema = z.object({
159
+ director_id: Uuid,
160
+ short_token: z.string().min(1),
161
+ ws_url: z.string().url(),
162
+ expires_at: z.string().datetime(),
163
+ });
164
+ export type DirectorRegisterHandshakeResponse = z.infer<
165
+ typeof DirectorRegisterHandshakeResponseSchema
166
+ >;
167
+
168
+ /* ============================================================================
169
+ * R2 presigned URL flows
170
+ * ============================================================================ */
171
+
172
+ export const SessionUploadPresignRequestSchema = z.object({
173
+ size_bytes: z.number().int().positive(),
174
+ content_hash: ContentHash,
175
+ });
176
+ export type SessionUploadPresignRequest = z.infer<
177
+ typeof SessionUploadPresignRequestSchema
178
+ >;
179
+
180
+ export const SessionUploadPresignResponseSchema = z.object({
181
+ upload_url: z.string().url(),
182
+ object_key: z.string().min(1),
183
+ expires_at: z.string().datetime(),
184
+ });
185
+ export type SessionUploadPresignResponse = z.infer<
186
+ typeof SessionUploadPresignResponseSchema
187
+ >;
188
+
189
+ export const SessionFinalizeRequestSchema = z.object({
190
+ object_key: z.string().min(1),
191
+ content_hash: ContentHash,
192
+ size_bytes: z.number().int().positive(),
193
+ note: z.string().optional(),
194
+ session_preview: OmniFlowSessionSummarySchema.optional(),
195
+ });
196
+ export type SessionFinalizeRequest = z.infer<
197
+ typeof SessionFinalizeRequestSchema
198
+ >;
199
+
200
+ export const SessionFinalizeResponseSchema = z.object({
201
+ id: Uuid,
202
+ content_hash: ContentHash,
203
+ new_config_etag: ConfigEtag.optional(),
204
+ });
205
+ export type SessionFinalizeResponse = z.infer<
206
+ typeof SessionFinalizeResponseSchema
207
+ >;
208
+
209
+ export const AttachmentUploadPresignRequestSchema = z.object({
210
+ filename: z.string().min(1),
211
+ mime: z.string().optional(),
212
+ size_bytes: z.number().int().positive(),
213
+ });
214
+
215
+ export const AttachmentUploadPresignResponseSchema =
216
+ SessionUploadPresignResponseSchema;
217
+
218
+ export const AttachmentFinalizeRequestSchema = z.object({
219
+ object_key: z.string().min(1),
220
+ filename: z.string().min(1),
221
+ mime: z.string().optional(),
222
+ size_bytes: z.number().int().positive(),
223
+ });
224
+ export type AttachmentFinalizeRequest = z.infer<
225
+ typeof AttachmentFinalizeRequestSchema
226
+ >;
227
+
228
+ export const AttachmentSchema = z.object({
229
+ id: Uuid,
230
+ filename: z.string().min(1),
231
+ mime: z.string().optional(),
232
+ size_bytes: z.number().int().positive(),
233
+ created_at: z.string().datetime(),
234
+ download_url: z.string().url().optional(),
235
+ });
236
+ export type Attachment = z.infer<typeof AttachmentSchema>;
237
+
238
+ /* ============================================================================
239
+ * Tasks
240
+ * ============================================================================ */
241
+
242
+ export const AdhocTaskTargetSchema = z
243
+ .object({
244
+ worker_ids: z.array(Uuid).default([]),
245
+ group_ids: z.array(Uuid).default([]),
246
+ })
247
+ .refine((v) => v.worker_ids.length + v.group_ids.length > 0, {
248
+ message: "must target at least one dp-worker or group",
249
+ });
250
+
251
+ export const AdhocTaskRequestSchema = z.object({
252
+ name: z.string().min(1),
253
+ prompt: z.string().min(1),
254
+ target: AdhocTaskTargetSchema,
255
+ /**
256
+ * 0 means dispatch immediately unless dispatch_window_seconds is set.
257
+ * >0 picks rand(0, random_delay_seconds) per target only when no dispatch
258
+ * window is set.
259
+ */
260
+ random_delay_seconds: z.number().int().nonnegative().default(0),
261
+ /** 0 means no spreading; >0 spreads targets evenly over this dispatch window. */
262
+ dispatch_window_seconds: z.number().int().nonnegative().default(0),
263
+ priority: z.number().int().default(100),
264
+ });
265
+ export type AdhocTaskRequest = z.infer<typeof AdhocTaskRequestSchema>;
266
+
267
+ export const AdhocTaskBatchResponseSchema = z.object({
268
+ batch_id: Uuid,
269
+ task_run_ids: z.array(Uuid).min(1),
270
+ });
271
+
272
+ export const TaskRunSummarySchema = z.object({
273
+ id: Uuid,
274
+ worker_id: Uuid,
275
+ scheduled_task_id: Uuid.optional(),
276
+ source: TaskSource,
277
+ status: TaskRunStatus,
278
+ dispatched_at: z.string().datetime().optional(),
279
+ started_at: z.string().datetime().optional(),
280
+ finished_at: z.string().datetime().optional(),
281
+ error: z.string().optional(),
282
+ result_summary: z.string().optional(),
283
+ parent_adhoc_task_id: Uuid.optional(),
284
+ });
285
+ export type TaskRunSummary = z.infer<typeof TaskRunSummarySchema>;
286
+
287
+ export const TaskRunListResponseSchema = z.object({
288
+ items: z.array(TaskRunSummarySchema),
289
+ next_cursor: z.string().optional(),
290
+ });
291
+
292
+ /* ============================================================================
293
+ * Scheduled tasks CRUD
294
+ * ============================================================================ */
295
+
296
+ export const ScheduledTaskBodySchema = z.object({
297
+ name: z.string().min(1),
298
+ cron: z.string().min(1),
299
+ timezone: z.string().optional(),
300
+ prompt: z.string().min(1),
301
+ random_delay_seconds: z.number().int().nonnegative().default(0),
302
+ enabled: z.boolean().default(true),
303
+ });
304
+ export type ScheduledTaskBody = z.infer<typeof ScheduledTaskBodySchema>;
305
+
306
+ export const ScheduledTaskResponseSchema = ScheduledTaskBodySchema.extend({
307
+ id: Uuid,
308
+ worker_id: Uuid,
309
+ last_run_at: z.string().datetime().optional(),
310
+ last_status: z.enum(["ok", "error"]).optional(),
311
+ run_count: z.number().int().nonnegative().default(0),
312
+ success_count: z.number().int().nonnegative().default(0),
313
+ created_at: z.string().datetime(),
314
+ updated_at: z.string().datetime(),
315
+ });
316
+
317
+ /* ============================================================================
318
+ * Chat
319
+ * ============================================================================ */
320
+
321
+ export const ChatSendRequestSchema = z
322
+ .object({
323
+ content: z.string().default(""),
324
+ attachment_ids: z.array(Uuid).default([]),
325
+ })
326
+ .refine(
327
+ (body) => body.content.trim().length > 0 || body.attachment_ids.length > 0,
328
+ {
329
+ message: "content or attachment_ids required",
330
+ path: ["content"],
331
+ }
332
+ );
333
+
334
+ export const ChatHistoryItemSchema = z.object({
335
+ id: Uuid,
336
+ chat_id: Uuid,
337
+ role: z.string(),
338
+ content_json: z.unknown(),
339
+ attachment_ids: z.array(Uuid).default([]),
340
+ attachments: z.array(AttachmentSchema).default([]),
341
+ task_run_id: Uuid.optional(),
342
+ sender_user_id: Uuid.optional(),
343
+ created_at: z.string().datetime(),
344
+ });
345
+
346
+ export const ChatHistoryResponseSchema = z.object({
347
+ items: z.array(ChatHistoryItemSchema),
348
+ next_cursor: z.string().optional(),
349
+ });
350
+
351
+ /* ============================================================================
352
+ * Groups CRUD (M7 Phase A)
353
+ * ============================================================================ */
354
+
355
+ export const GroupBodySchema = z.object({
356
+ name: z.string().min(1).max(120),
357
+ description: z.string().max(1000).optional(),
358
+ });
359
+ export type GroupBody = z.infer<typeof GroupBodySchema>;
360
+
361
+ export const GroupPatchSchema = z
362
+ .object({
363
+ name: z.string().min(1).max(120).optional(),
364
+ description: z.string().max(1000).nullable().optional(),
365
+ })
366
+ .refine((v) => Object.keys(v).length > 0, {
367
+ message: "patch body must contain at least one field",
368
+ });
369
+ export type GroupPatch = z.infer<typeof GroupPatchSchema>;
370
+
371
+ export const GroupMemberMutationSchema = z.object({
372
+ worker_ids: z.array(Uuid).min(1).max(200),
373
+ });
374
+ export type GroupMemberMutation = z.infer<typeof GroupMemberMutationSchema>;
375
+
376
+ export const GroupListItemSchema = z.object({
377
+ id: Uuid,
378
+ name: z.string(),
379
+ description: z.string().optional(),
380
+ member_count: z.number().int().nonnegative(),
381
+ created_at: z.string().datetime(),
382
+ updated_at: z.string().datetime(),
383
+ });
384
+
385
+ export const GroupDetailSchema = GroupListItemSchema.extend({
386
+ member_worker_ids: z.array(Uuid),
387
+ });
388
+
389
+ /* ============================================================================
390
+ * Status / list endpoints (subset)
391
+ * ============================================================================ */
392
+
393
+ export const WorkerListItemSchema = z.object({
394
+ id: Uuid,
395
+ name: z.string(),
396
+ director_id: Uuid.optional(),
397
+ status: EffectiveWorkerStatus,
398
+ current_task_id: Uuid.optional(),
399
+ process_status: ProcessStatus.optional(),
400
+ runtime_status: RuntimeStatus.optional(),
401
+ process_observed_at: z.string().datetime().optional(),
402
+ runtime_observed_at: z.string().datetime().optional(),
403
+ last_heartbeat_at: z.string().datetime().optional(),
404
+ effective_status: EffectiveWorkerStatus.optional(),
405
+ });
406
+
407
+ export const WorkerListResponseSchema = z.object({
408
+ items: z.array(WorkerListItemSchema),
409
+ });
@@ -0,0 +1,115 @@
1
+ import { z } from "zod/v4";
2
+ import { TaskRunStatus, TaskSource, Uuid } from "./domain.js";
3
+
4
+ /**
5
+ * History / cross-dp-worker listing contracts (M8 Phase A wave-1).
6
+ *
7
+ * Three new GET endpoints share these wire shapes:
8
+ * - GET /api/tasks/adhoc AdhocBatchListItemSchema
9
+ * - GET /api/tasks/runs TaskRunListItemSchema
10
+ * - GET /api/scheduled-tasks ScheduledTaskListItemSchema
11
+ *
12
+ * Cursors are opaque strings (timestamp-based, but the client should NOT
13
+ * parse them) — the server hands one back as `next_cursor` and the client
14
+ * passes it through unchanged to fetch the next page.
15
+ */
16
+
17
+ export const AdhocBatchListItemSchema = z.object({
18
+ id: Uuid,
19
+ name: z.string(),
20
+ prompt: z.string(),
21
+ target_descriptor_json: z.record(z.string(), z.unknown()),
22
+ random_delay_seconds: z.number().int().nonnegative(),
23
+ dispatch_window_seconds: z.number().int().nonnegative(),
24
+ summary_stats_json: z.record(z.string(), z.unknown()).optional(),
25
+ created_by: Uuid.optional(),
26
+ created_at: z.string().datetime(),
27
+ /** Counts derived from joined task_runs.parent_adhoc_task_id. */
28
+ run_count: z.number().int().nonnegative(),
29
+ success_count: z.number().int().nonnegative(),
30
+ failure_count: z.number().int().nonnegative(),
31
+ });
32
+ export type AdhocBatchListItem = z.infer<typeof AdhocBatchListItemSchema>;
33
+
34
+ export const AdhocBatchListResponseSchema = z.object({
35
+ items: z.array(AdhocBatchListItemSchema),
36
+ next_cursor: z.string().optional(),
37
+ });
38
+ export type AdhocBatchListResponse = z.infer<typeof AdhocBatchListResponseSchema>;
39
+
40
+ export const TaskRunListItemSchema = z.object({
41
+ id: Uuid,
42
+ worker_id: Uuid,
43
+ worker_name: z.string(),
44
+ scheduled_task_id: Uuid.optional(),
45
+ parent_adhoc_task_id: Uuid.optional(),
46
+ source: TaskSource,
47
+ status: TaskRunStatus,
48
+ prompt: z.string(),
49
+ dispatched_at: z.string().datetime().optional(),
50
+ started_at: z.string().datetime().optional(),
51
+ finished_at: z.string().datetime().optional(),
52
+ result_summary: z.string().optional(),
53
+ error: z.string().optional(),
54
+ randomized_delay_ms: z.number().int().nonnegative(),
55
+ created_at: z.string().datetime(),
56
+ });
57
+ export type TaskRunListItem = z.infer<typeof TaskRunListItemSchema>;
58
+
59
+ export const TaskRunHistoryListResponseSchema = z.object({
60
+ items: z.array(TaskRunListItemSchema),
61
+ next_cursor: z.string().optional(),
62
+ });
63
+ export type TaskRunHistoryListResponse = z.infer<
64
+ typeof TaskRunHistoryListResponseSchema
65
+ >;
66
+
67
+ /**
68
+ * Cross-dp-worker scheduled-task row. Shape differs from the per-dp-worker
69
+ * `ScheduledTaskResponseSchema` only in that it carries `worker_name`
70
+ * (joined from dp_workers) — handy when listing across dp-workers.
71
+ */
72
+ export const ScheduledTaskListItemSchema = z.object({
73
+ id: Uuid,
74
+ worker_id: Uuid,
75
+ worker_name: z.string(),
76
+ worker_status: z.string().optional(),
77
+ name: z.string(),
78
+ cron: z.string(),
79
+ timezone: z.string().optional(),
80
+ prompt: z.string(),
81
+ random_delay_seconds: z.number().int().nonnegative(),
82
+ enabled: z.boolean(),
83
+ last_run_at: z.string().datetime().optional(),
84
+ last_status: z.enum(["ok", "error"]).optional(),
85
+ run_count: z.number().int().nonnegative(),
86
+ success_count: z.number().int().nonnegative(),
87
+ effective_timezone: z.string(),
88
+ timezone_source: z.enum(["task", "proxy", "utc"]),
89
+ next_fire_at: z.string().datetime().optional(),
90
+ health_status: z.enum(["healthy", "failing", "never_run", "disabled"]),
91
+ latest_run_id: Uuid.optional(),
92
+ latest_run_status: z
93
+ .enum([
94
+ "queued",
95
+ "dispatched",
96
+ "running",
97
+ "success",
98
+ "failed",
99
+ "cancelled",
100
+ "timeout",
101
+ ])
102
+ .optional(),
103
+ last_error: z.string().optional(),
104
+ created_at: z.string().datetime(),
105
+ updated_at: z.string().datetime(),
106
+ });
107
+ export type ScheduledTaskListItem = z.infer<typeof ScheduledTaskListItemSchema>;
108
+
109
+ export const ScheduledTaskListResponseSchema = z.object({
110
+ items: z.array(ScheduledTaskListItemSchema),
111
+ next_cursor: z.string().optional(),
112
+ });
113
+ export type ScheduledTaskListResponse = z.infer<
114
+ typeof ScheduledTaskListResponseSchema
115
+ >;