lody 0.112.0-nightly.2 → 0.112.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 +20 -3
  2. package/dist/{acp-interaction-owner-CiULN0Z2.js → acp-interaction-owner-DoEjKocA.js} +9 -9
  3. package/dist/{agent-execution-B3xPhd_I.js → agent-execution-lwZP67_X.js} +75 -35
  4. package/dist/{authority-clock-BZRIVoCe.js → authority-clock-DtVBffiE.js} +19 -25
  5. package/dist/baguette-worker.js +3 -3
  6. package/dist/chunks/{vendor-@effect-platform-node-shared-2lBwiIzn.js → vendor-@effect-platform-node-shared-C91Oo6pe.js} +2 -2
  7. package/dist/chunks/{vendor-@loro-dev-streams-client-1Yj3RVKk.js → vendor-@loro-dev-streams-client-DJ0h5YTP.js} +2 -2
  8. package/dist/chunks/{vendor-@loro-dev-streams-crdt-T5Tehg_z.js → vendor-@loro-dev-streams-crdt-BLmhRokm.js} +3 -3
  9. package/dist/chunks/{vendor-@opencode-codemode-C3CJ-7sd.js → vendor-@opencode-codemode-jXh7-qOh.js} +2 -2
  10. package/dist/chunks/{vendor-effect-PvNFaBIH.js → vendor-effect-SctpCzOj.js} +121 -112
  11. package/dist/chunks/{vendor-loro-repo-CkSgp_Vi.js → vendor-loro-repo-D6i7KLUp.js} +2 -2
  12. package/dist/claude-acp.js +66 -44
  13. package/dist/{client-Fs-WEcuQ.js → client-Bd4qavdP.js} +9 -9
  14. package/dist/{cloudflared-native-B1whhyCk.js → cloudflared-native-DjZHdvsA.js} +3 -3
  15. package/dist/cloudflared-worker.js +5 -5
  16. package/dist/{daemon-session-tools-Dq-Jq-kq.js → daemon-session-tools-cRK3xXKm.js} +9 -9
  17. package/dist/{diff-line-counts-Mp44NDcU.js → diff-line-counts-Cu6JdleF.js} +2 -2
  18. package/dist/{diff-worker-task-DTxl6DAQ.js → diff-worker-task-zCj0Y9fA.js} +2 -2
  19. package/dist/diff-worker.js +5 -5
  20. package/dist/{directory-handle-Cml3zTLb.js → directory-handle-C4eOXtlt.js} +3 -3
  21. package/dist/{dsh-plugins-2y_SBnoG.js → dsh-plugins-DpqSh3-O.js} +18 -18
  22. package/dist/file-index-scan-worker.js +5 -5
  23. package/dist/{file-lock-50Io-IF2.js → file-lock-PDoVkDHw.js} +10 -10
  24. package/dist/{index-Bi9UXveW.js → index-CYvWpkBg.js} +4 -4
  25. package/dist/{index-ycrVGzhi.js → index-CbKhafRj.js} +14 -14
  26. package/dist/{index-OrZQQKnS.js → index-Ch8_hyxo.js} +10 -10
  27. package/dist/{index-BkJLlFbH.js → index-DR0O0cQ9.js} +10 -10
  28. package/dist/{index-9sQ3mAD5.js → index-v7Ye3lmj.js} +19 -19
  29. package/dist/index.js +9 -9
  30. package/dist/{machine-identity-restore-CYpkZLmm.js → machine-identity-restore--FvAooVt.js} +18 -18
  31. package/dist/{process-CaS7MJ42.js → process-DaWJoKvh.js} +3 -3
  32. package/dist/{process-options-Ch7o7DJQ.js → process-options-BuZHtHzm.js} +12 -12
  33. package/dist/{realtime-journal-DvyGjm-o.js → realtime-journal-BlaIverm.js} +195 -4
  34. package/dist/{register-mRUI9jUs.js → register-CqS0IQRQ.js} +456 -203
  35. package/dist/{remote-pairing-BksKl_OS.js → remote-pairing-DVX6qr-3.js} +13 -13
  36. package/dist/{reset-identity-CDOmIVtL.js → reset-identity-BS6djjTa.js} +13 -13
  37. package/dist/{review-viewer-DtTxv0iI.js → review-viewer-CtzFQaC-.js} +6 -6
  38. package/dist/{schedule-command-client-BRJwkvmU.js → schedule-command-client-D7jUBEcM.js} +26 -9
  39. package/dist/{telemetry-BjI_4Kmq.js → telemetry-aaXBGmZf.js} +933 -757
  40. package/dist/{workspace-legacy-C8HXr8Uf.js → workspace-legacy-BJxTLS8t.js} +1017 -300
  41. package/package.json +1 -1
