dp-worker 0.1.0 → 0.1.2

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 (67) hide show
  1. package/dist/agent/agent.d.ts +6 -13
  2. package/dist/agent/agent.js +9 -19
  3. package/dist/agent/agent.js.map +1 -1
  4. package/dist/browser/actions.d.ts +1 -1
  5. package/dist/browser/actions.js.map +1 -1
  6. package/dist/browser/builtin-page-cleanups.d.ts +1 -1
  7. package/dist/browser/chrome-process.d.ts +3 -0
  8. package/dist/browser/chrome-process.js +101 -13
  9. package/dist/browser/chrome-process.js.map +1 -1
  10. package/dist/browser/dom-helpers.d.ts +1 -1
  11. package/dist/browser/expect.d.ts +1 -1
  12. package/dist/browser/expect.js.map +1 -1
  13. package/dist/browser/humanize.d.ts +1 -1
  14. package/dist/browser/locator-resolver.d.ts +1 -1
  15. package/dist/browser/manager.d.ts +5 -5
  16. package/dist/browser/manager.js +95 -45
  17. package/dist/browser/manager.js.map +1 -1
  18. package/dist/browser/snapshot.d.ts +1 -1
  19. package/dist/center/session-sync.d.ts +16 -77
  20. package/dist/center/session-sync.js +58 -303
  21. package/dist/center/session-sync.js.map +1 -1
  22. package/dist/chrome-extension/omni-flow/background.js +561 -0
  23. package/dist/chrome-extension/omni-flow/content.js +29 -0
  24. package/dist/chrome-extension/omni-flow/icon.png +0 -0
  25. package/dist/chrome-extension/omni-flow/inject.js +173 -0
  26. package/dist/chrome-extension/omni-flow/manifest.json +44 -0
  27. package/dist/chrome-extension/omni-flow/popup.css +819 -0
  28. package/dist/chrome-extension/omni-flow/popup.html +284 -0
  29. package/dist/chrome-extension/omni-flow/popup.js +1021 -0
  30. package/dist/chrome-extension/omni-flow/usage_guide.md +139 -0
  31. package/dist/index.js +15 -45
  32. package/dist/index.js.map +1 -1
  33. package/node_modules/dp-shared/dist/domain.d.ts +4 -4
  34. package/node_modules/dp-shared/dist/domain.d.ts.map +1 -1
  35. package/node_modules/dp-shared/dist/domain.js +4 -4
  36. package/node_modules/dp-shared/dist/domain.js.map +1 -1
  37. package/node_modules/dp-shared/dist/identities.d.ts +22 -0
  38. package/node_modules/dp-shared/dist/identities.d.ts.map +1 -1
  39. package/node_modules/dp-shared/dist/identities.js +3 -0
  40. package/node_modules/dp-shared/dist/identities.js.map +1 -1
  41. package/node_modules/dp-shared/dist/index.d.ts +1 -0
  42. package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
  43. package/node_modules/dp-shared/dist/index.js +1 -0
  44. package/node_modules/dp-shared/dist/index.js.map +1 -1
  45. package/node_modules/dp-shared/dist/omni-flow-session.d.ts +85 -0
  46. package/node_modules/dp-shared/dist/omni-flow-session.d.ts.map +1 -0
  47. package/node_modules/dp-shared/dist/omni-flow-session.js +59 -0
  48. package/node_modules/dp-shared/dist/omni-flow-session.js.map +1 -0
  49. package/node_modules/dp-shared/dist/rest-contracts.d.ts +12 -1
  50. package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
  51. package/node_modules/dp-shared/dist/rest-contracts.js +5 -3
  52. package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
  53. package/node_modules/dp-shared/dist/ws-protocol.d.ts +4 -4
  54. package/node_modules/dp-shared/src/admin-broadcast.ts +38 -0
  55. package/node_modules/dp-shared/src/audit-contracts.ts +33 -0
  56. package/node_modules/dp-shared/src/configs-contracts.ts +206 -0
  57. package/node_modules/dp-shared/src/db-rows.ts +280 -0
  58. package/node_modules/dp-shared/src/deploy-contracts.ts +38 -0
  59. package/node_modules/dp-shared/src/domain.ts +124 -0
  60. package/node_modules/dp-shared/src/identities.ts +36 -0
  61. package/node_modules/dp-shared/src/index.ts +25 -0
  62. package/node_modules/dp-shared/src/omni-flow-session.ts +80 -0
  63. package/node_modules/dp-shared/src/rest-contracts.ts +409 -0
  64. package/node_modules/dp-shared/src/task-history-contracts.ts +115 -0
  65. package/node_modules/dp-shared/src/worker-detail-contracts.ts +230 -0
  66. package/node_modules/dp-shared/src/ws-protocol.ts +435 -0
  67. package/package.json +6 -8
