lody 0.111.0 → 0.111.2-next.0

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 (41) hide show
  1. package/README.md +50 -37
  2. package/dist/{acp-interaction-owner-U5gmgHzv.js → acp-interaction-owner-DK2dXGPq.js} +63 -63
  3. package/dist/{agent-execution-DND1xdse.js → agent-execution-wyY_20dj.js} +164 -3
  4. package/dist/authority-clock-YIVdHT4y.js +480 -0
  5. package/dist/baguette-worker.js +3 -3
  6. package/dist/chunks/{vendor-@effect-platform-node-shared-C3vEQ-7m.js → vendor-@effect-platform-node-shared-BkNtLuZm.js} +2 -2
  7. package/dist/chunks/{vendor-@loro-dev-streams-client-B5HWGDv7.js → vendor-@loro-dev-streams-client-DzUskix-.js} +12 -12
  8. package/dist/chunks/{vendor-@loro-dev-streams-crdt-e4yhr5Ky.js → vendor-@loro-dev-streams-crdt-DHMQIzWN.js} +7 -8
  9. package/dist/chunks/{vendor-@opencode-codemode-Bo8uQG1T.js → vendor-@opencode-codemode-B9CuiPYU.js} +2 -2
  10. package/dist/chunks/{vendor-effect-BcqAZ7RD.js → vendor-effect-ygutZ0OR.js} +64 -64
  11. package/dist/chunks/{vendor-loro-repo-Bn7ZyXGt.js → vendor-loro-repo-CMjClCnf.js} +2 -2
  12. package/dist/chunks/{vendor-ws-DPfDb9HP.js → vendor-ws-DSn-BAa0.js} +6 -6
  13. package/dist/{client-CEfn-YWo.js → client-DKgCydR1.js} +63 -63
  14. package/dist/{cloudflared-native-CDEjYrz5.js → cloudflared-native-BNdJAC9v.js} +3 -3
  15. package/dist/cloudflared-worker.js +5 -5
  16. package/dist/{daemon-session-tools-DWqlzwmI.js → daemon-session-tools-PZV1PLfX.js} +63 -63
  17. package/dist/{diff-line-counts-7tSV8pEZ.js → diff-line-counts-DS3NTLT4.js} +2 -2
  18. package/dist/{diff-worker-task-BOwESZtp.js → diff-worker-task-baVi790r.js} +2 -2
  19. package/dist/diff-worker.js +5 -5
  20. package/dist/{directory-handle-rZKgRLvJ.js → directory-handle-BMcXjYE6.js} +3 -3
  21. package/dist/{dsh-plugins-CU5NOgp8.js → dsh-plugins-USLgdmAE.js} +34 -34
  22. package/dist/file-index-scan-worker.js +5 -5
  23. package/dist/{file-lock-BDk2nHD1.js → file-lock-yOQQBtqa.js} +64 -64
  24. package/dist/{index-CHejLb12.js → index-C1O07bhK.js} +64 -64
  25. package/dist/{index-CxVpJe-t.js → index-D26bOyO7.js} +4 -4
  26. package/dist/{index-2FWwoHbP.js → index-DsQYoKQ2.js} +229 -266
  27. package/dist/{index-CxSGZcPV.js → index-RFliQGDD.js} +64 -64
  28. package/dist/{index-DIx0_Tmf.js → index-uSRAGBc-.js} +73 -73
  29. package/dist/index.js +70 -69
  30. package/dist/{machine-identity-restore-DQGAyQGr.js → machine-identity-restore-BWpv7f9D.js} +42 -40
  31. package/dist/{process-DJHRUC0C.js → process-C4E1E8qi.js} +17 -12
  32. package/dist/{process-options-CwB784qP.js → process-options-CHoYaJLg.js} +68 -21
  33. package/dist/{register-Ckv3mOhI.js → register-CufZlhT9.js} +1629 -654
  34. package/dist/{remote-pairing-Betw2bE6.js → remote-pairing-CY6W6R8O.js} +47 -47
  35. package/dist/{reset-identity-D_5lqUCh.js → reset-identity-DZIX4A5a.js} +74 -74
  36. package/dist/{review-viewer-BxgCMlmh.js → review-viewer-GakvZFYc.js} +6 -6
  37. package/dist/{schedule-command-client-BYBOGR_C.js → schedule-command-client-CEcx8MjE.js} +5 -5
  38. package/dist/{telemetry-3aPi8ATd.js → telemetry-_bjS2EY9.js} +18765 -18373
  39. package/dist/{workspace-legacy-DYv8EYIc.js → workspace-legacy-BXA2kfWm.js} +546 -323
  40. package/package.json +4 -2
  41. package/dist/authority-clock-DKvmDgsy.js +0 -127
