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,495 +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
- /** Stable scheduled_tasks.id (matches DB column task_runs.scheduled_task_id).
74
- * OMITTED (never null) for pure ad-hoc runs — zod optional rejects null. */
75
- scheduled_task_id: Uuid.optional(),
76
- prompt: z.string().min(1),
77
- randomized_delay_ms: z.number().int().nonnegative().default(0),
78
- deadline_ms: z.number().int().positive().optional(),
79
- attachments: z
80
- .array(
81
- z.object({
82
- r2_object_key: z.string().min(1),
83
- filename: z.string().min(1),
84
- mime: z.string().optional(),
85
- })
86
- )
87
- .optional(),
88
- })
89
- );
90
-
91
- export const ChatUserMessage = Envelope(
92
- "chat_user_message",
93
- z.object({
94
- chat_id: Uuid,
95
- message_id: Uuid,
96
- content: z.union([
97
- z.string(),
98
- z.array(
99
- z.object({
100
- type: z.string(),
101
- text: z.string().optional(),
102
- attachment_id: Uuid.optional(),
103
- filename: z.string().optional(),
104
- mime: z.string().optional(),
105
- size_bytes: z.number().int().positive().optional(),
106
- url: z.string().url().optional(),
107
- })
108
- ),
109
- ]),
110
- })
111
- );
112
-
113
- export const ConfigInvalidateMessage = Envelope(
114
- "config_invalidate",
115
- z.object({
116
- which: z.array(z.enum(["llm", "proxy", "persona", "session", "telegram", "social_accounts"])),
117
- new_config_etag: ConfigEtag,
118
- })
119
- );
120
-
121
- export const CancelTaskMessage = Envelope(
122
- "cancel_task",
123
- z.object({
124
- task_run_id: Uuid,
125
- reason: z.string().optional(),
126
- })
127
- );
128
-
129
- export const WorkerHelloMessage = Envelope(
130
- "hello",
131
- z.object({
132
- worker_id: Uuid,
133
- version: z.string().min(1),
134
- config_etag: ConfigEtag,
135
- current_status: RuntimeStatus,
136
- current_task_id: Uuid.optional(),
137
- })
138
- );
139
-
140
- export const StatusChangeMessage = Envelope(
141
- "status_change",
142
- z.object({
143
- status: RuntimeStatus,
144
- current_task_id: Uuid.optional(),
145
- chrome_uptime_ms: z.number().int().nonnegative().optional(),
146
- reason: z.string().optional(),
147
- })
148
- );
149
-
150
- /** Periodic 30s liveness ping from dp-worker to center. Empty payload —
151
- * the envelope's arrival is the signal. */
152
- export const WorkerHeartbeatMessage = Envelope(
153
- "worker_heartbeat",
154
- z.object({}),
155
- );
156
-
157
- export const TaskEventMessage = Envelope(
158
- "task_event",
159
- z.object({
160
- task_run_id: Uuid,
161
- event: z.enum(["dispatched_ack", "started", "step_log", "finished"]),
162
- status: TaskRunStatus.optional(),
163
- error: z.string().optional(),
164
- result_summary: z.string().optional(),
165
- step_index: z.number().int().nonnegative().optional(),
166
- step_log: z.string().optional(),
167
- })
168
- );
169
-
170
- export const ChatMessageChunkMessage = Envelope(
171
- "chat_message_chunk",
172
- z.object({
173
- chat_id: Uuid,
174
- message_id: Uuid,
175
- delta: z.string(),
176
- done: z.boolean(),
177
- })
178
- );
179
-
180
- export const ChatMessageFinalizedMessage = Envelope(
181
- "chat_message_finalized",
182
- z.object({
183
- chat_id: Uuid,
184
- message_id: Uuid,
185
- role: z.string(),
186
- content: z.string(),
187
- tool_traces: z.array(z.record(z.string(), z.unknown())).optional(),
188
- })
189
- );
190
-
191
- /** Returned by dp-worker when a chat arrives while BrowserLock is held by a task. */
192
- export const ChatMessageQueuedMessage = Envelope(
193
- "chat_message_queued",
194
- z.object({
195
- chat_id: Uuid,
196
- message_id: Uuid,
197
- queue_position: z.number().int().nonnegative(),
198
- })
199
- );
200
-
201
- export const AttachmentUploadRequestMessage = Envelope(
202
- "attachment_upload",
203
- z.object({
204
- request_id: ShortId,
205
- filename: z.string().min(1),
206
- mime: z.string().optional(),
207
- size_bytes: z.number().int().positive(),
208
- })
209
- );
210
-
211
- export const ErrorReportMessage = Envelope(
212
- "error_report",
213
- z.object({
214
- code: z.string().min(1),
215
- message: z.string().min(1),
216
- stack: z.string().optional(),
217
- })
218
- );
219
-
220
- /* ----- Payload type aliases ----- *
221
- * TypeScript's `Extract<UnionType, { type: "x" }>` is fragile on inferred
222
- * discriminated unions whose variants share structural shape (all wrap
223
- * `{ id?, type, ts, payload }`). Re-exporting payload types directly per
224
- * message keeps consumers from having to fight that pattern.
225
- */
226
- export type TaskDispatchPayload = z.infer<typeof TaskDispatchMessage>["payload"];
227
- export type ChatUserMessagePayload = z.infer<typeof ChatUserMessage>["payload"];
228
- export type ConfigInvalidatePayload = z.infer<typeof ConfigInvalidateMessage>["payload"];
229
- export type CancelTaskPayload = z.infer<typeof CancelTaskMessage>["payload"];
230
- export type PingRequestPayload = z.infer<typeof PingRequestMessage>["payload"];
231
- export type PongPayload = z.infer<typeof PongMessage>["payload"];
232
- export type WorkerHelloPayload = z.infer<typeof WorkerHelloMessage>["payload"];
233
- export type StatusChangePayload = z.infer<typeof StatusChangeMessage>["payload"];
234
- export type TaskEventPayload = z.infer<typeof TaskEventMessage>["payload"];
235
- export type ChatMessageChunkPayload = z.infer<typeof ChatMessageChunkMessage>["payload"];
236
- export type ChatMessageFinalizedPayload = z.infer<typeof ChatMessageFinalizedMessage>["payload"];
237
- export type ChatMessageQueuedPayload = z.infer<typeof ChatMessageQueuedMessage>["payload"];
238
- export type WorkerHeartbeatPayload = z.infer<typeof WorkerHeartbeatMessage>["payload"];
239
-
240
- /** Union of every message that may travel on a center↔dp-worker WebSocket. */
241
- export const CenterWorkerWsMessage = z.discriminatedUnion("type", [
242
- AckMessage,
243
- PingRequestMessage,
244
- PongMessage,
245
- // center → dp-worker
246
- TaskDispatchMessage,
247
- ChatUserMessage,
248
- ConfigInvalidateMessage,
249
- CancelTaskMessage,
250
- // dp-worker → center
251
- WorkerHelloMessage,
252
- StatusChangeMessage,
253
- WorkerHeartbeatMessage,
254
- TaskEventMessage,
255
- ChatMessageChunkMessage,
256
- ChatMessageFinalizedMessage,
257
- ChatMessageQueuedMessage,
258
- AttachmentUploadRequestMessage,
259
- ErrorReportMessage,
260
- ]);
261
- export type CenterWorkerWsMessage = z.infer<typeof CenterWorkerWsMessage>;
262
-
263
- /* ============================================================================
264
- * center ↔ dp-director
265
- * ============================================================================ */
266
-
267
- export const SpawnWorkerMessage = Envelope(
268
- "spawn_worker",
269
- z.object({
270
- worker_id: Uuid,
271
- api_key: z.string().min(1),
272
- center_url: z.string().url(),
273
- version: z.string().optional(),
274
- workspace_path: z.string().optional(),
275
- })
276
- );
277
-
278
- export const StopWorkerMessage = Envelope(
279
- "stop_worker",
280
- z.object({
281
- worker_id: Uuid,
282
- graceful: z.boolean().default(true),
283
- })
284
- );
285
-
286
- export const RestartWorkerMessage = Envelope(
287
- "restart_worker",
288
- z.object({
289
- worker_id: Uuid,
290
- })
291
- );
292
-
293
- export const UpgradeDpWorkerMessage = Envelope(
294
- "upgrade_dp_worker",
295
- z.object({
296
- request_id: z.string().min(1),
297
- })
298
- );
299
-
300
- export const QueryWorkerStatusMessage = Envelope(
301
- "query_worker_status",
302
- z.object({
303
- worker_ids: z.array(Uuid).min(1),
304
- })
305
- );
306
-
307
- export const ReconcileWorkersMessage = Envelope(
308
- "reconcile_workers",
309
- z.object({
310
- generation: z.string().min(1),
311
- workers: z.array(
312
- z.object({
313
- worker_id: Uuid,
314
- api_key: z.string().min(1),
315
- center_url: z.string().url(),
316
- workspace_path: z.string().optional(),
317
- })
318
- ),
319
- stop_unlisted: z.boolean().default(true),
320
- })
321
- );
322
-
323
- export const DirectorHelloMessage = Envelope(
324
- "hello",
325
- z.object({
326
- director_id: Uuid,
327
- host_label: z.string().min(1).optional(),
328
- version: z.string().min(1),
329
- worker_pids: z.record(Uuid, z.number().int().positive()),
330
- capabilities: z.array(z.string()).default([]),
331
- dp_worker_runtime_mode: DpWorkerRuntimeMode.optional(),
332
- dp_worker_version: z.string().min(1).optional(),
333
- dp_worker_latest_version: z.string().min(1).optional(),
334
- dp_worker_upgrade_status: DpWorkerUpgradeStatus.optional(),
335
- })
336
- );
337
-
338
- /**
339
- * Sent by DirectorConnection DO to the dp-director immediately after the WS upgrade so
340
- * the dp-director learns its own canonical director_id (the DO resolved it from the
341
- * api_key during the upgrade and knows the authoritative value). The dp-director
342
- * waits for this before sending `hello`.
343
- */
344
- export const WelcomeMessage = Envelope(
345
- "welcome",
346
- z.object({
347
- director_id: Uuid,
348
- })
349
- );
350
-
351
- export const WorkerStateChangeMessage = Envelope(
352
- "worker_state_change",
353
- z.object({
354
- worker_id: Uuid,
355
- state: z.enum(["running", "stopped", "crashed", "crashed_loop"]),
356
- pid: z.number().int().positive().optional(),
357
- exit_code: z.number().int().optional(),
358
- })
359
- );
360
-
361
- export const DirectorHeartbeatMessage = Envelope(
362
- "director_heartbeat",
363
- z.object({
364
- running_workers: z.array(Uuid),
365
- cpu: z.number().nonnegative().optional(),
366
- mem: z.number().nonnegative().optional(),
367
- })
368
- );
369
-
370
- export const DpWorkerUpgradeStatusMessage = Envelope(
371
- "dp_worker_upgrade_status",
372
- z.object({
373
- request_id: z.string().min(1),
374
- status: DpWorkerUpgradeStatus,
375
- runtime_mode: DpWorkerRuntimeMode,
376
- current_version: z.string().min(1).optional(),
377
- latest_version: z.string().min(1).optional(),
378
- message: z.string().optional(),
379
- })
380
- );
381
-
382
- export type SpawnWorkerPayload = z.infer<typeof SpawnWorkerMessage>["payload"];
383
- export type StopWorkerPayload = z.infer<typeof StopWorkerMessage>["payload"];
384
- export type RestartWorkerPayload = z.infer<typeof RestartWorkerMessage>["payload"];
385
- export type UpgradeDpWorkerPayload = z.infer<typeof UpgradeDpWorkerMessage>["payload"];
386
- export type QueryWorkerStatusPayload = z.infer<typeof QueryWorkerStatusMessage>["payload"];
387
- export type ReconcileWorkersPayload = z.infer<typeof ReconcileWorkersMessage>["payload"];
388
- export type DirectorHelloPayload = z.infer<typeof DirectorHelloMessage>["payload"];
389
- export type WorkerStateChangePayload = z.infer<typeof WorkerStateChangeMessage>["payload"];
390
- export type DirectorHeartbeatPayload = z.infer<typeof DirectorHeartbeatMessage>["payload"];
391
- export type WelcomePayload = z.infer<typeof WelcomeMessage>["payload"];
392
- export type DpWorkerUpgradeStatusPayload = z.infer<typeof DpWorkerUpgradeStatusMessage>["payload"];
393
-
394
- /** Union of every message that may travel on a center↔dp-director WebSocket. */
395
- export const CenterDirectorWsMessage = z.discriminatedUnion("type", [
396
- AckMessage,
397
- PingRequestMessage,
398
- PongMessage,
399
- // center → dp-director
400
- SpawnWorkerMessage,
401
- StopWorkerMessage,
402
- RestartWorkerMessage,
403
- UpgradeDpWorkerMessage,
404
- QueryWorkerStatusMessage,
405
- ReconcileWorkersMessage,
406
- WelcomeMessage,
407
- // dp-director → center
408
- DirectorHelloMessage,
409
- WorkerStateChangeMessage,
410
- DirectorHeartbeatMessage,
411
- DpWorkerUpgradeStatusMessage,
412
- ]);
413
- export type CenterDirectorWsMessage = z.infer<typeof CenterDirectorWsMessage>;
414
-
415
- /* ============================================================================
416
- * Web UI ↔ ChatBroadcast DO
417
- * ============================================================================ */
418
-
419
- /** UI sends to subscribe to a chat (auth is via JWT in connect URL). */
420
- export const ChatSubscribeMessage = Envelope(
421
- "subscribe",
422
- z.object({
423
- chat_id: Uuid,
424
- since_message_id: Uuid.optional(),
425
- })
426
- );
427
-
428
- /** ChatBroadcast pushes the same chunks dp-worker emits, plus user-side echoes. */
429
- export const ChatBroadcastChunkMessage = ChatMessageChunkMessage;
430
- export const ChatBroadcastFinalizedMessage = ChatMessageFinalizedMessage;
431
-
432
- export const CenterWebChatWsMessage = z.discriminatedUnion("type", [
433
- AckMessage,
434
- ChatSubscribeMessage,
435
- ChatBroadcastChunkMessage,
436
- ChatBroadcastFinalizedMessage,
437
- ]);
438
- export type CenterWebChatWsMessage = z.infer<typeof CenterWebChatWsMessage>;
439
-
440
- /* ============================================================================
441
- * center ↔ dp-cloak (desktop fingerprint browser, cs mode)
442
- *
443
- * dp-cloak connects to /ws/cloak?token=<user_jwt> so center can push
444
- * revocations in real time. The channel carries no session bytes (those go over
445
- * the encrypted REST pull); it exists to instantly wipe local sessions when the
446
- * account is disabled/deleted or a specific worker session is revoked.
447
- * ============================================================================ */
448
-
449
- /** Sent by dp-cloak right after the WS upgrade so center knows the instance. */
450
- export const CloakHelloMessage = Envelope(
451
- "hello",
452
- z.object({
453
- /** Per-process uuid identifying this dp-cloak instance. */
454
- instance_id: Uuid,
455
- version: z.string().min(1),
456
- })
457
- );
458
-
459
- /** Periodic liveness ping from dp-cloak. Empty payload — arrival is the signal. */
460
- export const CloakHeartbeatMessage = Envelope("cloak_heartbeat", z.object({}));
461
-
462
- /** center → dp-cloak: wipe the local session/profile for this worker. */
463
- export const CloakSessionRevokeMessage = Envelope(
464
- "session_revoke",
465
- z.object({
466
- worker_id: Uuid,
467
- reason: z.string().optional(),
468
- })
469
- );
470
-
471
- /** center → dp-cloak: account disabled/deleted — wipe ALL sessions and log out. */
472
- export const CloakAccountDisabledMessage = Envelope(
473
- "account_disabled",
474
- z.object({
475
- reason: z.string().optional(),
476
- })
477
- );
478
-
479
- export type CloakHelloPayload = z.infer<typeof CloakHelloMessage>["payload"];
480
- export type CloakSessionRevokePayload = z.infer<typeof CloakSessionRevokeMessage>["payload"];
481
- export type CloakAccountDisabledPayload = z.infer<typeof CloakAccountDisabledMessage>["payload"];
482
-
483
- /** Union of every message that may travel on a center↔dp-cloak WebSocket. */
484
- export const CenterCloakWsMessage = z.discriminatedUnion("type", [
485
- AckMessage,
486
- PingRequestMessage,
487
- PongMessage,
488
- // center → dp-cloak
489
- CloakSessionRevokeMessage,
490
- CloakAccountDisabledMessage,
491
- // dp-cloak → center
492
- CloakHelloMessage,
493
- CloakHeartbeatMessage,
494
- ]);
495
- export type CenterCloakWsMessage = z.infer<typeof CenterCloakWsMessage>;