@@ -1,85 +1,24 @@
1
- import type { SessionBlob } from "dp-shared";
2
- export interface SessionFileListing {
3
- /** Absolute paths of files that should be packaged. */
4
- include: string[];
5
- /**
6
- * Absolute paths of files that were considered but skipped. Returned to
7
- * callers (and tests) so the exclusion contract is observable.
8
- */
9
- excluded: string[];
10
- }
11
- /**
12
- * Walks a Chrome user-data-dir and returns the inclusion list per §worker-session.
13
- * Symlinks are followed; deep dirs are walked depth-first. Returns sorted
14
- * absolute paths so callers building a zip get deterministic ordering for
15
- * stable content hashes.
16
- */
17
- export declare function buildSessionFileList(browserDataDir: string): Promise<SessionFileListing>;
18
- export interface PackagedSession {
19
- buf: Uint8Array;
20
- content_hash: string;
21
- size_bytes: number;
22
- }
23
- /**
24
- * Build the session zip for `<workspace>/browser-data`. Returns the zip
25
- * buffer plus its sha256-hex digest and byte length. Caller is expected to
26
- * have stopped Chrome before reading the profile (open Cookies/IndexedDB
27
- * files give torn reads on macOS/Windows).
28
- */
29
- export declare function packageSessionToZip(workspace: string): Promise<PackagedSession>;
1
+ import { type SessionBlob } from "dp-shared";
30
2
  export interface SessionMeta {
31
- /** sha256 hash of the canonical zip currently applied locally. */
3
+ /** sha256 hash of the current center-published OmniFlow session JSON. */
32
4
  content_hash: string;
33
- /** ISO timestamp — when the local profile was last considered authoritative. */
5
+ /** ISO timestamp when this artifact was last synced locally. */
34
6
  last_local_modified_at: string;
35
- /** ISO timestamp — when this content_hash was pulled from center. */
7
+ /** ISO timestamp when this content_hash was pulled from center. */
36
8
  synced_at: string;
37
9
  }
