dp-worker 0.1.3 → 0.1.5

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 (35) hide show
  1. package/dist/browser/chrome-process.js +30 -58
  2. package/dist/browser/chrome-process.js.map +1 -1
  3. package/dist/chrome-extension/omni-flow/background.js +24 -6
  4. package/node_modules/dp-shared/dist/configs-contracts.d.ts +5 -0
  5. package/node_modules/dp-shared/dist/configs-contracts.d.ts.map +1 -1
  6. package/node_modules/dp-shared/dist/configs-contracts.js +5 -0
  7. package/node_modules/dp-shared/dist/configs-contracts.js.map +1 -1
  8. package/node_modules/dp-shared/dist/db-rows.d.ts +1 -1
  9. package/node_modules/dp-shared/dist/db-rows.d.ts.map +1 -1
  10. package/node_modules/dp-shared/dist/db-rows.js +1 -1
  11. package/node_modules/dp-shared/dist/db-rows.js.map +1 -1
  12. package/node_modules/dp-shared/dist/identities.d.ts +2 -0
  13. package/node_modules/dp-shared/dist/identities.d.ts.map +1 -1
  14. package/node_modules/dp-shared/dist/identities.js +2 -0
  15. package/node_modules/dp-shared/dist/identities.js.map +1 -1
  16. package/node_modules/dp-shared/dist/task-history-contracts.d.ts +6 -0
  17. package/node_modules/dp-shared/dist/task-history-contracts.d.ts.map +1 -1
  18. package/node_modules/dp-shared/dist/task-history-contracts.js +3 -0
  19. package/node_modules/dp-shared/dist/task-history-contracts.js.map +1 -1
  20. package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +2 -0
  21. package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/node_modules/dp-shared/src/admin-broadcast.ts +0 -38
  24. package/node_modules/dp-shared/src/audit-contracts.ts +0 -33
  25. package/node_modules/dp-shared/src/configs-contracts.ts +0 -206
  26. package/node_modules/dp-shared/src/db-rows.ts +0 -280
  27. package/node_modules/dp-shared/src/deploy-contracts.ts +0 -38
  28. package/node_modules/dp-shared/src/domain.ts +0 -124
  29. package/node_modules/dp-shared/src/identities.ts +0 -36
  30. package/node_modules/dp-shared/src/index.ts +0 -25
  31. package/node_modules/dp-shared/src/omni-flow-session.ts +0 -80
  32. package/node_modules/dp-shared/src/rest-contracts.ts +0 -409
  33. package/node_modules/dp-shared/src/task-history-contracts.ts +0 -115
  34. package/node_modules/dp-shared/src/worker-detail-contracts.ts +0 -230
  35. package/node_modules/dp-shared/src/ws-protocol.ts +0 -435