package/README.md CHANGED
@@ -87,13 +87,17 @@ lody e2ee journal reset --file /absolute/path/to/journal.sqlite --json
87
87
 
88
88
  The command works offline and returns `archivePath` and `journalPath`. It renames
89
89
  and preserves the old execution log, creates a fresh log, and retains old current-format
90
- request ID fences in the adjacent `.control.sqlite`. Keep that file and the archive;
90
+ request ID fences and root derivation quota receipts in the adjacent `.control.sqlite`.
91
+ Reset does not replenish the shared-member 20-start quota; Owner starts are unbounded. Reservations commit before starts; a
92
+ failed or interrupted start may consume a slot, while an exact retry reuses it.
93
+ Keep that file and the archive;
91
94
  unknown results are not automatically retried. Restart owners after reset. Retrying
92
95
  this command completes an interrupted reset using the same archive path.
93
96
 
94
97
  A clock error asks you to calibrate the system clock. Without trusted reference time,
95
- a bad observation can still reject new claims in its workspace until explicit reset;
96
- other workspaces and completed evidence remain available. Empty interrupted first
98
+ claims use the current local clock, so correcting a bad forward observation recovers
99
+ new claims without reset. Started request IDs still cannot execute twice, and
100
+ completed evidence remains available. Empty interrupted first
97
101
  creation initializes automatically. An unknown schema is archived and reported,
98
102
  then waits for explicit reset. An incomplete current-format store still retires all
99
103
  readable request keys before archival; unreadable current request keys refuse reset
@@ -118,6 +122,19 @@ once; a fallback timer doubles from one second to at most five minutes. Stop can
118
122
  watcher's delayed retry. A cancelled input that never started is retired in the journal.
119
123
  Member removal retains its identity-verified receipt/erasure path; single-device
120
124
  revocation closes the workspace while retaining local state.
125
+ After a crash, an encrypted start with no completion receipt is never replayed.
126
+ Recovery closes any partial assistant reply, fails the user turn and writes one
127
+ interruption notice per turn before returning the session to idle. Repeated
128
+ restarts keep that notice. Already terminal turns retain their outcome, and recovery
129
+ never replaces a newer handled pointer. An old turn's journal failure cannot block
130
+ an independently selected new turn. Check any external effects before sending a new message.
131
+ Iroh and Streams share live write completion signals, registered together with the
132
+ journal claim before invoking a handler. A duplicate waits for that owner within
133
+ its request deadline and returns the committed response frames. A retried encrypted
134
+ feature write with no live owner and an unknown outcome returns
135
+ `e2ee_outcome_uncertain`; it does not execute the write again. Sealed frames retained
136
+ after a persistence failure remain retryable across both receivers.
137
+
121
138
  Ordinary workspaces do not open this log.
122
139
  Transport frames keep their own original request/response receipts; execution evidence
123
140
  contains intent identities and a settlement marker, never prompt or response plaintext.
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
- import { aY as e2eeAcpInteractionInputContext, aZ as e2eeAcpInteractionResponseContext } from "./telemetry-BjI_4Kmq.js";
3
- import "./chunks/vendor-effect-PvNFaBIH.js";
2
+ import { aY as e2eeAcpInteractionInputContext, aZ as e2eeAcpInteractionResponseContext } from "./telemetry-aaXBGmZf.js";
3
+ import "./chunks/vendor-effect-SctpCzOj.js";
4
4
  import "./chunks/vendor-commander-B86VeeRa.js";
5
5
  import "node:events";
6
6
  import "node:child_process";
@@ -9,11 +9,11 @@ import "node:fs";
9
9
  import "node:process";
10
10
  import "./chunks/commonjs-helpers-CCIqAdii.js";
11
11
  import "./chunks/vendor-zod-CBWGVFD-.js";
12
- import "./chunks/vendor-@loro-dev-streams-client-1Yj3RVKk.js";
12
+ import "./chunks/vendor-@loro-dev-streams-client-DJ0h5YTP.js";
13
13
  import "node:fs/promises";
14
14
  import "./code-collab-COUEig0Z.js";
