dp-worker 0.1.18 → 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.
Files changed (86) hide show
  1. package/builtin-skills/x.md +27 -0
  2. package/dist/bird/bird-frontend.d.ts +33 -0
  3. package/dist/bird/bird-frontend.js +68 -0
  4. package/dist/bird/bird-frontend.js.map +1 -0
  5. package/dist/bird/credentials.d.ts +36 -0
  6. package/dist/bird/credentials.js +82 -0
  7. package/dist/bird/credentials.js.map +1 -0
  8. package/dist/bird/ops.d.ts +103 -0
  9. package/dist/bird/ops.js +523 -0
  10. package/dist/bird/ops.js.map +1 -0
  11. package/dist/bird/sidecar-entry.d.ts +25 -0
  12. package/dist/bird/sidecar-entry.js +192 -0
  13. package/dist/bird/sidecar-entry.js.map +1 -0
  14. package/dist/bird/sidecar-host.d.ts +54 -0
  15. package/dist/bird/sidecar-host.js +318 -0
  16. package/dist/bird/sidecar-host.js.map +1 -0
  17. package/dist/bird/socks-connector.d.ts +26 -0
  18. package/dist/bird/socks-connector.js +49 -0
  19. package/dist/bird/socks-connector.js.map +1 -0
  20. package/dist/chrome-extension/omni-flow/manifest.json +1 -1
  21. package/dist/config/center-config.d.ts +8 -0
  22. package/dist/config/center-config.js +1 -0
  23. package/dist/config/center-config.js.map +1 -1
  24. package/dist/index.js +14 -0
  25. package/dist/index.js.map +1 -1
  26. package/node_modules/dp-shared/dist/admin-broadcast.d.ts +1 -1
  27. package/node_modules/dp-shared/dist/admin-broadcast.d.ts.map +1 -1
  28. package/node_modules/dp-shared/dist/bird-contracts.d.ts +483 -0
  29. package/node_modules/dp-shared/dist/bird-contracts.d.ts.map +1 -0
  30. package/node_modules/dp-shared/dist/bird-contracts.js +372 -0
  31. package/node_modules/dp-shared/dist/bird-contracts.js.map +1 -0
  32. package/node_modules/dp-shared/dist/configs-contracts.d.ts +11 -1
  33. package/node_modules/dp-shared/dist/configs-contracts.d.ts.map +1 -1
  34. package/node_modules/dp-shared/dist/configs-contracts.js +43 -0
  35. package/node_modules/dp-shared/dist/configs-contracts.js.map +1 -1
  36. package/node_modules/dp-shared/dist/index.d.ts +2 -0
  37. package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
  38. package/node_modules/dp-shared/dist/index.js +2 -0
  39. package/node_modules/dp-shared/dist/index.js.map +1 -1
  40. package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts +9 -3
  41. package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts.map +1 -1
  42. package/node_modules/dp-shared/dist/post-drafts-contracts.js +34 -0
  43. package/node_modules/dp-shared/dist/post-drafts-contracts.js.map +1 -1
  44. package/node_modules/dp-shared/dist/promo-contracts.d.ts +651 -0
  45. package/node_modules/dp-shared/dist/promo-contracts.d.ts.map +1 -0
  46. package/node_modules/dp-shared/dist/promo-contracts.js +566 -0
  47. package/node_modules/dp-shared/dist/promo-contracts.js.map +1 -0
  48. package/node_modules/dp-shared/dist/rest-contracts.d.ts +73 -0
  49. package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
  50. package/node_modules/dp-shared/dist/rest-contracts.js +70 -0
  51. package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
  52. package/node_modules/dp-shared/dist/smart-money-contracts.d.ts +86 -0
  53. package/node_modules/dp-shared/dist/smart-money-contracts.d.ts.map +1 -0
  54. package/node_modules/dp-shared/dist/smart-money-contracts.js +71 -0
  55. package/node_modules/dp-shared/dist/smart-money-contracts.js.map +1 -0
  56. package/node_modules/dp-shared/dist/task-history-contracts.d.ts +2 -0
  57. package/node_modules/dp-shared/dist/task-history-contracts.d.ts.map +1 -1
  58. package/node_modules/dp-shared/dist/task-history-contracts.js +2 -0
  59. package/node_modules/dp-shared/dist/task-history-contracts.js.map +1 -1
  60. package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +7 -0
  61. package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts.map +1 -1
  62. package/node_modules/dp-shared/dist/worker-detail-contracts.js +9 -0
  63. package/node_modules/dp-shared/dist/worker-detail-contracts.js.map +1 -1
  64. package/node_modules/dp-shared/dist/ws-protocol.d.ts +52 -0
  65. package/node_modules/dp-shared/dist/ws-protocol.d.ts.map +1 -1
  66. package/node_modules/dp-shared/dist/ws-protocol.js +37 -0
  67. package/node_modules/dp-shared/dist/ws-protocol.js.map +1 -1
  68. package/package.json +4 -1
  69. package/node_modules/dp-shared/src/admin-broadcast.ts +0 -41
  70. package/node_modules/dp-shared/src/audit-contracts.ts +0 -33
  71. package/node_modules/dp-shared/src/auto-post-contracts.ts +0 -206
  72. package/node_modules/dp-shared/src/cloak-contracts.ts +0 -110
  73. package/node_modules/dp-shared/src/configs-contracts.ts +0 -249
  74. package/node_modules/dp-shared/src/db-rows.ts +0 -303
  75. package/node_modules/dp-shared/src/deploy-contracts.ts +0 -38
  76. package/node_modules/dp-shared/src/domain.ts +0 -124
  77. package/node_modules/dp-shared/src/fingerprint.ts +0 -21
  78. package/node_modules/dp-shared/src/identities.ts +0 -38
  79. package/node_modules/dp-shared/src/index.ts +0 -30
  80. package/node_modules/dp-shared/src/omni-flow-cookie.ts +0 -272
  81. package/node_modules/dp-shared/src/omni-flow-session.ts +0 -79
  82. package/node_modules/dp-shared/src/post-drafts-contracts.ts +0 -807
  83. package/node_modules/dp-shared/src/rest-contracts.ts +0 -592
  84. package/node_modules/dp-shared/src/task-history-contracts.ts +0 -124
  85. package/node_modules/dp-shared/src/worker-detail-contracts.ts +0 -236
  86. package/node_modules/dp-shared/src/ws-protocol.ts +0 -495