@@ -1,115 +0,0 @@
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
- >;
@@ -1,230 +0,0 @@
1
- import { z } from "zod/v4";
2
- import {
3
- ConfigEtag,
4
- ContentHash,
5
- EffectiveWorkerStatus,
6
- EffectiveDirectorStatus,
7
- IanaTimezone,
8
- ProcessStatus,
9
- ProxyProtocol,
10
- RuntimeStatus,
11
- SocialPlatform,
12
- Uuid,
13
- } from "./domain.js";
14
- import { IdentityRow } from "./identities.js";
15
-
16
- /**
17
- * REST contracts for the Web-UI /workers/:id detail surface (wave 1 Agent B).
18
- *
19
- * Split out from rest-contracts.ts to keep the existing wire surface stable
20
- * while the dp-worker detail tabs land; everything here is browser-facing and
21
- * never reaches the dp-worker or dp-director.
22
- */
23
-
24
- /* ============================================================================
25
- * dp-worker create / detail
26
- * ============================================================================ */
27
-
28
- /**
29
- * Body for POST /api/workers. The api_key may be supplied by the caller (64
30
- * lowercase hex chars — 32 crypto-random bytes) or omitted to have the
31
- * server generate one. The column is stored plaintext per v2.13, so the
32
- * operator can read or reset it later from the dp-worker detail surface.
33
- */
34
- export const WorkerCreateRequestSchema = z.object({
35
- name: z.string().min(1).max(120),
36
- director_id: Uuid.optional(),
37
- llm_profile_id: Uuid,
38
- proxy_id: Uuid.optional(),
39
- identity_id: Uuid.nullable().optional(),
40
- /** Pre-generated 64-char hex api_key from the UI. Server generates one if absent. */
41
- api_key: z
42
- .string()
43
- .regex(/^[0-9a-f]{64}$/, "api_key must be 64 lowercase hex chars")
44
- .optional(),
45
- telegram_bot_token: z.string().min(1).optional(),
46
- telegram_allowed_users: z.array(z.number().int()).optional(),
47
- headless: z.boolean().optional(),
48
- });
49
- export type WorkerCreateRequest = z.infer<typeof WorkerCreateRequestSchema>;
50
-
51
- /** The plaintext api_key wire shape returned after create. */
52
- export const WorkerCreateResponseSchema = z.object({
53
- id: Uuid,
54
- name: z.string(),
55
- api_key: z.string().min(1),
56
- config_etag: ConfigEtag,
57
- });
58
- export type WorkerCreateResponse = z.infer<typeof WorkerCreateResponseSchema>;
59
-
60
- const ProxyJoinSchema = z.object({
61
- id: Uuid,
62
- label: z.string(),
63
- protocol: ProxyProtocol,
64
- host: z.string(),
65
- port: z.number().int().positive(),
66
- username: z.string(),
67
- timezone: IanaTimezone,
68
- });
69
-
70
- const LlmProfileJoinSchema = z.object({
71
- id: Uuid,
72
- name: z.string(),
73
- model: z.string(),
74
- });
75
-
76
- const DirectorJoinSchema = z.object({
77
- id: Uuid,
78
- name: z.string(),
79
- host_label: z.string(),
80
- status: EffectiveDirectorStatus,
81
- });
82
-
83
- const SessionHeadSchema = z.object({
84
- id: Uuid,
85
- content_hash: ContentHash,
86
- size_bytes: z.number().int().positive(),
87
- uploaded_at: z.string().datetime(),
88
- uploaded_by: Uuid,
89
- r2_object_key: z.string(),
90
- });
91
-
92
- export const WorkerDetailResponseSchema = z.object({
93
- id: Uuid,
94
- name: z.string(),
95
- director_id: Uuid.optional(),
96
- director: DirectorJoinSchema.optional(),
97
- status: EffectiveWorkerStatus,
98
- process_status: ProcessStatus.optional(),
99
- runtime_status: RuntimeStatus.optional(),
100
- process_observed_at: z.string().datetime().optional(),
101
- runtime_observed_at: z.string().datetime().optional(),
102
- last_heartbeat_at: z.string().datetime().optional(),
103
- effective_status: EffectiveWorkerStatus.optional(),
104
- current_task_id: Uuid.optional(),
105
- config_etag: ConfigEtag,
106
- headless: z.boolean(),
107
- identity_id: Uuid.nullable().optional(),
108
- telegram_bot_token: z.string().nullable(),
109
- telegram_allowed_users: z.array(z.number().int()).optional(),
110
- created_at: z.string().datetime(),
111
- updated_at: z.string().datetime(),
112
- proxy: ProxyJoinSchema.optional(),
113
- llm_profile: LlmProfileJoinSchema,
114
- social_accounts_count: z.number().int().nonnegative(),
115
- scheduled_tasks_count: z.number().int().nonnegative(),
116
- current_session: SessionHeadSchema.optional(),
117
- /**
118
- * Plaintext dp-worker api_key. Surfaced read-only on the detail page so the
119
- * operator can copy it into an dp-director spawn command or re-paste during
120
- * fleet migration. Per v2.13 (internal-use stance,
121
- * feedback_security_simple memory) the key is stored plaintext in
122
- * `dp_workers.api_key`, so re-displaying it carries no
123
- * additional disclosure risk.
124
- */
125
- api_key: z.string().min(1),
126
- /**
127
- * Full identity row when the dp-worker is bound to an identity; null otherwise.
128
- * Populated via LEFT JOIN in getWorkerDetail (M3.T2).
129
- */
130
- identity: IdentityRow.nullable().optional(),
131
- });
132
- export type WorkerDetailResponse = z.infer<typeof WorkerDetailResponseSchema>;
133
-
134
- /* ============================================================================
135
- * Social accounts CRUD
136
- * ============================================================================ */
137
-
138
- /**
139
- * Sub-account model:
140
- * - One row per (identity, platform) — enforced by UNIQUE.
141
- * - UI restricts to platform ∈ {x, youtube, reddit}; the DB enum stays
142
- * wider for backward compat but the API rejects others.
143
- * - login_type='password' carries email + optional username (handle) +
144
- * password; login_type='oauth' carries no secrets (assumed pre-logged-in
145
- * in the Chrome profile).
146
- * - persona_text=null means "inherit from identity.persona_text". The
147
- * bootstrap composer resolves this before handing config to dp-worker.
148
- */
149
- const SubAccountPlatform = z.enum(["x", "youtube", "reddit"]);
150
-
151
- export const SocialAccountBodySchema = z.object({
152
- platform: SubAccountPlatform,
153
- profile_name: z.string().min(1).max(120),
154
- login_type: z.enum(["password", "oauth"]),
155
- username: z.string().min(1).max(120).optional(),
156
- email: z.string().email().optional(),
157
- password: z.string().min(1).optional(),
158
- /** Omit / null → inherit identity persona. */
159
- persona_text: z.string().max(4000).nullable().optional(),
160
- persona_other_json: z.record(z.string(), z.unknown()).optional(),
161
- enabled: z.boolean().default(true),
162
- });
163
- export type SocialAccountBody = z.infer<typeof SocialAccountBodySchema>;
164
-
165
- export const SocialAccountPatchSchema = z
166
- .object({
167
- profile_name: z.string().min(1).max(120).optional(),
168
- login_type: z.enum(["password", "oauth"]).optional(),
169
- username: z.string().min(1).max(120).nullable().optional(),
170
- email: z.string().email().nullable().optional(),
171
- password: z.string().min(1).nullable().optional(),
172
- persona_text: z.string().max(4000).nullable().optional(),
173
- persona_other_json: z.record(z.string(), z.unknown()).nullable().optional(),
174
- enabled: z.boolean().optional(),
175
- })
176
- .refine((v) => Object.keys(v).length > 0, {
177
- message: "patch body must contain at least one field",
178
- });
179
- export type SocialAccountPatch = z.infer<typeof SocialAccountPatchSchema>;
180
-
181
- export const SocialAccountResponseSchema = z.object({
182
- id: Uuid,
183
- identity_id: Uuid,
184
- platform: SocialPlatform,
185
- profile_name: z.string(),
186
- login_type: z.enum(["password", "oauth"]),
187
- username: z.string().nullable(),
188
- email: z.string().nullable(),
189
- password: z.string().nullable(),
190
- persona_text: z.string().nullable(),
191
- persona_other_json: z.record(z.string(), z.unknown()).optional(),
192
- enabled: z.boolean(),
193
- created_at: z.string().datetime(),
194
- updated_at: z.string().datetime(),
195
- });
196
- export type SocialAccountResponse = z.infer<typeof SocialAccountResponseSchema>;
197
-
198
- /* ============================================================================
199
- * Chrome sessions history list
200
- *
201
- * GET /api/workers/:id/sessions returns past chrome_sessions newest-first with
202
- * opaque cursor pagination, mirroring the `task-history.ts` shape. The
203
- * `is_current` flag is true for the single row whose content_hash matches
204
- * `dp_workers.session_content_hash` — the SessionTab uses it to render
205
- * a "current" badge without a second round-trip to /api/workers/:id detail.
206
- *
207
- * Named `ChromeSessionListRow*` to avoid a name collision with the
208
- * existing `ChromeSessionRow` postgres-row schema in `db-rows.ts` — they
209
- * describe different surfaces (DB row vs. browser-facing list row + flag).
210
- * ============================================================================ */
211
-
212
- export const ChromeSessionListRowSchema = z.object({
213
- id: Uuid,
214
- content_hash: ContentHash,
215
- size_bytes: z.number().int().positive(),
216
- uploaded_at: z.string().datetime(),
217
- uploaded_by: Uuid,
218
- r2_object_key: z.string(),
219
- note: z.string().optional(),
220
- is_current: z.boolean(),
221
- });
222
- export type ChromeSessionListRow = z.infer<typeof ChromeSessionListRowSchema>;
223
-
224
- export const ListChromeSessionsResponseSchema = z.object({
225
- items: z.array(ChromeSessionListRowSchema),
226
- next_cursor: z.string().nullable(),
227
- });
228
- export type ListChromeSessionsResponse = z.infer<
229
- typeof ListChromeSessionsResponseSchema
230
- >;