15
- import "./process-options-Ch7o7DJQ.js";
16
- import "./process-CaS7MJ42.js";
15
+ import "./process-options-BuZHtHzm.js";
16
+ import "./process-DaWJoKvh.js";
17
17
  import "node:url";
18
18
  import "./chunks/vendor-cross-spawn-BK3s9AWC.js";
19
19
  import "child_process";
@@ -24,7 +24,7 @@ import "fs";
24
24
  import "./chunks/vendor-path-key-Dc8-E0k2.js";
25
25
  import "./chunks/vendor-shebang-command-CiljJy-j.js";
26
26
  import "./chunks/vendor-shebang-regex-CzQXTLh9.js";
27
- import "./chunks/vendor-@effect-platform-node-shared-2lBwiIzn.js";
27
+ import "./chunks/vendor-@effect-platform-node-shared-C91Oo6pe.js";
28
28
  import "node:stream";
29
29
  import "node:buffer";
30
30
  import "node:net";
@@ -104,7 +104,7 @@ import "./chunks/vendor-micromark-factory-whitespace-Dg9BFbm3.js";
104
104
  import "./chunks/vendor-micromark-util-html-tag-name-CslaPeLE.js";
105
105
  import "./chunks/vendor-unist-util-stringify-position-DD2_lbmV.js";
106
106
  import "./chunks/vendor-mdast-util-to-string-cbiyYImb.js";
107
- import "./chunks/vendor-@loro-dev-streams-crdt-T5Tehg_z.js";
107
+ import "./chunks/vendor-@loro-dev-streams-crdt-BLmhRokm.js";
108
108
  import "./chunks/vendor-@loro-dev-flock-wasm-s93aGRSx.js";
109
109
  import "node:diagnostics_channel";
110
110
  import "./chunks/vendor-undici-BBneXIsH.js";
@@ -151,7 +151,7 @@ import "./chunks/vendor-@better-auth-api-key-Dy9PtbSj.js";
151
151
  import "./chunks/vendor-@convex-dev-better-auth-DvFvwHmk.js";
152
152
  import "perf_hooks";
153
153
  import "./chunks/vendor-ws-DSn-BAa0.js";
154
- import "./chunks/vendor-loro-repo-CkSgp_Vi.js";
154
+ import "./chunks/vendor-loro-repo-D6i7KLUp.js";
155
155
  import "better-sqlite3";
156
156
  import "./chunks/vendor-uuid-B-b1kXnZ.js";
157
157
  import "./chunks/vendor-@modelcontextprotocol-server-CRe5__5l.js";
