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.
- package/dist/browser/chrome-process.js +30 -58
- 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,435 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
import {
|
|
3
|
-
ConfigEtag,
|
|
4
|
-
DpWorkerRuntimeMode,
|
|
5
|
-
DpWorkerUpgradeStatus,
|
|
6
|
-
RuntimeStatus,
|
|
7
|
-
ShortId,
|
|
8
|
-
TaskRunStatus,
|
|
9
|
-
Uuid,
|
|
10
|
-
} from "./domain.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* WebSocket message envelopes.
|
|
14
|
-
*
|
|
15
|
-
* Every message that crosses the wire has the same outer shape; the inner
|
|
16
|
-
* `type` discriminates the payload. Senders that need a reply set `id`;
|
|
17
|
-
* receivers reply with `ack { ref_id: <that id> }`.
|
|
18
|
-
*
|
|
19
|
-
* See docs/architecture.md §Communication protocols → WebSocket for the
|
|
20
|
-
* authoritative list of message types per channel.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const Envelope = <T extends z.ZodType>(type: string, payload: T) =>
|
|
24
|
-
z.object({
|
|
25
|
-
/** Sender-assigned message id (typically uuid). Required when an ack is expected. */
|
|
26
|
-
id: z.string().min(1).optional(),
|
|
27
|
-
type: z.literal(type),
|
|
28
|
-
/** Unix ms at send time. */
|
|
29
|
-
ts: z.number().int().positive(),
|
|
30
|
-
payload,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
/* ============================================================================
|
|
34
|
-
* Generic envelope (every channel)
|
|
35
|
-
* ============================================================================ */
|
|
36
|
-
|
|
37
|
-
export const AckMessage = Envelope(
|
|
38
|
-
"ack",
|
|
39
|
-
z.object({
|
|
40
|
-
/** id of the message being acknowledged. */
|
|
41
|
-
ref_id: z.string().min(1),
|
|
42
|
-
/** Optional outcome — for "dispatched_ack" style acks the dp-worker reports back its current state. */
|
|
43
|
-
status: z.string().optional(),
|
|
44
|
-
error: z.string().optional(),
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
export const PingRequestMessage = Envelope(
|
|
49
|
-
"ping_request",
|
|
50
|
-
z.object({
|
|
51
|
-
ref_id: z.string().min(1),
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
export const PongMessage = Envelope(
|
|
56
|
-
"pong",
|
|
57
|
-
z.object({
|
|
58
|
-
ref_id: z.string().min(1),
|
|
59
|
-
status: RuntimeStatus.optional(),
|
|
60
|
-
current_task_id: Uuid.optional(),
|
|
61
|
-
chrome_uptime_ms: z.number().int().nonnegative().optional(),
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
/* ============================================================================
|
|
66
|
-
* center ↔ dp-worker
|
|
67
|
-
* ============================================================================ */
|
|
68
|
-
|
|
69
|
-
export const TaskDispatchMessage = Envelope(
|
|
70
|
-
"task_dispatch",
|
|
71
|
-
z.object({
|
|
72
|
-
task_run_id: Uuid,
|
|
73
|
-
prompt: z.string().min(1),
|
|
74
|
-
randomized_delay_ms: z.number().int().nonnegative().default(0),
|
|
75
|
-
deadline_ms: z.number().int().positive().optional(),
|
|
76
|
-
attachments: z
|
|
77
|
-
.array(
|
|
78
|
-
z.object({
|
|
79
|
-
r2_object_key: z.string().min(1),
|
|
80
|
-
filename: z.string().min(1),
|
|
81
|
-
mime: z.string().optional(),
|
|
82
|
-
})
|
|
83
|
-
)
|
|
84
|
-
.optional(),
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
export const ChatUserMessage = Envelope(
|
|
89
|
-
"chat_user_message",
|
|
90
|
-
z.object({
|
|
91
|
-
chat_id: Uuid,
|
|
92
|
-
message_id: Uuid,
|
|
93
|
-
content: z.union([
|
|
94
|
-
z.string(),
|
|
95
|
-
z.array(
|
|
96
|
-
z.object({
|
|
97
|
-
type: z.string(),
|
|
98
|
-
text: z.string().optional(),
|
|
99
|
-
attachment_id: Uuid.optional(),
|
|
100
|
-
filename: z.string().optional(),
|
|
101
|
-
mime: z.string().optional(),
|
|
102
|
-
size_bytes: z.number().int().positive().optional(),
|
|
103
|
-
url: z.string().url().optional(),
|
|
104
|
-
})
|
|
105
|
-
),
|
|
106
|
-
]),
|
|
107
|
-
})
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
export const ConfigInvalidateMessage = Envelope(
|
|
111
|
-
"config_invalidate",
|
|
112
|
-
z.object({
|
|
113
|
-
which: z.array(z.enum(["llm", "proxy", "persona", "session", "telegram", "social_accounts"])),
|
|
114
|
-
new_config_etag: ConfigEtag,
|
|
115
|
-
})
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
export const CancelTaskMessage = Envelope(
|
|
119
|
-
"cancel_task",
|
|
120
|
-
z.object({
|
|
121
|
-
task_run_id: Uuid,
|
|
122
|
-
reason: z.string().optional(),
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
export const WorkerHelloMessage = Envelope(
|
|
127
|
-
"hello",
|
|
128
|
-
z.object({
|
|
129
|
-
worker_id: Uuid,
|
|
130
|
-
version: z.string().min(1),
|
|
131
|
-
config_etag: ConfigEtag,
|
|
132
|
-
current_status: RuntimeStatus,
|
|
133
|
-
current_task_id: Uuid.optional(),
|
|
134
|
-
})
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
export const StatusChangeMessage = Envelope(
|
|
138
|
-
"status_change",
|
|
139
|
-
z.object({
|
|
140
|
-
status: RuntimeStatus,
|
|
141
|
-
current_task_id: Uuid.optional(),
|
|
142
|
-
chrome_uptime_ms: z.number().int().nonnegative().optional(),
|
|
143
|
-
reason: z.string().optional(),
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
/** Periodic 30s liveness ping from dp-worker to center. Empty payload —
|
|
148
|
-
* the envelope's arrival is the signal. */
|
|
149
|
-
export const WorkerHeartbeatMessage = Envelope(
|
|
150
|
-
"worker_heartbeat",
|
|
151
|
-
z.object({}),
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
export const TaskEventMessage = Envelope(
|
|
155
|
-
"task_event",
|
|
156
|
-
z.object({
|
|
157
|
-
task_run_id: Uuid,
|
|
158
|
-
event: z.enum(["dispatched_ack", "started", "step_log", "finished"]),
|
|
159
|
-
status: TaskRunStatus.optional(),
|
|
160
|
-
error: z.string().optional(),
|
|
161
|
-
result_summary: z.string().optional(),
|
|
162
|
-
step_index: z.number().int().nonnegative().optional(),
|
|
163
|
-
step_log: z.string().optional(),
|
|
164
|
-
})
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
export const ChatMessageChunkMessage = Envelope(
|
|
168
|
-
"chat_message_chunk",
|
|
169
|
-
z.object({
|
|
170
|
-
chat_id: Uuid,
|
|
171
|
-
message_id: Uuid,
|
|
172
|
-
delta: z.string(),
|
|
173
|
-
done: z.boolean(),
|
|
174
|
-
})
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
export const ChatMessageFinalizedMessage = Envelope(
|
|
178
|
-
"chat_message_finalized",
|
|
179
|
-
z.object({
|
|
180
|
-
chat_id: Uuid,
|
|
181
|
-
message_id: Uuid,
|
|
182
|
-
role: z.string(),
|
|
183
|
-
content: z.string(),
|
|
184
|
-
tool_traces: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
/** Returned by dp-worker when a chat arrives while BrowserLock is held by a task. */
|
|
189
|
-
export const ChatMessageQueuedMessage = Envelope(
|
|
190
|
-
"chat_message_queued",
|
|
191
|
-
z.object({
|
|
192
|
-
chat_id: Uuid,
|
|
193
|
-
message_id: Uuid,
|
|
194
|
-
queue_position: z.number().int().nonnegative(),
|
|
195
|
-
})
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
export const AttachmentUploadRequestMessage = Envelope(
|
|
199
|
-
"attachment_upload",
|
|
200
|
-
z.object({
|
|
201
|
-
request_id: ShortId,
|
|
202
|
-
filename: z.string().min(1),
|
|
203
|
-
mime: z.string().optional(),
|
|
204
|
-
size_bytes: z.number().int().positive(),
|
|
205
|
-
})
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
export const ErrorReportMessage = Envelope(
|
|
209
|
-
"error_report",
|
|
210
|
-
z.object({
|
|
211
|
-
code: z.string().min(1),
|
|
212
|
-
message: z.string().min(1),
|
|
213
|
-
stack: z.string().optional(),
|
|
214
|
-
})
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
/* ----- Payload type aliases ----- *
|
|
218
|
-
* TypeScript's `Extract<UnionType, { type: "x" }>` is fragile on inferred
|
|
219
|
-
* discriminated unions whose variants share structural shape (all wrap
|
|
220
|
-
* `{ id?, type, ts, payload }`). Re-exporting payload types directly per
|
|
221
|
-
* message keeps consumers from having to fight that pattern.
|
|
222
|
-
*/
|
|
223
|
-
export type TaskDispatchPayload = z.infer<typeof TaskDispatchMessage>["payload"];
|
|
224
|
-
export type ChatUserMessagePayload = z.infer<typeof ChatUserMessage>["payload"];
|
|
225
|
-
export type ConfigInvalidatePayload = z.infer<typeof ConfigInvalidateMessage>["payload"];
|
|
226
|
-
export type CancelTaskPayload = z.infer<typeof CancelTaskMessage>["payload"];
|
|
227
|
-
export type PingRequestPayload = z.infer<typeof PingRequestMessage>["payload"];
|
|
228
|
-
export type PongPayload = z.infer<typeof PongMessage>["payload"];
|
|
229
|
-
export type WorkerHelloPayload = z.infer<typeof WorkerHelloMessage>["payload"];
|
|
230
|
-
export type StatusChangePayload = z.infer<typeof StatusChangeMessage>["payload"];
|
|
231
|
-
export type TaskEventPayload = z.infer<typeof TaskEventMessage>["payload"];
|
|
232
|
-
export type ChatMessageChunkPayload = z.infer<typeof ChatMessageChunkMessage>["payload"];
|
|
233
|
-
export type ChatMessageFinalizedPayload = z.infer<typeof ChatMessageFinalizedMessage>["payload"];
|
|
234
|
-
export type ChatMessageQueuedPayload = z.infer<typeof ChatMessageQueuedMessage>["payload"];
|
|
235
|
-
export type WorkerHeartbeatPayload = z.infer<typeof WorkerHeartbeatMessage>["payload"];
|
|
236
|
-
|
|
237
|
-
/** Union of every message that may travel on a center↔dp-worker WebSocket. */
|
|
238
|
-
export const CenterWorkerWsMessage = z.discriminatedUnion("type", [
|
|
239
|
-
AckMessage,
|
|
240
|
-
PingRequestMessage,
|
|
241
|
-
PongMessage,
|
|
242
|
-
// center → dp-worker
|
|
243
|
-
TaskDispatchMessage,
|
|
244
|
-
ChatUserMessage,
|
|
245
|
-
ConfigInvalidateMessage,
|
|
246
|
-
CancelTaskMessage,
|
|
247
|
-
// dp-worker → center
|
|
248
|
-
WorkerHelloMessage,
|
|
249
|
-
StatusChangeMessage,
|
|
250
|
-
WorkerHeartbeatMessage,
|
|
251
|
-
TaskEventMessage,
|
|
252
|
-
ChatMessageChunkMessage,
|
|
253
|
-
ChatMessageFinalizedMessage,
|
|
254
|
-
ChatMessageQueuedMessage,
|
|
255
|
-
AttachmentUploadRequestMessage,
|
|
256
|
-
ErrorReportMessage,
|
|
257
|
-
]);
|
|
258
|
-
export type CenterWorkerWsMessage = z.infer<typeof CenterWorkerWsMessage>;
|
|
259
|
-
|
|
260
|
-
/* ============================================================================
|
|
261
|
-
* center ↔ dp-director
|
|
262
|
-
* ============================================================================ */
|
|
263
|
-
|
|
264
|
-
export const SpawnWorkerMessage = Envelope(
|
|
265
|
-
"spawn_worker",
|
|
266
|
-
z.object({
|
|
267
|
-
worker_id: Uuid,
|
|
268
|
-
api_key: z.string().min(1),
|
|
269
|
-
center_url: z.string().url(),
|
|
270
|
-
version: z.string().optional(),
|
|
271
|
-
workspace_path: z.string().optional(),
|
|
272
|
-
})
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
export const StopWorkerMessage = Envelope(
|
|
276
|
-
"stop_worker",
|
|
277
|
-
z.object({
|
|
278
|
-
worker_id: Uuid,
|
|
279
|
-
graceful: z.boolean().default(true),
|
|
280
|
-
})
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
export const RestartWorkerMessage = Envelope(
|
|
284
|
-
"restart_worker",
|
|
285
|
-
z.object({
|
|
286
|
-
worker_id: Uuid,
|
|
287
|
-
})
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
export const UpgradeDpWorkerMessage = Envelope(
|
|
291
|
-
"upgrade_dp_worker",
|
|
292
|
-
z.object({
|
|
293
|
-
request_id: z.string().min(1),
|
|
294
|
-
})
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
export const QueryWorkerStatusMessage = Envelope(
|
|
298
|
-
"query_worker_status",
|
|
299
|
-
z.object({
|
|
300
|
-
worker_ids: z.array(Uuid).min(1),
|
|
301
|
-
})
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
export const ReconcileWorkersMessage = Envelope(
|
|
305
|
-
"reconcile_workers",
|
|
306
|
-
z.object({
|
|
307
|
-
generation: z.string().min(1),
|
|
308
|
-
workers: z.array(
|
|
309
|
-
z.object({
|
|
310
|
-
worker_id: Uuid,
|
|
311
|
-
api_key: z.string().min(1),
|
|
312
|
-
center_url: z.string().url(),
|
|
313
|
-
workspace_path: z.string().optional(),
|
|
314
|
-
})
|
|
315
|
-
),
|
|
316
|
-
stop_unlisted: z.boolean().default(true),
|
|
317
|
-
})
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
export const DirectorHelloMessage = Envelope(
|
|
321
|
-
"hello",
|
|
322
|
-
z.object({
|
|
323
|
-
director_id: Uuid,
|
|
324
|
-
host_label: z.string().min(1).optional(),
|
|
325
|
-
version: z.string().min(1),
|
|
326
|
-
worker_pids: z.record(Uuid, z.number().int().positive()),
|
|
327
|
-
capabilities: z.array(z.string()).default([]),
|
|
328
|
-
dp_worker_runtime_mode: DpWorkerRuntimeMode.optional(),
|
|
329
|
-
dp_worker_version: z.string().min(1).optional(),
|
|
330
|
-
dp_worker_latest_version: z.string().min(1).optional(),
|
|
331
|
-
dp_worker_upgrade_status: DpWorkerUpgradeStatus.optional(),
|
|
332
|
-
})
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Sent by DirectorConnection DO to the dp-director immediately after the WS upgrade so
|
|
337
|
-
* the dp-director learns its own canonical director_id (the DO resolved it from the
|
|
338
|
-
* api_key during the upgrade and knows the authoritative value). The dp-director
|
|
339
|
-
* waits for this before sending `hello`.
|
|
340
|
-
*/
|
|
341
|
-
export const WelcomeMessage = Envelope(
|
|
342
|
-
"welcome",
|
|
343
|
-
z.object({
|
|
344
|
-
director_id: Uuid,
|
|
345
|
-
})
|
|
346
|
-
);
|
|
347
|
-
|
|
348
|
-
export const WorkerStateChangeMessage = Envelope(
|
|
349
|
-
"worker_state_change",
|
|
350
|
-
z.object({
|
|
351
|
-
worker_id: Uuid,
|
|
352
|
-
state: z.enum(["running", "stopped", "crashed", "crashed_loop"]),
|
|
353
|
-
pid: z.number().int().positive().optional(),
|
|
354
|
-
exit_code: z.number().int().optional(),
|
|
355
|
-
})
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
export const DirectorHeartbeatMessage = Envelope(
|
|
359
|
-
"director_heartbeat",
|
|
360
|
-
z.object({
|
|
361
|
-
running_workers: z.array(Uuid),
|
|
362
|
-
cpu: z.number().nonnegative().optional(),
|
|
363
|
-
mem: z.number().nonnegative().optional(),
|
|
364
|
-
})
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
export const DpWorkerUpgradeStatusMessage = Envelope(
|
|
368
|
-
"dp_worker_upgrade_status",
|
|
369
|
-
z.object({
|
|
370
|
-
request_id: z.string().min(1),
|
|
371
|
-
status: DpWorkerUpgradeStatus,
|
|
372
|
-
runtime_mode: DpWorkerRuntimeMode,
|
|
373
|
-
current_version: z.string().min(1).optional(),
|
|
374
|
-
latest_version: z.string().min(1).optional(),
|
|
375
|
-
message: z.string().optional(),
|
|
376
|
-
})
|
|
377
|
-
);
|
|
378
|
-
|
|
379
|
-
export type SpawnWorkerPayload = z.infer<typeof SpawnWorkerMessage>["payload"];
|
|
380
|
-
export type StopWorkerPayload = z.infer<typeof StopWorkerMessage>["payload"];
|
|
381
|
-
export type RestartWorkerPayload = z.infer<typeof RestartWorkerMessage>["payload"];
|
|
382
|
-
export type UpgradeDpWorkerPayload = z.infer<typeof UpgradeDpWorkerMessage>["payload"];
|
|
383
|
-
export type QueryWorkerStatusPayload = z.infer<typeof QueryWorkerStatusMessage>["payload"];
|
|
384
|
-
export type ReconcileWorkersPayload = z.infer<typeof ReconcileWorkersMessage>["payload"];
|
|
385
|
-
export type DirectorHelloPayload = z.infer<typeof DirectorHelloMessage>["payload"];
|
|
386
|
-
export type WorkerStateChangePayload = z.infer<typeof WorkerStateChangeMessage>["payload"];
|
|
387
|
-
export type DirectorHeartbeatPayload = z.infer<typeof DirectorHeartbeatMessage>["payload"];
|
|
388
|
-
export type WelcomePayload = z.infer<typeof WelcomeMessage>["payload"];
|
|
389
|
-
export type DpWorkerUpgradeStatusPayload = z.infer<typeof DpWorkerUpgradeStatusMessage>["payload"];
|
|
390
|
-
|
|
391
|
-
/** Union of every message that may travel on a center↔dp-director WebSocket. */
|
|
392
|
-
export const CenterDirectorWsMessage = z.discriminatedUnion("type", [
|
|
393
|
-
AckMessage,
|
|
394
|
-
PingRequestMessage,
|
|
395
|
-
PongMessage,
|
|
396
|
-
// center → dp-director
|
|
397
|
-
SpawnWorkerMessage,
|
|
398
|
-
StopWorkerMessage,
|
|
399
|
-
RestartWorkerMessage,
|
|
400
|
-
UpgradeDpWorkerMessage,
|
|
401
|
-
QueryWorkerStatusMessage,
|
|
402
|
-
ReconcileWorkersMessage,
|
|
403
|
-
WelcomeMessage,
|
|
404
|
-
// dp-director → center
|
|
405
|
-
DirectorHelloMessage,
|
|
406
|
-
WorkerStateChangeMessage,
|
|
407
|
-
DirectorHeartbeatMessage,
|
|
408
|
-
DpWorkerUpgradeStatusMessage,
|
|
409
|
-
]);
|
|
410
|
-
export type CenterDirectorWsMessage = z.infer<typeof CenterDirectorWsMessage>;
|
|
411
|
-
|
|
412
|
-
/* ============================================================================
|
|
413
|
-
* Web UI ↔ ChatBroadcast DO
|
|
414
|
-
* ============================================================================ */
|
|
415
|
-
|
|
416
|
-
/** UI sends to subscribe to a chat (auth is via JWT in connect URL). */
|
|
417
|
-
export const ChatSubscribeMessage = Envelope(
|
|
418
|
-
"subscribe",
|
|
419
|
-
z.object({
|
|
420
|
-
chat_id: Uuid,
|
|
421
|
-
since_message_id: Uuid.optional(),
|
|
422
|
-
})
|
|
423
|
-
);
|
|
424
|
-
|
|
425
|
-
/** ChatBroadcast pushes the same chunks dp-worker emits, plus user-side echoes. */
|
|
426
|
-
export const ChatBroadcastChunkMessage = ChatMessageChunkMessage;
|
|
427
|
-
export const ChatBroadcastFinalizedMessage = ChatMessageFinalizedMessage;
|
|
428
|
-
|
|
429
|
-
export const CenterWebChatWsMessage = z.discriminatedUnion("type", [
|
|
430
|
-
AckMessage,
|
|
431
|
-
ChatSubscribeMessage,
|
|
432
|
-
ChatBroadcastChunkMessage,
|
|
433
|
-
ChatBroadcastFinalizedMessage,
|
|
434
|
-
]);
|
|
435
|
-
export type CenterWebChatWsMessage = z.infer<typeof CenterWebChatWsMessage>;
|