@@ -0,0 +1,480 @@
1
+ import fs__default from "node:fs/promises";
2
+ import path__default from "node:path";
3
+ import { randomUUID, createHash } from "node:crypto";
4
+ import { gunzipSync } from "node:zlib";
5
+ import { g as getLodyDataDir } from "./process-options-CHoYaJLg.js";
6
+ import { d4 as ManagedDaemonUpgradeOptionsSchema, d5 as DaemonReleaseSchema, d6 as resolveRuntimeArtifactsBaseUrl } from "./telemetry-_bjS2EY9.js";
7
+ import { o as object, c as string, a as literal, n as number, g as _enum } from "./chunks/vendor-zod-CBWGVFD-.js";
8
+ const digest = (bytes) => createHash("sha256").update(bytes).digest("hex");
9
+ const hash = string().regex(/^[a-f0-9]{64}$/);
10
+ const version = string().regex(/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/);
11
+ const ContextSchema = object({
12
+ metadata: object({
13
+ format: literal(1),
14
+ product: _enum(["lody-oss", "lody-cloud"]),
15
+ distribution: string().regex(/^[a-z][a-z0-9-]{0,79}$/),
16
+ version,
17
+ channel: _enum(["stable", "next", "nightly"]),
18
+ platform: string(),
19
+ serviceProtocol: literal(1),
20
+ payloadSha256: hash,
21
+ node: object({
22
+ sha256: hash,
23
+ size: number().int().positive(),
24
+ version: literal("26.13.0")
25
+ })
26
+ }),
27
+ nodePath: string(),
28
+ releaseDir: string(),
29
+ capsulePath: string()
30
+ });
31
+ function getSeaContext() {
32
+ const value = Reflect.get(globalThis, Symbol.for("lody.sea.context"));
33
+ const parsed = ContextSchema.safeParse(value);
34
+ return parsed.success ? parsed.data : null;
35
+ }
36
+ function getCliNodeExecutable() {
37
+ return getSeaContext()?.nodePath ?? process.execPath;
38
+ }
39
+ function managedDaemonRoot() {
40
+ return path__default.join(getLodyDataDir(), "daemon-managed");
41
+ }
42
+ function verifyDaemonRelease(raw, trust) {
43
+ const release = DaemonReleaseSchema.parse(JSON.parse(raw));
44
+ if (release.product !== trust.product || release.distribution !== (trust.distribution ?? `${trust.product}-daemon`) || release.platform !== `${process.platform}-${process.arch}`)
45
+ throw new Error("Daemon product/platform mismatch");
46
+ return release;
47
+ }
48
+ async function writeManagedRecord(file, value) {
49
+ await fs__default.mkdir(path__default.dirname(file), { recursive: true, mode: 448 });
50
+ const temporary = `${file}.${randomUUID()}.tmp`;
51
+ const fd = await fs__default.open(temporary, "wx", 384);
52
+ try {
53
+ await fd.writeFile(JSON.stringify(value) + "\n");
54
+ await fd.sync();
55
+ } finally {
56
+ await fd.close();
57
+ }
58
+ try {
59
+ await fs__default.rename(temporary, file);
60
+ if (process.platform !== "win32") {
61
+ const dir = await fs__default.open(path__default.dirname(file), "r");
62
+ try {
63
+ await dir.sync();
64
+ } finally {
65
+ await dir.close();
66
+ }
67
+ }
68
+ } finally {
69
+ await fs__default.rm(temporary, { force: true });
70
+ }
71
+ }
72
+ const OperationSchema = object({
73
+ format: literal(1),
74
+ requestId: string().min(1),
75
+ machineId: string().min(1),
76
+ serviceInstanceId: string().min(1),
77
+ targetVersion: version,
78
+ releaseDigest: hash,
79
+ previousVersion: version,
80
+ requestedTarget: string().min(1),
81
+ upgrade: ManagedDaemonUpgradeOptionsSchema.optional(),
82
+ expiresAtMs: number().finite().positive().optional(),
83
+ phase: _enum([
84
+ "preparing",
85
+ "prepared",
86
+ "waiting",
87
+ "switching",
88
+ "observing",
89
+ "applied",
90
+ "rollback-stop",
91
+ "rolled-back",
92
+ "blocked",
93
+ "failed"
94
+ ])
95
+ }).strict();
96
+ function operationFile(requestId) {
97
+ return path__default.join(managedDaemonRoot(), "operations", digest(Buffer.from(requestId)) + ".json");
98
+ }
99
+ async function readManagedOperation(requestId) {
100
+ try {
101
+ const selected = OperationSchema.parse(
102
+ JSON.parse(
103
+ await fs__default.readFile(
104
+ requestId ? operationFile(requestId) : path__default.join(managedDaemonRoot(), "operation.json"),
105
+ "utf8"
106
+ )
107
+ )
108
+ );
109
+ if (requestId && selected.requestId !== requestId)
110
+ throw new Error("Managed operation identity mismatch");
111
+ if (!requestId) return await readManagedOperation(selected.requestId) ?? selected;
112
+ return selected;
113
+ } catch (error) {
114
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
115
+ throw error;
116
+ }
117
+ }
118
+ async function saveManagedOperation(operation) {
119
+ const parsed = OperationSchema.parse(operation);
120
+ const existing = await readManagedOperation(parsed.requestId);
121
+ if (existing && (existing.machineId !== parsed.machineId || existing.serviceInstanceId !== parsed.serviceInstanceId || existing.releaseDigest !== parsed.releaseDigest || existing.targetVersion !== parsed.targetVersion || existing.requestedTarget !== parsed.requestedTarget || existing.expiresAtMs !== parsed.expiresAtMs || JSON.stringify(existing.upgrade) !== JSON.stringify(parsed.upgrade)))
122
+ throw new Error("Managed operation target is immutable");
123
+ await writeManagedRecord(path__default.join(managedDaemonRoot(), "operation.json"), parsed);
124
+ await writeManagedRecord(operationFile(parsed.requestId), parsed);
125
+ }
126
+ function initialManagedInstallation(context) {
127
+ return {
128
+ version: context.metadata.version,
129
+ channel: context.metadata.channel,
130
+ bin: path__default.join(context.releaseDir, "index.js"),
131
+ node: context.nodePath
132
+ };
133
+ }
134
+ function installationForRelease(release) {
135
+ return {
136
+ version: release.version,
137
+ channel: release.channel,
138
+ bin: path__default.join(managedDaemonRoot(), "payloads", release.payloadSha256, "index.js"),
139
+ node: path__default.join(
140
+ managedDaemonRoot(),
141
+ "nodes",
142
+ release.node.contentSha256,
143
+ process.platform === "win32" ? "node.exe" : "node"
144
+ ),
145
+ releaseDigest: release.capsule.contentSha256
146
+ };
147
+ }
148
+ async function checkInstallationFiles(release) {
149
+ const installation = installationForRelease(release);
150
+ const node = await fs__default.readFile(installation.node);
151
+ if (node.length !== release.node.contentSize || digest(node) !== release.node.contentSha256)
152
+ throw new Error("Managed Node identity mismatch");
153
+ const marker = await fs__default.readFile(path__default.join(path__default.dirname(installation.bin), ".complete"), "utf8");
154
+ if (marker !== release.payloadSha256) throw new Error("Incomplete daemon payload");
155
+ await fs__default.access(installation.bin);
156
+ }
157
+ async function readSelectedInstallation(context) {
158
+ try {
159
+ const selected = object({ format: literal(1), digest: hash.nullable() }).strict().parse(
160
+ JSON.parse(await fs__default.readFile(path__default.join(managedDaemonRoot(), "selected.json"), "utf8"))
161
+ );
162
+ if (selected.digest === null) return initialManagedInstallation(context);
163
+ const envelope = await fs__default.readFile(
164
+ path__default.join(managedDaemonRoot(), "releases", selected.digest, "manifest.json"),
165
+ "utf8"
166
+ );
167
+ const release = verifyDaemonRelease(envelope, context.metadata);
168
+ if (release.capsule.contentSha256 !== selected.digest)
169
+ throw new Error("Selected release identity mismatch");
170
+ await checkInstallationFiles(release);
171
+ return installationForRelease(release);
172
+ } catch (error) {
173
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
174
+ try {
175
+ await fs__default.access(path__default.join(managedDaemonRoot(), "selected.json"));
176
+ } catch (missing) {
177
+ if (missing instanceof Error && "code" in missing && missing.code === "ENOENT")
178
+ return initialManagedInstallation(context);
179
+ }
180
+ }
181
+ throw error;
182
+ }
183
+ }
184
+ async function downloadArtifact(url, description, destination, signal) {
185
+ try {
186
+ const cached = await fs__default.readFile(destination);
187
+ if (cached.length === description.contentSize && digest(cached) === description.contentSha256)
188
+ return;
189
+ throw new Error("Existing immutable daemon artifact is corrupt");
190
+ } catch (error) {
191
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
192
+ }
193
+ await fs__default.mkdir(path__default.dirname(destination), { recursive: true, mode: 448 });
194
+ const partial = destination + ".partial";
195
+ let failure;
196
+ let compressed;
197
+ for (let attempt = 0; attempt < 3; attempt++) {
198
+ signal?.throwIfAborted();
199
+ try {
200
+ let offset = await fs__default.stat(partial).then((stat) => stat.size).catch((error) => {
201
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return 0;
202
+ throw error;
203
+ });
204
+ if (offset > description.size) {
205
+ await fs__default.truncate(partial, 0);
206
+ offset = 0;
207
+ }
208
+ if (offset < description.size) {
209
+ const response = await fetch(url, {
210
+ headers: offset ? { Range: `bytes=${offset}-` } : void 0,
211
+ signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(12e4)]) : AbortSignal.timeout(12e4),
212
+ redirect: "error"
213
+ });
214
+ if (!response.body || response.status !== 200 && response.status !== 206) {
215
+ await response.body?.cancel().catch(() => {
216
+ });
217
+ throw new Error(`Daemon download failed: ${response.status}`);
218
+ }
219
+ if (response.status === 206 && response.headers.get("content-range") !== `bytes ${offset}-${description.size - 1}/${description.size}`) {
220
+ await response.body.cancel().catch(() => {
221
+ });
222
+ throw new Error("Invalid daemon download range");
223
+ }
224
+ if (response.status === 200) offset = 0;
225
+ const fd2 = await fs__default.open(partial, offset ? "a" : "w", 384);
226
+ const reader = response.body.getReader();
227
+ try {
228
+ for (; ; ) {
229
+ const item = await reader.read();
230
+ if (item.done) break;
231
+ offset += item.value.length;
232
+ if (offset > description.size) throw new Error("Oversized daemon artifact");
233
+ await fd2.writeFile(item.value);
234
+ }
235
+ await fd2.sync();
236
+ } finally {
237
+ await reader.cancel().catch(() => {
238
+ });
239
+ await fd2.close();
240
+ }
241
+ }
242
+ compressed = await fs__default.readFile(partial);
243
+ if (compressed.length !== description.size || digest(compressed) !== description.sha256) {
244
+ await fs__default.rm(partial, { force: true });
245
+ throw new Error("Daemon artifact digest mismatch");
246
+ }
247
+ break;
248
+ } catch (error) {
249
+ failure = error;
250
+ }
251
+ }
252
+ if (!compressed || compressed.length !== description.size || digest(compressed) !== description.sha256)
253
+ throw failure ?? new Error("Incomplete daemon artifact");
254
+ const content = gunzipSync(compressed, { maxOutputLength: description.contentSize });
255
+ if (content.length !== description.contentSize || digest(content) !== description.contentSha256)
256
+ throw new Error("Daemon executable digest mismatch");
257
+ await fs__default.mkdir(path__default.dirname(destination), { recursive: true, mode: 448 });
258
+ const temporary = `${destination}.${randomUUID()}.tmp`;
259
+ const fd = await fs__default.open(temporary, "wx", 448);
260
+ try {
261
+ await fd.writeFile(content);
262
+ await fd.sync();
263
+ } finally {
264
+ await fd.close();
265
+ }
266
+ try {
267
+ await fs__default.rename(temporary, destination);
268
+ await fs__default.rm(partial, { force: true });
269
+ } finally {
270
+ await fs__default.rm(temporary, { force: true });
271
+ }
272
+ }
273
+ async function prepareManagedRelease(context, target, options = {}) {
274
+ if (!/^(latest|next|nightly|\d+\.\d+\.\d+(?:-[\w.-]+)?)$/.test(target))
275
+ throw new Error("Invalid daemon target");
276
+ const base = resolveRuntimeArtifactsBaseUrl(options.baseUrl);
277
+ const channel = target === "latest" ? "stable" : target;
278
+ const floating = ["stable", "next", "nightly"].includes(channel);
279
+ const prefix = `${base}/api/runtimes/${context.metadata.distribution}`;
280
+ const url = floating ? `${prefix}/channels/${context.metadata.platform}/${channel}.json` : `${prefix}/${target}/${context.metadata.platform}/manifest.json`;
281
+ const response = await fetch(url, {
282
+ signal: options.signal ? AbortSignal.any([options.signal, AbortSignal.timeout(15e3)]) : AbortSignal.timeout(15e3),
283
+ redirect: "error"
284
+ });
285
+ if (!response.ok || !response.body) {
286
+ await response.body?.cancel().catch(() => {
287
+ });
288
+ throw new Error(`Daemon manifest unavailable: ${response.status}`);
289
+ }
290
+ const reader = response.body.getReader();
291
+ const chunks = [];
292
+ let manifestBytes = 0;
293
+ try {
294
+ for (; ; ) {
295
+ const item = await reader.read();
296
+ if (item.done) break;
297
+ manifestBytes += item.value.length;
298
+ if (manifestBytes > 131072) throw new Error("Oversized daemon manifest");
299
+ chunks.push(item.value);
300
+ }
301
+ } finally {
302
+ await reader.cancel().catch(() => {
303
+ });
304
+ }
305
+ const envelope = Buffer.concat(chunks).toString("utf8");
306
+ const release = verifyDaemonRelease(envelope, context.metadata);
307
+ if (floating ? release.channel !== channel : release.version !== target)
308
+ throw new Error("Daemon target mismatch");
309
+ await options.onResolved?.(release);
310
+ const directory = path__default.join(managedDaemonRoot(), "releases", release.capsule.contentSha256);
311
+ const capsule = path__default.join(directory, process.platform === "win32" ? "daemon.exe" : "daemon");
312
+ const releaseBase = `${prefix}/${release.version}/${release.platform}`;
313
+ await downloadArtifact(
314
+ `${releaseBase}/${release.capsule.file}`,
315
+ release.capsule,
316
+ capsule,
317
+ options.signal
318
+ );
319
+ await downloadArtifact(
320
+ `${releaseBase}/${release.node.file}`,
321
+ release.node,
322
+ installationForRelease(release).node,
323
+ options.signal
324
+ );
325
+ await writeManagedRecord(path__default.join(directory, "manifest.json"), release);
326
+ return { release, envelope, capsule };
327
+ }
328
+ const managedDaemonRelease = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
329
+ __proto__: null,
330
+ DaemonReleaseSchema,
331
+ checkInstallationFiles,
332
+ getCliNodeExecutable,
333
+ getSeaContext,
334
+ initialManagedInstallation,
335
+ installationForRelease,
336
+ managedDaemonRoot,
337
+ prepareManagedRelease,
338
+ readManagedOperation,
339
+ readSelectedInstallation,
340
+ saveManagedOperation,
341
+ verifyDaemonRelease,
342
+ writeManagedRecord
343
+ }, Symbol.toStringTag, { value: "Module" }));
344
+ const daemonLossProbeEnabled = false;
345
+ function createDaemonLossRegistry(enabled, pid = process.pid) {
346
+ const listeners = /* @__PURE__ */ new Set();
347
+ const rows = /* @__PURE__ */ new Map();
348
+ const changed = () => {
349
+ return;
350
+ };
351
+ const inspect = (workspaceId, requesterDevice) => {
352
+ rows.get(workspaceId);
353
+ return null;
354
+ };
355
+ return {
356
+ enabled,
357
+ changed,
358
+ inspect,
359
+ trackRaw(workspaceId, request) {
360
+ return;
361
+ },
362
+ register(scope, read, readAuthority) {
363
+ return void 0;
364
+ },
365
+ wait(workspaceId, afterSequence, signal, timeoutMs = 3e4, requesterDevice) {
366
+ return new Promise((resolve, reject) => {
367
+ let timer;
368
+ const initialOwner = rows.get(workspaceId)?.ownerInstance;
369
+ const cleanup = () => {
370
+ clearTimeout(timer);
371
+ listeners.delete(check);
372
+ signal?.removeEventListener("abort", aborted);
373
+ };
374
+ const fail = (code) => {
375
+ cleanup();
376
+ reject(new Error(code));
377
+ };
378
+ const aborted = () => fail("daemon_loss_aborted");
379
+ const check = () => {
380
+ try {
381
+ if (rows.get(workspaceId)?.ownerInstance !== initialOwner)
382
+ return fail("daemon_loss_owner_changed");
383
+ const value = inspect(workspaceId, requesterDevice);
384
+ if (!value) return fail("daemon_loss_missing");
385
+ if (value.status === "failed" || value.lossSequence > afterSequence && value.drained) {
386
+ cleanup();
387
+ resolve(value);
388
+ }
389
+ } catch {
390
+ fail("daemon_loss_unavailable");
391
+ }
392
+ };
393
+ if (signal?.aborted) {
394
+ aborted();
395
+ return;
396
+ }
397
+ timer = setTimeout(() => fail("daemon_loss_deadline"), timeoutMs);
398
+ listeners.add(check);
399
+ signal?.addEventListener("abort", aborted, { once: true });
400
+ check();
401
+ });
402
+ }
403
+ };
404
+ }
405
+ const daemonLossObserver = createDaemonLossRegistry(daemonLossProbeEnabled);
406
+ function createDaemonLossTasks(enabled = daemonLossProbeEnabled, changed = daemonLossObserver.changed) {
407
+ const tasks = enabled ? /* @__PURE__ */ new Set() : null;
408
+ return {
409
+ get size() {
410
+ return tasks?.size ?? 0;
411
+ },
412
+ track(work) {
413
+ if (!tasks) return work;
414
+ tasks.add(work);
415
+ changed();
416
+ const settled = () => {
417
+ tasks.delete(work);
418
+ changed();
419
+ };
420
+ void work.then(settled, settled);
421
+ return work;
422
+ }
423
+ };
424
+ }
425
+ const MAX_DERIVED_TURNS_PER_ORIGIN = 20;
426
+ const DERIVED_START_GRACE_MS = 15 * 6e4;
427
+ function decideEncryptedDerivation(input) {
428
+ if (input.live === "owner") return "owner";
429
+ if (input.verified === "owner" && input.live === void 0) return "owner";
430
+ if (input.verified === "member" && input.live === "member") {
431
+ if (input.targetMachineId !== input.machineId)
432
+ throw new Error("e2ee_derivation_cross_machine_unsupported");
433
+ return "member";
434
+ }
435
+ throw new Error("e2ee_derivation_denied");
436
+ }
437
+ const AUTHORITY_CLOCK_SKEW_MS = 6e4;
438
+ const authorityStamp = () => ({
439
+ wall: Date.now(),
440
+ monotonic: process.hrtime.bigint()
441
+ });
442
+ const elapsed = (start, now) => ({
443
+ wall: now.wall - start.wall,
444
+ monotonic: Number((now.monotonic - start.monotonic) / 1000000n)
445
+ });
446
+ const authorityClocksAgree = (start, now) => {
447
+ const { wall, monotonic } = elapsed(start, now);
448
+ return wall >= 0 && monotonic >= 0 && Math.abs(wall - monotonic) < AUTHORITY_CLOCK_SKEW_MS;
449
+ };
450
+ const withinAuthorityLimit = (start, now, limitMs) => {
451
+ const { wall, monotonic } = elapsed(start, now);
452
+ return authorityClocksAgree(start, now) && wall < limitMs && monotonic < limitMs;
453
+ };
454
+ const authorityTimeLeft = (start, now, limitMs) => {
455
+ const { wall, monotonic } = elapsed(start, now);
456
+ return limitMs - Math.max(wall, monotonic);
457
+ };
458
+ export {
459
+ DERIVED_START_GRACE_MS as D,
460
+ MAX_DERIVED_TURNS_PER_ORIGIN as M,
461
+ authorityClocksAgree as a,
462
+ authorityStamp as b,
463
+ createDaemonLossTasks as c,
464
+ daemonLossObserver as d,
465
+ decideEncryptedDerivation as e,
466
+ authorityTimeLeft as f,
467
+ getCliNodeExecutable as g,
468
+ getSeaContext as h,
469
+ writeManagedRecord as i,
470
+ readSelectedInstallation as j,
471
+ checkInstallationFiles as k,
472
+ installationForRelease as l,
473
+ managedDaemonRoot as m,
474
+ managedDaemonRelease as n,
475
+ prepareManagedRelease as p,
476
+ readManagedOperation as r,
477
+ saveManagedOperation as s,
478
+ withinAuthorityLimit as w
479
+ };
480
+ //# sourceMappingURL=authority-clock-YIVdHT4y.js.map
@@ -1,10 +1,10 @@
1
- import { s as startProcessLegacy, t as terminateChildTreeLegacy, b as runCommand, p as processLayer } from "./process-DJHRUC0C.js";
1
+ import { s as startProcessLegacy, t as terminateChildTreeLegacy, b as runCommand, p as processLayer } from "./process-C4E1E8qi.js";
2
2
  import { createServer } from "node:net";