@@ -503,4 +503,4 @@ function createAcpInteractionOwner(options) {
503
503
  export {
504
504
  createAcpInteractionOwner
505
505
  };
506
- //# sourceMappingURL=acp-interaction-owner-CiULN0Z2.js.map
506
+ //# sourceMappingURL=acp-interaction-owner-DoEjKocA.js.map
@@ -1,16 +1,16 @@
1
1
  import { existsSync } from "node:fs";
2
- import { RealtimeJournal, RealtimeJournalError } from "./realtime-journal-DvyGjm-o.js";
3
- import { M as MAX_DERIVED_TURNS_PER_ORIGIN } from "./authority-clock-BZRIVoCe.js";
4
- import { aW as turnExecutionDigest } from "./telemetry-BjI_4Kmq.js";
5
- import { f as fnUntraced, b as fail, a1 as succeed, w as try_, a2 as map } from "./chunks/vendor-effect-PvNFaBIH.js";
2
+ import { RealtimeJournal, RealtimeJournalError } from "./realtime-journal-BlaIverm.js";
3
+ import { aW as turnExecutionDigest } from "./telemetry-aaXBGmZf.js";
4
+ import { f as fnUntraced, b as fail, a1 as succeed, w as try_, a2 as map } from "./chunks/vendor-effect-SctpCzOj.js";
6
5
  import { o as object, f as array, c as string, j as unknown, z as tuple, a as literal } from "./chunks/vendor-zod-CBWGVFD-.js";
7
6
  import "node:crypto";
8
7
  import "node:path";
9
8
  import "better-sqlite3";
9
+ import "./authority-clock-DtVBffiE.js";
10
10
  import "node:fs/promises";
11
11
  import "node:zlib";
12
- import "./process-options-Ch7o7DJQ.js";
13
- import "./process-CaS7MJ42.js";
12
+ import "./process-options-BuZHtHzm.js";
13
+ import "./process-DaWJoKvh.js";
14
14
  import "node:child_process";
15
15
  import "node:url";
16
16
  import "./chunks/vendor-cross-spawn-BK3s9AWC.js";
@@ -23,7 +23,7 @@ import "fs";
23
23
  import "./chunks/vendor-path-key-Dc8-E0k2.js";
24
24
  import "./chunks/vendor-shebang-command-CiljJy-j.js";
25
25
  import "./chunks/vendor-shebang-regex-CzQXTLh9.js";
26
- import "./chunks/vendor-@effect-platform-node-shared-2lBwiIzn.js";
26
+ import "./chunks/vendor-@effect-platform-node-shared-C91Oo6pe.js";
27
27
  import "node:stream";
28
28
  import "node:buffer";
29
29
  import "node:net";
@@ -74,7 +74,7 @@ import "./chunks/vendor-moment-CvzSeL6T.js";
74
74
  import "node:util";
75
75
  import "./chunks/vendor-commander-B86VeeRa.js";
76
76
  import "node:process";
77
- import "./chunks/vendor-@loro-dev-streams-client-1Yj3RVKk.js";
77
+ import "./chunks/vendor-@loro-dev-streams-client-DJ0h5YTP.js";
78
78
  import "./code-collab-COUEig0Z.js";
79
79
  import "./ios-simulator-BJjtVdO8.js";
80
80
  import "node:async_hooks";
@@ -107,7 +107,7 @@ import "./chunks/vendor-micromark-factory-whitespace-Dg9BFbm3.js";
107
107
  import "./chunks/vendor-micromark-util-html-tag-name-CslaPeLE.js";
108
108
  import "./chunks/vendor-unist-util-stringify-position-DD2_lbmV.js";
109
109
  import "./chunks/vendor-mdast-util-to-string-cbiyYImb.js";
110
- import "./chunks/vendor-@loro-dev-streams-crdt-T5Tehg_z.js";
110
+ import "./chunks/vendor-@loro-dev-streams-crdt-BLmhRokm.js";
111
111
  import "./chunks/vendor-@loro-dev-flock-wasm-s93aGRSx.js";
112
112
  import "node:diagnostics_channel";
113
113
  import "./chunks/vendor-undici-BBneXIsH.js";
@@ -154,7 +154,7 @@ import "./chunks/vendor-@better-auth-api-key-Dy9PtbSj.js";
154
154
  import "./chunks/vendor-@convex-dev-better-auth-DvFvwHmk.js";
155
155
  import "perf_hooks";
156
156
  import "./chunks/vendor-ws-DSn-BAa0.js";
157
- import "./chunks/vendor-loro-repo-CkSgp_Vi.js";
157
+ import "./chunks/vendor-loro-repo-D6i7KLUp.js";
158
158
  import "./chunks/vendor-uuid-B-b1kXnZ.js";
159
159
  import "./chunks/vendor-@modelcontextprotocol-server-CRe5__5l.js";
160
160
  import "./chunks/vendor-@modelcontextprotocol-core-C9sSLfHz.js";
@@ -187,13 +187,13 @@ const intentSchema = object({
187
187
  localProjectIds: array(string().min(1)).optional()
188
188
  });
189
189
  function makeEncryptedAgentExecution(options) {
190
- const derivedClaims = /* @__PURE__ */ new Map();
191
190
  const hex64 = /^[0-9a-f]{64}$/;
191
+ const readOrigin = (ref) => options.resolveVerifiedOriginal(
192
+ { workspaceId: options.workspaceId, sessionId: ref.sessionId, userTurnId: ref.userTurnId },
193
+ { origin: true }
194
+ );
192
195
  const verifiedOrigin = fnUntraced(function* (ref) {
193
- const origin = yield* options.resolveVerifiedOriginal(
194
- { workspaceId: options.workspaceId, sessionId: ref.sessionId, userTurnId: ref.userTurnId },
195
- { origin: true }
196
- );
196
+ const origin = yield* readOrigin(ref);
197
197
  if (!origin || "state" in origin || !hex64.test(origin.requesterDevice)) return void 0;
198
198
  return origin;
199
199
  });
@@ -213,14 +213,26 @@ function makeEncryptedAgentExecution(options) {
213
213
  ...owner ? { principal: "owner" } : {}
214
214
  };
215
215
  });
