lody 0.115.0 → 0.116.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 (145) hide show
  1. package/dist/{access-Sut1_1-c.js → access-DIhEb_MP.js} +333 -314
  2. package/dist/{acp-interaction-owner-uSfNzpiU.js → acp-interaction-owner-8OMcZVET.js} +33 -33
  3. package/dist/{agent-execution-D1-dEIN6.js → agent-execution-ZTPT3A88.js} +13 -13
  4. package/dist/{analytics-events-BQIrmfJp.js → analytics-events-BNLOju7l.js} +2 -2
  5. package/dist/{app-J2sTmsZo.js → app-DzrwnZPK.js} +34 -34
  6. package/dist/{application-runtime-BPgp9fKR.js → application-runtime-4EGQJvLm.js} +2 -2
  7. package/dist/{auth-CTegS0TL.js → auth-CA7u_ijj.js} +8 -8
  8. package/dist/{automation-BL7x_nUm.js → automation-ClFKwWKg.js} +34 -34
  9. package/dist/baguette-worker.js +6 -6
  10. package/dist/chunks/{vendor-@agentclientprotocol-sdk-CpxTRW1f.js → vendor-@agentclientprotocol-sdk-54yhgJSn.js} +2 -2
  11. package/dist/chunks/{vendor-@anthropic-ai-claude-agent-sdk-B0HhZ112.js → vendor-@anthropic-ai-claude-agent-sdk-NAjHQcVv.js} +27 -3
  12. package/dist/chunks/{vendor-@better-auth-api-key-D0bKvhcn.js → vendor-@better-auth-api-key-Dy9PtbSj.js} +2 -2
  13. package/dist/chunks/{vendor-@better-auth-core-Dpzqxq_j.js → vendor-@better-auth-core-C7hql1k7.js} +8 -8
  14. package/dist/chunks/{vendor-@effect-platform-node-shared-DkrmBObz.js → vendor-@effect-platform-node-shared-DUSlMsdQ.js} +2 -2
  15. package/dist/chunks/{vendor-@loro-dev-streams-client-DPTfaXHE.js → vendor-@loro-dev-streams-client-DkeRiNAY.js} +1329 -88
  16. package/dist/chunks/{vendor-@loro-dev-streams-crdt-BOuVa3yO.js → vendor-@loro-dev-streams-crdt-CsXRvQxK.js} +861 -322
  17. package/dist/chunks/{vendor-@modelcontextprotocol-client-B_Q9G9Ku.js → vendor-@modelcontextprotocol-client-DuJtk4js.js} +3 -3
  18. package/dist/chunks/{vendor-@modelcontextprotocol-core-CW-vRGZP.js → vendor-@modelcontextprotocol-core-BkUcdvo6.js} +2 -2
  19. package/dist/chunks/{vendor-@modelcontextprotocol-node-CSCPUEbv.js → vendor-@modelcontextprotocol-node-D0s30TCx.js} +2 -2
  20. package/dist/chunks/{vendor-@modelcontextprotocol-server-BA5N3RYD.js → vendor-@modelcontextprotocol-server-C9c_OMTp.js} +3 -3
  21. package/dist/chunks/{vendor-@opencode-codemode-61MXX511.js → vendor-@opencode-codemode-DmkYINkB.js} +2 -2
  22. package/dist/chunks/{vendor-@sorbetai-artifacts-Dt9BTK8Q.js → vendor-@sorbetai-artifacts-Vz3r0uhj.js} +3 -3
  23. package/dist/chunks/{vendor-@sorbetai-context-COh8_Kmc.js → vendor-@sorbetai-context-BV7q3KwO.js} +2 -2
  24. package/dist/chunks/{vendor-@sorbetai-control-HcZa4Y-V.js → vendor-@sorbetai-control-C9pxQF9a.js} +137 -51
  25. package/dist/chunks/{vendor-@sorbetai-plugins-Bs93fyHc.js → vendor-@sorbetai-plugins-COkYjDxn.js} +3 -3
  26. package/dist/chunks/{vendor-@sorbetai-runtime-kicj4Xs_.js → vendor-@sorbetai-runtime-DKAfUiS0.js} +172 -60
  27. package/dist/chunks/{vendor-@sorbetai-schema-BYxzbt6U.js → vendor-@sorbetai-schema-D53JJ0HJ.js} +2 -2
  28. package/dist/chunks/{vendor-better-auth-PQ6PT4aF.js → vendor-better-auth-D1bP-dEy.js} +2 -2
  29. package/dist/chunks/{vendor-effect-CNM-5PoN.js → vendor-effect-BTVRmkqM.js} +418 -418
  30. package/dist/chunks/{vendor-es-toolkit-DnvFX_hl.js → vendor-es-toolkit-BDp9OdLC.js} +4 -4
  31. package/dist/chunks/{vendor-loro-repo-B1zdQ8Qd.js → vendor-loro-repo-DbOhEZ39.js} +2166 -93
  32. package/dist/chunks/{vendor-zod-DAcQjQuC.js → vendor-zod-nebGZ0VM.js} +6 -6
  33. package/dist/claude-acp.js +28 -7
  34. package/dist/{cli-platform-Cfc6A61f.js → cli-platform-qpp4fxi7.js} +6 -6
  35. package/dist/{cli-presence-application-D2Dn0fPM.js → cli-presence-application-Cw9rnD3u.js} +18 -18
  36. package/dist/{client-BsIzN-iC.js → client-09TiIsd2.js} +33 -33
  37. package/dist/{cloudflared-native-DmvSYnMb.js → cloudflared-native-Ber1sIlU.js} +4 -4
  38. package/dist/cloudflared-worker.js +7 -7
  39. package/dist/{code-collab-Cgso3Ix3.js → code-collab-DRoDl8u7.js} +3 -3
  40. package/dist/codex-acp.js +2 -1
  41. package/dist/{command-runtime-C7EPuHLe.js → command-runtime-CYs2KAyh.js} +774 -224
  42. package/dist/{const-LYLptZ7f.js → const-C9yql4zo.js} +2 -2
  43. package/dist/{control-CgRxpxvc.js → control-HMzEZJTm.js} +36 -36
  44. package/dist/{cross-workspace-D6-aE1-w.js → cross-workspace-CEB-pWmO.js} +3 -3
  45. package/dist/{daemon-runner-Bn8O9-a0.js → daemon-runner-BHgvKJ_l.js} +27 -27
  46. package/dist/{daemon-DWm2IzH9.js → daemon-s8LqFNYd.js} +30 -30
  47. package/dist/{daemon-session-tools-BSAgq4O1.js → daemon-session-tools-CrxHUVDk.js} +46 -46
  48. package/dist/{daemon-shared-NcwWGSEj.js → daemon-shared-BGfDcTED.js} +10 -10
  49. package/dist/{daemon-update-qOLnkZcv.js → daemon-update-BjGbzSFc.js} +2 -2
  50. package/dist/deepseek-acp.js +14 -2
  51. package/dist/{deepseek-harness-runtime-D6lV9pxi.js → deepseek-harness-runtime-CtfyKY7w.js} +8 -8
  52. package/dist/{deepseek-system-node-C2YpUQwp.js → deepseek-system-node-CBHH8N-Z.js} +4 -4
  53. package/dist/{device-preview-BjqAbZ9g.js → device-preview-WVdriBmC.js} +36 -11
  54. package/dist/devin-acp.js +2 -1
  55. package/dist/{diff-line-counts-ClicfZ_E.js → diff-line-counts-C7vhQioX.js} +2 -2
  56. package/dist/{diff-worker-task-BVD3EgeO.js → diff-worker-task-wwEm25bo.js} +2 -2
  57. package/dist/diff-worker.js +5 -5
  58. package/dist/{discovery-query-C_7lyBI8.js → discovery-query-6rvHO0Ax.js} +4 -4
  59. package/dist/{dsh-DVyIAYZ9.js → dsh-D8jYqbih.js} +9 -9
  60. package/dist/{dsh-plugins-Dfsqsiu7.js → dsh-plugins-BGuhIgPz.js} +15 -15
  61. package/dist/{e2ee-CslOKVIM.js → e2ee-BDxs5Gma.js} +3 -3
  62. package/dist/{e2ee-execution-intent-DYBEG410.js → e2ee-execution-intent-BTTWEaTs.js} +4 -4
  63. package/dist/{export-C-zeWP1i.js → export-BVe6KJcH.js} +40 -40
  64. package/dist/{feedback-Dde39k5W.js → feedback-8RRkLuXP.js} +34 -34
  65. package/dist/{feedback-jvl2Dz8w.js → feedback-Da3aBQ2E.js} +4 -4
  66. package/dist/{file-index-scan-core-Bta7tnbY.js → file-index-scan-core-QNHdA1nq.js} +5 -5
  67. package/dist/file-index-scan-worker.js +8 -8
  68. package/dist/{file-lock-By0YSSDw.js → file-lock-Oeerthnp.js} +9 -9
  69. package/dist/{github-BtMkInqL.js → github-B3lOSLjx.js} +33 -33
  70. package/dist/grok-acp.js +2 -1
  71. package/dist/{http-transport-C1f1XEnB.js → http-transport-3J_3rzKQ.js} +6 -6
  72. package/dist/{index-C41WZg1y.js → index-C5TYbo5p.js} +2 -2
  73. package/dist/{index-CitAbDql.js → index-CNsJ2gEh.js} +19 -6
  74. package/dist/{index-BUam8GIX.js → index-CbO2HBCx.js} +35 -35
  75. package/dist/{index-Ce9khNjj.js → index-CvTdgB45.js} +87 -75
  76. package/dist/{index-BsfKnSuo.js → index-CzJfh76P.js} +991 -964
  77. package/dist/index-DdJk9U2O.js +202 -0
  78. package/dist/{index-Dy-FYtdl.js → index-DtKSPvAx.js} +41 -41
  79. package/dist/{index-CZG5q6QS.js → index-PK9ed2VJ.js} +4 -4
  80. package/dist/{index-CwHleXV2.js → index-Z-EXLH2-.js} +2 -2
  81. package/dist/index.js +15 -15
  82. package/dist/{internal-BPOwohVc.js → internal-210PnQHj.js} +48 -48
  83. package/dist/{ios-simulator-BduF_qia.js → ios-simulator-B8Edygo_.js} +10 -10
  84. package/dist/{local-cli-host-lease-Chm4-jV0.js → local-cli-host-lease-BcOQ-7Gk.js} +3 -3
  85. package/dist/{local-ipc-B8vySppK.js → local-ipc-BNwkKO5i.js} +156 -103
  86. package/dist/{local-project-control-client-CIBpaXbo.js → local-project-control-client-BKaZlhrn.js} +5 -5
  87. package/dist/{lody-mcp-http-protocol-DBLKn7SZ.js → lody-mcp-http-protocol-C24PR-58.js} +46 -10
  88. package/dist/{lody-mcp-server-B4OeNPT4.js → lody-mcp-server-C_KUMdUq.js} +84 -39
  89. package/dist/{logger-C-G7jpWR.js → logger-zm-QQb1B.js} +2 -2
  90. package/dist/{login-Df1IkdeV.js → login-DoRU06W8.js} +18 -18
  91. package/dist/{login-shell-env-HKDW5zwx.js → login-shell-env-CFLesG20.js} +6 -6
  92. package/dist/{logout-gDuSiB0l.js → logout-4T76xG1C.js} +18 -18
  93. package/dist/{machine-bjdZ1hmy.js → machine-BFM6JQSw.js} +42 -42
  94. package/dist/{machine-identity-restore-BuoxXyiw.js → machine-identity-restore-CYjkTQcN.js} +3 -3
  95. package/dist/{machine-protocol-capabilities-DEhAj9SH.js → machine-protocol-capabilities-DcJpLvsC.js} +68 -47
  96. package/dist/{magpie-import-IrqfCF6i.js → magpie-import-CsiqaviF.js} +52 -50
  97. package/dist/{managed-daemon-forwarding-BpXhy_-O.js → managed-daemon-forwarding-D10w26x_.js} +9 -9
  98. package/dist/{managed-daemon-release-CwkvVtSj.js → managed-daemon-release-Bq0NQ5KB.js} +8 -8
  99. package/dist/{mcp-DTnh_PAT.js → mcp-CFSVE37k.js} +39 -39
  100. package/dist/{migrate-CUdZ3XBR.js → migrate-D0JGnFDi.js} +40 -38
  101. package/dist/{open-browser-3TOC7G1u.js → open-browser-CXJ_k8PZ.js} +3 -3
  102. package/dist/{operation-CzLcjV3W.js → operation-CjjYD8KR.js} +35 -35
  103. package/dist/{operation-store-rllAX2mr.js → operation-store-CjW-plfi.js} +6 -6
  104. package/dist/{presence-CZco7UQH.js → presence-DfPa6xSX.js} +95 -71
  105. package/dist/{presence-legacy-DIYBtj5j.js → presence-legacy-B7H0xyqf.js} +5 -5
  106. package/dist/{process-DrX1wZZk.js → process-BU5vWwzZ.js} +3 -3
  107. package/dist/{process-options-DNYWY_s6.js → process-options-CvxupoAj.js} +4 -4
  108. package/dist/{project-C_EZ2dLN.js → project-DbFdl-Tc.js} +41 -41
  109. package/dist/{project-path-CAQE9bes.js → project-path-BylnHhzQ.js} +11 -11
  110. package/dist/{realtime-journal-DyMe8jsR.js → realtime-journal-D5hdU6Fc.js} +2 -2
  111. package/dist/{register-VLBUVPh5.js → register-DzkfcD0R.js} +33 -33
  112. package/dist/{registry-generated-wkLapT7U.js → registry-generated-BtQFYqS0.js} +30 -30
  113. package/dist/{remote-pairing-D24xSpRh.js → remote-pairing-B-1pCVbn.js} +40 -40
  114. package/dist/{reset-identity-DVubJrt0.js → reset-identity-BKSdKzDv.js} +40 -40
  115. package/dist/{review-6aCgWEdv.js → review-DHDdCwwj.js} +9 -9
  116. package/dist/{review-viewer-CRYK94SE.js → review-viewer-DO7rhsH9.js} +3 -3
  117. package/dist/{rpc-secret-CPdan_XW.js → rpc-secret-Ds9rnsWf.js} +2 -2
  118. package/dist/{runtime-diagnostics-5l1pBD3m.js → runtime-diagnostics-BElvgU5u.js} +5 -5
  119. package/dist/{schedule-CGTbG70S.js → schedule-C-UJnfpM.js} +39 -39
  120. package/dist/{schedule-command-client-C6matZWn.js → schedule-command-client-B2k5ix1s.js} +38 -38
  121. package/dist/{schedule-command-service-2gToipBI.js → schedule-command-service-pFq9cQHf.js} +134 -58
  122. package/dist/{schedule-documents-DRc0byQm.js → schedule-documents-Di23etFx.js} +3 -3
  123. package/dist/{schedule-recurrence-BVxMRfp4.js → schedule-recurrence-D4r80Udd.js} +42 -14
  124. package/dist/{schedule-repository-dz9iwR0x.js → schedule-repository-BNUNXl15.js} +4 -4
  125. package/dist/{schedule-run-preparation-1oSQ5i-A.js → schedule-run-preparation-D2GjotJy.js} +5 -5
  126. package/dist/{schedule-types-BquxGfza.js → schedule-types-B9O0I1Ui.js} +472 -364
  127. package/dist/{service-D9xJKmI-.js → service-pb71b8fj.js} +5 -5
  128. package/dist/{session-npaRR-y3.js → session-C6dNbMjx.js} +21 -21
  129. package/dist/{session-file-blob-store-CBHDgf4e.js → session-file-blob-store-CdpmEU94.js} +4 -4
  130. package/dist/{session-image-download-DUwc2Fb4.js → session-image-download-DeZ6r1-w.js} +4 -4
  131. package/dist/{session-input-MeZheBJ0.js → session-input-Dz8R9xPL.js} +3 -3
  132. package/dist/{session-link-demCF_Y_.js → session-link-CABPzB2T.js} +51 -2
  133. package/dist/{session-link-export-BM1zZQRs.js → session-link-export-CabjkQNk.js} +3 -3
  134. package/dist/{session-operation-targets-lq3rsTnV.js → session-operation-targets-B-VimRwZ.js} +3 -3
  135. package/dist/{setting-Cq6nKJgF.js → setting-CKO-Tb-e.js} +116 -64
  136. package/dist/{start-BolVcMOA.js → start-B83c1-EW.js} +957 -297
  137. package/dist/streams-crdt-factory-CkuXGilB.js +17 -0
  138. package/dist/{subagent-emitter-DALyc5yu.js → subagent-emitter-D-zUFnS9.js} +2 -2
  139. package/dist/{subagent-events-CyFbbE20.js → subagent-events-D22OQNDm.js} +7 -2
  140. package/dist/{sync-BrDYKZ4H.js → sync-Cf_HanAI.js} +35 -35
  141. package/dist/{time-sync-D63wG9u-.js → time-sync-DjSg4eHx.js} +2 -2
  142. package/dist/{workspace-Bthb-nhu.js → workspace-BCjgp5pF.js} +36 -36
  143. package/dist/{workspace-legacy-jZ0D5Xl-.js → workspace-legacy-DJAko-Yj.js} +24 -24
  144. package/package.json +5 -5
  145. package/dist/index-BTgKuz44.js +0 -65