38
- export declare function sessionMetaPath(workspace: string): string;
39
- export declare function readLocalSessionMeta(workspace: string): Promise<SessionMeta | null>;
40
- export declare function writeLocalSessionMeta(workspace: string, meta: SessionMeta): Promise<void>;
41
- /**
42
- * Decide whether to pull this center-published session blob over the local
43
- * browser-data, or leave the local copy alone. Returns null when a pull
44
- * should proceed, or a short reason string when it should be skipped.
45
- *
46
- * Skip conditions:
47
- * - "hash-match": local hash equals server hash — no work to do
48
- * - "local-newer": local has changed since the server's copy was uploaded
49
- * (probably the worker logged into a new account during a task; that login
50
- * state would be lost if we overwrote it with the older server copy)
51
- */
52
- export declare function shouldSkipSessionSwap(workspace: string, blob: SessionBlob): Promise<string | null>;
53
- export interface ApplySessionDeps {
10
+ export interface SyncOmniFlowSessionDeps {
54
11
  fetchUrlToBuffer: (url: string) => Promise<Uint8Array>;
55
- extractZipToDir: (buf: Uint8Array, destDir: string) => Promise<void>;
56
12
  now?: () => number;
57
13
  }
58
- /**
59
- * Extract a zip buffer onto a destination directory. Designed for the
60
- * Chrome user-data-dir overwrite case:
61
- *
62
- * - **No purge first**: we don't wipe destDir. Files in the zip
63
- * overwrite their counterparts; files NOT in the zip stay put. This
64
- * keeps any worker-local state that wasn't packaged (logs, transient
65
- * dirs the §C exclude list dropped) untouched.
66
- * - **Path traversal guard**: every entry's resolved absolute path
67
- * must stay inside `destDir`. A malicious "../../etc/passwd" entry
68
- * gets rejected loudly instead of silently writing outside.
69
- * - **Mkdir parents**: zip entries don't always include their parent
70
- * directories explicitly; we resolve each file's dir and recursive-
71
- * mkdir before writing.
72
- *
73
- * Exposed as a named export so callers / tests can plug it directly
74
- * into ApplySessionDeps.extractZipToDir.
75
- */
76
- export declare function extractZipBufferToDir(buf: Uint8Array, destDir: string): Promise<void>;
77
- /**
78
- * Pull a center session zip onto the local browser-data dir. Caller MUST hold
79
- * the BrowserLock and have closed Chrome before invoking this — overwriting
80
- * `Default/Cookies` etc. while Chrome holds them is undefined-behavior on
81
- * macOS / Windows.
82
- *
83
- * On success, the .session-meta.json is rewritten to record the new hash.
84
- */
85
- export declare function applySessionBlob(workspace: string, blob: SessionBlob, depsOverride?: Partial<ApplySessionDeps>): Promise<void>;
14
+ export interface SyncOmniFlowSessionResult {
15
+ status: "applied" | "skipped";
16
+ reason?: "hash-match";
17
+ content_hash: string;
18
+ path: string;
19
+ }
20
+ export declare function sessionMetaPath(workspace: string): string;
21
+ export declare function omniFlowSessionPath(workspace: string): string;
22
+ export declare function readLocalSessionMeta(workspace: string): Promise<SessionMeta | null>;
23
+ export declare function writeLocalSessionMeta(workspace: string, meta: SessionMeta): Promise<void>;
24
+ export declare function syncOmniFlowSessionBlob(workspace: string, blob: SessionBlob, depsOverride?: Partial<SyncOmniFlowSessionDeps>): Promise<SyncOmniFlowSessionResult>;
@@ -1,230 +1,24 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { createHash } from "node:crypto";
4
- import AdmZip from "adm-zip";
4
+ import { OmniFlowSessionExportSchema } from "dp-shared";
5
5
  /**
6
- * Session sync: package the Chrome user-data-dir into a deterministic zip
7
- * (for center upload), and apply a center-provided zip back onto the local browser
8
- * profile.
6
+ * Center session sync.
9
7
  *
10
- * Per v2.9 (方案2 white-list 最小化), the include set is "everything under
11
- * Default/ minus a tightened block-list" so the produced zip lands in the
12
- * 5-50MB range. Core kept entries for a logged-in session:
13
- *
14
- * - Default/Cookies, Default/Network/Cookies (Chrome ≥85 cookie home)
15
- * - Default/Local Storage/leveldb/*
16
- * - Default/IndexedDB/*
17
- * - Default/Preferences
18
- * - Default/Service Worker/Database (SW registration index)
19
- * - Local State (sibling of Default/)
20
- *
21
- * Tightened drops: Cache, Code Cache, GPUCache, CacheStorage, ShaderCache,
22
- * GrShaderCache, blob_storage, Sessions (open-tab restore state), Session
23
- * Storage (per-tab volatile), File System (sandbox), Service Worker/
24
- * {CacheStorage,ScriptCache}, all top-level cache dirs, lock/sentinel files.
25
- *
26
- * This module only handles the filesystem side. Network IO (fetching the
27
- * R2 GET URL) and zip framing live behind injectable deps so the swap flow
28
- * can be unit-tested without a real browser or live R2.
8
+ * dp-center stores the OmniFlow extension JSON export. dp-worker only pulls
9
+ * that artifact into the local workspace when the center content hash changes;
10
+ * Chrome startup then copies it into the bundled OmniFlow extension, and the
11
+ * extension imports proxy/timezone/cookies before browser launch is considered
12
+ * complete.
29
13
  */
30
14
  const SESSION_META_FILENAME = ".session-meta.json";
31
- /**
32
- * Directories under `<browser-data>/` that are pure caches / runtime state.
33
- * Path entries are slash-joined posix-style and matched against entries
34
- * relative to the browser-data root.
35
- */
36
- const EXCLUDED_DIR_PREFIXES = [
37
- // Profile-local caches.
38
- "Default/Cache",
39
- "Default/Code Cache",
40
- "Default/GPUCache",
41
- "Default/CacheStorage",
42
- // The Service Worker DIR is partially kept: "Default/Service Worker/Database"
43
- // holds the SW registration index and must travel with a logged-in session,
44
- // but "Default/Service Worker/CacheStorage" and "Default/Service Worker/ScriptCache"
45
- // are caches. Kept-vs-dropped is enforced via SERVICE_WORKER_KEEP_PREFIXES.
46
- "Default/Service Worker/CacheStorage",
47
- "Default/Service Worker/ScriptCache",
48
- "Default/ShaderCache",
49
- "Default/GrShaderCache",
50
- "Default/DawnCache",
51
- "Default/DawnGraphiteCache",
52
- "Default/DawnWebGPUCache",
53
- "Default/blob_storage",
54
- // "Sessions" holds restore-state for currently-open tabs. Volatile.
55
- "Default/Sessions",
56
- "Default/Session Storage",
57
- "Default/File System",
58
- // Download metadata + optimization-guide model files: regenerable, can be 10s of MB.
59
- "Default/Download Service",
60
- "Default/optimization_guide_hint_cache_store",
61
- "Default/optimization_guide_model_store",
62
- "Default/optimization_guide_prediction_model_downloads",
63
- // Top-level caches/runtime.
64
- "ShaderCache",
65
- "GrShaderCache",
66
- "GPUCache",
67
- "GraphiteDawnCache",
68
- "Crashpad",
69
- "BrowserMetrics",
70
- "component_crx_cache",
71
- "extensions_crx_cache",
72
- // Lock files / sentinels.
73
- "Singleton",
74
- ];
75
- const EXCLUDED_DIR_PREFIXES_NORMALIZED = EXCLUDED_DIR_PREFIXES.map((p) => p.replace(/\\/g, "/"));
76
- /** Sub-paths under Default/Service Worker that we DO keep. Whitelist beats blacklist. */
77
- const SERVICE_WORKER_KEEP_PREFIXES = [
78
- "Default/Service Worker/Database",
79
- ];
80
- const EXCLUDED_FILENAME_PATTERNS = [
81
- /\.tmp$/i,
82
- /\.bak$/i,
83
- /-journal$/i,
84
- /^LOCK$/,
85
- /^LOG\.old$/,
86
- /^chrome_debug\.log$/,
87
- /^SingletonLock$/,
88
- /^SingletonCookie$/,
89
- /^SingletonSocket$/,
90
- ];
91
- /**
92
- * Walks a Chrome user-data-dir and returns the inclusion list per §worker-session.
93
- * Symlinks are followed; deep dirs are walked depth-first. Returns sorted
94
- * absolute paths so callers building a zip get deterministic ordering for
95
- * stable content hashes.
96
- */
97
- export async function buildSessionFileList(browserDataDir) {
98
- const root = path.resolve(browserDataDir);
99
- const include = [];
100
- const excluded = [];
101
- const walk = (absDir) => {
102
- let entries;
103
- try {
104
- entries = fs.readdirSync(absDir, { withFileTypes: true });
105
- }
106
- catch {
107
- return;
108
- }
109
- for (const ent of entries) {
110
- const absPath = path.join(absDir, ent.name);
111
- const rel = path.relative(root, absPath).split(path.sep).join("/");
112
- if (ent.isDirectory()) {
113
- if (isExcludedDir(rel)) {
114
- // Don't even descend; everything under here is excluded.
115
- continue;
116
- }
117
- walk(absPath);
118
- continue;
119
- }
120
- if (!ent.isFile())
121
- continue;
122
- if (isExcludedFile(rel, ent.name)) {
123
- excluded.push(absPath);
124
- continue;
125
- }
126
- include.push(absPath);
127
- }
128
- };
129
- walk(root);
130
- include.sort();
131
- excluded.sort();
132
- return { include, excluded };
133
- }
134
- function isExcludedDir(relDir) {
135
- // The Service Worker whitelist trumps the Service Worker blacklist entry.
136
- for (const keep of SERVICE_WORKER_KEEP_PREFIXES) {
137
- if (relDir === keep || relDir.startsWith(keep + "/"))
138
- return false;
139
- }
140
- for (const ex of EXCLUDED_DIR_PREFIXES_NORMALIZED) {
141
- if (relDir === ex || relDir.startsWith(ex + "/"))
142
- return true;
143
- }
144
- return false;
145
- }
146
- /* ============================================================================
147
- * Packager: turn a browser-data dir into a deterministic zip buffer.
148
- *
149
- * Used by the `dipclaw package-session` CLI subcommand and (future) the
150
- * worker-side push path. The buffer is the canonical thing whose sha256 becomes
151
- * `chrome_sessions.content_hash` — same dir contents must produce the same
152
- * hash so the content-addressed R2 layout (`sessions/<worker>/<hash>.zip`) is
153
- * idempotent.
154
- *
155
- * Determinism comes from:
156
- * - buildSessionFileList sorts include paths
157
- * - AdmZip adds entries in insertion order (we feed them sorted)
158
- * - entry mtimes are pinned to a fixed epoch so two packagings of the
159
- * same bytes hash identically regardless of filesystem timestamps
160
- * ============================================================================ */
161
- /**
162
- * Fixed timestamp baked into every zip entry so the resulting buffer is
163
- * byte-identical for the same file contents across hosts/runs. We pick
164
- * 2020-01-01T00:00:00Z (well after DOS time epoch) so the legacy zip date
165
- * fields encode cleanly.
166
- */
167
- const DETERMINISTIC_ENTRY_DATE = new Date(Date.UTC(2020, 0, 1, 0, 0, 0));
168
- /**
169
- * Build the session zip for `<workspace>/browser-data`. Returns the zip
170
- * buffer plus its sha256-hex digest and byte length. Caller is expected to
171
- * have stopped Chrome before reading the profile (open Cookies/IndexedDB
172
- * files give torn reads on macOS/Windows).
173
- */
174
- export async function packageSessionToZip(workspace) {
175
- const browserData = path.join(workspace, "browser-data");
176
- const { include } = await buildSessionFileList(browserData);
177
- const root = path.resolve(browserData);
178
- const zip = new AdmZip();
179
- for (const absPath of include) {
180
- const rel = path.relative(root, absPath).split(path.sep).join("/");
181
- let data;
182
- try {
183
- data = fs.readFileSync(absPath);
184
- }
185
- catch {
186
- // File vanished between listing and read (e.g. Chrome rotating logs);
187
- // skip rather than abort. Determinism still holds because the include
188
- // list was sorted before this loop.
189
- continue;
190
- }
191
- const entry = zip.addFile(rel, data);
192
- // Pin entry metadata for deterministic byte output.
193
- entry.header.time = DETERMINISTIC_ENTRY_DATE;
194
- }
195
- const nodeBuf = zip.toBuffer();
196
- const buf = new Uint8Array(nodeBuf.buffer, nodeBuf.byteOffset, nodeBuf.byteLength);
197
- const content_hash = createHash("sha256").update(nodeBuf).digest("hex");
198
- return { buf, content_hash, size_bytes: buf.byteLength };
199
- }
200
- function isExcludedFile(relPath, basename) {
201
- // First: a file inside an excluded dir is itself excluded (we usually
202
- // skip these earlier by not descending, but this is the safety net for
203
- // files reached via symlink loops or callers passing prefiltered dirs).
204
- // Skip the SW whitelist check — files under "Database" are kept by walk()
205
- // already because isExcludedDir lets them through.
206
- for (const ex of EXCLUDED_DIR_PREFIXES_NORMALIZED) {
207
- if (relPath.startsWith(ex + "/")) {
208
- let onWhitelist = false;
209
- for (const keep of SERVICE_WORKER_KEEP_PREFIXES) {
210
- if (relPath.startsWith(keep + "/")) {
211
- onWhitelist = true;
212
- break;
213
- }
214
- }
215
- if (!onWhitelist)
216
- return true;
217
- }
218
- }
219
- for (const re of EXCLUDED_FILENAME_PATTERNS) {
220
- if (re.test(basename))
221
- return true;
222
- }
223
- return false;
224
- }
15
+ const OMNI_FLOW_SESSION_FILENAME = "omni-flow-session.json";
225
16
  export function sessionMetaPath(workspace) {
226
17
  return path.join(workspace, SESSION_META_FILENAME);
227
18
  }
19
+ export function omniFlowSessionPath(workspace) {
20
+ return path.join(workspace, ".dipclaw", OMNI_FLOW_SESSION_FILENAME);
21
+ }
228
22
  export async function readLocalSessionMeta(workspace) {
229
23
  const p = sessionMetaPath(workspace);
230
24
  if (!fs.existsSync(p))
@@ -247,99 +41,60 @@ export async function writeLocalSessionMeta(workspace, meta) {
247
41
  const p = sessionMetaPath(workspace);
248
42
  fs.writeFileSync(p, JSON.stringify(meta, null, 2) + "\n", "utf-8");
249
43
  }
250
- /**
251
- * Decide whether to pull this center-published session blob over the local
252
- * browser-data, or leave the local copy alone. Returns null when a pull
253
- * should proceed, or a short reason string when it should be skipped.
254
- *
255
- * Skip conditions:
256
- * - "hash-match": local hash equals server hash — no work to do
257
- * - "local-newer": local has changed since the server's copy was uploaded
258
- * (probably the worker logged into a new account during a task; that login
259
- * state would be lost if we overwrote it with the older server copy)
260
- */
261
- export async function shouldSkipSessionSwap(workspace, blob) {
44
+ export async function syncOmniFlowSessionBlob(workspace, blob, depsOverride) {
45
+ const dest = omniFlowSessionPath(workspace);
262
46
  const local = await readLocalSessionMeta(workspace);
263
- if (!local)
264
- return null;
265
- if (local.content_hash === blob.content_hash)
266
- return "hash-match";
267
- const localMs = Date.parse(local.last_local_modified_at);
268
- const uploadedMs = Date.parse(blob.uploaded_at);
269
- if (!Number.isFinite(localMs) || !Number.isFinite(uploadedMs))
270
- return null;
271
- if (localMs > uploadedMs)
272
- return "local-newer";
273
- return null;
274
- }
275
- const DEFAULT_DEPS = {
276
- fetchUrlToBuffer: async (url) => {
277
- const res = await fetch(url);
278
- if (!res.ok) {
279
- throw new Error(`Session blob fetch failed: ${res.status} ${res.statusText}`);
280
- }
281
- return new Uint8Array(await res.arrayBuffer());
282
- },
283
- extractZipToDir: extractZipBufferToDir,
284
- };
285
- /**
286
- * Extract a zip buffer onto a destination directory. Designed for the
287
- * Chrome user-data-dir overwrite case:
288
- *
289
- * - **No purge first**: we don't wipe destDir. Files in the zip
290
- * overwrite their counterparts; files NOT in the zip stay put. This
291
- * keeps any worker-local state that wasn't packaged (logs, transient
292
- * dirs the §C exclude list dropped) untouched.
293
- * - **Path traversal guard**: every entry's resolved absolute path
294
- * must stay inside `destDir`. A malicious "../../etc/passwd" entry
295
- * gets rejected loudly instead of silently writing outside.
296
- * - **Mkdir parents**: zip entries don't always include their parent
297
- * directories explicitly; we resolve each file's dir and recursive-
298
- * mkdir before writing.
299
- *
300
- * Exposed as a named export so callers / tests can plug it directly
301
- * into ApplySessionDeps.extractZipToDir.
302
- */
303
- export async function extractZipBufferToDir(buf, destDir) {
304
- const absDest = path.resolve(destDir);
305
- fs.mkdirSync(absDest, { recursive: true });
306
- const zip = new AdmZip(Buffer.from(buf));
307
- for (const entry of zip.getEntries()) {
308
- if (entry.isDirectory)
309
- continue;
310
- const resolved = path.resolve(absDest, entry.entryName);
311
- // path.resolve handles ".." already, but the security check below
312
- // makes the prefix relationship explicit so a future refactor can't
313
- // silently lose the guard. The trailing-sep check stops
314
- // "destDir/foo" from being accepted as inside "destDir/fo".
315
- if (resolved !== absDest &&
316
- !resolved.startsWith(absDest + path.sep)) {
317
- throw new Error(`zip entry escapes destination: ${entry.entryName} -> ${resolved}`);
318
- }
319
- fs.mkdirSync(path.dirname(resolved), { recursive: true });
320
- fs.writeFileSync(resolved, entry.getData());
47
+ if (local?.content_hash === blob.content_hash && fs.existsSync(dest)) {
48
+ return {
49
+ status: "skipped",
50
+ reason: "hash-match",
51
+ content_hash: blob.content_hash,
52
+ path: dest,
53
+ };
321
54
  }
322
- }
323
- /**
324
- * Pull a center session zip onto the local browser-data dir. Caller MUST hold
325
- * the BrowserLock and have closed Chrome before invoking this — overwriting
326
- * `Default/Cookies` etc. while Chrome holds them is undefined-behavior on
327
- * macOS / Windows.
328
- *
329
- * On success, the .session-meta.json is rewritten to record the new hash.
330
- */
331
- export async function applySessionBlob(workspace, blob, depsOverride) {
332
- const deps = { ...DEFAULT_DEPS, ...depsOverride };
333
- const browserData = path.join(workspace, "browser-data");
334
- fs.mkdirSync(browserData, { recursive: true });
335
- const buf = await deps.fetchUrlToBuffer(blob.r2_get_url);
336
- await deps.extractZipToDir(buf, browserData);
337
- const now = (deps.now ?? Date.now)();
55
+ const fetchUrlToBuffer = depsOverride?.fetchUrlToBuffer ?? defaultFetchUrlToBuffer;
56
+ const buf = await fetchUrlToBuffer(blob.r2_get_url);
57
+ if (buf.byteLength !== blob.size_bytes) {
58
+ throw new Error(`OmniFlow session size mismatch: expected ${blob.size_bytes}, got ${buf.byteLength}`);
59
+ }
60
+ const actualHash = createHash("sha256").update(Buffer.from(buf)).digest("hex");
61
+ if (actualHash !== blob.content_hash) {
62
+ throw new Error(`OmniFlow session hash mismatch: expected ${blob.content_hash}, got ${actualHash}`);
63
+ }
64
+ const raw = Buffer.from(buf).toString("utf8");
65
+ let json;
66
+ try {
67
+ json = JSON.parse(raw);
68
+ }
69
+ catch {
70
+ throw new Error("OmniFlow session is not valid JSON");
71
+ }
72
+ const parsed = OmniFlowSessionExportSchema.safeParse(json);
73
+ if (!parsed.success) {
74
+ throw new Error(`Invalid OmniFlow session: ${parsed.error.issues
75
+ .map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`)
76
+ .join("; ")}`);
77
+ }
78
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
79
+ fs.writeFileSync(dest, raw.endsWith("\n") ? raw : raw + "\n", "utf8");
80
+ const now = (depsOverride?.now ?? Date.now)();
338
81
  const isoNow = new Date(now).toISOString();
339
82
  await writeLocalSessionMeta(workspace, {
340
83
  content_hash: blob.content_hash,
341
84
  synced_at: isoNow,
342
85
  last_local_modified_at: isoNow,
343
86
  });
87
+ return {
88
+ status: "applied",
89
+ content_hash: blob.content_hash,
90
+ path: dest,
91
+ };
92
+ }
93
+ async function defaultFetchUrlToBuffer(url) {
94
+ const res = await fetch(url);
95
+ if (!res.ok) {
96
+ throw new Error(`Session blob fetch failed: ${res.status} ${res.statusText}`);
97
+ }
98
+ return new Uint8Array(await res.arrayBuffer());
344
99
  }
345
100
  //# sourceMappingURL=session-sync.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-sync.js","sourceRoot":"","sources":["../../src/center/session-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,SAAS,CAAC;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,qBAAqB,GAAG;IAC5B,wBAAwB;IACxB,eAAe;IACf,oBAAoB;IACpB,kBAAkB;IAClB,sBAAsB;IACtB,8EAA8E;IAC9E,4EAA4E;IAC5E,qFAAqF;IACrF,4EAA4E;IAC5E,qCAAqC;IACrC,oCAAoC;IACpC,qBAAqB;IACrB,uBAAuB;IACvB,mBAAmB;IACnB,2BAA2B;IAC3B,yBAAyB;IACzB,sBAAsB;IACtB,oEAAoE;IACpE,kBAAkB;IAClB,yBAAyB;IACzB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