3
3
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
4
4
  import { mkdtemp, writeFile, rm } from "node:fs/promises";
5
5
  import { tmpdir } from "node:os";
6
6
  import { join } from "node:path";
7
- import { cz as runPromise, bG as raceAll, v as promise, J as sleep, ak as provide } from "./chunks/vendor-effect-BcqAZ7RD.js";
7
+ import { cz as runPromise, bG as raceAll, v as promise, J as sleep, ak as provide } from "./chunks/vendor-effect-ygutZ0OR.js";
8
8
  import { c as string, o as object, u as union, g as _enum, n as number, a as literal } from "./chunks/vendor-zod-CBWGVFD-.js";
9
9
  import { I as IosSimulatorDeviceControlSchema } from "./ios-simulator-BJjtVdO8.js";
10
10
  import "node:child_process";
@@ -20,7 +20,7 @@ import "fs";
20
20
  import "./chunks/vendor-path-key-Dc8-E0k2.js";
21
21
  import "./chunks/vendor-shebang-command-CiljJy-j.js";
22
22
  import "./chunks/vendor-shebang-regex-CzQXTLh9.js";
23
- import "./chunks/vendor-@effect-platform-node-shared-C3vEQ-7m.js";
23
+ import "./chunks/vendor-@effect-platform-node-shared-BkNtLuZm.js";
24
24
  import "node:stream";