@@ -1,249 +0,0 @@
1
- import { z } from "zod/v4";
2
- import {
3
- DpWorkerRuntimeMode,
4
- DpWorkerUpgradeStatus,
5
- EffectiveDirectorStatus,
6
- IanaTimezone,
7
- LlmProtocol,
8
- ProxyProtocol,
9
- } from "./domain.js";
10
-
11
- /**
12
- * Request/response contracts for the `/configs/*` REST family — LLM profile
13
- * and proxy CRUD that the Web UI drives. Kept distinct from
14
- * `rest-contracts.ts` so the wave-1 UI work doesn't touch the
15
- * already-stable bootstrap/task schemas.
16
- *
17
- * Notes:
18
- * - LLM profile responses include `api_key` / `image_api_key` in plaintext
19
- * for the admin UI's reveal/copy affordance (internal-use project; see
20
- * CLAUDE.md). dp-worker bootstrap reads the same secrets via a separate
21
- * schema (`LlmProfileSchema` in rest-contracts.ts).
22
- * - Proxy responses include `password` in plaintext for the same reason
23
- * (admin UI reveal/copy).
24
- * - `base_url` is sanitized server-side per the project convention (strip
25
- * trailing `/v1`); the client can send either form.
26
- */
27
-
28
- /* ============================================================================
29
- * LLM profiles
30
- * ============================================================================ */
31
-
32
- export const LlmProfileBodySchema = z.object({
33
- name: z.string().min(1).max(120),
34
- protocol: LlmProtocol,
35
- base_url: z.string().min(1).max(500),
36
- api_key: z.string().min(1),
37
- model: z.string().min(1).max(120),
38
- image_model: z.string().min(1).max(120).optional(),
39
- image_api_key: z.string().min(1).optional(),
40
- image_size: z.string().min(1).max(40).optional(),
41
- });
42
- export type LlmProfileBody = z.infer<typeof LlmProfileBodySchema>;
43
-
44
- export const LlmProfilePatchSchema = z
45
- .object({
46
- name: z.string().min(1).max(120).optional(),
47
- protocol: LlmProtocol.optional(),
48
- base_url: z.string().min(1).max(500).optional(),
49
- api_key: z.string().min(1).optional(),
50
- model: z.string().min(1).max(120).optional(),
51
- image_model: z.string().min(1).max(120).nullable().optional(),
52
- image_api_key: z.string().min(1).nullable().optional(),
53
- image_size: z.string().min(1).max(40).nullable().optional(),
54
- })
55
- .refine((v) => Object.keys(v).length > 0, {
56
- message: "patch body must contain at least one field",
57
- });
58
- export type LlmProfilePatch = z.infer<typeof LlmProfilePatchSchema>;
59
-
60
- export const LlmProfileListItemSchema = z.object({
61
- id: z.string().uuid(),
62
- name: z.string(),
63
- protocol: LlmProtocol,
64
- base_url: z.string(),
65
- api_key: z.string(),
66
- model: z.string(),
67
- image_model: z.string().optional(),
68
- image_api_key: z.string().optional(),
69
- image_size: z.string().optional(),
70
- in_use_by_worker_count: z.number().int().nonnegative(),
71
- created_at: z.string().datetime(),
72
- updated_at: z.string().datetime(),
73
- });
74
- export type LlmProfileListItem = z.infer<typeof LlmProfileListItemSchema>;
75
-
76
- export const LlmProfileTestResultSchema = z.object({
77
- ok: z.boolean(),
78
- latency_ms: z.number().int().nonnegative(),
79
- detail: z.string(),
80
- });
81
- export type LlmProfileTestResult = z.infer<
82
- typeof LlmProfileTestResultSchema
83
- >;
84
-
85
- /* ============================================================================
86
- * Proxies
87
- * ============================================================================ */
88
-
89
- export const ProxyBodySchema = z.object({
90
- label: z.string().min(1).max(120),
91
- protocol: ProxyProtocol,
92
- host: z.string().min(1).max(255),
93
- port: z.number().int().positive().max(65535),
94
- username: z.string().min(1).max(255),
95
- password: z.string().min(1),
96
- timezone: IanaTimezone,
97
- note: z.string().max(2000).optional(),
98
- });
99
- export type ProxyBody = z.infer<typeof ProxyBodySchema>;
100
-
101
- export const ProxyPatchSchema = z
102
- .object({
103
- label: z.string().min(1).max(120).optional(),
104
- protocol: ProxyProtocol.optional(),
105
- host: z.string().min(1).max(255).optional(),
106
- port: z.number().int().positive().max(65535).optional(),
107
- username: z.string().min(1).max(255).optional(),
108
- password: z.string().min(1).optional(),
109
- timezone: IanaTimezone.optional(),
110
- note: z.string().max(2000).nullable().optional(),
111
- })
112
- .refine((v) => Object.keys(v).length > 0, {
113
- message: "patch body must contain at least one field",
114
- });
115
- export type ProxyPatch = z.infer<typeof ProxyPatchSchema>;
116
-
117
- export const ProxyListItemSchema = z.object({
118
- id: z.string().uuid(),
119
- label: z.string(),
120
- protocol: ProxyProtocol,
121
- host: z.string(),
122
- port: z.number().int().positive(),
123
- username: z.string(),
124
- password: z.string(),
125
- timezone: IanaTimezone,
126
- note: z.string().optional(),
127
- in_use_by_worker_id: z.string().uuid().optional(),
128
- in_use_by_worker_name: z.string().optional(),
129
- bound_worker_id: z.string().uuid().optional(),
130
- bound_worker_name: z.string().optional(),
131
- bound_identity_id: z.string().uuid().optional(),
132
- bound_identity_name: z.string().optional(),
133
- /** How many identities currently have this proxy bound. */
134
- bound_identity_count: z.number().int().nonnegative().default(0),
135
- created_at: z.string().datetime(),
136
- updated_at: z.string().datetime(),
137
- });
138
- export type ProxyListItem = z.infer<typeof ProxyListItemSchema>;
139
-
140
- export const ProxyTestResultSchema = z.object({
141
- ok: z.boolean(),
142
- latency_ms: z.number().int().nonnegative(),
143
- detail: z.string(),
144
- });
145
- export type ProxyTestResult = z.infer<typeof ProxyTestResultSchema>;
146
-
147
- /**
148
- * Auto-detect timezone for a (not-yet-saved) proxy. The center worker first
149
- * routes a geo-IP lookup *through* the proxy to learn its real exit IP/zone,
150
- * falling back to a direct lookup of the entered host. Body carries connection
151
- * details inline because detection happens in the create/edit drawer before the
152
- * proxy is persisted.
153
- */
154
- export const DetectTimezoneBodySchema = z.object({
155
- protocol: ProxyProtocol,
156
- host: z.string().min(1).max(255),
157
- port: z.number().int().positive().max(65535),
158
- username: z.string().min(1).max(255),
159
- password: z.string().min(1),
160
- });
161
- export type DetectTimezoneBody = z.infer<typeof DetectTimezoneBodySchema>;
162
-
163
- export const DetectTimezoneResultSchema = z.object({
164
- ok: z.boolean(),
165
- /** IANA zone, e.g. "Asia/Tokyo". */
166
- timezone: z.string().optional(),
167
- /** Exit IP seen by the geo-IP service (only meaningful for source="proxy"). */
168
- exit_ip: z.string().optional(),
169
- /** ISO country code, e.g. "JP". */
170
- country: z.string().optional(),
171
- /** Where the zone came from: through the proxy, the entered host, or nothing. */
172
- source: z.enum(["proxy", "host", "none"]),
173
- /** One-line diagnostic. */
174
- detail: z.string(),
175
- });
176
- export type DetectTimezoneResult = z.infer<typeof DetectTimezoneResultSchema>;
177
-
178
- /* ============================================================================
179
- * dp-directors
180
- * ============================================================================ */
181
-
182
- export const DirectorListItemSchema = z.object({
183
- id: z.string().uuid(),
184
- name: z.string(),
185
- host_label: z.string(),
186
- // Optional: the server strips api_key for non-admins on protected directors.
187
- api_key: z.string().optional(),
188
- status: EffectiveDirectorStatus,
189
- // Admin-lock: when true only admins may edit/delete/upgrade or read api_key.
190
- is_protected: z.boolean().default(false),
191
- max_concurrent_tasks: z.number().int().nonnegative().default(0),
192
- last_heartbeat_at: z.string().datetime().optional(),
193
- version: z.string().optional(),
194
- dp_worker_version: z.string().optional(),
195
- dp_worker_latest_version: z.string().optional(),
196
- dp_worker_runtime_mode: DpWorkerRuntimeMode.optional(),
197
- dp_worker_upgrade_status: DpWorkerUpgradeStatus.optional(),
198
- dp_worker_upgrade_message: z.string().optional(),
199
- dp_worker_upgrade_started_at: z.string().datetime().optional(),
200
- dp_worker_upgrade_finished_at: z.string().datetime().optional(),
201
- created_at: z.string().datetime(),
202
- updated_at: z.string().datetime(),
203
- });
204
- export type DirectorListItem = z.infer<typeof DirectorListItemSchema>;
205
-
206
- export const DirectorCreateBodySchema = z.object({
207
- name: z.string().trim().min(1),
208
- host_label: z.string().trim().min(1),
209
- api_key: z.string().trim().min(1).optional(),
210
- max_concurrent_tasks: z.number().int().nonnegative().default(0),
211
- // Admin-only in effect: the handler forces false for non-admin callers.
212
- is_protected: z.boolean().optional(),
213
- });
214
- export type DirectorCreateBody = z.infer<typeof DirectorCreateBodySchema>;
215
-
216
- export const DirectorPatchSchema = z
217
- .object({
218
- name: z.string().trim().min(1).optional(),
219
- host_label: z.string().trim().min(1).optional(),
220
- api_key: z.string().trim().min(1).optional(),
221
- max_concurrent_tasks: z.number().int().nonnegative().optional(),
222
- // Admin-only toggle (enforced in the handler, not here).
223
- is_protected: z.boolean().optional(),
224
- })
225
- .refine((v) => Object.keys(v).length > 0, {
226
- message: "patch body must contain at least one field",
227
- });
228
- export type DirectorPatch = z.infer<typeof DirectorPatchSchema>;
229
-
230
- /* ============================================================================
231
- * Dispatch settings
232
- * ============================================================================ */
233
-
234
- export const DispatchSettingsSchema = z.object({
235
- global_max_concurrent_tasks: z.number().int().nonnegative().default(0),
236
- updated_at: z.string().datetime(),
237
- });
238
- export type DispatchSettings = z.infer<typeof DispatchSettingsSchema>;
239
-
240
- export const DispatchSettingsPatchSchema = z
241
- .object({
242
- global_max_concurrent_tasks: z.number().int().nonnegative().optional(),
243
- })
244
- .refine((v) => Object.keys(v).length > 0, {
245
- message: "patch body must contain at least one field",
246
- });
247
- export type DispatchSettingsPatch = z.infer<
248
- typeof DispatchSettingsPatchSchema
249
- >;
@@ -1,303 +0,0 @@
1
- import { z } from "zod/v4";
2
- import {
3
- ProcessStatus,
4
- RuntimeStatus,
5
- ChatScopeType,
6
- ConfigEtag,
7
- ContentHash,
8
- DpWorkerRuntimeMode,
9
- DpWorkerUpgradeStatus,
10
- IanaTimezone,
11
- LlmProtocol,
12
- ProxyProtocol,
13
- SocialPlatform,
14
- TaskRunStatus,
15
- TaskSource,
16
- UserRole,
17
- Uuid,
18
- } from "./domain.js";
19
-
20
- /**
21
- * Database row schemas — mirror the Postgres tables described in
22
- * docs/architecture.md §Data model. These are the canonical TypeScript shapes
23
- * that DAL code (Workers `src/lib/db.ts`) returns; do not hand-roll row types
24
- * elsewhere.
25
- *
26
- * All timestamps are ISO-8601 strings here (postgres.js returns Date but we
27
- * normalize at the DAL boundary). Nullable columns are modelled with .optional().
28
- */
29
-
30
- const Timestamps = {
31
- created_at: z.string().datetime(),
32
- updated_at: z.string().datetime(),
33
- };
34
-
35
- export const TenantRow = z.object({
36
- id: Uuid,
37
- name: z.string().min(1),
38
- ...Timestamps,
39
- });
40
-
41
- export const UserRow = z.object({
42
- id: Uuid,
43
- email: z.string().email(),
44
- role: UserRole,
45
- ...Timestamps,
46
- });
47
-
48
- export const ProxyRow = z.object({
49
- id: Uuid,
50
- label: z.string().min(1),
51
- protocol: ProxyProtocol,
52
- host: z.string().min(1),
53
- port: z.number().int().positive(),
54
- username: z.string().min(1),
55
- password: z.string().min(1),
56
- /** IANA timezone of the proxy egress. Required since v2.1 of the plan. */
57
- timezone: IanaTimezone,
58
- note: z.string().optional(),
59
- ...Timestamps,
60
- });
61
-
62
- export const LlmProfileRow = z.object({
63
- id: Uuid,
64
- name: z.string().min(1),
65
- protocol: LlmProtocol,
66
- base_url: z.string().min(1),
67
- api_key: z.string().min(1),
68
- model: z.string().min(1),
69
- image_model: z.string().optional(),
70
- image_api_key: z.string().optional(),
71
- image_size: z.string().optional(),
72
- ...Timestamps,
73
- });
74
-
75
- export const DirectorRow = z.object({
76
- id: Uuid,
77
- name: z.string().min(1),
78
- api_key: z.string().min(1),
79
- host_label: z.string().min(1),
80
- max_concurrent_tasks: z.number().int().nonnegative().default(0),
81
- last_heartbeat_at: z.string().datetime().optional(),
82
- version: z.string().optional(),
83
- dp_worker_version: z.string().optional(),
84
- dp_worker_latest_version: z.string().optional(),
85
- dp_worker_runtime_mode: DpWorkerRuntimeMode.optional(),
86
- dp_worker_upgrade_status: DpWorkerUpgradeStatus.optional(),
87
- dp_worker_upgrade_message: z.string().optional(),
88
- dp_worker_upgrade_started_at: z.string().datetime().optional(),
89
- dp_worker_upgrade_finished_at: z.string().datetime().optional(),
90
- ...Timestamps,
91
- });
92
-
93
- export const WorkerRow = z.object({
94
- id: Uuid,
95
- name: z.string().min(1),
96
- director_id: Uuid.optional(),
97
- api_key: z.string().min(1),
98
- llm_profile_id: Uuid,
99
- proxy_id: Uuid.optional(),
100
- /**
101
- * Per-dp-worker Chrome headless flag (M6). Defaults to false at the schema
102
- * level; operators flip it via Web UI.
103
- */
104
- headless: z.boolean().default(false),
105
- /**
106
- * Browser automation backend (cs). "chrome" = real Chrome + CDP + OmniFlow;
107
- * "cloakbrowser" = patched stealth Chromium via the cloakbrowser package.
108
- * Operators pick this at worker creation; PATCHable later.
109
- */
110
- browser_automation_mode: z.enum(["chrome", "cloakbrowser"]).default("cloakbrowser"),
111
- identity_id: Uuid.nullable().optional(),
112
- process_status: ProcessStatus,
113
- process_observed_at: z.string().datetime().optional(),
114
- runtime_status: RuntimeStatus,
115
- runtime_observed_at: z.string().datetime().optional(),
116
- last_heartbeat_at: z.string().datetime().optional(),
117
- current_task_id: Uuid.optional(),
118
- config_etag: ConfigEtag,
119
- session_content_hash: ContentHash.optional(),
120
- telegram_bot_token: z.string().optional(),
121
- telegram_allowed_users: z.array(z.number().int()).optional(),
122
- ...Timestamps,
123
- });
124
-
125
- export const SocialAccountRow = z.object({
126
- id: Uuid,
127
- identity_id: Uuid,
128
- platform: SocialPlatform,
129
- profile_name: z.string().default(""),
130
- login_type: z.enum(["password", "oauth"]).default("password"),
131
- username: z.string().nullable(),
132
- email: z.string().nullable(),
133
- password: z.string().nullable(),
134
- /** 2FA/TOTP secret or backup codes — record-only. */
135
- totp_secret: z.string().nullable(),
136
- /** NULL = inherit identity.persona_text; non-null = own persona. */
137
- persona_text: z.string().nullable(),
138
- persona_other_json: z.record(z.string(), z.unknown()).optional(),
139
- enabled: z.boolean().default(true),
140
- ...Timestamps,
141
- });
142
-
143
- export const WorkerGroupRow = z.object({
144
- id: Uuid,
145
- name: z.string().min(1),
146
- description: z.string().optional(),
147
- ...Timestamps,
148
- });
149
-
150
- export const WorkerGroupMemberRow = z.object({
151
- group_id: Uuid,
152
- worker_id: Uuid,
153
- added_at: z.string().datetime(),
154
- });
155
-
156
- export const ChromeSessionRow = z.object({
157
- id: Uuid,
158
- identity_id: Uuid,
159
- r2_object_key: z.string().min(1),
160
- content_hash: ContentHash,
161
- size_bytes: z.number().int().positive(),
162
- uploaded_by: Uuid,
163
- uploaded_at: z.string().datetime(),
164
- note: z.string().optional(),
165
- });
166
-
167
- export const ScheduledTaskRow = z.object({
168
- id: Uuid,
169
- worker_id: Uuid,
170
- name: z.string().min(1),
171
- cron: z.string().min(1),
172
- timezone: z.string().optional(),
173
- prompt: z.string().min(1),
174
- random_delay_seconds: z.number().int().nonnegative().default(0),
175
- enabled: z.boolean(),
176
- last_run_at: z.string().datetime().optional(),
177
- last_status: z.enum(["ok", "error"]).optional(),
178
- run_count: z.number().int().nonnegative().default(0),
179
- success_count: z.number().int().nonnegative().default(0),
180
- /** Owning master card (scheduled_task_groups.id); absent for standalone tasks. */
181
- group_task_id: Uuid.optional(),
182
- created_by: Uuid.optional(),
183
- ...Timestamps,
184
- });
185
-
186
- export const ScheduledTaskGroupRow = z.object({
187
- id: Uuid,
188
- name: z.string().min(1),
189
- cron: z.string().min(1),
190
- prompt: z.string().min(1),
191
- random_delay_seconds: z.number().int().nonnegative().default(0),
192
- enabled: z.boolean(),
193
- /** worker_group this master was created from; null after that group is deleted. */
194
- source_group_id: Uuid.optional(),
195
- created_by: Uuid.optional(),
196
- ...Timestamps,
197
- });
198
-
199
- export const TaskRunRow = z.object({
200
- id: Uuid,
201
- worker_id: Uuid,
202
- scheduled_task_id: Uuid.optional(),
203
- source: TaskSource,
204
- prompt: z.string().min(1),
205
- target_descriptor_json: z.record(z.string(), z.unknown()).optional(),
206
- status: TaskRunStatus,
207
- dispatched_at: z.string().datetime().optional(),
208
- started_at: z.string().datetime().optional(),
209
- finished_at: z.string().datetime().optional(),
210
- result_summary: z.string().optional(),
211
- error: z.string().optional(),
212
- randomized_delay_ms: z.number().int().nonnegative().default(0),
213
- scheduled_fire_at: z.string().datetime().optional(),
214
- created_by: Uuid.optional(),
215
- parent_adhoc_task_id: Uuid.optional(),
216
- ...Timestamps,
217
- });
218
-
219
- export const AdhocTaskBatchRow = z.object({
220
- id: Uuid,
221
- name: z.string().min(1),
222
- prompt: z.string().min(1),
223
- target_descriptor_json: z.record(z.string(), z.unknown()),
224
- random_delay_seconds: z.number().int().nonnegative().default(0),
225
- dispatch_window_seconds: z.number().int().nonnegative().default(0),
226
- created_by: Uuid.optional(),
227
- created_at: z.string().datetime(),
228
- summary_stats_json: z.record(z.string(), z.unknown()).optional(),
229
- });
230
-
231
- export const TaskDispatchQueueRow = z.object({
232
- id: Uuid,
233
- worker_id: Uuid,
234
- task_run_id: Uuid,
235
- eta: z.string().datetime(),
236
- priority: z.number().int().default(0),
237
- attempts: z.number().int().nonnegative().default(0),
238
- ...Timestamps,
239
- });
240
-
241
- export const ChatRow = z.object({
242
- id: Uuid,
243
- scope_type: ChatScopeType,
244
- scope_id: Uuid,
245
- last_message_at: z.string().datetime().optional(),
246
- ...Timestamps,
247
- });
248
-
249
- export const ChatMessageRow = z.object({
250
- id: Uuid,
251
- chat_id: Uuid,
252
- role: z.string().min(1),
253
- content_json: z.unknown(),
254
- attachment_ids: z.array(Uuid).default([]),
255
- task_run_id: Uuid.optional(),
256
- sender_user_id: Uuid.optional(),
257
- created_at: z.string().datetime(),
258
- });
259
-
260
- export const AttachmentRow = z.object({
261
- id: Uuid,
262
- chat_id: Uuid.optional(),
263
- r2_object_key: z.string().min(1),
264
- filename: z.string().min(1),
265
- mime: z.string().optional(),
266
- size: z.number().int().positive(),
267
- uploaded_by: Uuid,
268
- created_at: z.string().datetime(),
269
- });
270
-
271
- export const AuditLogRow = z.object({
272
- id: Uuid,
273
- actor_user_id: Uuid.optional(),
274
- actor_machine_id: Uuid.optional(),
275
- action: z.string().min(1),
276
- target_type: z.string().min(1),
277
- target_id: z.string().min(1),
278
- payload_json: z.record(z.string(), z.unknown()).optional(),
279
- created_at: z.string().datetime(),
280
- });
281
-
282
- /* ============================================================================
283
- * Inferred row types — what DAL functions return.
284
- * ============================================================================ */
285
-
286
- export type TenantRow = z.infer<typeof TenantRow>;
287
- export type UserRow = z.infer<typeof UserRow>;
288
- export type ProxyRow = z.infer<typeof ProxyRow>;
289
- export type LlmProfileRow = z.infer<typeof LlmProfileRow>;
290
- export type DirectorRow = z.infer<typeof DirectorRow>;
291
- export type WorkerRow = z.infer<typeof WorkerRow>;
292
- export type SocialAccountRow = z.infer<typeof SocialAccountRow>;
293
- export type WorkerGroupRow = z.infer<typeof WorkerGroupRow>;
294
- export type WorkerGroupMemberRow = z.infer<typeof WorkerGroupMemberRow>;
295
- export type ChromeSessionRow = z.infer<typeof ChromeSessionRow>;
296
- export type ScheduledTaskRow = z.infer<typeof ScheduledTaskRow>;
297
- export type TaskRunRow = z.infer<typeof TaskRunRow>;
298
- export type AdhocTaskBatchRow = z.infer<typeof AdhocTaskBatchRow>;
299
- export type TaskDispatchQueueRow = z.infer<typeof TaskDispatchQueueRow>;
300
- export type ChatRow = z.infer<typeof ChatRow>;
301
- export type ChatMessageRow = z.infer<typeof ChatMessageRow>;
302
- export type AttachmentRow = z.infer<typeof AttachmentRow>;
303
- export type AuditLogRow = z.infer<typeof AuditLogRow>;
@@ -1,38 +0,0 @@
1
- import { z } from "zod/v4";
2
- import { Uuid } from "./domain.js";
3
-
4
- /**
5
- * dp-worker lifecycle deploy / restart / stop contracts (M-X wave 2 Agent A).
6
- *
7
- * The UI button hits dp-center-worker; dp-center-worker RPCs the DirectorConnection DO,
8
- * which forwards a `spawn_worker` / `restart_worker` / `stop_worker` envelope
9
- * (defined in ws-protocol.ts) over the hibernating WS to the dp-director. The
10
- * dp-director's `worker_state_change` flows back asynchronously — the REST call
11
- * just confirms the envelope was queued for delivery.
12
- *
13
- * Request bodies are intentionally thin: the WS envelope is assembled
14
- * server-side from the dp-worker row (api_key, director_id, …) so callers never
15
- * see the api_key in the wire path.
16
- */
17
-
18
- /** No body. The deploy envelope is constructed entirely server-side. */
19
- export const DeployRequestSchema = z.object({});
20
- export type DeployRequest = z.infer<typeof DeployRequestSchema>;
21
-
22
- /** Same shape used by all three lifecycle endpoints on the 202 path. */
23
- export const DeployResponseSchema = z.object({
24
- accepted: z.literal(true),
25
- envelope_id: Uuid,
26
- director_id: Uuid,
27
- });
28
- export type DeployResponse = z.infer<typeof DeployResponseSchema>;
29
-
30
- /**
31
- * Optional `graceful` flag on stop. When `false` the dp-director SIGKILLs instead
32
- * of giving the dp-worker process its normal SIGTERM grace window. Defaults to
33
- * true (graceful) when the body is omitted.
34
- */
35
- export const StopRequestSchema = z.object({
36
- graceful: z.boolean().optional(),
37
- });
38
- export type StopRequest = z.infer<typeof StopRequestSchema>;