dp-worker 0.1.19 → 0.1.20
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/builtin-skills/x.md +27 -0
- package/dist/bird/bird-frontend.d.ts +33 -0
- package/dist/bird/bird-frontend.js +68 -0
- package/dist/bird/bird-frontend.js.map +1 -0
- package/dist/bird/credentials.d.ts +36 -0
- package/dist/bird/credentials.js +82 -0
- package/dist/bird/credentials.js.map +1 -0
- package/dist/bird/ops.d.ts +103 -0
- package/dist/bird/ops.js +523 -0
- package/dist/bird/ops.js.map +1 -0
- package/dist/bird/sidecar-entry.d.ts +25 -0
- package/dist/bird/sidecar-entry.js +192 -0
- package/dist/bird/sidecar-entry.js.map +1 -0
- package/dist/bird/sidecar-host.d.ts +54 -0
- package/dist/bird/sidecar-host.js +318 -0
- package/dist/bird/sidecar-host.js.map +1 -0
- package/dist/bird/socks-connector.d.ts +26 -0
- package/dist/bird/socks-connector.js +49 -0
- package/dist/bird/socks-connector.js.map +1 -0
- package/dist/browser/cloakbrowser-backend.js +10 -27
- package/dist/browser/cloakbrowser-backend.js.map +1 -1
- package/dist/chrome-extension/omni-flow/manifest.json +1 -1
- package/dist/config/center-config.d.ts +8 -0
- package/dist/config/center-config.js +1 -0
- package/dist/config/center-config.js.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/admin-broadcast.d.ts +1 -1
- package/node_modules/dp-shared/dist/admin-broadcast.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/bird-contracts.d.ts +483 -0
- package/node_modules/dp-shared/dist/bird-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/bird-contracts.js +372 -0
- package/node_modules/dp-shared/dist/bird-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/configs-contracts.d.ts +11 -1
- package/node_modules/dp-shared/dist/configs-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/configs-contracts.js +43 -0
- package/node_modules/dp-shared/dist/configs-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/index.d.ts +2 -0
- package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/index.js +2 -0
- package/node_modules/dp-shared/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts +9 -3
- package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/post-drafts-contracts.js +34 -0
- package/node_modules/dp-shared/dist/post-drafts-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/promo-contracts.d.ts +651 -0
- package/node_modules/dp-shared/dist/promo-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/promo-contracts.js +566 -0
- package/node_modules/dp-shared/dist/promo-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts +73 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/rest-contracts.js +70 -0
- package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/smart-money-contracts.d.ts +86 -0
- package/node_modules/dp-shared/dist/smart-money-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/smart-money-contracts.js +71 -0
- package/node_modules/dp-shared/dist/smart-money-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts +2 -0
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/task-history-contracts.js +2 -0
- package/node_modules/dp-shared/dist/task-history-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +7 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/worker-detail-contracts.js +9 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/ws-protocol.d.ts +52 -0
- package/node_modules/dp-shared/dist/ws-protocol.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/ws-protocol.js +37 -0
- package/node_modules/dp-shared/dist/ws-protocol.js.map +1 -1
- package/package.json +4 -2
- package/dist/browser/proxy-relay.d.ts +0 -50
- package/dist/browser/proxy-relay.js +0 -50
- package/dist/browser/proxy-relay.js.map +0 -1
- package/node_modules/dp-shared/src/admin-broadcast.ts +0 -41
- package/node_modules/dp-shared/src/audit-contracts.ts +0 -33
- package/node_modules/dp-shared/src/auto-post-contracts.ts +0 -206
- package/node_modules/dp-shared/src/cloak-contracts.ts +0 -110
- package/node_modules/dp-shared/src/configs-contracts.ts +0 -249
- package/node_modules/dp-shared/src/db-rows.ts +0 -303
- package/node_modules/dp-shared/src/deploy-contracts.ts +0 -38
- package/node_modules/dp-shared/src/domain.ts +0 -124
- package/node_modules/dp-shared/src/fingerprint.ts +0 -21
- package/node_modules/dp-shared/src/identities.ts +0 -38
- package/node_modules/dp-shared/src/index.ts +0 -30
- package/node_modules/dp-shared/src/omni-flow-cookie.ts +0 -272
- package/node_modules/dp-shared/src/omni-flow-session.ts +0 -79
- package/node_modules/dp-shared/src/post-drafts-contracts.ts +0 -807
- package/node_modules/dp-shared/src/rest-contracts.ts +0 -592
- package/node_modules/dp-shared/src/task-history-contracts.ts +0 -124
- package/node_modules/dp-shared/src/worker-detail-contracts.ts +0 -236
- package/node_modules/dp-shared/src/ws-protocol.ts +0 -495
|
@@ -1,592 +0,0 @@
|
|
|
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
|
-
/**
|
|
124
|
-
* Browser automation backend for this dp-worker. "cloakbrowser" (default)
|
|
125
|
-
* launches the C++-patched stealth Chromium via the cloakbrowser package,
|
|
126
|
-
* with OmniFlow loaded in passive (session-only) mode. "chrome" spawns real
|
|
127
|
-
* Google Chrome + CDP attach with the OmniFlow extension — retained in code
|
|
128
|
-
* but no longer offered in the UI. cs-only; the host CLI flag
|
|
129
|
-
* `--browser-backend` is a fallback for non-bootstrap local mode.
|
|
130
|
-
*/
|
|
131
|
-
browser_automation_mode: z.enum(["chrome", "cloakbrowser"]).default("cloakbrowser"),
|
|
132
|
-
social_accounts: z.array(SocialAccountSchema).default([]),
|
|
133
|
-
telegram: TelegramFrontendSchema.optional(),
|
|
134
|
-
/**
|
|
135
|
-
* Limits that center enforces but dp-worker also caches for runtime decisions
|
|
136
|
-
* (max iterations, task timeout, etc.).
|
|
137
|
-
*/
|
|
138
|
-
limits: z
|
|
139
|
-
.object({
|
|
140
|
-
max_iterations: z.number().int().positive().default(90),
|
|
141
|
-
task_timeout_ms: z.number().int().positive().default(30 * 60 * 1000),
|
|
142
|
-
chrome_max_runtime_ms: z
|
|
143
|
-
.number()
|
|
144
|
-
.int()
|
|
145
|
-
.positive()
|
|
146
|
-
.default(24 * 60 * 60 * 1000),
|
|
147
|
-
})
|
|
148
|
-
.default(() => ({
|
|
149
|
-
max_iterations: 90,
|
|
150
|
-
task_timeout_ms: 30 * 60 * 1000,
|
|
151
|
-
chrome_max_runtime_ms: 24 * 60 * 60 * 1000,
|
|
152
|
-
})),
|
|
153
|
-
}),
|
|
154
|
-
session_blob: SessionBlobSchema.optional(),
|
|
155
|
-
});
|
|
156
|
-
export type WorkerBootstrapResponse = z.infer<typeof WorkerBootstrapResponseSchema>;
|
|
157
|
-
|
|
158
|
-
/* ============================================================================
|
|
159
|
-
* dp-director register handshake
|
|
160
|
-
* ============================================================================ */
|
|
161
|
-
|
|
162
|
-
export const DirectorRegisterHandshakeRequestSchema = z.object({
|
|
163
|
-
version: z.string().min(1),
|
|
164
|
-
host_label: z.string().min(1),
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
export const DirectorRegisterHandshakeResponseSchema = z.object({
|
|
168
|
-
director_id: Uuid,
|
|
169
|
-
short_token: z.string().min(1),
|
|
170
|
-
ws_url: z.string().url(),
|
|
171
|
-
expires_at: z.string().datetime(),
|
|
172
|
-
});
|
|
173
|
-
export type DirectorRegisterHandshakeResponse = z.infer<
|
|
174
|
-
typeof DirectorRegisterHandshakeResponseSchema
|
|
175
|
-
>;
|
|
176
|
-
|
|
177
|
-
/* ============================================================================
|
|
178
|
-
* R2 presigned URL flows
|
|
179
|
-
* ============================================================================ */
|
|
180
|
-
|
|
181
|
-
export const SessionUploadPresignRequestSchema = z.object({
|
|
182
|
-
size_bytes: z.number().int().positive(),
|
|
183
|
-
content_hash: ContentHash,
|
|
184
|
-
});
|
|
185
|
-
export type SessionUploadPresignRequest = z.infer<
|
|
186
|
-
typeof SessionUploadPresignRequestSchema
|
|
187
|
-
>;
|
|
188
|
-
|
|
189
|
-
export const SessionUploadPresignResponseSchema = z.object({
|
|
190
|
-
upload_url: z.string().url(),
|
|
191
|
-
object_key: z.string().min(1),
|
|
192
|
-
expires_at: z.string().datetime(),
|
|
193
|
-
});
|
|
194
|
-
export type SessionUploadPresignResponse = z.infer<
|
|
195
|
-
typeof SessionUploadPresignResponseSchema
|
|
196
|
-
>;
|
|
197
|
-
|
|
198
|
-
export const SessionFinalizeRequestSchema = z.object({
|
|
199
|
-
object_key: z.string().min(1),
|
|
200
|
-
content_hash: ContentHash,
|
|
201
|
-
size_bytes: z.number().int().positive(),
|
|
202
|
-
note: z.string().optional(),
|
|
203
|
-
session_preview: OmniFlowSessionSummarySchema.optional(),
|
|
204
|
-
});
|
|
205
|
-
export type SessionFinalizeRequest = z.infer<
|
|
206
|
-
typeof SessionFinalizeRequestSchema
|
|
207
|
-
>;
|
|
208
|
-
|
|
209
|
-
export const SessionFinalizeResponseSchema = z.object({
|
|
210
|
-
id: Uuid,
|
|
211
|
-
content_hash: ContentHash,
|
|
212
|
-
new_config_etag: ConfigEtag.optional(),
|
|
213
|
-
});
|
|
214
|
-
export type SessionFinalizeResponse = z.infer<
|
|
215
|
-
typeof SessionFinalizeResponseSchema
|
|
216
|
-
>;
|
|
217
|
-
|
|
218
|
-
export const AttachmentUploadPresignRequestSchema = z.object({
|
|
219
|
-
filename: z.string().min(1),
|
|
220
|
-
mime: z.string().optional(),
|
|
221
|
-
size_bytes: z.number().int().positive(),
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
export const AttachmentUploadPresignResponseSchema =
|
|
225
|
-
SessionUploadPresignResponseSchema;
|
|
226
|
-
|
|
227
|
-
export const AttachmentFinalizeRequestSchema = z.object({
|
|
228
|
-
object_key: z.string().min(1),
|
|
229
|
-
filename: z.string().min(1),
|
|
230
|
-
mime: z.string().optional(),
|
|
231
|
-
size_bytes: z.number().int().positive(),
|
|
232
|
-
});
|
|
233
|
-
export type AttachmentFinalizeRequest = z.infer<
|
|
234
|
-
typeof AttachmentFinalizeRequestSchema
|
|
235
|
-
>;
|
|
236
|
-
|
|
237
|
-
export const AttachmentSchema = z.object({
|
|
238
|
-
id: Uuid,
|
|
239
|
-
filename: z.string().min(1),
|
|
240
|
-
mime: z.string().optional(),
|
|
241
|
-
size_bytes: z.number().int().positive(),
|
|
242
|
-
created_at: z.string().datetime(),
|
|
243
|
-
download_url: z.string().url().optional(),
|
|
244
|
-
});
|
|
245
|
-
export type Attachment = z.infer<typeof AttachmentSchema>;
|
|
246
|
-
|
|
247
|
-
/* ============================================================================
|
|
248
|
-
* Tasks
|
|
249
|
-
* ============================================================================ */
|
|
250
|
-
|
|
251
|
-
export const AdhocTaskTargetSchema = z
|
|
252
|
-
.object({
|
|
253
|
-
worker_ids: z.array(Uuid).default([]),
|
|
254
|
-
group_ids: z.array(Uuid).default([]),
|
|
255
|
-
})
|
|
256
|
-
.refine((v) => v.worker_ids.length + v.group_ids.length > 0, {
|
|
257
|
-
message: "must target at least one dp-worker or group",
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
export const AdhocTaskRequestSchema = z.object({
|
|
261
|
-
name: z.string().min(1),
|
|
262
|
-
prompt: z.string().min(1),
|
|
263
|
-
target: AdhocTaskTargetSchema,
|
|
264
|
-
/**
|
|
265
|
-
* 0 means dispatch immediately unless dispatch_window_seconds is set.
|
|
266
|
-
* >0 picks rand(0, random_delay_seconds) per target only when no dispatch
|
|
267
|
-
* window is set.
|
|
268
|
-
*/
|
|
269
|
-
random_delay_seconds: z.number().int().nonnegative().default(0),
|
|
270
|
-
/** 0 means no spreading; >0 spreads targets evenly over this dispatch window. */
|
|
271
|
-
dispatch_window_seconds: z.number().int().nonnegative().default(0),
|
|
272
|
-
priority: z.number().int().default(100),
|
|
273
|
-
});
|
|
274
|
-
export type AdhocTaskRequest = z.infer<typeof AdhocTaskRequestSchema>;
|
|
275
|
-
|
|
276
|
-
export const AdhocTaskBatchResponseSchema = z.object({
|
|
277
|
-
batch_id: Uuid,
|
|
278
|
-
task_run_ids: z.array(Uuid).min(1),
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
export const TaskRunSummarySchema = z.object({
|
|
282
|
-
id: Uuid,
|
|
283
|
-
worker_id: Uuid,
|
|
284
|
-
scheduled_task_id: Uuid.optional(),
|
|
285
|
-
source: TaskSource,
|
|
286
|
-
status: TaskRunStatus,
|
|
287
|
-
dispatched_at: z.string().datetime().optional(),
|
|
288
|
-
started_at: z.string().datetime().optional(),
|
|
289
|
-
finished_at: z.string().datetime().optional(),
|
|
290
|
-
error: z.string().optional(),
|
|
291
|
-
result_summary: z.string().optional(),
|
|
292
|
-
parent_adhoc_task_id: Uuid.optional(),
|
|
293
|
-
});
|
|
294
|
-
export type TaskRunSummary = z.infer<typeof TaskRunSummarySchema>;
|
|
295
|
-
|
|
296
|
-
export const TaskRunListResponseSchema = z.object({
|
|
297
|
-
items: z.array(TaskRunSummarySchema),
|
|
298
|
-
next_cursor: z.string().optional(),
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
/* ============================================================================
|
|
302
|
-
* Scheduled tasks CRUD
|
|
303
|
-
* ============================================================================ */
|
|
304
|
-
|
|
305
|
-
export const ScheduledTaskBodySchema = z.object({
|
|
306
|
-
name: z.string().min(1),
|
|
307
|
-
cron: z.string().min(1),
|
|
308
|
-
timezone: z.string().optional(),
|
|
309
|
-
prompt: z.string().min(1),
|
|
310
|
-
random_delay_seconds: z.number().int().nonnegative().default(0),
|
|
311
|
-
enabled: z.boolean().default(true),
|
|
312
|
-
});
|
|
313
|
-
export type ScheduledTaskBody = z.infer<typeof ScheduledTaskBodySchema>;
|
|
314
|
-
|
|
315
|
-
export const ScheduledTaskResponseSchema = ScheduledTaskBodySchema.extend({
|
|
316
|
-
id: Uuid,
|
|
317
|
-
worker_id: Uuid,
|
|
318
|
-
group_task_id: Uuid.optional(),
|
|
319
|
-
last_run_at: z.string().datetime().optional(),
|
|
320
|
-
last_status: z.enum(["ok", "error"]).optional(),
|
|
321
|
-
run_count: z.number().int().nonnegative().default(0),
|
|
322
|
-
success_count: z.number().int().nonnegative().default(0),
|
|
323
|
-
created_at: z.string().datetime(),
|
|
324
|
-
updated_at: z.string().datetime(),
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
/* ============================================================================
|
|
328
|
-
* Scheduled-task groups — master card that owns one child scheduled_tasks row
|
|
329
|
-
* per worker. The master fans out create/patch/enable/delete to its children;
|
|
330
|
-
* each child still fires on its own bound-proxy timezone.
|
|
331
|
-
* ============================================================================ */
|
|
332
|
-
|
|
333
|
-
/** Create a master: shared task definition + the target workers/groups to fan out to. */
|
|
334
|
-
export const ScheduledTaskGroupBodySchema = z.object({
|
|
335
|
-
name: z.string().min(1),
|
|
336
|
-
cron: z.string().min(1),
|
|
337
|
-
prompt: z.string().min(1),
|
|
338
|
-
random_delay_seconds: z.number().int().nonnegative().default(0),
|
|
339
|
-
enabled: z.boolean().default(true),
|
|
340
|
-
target: AdhocTaskTargetSchema,
|
|
341
|
-
/**
|
|
342
|
-
* Optional worker_group this master is sourced from. Stored so the UI can
|
|
343
|
-
* later "sync members" against the live group roster. Membership is otherwise
|
|
344
|
-
* a snapshot taken at creation time.
|
|
345
|
-
*/
|
|
346
|
-
source_group_id: Uuid.optional(),
|
|
347
|
-
});
|
|
348
|
-
export type ScheduledTaskGroupBody = z.infer<typeof ScheduledTaskGroupBodySchema>;
|
|
349
|
-
|
|
350
|
-
/** Partial update; every present field propagates to all child tasks. */
|
|
351
|
-
export const ScheduledTaskGroupPatchSchema = z
|
|
352
|
-
.object({
|
|
353
|
-
name: z.string().min(1).optional(),
|
|
354
|
-
cron: z.string().min(1).optional(),
|
|
355
|
-
prompt: z.string().min(1).optional(),
|
|
356
|
-
random_delay_seconds: z.number().int().nonnegative().optional(),
|
|
357
|
-
enabled: z.boolean().optional(),
|
|
358
|
-
})
|
|
359
|
-
.refine((v) => Object.keys(v).length > 0, {
|
|
360
|
-
message: "patch body must contain at least one field",
|
|
361
|
-
});
|
|
362
|
-
export type ScheduledTaskGroupPatch = z.infer<typeof ScheduledTaskGroupPatchSchema>;
|
|
363
|
-
|
|
364
|
-
/** Per-member health rollup shown on the master card. */
|
|
365
|
-
export const ScheduledTaskGroupHealthSchema = z.object({
|
|
366
|
-
healthy: z.number().int().nonnegative(),
|
|
367
|
-
failing: z.number().int().nonnegative(),
|
|
368
|
-
never_run: z.number().int().nonnegative(),
|
|
369
|
-
disabled: z.number().int().nonnegative(),
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
export const ScheduledTaskGroupListItemSchema = z.object({
|
|
373
|
-
id: Uuid,
|
|
374
|
-
name: z.string(),
|
|
375
|
-
cron: z.string(),
|
|
376
|
-
prompt: z.string(),
|
|
377
|
-
random_delay_seconds: z.number().int().nonnegative(),
|
|
378
|
-
enabled: z.boolean(),
|
|
379
|
-
source_group_id: Uuid.optional(),
|
|
380
|
-
source_group_name: z.string().optional(),
|
|
381
|
-
member_count: z.number().int().nonnegative(),
|
|
382
|
-
health: ScheduledTaskGroupHealthSchema,
|
|
383
|
-
/** Earliest/latest next fire across members (per-proxy tz), for the "next run" range. */
|
|
384
|
-
next_fire_at_min: z.string().datetime().optional(),
|
|
385
|
-
next_fire_at_max: z.string().datetime().optional(),
|
|
386
|
-
created_at: z.string().datetime(),
|
|
387
|
-
updated_at: z.string().datetime(),
|
|
388
|
-
});
|
|
389
|
-
export type ScheduledTaskGroupListItem = z.infer<
|
|
390
|
-
typeof ScheduledTaskGroupListItemSchema
|
|
391
|
-
>;
|
|
392
|
-
|
|
393
|
-
export const ScheduledTaskGroupListResponseSchema = z.object({
|
|
394
|
-
items: z.array(ScheduledTaskGroupListItemSchema),
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
/** Detail = master + its child task ids (children fetched via the scheduled-tasks list). */
|
|
398
|
-
export const ScheduledTaskGroupDetailSchema =
|
|
399
|
-
ScheduledTaskGroupListItemSchema.extend({
|
|
400
|
-
member_worker_ids: z.array(Uuid),
|
|
401
|
-
});
|
|
402
|
-
export type ScheduledTaskGroupDetail = z.infer<
|
|
403
|
-
typeof ScheduledTaskGroupDetailSchema
|
|
404
|
-
>;
|
|
405
|
-
|
|
406
|
-
/** Result of a member-sync: which child tasks were added / removed. */
|
|
407
|
-
export const ScheduledTaskGroupSyncResponseSchema = z.object({
|
|
408
|
-
added_worker_ids: z.array(Uuid),
|
|
409
|
-
removed_worker_ids: z.array(Uuid),
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Backfill: adopt OLD standalone scheduled tasks (group_task_id IS NULL) that
|
|
414
|
-
* were fanned out by the legacy loop into master cards. Two tasks are treated
|
|
415
|
-
* as one batch when name + cron + prompt + random_delay_seconds all match across
|
|
416
|
-
* 2+ distinct workers. Always dry-run-first; only touches ungrouped tasks.
|
|
417
|
-
*/
|
|
418
|
-
export const ScheduledTaskBackfillRequestSchema = z.object({
|
|
419
|
-
/** true = preview only (no writes). */
|
|
420
|
-
dry_run: z.boolean().default(true),
|
|
421
|
-
/** Optional cutoff; only tasks created before this instant are eligible. */
|
|
422
|
-
created_before: z.string().datetime().optional(),
|
|
423
|
-
});
|
|
424
|
-
export type ScheduledTaskBackfillRequest = z.infer<
|
|
425
|
-
typeof ScheduledTaskBackfillRequestSchema
|
|
426
|
-
>;
|
|
427
|
-
|
|
428
|
-
export const ScheduledTaskBackfillGroupSchema = z.object({
|
|
429
|
-
name: z.string(),
|
|
430
|
-
cron: z.string(),
|
|
431
|
-
prompt: z.string(),
|
|
432
|
-
random_delay_seconds: z.number().int().nonnegative(),
|
|
433
|
-
member_count: z.number().int().nonnegative(),
|
|
434
|
-
enabled_count: z.number().int().nonnegative(),
|
|
435
|
-
worker_names: z.array(z.string()),
|
|
436
|
-
created_at_min: z.string().datetime(),
|
|
437
|
-
created_at_max: z.string().datetime(),
|
|
438
|
-
/** Matched worker_group with an identical member set (enables later sync). */
|
|
439
|
-
source_group_name: z.string().optional(),
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
export const ScheduledTaskBackfillResponseSchema = z.object({
|
|
443
|
-
dry_run: z.boolean(),
|
|
444
|
-
groups: z.array(ScheduledTaskBackfillGroupSchema),
|
|
445
|
-
/** Present when dry_run=false: what was actually written. */
|
|
446
|
-
created_group_count: z.number().int().nonnegative().optional(),
|
|
447
|
-
grouped_task_count: z.number().int().nonnegative().optional(),
|
|
448
|
-
});
|
|
449
|
-
export type ScheduledTaskBackfillResponse = z.infer<
|
|
450
|
-
typeof ScheduledTaskBackfillResponseSchema
|
|
451
|
-
>;
|
|
452
|
-
|
|
453
|
-
/* ============================================================================
|
|
454
|
-
* Task health report — fleet-wide run-outcome rollup over a time window,
|
|
455
|
-
* grouped by master card (scheduled_task_group) and by worker.
|
|
456
|
-
* ============================================================================ */
|
|
457
|
-
|
|
458
|
-
export const HealthReportWindow = z.enum(["24h", "7d"]);
|
|
459
|
-
export type HealthReportWindowT = z.infer<typeof HealthReportWindow>;
|
|
460
|
-
|
|
461
|
-
export const HealthReportSummarySchema = z.object({
|
|
462
|
-
total_runs: z.number().int().nonnegative(),
|
|
463
|
-
success: z.number().int().nonnegative(),
|
|
464
|
-
failed: z.number().int().nonnegative(),
|
|
465
|
-
cancelled: z.number().int().nonnegative(),
|
|
466
|
-
in_progress: z.number().int().nonnegative(),
|
|
467
|
-
/** success / (success + failed); 0 when there were no terminal runs. */
|
|
468
|
-
success_rate: z.number(),
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
export const HealthReportGroupSchema = z.object({
|
|
472
|
-
id: Uuid,
|
|
473
|
-
name: z.string(),
|
|
474
|
-
member_count: z.number().int().nonnegative(),
|
|
475
|
-
runs: z.number().int().nonnegative(),
|
|
476
|
-
success: z.number().int().nonnegative(),
|
|
477
|
-
failed: z.number().int().nonnegative(),
|
|
478
|
-
success_rate: z.number(),
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
export const HealthReportWorkerSchema = z.object({
|
|
482
|
-
worker_id: Uuid,
|
|
483
|
-
worker_name: z.string(),
|
|
484
|
-
runs: z.number().int().nonnegative(),
|
|
485
|
-
success: z.number().int().nonnegative(),
|
|
486
|
-
failed: z.number().int().nonnegative(),
|
|
487
|
-
success_rate: z.number(),
|
|
488
|
-
last_success_at: z.string().datetime().optional(),
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
export const HealthReportResponseSchema = z.object({
|
|
492
|
-
window: HealthReportWindow,
|
|
493
|
-
generated_at: z.string().datetime(),
|
|
494
|
-
summary: HealthReportSummarySchema,
|
|
495
|
-
groups: z.array(HealthReportGroupSchema),
|
|
496
|
-
workers: z.array(HealthReportWorkerSchema),
|
|
497
|
-
});
|
|
498
|
-
export type HealthReportResponse = z.infer<typeof HealthReportResponseSchema>;
|
|
499
|
-
|
|
500
|
-
/* ============================================================================
|
|
501
|
-
* Chat
|
|
502
|
-
* ============================================================================ */
|
|
503
|
-
|
|
504
|
-
export const ChatSendRequestSchema = z
|
|
505
|
-
.object({
|
|
506
|
-
content: z.string().default(""),
|
|
507
|
-
attachment_ids: z.array(Uuid).default([]),
|
|
508
|
-
})
|
|
509
|
-
.refine(
|
|
510
|
-
(body) => body.content.trim().length > 0 || body.attachment_ids.length > 0,
|
|
511
|
-
{
|
|
512
|
-
message: "content or attachment_ids required",
|
|
513
|
-
path: ["content"],
|
|
514
|
-
}
|
|
515
|
-
);
|
|
516
|
-
|
|
517
|
-
export const ChatHistoryItemSchema = z.object({
|
|
518
|
-
id: Uuid,
|
|
519
|
-
chat_id: Uuid,
|
|
520
|
-
role: z.string(),
|
|
521
|
-
content_json: z.unknown(),
|
|
522
|
-
attachment_ids: z.array(Uuid).default([]),
|
|
523
|
-
attachments: z.array(AttachmentSchema).default([]),
|
|
524
|
-
task_run_id: Uuid.optional(),
|
|
525
|
-
sender_user_id: Uuid.optional(),
|
|
526
|
-
created_at: z.string().datetime(),
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
export const ChatHistoryResponseSchema = z.object({
|
|
530
|
-
items: z.array(ChatHistoryItemSchema),
|
|
531
|
-
next_cursor: z.string().optional(),
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
/* ============================================================================
|
|
535
|
-
* Groups CRUD (M7 Phase A)
|
|
536
|
-
* ============================================================================ */
|
|
537
|
-
|
|
538
|
-
export const GroupBodySchema = z.object({
|
|
539
|
-
name: z.string().min(1).max(120),
|
|
540
|
-
description: z.string().max(1000).optional(),
|
|
541
|
-
});
|
|
542
|
-
export type GroupBody = z.infer<typeof GroupBodySchema>;
|
|
543
|
-
|
|
544
|
-
export const GroupPatchSchema = z
|
|
545
|
-
.object({
|
|
546
|
-
name: z.string().min(1).max(120).optional(),
|
|
547
|
-
description: z.string().max(1000).nullable().optional(),
|
|
548
|
-
})
|
|
549
|
-
.refine((v) => Object.keys(v).length > 0, {
|
|
550
|
-
message: "patch body must contain at least one field",
|
|
551
|
-
});
|
|
552
|
-
export type GroupPatch = z.infer<typeof GroupPatchSchema>;
|
|
553
|
-
|
|
554
|
-
export const GroupMemberMutationSchema = z.object({
|
|
555
|
-
worker_ids: z.array(Uuid).min(1).max(200),
|
|
556
|
-
});
|
|
557
|
-
export type GroupMemberMutation = z.infer<typeof GroupMemberMutationSchema>;
|
|
558
|
-
|
|
559
|
-
export const GroupListItemSchema = z.object({
|
|
560
|
-
id: Uuid,
|
|
561
|
-
name: z.string(),
|
|
562
|
-
description: z.string().optional(),
|
|
563
|
-
member_count: z.number().int().nonnegative(),
|
|
564
|
-
created_at: z.string().datetime(),
|
|
565
|
-
updated_at: z.string().datetime(),
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
export const GroupDetailSchema = GroupListItemSchema.extend({
|
|
569
|
-
member_worker_ids: z.array(Uuid),
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
/* ============================================================================
|
|
573
|
-
* Status / list endpoints (subset)
|
|
574
|
-
* ============================================================================ */
|
|
575
|
-
|
|
576
|
-
export const WorkerListItemSchema = z.object({
|
|
577
|
-
id: Uuid,
|
|
578
|
-
name: z.string(),
|
|
579
|
-
director_id: Uuid.optional(),
|
|
580
|
-
status: EffectiveWorkerStatus,
|
|
581
|
-
current_task_id: Uuid.optional(),
|
|
582
|
-
process_status: ProcessStatus.optional(),
|
|
583
|
-
runtime_status: RuntimeStatus.optional(),
|
|
584
|
-
process_observed_at: z.string().datetime().optional(),
|
|
585
|
-
runtime_observed_at: z.string().datetime().optional(),
|
|
586
|
-
last_heartbeat_at: z.string().datetime().optional(),
|
|
587
|
-
effective_status: EffectiveWorkerStatus.optional(),
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
export const WorkerListResponseSchema = z.object({
|
|
591
|
-
items: z.array(WorkerListItemSchema),
|
|
592
|
-
});
|