25
25
  import "node:buffer";
26
26
  import "node:tls";
@@ -1,4 +1,4 @@
1
- import { al as fromChannel, am as mapDone, an as fromTransform, a1 as succeed, K as flatMap, ao as callback, M as sync, L as void_, ap as forever, aq as identity, ar as catchDone, as as done, A as raceFirst, b as fail, at as fromChannel$1, au as make, av as as, aw as addFinalizer, R as fail$1, $ as suspend, ax as makeUnsafe, ay as of, az as UnknownError, aA as Done, aB as systemError, aj as effect, aC as FileSystem, a2 as map, aD as serviceOption, aE as WatchBackend, aF as make$1, aG as tryPromise, aH as acquireRelease, ab as orDie, aI as flatMap$1, aJ as getOrElse, aK as unwrap, aL as badArgument, aM as effectify, w as try_, aN as some, aO as bytes, aP as none, aQ as fromNullishOr, aR as pipe, f as fnUntraced, aS as callback$1, aT as toNumber, aU as FileTypeId, aV as offerUnsafe, aW as runFork, aX as matchEffect, aY as offer, aZ as failCauseUnsafe, X as fail$2, a_ as endUnsafe } from "./vendor-effect-BcqAZ7RD.js";
1
+ import { al as fromChannel, am as mapDone, an as fromTransform, a1 as succeed, K as flatMap, ao as callback, M as sync, L as void_, ap as forever, aq as identity, ar as catchDone, as as done, A as raceFirst, b as fail, at as fromChannel$1, au as make, av as as, aw as addFinalizer, S as fail$1, $ as suspend, ax as makeUnsafe, ay as of, az as UnknownError, aA as Done, aB as systemError, aj as effect, aC as FileSystem, a2 as map, aD as serviceOption, aE as WatchBackend, aF as make$1, aG as tryPromise, aH as acquireRelease, ab as orDie, aI as flatMap$1, aJ as getOrElse, aK as unwrap, aL as badArgument, aM as effectify, w as try_, aN as some, aO as bytes, aP as none, aQ as fromNullishOr, aR as pipe, f as fnUntraced, aS as callback$1, aT as toNumber, aU as FileTypeId, aV as offerUnsafe, aW as runFork, aX as matchEffect, aY as offer, aZ as failCauseUnsafe, X as fail$2, a_ as endUnsafe } from "./vendor-effect-ygutZ0OR.js";
2
2
  import "node:stream";