@@ -1,8 +1,8 @@
1
- import { M as ModelContextSchema, A as AssistantMessageSchema, U as UserMessageSchema, T as ToolResultMessageSchema, a as UsageSchema, b as TextContentSchema, I as ImageContentSchema, c as ModelContextMessageSchema, N as NamedStateNameSchema, P as PrefixSnapshotSchema, d as ContextAssemblyEvidenceSchema, e as TurnMaterialSnapshotSchema, R as RequestMaterialSnapshotSchema, f as ToolStateSnapshotSchema, g as NamedStateSnapshotSchema, h as MessageSchema, i as PrefixContextSourceSchema, j as ContextSourcesSchema, k as ModelRequestSettingsSchema, l as TurnContextSourceSchema } from "./vendor-@sorbetai-context-COh8_Kmc.js";
2
- import { d as decode, a as decodeWith, J as JsonValueSchema, c as compile, o as objectProperties } from "./vendor-@sorbetai-schema-BYxzbt6U.js";
3
- import { a as isError, b as isPromise, s as sortedIndexOf, c as isString, d as isEqual, p as pick, e as isFunction, f as isPlainObject, o as omit } from "./vendor-es-toolkit-DnvFX_hl.js";
4
- import { P as PluginInputSchema, a as PreparedToolHooksSchema, S as SessionBehaviorViewSchema, b as SessionBehaviorCommandSchema, M as ModelViewSchema } from "./vendor-@sorbetai-plugins-Bs93fyHc.js";
5
- import { A as ArtifactRefSchema } from "./vendor-@sorbetai-artifacts-Dt9BTK8Q.js";
1
+ import { M as ModelContextSchema, A as AssistantMessageSchema, U as UserMessageSchema, T as ToolResultMessageSchema, a as UsageSchema, b as TextContentSchema, I as ImageContentSchema, c as ModelContextMessageSchema, N as NamedStateNameSchema, P as PrefixSnapshotSchema, d as ContextAssemblyEvidenceSchema, e as TurnMaterialSnapshotSchema, R as RequestMaterialSnapshotSchema, f as ToolStateSnapshotSchema, g as NamedStateSnapshotSchema, h as MessageSchema, i as PrefixContextSourceSchema, j as ContextSourcesSchema, k as ModelRequestSettingsSchema, l as TurnContextSourceSchema } from "./vendor-@sorbetai-context-BV7q3KwO.js";
2
+ import { d as decode, a as decodeWith, J as JsonValueSchema, c as compile, o as objectProperties } from "./vendor-@sorbetai-schema-D53JJ0HJ.js";
3
+ import { a as isError, b as isPromise, s as sortedIndexOf, c as isString, d as isPlainObject, e as isEqual, p as pick, f as isFunction, o as omit } from "./vendor-es-toolkit-BDp9OdLC.js";
4
+ import { P as PluginInputSchema, a as PreparedToolHooksSchema, S as SessionBehaviorViewSchema, b as SessionBehaviorCommandSchema, M as ModelViewSchema } from "./vendor-@sorbetai-plugins-COkYjDxn.js";
5
+ import { A as ArtifactRefSchema } from "./vendor-@sorbetai-artifacts-Vz3r0uhj.js";
6
6
  import { e as ensureError } from "./vendor-ensure-error-DDMvQx1H.js";
