dp-worker 0.1.4 → 0.1.6
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 +58 -7
- package/dist/browser/chrome-process.js.map +1 -1
- package/dist/chrome-extension/omni-flow/background.js +24 -6
- package/node_modules/dp-shared/dist/configs-contracts.d.ts +5 -0
- package/node_modules/dp-shared/dist/configs-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/configs-contracts.js +5 -0
- package/node_modules/dp-shared/dist/configs-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/db-rows.d.ts +1 -1
- package/node_modules/dp-shared/dist/db-rows.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/db-rows.js +1 -1
- package/node_modules/dp-shared/dist/db-rows.js.map +1 -1
- package/node_modules/dp-shared/dist/identities.d.ts +2 -0
- package/node_modules/dp-shared/dist/identities.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/identities.js +2 -0
- package/node_modules/dp-shared/dist/identities.js.map +1 -1
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts +6 -0
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/task-history-contracts.js +3 -0
- package/node_modules/dp-shared/dist/task-history-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +2 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts.map +1 -1
- package/package.json +1 -1
- package/node_modules/dp-shared/src/admin-broadcast.ts +0 -38
- package/node_modules/dp-shared/src/audit-contracts.ts +0 -33
- package/node_modules/dp-shared/src/configs-contracts.ts +0 -206
- package/node_modules/dp-shared/src/db-rows.ts +0 -280
- package/node_modules/dp-shared/src/deploy-contracts.ts +0 -38
- package/node_modules/dp-shared/src/domain.ts +0 -124
- package/node_modules/dp-shared/src/identities.ts +0 -36
- package/node_modules/dp-shared/src/index.ts +0 -25
- package/node_modules/dp-shared/src/omni-flow-session.ts +0 -80
- package/node_modules/dp-shared/src/rest-contracts.ts +0 -409
- package/node_modules/dp-shared/src/task-history-contracts.ts +0 -115
- package/node_modules/dp-shared/src/worker-detail-contracts.ts +0 -230
- package/node_modules/dp-shared/src/ws-protocol.ts +0 -435
|
@@ -1,206 +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
|
-
/** How many identities currently have this proxy bound. */
|
|
129
|
-
bound_identity_count: z.number().int().nonnegative().default(0),
|
|
130
|
-
created_at: z.string().datetime(),
|
|
131
|
-
updated_at: z.string().datetime(),
|
|
132
|
-
});
|
|
133
|
-
export type ProxyListItem = z.infer<typeof ProxyListItemSchema>;
|
|
134
|
-
|
|
135
|
-
export const ProxyTestResultSchema = z.object({
|
|
136
|
-
ok: z.boolean(),
|
|
137
|
-
latency_ms: z.number().int().nonnegative(),
|
|
138
|
-
detail: z.string(),
|
|
139
|
-
});
|
|
140
|
-
export type ProxyTestResult = z.infer<typeof ProxyTestResultSchema>;
|
|
141
|
-
|
|
142
|
-
/* ============================================================================
|
|
143
|
-
* dp-directors
|
|
144
|
-
* ============================================================================ */
|
|
145
|
-
|
|
146
|
-
export const DirectorListItemSchema = z.object({
|
|
147
|
-
id: z.string().uuid(),
|
|
148
|
-
name: z.string(),
|
|
149
|
-
host_label: z.string(),
|
|
150
|
-
api_key: z.string(),
|
|
151
|
-
status: EffectiveDirectorStatus,
|
|
152
|
-
max_concurrent_tasks: z.number().int().nonnegative().default(0),
|
|
153
|
-
last_heartbeat_at: z.string().datetime().optional(),
|
|
154
|
-
version: z.string().optional(),
|
|
155
|
-
dp_worker_version: z.string().optional(),
|
|
156
|
-
dp_worker_latest_version: z.string().optional(),
|
|
157
|
-
dp_worker_runtime_mode: DpWorkerRuntimeMode.optional(),
|
|
158
|
-
dp_worker_upgrade_status: DpWorkerUpgradeStatus.optional(),
|
|
159
|
-
dp_worker_upgrade_message: z.string().optional(),
|
|
160
|
-
dp_worker_upgrade_started_at: z.string().datetime().optional(),
|
|
161
|
-
dp_worker_upgrade_finished_at: z.string().datetime().optional(),
|
|
162
|
-
created_at: z.string().datetime(),
|
|
163
|
-
updated_at: z.string().datetime(),
|
|
164
|
-
});
|
|
165
|
-
export type DirectorListItem = z.infer<typeof DirectorListItemSchema>;
|
|
166
|
-
|
|
167
|
-
export const DirectorCreateBodySchema = z.object({
|
|
168
|
-
name: z.string().trim().min(1),
|
|
169
|
-
host_label: z.string().trim().min(1),
|
|
170
|
-
api_key: z.string().trim().min(1).optional(),
|
|
171
|
-
max_concurrent_tasks: z.number().int().nonnegative().default(0),
|
|
172
|
-
});
|
|
173
|
-
export type DirectorCreateBody = z.infer<typeof DirectorCreateBodySchema>;
|
|
174
|
-
|
|
175
|
-
export const DirectorPatchSchema = z
|
|
176
|
-
.object({
|
|
177
|
-
name: z.string().trim().min(1).optional(),
|
|
178
|
-
host_label: z.string().trim().min(1).optional(),
|
|
179
|
-
api_key: z.string().trim().min(1).optional(),
|
|
180
|
-
max_concurrent_tasks: z.number().int().nonnegative().optional(),
|
|
181
|
-
})
|
|
182
|
-
.refine((v) => Object.keys(v).length > 0, {
|
|
183
|
-
message: "patch body must contain at least one field",
|
|
184
|
-
});
|
|
185
|
-
export type DirectorPatch = z.infer<typeof DirectorPatchSchema>;
|
|
186
|
-
|
|
187
|
-
/* ============================================================================
|
|
188
|
-
* Dispatch settings
|
|
189
|
-
* ============================================================================ */
|
|
190
|
-
|
|
191
|
-
export const DispatchSettingsSchema = z.object({
|
|
192
|
-
global_max_concurrent_tasks: z.number().int().nonnegative().default(0),
|
|
193
|
-
updated_at: z.string().datetime(),
|
|
194
|
-
});
|
|
195
|
-
export type DispatchSettings = z.infer<typeof DispatchSettingsSchema>;
|
|
196
|
-
|
|
197
|
-
export const DispatchSettingsPatchSchema = z
|
|
198
|
-
.object({
|
|
199
|
-
global_max_concurrent_tasks: z.number().int().nonnegative().optional(),
|
|
200
|
-
})
|
|
201
|
-
.refine((v) => Object.keys(v).length > 0, {
|
|
202
|
-
message: "patch body must contain at least one field",
|
|
203
|
-
});
|
|
204
|
-
export type DispatchSettingsPatch = z.infer<
|
|
205
|
-
typeof DispatchSettingsPatchSchema
|
|
206
|
-
>;
|
|
@@ -1,280 +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
|
-
in_use_by_worker_id: Uuid.optional(),
|
|
60
|
-
...Timestamps,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
export const LlmProfileRow = z.object({
|
|
64
|
-
id: Uuid,
|
|
65
|
-
name: z.string().min(1),
|
|
66
|
-
protocol: LlmProtocol,
|
|
67
|
-
base_url: z.string().min(1),
|
|
68
|
-
api_key: z.string().min(1),
|
|
69
|
-
model: z.string().min(1),
|
|
70
|
-
image_model: z.string().optional(),
|
|
71
|
-
image_api_key: z.string().optional(),
|
|
72
|
-
image_size: z.string().optional(),
|
|
73
|
-
...Timestamps,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
export const DirectorRow = z.object({
|
|
77
|
-
id: Uuid,
|
|
78
|
-
name: z.string().min(1),
|
|
79
|
-
api_key: z.string().min(1),
|
|
80
|
-
host_label: z.string().min(1),
|
|
81
|
-
max_concurrent_tasks: z.number().int().nonnegative().default(0),
|
|
82
|
-
last_heartbeat_at: z.string().datetime().optional(),
|
|
83
|
-
version: z.string().optional(),
|
|
84
|
-
dp_worker_version: z.string().optional(),
|
|
85
|
-
dp_worker_latest_version: z.string().optional(),
|
|
86
|
-
dp_worker_runtime_mode: DpWorkerRuntimeMode.optional(),
|
|
87
|
-
dp_worker_upgrade_status: DpWorkerUpgradeStatus.optional(),
|
|
88
|
-
dp_worker_upgrade_message: z.string().optional(),
|
|
89
|
-
dp_worker_upgrade_started_at: z.string().datetime().optional(),
|
|
90
|
-
dp_worker_upgrade_finished_at: z.string().datetime().optional(),
|
|
91
|
-
...Timestamps,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
export const WorkerRow = z.object({
|
|
95
|
-
id: Uuid,
|
|
96
|
-
name: z.string().min(1),
|
|
97
|
-
director_id: Uuid.optional(),
|
|
98
|
-
api_key: z.string().min(1),
|
|
99
|
-
llm_profile_id: Uuid,
|
|
100
|
-
proxy_id: Uuid.optional(),
|
|
101
|
-
/**
|
|
102
|
-
* Per-dp-worker Chrome headless flag (M6). Defaults to false at the schema
|
|
103
|
-
* level; operators flip it via Web UI.
|
|
104
|
-
*/
|
|
105
|
-
headless: z.boolean().default(false),
|
|
106
|
-
identity_id: Uuid.nullable().optional(),
|
|
107
|
-
process_status: ProcessStatus,
|
|
108
|
-
process_observed_at: z.string().datetime().optional(),
|
|
109
|
-
runtime_status: RuntimeStatus,
|
|
110
|
-
runtime_observed_at: z.string().datetime().optional(),
|
|
111
|
-
last_heartbeat_at: z.string().datetime().optional(),
|
|
112
|
-
current_task_id: Uuid.optional(),
|
|
113
|
-
config_etag: ConfigEtag,
|
|
114
|
-
session_content_hash: ContentHash.optional(),
|
|
115
|
-
telegram_bot_token: z.string().optional(),
|
|
116
|
-
telegram_allowed_users: z.array(z.number().int()).optional(),
|
|
117
|
-
...Timestamps,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
export const SocialAccountRow = z.object({
|
|
121
|
-
id: Uuid,
|
|
122
|
-
identity_id: Uuid,
|
|
123
|
-
platform: SocialPlatform,
|
|
124
|
-
profile_name: z.string().default(""),
|
|
125
|
-
login_type: z.enum(["password", "oauth"]).default("password"),
|
|
126
|
-
username: z.string().nullable(),
|
|
127
|
-
email: z.string().nullable(),
|
|
128
|
-
password: z.string().nullable(),
|
|
129
|
-
/** NULL = inherit identity.persona_text; non-null = own persona. */
|
|
130
|
-
persona_text: z.string().nullable(),
|
|
131
|
-
persona_other_json: z.record(z.string(), z.unknown()).optional(),
|
|
132
|
-
enabled: z.boolean().default(true),
|
|
133
|
-
...Timestamps,
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
export const WorkerGroupRow = z.object({
|
|
137
|
-
id: Uuid,
|
|
138
|
-
name: z.string().min(1),
|
|
139
|
-
description: z.string().optional(),
|
|
140
|
-
...Timestamps,
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
export const WorkerGroupMemberRow = z.object({
|
|
144
|
-
group_id: Uuid,
|
|
145
|
-
worker_id: Uuid,
|
|
146
|
-
added_at: z.string().datetime(),
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
export const ChromeSessionRow = z.object({
|
|
150
|
-
id: Uuid,
|
|
151
|
-
identity_id: Uuid,
|
|
152
|
-
r2_object_key: z.string().min(1),
|
|
153
|
-
content_hash: ContentHash,
|
|
154
|
-
size_bytes: z.number().int().positive(),
|
|
155
|
-
uploaded_by: Uuid,
|
|
156
|
-
uploaded_at: z.string().datetime(),
|
|
157
|
-
note: z.string().optional(),
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
export const ScheduledTaskRow = z.object({
|
|
161
|
-
id: Uuid,
|
|
162
|
-
worker_id: Uuid,
|
|
163
|
-
name: z.string().min(1),
|
|
164
|
-
cron: z.string().min(1),
|
|
165
|
-
timezone: z.string().optional(),
|
|
166
|
-
prompt: z.string().min(1),
|
|
167
|
-
random_delay_seconds: z.number().int().nonnegative().default(0),
|
|
168
|
-
enabled: z.boolean(),
|
|
169
|
-
last_run_at: z.string().datetime().optional(),
|
|
170
|
-
last_status: z.enum(["ok", "error"]).optional(),
|
|
171
|
-
run_count: z.number().int().nonnegative().default(0),
|
|
172
|
-
success_count: z.number().int().nonnegative().default(0),
|
|
173
|
-
created_by: Uuid.optional(),
|
|
174
|
-
...Timestamps,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
export const TaskRunRow = z.object({
|
|
178
|
-
id: Uuid,
|
|
179
|
-
worker_id: Uuid,
|
|
180
|
-
scheduled_task_id: Uuid.optional(),
|
|
181
|
-
source: TaskSource,
|
|
182
|
-
prompt: z.string().min(1),
|
|
183
|
-
target_descriptor_json: z.record(z.string(), z.unknown()).optional(),
|
|
184
|
-
status: TaskRunStatus,
|
|
185
|
-
dispatched_at: z.string().datetime().optional(),
|
|
186
|
-
started_at: z.string().datetime().optional(),
|
|
187
|
-
finished_at: z.string().datetime().optional(),
|
|
188
|
-
result_summary: z.string().optional(),
|
|
189
|
-
error: z.string().optional(),
|
|
190
|
-
randomized_delay_ms: z.number().int().nonnegative().default(0),
|
|
191
|
-
created_by: Uuid.optional(),
|
|
192
|
-
parent_adhoc_task_id: Uuid.optional(),
|
|
193
|
-
...Timestamps,
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
export const AdhocTaskBatchRow = z.object({
|
|
197
|
-
id: Uuid,
|
|
198
|
-
name: z.string().min(1),
|
|
199
|
-
prompt: z.string().min(1),
|
|
200
|
-
target_descriptor_json: z.record(z.string(), z.unknown()),
|
|
201
|
-
random_delay_seconds: z.number().int().nonnegative().default(0),
|
|
202
|
-
dispatch_window_seconds: z.number().int().nonnegative().default(0),
|
|
203
|
-
created_by: Uuid.optional(),
|
|
204
|
-
created_at: z.string().datetime(),
|
|
205
|
-
summary_stats_json: z.record(z.string(), z.unknown()).optional(),
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
export const TaskDispatchQueueRow = z.object({
|
|
209
|
-
id: Uuid,
|
|
210
|
-
worker_id: Uuid,
|
|
211
|
-
task_run_id: Uuid,
|
|
212
|
-
eta: z.string().datetime(),
|
|
213
|
-
priority: z.number().int().default(0),
|
|
214
|
-
attempts: z.number().int().nonnegative().default(0),
|
|
215
|
-
...Timestamps,
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
export const ChatRow = z.object({
|
|
219
|
-
id: Uuid,
|
|
220
|
-
scope_type: ChatScopeType,
|
|
221
|
-
scope_id: Uuid,
|
|
222
|
-
last_message_at: z.string().datetime().optional(),
|
|
223
|
-
...Timestamps,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
export const ChatMessageRow = z.object({
|
|
227
|
-
id: Uuid,
|
|
228
|
-
chat_id: Uuid,
|
|
229
|
-
role: z.string().min(1),
|
|
230
|
-
content_json: z.unknown(),
|
|
231
|
-
attachment_ids: z.array(Uuid).default([]),
|
|
232
|
-
task_run_id: Uuid.optional(),
|
|
233
|
-
sender_user_id: Uuid.optional(),
|
|
234
|
-
created_at: z.string().datetime(),
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
export const AttachmentRow = z.object({
|
|
238
|
-
id: Uuid,
|
|
239
|
-
chat_id: Uuid.optional(),
|
|
240
|
-
r2_object_key: z.string().min(1),
|
|
241
|
-
filename: z.string().min(1),
|
|
242
|
-
mime: z.string().optional(),
|
|
243
|
-
size: z.number().int().positive(),
|
|
244
|
-
uploaded_by: Uuid,
|
|
245
|
-
created_at: z.string().datetime(),
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
export const AuditLogRow = z.object({
|
|
249
|
-
id: Uuid,
|
|
250
|
-
actor_user_id: Uuid.optional(),
|
|
251
|
-
actor_machine_id: Uuid.optional(),
|
|
252
|
-
action: z.string().min(1),
|
|
253
|
-
target_type: z.string().min(1),
|
|
254
|
-
target_id: z.string().min(1),
|
|
255
|
-
payload_json: z.record(z.string(), z.unknown()).optional(),
|
|
256
|
-
created_at: z.string().datetime(),
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
/* ============================================================================
|
|
260
|
-
* Inferred row types — what DAL functions return.
|
|
261
|
-
* ============================================================================ */
|
|
262
|
-
|
|
263
|
-
export type TenantRow = z.infer<typeof TenantRow>;
|
|
264
|
-
export type UserRow = z.infer<typeof UserRow>;
|
|
265
|
-
export type ProxyRow = z.infer<typeof ProxyRow>;
|
|
266
|
-
export type LlmProfileRow = z.infer<typeof LlmProfileRow>;
|
|
267
|
-
export type DirectorRow = z.infer<typeof DirectorRow>;
|
|
268
|
-
export type WorkerRow = z.infer<typeof WorkerRow>;
|
|
269
|
-
export type SocialAccountRow = z.infer<typeof SocialAccountRow>;
|
|
270
|
-
export type WorkerGroupRow = z.infer<typeof WorkerGroupRow>;
|
|
271
|
-
export type WorkerGroupMemberRow = z.infer<typeof WorkerGroupMemberRow>;
|
|
272
|
-
export type ChromeSessionRow = z.infer<typeof ChromeSessionRow>;
|
|
273
|
-
export type ScheduledTaskRow = z.infer<typeof ScheduledTaskRow>;
|
|
274
|
-
export type TaskRunRow = z.infer<typeof TaskRunRow>;
|
|
275
|
-
export type AdhocTaskBatchRow = z.infer<typeof AdhocTaskBatchRow>;
|
|
276
|
-
export type TaskDispatchQueueRow = z.infer<typeof TaskDispatchQueueRow>;
|
|
277
|
-
export type ChatRow = z.infer<typeof ChatRow>;
|
|
278
|
-
export type ChatMessageRow = z.infer<typeof ChatMessageRow>;
|
|
279
|
-
export type AttachmentRow = z.infer<typeof AttachmentRow>;
|
|
280
|
-
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>;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Cross-tier primitives — identity, status enums, opaque IDs.
|
|
5
|
-
*
|
|
6
|
-
* Anything that appears in WS messages, REST bodies, AND DB rows lives here so
|
|
7
|
-
* the three contract files don't drift from each other.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export const Uuid = z.string().uuid();
|
|
11
|
-
export type Uuid = z.infer<typeof Uuid>;
|
|
12
|
-
|
|
13
|
-
/** Short opaque ID like the existing src/agent/scheduler.ts uses (8 hex chars). */
|
|
14
|
-
export const ShortId = z.string().regex(/^[a-z0-9-]{6,32}$/);
|
|
15
|
-
export type ShortId = z.infer<typeof ShortId>;
|
|
16
|
-
|
|
17
|
-
/** Identifier used by Agent.registerFrontend in dp-worker (see §dp-worker-A in architecture.md). */
|
|
18
|
-
export const FrontendId = z.enum(["telegram", "center", "tui", "legacy"]);
|
|
19
|
-
export type FrontendId = z.infer<typeof FrontendId>;
|
|
20
|
-
|
|
21
|
-
export const LlmProtocol = z.enum(["openai", "claude"]);
|
|
22
|
-
export type LlmProtocol = z.infer<typeof LlmProtocol>;
|
|
23
|
-
|
|
24
|
-
export const ProxyProtocol = z.enum(["socks5", "socks4", "http", "https"]);
|
|
25
|
-
export type ProxyProtocol = z.infer<typeof ProxyProtocol>;
|
|
26
|
-
|
|
27
|
-
export const SocialPlatform = z.enum(["x", "youtube", "reddit", "instagram", "tiktok"]);
|
|
28
|
-
export type SocialPlatform = z.infer<typeof SocialPlatform>;
|
|
29
|
-
|
|
30
|
-
/** Process-axis status — written exclusively by dp-director (via PM events / heartbeat). */
|
|
31
|
-
export const ProcessStatus = z.enum(["running", "stopped", "crashed", "unknown"]);
|
|
32
|
-
export type ProcessStatus = z.infer<typeof ProcessStatus>;
|
|
33
|
-
|
|
34
|
-
/** Runtime/business-axis status — written exclusively by dp-worker (status_change). */
|
|
35
|
-
export const RuntimeStatus = z.enum(["idle", "busy", "error", "unknown"]);
|
|
36
|
-
export type RuntimeStatus = z.infer<typeof RuntimeStatus>;
|
|
37
|
-
|
|
38
|
-
/** Read-time derived status surfaced by the API; never stored. */
|
|
39
|
-
export const EffectiveWorkerStatus = z.enum([
|
|
40
|
-
"offline", "crashed", "error", "busy", "idle", "unknown",
|
|
41
|
-
]);
|
|
42
|
-
export type EffectiveWorkerStatus = z.infer<typeof EffectiveWorkerStatus>;
|
|
43
|
-
|
|
44
|
-
export const EffectiveDirectorStatus = z.enum(["online", "offline"]);
|
|
45
|
-
export type EffectiveDirectorStatus = z.infer<typeof EffectiveDirectorStatus>;
|
|
46
|
-
|
|
47
|
-
export const DpWorkerRuntimeMode = z.enum(["npm", "dev-dist"]);
|
|
48
|
-
export type DpWorkerRuntimeMode = z.infer<typeof DpWorkerRuntimeMode>;
|
|
49
|
-
|
|
50
|
-
export const DpWorkerUpgradeStatus = z.enum([
|
|
51
|
-
"idle",
|
|
52
|
-
"checking",
|
|
53
|
-
"installing",
|
|
54
|
-
"building",
|
|
55
|
-
"restarting",
|
|
56
|
-
"success",
|
|
57
|
-
"skipped",
|
|
58
|
-
"failed",
|
|
59
|
-
]);
|
|
60
|
-
export type DpWorkerUpgradeStatus = z.infer<typeof DpWorkerUpgradeStatus>;
|
|
61
|
-
|
|
62
|
-
export const TaskSource = z.enum(["scheduled", "ad_hoc", "chat_replay"]);
|
|
63
|
-
export type TaskSource = z.infer<typeof TaskSource>;
|
|
64
|
-
|
|
65
|
-
export const TaskRunStatus = z.enum([
|
|
66
|
-
"queued",
|
|
67
|
-
"dispatched",
|
|
68
|
-
"running",
|
|
69
|
-
"success",
|
|
70
|
-
"failed",
|
|
71
|
-
"cancelled",
|
|
72
|
-
"timeout",
|
|
73
|
-
]);
|
|
74
|
-
export type TaskRunStatus = z.infer<typeof TaskRunStatus>;
|
|
75
|
-
|
|
76
|
-
export const UserRole = z.enum(["admin", "operator", "viewer"]);
|
|
77
|
-
export type UserRole = z.infer<typeof UserRole>;
|
|
78
|
-
|
|
79
|
-
export const ChatScopeType = z.enum(["worker", "group"]);
|
|
80
|
-
export type ChatScopeType = z.infer<typeof ChatScopeType>;
|
|
81
|
-
|
|
82
|
-
export const ChatMessageRole = z.enum(["user", "assistant", "system", "tool"]);
|
|
83
|
-
export type ChatMessageRole = z.infer<typeof ChatMessageRole>;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Opaque etag — dp-worker caches the latest etag locally; center bumps it whenever any
|
|
87
|
-
* field a dp-worker would care about changes. dp-worker compares against its cached value
|
|
88
|
-
* to decide whether to re-bootstrap.
|
|
89
|
-
*/
|
|
90
|
-
export const ConfigEtag = z.string().min(1);
|
|
91
|
-
export type ConfigEtag = z.infer<typeof ConfigEtag>;
|
|
92
|
-
|
|
93
|
-
/** Hex-encoded SHA-256 of the canonical session artifact; 64 chars. */
|
|
94
|
-
export const ContentHash = z.string().regex(/^[a-f0-9]{64}$/);
|
|
95
|
-
export type ContentHash = z.infer<typeof ContentHash>;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* An IANA-zone name string (e.g. "America/New_York", "Asia/Tokyo", "UTC").
|
|
99
|
-
* Validated via the runtime `Intl.DateTimeFormat` constructor, which is
|
|
100
|
-
* available in every target runtime: Node, browsers, and Cloudflare Workers
|
|
101
|
-
* (V8 isolate). Invalid zone names throw RangeError on construction.
|
|
102
|
-
*
|
|
103
|
-
* Proxies carry one of these; a dp-worker bound to a proxy uses it as the
|
|
104
|
-
* default cron timezone, while Chrome timezone spoofing is handled inside
|
|
105
|
-
* the OmniFlow extension session imported into that browser profile.
|
|
106
|
-
*/
|
|
107
|
-
export const IanaTimezone = z
|
|
108
|
-
.string()
|
|
109
|
-
.min(1)
|
|
110
|
-
.refine(
|
|
111
|
-
(tz) => {
|
|
112
|
-
try {
|
|
113
|
-
new Intl.DateTimeFormat(undefined, { timeZone: tz });
|
|
114
|
-
return true;
|
|
115
|
-
} catch {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
message:
|
|
121
|
-
"must be a valid IANA timezone name (e.g. 'America/New_York', 'Asia/Tokyo', 'UTC')",
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
export type IanaTimezone = z.infer<typeof IanaTimezone>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
import { Uuid } from "./domain.js";
|
|
3
|
-
import { OmniFlowSessionSummarySchema } from "./omni-flow-session.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Identity == a Chrome persona owned by the org. Holds the primary
|
|
7
|
-
* email/password the dp-worker uses for Gmail / Google flows, plus an
|
|
8
|
-
* optional egress proxy. Per-platform sub-accounts (X / YouTube / Reddit)
|
|
9
|
-
* live in the `social_accounts` table and inherit `persona_text` by default.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export const IdentityRow = z.object({
|
|
13
|
-
id: Uuid,
|
|
14
|
-
name: z.string(),
|
|
15
|
-
email: z.string().email(),
|
|
16
|
-
password: z.string().nullable(),
|
|
17
|
-
proxy_id: Uuid.nullable(),
|
|
18
|
-
persona_text: z.string(),
|
|
19
|
-
created_at: z.string().datetime(),
|
|
20
|
-
updated_at: z.string().datetime(),
|
|
21
|
-
});
|
|
22
|
-
export type IdentityRow = z.infer<typeof IdentityRow>;
|
|
23
|
-
|
|
24
|
-
export const CreateIdentityBody = z.object({
|
|
25
|
-
name: z.string().min(1).max(120),
|
|
26
|
-
email: z.string().email(),
|
|
27
|
-
password: z.string().min(1).nullable().optional(),
|
|
28
|
-
proxy_id: Uuid.nullable().optional(),
|
|
29
|
-
persona_text: z.string().default(""),
|
|
30
|
-
/** Optional UI-provided preview for create-time session/proxy validation. */
|
|
31
|
-
session_preview: OmniFlowSessionSummarySchema.optional(),
|
|
32
|
-
});
|
|
33
|
-
export type CreateIdentityBody = z.infer<typeof CreateIdentityBody>;
|
|
34
|
-
|
|
35
|
-
export const PatchIdentityBody = CreateIdentityBody.partial();
|
|
36
|
-
export type PatchIdentityBody = z.infer<typeof PatchIdentityBody>;
|