dp-worker 0.1.19 → 0.1.21

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 (92) hide show
  1. package/builtin-skills/x.md +27 -0
  2. package/dist/bird/bird-frontend.d.ts +58 -0
  3. package/dist/bird/bird-frontend.js +110 -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/browser/cloakbrowser-backend.js +10 -27
  21. package/dist/browser/cloakbrowser-backend.js.map +1 -1
  22. package/dist/chrome-extension/omni-flow/manifest.json +1 -1
  23. package/dist/config/center-config.d.ts +8 -0
  24. package/dist/config/center-config.js +1 -0
  25. package/dist/config/center-config.js.map +1 -1
  26. package/dist/index.js +25 -0
  27. package/dist/index.js.map +1 -1
  28. package/node_modules/dp-shared/dist/admin-broadcast.d.ts +1 -1
  29. package/node_modules/dp-shared/dist/admin-broadcast.d.ts.map +1 -1
  30. package/node_modules/dp-shared/dist/bird-contracts.d.ts +487 -0
  31. package/node_modules/dp-shared/dist/bird-contracts.d.ts.map +1 -0
  32. package/node_modules/dp-shared/dist/bird-contracts.js +381 -0
  33. package/node_modules/dp-shared/dist/bird-contracts.js.map +1 -0
  34. package/node_modules/dp-shared/dist/configs-contracts.d.ts +11 -1
  35. package/node_modules/dp-shared/dist/configs-contracts.d.ts.map +1 -1
  36. package/node_modules/dp-shared/dist/configs-contracts.js +43 -0
  37. package/node_modules/dp-shared/dist/configs-contracts.js.map +1 -1
  38. package/node_modules/dp-shared/dist/index.d.ts +2 -0
  39. package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
  40. package/node_modules/dp-shared/dist/index.js +2 -0
  41. package/node_modules/dp-shared/dist/index.js.map +1 -1
  42. package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts +9 -3
  43. package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts.map +1 -1
  44. package/node_modules/dp-shared/dist/post-drafts-contracts.js +34 -0
  45. package/node_modules/dp-shared/dist/post-drafts-contracts.js.map +1 -1
  46. package/node_modules/dp-shared/dist/promo-contracts.d.ts +651 -0
  47. package/node_modules/dp-shared/dist/promo-contracts.d.ts.map +1 -0
  48. package/node_modules/dp-shared/dist/promo-contracts.js +566 -0
  49. package/node_modules/dp-shared/dist/promo-contracts.js.map +1 -0
  50. package/node_modules/dp-shared/dist/rest-contracts.d.ts +73 -0
  51. package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
  52. package/node_modules/dp-shared/dist/rest-contracts.js +70 -0
  53. package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
  54. package/node_modules/dp-shared/dist/smart-money-contracts.d.ts +86 -0
  55. package/node_modules/dp-shared/dist/smart-money-contracts.d.ts.map +1 -0
  56. package/node_modules/dp-shared/dist/smart-money-contracts.js +71 -0
  57. package/node_modules/dp-shared/dist/smart-money-contracts.js.map +1 -0
  58. package/node_modules/dp-shared/dist/task-history-contracts.d.ts +2 -0
  59. package/node_modules/dp-shared/dist/task-history-contracts.d.ts.map +1 -1
  60. package/node_modules/dp-shared/dist/task-history-contracts.js +2 -0
  61. package/node_modules/dp-shared/dist/task-history-contracts.js.map +1 -1
  62. package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +7 -0
  63. package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts.map +1 -1
  64. package/node_modules/dp-shared/dist/worker-detail-contracts.js +9 -0
  65. package/node_modules/dp-shared/dist/worker-detail-contracts.js.map +1 -1
  66. package/node_modules/dp-shared/dist/ws-protocol.d.ts +52 -0
  67. package/node_modules/dp-shared/dist/ws-protocol.d.ts.map +1 -1
  68. package/node_modules/dp-shared/dist/ws-protocol.js +37 -0
  69. package/node_modules/dp-shared/dist/ws-protocol.js.map +1 -1
  70. package/package.json +9 -4
  71. package/scripts/prepack-bundle-shared.mjs +67 -0
  72. package/dist/browser/proxy-relay.d.ts +0 -50
  73. package/dist/browser/proxy-relay.js +0 -50
  74. package/dist/browser/proxy-relay.js.map +0 -1
  75. package/node_modules/dp-shared/src/admin-broadcast.ts +0 -41
  76. package/node_modules/dp-shared/src/audit-contracts.ts +0 -33
  77. package/node_modules/dp-shared/src/auto-post-contracts.ts +0 -206
  78. package/node_modules/dp-shared/src/cloak-contracts.ts +0 -110
  79. package/node_modules/dp-shared/src/configs-contracts.ts +0 -249
  80. package/node_modules/dp-shared/src/db-rows.ts +0 -303
  81. package/node_modules/dp-shared/src/deploy-contracts.ts +0 -38
  82. package/node_modules/dp-shared/src/domain.ts +0 -124
  83. package/node_modules/dp-shared/src/fingerprint.ts +0 -21
  84. package/node_modules/dp-shared/src/identities.ts +0 -38
  85. package/node_modules/dp-shared/src/index.ts +0 -30
  86. package/node_modules/dp-shared/src/omni-flow-cookie.ts +0 -272
  87. package/node_modules/dp-shared/src/omni-flow-session.ts +0 -79
  88. package/node_modules/dp-shared/src/post-drafts-contracts.ts +0 -807
  89. package/node_modules/dp-shared/src/rest-contracts.ts +0 -592
  90. package/node_modules/dp-shared/src/task-history-contracts.ts +0 -124
  91. package/node_modules/dp-shared/src/worker-detail-contracts.ts +0 -236
  92. package/node_modules/dp-shared/src/ws-protocol.ts +0 -495