7
7
  import { mkdir, open, realpath, readFile, rename, rm, unlink, stat } from "node:fs/promises";
8
8
  import { dirname, resolve, basename, join } from "node:path";
@@ -11,7 +11,7 @@ import { promisify } from "node:util";
11
11
  import { a as obj, m as map, s as str, i as int, o as opt, b as arr, t as tuple, d as bool, l as lit, c as union, n as num, e as nul, u as unknown } from "./vendor-@earendil-works-pi-schema-B1AXVDtt.js";
12
12
  const Utf8Encoder = new TextEncoder();
13
13
  function utf8ByteLength(text) {
14
- return Utf8Encoder.encode(text).byteLength;
14
+ return typeof Buffer !== "undefined" ? Buffer.byteLength(text, "utf8") : Utf8Encoder.encode(text).byteLength;
15
15
  }
16
16
  const NonEmptyString$2 = str({ minLength: 1 });
17
17
  const ApprovalModeSchema = union([lit("human"), lit("auto")]);
@@ -2309,6 +2309,45 @@ var ExternalizedStringReuse = class {
2309
2309
  }
2310
2310
  }
2311
2311
  };
2312
+ const STOP_SCAN = Symbol("journal.offload.stop");
2313
+ const UNCHANGED = Symbol("journal.offload.unchanged");
2314
+ function scanStrings(value, path, threshold, visit) {
2315
+ if (isString(value)) return utf8ByteLength(value) < threshold ? UNCHANGED : visit(path, value);
2316
+ if (Array.isArray(value)) {
2317
+ let rebuilt;
2318
+ for (const [index, entry] of value.entries()) {
2319
+ path.push(index);
2320
+ const child = scanStrings(entry, path, threshold, visit);
2321
+ path.pop();
2322
+ if (child === STOP_SCAN) return STOP_SCAN;
2323
+ if (rebuilt !== void 0) rebuilt.push(child === UNCHANGED ? entry : child);
2324
+ else if (child !== UNCHANGED) {
2325
+ rebuilt = value.slice(0, index);
2326
+ rebuilt.push(child);
2327
+ }
2328
+ }
2329
+ return rebuilt ?? UNCHANGED;
2330
+ }
2331
+ if (isPlainObject(value)) {
2332
+ let rebuilt;
2333
+ for (const [key$1, entry] of Object.entries(value)) {
2334
+ path.push(key$1);
2335
+ const child = scanStrings(entry, path, threshold, visit);
2336
+ path.pop();
2337
+ if (child === STOP_SCAN) return STOP_SCAN;
2338
+ if (rebuilt !== void 0) rebuilt[key$1] = child === UNCHANGED ? entry : child;
2339
+ else if (child !== UNCHANGED) {
2340
+ rebuilt = { ...value };
2341
+ rebuilt[key$1] = child;
2342
+ }
2343
+ }
2344
+ return rebuilt ?? UNCHANGED;
2345
+ }
2346
+ return UNCHANGED;
2347
+ }
2348
+ function hasOffloadableString(value, threshold) {
2349
+ return scanStrings(value, [], threshold, () => STOP_SCAN) === STOP_SCAN;
2350
+ }
2312
2351
  function encodeJournalFact(fact$1, store, inlineStringBytes, reuse) {
2313
2352
  const candidates = [];
2314
2353
  const encoded = {
@@ -2378,17 +2417,14 @@ function encodePath(path) {
2378
2417
  return path.join("\0");
2379
2418
  }
2380
2419
  function externalizeStrings(value, path, candidates, inlineStringBytes) {
2381
- if (isString(value)) {
2382
- if (utf8ByteLength(value) < inlineStringBytes) return value;
2420
+ const scanned = scanStrings(value, [...path], inlineStringBytes, (leaf, text) => {
2383
2421
  candidates.push({
2384
- path: [...path],
2385
- text: value
2422
+ path: [...leaf],
2423
+ text
2386
2424
  });
2387
2425
  return null;
2388
- }
2389
- if (Array.isArray(value)) return value.map((entry, index) => externalizeStrings(entry, [...path, index], candidates, inlineStringBytes));
2390
- if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key$1, entry]) => [key$1, externalizeStrings(entry, [...path, key$1], candidates, inlineStringBytes)]));
2391
- return value;
2426
+ });
2427
+ return scanned === UNCHANGED ? value : scanned;
2392
2428
  }