216
- const classifyOrigin = fnUntraced(function* (ref) {
217
- const origin = yield* verifiedOrigin(ref);
218
- if (!origin || origin.derivedFrom || !options.authorizeExecution) return "denied";
219
- if (origin.requesterDevice === options.selfDevice) return "owner";
220
- const result = yield* options.authorizeExecution(options.workspaceId, origin.requesterDevice);
221
- if (result._tag === "Authorized") return result.principal === "owner" ? "owner" : "member";
222
- return result.reason === "e2ee_machine_not_shared" ? "member" : "denied";
216
+ const resolveDerivationOrigin = fnUntraced(function* (ref) {
217
+ const driving = yield* verifiedOrigin(ref);
218
+ if (!driving || !options.authorizeExecution) return void 0;
219
+ if (driving.derivedFrom && (driving.requesterDevice !== options.selfDevice || driving.schedule))
220
+ return void 0;
221
+ const rootRef = driving.derivedFrom ?? ref;
222
+ const root = driving.derivedFrom ? yield* verifiedOrigin(rootRef) : driving;
223
+ if (!root || root.derivedFrom || root.schedule && root.requesterDevice !== options.selfDevice || driving.derivedFrom && (root.machineAuthored || root.schedule || root.requesterDevice === options.selfDevice))
224
+ return void 0;
225
+ const grant = yield* options.authorizeExecution(options.workspaceId, root.requesterDevice);
226
+ if (grant._tag !== "Authorized" || grant.isCurrent?.() === false) return void 0;
227
+ if (root.machineAuthored && grant.principal !== "owner") return void 0;
228
+ return {
229
+ principal: grant.principal === "owner" ? "owner" : "member",
230
+ ...!root.machineAuthored && root.requesterDevice !== options.selfDevice ? { origin: rootRef } : {}
231
+ };
223
232
  });
233
+ const classifyOrigin = (ref) => resolveDerivationOrigin(ref).pipe(
234
+ map((resolved) => resolved?.principal ?? "denied")
235
+ );
224
236
  const authorizeAgentControl = (requesterDevice, localProjectIds) => options.authorizeExecution && hex64.test(requesterDevice) ? authorizeAll(
225
237
  options.authorizeExecution,
226
238
  options.workspaceId,
@@ -231,8 +243,16 @@ function makeEncryptedAgentExecution(options) {
231
243
  ) : succeed(false);
232
244
  const verifiedRequester = fnUntraced(function* (verified) {
233
245
  if (verified.derivedFrom) {
234
- const origin = yield* verifiedOrigin(verified.derivedFrom);
235
- return origin ? encryptedMemberRequester(origin.requesterCryptoUserId) : void 0;
246
+ const origin = yield* readOrigin(verified.derivedFrom);
247
+ if (origin && "state" in origin)
248
+ return origin.state === "pending-evidence" ? origin : void 0;
249
+ if (!origin || !hex64.test(origin.requesterDevice) || origin.derivedFrom || origin.machineAuthored || origin.schedule || origin.requesterDevice === options.selfDevice || !options.authorizeExecution)
250
+ return void 0;
251
+ const grant = yield* options.authorizeExecution(options.workspaceId, origin.requesterDevice);
252
+ if (grant._tag !== "Authorized")
253
+ return grant.reason === "unavailable" ? { state: "pending-evidence" } : void 0;
254
+ if (grant.isCurrent?.() === false) return void 0;
255
+ return grant.principal === "owner" ? options.machineUserId : encryptedMemberRequester(origin.requesterCryptoUserId);
236
256
  }
237
257
  if (verified.requesterDevice === options.selfDevice || !options.ledgerIdentity)
238
258
  return void 0;
@@ -245,6 +265,8 @@ function makeEncryptedAgentExecution(options) {
245
265
  return { state: verified.state === "refused" ? "denied" : "pending" };
246
266
  if (!verified) return { state: "denied" };
247
267
  const userId = yield* verifiedRequester(verified);
268
+ if (typeof userId === "object") return { state: "pending" };
269
+ if (verified.derivedFrom && userId === void 0) return { state: "denied" };
248
270
  return userId === void 0 ? {} : { userId };
249
271
  });
250
272
  const verifyRequesterAccess = fnUntraced(function* (requesterUserId, localProjectId) {
@@ -315,17 +337,17 @@ function makeEncryptedAgentExecution(options) {
315
337
  const authorizeExecution = options.authorizeExecution;
316
338
  if (!authorizeExecution) return { state: "denied" };
317
339
  let authorityDevice = verified.requesterDevice;
318
- let originKey;
340
+ let originRef;
319
341
  let originRequester;
320
342
  if (verified.derivedFrom) {
321
343
  if (!options.selfDevice || verified.requesterDevice !== options.selfDevice || verified.schedule)
322
344
  return { state: "denied" };
323
- const origin = yield* verifiedOrigin(verified.derivedFrom);
324
- if (!origin || origin.derivedFrom || origin.schedule || origin.requesterDevice === options.selfDevice)
325
- return { state: "denied" };
326
- originKey = JSON.stringify([verified.derivedFrom.sessionId, verified.derivedFrom.userTurnId]);
327
- if ((derivedClaims.get(originKey) ?? 0) >= MAX_DERIVED_TURNS_PER_ORIGIN)
345
+ const origin = yield* readOrigin(verified.derivedFrom);
346
+ if (origin && "state" in origin)
347
+ return { state: origin.state === "pending-evidence" ? "pending-evidence" : "denied" };
348
+ if (!origin || !hex64.test(origin.requesterDevice) || origin.derivedFrom || origin.machineAuthored || origin.schedule || origin.requesterDevice === options.selfDevice)
328
349
  return { state: "denied" };
350
+ originRef = verified.derivedFrom;
329
351
  authorityDevice = origin.requesterDevice;
330
352
  originRequester = encryptedMemberRequester(origin.requesterCryptoUserId);
331
353
  }
@@ -368,20 +390,21 @@ function makeEncryptedAgentExecution(options) {
368
390
  frame
369
391
  };
370
392
  const executionCurrent = authorization.isCurrent;
371
- const principal = originKey ? "derived" : authorization.principal === "owner" ? "owner" : "member";
393
+ const principal = originRef && authorization.principal !== "owner" ? "derived" : authorization.principal === "owner" ? "owner" : "member";
372
394
  if (principal !== "owner" && intent.requesterUserId === options.machineUserId)
373
395
  return { state: "denied" };
374
- const expectedRequester = !options.ledgerIdentity ? void 0 : originRequester ?? (verified.requesterDevice === options.selfDevice ? void 0 : principal === "owner" ? options.machineUserId : encryptedMemberRequester(verified.requesterCryptoUserId));
396
+ const expectedRequester = !options.ledgerIdentity ? void 0 : originRef && authorization.principal === "owner" ? options.machineUserId : originRequester ?? (verified.requesterDevice === options.selfDevice ? void 0 : principal === "owner" ? options.machineUserId : encryptedMemberRequester(verified.requesterCryptoUserId));
375
397
  if (expectedRequester !== void 0 && intent.requesterUserId !== expectedRequester)
376
398
  return { state: "denied" };
377
399
  return yield* attempt(() => {
378
400
  if (options.isExecutionOpen?.() === false || executionCurrent?.() === false || scheduleCurrent?.() === false)
379
401
  return { state: "denied" };
380
402
  journal.receive(request);
403
+ if (originRef && authorization.principal !== "owner" && !journal.reserveDerivation(request, originRef))
404
+ return { state: "denied" };
381
405
  const result = journal.claim(request);
382
406
  if (result.state === "expired") return { state: "denied" };
383
407
  if (result.state === "claimed") {
384
- if (originKey) derivedClaims.set(originKey, (derivedClaims.get(originKey) ?? 0) + 1);
385
408
  try {
386
409
  options.onClaim?.(intent.userTurnId);
387
410
  } catch {
@@ -392,7 +415,7 @@ function makeEncryptedAgentExecution(options) {
392
415
  } : {
393
416
  ...result,
394
417
  principal,
395
- ...principal === "member" ? { origin: { requesterDevice: authorityDevice } } : {}
418
+ ...principal === "member" || principal === "derived" ? { origin: { requesterDevice: authorityDevice } } : {}
396
419
  };
397
420
  });
398
421
  });
@@ -416,14 +439,31 @@ function makeEncryptedAgentExecution(options) {
416
439
  if (claimed.state === "claimed")
417
440
  journal.finish(claimed.permit, Buffer.from('{"state":"retired"}'));
418
441
  });
442
+ const readState = (input) => attempt(() => {
443
+ const record = options.journal().read({
444
+ genesis: options.genesis,
445
+ workspaceId: options.workspaceId,
446
+ targetMachineId: options.targetMachineId,
447
+ requestId: `agent-start:${input.userTurnId}`
448
+ });
449
+ if (!record) return void 0;
450
+ const saved = retainedIntentSchema.parse(
451
+ JSON.parse(Buffer.from(record.frame).toString("utf8"))
452
+ );
453
+ if (saved[1] !== input.sessionId || saved[2] !== input.userTurnId)
454
+ throw new RealtimeJournalError("identity_conflict");
455
+ return record.state;
456
+ });
419
457
  const complete = (permit) => attempt(() => {
420
458
  options.journal().finish(permit, Buffer.from('{"state":"settled"}'));
421
459
  });
422
460
  return {
423
461
  claim,
462
+ readState,
424
463
  complete,
425
464
  retire,
426
465
  classifyOrigin,
466
+ resolveDerivationOrigin,
427
467
  authorizeAgentControl,
428
468
  automationEvidence,
429
469
  resolveRequester,
@@ -452,4 +492,4 @@ export {
452
492
  lazyExecutionJournal,
453
493
  makeEncryptedAgentExecution
454
494
  };
455
- //# sourceMappingURL=agent-execution-B3xPhd_I.js.map
495
+ //# sourceMappingURL=agent-execution-lwZP67_X.js.map
@@ -3,9 +3,9 @@ import { constants, readFileSync, existsSync } from "node:fs";
3
3
  import path__default from "node:path";
4
4
  import { randomUUID, createHash } from "node:crypto";
5
5
  import { gunzipSync } from "node:zlib";
6
- import { g as getLodyDataDir, t as toShared } from "./process-options-Ch7o7DJQ.js";
7
- import { d7 as ManagedDaemonUpgradeOptionsSchema, d8 as DaemonReleaseSchema, d9 as resolveRuntimeArtifactsBaseUrl } from "./telemetry-BjI_4Kmq.js";
8
- import { i as isPidAliveSyncLegacy } from "./process-CaS7MJ42.js";
6
+ import { g as getLodyDataDir, t as toShared } from "./process-options-BuZHtHzm.js";
7
+ import { d7 as ManagedDaemonUpgradeOptionsSchema, d8 as DaemonReleaseSchema, d9 as resolveRuntimeArtifactsBaseUrl } from "./telemetry-aaXBGmZf.js";
8
+ import { i as isPidAliveSyncLegacy } from "./process-DaWJoKvh.js";
9
9
  import { o as object, c as string, a as literal, n as number, g as _enum } from "./chunks/vendor-zod-CBWGVFD-.js";
10
10
  const digest = (bytes) => createHash("sha256").update(bytes).digest("hex");
11
11
  const hash = string().regex(/^[a-f0-9]{64}$/);
@@ -513,7 +513,7 @@ function createDaemonLossTasks(enabled = daemonLossProbeEnabled, changed = daemo
513
513
  }
514
514
  const MAX_DERIVED_TURNS_PER_ORIGIN = 20;
515
515
  function decideEncryptedDerivation(input) {
516
- if (input.live === "owner") return "owner";
516
+ if (input.live === "owner" && input.verified === "owner") return "owner";
517
517
  if (input.verified === "owner" && input.live === void 0) return "owner";
518
518
  if (input.verified === "member" && input.live === "member") {
519
519
  if (input.targetMachineId !== input.machineId)
@@ -522,7 +522,6 @@ function decideEncryptedDerivation(input) {
522
522
  }
523
523
  throw new Error("e2ee_derivation_denied");
524
524
  }
525
- const AUTHORITY_CLOCK_SKEW_MS = 6e4;
526
525
  const authorityStamp = () => ({
527
526
  wall: Date.now(),
528
527
  monotonic: process.hrtime.bigint()
@@ -531,13 +530,9 @@ const elapsed = (start, now) => ({
531
530
  wall: now.wall - start.wall,
532
531
  monotonic: Number((now.monotonic - start.monotonic) / 1000000n)
533
532
  });
534
- const authorityClocksAgree = (start, now) => {
535
- const { wall, monotonic } = elapsed(start, now);
536
- return wall >= 0 && monotonic >= 0 && Math.abs(wall - monotonic) < AUTHORITY_CLOCK_SKEW_MS;
537
- };
538
533
  const withinAuthorityLimit = (start, now, limitMs) => {
539
534
  const { wall, monotonic } = elapsed(start, now);
540
- return authorityClocksAgree(start, now) && wall < limitMs && monotonic < limitMs;
535
+ return monotonic >= 0 && Math.max(wall, monotonic) < limitMs;
541
536
  };
542
537
  const authorityTimeLeft = (start, now, limitMs) => {
543
538
  const { wall, monotonic } = elapsed(start, now);
@@ -545,28 +540,27 @@ const authorityTimeLeft = (start, now, limitMs) => {
545
540
  };
546
541
  export {
547
542
  MAX_DERIVED_TURNS_PER_ORIGIN as M,
548
- authorityClocksAgree as a,
549
- authorityStamp as b,
543
+ authorityStamp as a,
544
+ decideEncryptedDerivation as b,
550
545
  createDaemonLossTasks as c,
551
546
  daemonLossObserver as d,
552
- decideEncryptedDerivation as e,
553
- authorityTimeLeft as f,
547
+ authorityTimeLeft as e,
548
+ getSeaContext as f,
554
549
  getCliNodeExecutable as g,
555
- getSeaContext as h,
556
- resolvePublishedManagedService as i,
557
- installFixedServiceEntry as j,
558
- readSelectedInstallation as k,
559
- checkInstallationFiles as l,
550
+ resolvePublishedManagedService as h,
551
+ installFixedServiceEntry as i,
552
+ readSelectedInstallation as j,
553
+ checkInstallationFiles as k,
554
+ installationForRelease as l,
560
555
  managedDaemonRoot as m,
561
- installationForRelease as n,
562
- npmMigrationTrust as o,
556
+ npmMigrationTrust as n,
557
+ writeManagedRecord as o,
563
558
  publishManagedInstallation as p,
564
- writeManagedRecord as q,
559
+ prepareManagedRelease as q,
565
560
  readManagedOperation as r,
566
561
  saveManagedOperation as s,
567
- prepareManagedRelease as t,
568
- managedDaemonRelease as u,
562
+ managedDaemonRelease as t,
569
563
  verifyDaemonRelease as v,
570
564
  withinAuthorityLimit as w
571
565
  };
572
- //# sourceMappingURL=authority-clock-BZRIVoCe.js.map
566
+ //# sourceMappingURL=authority-clock-DtVBffiE.js.map
@@ -1,10 +1,10 @@
1
- import { s as startProcessLegacy, t as terminateChildTreeLegacy, b as runCommand, p as processLayer } from "./process-CaS7MJ42.js";
1
+ import { s as startProcessLegacy, t as terminateChildTreeLegacy, b as runCommand, p as processLayer } from "./process-DaWJoKvh.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-PvNFaBIH.js";
7
+ import { cz as runPromise, bG as raceAll, v as promise, J as sleep, ak as provide } from "./chunks/vendor-effect-SctpCzOj.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-2lBwiIzn.js";
23
+ import "./chunks/vendor-@effect-platform-node-shared-C91Oo6pe.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, 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-PvNFaBIH.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-SctpCzOj.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-2lBwiIzn.js.map
582
+ //# sourceMappingURL=vendor-@effect-platform-node-shared-C91Oo6pe.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, 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-PvNFaBIH.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-SctpCzOj.js";
2
2
  const NETWORK_CODES = /* @__PURE__ */ new Set([
3
3
  "ENOTFOUND",
4
4
  "EAI_AGAIN",
@@ -3279,4 +3279,4 @@ export {
3279
3279
  safeRequestId as s,
3280
3280
  thrownToStreamError as t
3281
3281
  };
3282
- //# sourceMappingURL=vendor-@loro-dev-streams-client-1Yj3RVKk.js.map
3282
+ //# sourceMappingURL=vendor-@loro-dev-streams-client-DJ0h5YTP.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-1Yj3RVKk.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-PvNFaBIH.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-DJ0h5YTP.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-SctpCzOj.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;
@@ -6324,4 +6324,4 @@ export {
6324
6324
  isValidRillId as i,
6325
6325
  makeEphemeralStream as m
6326
6326
  };
6327
- //# sourceMappingURL=vendor-@loro-dev-streams-crdt-T5Tehg_z.js.map
6327
+ //# sourceMappingURL=vendor-@loro-dev-streams-crdt-BLmhRokm.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_, 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-PvNFaBIH.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-SctpCzOj.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-C3CJ-7sd.js.map
7215
+ //# sourceMappingURL=vendor-@opencode-codemode-jXh7-qOh.js.map