@@ -1,124 +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
- /** The worker's bound X (Twitter) handle (social_accounts.username, platform='x'). */
45
- x_username: z.string().optional(),
46
- task_name: z.string(),
47
- scheduled_task_id: Uuid.optional(),
48
- parent_adhoc_task_id: Uuid.optional(),
49
- source: TaskSource,
50
- status: TaskRunStatus,
51
- prompt: z.string(),
52
- dispatched_at: z.string().datetime().optional(),
53
- started_at: z.string().datetime().optional(),
54
- finished_at: z.string().datetime().optional(),
55
- result_summary: z.string().optional(),
56
- error: z.string().optional(),
57
- randomized_delay_ms: z.number().int().nonnegative(),
58
- scheduled_fire_at: z.string().datetime().optional(),
59
- created_at: z.string().datetime(),
60
- });
61
- export type TaskRunListItem = z.infer<typeof TaskRunListItemSchema>;
62
-
63
- export const TaskRunHistoryListResponseSchema = z.object({
64
- items: z.array(TaskRunListItemSchema),
65
- next_cursor: z.string().optional(),
66
- });
67
- export type TaskRunHistoryListResponse = z.infer<
68
- typeof TaskRunHistoryListResponseSchema
69
- >;
70
-
71
- /**
72
- * Cross-dp-worker scheduled-task row. Shape differs from the per-dp-worker
73
- * `ScheduledTaskResponseSchema` only in that it carries `worker_name`
74
- * (joined from dp_workers) — handy when listing across dp-workers.
75
- */
76
- export const ScheduledTaskListItemSchema = z.object({
77
- id: Uuid,
78
- worker_id: Uuid,
79
- worker_name: z.string(),
80
- worker_status: z.string().optional(),
81
- /** The worker's bound X (Twitter) handle (social_accounts.username, platform='x'). */
82
- x_username: z.string().optional(),
83
- name: z.string(),
84
- cron: z.string(),
85
- timezone: z.string().optional(),
86
- prompt: z.string(),
87
- random_delay_seconds: z.number().int().nonnegative(),
88
- enabled: z.boolean(),
89
- /** Owning master card (scheduled_task_groups.id); absent for standalone tasks. */
90
- group_task_id: Uuid.optional(),
91
- last_run_at: z.string().datetime().optional(),
92
- last_status: z.enum(["ok", "error"]).optional(),
93
- run_count: z.number().int().nonnegative(),
94
- success_count: z.number().int().nonnegative(),
95
- proxy_timezone: z.string().optional(),
96
- effective_timezone: z.string(),
97
- timezone_source: z.enum(["task", "proxy", "utc"]),
98
- next_fire_at: z.string().datetime().optional(),
99
- health_status: z.enum(["healthy", "failing", "never_run", "disabled"]),
100
- latest_run_id: Uuid.optional(),
101
- latest_run_status: z
102
- .enum([
103
- "queued",
104
- "dispatched",
105
- "running",
106
- "success",
107
- "failed",
108
- "cancelled",
109
- "timeout",
110
- ])
111
- .optional(),
112
- last_error: z.string().optional(),
113
- created_at: z.string().datetime(),
114
- updated_at: z.string().datetime(),
115
- });
116
- export type ScheduledTaskListItem = z.infer<typeof ScheduledTaskListItemSchema>;
117
-
118
- export const ScheduledTaskListResponseSchema = z.object({
119
- items: z.array(ScheduledTaskListItemSchema),
120
- next_cursor: z.string().optional(),
121
- });
122
- export type ScheduledTaskListResponse = z.infer<
123
- typeof ScheduledTaskListResponseSchema
124
- >;
@@ -1,236 +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
- browser_automation_mode: z.enum(["chrome", "cloakbrowser"]).optional(),
49
- });
50
- export type WorkerCreateRequest = z.infer<typeof WorkerCreateRequestSchema>;
51
-
52
- /** The plaintext api_key wire shape returned after create. */
53
- export const WorkerCreateResponseSchema = z.object({
54
- id: Uuid,
55
- name: z.string(),
56
- api_key: z.string().min(1),
57
- config_etag: ConfigEtag,
58
- });
59
- export type WorkerCreateResponse = z.infer<typeof WorkerCreateResponseSchema>;
60
-
61
- const ProxyJoinSchema = z.object({
62
- id: Uuid,
63
- label: z.string(),
64
- protocol: ProxyProtocol,
65
- host: z.string(),
66
- port: z.number().int().positive(),
67
- username: z.string(),
68
- timezone: IanaTimezone,
69
- });
70
-
71
- const LlmProfileJoinSchema = z.object({
72
- id: Uuid,
73
- name: z.string(),
74
- model: z.string(),
75
- });
76
-
77
- const DirectorJoinSchema = z.object({
78
- id: Uuid,
79
- name: z.string(),
80
- host_label: z.string(),
81
- status: EffectiveDirectorStatus,
82
- });
83
-
84
- const SessionHeadSchema = z.object({
85
- id: Uuid,
86
- content_hash: ContentHash,
87
- size_bytes: z.number().int().positive(),
88
- uploaded_at: z.string().datetime(),
89
- uploaded_by: Uuid,
90
- r2_object_key: z.string(),
91
- });
92
-
93
- export const WorkerDetailResponseSchema = z.object({
94
- id: Uuid,
95
- name: z.string(),
96
- director_id: Uuid.optional(),
97
- director: DirectorJoinSchema.optional(),
98
- status: EffectiveWorkerStatus,
99
- process_status: ProcessStatus.optional(),
100
- runtime_status: RuntimeStatus.optional(),
101
- process_observed_at: z.string().datetime().optional(),
102
- runtime_observed_at: z.string().datetime().optional(),
103
- last_heartbeat_at: z.string().datetime().optional(),
104
- effective_status: EffectiveWorkerStatus.optional(),
105
- current_task_id: Uuid.optional(),
106
- config_etag: ConfigEtag,
107
- headless: z.boolean(),
108
- browser_automation_mode: z.enum(["chrome", "cloakbrowser"]).default("cloakbrowser"),
109
- identity_id: Uuid.nullable().optional(),
110
- telegram_bot_token: z.string().nullable(),
111
- telegram_allowed_users: z.array(z.number().int()).optional(),
112
- created_at: z.string().datetime(),
113
- updated_at: z.string().datetime(),
114
- proxy: ProxyJoinSchema.optional(),
115
- llm_profile: LlmProfileJoinSchema,
116
- social_accounts_count: z.number().int().nonnegative(),
117
- scheduled_tasks_count: z.number().int().nonnegative(),
118
- current_session: SessionHeadSchema.optional(),
119
- /**
120
- * Plaintext dp-worker api_key. Surfaced read-only on the detail page so the
121
- * operator can copy it into an dp-director spawn command or re-paste during
122
- * fleet migration. Per v2.13 (internal-use stance,
123
- * feedback_security_simple memory) the key is stored plaintext in
124
- * `dp_workers.api_key`, so re-displaying it carries no
125
- * additional disclosure risk.
126
- */
127
- api_key: z.string().min(1),
128
- /**
129
- * Full identity row when the dp-worker is bound to an identity; null otherwise.
130
- * Populated via LEFT JOIN in getWorkerDetail (M3.T2).
131
- */
132
- identity: IdentityRow.nullable().optional(),
133
- });
134
- export type WorkerDetailResponse = z.infer<typeof WorkerDetailResponseSchema>;
135
-
136
- /* ============================================================================
137
- * Social accounts CRUD
138
- * ============================================================================ */
139
-
140
- /**
141
- * Sub-account model:
142
- * - One row per (identity, platform) — enforced by UNIQUE.
143
- * - UI restricts to platform ∈ {x, youtube, reddit}; the DB enum stays
144
- * wider for backward compat but the API rejects others.
145
- * - login_type='password' carries email + optional username (handle) +
146
- * password; login_type='oauth' carries no secrets (assumed pre-logged-in
147
- * in the Chrome profile).
148
- * - persona_text=null means "inherit from identity.persona_text". The
149
- * bootstrap composer resolves this before handing config to dp-worker.
150
- */
151
- const SubAccountPlatform = z.enum(["x", "youtube", "reddit"]);
152
-
153
- export const SocialAccountBodySchema = z.object({
154
- platform: SubAccountPlatform,
155
- profile_name: z.string().min(1).max(120),
156
- login_type: z.enum(["password", "oauth"]),
157
- username: z.string().min(1).max(120).optional(),
158
- email: z.string().email().optional(),
159
- password: z.string().min(1).optional(),
160
- /** 2FA/TOTP secret or backup codes — record-only, never used for login. */
161
- totp_secret: z.string().max(2000).nullable().optional(),
162
- /** Omit / null → inherit identity persona. */
163
- persona_text: z.string().max(4000).nullable().optional(),
164
- persona_other_json: z.record(z.string(), z.unknown()).optional(),
165
- enabled: z.boolean().default(true),
166
- });
167
- export type SocialAccountBody = z.infer<typeof SocialAccountBodySchema>;
168
-
169
- export const SocialAccountPatchSchema = z
170
- .object({
171
- profile_name: z.string().min(1).max(120).optional(),
172
- login_type: z.enum(["password", "oauth"]).optional(),
173
- username: z.string().min(1).max(120).nullable().optional(),
174
- email: z.string().email().nullable().optional(),
175
- password: z.string().min(1).nullable().optional(),
176
- totp_secret: z.string().max(2000).nullable().optional(),
177
- persona_text: z.string().max(4000).nullable().optional(),
178
- persona_other_json: z.record(z.string(), z.unknown()).nullable().optional(),
179
- enabled: z.boolean().optional(),
180
- })
181
- .refine((v) => Object.keys(v).length > 0, {
182
- message: "patch body must contain at least one field",
183
- });
184
- export type SocialAccountPatch = z.infer<typeof SocialAccountPatchSchema>;
185
-
186
- export const SocialAccountResponseSchema = z.object({
187
- id: Uuid,
188
- identity_id: Uuid,
189
- platform: SocialPlatform,
190
- profile_name: z.string(),
191
- login_type: z.enum(["password", "oauth"]),
192
- username: z.string().nullable(),
193
- email: z.string().nullable(),
194
- password: z.string().nullable(),
195
- totp_secret: z.string().nullable(),
196
- persona_text: z.string().nullable(),
197
- persona_other_json: z.record(z.string(), z.unknown()).optional(),
198
- enabled: z.boolean(),
199
- created_at: z.string().datetime(),
200
- updated_at: z.string().datetime(),
201
- });
202
- export type SocialAccountResponse = z.infer<typeof SocialAccountResponseSchema>;
203
-
204
- /* ============================================================================
205
- * Chrome sessions history list
206
- *
207
- * GET /api/workers/:id/sessions returns past chrome_sessions newest-first with
208
- * opaque cursor pagination, mirroring the `task-history.ts` shape. The
209
- * `is_current` flag is true for the single row whose content_hash matches
210
- * `dp_workers.session_content_hash` — the SessionTab uses it to render
211
- * a "current" badge without a second round-trip to /api/workers/:id detail.
212
- *
213
- * Named `ChromeSessionListRow*` to avoid a name collision with the
214
- * existing `ChromeSessionRow` postgres-row schema in `db-rows.ts` — they
215
- * describe different surfaces (DB row vs. browser-facing list row + flag).
216
- * ============================================================================ */
217
-
218
- export const ChromeSessionListRowSchema = z.object({
219
- id: Uuid,
220
- content_hash: ContentHash,
221
- size_bytes: z.number().int().positive(),
222
- uploaded_at: z.string().datetime(),
223
- uploaded_by: Uuid,
224
- r2_object_key: z.string(),
225
- note: z.string().optional(),
226
- is_current: z.boolean(),
227
- });
228
- export type ChromeSessionListRow = z.infer<typeof ChromeSessionListRowSchema>;
229
-
230
- export const ListChromeSessionsResponseSchema = z.object({
231
- items: z.array(ChromeSessionListRowSchema),
232
- next_cursor: z.string().nullable(),
233
- });
234
- export type ListChromeSessionsResponse = z.infer<
235
- typeof ListChromeSessionsResponseSchema
236
- >;