3
3
  import "node:child_process";
4
4
  import "node:buffer";
@@ -579,4 +579,4 @@ export {
579
579
  fromWritable as f,
580
580
  layer as l
581
581
  };
582
- //# sourceMappingURL=vendor-@effect-platform-node-shared-C3vEQ-7m.js.map
582
+ //# sourceMappingURL=vendor-@effect-platform-node-shared-BkNtLuZm.js.map
@@ -1,4 +1,4 @@
1
- import { h as gen, m as make, aw as addFinalizer, p as provide, a as make$1, a$ as make$2, b0 as cached, W as run, j as exit, N as close, Z as tap, M as sync, k as isFailure, c as combine, b1 as andThen, b2 as succeed, Q as asVoid, a9 as empty, I as doneUnsafe, L as void_, X as fail, b3 as isPromise, $ as suspend, i as interrupt, aG as tryPromise, b4 as catchIf, b5 as add, E as isSuccess, D as hasInterruptsOnly, K as flatMap, O as join, b6 as forEach, _ as _await, b7 as isDoneUnsafe, P as interruptible, a3 as TaggedError, S as void_$1, a4 as Service, a0 as succeed$1, a1 as succeed$2, a5 as Reference, f as fnUntraced, C as Clock, d as die, b8 as make$3, b as fail$1, e as make$4, aH as acquireRelease, v as promise, B as failCause, ab as orDie, u as mapError, ag as HttpClientError, ah as TransportError, A as raceFirst, J as sleep$1, z as makeUnsafe, y as timeoutOrElse, ao as callback, b9 as all, ad as ensuring, V as addFinalizer$1, U as catchCause, Y as uninterruptibleMask, R as fail$2, n as done, ba as failCause$1, af as fromWeb, bb as onExit, bc as acquireUseRelease, a7 as await_, bd as annotateCurrentSpan, be as withSpan, bf as onInterrupt, G as findErrorOption, o as make$5, bg as setHeaders, r as bearerToken, s as setHeader, t as provideService, T as TracerDisabledWhen } from "./vendor-effect-BcqAZ7RD.js";
1
+ import { h as gen, m as make, aw as addFinalizer, p as provide, a as make$1, a$ as make$2, b0 as cached, W as run, j as exit, N as close, O as void_, Z as tap, M as sync, k as isFailure, c as combine, b1 as andThen, b2 as succeed, R as asVoid, a9 as empty, I as doneUnsafe, L as void_$1, X as fail, b3 as isPromise, $ as suspend, i as interrupt, aG as tryPromise, b4 as catchIf, b5 as add, E as isSuccess, D as hasInterruptsOnly, K as flatMap, P as join, b6 as forEach, _ as _await, b7 as isDoneUnsafe, Q as interruptible, a3 as TaggedError, a4 as Service, a0 as succeed$1, a1 as succeed$2, a5 as Reference, f as fnUntraced, C as Clock, d as die, b8 as make$3, b as fail$1, e as make$4, aH as acquireRelease, v as promise, B as failCause, ab as orDie, u as mapError, ag as HttpClientError, ah as TransportError, A as raceFirst, J as sleep$1, z as makeUnsafe, y as timeoutOrElse, ao as callback, b9 as all, ad as ensuring, V as addFinalizer$1, U as catchCause, Y as uninterruptibleMask, S as fail$2, n as done, ba as failCause$1, af as fromWeb, bb as onExit, bc as acquireUseRelease, a7 as await_, bd as annotateCurrentSpan, be as withSpan, bf as onInterrupt, G as findErrorOption, o as make$5, bg as setHeaders, r as bearerToken, s as setHeader, t as provideService, T as TracerDisabledWhen } from "./vendor-effect-ygutZ0OR.js";
2
2
  const NETWORK_CODES = /* @__PURE__ */ new Set([
3
3
  "ENOTFOUND",
4
4
  "EAI_AGAIN",
@@ -620,7 +620,7 @@ var IoOwner = class IoOwner2 {
620
620
  const tasks = yield* provide(scope)(make$1());
621
621
  const recoveryTasks = yield* provide(recoveryScope)(make$1());
622
622
  const scopeClosed = yield* make$2();
623
- owner = new IoOwner2(scope, tasks, recoveryScope, yield* cached(run(recoveryTasks, exit(close(scope, void_$1)).pipe(tap((exit2) => sync(() => {
623
+ owner = new IoOwner2(scope, tasks, recoveryScope, yield* cached(run(recoveryTasks, exit(close(scope, void_)).pipe(tap((exit2) => sync(() => {
624
624
  if (isFailure(exit2)) owner.releaseCause = combine(owner.releaseCause, exit2.cause);
625
625
  })), andThen(succeed(scopeClosed, void 0)), asVoid), { startImmediately: false })), scopeClosed);
626
626
  return owner;
@@ -635,7 +635,7 @@ var IoOwner = class IoOwner2 {
635
635
  stopping = false;
636
636
  finish(raw) {
637
637
  this.raw.delete(raw);
638
- if (raw.done != null) doneUnsafe(raw.done, void_);
638
+ if (raw.done != null) doneUnsafe(raw.done, void_$1);
639
639
  }
640
640
  observe(raw, promise2, cleanup) {
641
641
  return promise2.then((value) => {
@@ -760,7 +760,7 @@ var IoOwner = class IoOwner2 {
760
760
  r.done ??= done2;
761
761
  yield* _await(r.done);
762
762
  }), { concurrency: "unbounded" });
763
- if (this.resources.size === 0) yield* close(this.recoveryScope, void_$1);
763
+ if (this.resources.size === 0) yield* close(this.recoveryScope, void_);
764
764
  });
765
765
  get pending() {
766
766
  return this.raw.size + this.resources.size + (this.tasks.state._tag === "Open" ? this.tasks.state.backing.size : 0) + (this.stopping && !isDoneUnsafe(this.scopeClosed) ? 1 : 0);
@@ -1017,7 +1017,7 @@ fnUntraced(function* (options = {}) {
1017
1017
  lastProgressAt = now();
1018
1018
  const previous = activity;
1019
1019
  activity = makeUnsafe();
1020
- doneUnsafe(previous, void_);
1020
+ doneUnsafe(previous, void_$1);
1021
1021
  };
1022
1022
  const observe = (program, phase, timeoutMs, startedAt2) => program.pipe(onExit((exit2) => sync(() => {
1023
1023
  if (requestId == null) return;
@@ -1156,7 +1156,7 @@ fnUntraced(function* (options = {}) {
1156
1156
  onActivity: () => {
1157
1157
  const previous = activity;
1158
1158
  activity = makeUnsafe();
1159
- doneUnsafe(previous, void_);
1159
+ doneUnsafe(previous, void_$1);
1160
1160
  },
1161
1161
  onRelease: (completion) => {
1162
1162
  owner.track(() => completion, true).catch(() => {
@@ -1263,7 +1263,7 @@ fnUntraced(function* (options = {}) {
1263
1263
  concurrency: "unbounded",
1264
1264
  discard: true
1265
1265
  }));
1266
- const settleRefresh = suspend(() => refreshWork == null ? void_ : bounded(join(refreshWork)).pipe(catchCause((cause) => fail$1(receipt(cause)))));
1266
+ const settleRefresh = suspend(() => refreshWork == null ? void_$1 : bounded(join(refreshWork)).pipe(catchCause((cause) => fail$1(receipt(cause)))));
1267
1267
  const launch = (done$1, work) => forkManaged(uninterruptibleMask((restore) => restore(work).pipe(exit, tap((exit2) => done(done$1, exit2)), asVoid))).pipe(tap((task) => sync(() => {
1268
1268
  if (done$1 === closeDone) closeWork = task;
1269
1269
  })), asVoid);
@@ -1280,7 +1280,7 @@ fnUntraced(function* (options = {}) {
1280
1280
  return _await(closeDone);
1281
1281
  }).pipe(withSafeSpan("StreamsHttp.close"));
1282
1282
  const retryRelease = suspend(() => {
1283
- if (retired && blocked == null && owners.size === 0) return void_;
1283
+ if (retired && blocked == null && owners.size === 0) return void_$1;
1284
1284
  if (recovery != null) return _await(recovery);
1285
1285
  recovery = makeUnsafe();
1286
1286
  const done2 = recovery;
@@ -1297,11 +1297,11 @@ fnUntraced(function* (options = {}) {
1297
1297
  blocked = void 0;
1298
1298
  if (closed) {
1299
1299
  closeDone = makeUnsafe();
1300
- doneUnsafe(closeDone, void_);
1300
+ doneUnsafe(closeDone, void_$1);
1301
1301
  }
1302
1302
  }).pipe(ensuring(sync(() => {
1303
1303
  recovery = void 0;
1304
- })))).pipe(flatMap(() => _await(done2)), flatMap(() => retired ? close(supervisionScope, void_$1) : void_));
1304
+ })))).pipe(flatMap(() => _await(done2)), flatMap(() => retired ? close(supervisionScope, void_) : void_$1));
1305
1305
  }).pipe(withSafeSpan("StreamsHttp.retryRelease"));
1306
1306
  const receipt = (cause = empty) => new StreamsHttpReleaseFailure({
1307
1307
  pending: pending(),
@@ -1323,7 +1323,7 @@ fnUntraced(function* (options = {}) {
1323
1323
  yield* addFinalizer$1(() => gen(function* () {
1324
1324
  retired = true;
1325
1325
  yield* close$1;
1326
- yield* close(supervisionScope, void_$1);
1326
+ yield* close(supervisionScope, void_);
1327
1327
  }).pipe(orDie));
1328
1328
  return http;
1329
1329
  });
@@ -3279,4 +3279,4 @@ export {
3279
3279
  safeRequestId as s,
3280
3280
  thrownToStreamError as t
3281
3281
  };
3282
- //# sourceMappingURL=vendor-@loro-dev-streams-client-B5HWGDv7.js.map
3282
+ //# sourceMappingURL=vendor-@loro-dev-streams-client-DzUskix-.js.map
@@ -1,5 +1,5 @@
1
- import { I as IoOwner, r as readSseEvents, d as decodeSsePayload, n as networkErrorCode, s as safeRequestId, S as StreamsClient, t as thrownToStreamError, c as createDiagnosticId } from "./vendor-@loro-dev-streams-client-B5HWGDv7.js";
2
- import { f as fnUntraced, C as Clock, d as die, m as make, p as provide, a as make$1, b as fail, c as combine, i as interrupt, e as make$2, g as forkIn, h as gen, j as exit, k as isFailure, l as fail$1, n as done, _ as _await, o as make$3, s as setHeader, q as bodyUint8Array, r as bearerToken, t as provideService, T as TracerDisabledWhen, u as mapError, v as promise, w as try_, x as never, y as timeoutOrElse, z as makeUnsafe, A as raceFirst, B as failCause, D as hasInterruptsOnly, E as isSuccess, F as yieldNow, G as findErrorOption, H as currentTimeMillis, I as doneUnsafe, J as sleep$1, K as flatMap, L as void_, M as sync, N as close, O as join, P as interruptible, Q as asVoid, R as fail$2, S as void_$1, U as catchCause, V as addFinalizer, W as run$1, X as fail$3, Y as uninterruptibleMask, Z as tap, $ as suspend, a0 as succeed, a1 as succeed$1, a2 as map, a3 as TaggedError, a4 as Service, a5 as Reference, a6 as isTimeoutError, a7 as await_, a8 as catch_, a9 as empty, aa as uninterruptible, ab as orDie, ac as makeUnsafe$1, ad as ensuring, ae as logDebug, af as fromWeb, ag as HttpClientError, ah as TransportError, ai as make$4, aj as effect, ak as provide$1 } from "./vendor-effect-BcqAZ7RD.js";
1
+ import { I as IoOwner, r as readSseEvents, d as decodeSsePayload, n as networkErrorCode, s as safeRequestId, S as StreamsClient, t as thrownToStreamError, c as createDiagnosticId } from "./vendor-@loro-dev-streams-client-DzUskix-.js";
2
+ import { f as fnUntraced, C as Clock, d as die, m as make, p as provide, a as make$1, b as fail, c as combine, i as interrupt, e as make$2, g as forkIn, h as gen, j as exit, k as isFailure, l as fail$1, n as done, _ as _await, o as make$3, s as setHeader, q as bodyUint8Array, r as bearerToken, t as provideService, T as TracerDisabledWhen, u as mapError, v as promise, w as try_, x as never, y as timeoutOrElse, z as makeUnsafe, A as raceFirst, B as failCause, D as hasInterruptsOnly, E as isSuccess, F as yieldNow, G as findErrorOption, H as currentTimeMillis, I as doneUnsafe, J as sleep$1, K as flatMap, L as void_, M as sync, N as close, O as void_$1, P as join, Q as interruptible, R as asVoid, S as fail$2, U as catchCause, V as addFinalizer, W as run$1, X as fail$3, Y as uninterruptibleMask, Z as tap, $ as suspend, a0 as succeed, a1 as succeed$1, a2 as map, a3 as TaggedError, a4 as Service, a5 as Reference, a6 as isTimeoutError, a7 as await_, a8 as catch_, a9 as empty, aa as uninterruptible, ab as orDie, ac as makeUnsafe$1, ad as ensuring, ae as logDebug, af as fromWeb, ag as HttpClientError, ah as TransportError, ai as make$4, aj as effect, ak as provide$1 } from "./vendor-effect-ygutZ0OR.js";
3
3
  import { f as LoroDoc, V as VersionVector, g as decodeImportBlobMeta } from "./vendor-loro-crdt-CcUjyH5H.js";
4
4
  import { F as Flock } from "./vendor-@loro-dev-flock-wasm-s93aGRSx.js";
5
5
  var __defProp = Object.defineProperty;
@@ -2070,12 +2070,11 @@ const makeEphemeralStream = fnUntraced(function* (options) {
2070
2070
  let req = make$3(method)(routed).pipe(setHeader(method === "GET" ? "accept" : "content-type", method === "GET" ? "text/event-stream" : "application/octet-stream"));
2071
2071
  if (update != null) req = bodyUint8Array(req, update);
2072
2072
  if (bearer) req = bearerToken(req, bearer);
2073
- yield* timed(client.execute(req).pipe(provideService(TracerDisabledWhen, () => true), mapError((error) => error.reason._tag === "TransportError" && error.reason.cause instanceof EphemeralFailure ? error.reason.cause : failure(error, "fetch"))), "fetch");
2073
+ const responseWrapper = yield* timed(client.execute(req).pipe(provideService(TracerDisabledWhen, () => true), mapError((error) => error.reason._tag === "TransportError" && error.reason.cause instanceof EphemeralFailure ? error.reason.cause : failure(error, "fetch"))), "fetch");
2074
2074
  const response = responses.get(req);
2075
- return {
2076
- response,
2077
- lease: leases.get(response)
2078
- };
2075
+ const lease = leases.get(response);
2076
+ if (lease != null) lease.responseWrapper = responseWrapper;
2077
+ return { response, lease };
2079
2078
  });
2080
2079
  const firstToken = yield* token({ reason: "request" });
2081
2080
  let result = yield* send(firstToken);
@@ -6325,4 +6324,4 @@ export {
6325
6324
  isValidRillId as i,
6326
6325
  makeEphemeralStream as m
6327
6326
  };
6328
- //# sourceMappingURL=vendor-@loro-dev-streams-crdt-e4yhr5Ky.js.map
6327
+ //# sourceMappingURL=vendor-@loro-dev-streams-crdt-DHMQIzWN.js.map
@@ -1,5 +1,5 @@
1
1
  import { p as parse$1 } from "./vendor-acorn-FBr7vWTA.js";
2
- import { a5 as Reference, bh as TaggedError, bi as String$1, bj as optionalKey, bk as Defect, bl as toJsonSchemaDocument, bm as isSchema, bn as parseUriFragment, bo as toType, bp as decodeUnknownSync, $ as suspend, h as gen, w as try_, M as sync, U as catchCause, D as hasInterruptsOnly, i as interrupt, b as fail, bq as prettyErrors, br as format, bb as onExit, E as isSuccess, bs as squash, b1 as andThen, bt as Struct, bu as NullOr, bv as ArraySchema, bw as Int, bx as isGreaterThanOrEqualTo, by as isGreaterThan, L as void_, bz as undefined_, bA as isEffect, a1 as succeed, a2 as map, K as flatMap, j as exit, B as failCause, b6 as forEach, g as forkIn, bB as catchDefect, d as die, a7 as await_, Q as asVoid, bC as interruptAll, bD as withFiber, ao as callback, ad as ensuring, Y as uninterruptibleMask, k as isFailure, Z as tap, F as yieldNow, av as as, I as doneUnsafe, R as fail$1, _ as _await, z as makeUnsafe, bE as succeed$1, b9 as all, bF as flatten, bG as raceAll, a8 as catch_, bH as matchCauseEffect, bI as isInterruptReason, t as provideService, b7 as isDoneUnsafe, y as timeoutOrElse, bc as acquireUseRelease, N as close, m as make$3, aG as tryPromise, u as mapError, bJ as Literals, bK as Number$1, bL as Json, bM as Boolean$1, bN as Literal, bO as Union, bP as decodeUnknownOption, bQ as fromJsonString, bR as Unknown } from "./vendor-effect-BcqAZ7RD.js";
2
+ import { a5 as Reference, bh as TaggedError, bi as String$1, bj as optionalKey, bk as Defect, bl as toJsonSchemaDocument, bm as isSchema, bn as parseUriFragment, bo as toType, bp as decodeUnknownSync, $ as suspend, h as gen, w as try_, M as sync, U as catchCause, D as hasInterruptsOnly, i as interrupt, b as fail, bq as prettyErrors, br as format, bb as onExit, E as isSuccess, bs as squash, b1 as andThen, bt as Struct, bu as NullOr, bv as ArraySchema, bw as Int, bx as isGreaterThanOrEqualTo, by as isGreaterThan, L as void_, bz as undefined_, bA as isEffect, a1 as succeed, a2 as map, K as flatMap, j as exit, B as failCause, b6 as forEach, g as forkIn, bB as catchDefect, d as die, a7 as await_, R as asVoid, bC as interruptAll, bD as withFiber, ao as callback, ad as ensuring, Y as uninterruptibleMask, k as isFailure, Z as tap, F as yieldNow, av as as, I as doneUnsafe, S as fail$1, _ as _await, z as makeUnsafe, bE as succeed$1, b9 as all, bF as flatten, bG as raceAll, a8 as catch_, bH as matchCauseEffect, bI as isInterruptReason, t as provideService, b7 as isDoneUnsafe, y as timeoutOrElse, bc as acquireUseRelease, N as close, m as make$3, aG as tryPromise, u as mapError, bJ as Literals, bK as Number$1, bL as Json, bM as Boolean$1, bN as Literal, bO as Union, bP as decodeUnknownOption, bQ as fromJsonString, bR as Unknown } from "./vendor-effect-ygutZ0OR.js";
3
3
  const CallSite = Reference("codemode/CallSite", {
4
4
  defaultValue: () => ({ depth: 0 })
5
5
  });
@@ -7212,4 +7212,4 @@ export {
7212
7212
  make as a,
7213
7213
  make$2 as m
7214
7214
  };
7215
- //# sourceMappingURL=vendor-@opencode-codemode-Bo8uQG1T.js.map
7215
+ //# sourceMappingURL=vendor-@opencode-codemode-B9CuiPYU.js.map