dp-worker 0.1.7 → 0.1.9
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/dist/browser/chrome-process.js +16 -0
- package/dist/browser/chrome-process.js.map +1 -1
- package/dist/browser/cloakbrowser-backend.d.ts +39 -0
- package/dist/browser/cloakbrowser-backend.js +243 -0
- package/dist/browser/cloakbrowser-backend.js.map +1 -0
- package/dist/browser/humanize.d.ts +3 -0
- package/dist/browser/humanize.js +52 -7
- package/dist/browser/humanize.js.map +1 -1
- package/dist/browser/manager.d.ts +39 -0
- package/dist/browser/manager.js +109 -12
- package/dist/browser/manager.js.map +1 -1
- package/dist/chrome-extension/omni-flow/background.js +19 -40
- package/dist/chrome-extension/omni-flow/connect.html +8 -1
- package/dist/chrome-extension/omni-flow/connect.js +13 -0
- package/dist/chrome-extension/omni-flow/content.js +23 -16
- package/dist/chrome-extension/omni-flow/inject.js +32 -73
- package/dist/chrome-extension/omni-flow/manifest.json +1 -1
- package/dist/chrome-extension/omni-flow/popup.css +7 -1
- package/dist/chrome-extension/omni-flow/popup.html +1 -0
- package/dist/chrome-extension/omni-flow/popup.js +13 -0
- package/dist/config/center-config.js +3 -0
- package/dist/config/center-config.js.map +1 -1
- package/dist/config/types.d.ts +5 -0
- package/dist/config/types.js +14 -0
- package/dist/config/types.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/db-rows.d.ts +4 -0
- package/node_modules/dp-shared/dist/db-rows.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/db-rows.js +6 -0
- package/node_modules/dp-shared/dist/db-rows.js.map +1 -1
- package/node_modules/dp-shared/dist/fingerprint.d.ts +14 -0
- package/node_modules/dp-shared/dist/fingerprint.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/fingerprint.js +22 -0
- package/node_modules/dp-shared/dist/fingerprint.js.map +1 -0
- package/node_modules/dp-shared/dist/index.d.ts +1 -0
- package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/index.js +1 -0
- package/node_modules/dp-shared/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/rest-contracts.d.ts +4 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/rest-contracts.js +8 -0
- package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +8 -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 +2 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.js.map +1 -1
- package/node_modules/dp-shared/src/admin-broadcast.ts +38 -0
- package/node_modules/dp-shared/src/audit-contracts.ts +33 -0
- package/node_modules/dp-shared/src/configs-contracts.ts +211 -0
- package/node_modules/dp-shared/src/db-rows.ts +286 -0
- package/node_modules/dp-shared/src/deploy-contracts.ts +38 -0
- package/node_modules/dp-shared/src/domain.ts +124 -0
- package/node_modules/dp-shared/src/fingerprint.ts +21 -0
- package/node_modules/dp-shared/src/identities.ts +38 -0
- package/node_modules/dp-shared/src/index.ts +26 -0
- package/node_modules/dp-shared/src/omni-flow-session.ts +79 -0
- package/node_modules/dp-shared/src/rest-contracts.ts +417 -0
- package/node_modules/dp-shared/src/task-history-contracts.ts +118 -0
- package/node_modules/dp-shared/src/worker-detail-contracts.ts +232 -0
- package/node_modules/dp-shared/src/ws-protocol.ts +435 -0
- package/package.json +8 -2
- package/scripts/install-cloakbrowser.mjs +46 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types shared by the AdminBroadcast Durable Object (server) and the
|
|
3
|
+
* useAdminSocket hook (browser). See
|
|
4
|
+
* docs/superpowers/specs/2026-05-28-live-page-refresh-design.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type AdminTopic =
|
|
8
|
+
| "workers"
|
|
9
|
+
| "directors"
|
|
10
|
+
| "identities"
|
|
11
|
+
| "proxies"
|
|
12
|
+
| "llm_profiles"
|
|
13
|
+
| "groups"
|
|
14
|
+
| "users"
|
|
15
|
+
| "social_accounts"
|
|
16
|
+
| "scheduled_tasks"
|
|
17
|
+
| "adhoc_batches"
|
|
18
|
+
| "task_runs"
|
|
19
|
+
| "audit_log"
|
|
20
|
+
| "worker_chat_messages"
|
|
21
|
+
| "group_chat_messages"
|
|
22
|
+
| "dispatch_settings";
|
|
23
|
+
|
|
24
|
+
export interface Envelope<T = unknown> {
|
|
25
|
+
v: 1;
|
|
26
|
+
topic: AdminTopic;
|
|
27
|
+
op: "inserted" | "updated" | "deleted";
|
|
28
|
+
/** For op:"deleted" this is just `{ id }`. */
|
|
29
|
+
row: T;
|
|
30
|
+
/** ms since epoch, stamped by broadcaster.publish. */
|
|
31
|
+
ts: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Inbound messages the browser sends on the open admin WS. */
|
|
35
|
+
export type AdminClientOp =
|
|
36
|
+
| { op: "subscribe"; topics: AdminTopic[] }
|
|
37
|
+
| { op: "unsubscribe"; topics: AdminTopic[] }
|
|
38
|
+
| { op: "ping" };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { Uuid } from "./domain.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Audit-log read contracts (M8 Agent X).
|
|
6
|
+
*
|
|
7
|
+
* Every mutating handler in dp-center-worker writes one audit_log row via
|
|
8
|
+
* `writeAudit(...)` wrapped in `c.executionCtx.waitUntil`. The UI reads
|
|
9
|
+
* back through `GET /api/audit-log` which paginates newest-first by
|
|
10
|
+
* `(created_at, id) DESC` with an opaque base64url cursor.
|
|
11
|
+
*
|
|
12
|
+
* `actor_email` is JOIN-resolved from `public.users` so the list view can
|
|
13
|
+
* render "alice@example.com did X" without a second lookup. `payload_json`
|
|
14
|
+
* is a small, human-readable hint object — never row data, never secrets.
|
|
15
|
+
*/
|
|
16
|
+
export const AuditLogItemSchema = z.object({
|
|
17
|
+
id: Uuid,
|
|
18
|
+
actor_user_id: Uuid.optional(),
|
|
19
|
+
actor_email: z.string().optional(),
|
|
20
|
+
actor_machine_id: Uuid.optional(),
|
|
21
|
+
action: z.string(),
|
|
22
|
+
target_type: z.string(),
|
|
23
|
+
target_id: z.string(),
|
|
24
|
+
payload_json: z.unknown().nullable(),
|
|
25
|
+
created_at: z.string().datetime(),
|
|
26
|
+
});
|
|
27
|
+
export type AuditLogItem = z.infer<typeof AuditLogItemSchema>;
|
|
28
|
+
|
|
29
|
+
export const AuditLogListResponseSchema = z.object({
|
|
30
|
+
items: z.array(AuditLogItemSchema),
|
|
31
|
+
next_cursor: z.string().optional(),
|
|
32
|
+
});
|
|
33
|
+
export type AuditLogListResponse = z.infer<typeof AuditLogListResponseSchema>;
|
|
@@ -0,0 +1,211 @@
|
|
|
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
|
+
* dp-directors
|
|
149
|
+
* ============================================================================ */
|
|
150
|
+
|
|
151
|
+
export const DirectorListItemSchema = z.object({
|
|
152
|
+
id: z.string().uuid(),
|
|
153
|
+
name: z.string(),
|
|
154
|
+
host_label: z.string(),
|
|
155
|
+
api_key: z.string(),
|
|
156
|
+
status: EffectiveDirectorStatus,
|
|
157
|
+
max_concurrent_tasks: z.number().int().nonnegative().default(0),
|
|
158
|
+
last_heartbeat_at: z.string().datetime().optional(),
|
|
159
|
+
version: z.string().optional(),
|
|
160
|
+
dp_worker_version: z.string().optional(),
|
|
161
|
+
dp_worker_latest_version: z.string().optional(),
|
|
162
|
+
dp_worker_runtime_mode: DpWorkerRuntimeMode.optional(),
|
|
163
|
+
dp_worker_upgrade_status: DpWorkerUpgradeStatus.optional(),
|
|
164
|
+
dp_worker_upgrade_message: z.string().optional(),
|
|
165
|
+
dp_worker_upgrade_started_at: z.string().datetime().optional(),
|
|
166
|
+
dp_worker_upgrade_finished_at: z.string().datetime().optional(),
|
|
167
|
+
created_at: z.string().datetime(),
|
|
168
|
+
updated_at: z.string().datetime(),
|
|
169
|
+
});
|
|
170
|
+
export type DirectorListItem = z.infer<typeof DirectorListItemSchema>;
|
|
171
|
+
|
|
172
|
+
export const DirectorCreateBodySchema = z.object({
|
|
173
|
+
name: z.string().trim().min(1),
|
|
174
|
+
host_label: z.string().trim().min(1),
|
|
175
|
+
api_key: z.string().trim().min(1).optional(),
|
|
176
|
+
max_concurrent_tasks: z.number().int().nonnegative().default(0),
|
|
177
|
+
});
|
|
178
|
+
export type DirectorCreateBody = z.infer<typeof DirectorCreateBodySchema>;
|
|
179
|
+
|
|
180
|
+
export const DirectorPatchSchema = z
|
|
181
|
+
.object({
|
|
182
|
+
name: z.string().trim().min(1).optional(),
|
|
183
|
+
host_label: z.string().trim().min(1).optional(),
|
|
184
|
+
api_key: z.string().trim().min(1).optional(),
|
|
185
|
+
max_concurrent_tasks: z.number().int().nonnegative().optional(),
|
|
186
|
+
})
|
|
187
|
+
.refine((v) => Object.keys(v).length > 0, {
|
|
188
|
+
message: "patch body must contain at least one field",
|
|
189
|
+
});
|
|
190
|
+
export type DirectorPatch = z.infer<typeof DirectorPatchSchema>;
|
|
191
|
+
|
|
192
|
+
/* ============================================================================
|
|
193
|
+
* Dispatch settings
|
|
194
|
+
* ============================================================================ */
|
|
195
|
+
|
|
196
|
+
export const DispatchSettingsSchema = z.object({
|
|
197
|
+
global_max_concurrent_tasks: z.number().int().nonnegative().default(0),
|
|
198
|
+
updated_at: z.string().datetime(),
|
|
199
|
+
});
|
|
200
|
+
export type DispatchSettings = z.infer<typeof DispatchSettingsSchema>;
|
|
201
|
+
|
|
202
|
+
export const DispatchSettingsPatchSchema = z
|
|
203
|
+
.object({
|
|
204
|
+
global_max_concurrent_tasks: z.number().int().nonnegative().optional(),
|
|
205
|
+
})
|
|
206
|
+
.refine((v) => Object.keys(v).length > 0, {
|
|
207
|
+
message: "patch body must contain at least one field",
|
|
208
|
+
});
|
|
209
|
+
export type DispatchSettingsPatch = z.infer<
|
|
210
|
+
typeof DispatchSettingsPatchSchema
|
|
211
|
+
>;
|
|
@@ -0,0 +1,286 @@
|
|
|
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("chrome"),
|
|
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
|
+
/** NULL = inherit identity.persona_text; non-null = own persona. */
|
|
135
|
+
persona_text: z.string().nullable(),
|
|
136
|
+
persona_other_json: z.record(z.string(), z.unknown()).optional(),
|
|
137
|
+
enabled: z.boolean().default(true),
|
|
138
|
+
...Timestamps,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
export const WorkerGroupRow = z.object({
|
|
142
|
+
id: Uuid,
|
|
143
|
+
name: z.string().min(1),
|
|
144
|
+
description: z.string().optional(),
|
|
145
|
+
...Timestamps,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export const WorkerGroupMemberRow = z.object({
|
|
149
|
+
group_id: Uuid,
|
|
150
|
+
worker_id: Uuid,
|
|
151
|
+
added_at: z.string().datetime(),
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export const ChromeSessionRow = z.object({
|
|
155
|
+
id: Uuid,
|
|
156
|
+
identity_id: Uuid,
|
|
157
|
+
r2_object_key: z.string().min(1),
|
|
158
|
+
content_hash: ContentHash,
|
|
159
|
+
size_bytes: z.number().int().positive(),
|
|
160
|
+
uploaded_by: Uuid,
|
|
161
|
+
uploaded_at: z.string().datetime(),
|
|
162
|
+
note: z.string().optional(),
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export const ScheduledTaskRow = z.object({
|
|
166
|
+
id: Uuid,
|
|
167
|
+
worker_id: Uuid,
|
|
168
|
+
name: z.string().min(1),
|
|
169
|
+
cron: z.string().min(1),
|
|
170
|
+
timezone: z.string().optional(),
|
|
171
|
+
prompt: z.string().min(1),
|
|
172
|
+
random_delay_seconds: z.number().int().nonnegative().default(0),
|
|
173
|
+
enabled: z.boolean(),
|
|
174
|
+
last_run_at: z.string().datetime().optional(),
|
|
175
|
+
last_status: z.enum(["ok", "error"]).optional(),
|
|
176
|
+
run_count: z.number().int().nonnegative().default(0),
|
|
177
|
+
success_count: z.number().int().nonnegative().default(0),
|
|
178
|
+
created_by: Uuid.optional(),
|
|
179
|
+
...Timestamps,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
export const TaskRunRow = z.object({
|
|
183
|
+
id: Uuid,
|
|
184
|
+
worker_id: Uuid,
|
|
185
|
+
scheduled_task_id: Uuid.optional(),
|
|
186
|
+
source: TaskSource,
|
|
187
|
+
prompt: z.string().min(1),
|
|
188
|
+
target_descriptor_json: z.record(z.string(), z.unknown()).optional(),
|
|
189
|
+
status: TaskRunStatus,
|
|
190
|
+
dispatched_at: z.string().datetime().optional(),
|
|
191
|
+
started_at: z.string().datetime().optional(),
|
|
192
|
+
finished_at: z.string().datetime().optional(),
|
|
193
|
+
result_summary: z.string().optional(),
|
|
194
|
+
error: z.string().optional(),
|
|
195
|
+
randomized_delay_ms: z.number().int().nonnegative().default(0),
|
|
196
|
+
scheduled_fire_at: z.string().datetime().optional(),
|
|
197
|
+
created_by: Uuid.optional(),
|
|
198
|
+
parent_adhoc_task_id: Uuid.optional(),
|
|
199
|
+
...Timestamps,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
export const AdhocTaskBatchRow = z.object({
|
|
203
|
+
id: Uuid,
|
|
204
|
+
name: z.string().min(1),
|
|
205
|
+
prompt: z.string().min(1),
|
|
206
|
+
target_descriptor_json: z.record(z.string(), z.unknown()),
|
|
207
|
+
random_delay_seconds: z.number().int().nonnegative().default(0),
|
|
208
|
+
dispatch_window_seconds: z.number().int().nonnegative().default(0),
|
|
209
|
+
created_by: Uuid.optional(),
|
|
210
|
+
created_at: z.string().datetime(),
|
|
211
|
+
summary_stats_json: z.record(z.string(), z.unknown()).optional(),
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
export const TaskDispatchQueueRow = z.object({
|
|
215
|
+
id: Uuid,
|
|
216
|
+
worker_id: Uuid,
|
|
217
|
+
task_run_id: Uuid,
|
|
218
|
+
eta: z.string().datetime(),
|
|
219
|
+
priority: z.number().int().default(0),
|
|
220
|
+
attempts: z.number().int().nonnegative().default(0),
|
|
221
|
+
...Timestamps,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
export const ChatRow = z.object({
|
|
225
|
+
id: Uuid,
|
|
226
|
+
scope_type: ChatScopeType,
|
|
227
|
+
scope_id: Uuid,
|
|
228
|
+
last_message_at: z.string().datetime().optional(),
|
|
229
|
+
...Timestamps,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
export const ChatMessageRow = z.object({
|
|
233
|
+
id: Uuid,
|
|
234
|
+
chat_id: Uuid,
|
|
235
|
+
role: z.string().min(1),
|
|
236
|
+
content_json: z.unknown(),
|
|
237
|
+
attachment_ids: z.array(Uuid).default([]),
|
|
238
|
+
task_run_id: Uuid.optional(),
|
|
239
|
+
sender_user_id: Uuid.optional(),
|
|
240
|
+
created_at: z.string().datetime(),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
export const AttachmentRow = z.object({
|
|
244
|
+
id: Uuid,
|
|
245
|
+
chat_id: Uuid.optional(),
|
|
246
|
+
r2_object_key: z.string().min(1),
|
|
247
|
+
filename: z.string().min(1),
|
|
248
|
+
mime: z.string().optional(),
|
|
249
|
+
size: z.number().int().positive(),
|
|
250
|
+
uploaded_by: Uuid,
|
|
251
|
+
created_at: z.string().datetime(),
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
export const AuditLogRow = z.object({
|
|
255
|
+
id: Uuid,
|
|
256
|
+
actor_user_id: Uuid.optional(),
|
|
257
|
+
actor_machine_id: Uuid.optional(),
|
|
258
|
+
action: z.string().min(1),
|
|
259
|
+
target_type: z.string().min(1),
|
|
260
|
+
target_id: z.string().min(1),
|
|
261
|
+
payload_json: z.record(z.string(), z.unknown()).optional(),
|
|
262
|
+
created_at: z.string().datetime(),
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
/* ============================================================================
|
|
266
|
+
* Inferred row types — what DAL functions return.
|
|
267
|
+
* ============================================================================ */
|
|
268
|
+
|
|
269
|
+
export type TenantRow = z.infer<typeof TenantRow>;
|
|
270
|
+
export type UserRow = z.infer<typeof UserRow>;
|
|
271
|
+
export type ProxyRow = z.infer<typeof ProxyRow>;
|
|
272
|
+
export type LlmProfileRow = z.infer<typeof LlmProfileRow>;
|
|
273
|
+
export type DirectorRow = z.infer<typeof DirectorRow>;
|
|
274
|
+
export type WorkerRow = z.infer<typeof WorkerRow>;
|
|
275
|
+
export type SocialAccountRow = z.infer<typeof SocialAccountRow>;
|
|
276
|
+
export type WorkerGroupRow = z.infer<typeof WorkerGroupRow>;
|
|
277
|
+
export type WorkerGroupMemberRow = z.infer<typeof WorkerGroupMemberRow>;
|
|
278
|
+
export type ChromeSessionRow = z.infer<typeof ChromeSessionRow>;
|
|
279
|
+
export type ScheduledTaskRow = z.infer<typeof ScheduledTaskRow>;
|
|
280
|
+
export type TaskRunRow = z.infer<typeof TaskRunRow>;
|
|
281
|
+
export type AdhocTaskBatchRow = z.infer<typeof AdhocTaskBatchRow>;
|
|
282
|
+
export type TaskDispatchQueueRow = z.infer<typeof TaskDispatchQueueRow>;
|
|
283
|
+
export type ChatRow = z.infer<typeof ChatRow>;
|
|
284
|
+
export type ChatMessageRow = z.infer<typeof ChatMessageRow>;
|
|
285
|
+
export type AttachmentRow = z.infer<typeof AttachmentRow>;
|
|
286
|
+
export type AuditLogRow = z.infer<typeof AuditLogRow>;
|
|
@@ -0,0 +1,38 @@
|
|
|
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>;
|