2393
2429
  function replacePlaceholders(value, path, byPath, applied) {
2394
2430
  const key$1 = encodePath(path);
@@ -3129,21 +3165,26 @@ async function encodeUnitFrame(writes$1, options, transactions) {
3129
3165
  const store = options.artifactStore;
3130
3166
  if (store !== void 0) {
3131
3167
  const threshold = decode(InlineStringBytesSchema, options.inlineStringBytes ?? DEFAULT_UNIT_INLINE_STRING_BYTES);
3132
- const entries = writes$1.map(({ record, json: fact$1 }) => ({
3133
- scope: record.entry.scope,
3134
- fact: decodeWith(FactObjectValidator, JSON.parse(fact$1))
3135
- }));
3136
- const encode = async (payload) => {
3137
- return frame(await Promise.all(entries.map(async ({ scope, fact: fact$1 }) => {
3138
- const encoded = await (payload ? encodeJournalPayload(fact$1, store) : encodeJournalFact(fact$1, store, threshold, options.stringReuse));
3139
- return JSON.stringify({
3140
- scope,
3141
- fact: encoded
3142
- });
3143
- })));
3144
- };
3145
- json = await encode(utf8ByteLength(json) > JOURNAL_APPEND_BATCH_MAX_BYTES);
3146
- if (utf8ByteLength(json) > JOURNAL_APPEND_BATCH_MAX_BYTES) json = await encode(true);
3168
+ if (utf8ByteLength(json) > JOURNAL_APPEND_BATCH_MAX_BYTES || writes$1.some(({ record }) => {
3169
+ const payload = record.entry.fact?.payload;
3170
+ return payload === void 0 || hasOffloadableString(payload, threshold);
3171
+ })) {
3172
+ const entries = writes$1.map(({ record, json: fact$1 }) => ({
3173
+ scope: record.entry.scope,
3174
+ fact: decodeWith(FactObjectValidator, JSON.parse(fact$1))
3175
+ }));
3176
+ const encode = async (payload) => {
3177
+ return frame(await Promise.all(entries.map(async ({ scope, fact: fact$1 }) => {
3178
+ const encoded = await (payload ? encodeJournalPayload(fact$1, store) : encodeJournalFact(fact$1, store, threshold, options.stringReuse));
3179
+ return JSON.stringify({
3180
+ scope,
3181
+ fact: encoded
3182
+ });
3183
+ })));
3184
+ };
3185
+ json = await encode(utf8ByteLength(json) > JOURNAL_APPEND_BATCH_MAX_BYTES);
3186
+ if (utf8ByteLength(json) > JOURNAL_APPEND_BATCH_MAX_BYTES) json = await encode(true);
3187
+ }
3147
3188
  }
3148
3189
  if (writes$1.length <= JOURNAL_APPEND_BATCH_MAX_FACTS && utf8ByteLength(json) <= JOURNAL_APPEND_BATCH_MAX_BYTES) return json;
3149
3190
  const reference = decode(ReferenceFrameSchema, {
@@ -3164,33 +3205,78 @@ async function encodeUnitFrame(writes$1, options, transactions) {
3164
3205
  await transactions.write(reference.transaction.id, json);
3165
3206
  return committed;
3166
3207
  }
3167
- function decodeUnitFrame(input, artifacts, transactions) {
3208
+ const INTERNED_STRING_MIN_BYTES = 256;
3209
+ const DECODED_STRING_INTERN_BYTES = 8 * 1024 * 1024;
3210
+ var DecodedStringInterner = class {
3211
+ #strings = /* @__PURE__ */ new Map();
3212
+ #bytes = 0;
3213
+ constructor(maxBytes = DECODED_STRING_INTERN_BYTES) {
3214
+ this.maxBytes = maxBytes;
3215
+ }
3216
+ take(text) {
3217
+ if (text.length < INTERNED_STRING_MIN_BYTES) return text;
3218
+ const bytes = utf8ByteLength(text);
3219
+ if (bytes > this.maxBytes) return text;
3220
+ const existing = this.#strings.get(text);
3221
+ if (existing !== void 0) {
3222
+ this.#strings.delete(text);
3223
+ this.#strings.set(text, existing);
3224
+ return existing;
3225
+ }
3226
+ this.#strings.set(text, text);
3227
+ this.#bytes += bytes;
3228
+ while (this.#bytes > this.maxBytes) {
3229
+ const oldest = this.#strings.keys().next();
3230
+ if (oldest.done === true) break;
3231
+ this.#strings.delete(oldest.value);
3232
+ this.#bytes -= utf8ByteLength(oldest.value);
3233
+ }
3234
+ return text;
3235
+ }
3236
+ /** Shares repeated large strings in place; decoded payloads are immutable to readers. */
3237
+ intern(value) {
3238
+ if (Array.isArray(value)) {
3239
+ for (const [index, entry] of value.entries()) if (isString(entry)) value[index] = this.take(entry);
3240
+ else this.intern(entry);
3241
+ return;
3242
+ }
3243
+ if (isPlainObject(value)) for (const key$1 of Object.keys(value)) {
3244
+ const entry = value[key$1];
3245
+ if (isString(entry)) value[key$1] = this.take(entry);
3246
+ else if (entry !== void 0) this.intern(entry);
3247
+ }
3248
+ }
3249
+ };
3250
+ const sharedStringInterner = new DecodedStringInterner();
3251
+ function decodeUnitFrame(input, artifacts, transactions, interner = sharedStringInterner) {
3168
3252
  try {
3169
3253
  const frame = readFrame(isString(input) ? input : Utf8Decoder.decode(input), transactions);
3170
- const records = isPromise(frame) ? frame.then((decoded) => decodeFrameRecords(decoded, artifacts)) : decodeFrameRecords(frame, artifacts);
3254
+ const records = isPromise(frame) ? frame.then((decoded) => decodeFrameRecords(decoded, artifacts, interner)) : decodeFrameRecords(frame, artifacts, interner);
3171
3255
  return isPromise(records) ? records.catch(failFrameDecode) : records;
3172
3256
  } catch (cause) {
3173
3257
  return failFrameDecode(cause);
3174
3258
  }
3175
3259
  }
3176
- function decodeFrameRecords(frame, artifacts) {
3260
+ function decodeFrameRecords(frame, artifacts, interner) {
3177
3261
  const records = [];
3178
3262
  const pending = [];
3179
3263
  for (const [index, entry] of frame.entries.entries()) {
3180
3264
  const decoded = decodeJournalEnvelope(entry.fact, artifacts);
3181
3265
  const store = (fact$1) => {
3266
+ const entry2 = entry.scope === "session" ? {
3267
+ scope: entry.scope,
3268
+ fact: decode(CommittedJournalFact, fact$1)
3269
+ } : {
3270
+ scope: entry.scope,
3271
+ fact: decode(CommittedUnitFact, fact$1)
3272
+ };
3273
+ interner.intern(entry2.fact.payload);
3182
3274
  records[index] = {
3183
3275
  unitId: frame.unitId,
3184
3276
  epochId: frame.epochId,
3185
3277
  commitId: frame.commitId,
3186
3278
  unitSequence: frame.firstSequence + index,
3187
- entry: entry.scope === "session" ? {
3188
- scope: entry.scope,
3189
- fact: decode(CommittedJournalFact, fact$1)
3190
- } : {
3191
- scope: entry.scope,
3192
- fact: decode(CommittedUnitFact, fact$1)
3193
- }
3279
+ entry: entry2
3194
3280
  };
3195
3281
  };
3196
3282
  if (isPromise(decoded)) pending.push(decoded.then(store));
@@ -3408,6 +3494,40 @@ async function loadUnitSnapshot(filePath, unitId, sealed) {
3408
3494
  }
3409
3495
  const DECODED_FRAME_CACHE_MAX_BYTES = 16 * 1024 * 1024;
3410
3496
  const DECODED_FRAME_READ_CACHE_BYTES = 8 * 1024 * 1024;
3497
+ var DecodedFrameCache = class {
3498
+ #entries = /* @__PURE__ */ new Map();
3499
+ #bytes = 0;
3500
+ constructor(maxBytes) {
3501
+ this.maxBytes = maxBytes;
3502
+ }
3503
+ get(key$1) {
3504
+ const entry = this.#entries.get(key$1);
3505
+ if (entry === void 0) return void 0;
3506
+ this.#entries.delete(key$1);
3507
+ this.#entries.set(key$1, entry);
3508
+ return entry.records;
3509
+ }
3510
+ set(key$1, records, bytes) {
3511
+ const previous = this.#entries.get(key$1);
3512
+ if (previous !== void 0) {
3513
+ this.#entries.delete(key$1);
3514
+ this.#bytes -= previous.bytes;
3515
+ }
3516
+ this.#entries.set(key$1, {
3517
+ records,
3518
+ bytes
3519
+ });
3520
+ this.#bytes += bytes;
3521
+ while (this.#bytes > this.maxBytes) {
3522
+ const oldest = this.#entries.keys().next();
3523
+ if (oldest.done === true) break;
3524
+ this.#bytes -= this.#entries.get(oldest.value)?.bytes ?? 0;
3525
+ this.#entries.delete(oldest.value);
3526
+ }
3527
+ }
3528
+ };
3529
+ const sharedDecodedFrameCache = new DecodedFrameCache(DECODED_FRAME_READ_CACHE_BYTES);
3530
+ let unitFramesInstance = 0;
3411
3531
  function sharedPrefix(values) {
3412
3532
  const [first = "", ...rest] = values;
3413
3533
  let length = first.length;
@@ -3422,24 +3542,23 @@ const ReferenceFrameMarker = Buffer.from('"storageVersion":2');
3422
3542
  var UnitFrames = class {
3423
3543
  #positions = [];
3424
3544
  #frames = [];
3425
- #decoded = [];
3426
- #cacheOrder = [];
3427
- #cacheBytes = 0;
3428
3545
  completeBytes = 0;
3429
3546
  incompleteTail = false;
3430
- constructor(file, transactions, artifacts, cacheDecoded = false, cacheReads = true) {
3547
+ constructor(file, transactions, artifacts, cacheDecoded = false, cacheReads = true, cacheNamespace = `u${unitFramesInstance++}`, readCache = sharedDecodedFrameCache) {
3431
3548
  this.file = file;
3432
3549
  this.transactions = transactions;
3433
3550
  this.artifacts = artifacts;
3434
3551
  this.cacheDecoded = cacheDecoded;
3435
3552
  this.cacheReads = cacheReads;
3553
+ this.cacheNamespace = cacheNamespace;
3554
+ this.readCache = readCache;
3555
+ }
3556
+ #cacheKey(offset) {
3557
+ return `${this.cacheNamespace}:${offset}`;
3436
3558
  }
3437
3559
  async scan(visit, options) {
3438
3560
  this.#positions.length = 0;
3439
3561
  this.#frames.length = 0;
3440
- this.#decoded.length = 0;
3441
- this.#cacheOrder.length = 0;
3442
- this.#cacheBytes = 0;
3443
3562
  this.completeBytes = 0;
3444
3563
  this.incompleteTail = false;
3445
3564
  const cache = this.cacheDecoded && (await this.file.stat()).size <= DECODED_FRAME_CACHE_MAX_BYTES;
@@ -3456,7 +3575,7 @@ var UnitFrames = class {
3456
3575
  if (next === void 0) return;
3457
3576
  const records = isPromise(next.records) ? await next.records : next.records;
3458
3577
  visit(records, { offset: next.offset });
3459
- if (cache) this.#decoded[this.#frames.length] = records;
3578
+ if (cache) this.readCache.set(this.#cacheKey(next.offset), records, next.length);
3460
3579
  this.add({
3461
3580
  offset: next.offset,
3462
3581
  length: next.length
@@ -3495,21 +3614,13 @@ var UnitFrames = class {
3495
3614
  /**
3496
3615
  * Readers that refresh after every append asked for the same frames repeatedly. Keep the
3497
3616
  * most recent decodes so an unchanged frame costs nothing on the next read, bounded by the
3498
- * raw bytes it came from: decoded records are several times larger than their frame.
3617
+ * shared pool's raw byte budget: decoded records are several times larger than their frame.
3499
3618
  */
3500
3619
  #remember(frameIndex, records) {
3501
- if (!this.cacheReads || this.#decoded[frameIndex] !== void 0) return;
3620
+ if (!this.cacheReads) return;
3502
3621
  const frame = this.#frames[frameIndex];
3503
3622
  if (frame === void 0) return;
3504
- this.#decoded[frameIndex] = records;
3505
- this.#cacheOrder.push(frameIndex);
3506
- this.#cacheBytes += frame.length;
3507
- while (this.#cacheBytes > DECODED_FRAME_READ_CACHE_BYTES) {
3508
- const evicted = this.#cacheOrder.shift();
3509
- if (evicted === void 0) break;
3510
- this.#cacheBytes -= this.#frames[evicted]?.length ?? 0;
3511
- this.#decoded[evicted] = void 0;
3512
- }
3623
+ this.readCache.set(this.#cacheKey(frame.offset), records, frame.length);
3513
3624
  }
3514
3625
  async read(positions) {
3515
3626
  const decoded = /* @__PURE__ */ new Map();
@@ -3517,7 +3628,8 @@ var UnitFrames = class {
3517
3628
  for (const position of positions) {
3518
3629
  const locator = this.#positions[position];
3519
3630
  if (locator === void 0) throw new UnitStoreError("unit_corrupt", "Missing unit record locator");
3520
- const cached = this.#decoded[locator.frame];
3631
+ const framePosition = this.#frames[locator.frame];
3632
+ const cached = framePosition === void 0 ? void 0 : this.readCache.get(this.#cacheKey(framePosition.offset));
3521
3633
  if (cached === void 0) needed.add(locator.frame);
3522
3634
  else decoded.set(locator.frame, cached);
3523
3635
  }
@@ -3885,4 +3997,4 @@ async function readUnitSessions(options) {
3885
3997
  export {
3886
3998
  readUnitSessions as r
3887
3999
  };
3888
- //# sourceMappingURL=vendor-@sorbetai-runtime-kicj4Xs_.js.map
4000
+ //# sourceMappingURL=vendor-@sorbetai-runtime-DKAfUiS0.js.map
@@ -1,4 +1,4 @@
1
- import { i as isBoolean } from "./vendor-es-toolkit-DnvFX_hl.js";
1
+ import { i as isBoolean } from "./vendor-es-toolkit-BDp9OdLC.js";
2
2
  import { o as opt, a as obj, b as arr, s as str, m as map, u as unknown } from "./vendor-@earendil-works-pi-schema-B1AXVDtt.js";
3
3
  const ALWAYS = () => true;
4
4
  const NEVER = () => false;
@@ -2071,4 +2071,4 @@ export {
2071
2071
  decode as d,
2072
2072
  objectProperties as o
2073
2073
  };
2074
- //# sourceMappingURL=vendor-@sorbetai-schema-BYxzbt6U.js.map
2074
+ //# sourceMappingURL=vendor-@sorbetai-schema-D53JJ0HJ.js.map
@@ -1,4 +1,4 @@
1
- import { e as env, B as BetterAuthError, i as isSafeUrlScheme, t as toKebabCase, c as capitalizeFirstLetter } from "./vendor-@better-auth-core-Dpzqxq_j.js";
1
+ import { e as env, B as BetterAuthError, i as isSafeUrlScheme, t as toKebabCase, c as capitalizeFirstLetter } from "./vendor-@better-auth-core-C7hql1k7.js";
2
2
  import { o as onSet, a as onMount, b as atom, S as STORE_UNMOUNT_DELAY } from "./vendor-nanostores-U58ckFTK.js";
3
3
  import { d as defu } from "./vendor-defu-BJ13cSX9.js";
4
4
  import { c as createFetch } from "./vendor-@better-fetch-fetch-Cuh8CnyA.js";
@@ -729,4 +729,4 @@ export {
729
729
  createAuthClient as c,
730
730
  deviceAuthorizationClient as d
731
731
  };
732
- //# sourceMappingURL=vendor-better-auth-PQ6PT4aF.js.map
732
+ //# sourceMappingURL=vendor-better-auth-D1bP-dEy.js.map