dal-code 1.0.54 → 1.0.56

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 (342) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/NOTICE +11 -0
  3. package/dist/bundle/chunks/{anthropic-messages-UHE6F2IE.js → anthropic-messages-HHQLDDZH.js} +1 -1
  4. package/dist/bundle/chunks/{azure-openai-responses-EK4W2MKL.js → azure-openai-responses-S7VKEJTH.js} +1 -1
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  6. package/dist/bundle/chunks/{chunk-3ZHZINH3.js → chunk-3HGUIN22.js} +2 -2
  7. package/dist/bundle/chunks/{chunk-FE533CCR.js → chunk-3XMZ5UC3.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-EH7SFF47.js → chunk-AL3DFAIM.js} +2 -2
  9. package/dist/bundle/chunks/{chunk-IDZ3QKHZ.js → chunk-BCFLC6CK.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-K4B5ABCQ.js → chunk-BIY5HTFI.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-SCYK4XNE.js → chunk-F37JXTCY.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-K7VBBYTT.js → chunk-F5SIUTR7.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-356BFRU3.js → chunk-MKMLENQD.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-4DMD6C65.js → chunk-P4IBZA6D.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-B5GJW7C2.js → chunk-PH42AQ66.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-O7G23ELK.js → chunk-QCT6OHUR.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-RKLUP6JT.js → chunk-RX6CC5RH.js} +463 -460
  18. package/dist/bundle/chunks/{chunk-XRF4A4KI.js → chunk-SZZVJTVX.js} +3 -3
  19. package/dist/bundle/chunks/chunk-T3TEURLR.js +30 -0
  20. package/dist/bundle/chunks/{chunk-VIS5PYQO.js → chunk-UULAEZ3H.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-2C7JTP5O.js → chunk-VGMP27KM.js} +1 -1
  22. package/dist/bundle/chunks/chunk-XTN2LDU3.js +9 -0
  23. package/dist/bundle/chunks/{chunk-CSZTBJOE.js → chunk-Z64M4Q7A.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-33MCYYJ3.js → chunk-ZR6PGIL7.js} +1 -1
  25. package/dist/bundle/chunks/{cli-YJV3WN2N.js → cli-NGGC23SK.js} +1 -1
  26. package/dist/bundle/chunks/{cli-XOLEGZVC.js → cli-TVPE43YN.js} +1 -1
  27. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-KNGB64NR.js → cloudflare-workers-ai-system-one-RK2YCJXC.js} +1 -1
  28. package/dist/bundle/chunks/{easter-egg-3d-5TFBCTIS.js → easter-egg-3d-W2F3ROZ6.js} +1 -1
  29. package/dist/bundle/chunks/{execute-6PNQ63VS.js → execute-MGTKJB44.js} +1 -1
  30. package/dist/bundle/chunks/github-copilot.js +1 -1
  31. package/dist/bundle/chunks/{google-generative-ai-YJN7TGWU.js → google-generative-ai-ZPA4VBXP.js} +1 -1
  32. package/dist/bundle/chunks/{google-vertex-3BVJFMMZ.js → google-vertex-IWHW2RX7.js} +1 -1
  33. package/dist/bundle/chunks/{llama-cpp-classify-JVUWNG3E.js → llama-cpp-classify-FXJM52Q3.js} +1 -1
  34. package/dist/bundle/chunks/mcp-RLFUDVHN.js +10 -0
  35. package/dist/bundle/chunks/{mistral-conversations-O6YIQAS5.js → mistral-conversations-JXVPTO5Y.js} +1 -1
  36. package/dist/bundle/chunks/{office-AXLGVCMO.js → office-RTREQQ7W.js} +1 -1
  37. package/dist/bundle/chunks/{openai-codex-responses-YQ5NNPTG.js → openai-codex-responses-EYW27UUE.js} +1 -1
  38. package/dist/bundle/chunks/{openai-completions-R4I3PKBD.js → openai-completions-ROBKXDOC.js} +1 -1
  39. package/dist/bundle/chunks/{openai-decisions-IUHMKKHZ.js → openai-decisions-4T5LPJRA.js} +1 -1
  40. package/dist/bundle/chunks/{openai-responses-E2PHOQF4.js → openai-responses-ZVFZ75QW.js} +1 -1
  41. package/dist/bundle/chunks/{openrouter-images-NCMLTKZW.js → openrouter-images-6VJYTLAX.js} +1 -1
  42. package/dist/bundle/chunks/{pi-messages-GLTSGLSO.js → pi-messages-Y6HBOGKH.js} +1 -1
  43. package/dist/bundle/chunks/{review-KXWT7T3V.js → review-USSKCVWP.js} +1 -1
  44. package/dist/bundle/chunks/{router-26PXJ7YH.js → router-4JLK3BTT.js} +1 -1
  45. package/dist/bundle/chunks/{runtime-LJBCO7CX.js → runtime-G7F6UQLA.js} +1 -1
  46. package/dist/bundle/chunks/{sdk-6GP346VB.js → sdk-CEIRR6KD.js} +1 -1
  47. package/dist/bundle/chunks/sync-UCHKAOUU.js +21 -0
  48. package/dist/bundle/chunks/{typesafe-system-one-GQFHU7SQ.js → typesafe-system-one-XPDE7VYD.js} +1 -1
  49. package/dist/bundle/chunks/{usage-MY7HTXQB.js → usage-3ACOJWR3.js} +1 -1
  50. package/dist/bundle/chunks/{virtual-modules-BEBLHRXC.js → virtual-modules-P4JE2EA6.js} +1 -1
  51. package/dist/bundle/cli-runtime.js +1 -1
  52. package/dist/bundle/index.js +1 -1
  53. package/dist/bundle/rpc-entry.js +1 -1
  54. package/dist/core/agent-session-runtime.d.ts +1 -0
  55. package/dist/core/agent-session-runtime.js +1 -1
  56. package/dist/core/extensions/index.d.ts +1 -1
  57. package/dist/core/extensions/types.d.ts +9 -5
  58. package/dist/core/headless-approver.d.ts +3 -0
  59. package/dist/core/headless-approver.js +1 -0
  60. package/dist/core/tools/bash.js +1 -1
  61. package/dist/core/tools/edit.js +2 -3
  62. package/dist/core/tools/renderers/bash.js +1 -1
  63. package/dist/core/tools/renderers/edit.js +2 -2
  64. package/dist/dal/manifest.js +1 -1
  65. package/dist/index.d.ts +2 -1
  66. package/dist/index.js +1 -1
  67. package/dist/main.js +3 -3
  68. package/dist/modes/acp/acp-mapping.js +3 -2
  69. package/dist/modes/acp/acp-mode.js +1 -1
  70. package/dist/modes/acp/acp-permissions.js +1 -0
  71. package/dist/modes/acp/acp-session-options.d.ts +24 -0
  72. package/dist/modes/acp/acp-session-options.js +3 -0
  73. package/dist/modes/index.d.ts +1 -0
  74. package/dist/modes/index.js +1 -1
  75. package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
  76. package/dist/modes/interactive/components/assistant-message.js +2 -2
  77. package/dist/modes/interactive/components/diff.d.ts +22 -0
  78. package/dist/modes/interactive/components/diff.js +4 -3
  79. package/dist/modes/interactive/components/keybinding-hints.js +1 -1
  80. package/dist/modes/interactive/components/panel-line.js +1 -0
  81. package/dist/modes/interactive/components/status-indicator.d.ts +23 -1
  82. package/dist/modes/interactive/components/status-indicator.js +1 -1
  83. package/dist/modes/interactive/components/tool-execution.d.ts +2 -2
  84. package/dist/modes/interactive/components/tool-execution.js +5 -5
  85. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  86. package/dist/modes/interactive/interactive-mode.js +18 -18
  87. package/dist/modes/interactive/theme/dark.json +4 -0
  88. package/dist/modes/interactive/theme/light.json +4 -0
  89. package/dist/modes/interactive/theme/system-theme.js +1 -1
  90. package/dist/modes/interactive/theme/theme-tokens.d.ts +10 -0
  91. package/dist/modes/interactive/theme/theme-tokens.js +1 -1
  92. package/dist/modes/rpc/rpc-types.d.ts +2 -6
  93. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  94. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  95. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  96. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  97. package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
  98. package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
  99. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  100. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  101. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  102. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  103. package/dist/node_modules/@dalcode/dal-guard/src/index.js +4 -4
  104. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  105. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  106. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  107. package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
  108. package/dist/node_modules/@dalcode/dal-learn/src/engine.js +2 -2
  109. package/dist/node_modules/@dalcode/dal-learn/src/index.js +14 -14
  110. package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -4
  111. package/dist/node_modules/@dalcode/dal-learn/src/safety.js +2 -2
  112. package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
  113. package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
  114. package/dist/node_modules/@dalcode/dal-mcp/src/config.js +1 -1
  115. package/dist/node_modules/@dalcode/dal-mcp/src/index.js +16 -16
  116. package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +2 -0
  117. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  118. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +3 -3
  119. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  120. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +3 -3
  121. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  122. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  123. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  124. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  125. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  126. package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
  127. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  128. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  129. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  130. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  131. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  132. package/dist/node_modules/@dalcode/dal-sync/package.json +7 -5
  133. package/dist/node_modules/@dalcode/dal-sync/src/client.d.ts +2 -0
  134. package/dist/node_modules/@dalcode/dal-sync/src/client.js +1 -1
  135. package/dist/node_modules/@dalcode/dal-sync/src/host.d.ts +11 -1
  136. package/dist/node_modules/@dalcode/dal-sync/src/host.js +2 -2
  137. package/dist/node_modules/@dalcode/dal-sync/src/index.js +3 -3
  138. package/dist/node_modules/@dalcode/dal-sync/src/sessions.d.ts +153 -0
  139. package/dist/node_modules/@dalcode/dal-sync/src/sessions.js +15 -0
  140. package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
  141. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  142. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  143. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  144. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  145. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  146. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +4 -4
  147. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  148. package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
  149. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  150. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
  151. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  152. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
  153. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  154. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  155. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  156. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  157. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  158. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  159. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  160. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  161. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  162. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  163. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  164. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  165. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  166. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  167. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  168. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  169. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  170. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  171. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
  172. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
  173. package/dist/node_modules/@earendil-works/pi-ai/package.json +3 -3
  174. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  175. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  176. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  177. package/dist/node_modules/@earendil-works/pi-schema/package.json +1 -1
  178. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  179. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  180. package/dist/sdk/sync.d.ts +8 -1
  181. package/dist/sdk/sync.js +1 -1
  182. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  183. package/examples/extensions/gondolin/package-lock.json +2 -2
  184. package/examples/extensions/gondolin/package.json +1 -1
  185. package/examples/extensions/with-deps/package-lock.json +2 -2
  186. package/examples/extensions/with-deps/package.json +1 -1
  187. package/npm-shrinkwrap.json +2 -2
  188. package/package.json +1 -1
  189. package/dist/bun/register-bedrock.js +0 -1
  190. package/dist/bundle/chunks/chunk-L3RBW36Y.js +0 -9
  191. package/dist/bundle/chunks/chunk-R7FBN5UP.js +0 -30
  192. package/dist/bundle/chunks/mcp-PC3Y3FBI.js +0 -10
  193. package/dist/bundle/chunks/sync-ONQZCAYG.js +0 -7
  194. package/dist/cli/experimental/auth.js +0 -1
  195. package/dist/cli/experimental/cli.js +0 -1
  196. package/dist/cli/experimental/command-options.js +0 -1
  197. package/dist/cli/experimental/command.js +0 -1
  198. package/dist/cli/experimental/commands/client.js +0 -1
  199. package/dist/cli/experimental/commands/pi.js +0 -1
  200. package/dist/cli/experimental/commands/server.js +0 -1
  201. package/dist/cli/experimental/transport-address.js +0 -1
  202. package/dist/client/index.js +0 -1
  203. package/dist/client/remote-session.js +0 -1
  204. package/dist/client/transcript.js +0 -1
  205. package/dist/core/provider-attribution.js +0 -1
  206. package/dist/modes/interactive/components/daxnuts.js +0 -1
  207. package/dist/modes/interactive/theme/theme-json.js +0 -12
  208. package/dist/modes/interactive/theme/theme-schema.json +0 -356
  209. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +0 -1
  210. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +0 -37
  211. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +0 -104
  212. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +0 -16
  213. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/config.js +0 -1
  214. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/context.js +0 -1
  215. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +0 -10
  216. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js +0 -1
  217. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/assistant.js +0 -1
  218. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.js +0 -1
  219. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/tools.js +0 -1
  220. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/hooks.js +0 -1
  221. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +0 -17
  222. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bash.js +0 -1
  223. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bounded.js +0 -1
  224. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/chord.js +0 -1
  225. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/context.js +0 -1
  226. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/harness.js +0 -1
  227. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/hooks.js +0 -1
  228. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/index.js +0 -1
  229. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/jsonl.js +0 -4
  230. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/collapse.js +0 -3
  231. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/entries.js +0 -1
  232. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/frames.js +0 -1
  233. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/generation.js +0 -1
  234. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/job.js +0 -1
  235. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/plugin.js +0 -1
  236. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/post-tools.js +0 -1
  237. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/task-api.js +0 -1
  238. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/tool.js +0 -3
  239. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/membrane.js +0 -1
  240. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/memory.js +0 -1
  241. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/scheduler.js +0 -1
  242. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/session.js +0 -1
  243. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/system.js +0 -8
  244. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/types.js +0 -1
  245. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/view.js +0 -1
  246. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js +0 -5
  247. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +0 -1
  248. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/result.js +0 -1
  249. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/boundary.js +0 -1
  250. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/checkpoint.js +0 -1
  251. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/deferred.js +0 -1
  252. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/generation.js +0 -1
  253. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/reconcile.js +0 -1
  254. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/recovery.js +0 -1
  255. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/response.js +0 -1
  256. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/retry.js +0 -1
  257. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/structural.js +0 -1
  258. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/terminal.js +0 -1
  259. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tool-placement.js +0 -1
  260. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tools.js +0 -1
  261. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive.js +0 -1
  262. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/harness.js +0 -1
  263. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/index.js +0 -1
  264. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/lane.js +0 -1
  265. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/progress.js +0 -1
  266. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/reducer.js +0 -1
  267. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/restore.js +0 -1
  268. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/transcript.js +0 -1
  269. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/types.js +0 -1
  270. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/commit.js +0 -1
  271. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.js +0 -1
  272. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork-policy.js +0 -1
  273. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +0 -1
  274. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/in-memory-storage-state.js +0 -1
  275. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/index.js +0 -1
  276. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js +0 -1
  277. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +0 -1
  278. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/fork.js +0 -1
  279. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/index.js +0 -1
  280. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/io.js +0 -3
  281. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/legacy-v3.js +0 -1
  282. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js +0 -1
  283. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js +0 -8
  284. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.js +0 -1
  285. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -1
  286. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -5
  287. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl.js +0 -1
  288. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -1
  289. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -1
  290. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.js +0 -1
  291. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/mutation-line.js +0 -1
  292. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -1
  293. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +0 -1
  294. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js +0 -1
  295. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/datasets.js +0 -1
  296. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/session-repo.js +0 -1
  297. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/storage.js +0 -1
  298. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/session-repo.js +0 -1
  299. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/storage.js +0 -1
  300. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +0 -1
  301. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/gating-storage.js +0 -1
  302. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/index.js +0 -1
  303. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/instrumented-storage.js +0 -1
  304. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/storage-decorator.js +0 -1
  305. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/types.js +0 -0
  306. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.js +0 -1
  307. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/values.js +0 -1
  308. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +0 -10
  309. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js +0 -2
  310. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.js +0 -1
  311. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js +0 -12
  312. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js +0 -16
  313. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +0 -1
  314. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js +0 -1
  315. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js +0 -1
  316. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js +0 -1
  317. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js +0 -1
  318. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js +0 -14
  319. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js +0 -0
  320. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +0 -1
  321. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +0 -1
  322. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/adaptive-publisher.js +0 -1
  323. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/output-capture.js +0 -5
  324. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +0 -1
  325. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +0 -5
  326. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/usage.js +0 -1
  327. package/dist/node_modules/@earendil-works/pi-agent-core/dist/node.js +0 -1
  328. package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/index.js +0 -0
  329. package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +0 -1
  330. package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +0 -1
  331. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js +0 -74
  332. package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +0 -1
  333. package/dist/node_modules/@earendil-works/pi-ai/dist/images-models.js +0 -1
  334. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +0 -1
  335. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +0 -1
  336. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +0 -1
  337. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.js +0 -1
  338. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +0 -1
  339. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js +0 -1
  340. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.js +0 -1
  341. package/dist/server/create-harness.js +0 -1
  342. package/dist/utils/clipboard-native.js +0 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-plugins",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -20,9 +20,9 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.54",
24
- "@dalcode/dal-skills": "1.0.54",
25
- "@dalcode/deepailab": "1.0.54",
23
+ "@dalcode/dal-pi-kit": "1.0.56",
24
+ "@dalcode/dal-skills": "1.0.56",
25
+ "@dalcode/deepailab": "1.0.56",
26
26
  "typebox": "1.3.27"
27
27
  },
28
28
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-recall",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "description": "Search past sessions: a local full-text index of earlier conversations the model can query with session_search. Adapted from @henryqw/pi-session-recall 5.1.4 (MIT).",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.54",
23
+ "@dalcode/dal-pi-kit": "1.0.56",
24
24
  "typebox": "1.3.27"
25
25
  },
26
26
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-remote",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "description": "`dal remote enable|disable|status|pair|logs`: installs the phone daemon (a pinned, integrity-checked npm package) and runs it as a systemd user service or a launchd agent, so the DAL Code phone app can reach this machine.",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  ]
20
20
  },
21
21
  "dependencies": {
22
- "@dalcode/dal-pi-kit": "1.0.54"
22
+ "@dalcode/dal-pi-kit": "1.0.56"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-review",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "description": "Code review: a read-only reviewer sub-agent over uncommitted changes, a base branch, a commit, a PR or a supplied diff, returning structured, deduplicated findings. /review in the TUI, dal -p, RPC and the SDK.",
6
6
  "type": "module",
@@ -19,8 +19,8 @@
19
19
  ]
20
20
  },
21
21
  "dependencies": {
22
- "@dalcode/dal-pi-kit": "1.0.54",
23
- "@dalcode/dal-subagent": "1.0.54",
22
+ "@dalcode/dal-pi-kit": "1.0.56",
23
+ "@dalcode/dal-subagent": "1.0.56",
24
24
  "typebox": "1.3.7"
25
25
  },
26
26
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-rewind",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "description": "Git checkpoints for DAL: a snapshot after every turn that changes files, /rewind, Esc+Esc, safe restore, undo. Adapted from pi-rewind 0.5.0 (MIT, arpagon).",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  ]
22
22
  },
23
23
  "dependencies": {
24
- "@dalcode/dal-pi-kit": "1.0.54"
24
+ "@dalcode/dal-pi-kit": "1.0.56"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-router",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -29,11 +29,11 @@
29
29
  ]
30
30
  },
31
31
  "dependencies": {
32
- "@dalcode/dal-guard": "1.0.54",
33
- "@dalcode/dal-pi-kit": "1.0.54",
34
- "@dalcode/dal-tool-catalog": "1.0.54",
35
- "@dalcode/deepailab": "1.0.54",
36
- "@earendil-works/pi-tui": "1.0.54"
32
+ "@dalcode/dal-guard": "1.0.56",
33
+ "@dalcode/dal-pi-kit": "1.0.56",
34
+ "@dalcode/dal-tool-catalog": "1.0.56",
35
+ "@dalcode/deepailab": "1.0.56",
36
+ "@earendil-works/pi-tui": "1.0.56"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@earendil-works/pi-coding-agent": "^1.0.0"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-rtk",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "description": "Uses rtk, when the user has installed it, to compress the output of shell commands the agent runs. Does nothing when rtk is not installed; never installs it.",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.54"
21
+ "@dalcode/dal-pi-kit": "1.0.56"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-skills",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -22,8 +22,8 @@
22
22
  ]
23
23
  },
24
24
  "dependencies": {
25
- "@dalcode/dal-pi-kit": "1.0.54",
26
- "@dalcode/deepailab": "1.0.54",
25
+ "@dalcode/dal-pi-kit": "1.0.56",
26
+ "@dalcode/deepailab": "1.0.56",
27
27
  "typebox": "1.3.7"
28
28
  },
29
29
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-statusline",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "description": "A scriptable status line under the footer: a template or a command of the user's choosing. Grown from the status-line and custom-footer extension examples.",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.54"
21
+ "@dalcode/dal-pi-kit": "1.0.56"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-structured",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "description": "dal -p --output-schema: the final answer as JSON that matches a JSON Schema, with a non-zero exit when it does not. Grown from the structured-output extension example.",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.54",
21
+ "@dalcode/dal-pi-kit": "1.0.56",
22
22
  "typebox": "1.3.27"
23
23
  },
24
24
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-subagent",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -18,10 +18,10 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.54",
22
- "@dalcode/dal-guard": "1.0.54",
23
- "@earendil-works/pi-agent-core": "1.0.54",
24
- "@earendil-works/pi-ai": "1.0.54",
21
+ "@dalcode/dal-pi-kit": "1.0.56",
22
+ "@dalcode/dal-guard": "1.0.56",
23
+ "@earendil-works/pi-agent-core": "1.0.56",
24
+ "@earendil-works/pi-ai": "1.0.56",
25
25
  "typebox": "1.3.7"
26
26
  },
27
27
  "peerDependencies": {
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dalcode/dal-sync",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
- "description": "Opt-in sync of personal skills and personal lessons through the signed-in DeepAILab account, so other computers pick them up (/sync).",
5
+ "description": "Conversations, personal skills and personal lessons follow the signed-in DeepAILab account, so other computers pick them up (/sync).",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "./src/index.js",
@@ -10,6 +10,8 @@
10
10
  ".": "./src/index.js",
11
11
  "./core": "./src/core.js",
12
12
  "./host": "./src/host.js",
13
+ "./client": "./src/client.js",
14
+ "./sessions": "./src/sessions.js",
13
15
  "./package.json": "./package.json"
14
16
  },
15
17
  "files": [
@@ -21,9 +23,9 @@
21
23
  ]
22
24
  },
23
25
  "dependencies": {
24
- "@dalcode/dal-learn": "1.0.54",
25
- "@dalcode/dal-pi-kit": "1.0.54",
26
- "@dalcode/deepailab": "1.0.54"
26
+ "@dalcode/dal-learn": "1.0.56",
27
+ "@dalcode/dal-pi-kit": "1.0.56",
28
+ "@dalcode/deepailab": "1.0.56"
27
29
  },
28
30
  "peerDependencies": {
29
31
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,4 +1,5 @@
1
1
  import { type SyncRemote } from "./core.js";
2
+ import type { SessionRemote } from "./sessions.js";
2
3
  export interface HttpRemoteOptions {
3
4
  readonly apiBase: string;
4
5
  readonly token: () => Promise<string | undefined>;
@@ -8,5 +9,6 @@ export interface HttpRemoteOptions {
8
9
  }
9
10
  export interface HttpRemote extends SyncRemote {
10
11
  removeAll(): Promise<number>;
12
+ readonly sessions: SessionRemote;
11
13
  }
12
14
  export declare function createHttpRemote(options: HttpRemoteOptions): HttpRemote;
@@ -1 +1 @@
1
- var y=Object.defineProperty;var f=(a,u)=>y(a,"name",{value:u,configurable:!0});var v=Object.defineProperty,p=f((a,u)=>v(a,"name",{value:u,configurable:!0}),"u");import{SyncHttpError as c}from"./core.js";function w(a){const u=`${a.apiBase.replace(/\/+$/,"")}/portal/dal-sync`,l=a.fetch??fetch;async function o(t,n,r){const s=await a.token();if(!s)throw new c(401);const e=await l(`${u}${n}`,{method:t,headers:{Authorization:`Bearer ${s}`,Accept:"application/json",...r===void 0?{}:{"Content-Type":"application/json"}},body:r===void 0?void 0:JSON.stringify(r),signal:AbortSignal.timeout(a.timeoutMs??2e4)}),d=await e.json().catch(()=>null);return{status:e.status,data:d}}f(o,"c"),p(o,"call");const i=p(t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},"record"),m=p(t=>`/items/${encodeURIComponent(t)}`,"item");return{async manifest(){const{status:t,data:n}=await o("GET","/manifest");if(t!==200)throw new c(t);const r=i(n).items;return(Array.isArray(r)?r:[]).flatMap(s=>{const e=i(s);return typeof e.id!="string"||e.kind!=="skill"&&e.kind!=="lesson"?[]:[{id:e.id,kind:e.kind,version:Number(e.version)||0,updatedAt:typeof e.updatedAt=="string"?e.updatedAt:new Date(0).toISOString()}]})},async get(t){const{status:n,data:r}=await o("GET",m(t));if(n===404)return;if(n!==200)throw new c(n);const s=i(r);return{version:Number(s.version)||0,content:i(s.content)}},async put(t,n,r,s){const{status:e,data:d}=await o("PUT",m(t),{kind:n,baseVersion:r,content:s,device:a.device.slice(0,64)});if(e===200)return{status:"written",version:Number(i(d).version)||0};if(e===409)return{status:"conflict"};if(e===413||e===422||e===400)return{status:"refused",reason:String(i(d).error??e)};throw new c(e)},async remove(t){const{status:n}=await o("DELETE",m(t));if(n===200)return!0;if(n===404)return!1;throw new c(n)},async removeAll(){const{status:t,data:n}=await o("DELETE","");if(t!==200)throw new c(t);return Number(i(n).removed)||0}}}f(w,"g"),p(w,"createHttpRemote");export{w as createHttpRemote};
1
+ var E=Object.defineProperty;var g=(f,l)=>E(f,"name",{value:l,configurable:!0});var b=Object.defineProperty,w=g((f,l)=>b(f,"name",{value:l,configurable:!0}),"f");import{SyncHttpError as d}from"./core.js";function A(f){const l=`${f.apiBase.replace(/\/+$/,"")}/portal/dal-sync`,q=f.fetch??fetch;async function c(t,e,r,s){const n=await f.token();if(!n)throw new d(401);const o=await q(`${l}${e}`,{method:t,headers:{Authorization:`Bearer ${n}`,Accept:"application/json",...r===void 0?{}:{"Content-Type":"application/json"}},body:r===void 0?void 0:JSON.stringify(r),signal:AbortSignal.timeout(s??f.timeoutMs??2e4)}),u=await o.json().catch(()=>null);return{status:o.status,data:u}}g(c,"d"),w(c,"call");const a=w(t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},"record"),m=w(t=>`/items/${encodeURIComponent(t)}`,"item"),i=w(t=>Number(t)||0,"num"),p=w(t=>typeof t=="string"&&t?t:null,"strOrNull"),h=w(t=>{const e=a(t);if(typeof e.id=="string")return{id:e.id,generation:i(e.generation),nextSeq:i(e.nextSeq),title:p(e.title),projectKey:p(e.projectKey),projectName:p(e.projectName),cwd:p(e.cwd),device:p(e.device),entries:i(e.entries),createdAt:p(e.createdAt),modifiedAt:p(e.modifiedAt)}},"toSession"),y=w(t=>`/sessions/${encodeURIComponent(t)}`,"session"),v=12e4;return{sessions:{async list(t,e=200){const r=new URLSearchParams({limit:String(e)});t&&r.set("project",t);const{status:s,data:n}=await c("GET",`/sessions?${r}`);if(s!==200)throw new d(s);const o=a(n).sessions;return(Array.isArray(o)?o:[]).flatMap(u=>h(u)??[])},async putMeta(t,e,r){const{status:s,data:n}=await c("PUT",y(t),{...e,device:f.device.slice(0,64),...r?.create===!1?{create:!1}:{}});if(s===404)return{status:"missing"};if(s===200){const o=h(n);if(o)return{status:"ok",session:o}}if(s===409)return{status:"conflict",generation:i(a(n).generation),nextSeq:i(a(n).nextSeq)};if(s===413)return{status:"quota"};if(s===400)return{status:"refused",reason:String(a(n).error??s)};throw new d(s)},async append(t,e){const{status:r,data:s}=await c("POST",`${y(t)}/chunks`,e,v),n=a(s);if(r===200)return{status:"ok",nextSeq:i(n.nextSeq)};if(r===409)return{status:"conflict",generation:i(n.generation),nextSeq:i(n.nextSeq)};if(r===404)return{status:"missing"};if(r===413&&n.error==="account_quota_exceeded")return{status:"quota"};if(r===413||r===400)return{status:"refused",reason:String(n.error??r)};throw new d(r)},async chunks(t,e,r){const s=new URLSearchParams({generation:String(e),after:String(r)}),{status:n,data:o}=await c("GET",`${y(t)}/chunks?${s}`,void 0,v),u=a(o);if(n===200){const k=Array.isArray(u.chunks)?u.chunks:[];return{status:"ok",generation:i(u.generation),nextSeq:i(u.nextSeq),more:u.more===!0,chunks:k.flatMap(x=>{const S=a(x);return typeof S.data=="string"?[{seq:i(S.seq),data:S.data}]:[]})}}if(n===409)return{status:"conflict",generation:i(u.generation),nextSeq:i(u.nextSeq)};if(n===404)return{status:"missing"};throw new d(n)},async remove(t){const{status:e}=await c("DELETE",y(t));if(e===200)return!0;if(e===404)return!1;throw new d(e)}},async manifest(){const{status:t,data:e}=await c("GET","/manifest");if(t!==200)throw new d(t);const r=a(e).items;return(Array.isArray(r)?r:[]).flatMap(s=>{const n=a(s);return typeof n.id!="string"||n.kind!=="skill"&&n.kind!=="lesson"?[]:[{id:n.id,kind:n.kind,version:Number(n.version)||0,updatedAt:typeof n.updatedAt=="string"?n.updatedAt:new Date(0).toISOString()}]})},async get(t){const{status:e,data:r}=await c("GET",m(t));if(e===404)return;if(e!==200)throw new d(e);const s=a(r);return{version:Number(s.version)||0,content:a(s.content)}},async put(t,e,r,s){const{status:n,data:o}=await c("PUT",m(t),{kind:e,baseVersion:r,content:s,device:f.device.slice(0,64)});if(n===200)return{status:"written",version:Number(a(o).version)||0};if(n===409)return{status:"conflict"};if(n===413||n===422||n===400)return{status:"refused",reason:String(a(o).error??n)};throw new d(n)},async remove(t){const{status:e}=await c("DELETE",m(t));if(e===200)return!0;if(e===404)return!1;throw new d(e)},async removeAll(){const{status:t,data:e}=await c("DELETE","");if(t!==200)throw new d(t);return Number(a(e).removed)||0}}}g(A,"v"),w(A,"createHttpRemote");export{A as createHttpRemote};
@@ -1,14 +1,20 @@
1
1
  import { type HttpRemote } from "./client.js";
2
2
  import { type SyncReport } from "./core.js";
3
+ import { type SessionSyncOptions, type SessionSyncReport } from "./sessions.js";
3
4
  export declare const SETTINGS_KEY = "dalSync";
4
5
  export declare const SYNC_CONSOLE_URL = "https://deepailab.ai/dal-sync";
5
6
  export declare function syncEnabled(agentDir: string): boolean;
7
+ export declare function syncChosen(agentDir: string): boolean;
8
+ export declare function takeSyncNotice(agentDir: string, account: string): boolean;
6
9
  export declare function saveSyncEnabled(agentDir: string, enabled: boolean): void;
7
10
  export declare function syncErrorStatus(error: unknown): number;
8
11
  export declare function syncErrorText(error: unknown): string;
9
12
  export interface SyncStatus {
10
13
  readonly enabled: boolean;
11
14
  readonly synced: number;
15
+ readonly sessions: number;
16
+ readonly sessionsPendingBytes: number;
17
+ readonly sessionsQuotaExceeded: boolean;
12
18
  readonly lastRun?: string;
13
19
  readonly lastError?: string;
14
20
  readonly lastErrorStatus?: number;
@@ -21,5 +27,9 @@ export interface SyncConnection {
21
27
  readonly fetch?: typeof fetch;
22
28
  }
23
29
  export declare function syncRemote(connection: SyncConnection): HttpRemote;
24
- export declare function syncOnce(agentDir: string, account: string, remote: HttpRemote): Promise<SyncReport>;
30
+ export interface FullSyncReport extends SyncReport {
31
+ readonly sessions?: SessionSyncReport;
32
+ }
33
+ export declare function syncOnce(agentDir: string, account: string, remote: HttpRemote, sessions?: SessionSyncOptions): Promise<FullSyncReport>;
25
34
  export declare function removeCloudCopies(agentDir: string, remote: HttpRemote): Promise<number>;
35
+ export declare function deleteCloudSession(agentDir: string, account: string, remote: HttpRemote, sessionId: string): Promise<boolean>;
@@ -1,2 +1,2 @@
1
- var v=Object.defineProperty;var n=(u,t)=>v(u,"name",{value:t,configurable:!0});var w=Object.defineProperty,a=n((u,t)=>w(u,"name",{value:t,configurable:!0}),"o");import{existsSync as b,readFileSync as B}from"node:fs";import{join as g}from"node:path";import{declaredDataFormat as h,t as o,withFileLockSync as R,writeFileAtomicSync as O}from"@dalcode/dal-pi-kit";import{createHttpRemote as N}from"./client.js";import{clearState as L,readState as S,runSync as j,SyncHttpError as x,writeState as J}from"./core.js";const c="dalSync",T="https://deepailab.ai/dal-sync",A=a(u=>g(u,"settings.json"),"settingsPath");function i(u){try{const t=JSON.parse(B(u,"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}n(i,"c"),a(i,"readJson");function E(u){return process.env.DAL_SYNC==="0"?!1:i(A(u))?.[c]?.enabled===!0}n(E,"k"),a(E,"syncEnabled");function d(u,t){const r=A(u);R(r,()=>{if(b(r)&&i(r)===void 0)throw new Error(`${r} is not valid JSON; not overwriting it`);const s=i(r)??{};if(h(s)>1)throw new Error(`${r} was written by a newer DAL; not overwriting it`);const e=s[c]??{};s[c]={...e,enabled:t},O(r,`${JSON.stringify(s,null,2)}
2
- `)})}n(d,"P"),a(d,"saveSyncEnabled");function f(u,t){return u.replace(/\{(\w+)\}/g,(r,s)=>s in t?String(t[s]):r)}n(f,"A"),a(f,"fill");function l(u){return u instanceof x?u.status:0}n(l,"f"),a(l,"syncErrorStatus");function F(u){const t=l(u);return t===401?o("\u672A\u767B\u5F55 DeepAILab\uFF0C\u6216\u767B\u5F55\u5DF2\u8FC7\u671F\uFF1B\u767B\u5F55\u540E\u4F1A\u81EA\u52A8\u7EE7\u7EED\u540C\u6B65\u3002"):t===404?o("\u540C\u6B65\u670D\u52A1\u5C1A\u672A\u5F00\u653E\uFF0C\u5F00\u653E\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\u3002"):t===503?o("\u540C\u6B65\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002"):t?f(o("\u540C\u6B65\u8BF7\u6C42\u5931\u8D25\uFF08{status}\uFF09\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002"),{status:t}):o("\u7F51\u7EDC\u4E0D\u53EF\u7528\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002")}n(F,"C"),a(F,"syncErrorText");function C(u){const t=S(u),r=t?Object.values(t.items).filter(s=>!s.remoteDeleted&&s.version>0).length:0;return{enabled:E(u),synced:r,...t?.lastRun?{lastRun:t.lastRun}:{},...t?.lastError?{lastError:t.lastError}:{},...t?.lastError&&t.lastErrorStatus!==void 0?{lastErrorStatus:t.lastErrorStatus}:{}}}n(C,"_"),a(C,"syncStatus");function m(u){return N(u)}n(m,"T"),a(m,"syncRemote");async function D(u,t,r){try{return await j(u,t,r)}catch(s){const e=S(u),y=e?.account===t;throw J(u,{account:t,items:y?e.items:{},lastRun:y?e.lastRun:void 0,lastError:F(s),lastErrorStatus:l(s)}),s}}n(D,"Y"),a(D,"syncOnce");async function p(u,t){const r=await t.removeAll();return L(u),r}n(p,"$"),a(p,"removeCloudCopies");export{c as SETTINGS_KEY,T as SYNC_CONSOLE_URL,p as removeCloudCopies,d as saveSyncEnabled,E as syncEnabled,l as syncErrorStatus,F as syncErrorText,D as syncOnce,m as syncRemote,C as syncStatus};
1
+ var N=Object.defineProperty;var r=(t,e)=>N(t,"name",{value:e,configurable:!0});var k=Object.defineProperty,a=r((t,e)=>k(t,"name",{value:e,configurable:!0}),"r");import{existsSync as R,readFileSync as T}from"node:fs";import{join as j}from"node:path";import{declaredDataFormat as x,t as i,withFileLockSync as L,writeFileAtomicSync as I}from"@dalcode/dal-pi-kit";import{createHttpRemote as _}from"./client.js";import{clearState as $,readState as m,runSync as J,SyncHttpError as P,writeState as q}from"./core.js";import{clearSessionsState as G,markSessionDeleted as C,readSessionsState as D,syncSessions as H,writeSessionsState as M}from"./sessions.js";const l="dalSync",U="https://deepailab.ai/dal-sync",f=a(t=>j(t,"settings.json"),"settingsPath");function E(t){try{const e=JSON.parse(T(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}r(E,"l"),a(E,"readJson");function d(t){return process.env.DAL_SYNC==="0"?!1:E(f(t))?.[l]?.enabled!==!1}r(d,"j"),a(d,"syncEnabled");function F(t){return typeof E(f(t))?.[l]?.enabled=="boolean"}r(F,"H"),a(F,"syncChosen");function p(t,e){if(F(t))return!1;const s=D(t);if(s?.noticeShownAt)return!1;const n=s?.account===e?s:{account:e,sessions:{},projects:{}};return M(t,{...n,noticeShownAt:new Date().toISOString()}),!0}r(p,"D"),a(p,"takeSyncNotice");function w(t,e){const s=f(t);L(s,()=>{if(R(s)&&E(s)===void 0)throw new Error(`${s} is not valid JSON; not overwriting it`);const n=E(s)??{};if(x(n)>1)throw new Error(`${s} was written by a newer DAL; not overwriting it`);const o=n[l]??{};n[l]={...o,enabled:e},I(s,`${JSON.stringify(n,null,2)}
2
+ `)})}r(w,"G"),a(w,"saveSyncEnabled");function y(t,e){return t.replace(/\{(\w+)\}/g,(s,n)=>n in e?String(e[n]):s)}r(y,"p"),a(y,"fill");function v(t){return t instanceof Error?t.name==="TimeoutError"||t.name==="AbortError"?!0:t instanceof TypeError&&/fetch failed|network|socket|ECONN|ENOTFOUND|ETIMEDOUT|EAI_AGAIN/i.test(`${t.message} ${String(t.cause??"")}`):!1}r(v,"P"),a(v,"isNetworkFailure");function S(t){return t instanceof P?t.status:v(t)?0:-1}r(S,"m"),a(S,"syncErrorStatus");function A(t){const e=S(t);if(e===401)return i("\u672A\u767B\u5F55 DeepAILab\uFF0C\u6216\u767B\u5F55\u5DF2\u8FC7\u671F\uFF1B\u767B\u5F55\u540E\u4F1A\u81EA\u52A8\u7EE7\u7EED\u540C\u6B65\u3002");if(e===404)return i("\u540C\u6B65\u670D\u52A1\u5C1A\u672A\u5F00\u653E\uFF0C\u5F00\u653E\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\u3002");if(e===503)return i("\u540C\u6B65\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002");if(e===-1){const s=t instanceof Error?t.message:String(t);return y(i("\u540C\u6B65\u51FA\u9519\uFF08{detail}\uFF09\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002"),{detail:s.slice(0,200)})}return e?y(i("\u540C\u6B65\u8BF7\u6C42\u5931\u8D25\uFF08{status}\uFF09\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002"),{status:e}):i("\u7F51\u7EDC\u4E0D\u53EF\u7528\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002")}r(A,"L"),a(A,"syncErrorText");function b(t){const e=m(t),s=e?Object.values(e.items).filter(u=>!u.remoteDeleted&&u.version>0).length:0,n=D(t),o=n?Object.values(n.sessions).filter(u=>!u.remoteDeleted&&!u.skipped&&u.nextSeq>0):[];return{enabled:d(t),synced:s,sessions:o.length,sessionsPendingBytes:n?Object.values(n.sessions).filter(u=>!u.remoteDeleted&&!u.skipped).reduce((u,c)=>u+Math.max(0,c.size-c.offset),0):0,sessionsQuotaExceeded:n?.quotaExceeded===!0,...e?.lastRun?{lastRun:e.lastRun}:{},...e?.lastError?{lastError:e.lastError}:{},...e?.lastError&&e.lastErrorStatus!==void 0?{lastErrorStatus:e.lastErrorStatus}:{}}}r(b,"M"),a(b,"syncStatus");function g(t){return _(t)}r(g,"Q"),a(g,"syncRemote");async function h(t,e,s,n){try{const o=await J(t,e,s);return n?{...o,sessions:await H(t,e,s.sessions,n)}:o}catch(o){const u=m(t),c=u?.account===e;throw q(t,{account:e,items:c?u.items:{},lastRun:c?u.lastRun:void 0,lastError:A(o),lastErrorStatus:S(o)}),o}}r(h,"z"),a(h,"syncOnce");async function O(t,e){const s=await e.removeAll();return $(t),G(t),s}r(O,"K"),a(O,"removeCloudCopies");async function B(t,e,s,n){C(t,e,n,!0);const o=await s.sessions.remove(n);return C(t,e,n,!1),o}r(B,"V"),a(B,"deleteCloudSession");export{l as SETTINGS_KEY,U as SYNC_CONSOLE_URL,B as deleteCloudSession,O as removeCloudCopies,w as saveSyncEnabled,F as syncChosen,d as syncEnabled,S as syncErrorStatus,A as syncErrorText,h as syncOnce,g as syncRemote,b as syncStatus,p as takeSyncNotice};
@@ -1,3 +1,3 @@
1
- var b=Object.defineProperty;var l=(o,n)=>b(o,"name",{value:n,configurable:!0});var S=Object.defineProperty,a=l((o,n)=>S(o,"name",{value:n,configurable:!0}),"i");import{hostname as T}from"node:os";import{t as s}from"@dalcode/dal-pi-kit";import{deepAILabApiBase as R,resolveDeepAILabAccessToken as B}from"@dalcode/deepailab";import{decodeJwtPayload as I}from"@dalcode/deepailab/oidc";import{getAgentDir as L,VERSION as O}from"@earendil-works/pi-coding-agent";import{readState as _,SyncHttpError as j}from"./core.js";import{SYNC_CONSOLE_URL as y,syncErrorText as d,removeCloudCopies as k,syncOnce as N,saveSyncEnabled as g,syncEnabled as C,syncRemote as P}from"./host.js";import{SETTINGS_KEY as U,saveSyncEnabled as $,syncEnabled as Y}from"./host.js";const x=2e4,G="DALCODE_GATEWAY_URL";function r(o,n){return o.replace(/\{(\w+)\}/g,(c,E)=>E in n?String(n[E]):c)}l(r,"u"),a(r,"fill");function f(o){const n=[r(s("\u4E0A\u4F20 {n}"),{n:o.uploaded}),r(s("\u4E0B\u8F7D {n}"),{n:o.downloaded})];return o.deletedRemote&&n.push(r(s("\u4E91\u7AEF\u5220\u9664 {n}"),{n:o.deletedRemote})),o.conflicts&&n.push(r(s("\u51B2\u7A81 {n}\uFF08\u6309\u8F83\u65B0\u7684\u4FEE\u6539\u5904\u7406\uFF09"),{n:o.conflicts})),o.refused.length&&n.push(r(s("\u672A\u4E0A\u4F20 {n}\uFF08\u8FC7\u5927\u6216\u7591\u4F3C\u542B\u5BC6\u94A5\uFF09"),{n:o.refused.length})),n.join(s("\uFF0C"))}l(f,"C"),a(f,"reportText");function w(o){const n=L();let c=Promise.resolve(),E;const F=a((e,u,t="info")=>{e.hasUI?e.ui.notify(u,t):process.stdout.write(`${u}
2
- `)},"say"),D=a(e=>P({apiBase:R(),token:a(()=>B(e.modelRegistry),"token"),device:`${T()} (dal ${O})`}),"remoteFor"),h=a(async e=>{const u=await B(e.modelRegistry),t=u?I(u)?.sub:void 0;return typeof t=="string"&&t?t:void 0},"accountOf"),A=a(async e=>{const u=await h(e);if(!u)throw new j(401);return N(n,u,D(e))},"syncOnce"),p=a(e=>{if(!C(n)||!e.hasUI||process.env[G])return;const u=a(()=>A(e),"work");c=c.then(u,u).catch(()=>{})},"background");o.on("session_start",(e,u)=>{u.mode==="print"||u.mode==="json"||p(u)}),o.on("agent_end",(e,u)=>{u.mode==="print"||u.mode==="json"||!C(n)||(E&&clearTimeout(E),E=setTimeout(()=>p(u),x),E.unref?.())}),o.on("session_shutdown",async()=>{E&&clearTimeout(E),await Promise.race([c,new Promise(e=>setTimeout(e,5e3).unref?.())])});const v=a(()=>{const e=C(n),u=_(n),t=[e?s("\u6280\u80FD\u4E0E\u7ECF\u9A8C\u540C\u6B65\uFF1A\u5DF2\u5F00\u542F\u3002"):s("\u6280\u80FD\u4E0E\u7ECF\u9A8C\u540C\u6B65\uFF1A\u672A\u5F00\u542F\uFF08/sync on \u5F00\u542F\uFF09\u3002")];if(u){const m=Object.values(u.items).filter(i=>!i.remoteDeleted&&i.version>0).length;t.push(r(s("\u5DF2\u540C\u6B65 {n} \u6761\u3002"),{n:m})),u.lastRun&&t.push(r(s("\u4E0A\u6B21\u540C\u6B65\uFF1A{time}"),{time:new Date(u.lastRun).toLocaleString()})),u.lastError&&t.push(u.lastError)}return t.push(r(s("\u5728 {url} \u67E5\u770B\u3001\u5220\u9664\u548C\u5BFC\u51FA\u3002"),{url:y})),t.join(`
3
- `)},"status");o.registerCommand("sync",{description:s("\u540C\u6B65\u4E2A\u4EBA\u6280\u80FD\u548C\u4E2A\u4EBA\u7ECF\u9A8C\u5230 DeepAILab \u8D26\u6237\uFF08/sync on | off | now | status\uFF09"),getArgumentCompletions:a(e=>{const u=["on","off","now","status"].filter(t=>t.startsWith(e.trim()));return u.length?u.map(t=>({value:t,label:t})):null},"getArgumentCompletions"),handler:a(async(e,u)=>{const[t="status",m]=e.trim().toLowerCase().split(/\s+/);if(t==="status"||t===""){F(u,v());return}if(t==="on"){g(n,!0),F(u,s("\u5DF2\u5F00\u542F\u3002\u4F1A\u540C\u6B65\uFF1A\u4F60\u7684\u4E2A\u4EBA\u6280\u80FD\uFF08~/.dal/agent/skills\uFF09\u548C\u9002\u7528\u4E8E\u6240\u6709\u9879\u76EE\u7684\u4E2A\u4EBA\u7ECF\u9A8C\u3002\u4E0D\u4F1A\u540C\u6B65\uFF1A\u9879\u76EE\u7ECF\u9A8C\u3001\u5BF9\u8BDD\u3001\u4EE3\u7801\u3001\u8BBE\u7F6E\u548C\u4EFB\u4F55\u51ED\u636E\u3002\u4E0A\u4F20\u524D\u4F1A\u53BB\u6389\u5BC6\u94A5\u3001\u5BC6\u7801\u548C\u4E3B\u76EE\u5F55\u8DEF\u5F84\u3002"));try{F(u,f(await A(u)))}catch(i){F(u,d(i),"warning")}return}if(t==="now"){if(!C(n)){F(u,s("\u540C\u6B65\u672A\u5F00\u542F\uFF0C\u5148\u8FD0\u884C /sync on\u3002"),"warning");return}try{F(u,f(await A(u)))}catch(i){F(u,d(i),"warning")}return}if(t==="off"){if(g(n,!1),!(m==="--delete-cloud"||u.hasUI&&await u.ui.confirm(s("\u5173\u95ED\u540C\u6B65"),s("\u540C\u65F6\u5220\u9664\u4E91\u7AEF\u7684\u526F\u672C\u5417\uFF1F\u7535\u8111\u4E0A\u7684\u6280\u80FD\u548C\u7ECF\u9A8C\u4E0D\u53D7\u5F71\u54CD\u3002")))){F(u,r(s("\u5DF2\u5173\u95ED\uFF0C\u4E0D\u518D\u4E0A\u4F20\u3002\u4E91\u7AEF\u526F\u672C\u4FDD\u7559\uFF0C\u53EF\u5728 {url} \u5220\u9664\u3002"),{url:y}));return}try{const i=await k(n,D(u));F(u,r(s("\u5DF2\u5173\u95ED\uFF0C\u5E76\u5220\u9664\u4E86\u4E91\u7AEF\u7684 {n} \u6761\u3002"),{n:i}))}catch(i){F(u,`${s("\u5DF2\u5173\u95ED\uFF0C\u4F46\u4E91\u7AEF\u526F\u672C\u6CA1\u6709\u5220\u9664\uFF1A")}${d(i)}`,"warning")}return}F(u,s("\u7528\u6CD5\uFF1A/sync on | off | now | status"),"warning")},"handler")})}l(w,"H"),a(w,"default");export{U as SETTINGS_KEY,w as default,$ as saveSyncEnabled,Y as syncEnabled};
1
+ var v=Object.defineProperty;var A=(t,e)=>v(t,"name",{value:e,configurable:!0});var T=Object.defineProperty,E=A((t,e)=>T(t,"name",{value:e,configurable:!0}),"r");import{hostname as I}from"node:os";import{t as s}from"@dalcode/dal-pi-kit";import{deepAILabApiBase as L,resolveDeepAILabAccessToken as w}from"@dalcode/deepailab";import{decodeJwtPayload as R}from"@dalcode/deepailab/oidc";import{getAgentDir as O,getDefaultSessionDir as _,VERSION as P}from"@earendil-works/pi-coding-agent";import{readState as k,SyncHttpError as x}from"./core.js";import{SYNC_CONSOLE_URL as d,syncErrorText as l,removeCloudCopies as j,syncOnce as M,saveSyncEnabled as g,syncEnabled as c,syncRemote as N,syncStatus as U,takeSyncNotice as $}from"./host.js";import{SETTINGS_KEY as Y,saveSyncEnabled as G,syncEnabled as H}from"./host.js";const K=2e4,W="DALCODE_GATEWAY_URL";function o(t,e){return t.replace(/\{(\w+)\}/g,(a,i)=>i in e?String(e[i]):a)}A(o,"a"),E(o,"fill");function m(t){const e=[];if(t.sessions){const a=t.sessions;e.push(o(s("\u5BF9\u8BDD\uFF1A\u4E0A\u4F20 {up}\uFF0C\u4E0B\u8F7D {down}"),{up:a.uploaded,down:a.downloaded+a.updated})),a.pendingBytes>0&&e.push(o(s("\u8FD8\u6709\u7EA6 {mb} MB \u7A0D\u540E\u7EE7\u7EED\u4E0A\u4F20"),{mb:Math.max(1,Math.round(a.pendingBytes/1048576))})),a.quotaExceeded&&e.push(s("\u8D26\u6237\u7684\u5BF9\u8BDD\u7A7A\u95F4\u5DF2\u6EE1\uFF0C\u65B0\u5BF9\u8BDD\u53EA\u4FDD\u5B58\u5728\u8FD9\u53F0\u7535\u8111"))}return e.push(o(s("\u6280\u80FD\u4E0E\u7ECF\u9A8C\uFF1A\u4E0A\u4F20 {n}"),{n:t.uploaded}),o(s("\u4E0B\u8F7D {n}"),{n:t.downloaded})),t.deletedRemote&&e.push(o(s("\u4E91\u7AEF\u5220\u9664 {n}"),{n:t.deletedRemote})),t.conflicts&&e.push(o(s("\u51B2\u7A81 {n}\uFF08\u6309\u8F83\u65B0\u7684\u4FEE\u6539\u5904\u7406\uFF09"),{n:t.conflicts})),t.refused.length&&e.push(o(s("\u672A\u4E0A\u4F20 {n}\uFF08\u8FC7\u5927\u6216\u7591\u4F3C\u542B\u5BC6\u94A5\uFF09"),{n:t.refused.length})),e.join(s("\uFF0C"))}A(m,"C"),E(m,"reportText");function b(t){const e=O();let a=Promise.resolve(),i;const D=E((n,u,F="info")=>{n.hasUI?n.ui.notify(u,F):process.stdout.write(`${u}
2
+ `)},"say"),f=E(n=>N({apiBase:L(),token:E(()=>w(n.modelRegistry),"token"),device:`${I()} (dal ${P})`}),"remoteFor"),p=E(async n=>{const u=await w(n.modelRegistry),F=u?R(u)?.sub:void 0;return typeof F=="string"&&F?F:void 0},"accountOf"),C=E(async(n,u)=>{const F=u??await p(n);if(!F)throw new x(401);return M(e,F,f(n),{sessionDirFor:E(r=>_(r,e),"sessionDirFor"),pullCwds:[n.cwd]})},"syncOnce"),y=E(n=>{if(!c(e)||!n.hasUI||process.env[W])return;const u=E(async()=>{const F=await p(n);F&&(await C(n,F),$(e,F)&&n.ui.notify(o(s("\u4F60\u7684\u5BF9\u8BDD\u3001\u4E2A\u4EBA\u6280\u80FD\u548C\u7ECF\u9A8C\u4F1A\u540C\u6B65\u5230 DeepAILab \u8D26\u6237\uFF0C\u6362\u7535\u8111\u767B\u5F55\u540E\u53EF\u4EE5\u63A5\u7740\u7528\u3002\u4E0A\u4F20\u524D\u4F1A\u53BB\u6389\u5BC6\u94A5\u3001\u5BC6\u7801\u548C\u4E3B\u76EE\u5F55\u8DEF\u5F84\uFF0C\u56FE\u7247\u4E0D\u4E0A\u4F20\u3002\u5728 {url} \u67E5\u770B\u548C\u5220\u9664\uFF1B/sync off \u5173\u95ED\u3002"),{url:d}),"info"))},"work");a=a.then(u,u).catch(()=>{})},"background");t.on("session_start",(n,u)=>{u.mode==="print"||u.mode==="json"||y(u)}),t.on("agent_end",(n,u)=>{u.mode==="print"||u.mode==="json"||!c(e)||(i&&clearTimeout(i),i=setTimeout(()=>y(u),K),i.unref?.())}),t.on("session_shutdown",async()=>{i&&clearTimeout(i),await Promise.race([a,new Promise(n=>setTimeout(n,5e3).unref?.())])});const S=E(()=>{const n=c(e),u=k(e),F=U(e),r=[n?s("\u540C\u6B65\uFF1A\u5DF2\u5F00\u542F\uFF08\u5BF9\u8BDD\u3001\u4E2A\u4EBA\u6280\u80FD\u548C\u7ECF\u9A8C\uFF09\u3002"):s("\u540C\u6B65\uFF1A\u5DF2\u5173\u95ED\uFF0C\u53EA\u4FDD\u5B58\u5728\u8FD9\u53F0\u7535\u8111\uFF08/sync on \u5F00\u542F\uFF09\u3002")];if((F.sessions||F.sessionsPendingBytes)&&(r.push(o(s("\u5DF2\u540C\u6B65\u5BF9\u8BDD {n} \u4E2A\u3002"),{n:F.sessions})),F.sessionsPendingBytes>0&&r.push(o(s("\u8FD8\u6709\u7EA6 {mb} MB \u5BF9\u8BDD\u5F85\u4E0A\u4F20\uFF0C\u4F1A\u5728\u540E\u53F0\u7EE7\u7EED\u3002"),{mb:Math.max(1,Math.round(F.sessionsPendingBytes/1048576))})),F.sessionsQuotaExceeded&&r.push(s("\u8D26\u6237\u7684\u5BF9\u8BDD\u7A7A\u95F4\u5DF2\u6EE1\uFF0C\u65B0\u5BF9\u8BDD\u53EA\u4FDD\u5B58\u5728\u8FD9\u53F0\u7535\u8111\u3002"))),u){const B=Object.values(u.items).filter(h=>!h.remoteDeleted&&h.version>0).length;r.push(o(s("\u5DF2\u540C\u6B65\u6280\u80FD\u4E0E\u7ECF\u9A8C {n} \u6761\u3002"),{n:B})),u.lastRun&&r.push(o(s("\u4E0A\u6B21\u540C\u6B65\uFF1A{time}"),{time:new Date(u.lastRun).toLocaleString()})),u.lastError&&r.push(u.lastError)}return r.push(o(s("\u5728 {url} \u67E5\u770B\u3001\u5220\u9664\u548C\u5BFC\u51FA\u3002"),{url:d})),r.join(`
3
+ `)},"status");t.registerCommand("sync",{description:s("\u5BF9\u8BDD\u3001\u4E2A\u4EBA\u6280\u80FD\u548C\u7ECF\u9A8C\u8DDF\u968F DeepAILab \u8D26\u6237\u540C\u6B65\uFF08/sync on | off | now | status\uFF09"),getArgumentCompletions:E(n=>{const u=["on","off","now","status"].filter(F=>F.startsWith(n.trim()));return u.length?u.map(F=>({value:F,label:F})):null},"getArgumentCompletions"),handler:E(async(n,u)=>{const[F="status",r]=n.trim().toLowerCase().split(/\s+/);if(F==="status"||F===""){D(u,S());return}if(F==="on"){g(e,!0),D(u,s("\u5DF2\u5F00\u542F\u3002\u4F1A\u540C\u6B65\uFF1A\u5BF9\u8BDD\u8BB0\u5F55\u3001\u4F60\u7684\u4E2A\u4EBA\u6280\u80FD\uFF08~/.dal/agent/skills\uFF09\u548C\u9002\u7528\u4E8E\u6240\u6709\u9879\u76EE\u7684\u4E2A\u4EBA\u7ECF\u9A8C\uFF1B\u5728\u53E6\u4E00\u53F0\u7535\u8111\u767B\u5F55\u540E\uFF0C\u540C\u4E00\u4E2A\u9879\u76EE\u91CC\u53EF\u4EE5\u63A5\u7740\u4E4B\u524D\u7684\u5BF9\u8BDD\u3002\u4E0D\u4F1A\u540C\u6B65\uFF1A\u9879\u76EE\u7ECF\u9A8C\u3001\u9879\u76EE\u6587\u4EF6\u3001\u56FE\u7247\u3001\u8BBE\u7F6E\u548C\u4EFB\u4F55\u51ED\u636E\u3002\u4E0A\u4F20\u524D\u4F1A\u53BB\u6389\u5BC6\u94A5\u3001\u5BC6\u7801\u548C\u4E3B\u76EE\u5F55\u8DEF\u5F84\u3002"));try{D(u,m(await C(u)))}catch(B){D(u,l(B),"warning")}return}if(F==="now"){if(!c(e)){D(u,s("\u540C\u6B65\u672A\u5F00\u542F\uFF0C\u5148\u8FD0\u884C /sync on\u3002"),"warning");return}try{D(u,m(await C(u)))}catch(B){D(u,l(B),"warning")}return}if(F==="off"){if(g(e,!1),!(r==="--delete-cloud"||u.hasUI&&await u.ui.confirm(s("\u5173\u95ED\u540C\u6B65"),s("\u540C\u65F6\u5220\u9664\u4E91\u7AEF\u7684\u526F\u672C\u5417\uFF08\u5BF9\u8BDD\u3001\u6280\u80FD\u548C\u7ECF\u9A8C\uFF09\uFF1F\u8FD9\u53F0\u7535\u8111\u4E0A\u7684\u5185\u5BB9\u4E0D\u53D7\u5F71\u54CD\u3002")))){D(u,o(s("\u5DF2\u5173\u95ED\uFF0C\u4E0D\u518D\u4E0A\u4F20\u3002\u4E91\u7AEF\u526F\u672C\u4FDD\u7559\uFF0C\u53EF\u5728 {url} \u5220\u9664\u3002"),{url:d}));return}try{const B=await j(e,f(u));D(u,o(s("\u5DF2\u5173\u95ED\uFF0C\u5E76\u5220\u9664\u4E86\u4E91\u7AEF\u7684 {n} \u6761\u3002"),{n:B}))}catch(B){D(u,`${s("\u5DF2\u5173\u95ED\uFF0C\u4F46\u4E91\u7AEF\u526F\u672C\u6CA1\u6709\u5220\u9664\uFF1A")}${l(B)}`,"warning")}return}D(u,s("\u7528\u6CD5\uFF1A/sync on | off | now | status"),"warning")},"handler")})}A(b,"H"),E(b,"default");export{Y as SETTINGS_KEY,b as default,G as saveSyncEnabled,H as syncEnabled};
@@ -0,0 +1,153 @@
1
+ export interface RemoteSession {
2
+ readonly id: string;
3
+ readonly generation: number;
4
+ readonly nextSeq: number;
5
+ readonly title: string | null;
6
+ readonly projectKey: string | null;
7
+ readonly projectName: string | null;
8
+ readonly cwd: string | null;
9
+ readonly device: string | null;
10
+ readonly entries: number;
11
+ readonly createdAt: string | null;
12
+ readonly modifiedAt: string | null;
13
+ }
14
+ export interface SessionMetaInput {
15
+ readonly generation: number;
16
+ readonly title: string | null;
17
+ readonly projectKey: string | null;
18
+ readonly projectName: string | null;
19
+ readonly cwd: string | null;
20
+ readonly createdAt: string | null;
21
+ readonly modifiedAt: string | null;
22
+ }
23
+ export type MetaResult = {
24
+ status: "ok";
25
+ session: RemoteSession;
26
+ } | {
27
+ status: "missing";
28
+ } | {
29
+ status: "conflict";
30
+ generation: number;
31
+ nextSeq: number;
32
+ } | {
33
+ status: "quota";
34
+ } | {
35
+ status: "refused";
36
+ reason: string;
37
+ };
38
+ export type AppendResult = {
39
+ status: "ok";
40
+ nextSeq: number;
41
+ } | {
42
+ status: "conflict";
43
+ generation: number;
44
+ nextSeq: number;
45
+ } | {
46
+ status: "missing";
47
+ } | {
48
+ status: "quota";
49
+ } | {
50
+ status: "refused";
51
+ reason: string;
52
+ };
53
+ export type ChunksResult = {
54
+ status: "ok";
55
+ generation: number;
56
+ nextSeq: number;
57
+ more: boolean;
58
+ chunks: {
59
+ seq: number;
60
+ data: string;
61
+ }[];
62
+ } | {
63
+ status: "conflict";
64
+ generation: number;
65
+ nextSeq: number;
66
+ } | {
67
+ status: "missing";
68
+ };
69
+ export interface SessionRemote {
70
+ list(projectKey?: string, limit?: number): Promise<RemoteSession[]>;
71
+ putMeta(id: string, meta: SessionMetaInput, options?: {
72
+ create?: boolean;
73
+ }): Promise<MetaResult>;
74
+ append(id: string, chunk: {
75
+ generation: number;
76
+ seq: number;
77
+ data: string;
78
+ modifiedAt: string | null;
79
+ }): Promise<AppendResult>;
80
+ chunks(id: string, generation: number, after: number): Promise<ChunksResult>;
81
+ remove(id: string): Promise<boolean>;
82
+ }
83
+ export declare const DEFAULT_RUN_BUDGET: {
84
+ uploadBytes: number;
85
+ downloadBytes: number;
86
+ ms: number;
87
+ };
88
+ interface SessionState {
89
+ file: string;
90
+ generation: number;
91
+ nextSeq: number;
92
+ offset: number;
93
+ tail: string;
94
+ size: number;
95
+ mtimeMs: number;
96
+ metaHash?: string;
97
+ title?: string;
98
+ remoteDeleted?: boolean;
99
+ pendingDelete?: boolean;
100
+ deletedAt?: string;
101
+ skipped?: boolean;
102
+ }
103
+ interface ProjectState {
104
+ key: string | null;
105
+ name: string | null;
106
+ at: number;
107
+ }
108
+ export interface SessionsState {
109
+ account: string;
110
+ sessions: Record<string, SessionState>;
111
+ projects: Record<string, ProjectState>;
112
+ lastRun?: string;
113
+ quotaExceeded?: boolean;
114
+ noticeShownAt?: string;
115
+ }
116
+ export declare const sessionsStatePath: (agentDir: string) => string;
117
+ export declare function readSessionsState(agentDir: string): SessionsState | undefined;
118
+ export declare function writeSessionsState(agentDir: string, state: SessionsState): void;
119
+ export declare function markSessionDeleted(agentDir: string, account: string, sessionId: string, pending: boolean): void;
120
+ export declare function clearSessionsState(agentDir: string): void;
121
+ interface LocalSession {
122
+ readonly id: string;
123
+ readonly path: string;
124
+ readonly size: number;
125
+ readonly mtimeMs: number;
126
+ }
127
+ export declare function listLocalSessions(agentDir: string): LocalSession[];
128
+ export declare function cleanLine(line: string, home?: string): string | null;
129
+ export declare function normalizeRemote(url: string): string | undefined;
130
+ export declare function cwdLabel(cwd: string, home?: string): string;
131
+ export declare function projectIdentity(cwd: string, home?: string): ProjectState;
132
+ export interface SessionSyncOptions {
133
+ readonly sessionDirFor: (cwd: string) => string;
134
+ readonly pullCwds?: readonly string[];
135
+ readonly budget?: {
136
+ uploadBytes: number;
137
+ downloadBytes: number;
138
+ ms: number;
139
+ };
140
+ readonly home?: string;
141
+ readonly now?: () => number;
142
+ readonly localOnlyRoots?: readonly string[];
143
+ }
144
+ export interface SessionSyncReport {
145
+ uploaded: number;
146
+ downloaded: number;
147
+ updated: number;
148
+ pendingBytes: number;
149
+ quotaExceeded: boolean;
150
+ busy: boolean;
151
+ }
152
+ export declare function syncSessions(agentDir: string, account: string, remote: SessionRemote, options: SessionSyncOptions): Promise<SessionSyncReport>;
153
+ export {};
@@ -0,0 +1,15 @@
1
+ var Ee=Object.defineProperty;var d=(n,e)=>Ee(n,"name",{value:e,configurable:!0});var Re=Object.defineProperty,f=d((n,e)=>Re(n,"name",{value:e,configurable:!0}),"u");import{execFileSync as Ie}from"node:child_process";import{createHash as de}from"node:crypto";import{appendFileSync as Je,closeSync as Fe,existsSync as le,mkdirSync as J,openSync as _e,readdirSync as me,readFileSync as pe,readSync as He,rmSync as G,statSync as L,utimesSync as Te}from"node:fs";import{homedir as K}from"node:os";import{basename as Ce,isAbsolute as Ue,join as k,relative as We,resolve as V}from"node:path";import{gunzipSync as Pe,gzipSync as Ze}from"node:zlib";import{redact as X}from"@dalcode/dal-learn/safety";import{writeFileAtomicSync as ye}from"@dalcode/dal-pi-kit";const he=2*1024*1024,ge=3*1024*1024,Ge=2e5,Ke=2e4,Se={uploadBytes:48*1024*1024,downloadBytes:64*1024*1024,ms:9e4},Ve=50,Xe=1440*60*1e3,Ye=2160*60*60*1e3,we=1,Qe=4096,et=600*1e3,xe=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,tt=["/tmp/","/private/tmp/","/var/folders/","/private/var/folders/"],U=f(n=>k(n,"sync","sessions.json"),"sessionsStatePath");function F(n){try{const e=JSON.parse(pe(U(n),"utf8"));return e.formatVersion!==we||typeof e.account!="string"?void 0:{account:e.account,sessions:e.sessions&&typeof e.sessions=="object"?e.sessions:{},projects:e.projects&&typeof e.projects=="object"?e.projects:{},lastRun:typeof e.lastRun=="string"?e.lastRun:void 0,quotaExceeded:e.quotaExceeded===!0,noticeShownAt:typeof e.noticeShownAt=="string"?e.noticeShownAt:void 0}}catch{return}}d(F,"G"),f(F,"readSessionsState");function _(n,e){J(k(n,"sync"),{recursive:!0,mode:448}),ye(U(n),`${JSON.stringify({formatVersion:we,...e})}
2
+ `,{mode:384})}d(_,"U"),f(_,"writeSessionsState");function qe(n,e,t,s){const i=F(n),o=i?.account===e,c=o?i.sessions:{},r=c[t];c[t]={file:r?.file??"",generation:r?.generation??0,nextSeq:r?.nextSeq??0,offset:r?.offset??0,tail:r?.tail??"",size:r?.size??0,mtimeMs:r?.mtimeMs??0,remoteDeleted:!0,pendingDelete:s,deletedAt:new Date().toISOString()},_(n,{account:e,sessions:c,projects:o?i.projects:{},noticeShownAt:i?.noticeShownAt,...o&&i.quotaExceeded?{quotaExceeded:!0}:{}})}d(qe,"at"),f(qe,"markSessionDeleted");function be(n){const e=F(n);G(U(n),{force:!0}),e?.noticeShownAt&&_(n,{account:e.account,sessions:{},projects:{},noticeShownAt:e.noticeShownAt})}d(be,"ct"),f(be,"clearSessionsState");function ze(n){const e=k(n,"sync","sessions.lock");J(k(n,"sync"),{recursive:!0,mode:448});try{J(e)}catch{try{if(Date.now()-L(e).mtimeMs<et)return;G(e,{recursive:!0,force:!0}),J(e)}catch{return}}return()=>G(e,{recursive:!0,force:!0})}d(ze,"$e"),f(ze,"tryLock");function Y(n){const e=k(n,"sessions");if(!le(e))return[];const t=[];for(const s of me(e,{withFileTypes:!0})){if(!s.isDirectory())continue;let i;try{i=me(k(e,s.name))}catch{continue}for(const o of i){if(!o.endsWith(".jsonl"))continue;const c=o.slice(o.indexOf("_")+1,-6);if(!xe.test(c)||c.length>128)continue;const r=k(e,s.name,o);try{const l=L(r);l.isFile()&&l.size>0&&t.push({id:c,path:r,size:l.size,mtimeMs:l.mtimeMs})}catch{}}}return t.sort((s,i)=>i.mtimeMs-s.mtimeMs)}d(Y,"ve"),f(Y,"listLocalSessions");function E(n,e,t){const s=Math.max(0,t-e),i=Buffer.alloc(s);if(s===0)return i;const o=_e(n,"r");try{let c=0;for(;c<s;){const r=He(o,i,c,s-c,e+c);if(r===0)break;c+=r}return i.subarray(0,c)}finally{Fe(o)}}d(E,"T"),f(E,"readRange");function N(n,e){return de("sha256").update(E(n,Math.max(0,e-Qe),e)).digest("hex")}d(N,"L"),f(N,"tailHash");function Me(n){const e=E(n,0,1048576).toString("utf8"),t=e.slice(0,e.indexOf(`
3
+ `)>=0?e.indexOf(`
4
+ `):e.length);try{const s=JSON.parse(t);return s?.type==="session"&&typeof s.id=="string"?s:void 0}catch{return}}d(Me,"He"),f(Me,"readHeader");function Q(n,e=tt){if(!n)return!1;const t=n.endsWith("/")?n:`${n}/`;return e.some(s=>t.startsWith(s))}d(Q,"de"),f(Q,"isTemporary");function je(n,e){return n.length<=e?n:`${n.slice(0,e)}
5
+ [\u2026 ${n.length-e} characters not synced]`}d(je,"Ce"),f(je,"truncate");function H(n,e,t){if(typeof n=="string"){const s=je(n,e);return X(t&&t.length>1?s.split(t).join("~"):s)}if(Array.isArray(n))return n.map(s=>H(s,e,t));if(n&&typeof n=="object"){const s=n;if(s.type==="image"&&(typeof s.data=="string"||typeof s.source=="object"))return{type:"text",text:"[image not synced]"};const i={};for(const[o,c]of Object.entries(s))i[o]=H(c,e,t);return i}return n}d(H,"P"),f(H,"clean");function ee(n,e){let t;try{t=JSON.parse(n)}catch{return null}if(!t||typeof t!="object"||typeof t.type!="string")return null;let s=JSON.stringify(H(t,Ge,e));if(Buffer.byteLength(s)>ge&&(s=JSON.stringify(H(t,Ke,e))),Buffer.byteLength(s)>ge){const i={type:t.type,id:t.id,parentId:t.parentId,timestamp:t.timestamp},o=t.message;o&&typeof o=="object"&&(i.message={role:o.role,content:[{type:"text",text:"[content too large, not synced]"}]}),s=JSON.stringify(i)}return s}d(ee,"Je"),f(ee,"cleanLine");function T(n){try{const e=JSON.parse(n);return e.type!=="session"&&typeof e.id=="string"?e.id:void 0}catch{return}}d(T,"$"),f(T,"entryId");function ve(n){if(n.type!=="message")return;const e=n.message;if(e?.role!=="user")return;const t=e.content;if(typeof t=="string")return t;if(Array.isArray(t)){const s=t.find(i=>i.type==="text");return typeof s?.text=="string"?s.text:void 0}}d(ve,"Fe"),f(ve,"userText");function Oe(n,e){let t=e,s=!1;for(const i of n){if(!i.includes('"session_info"')&&(t||!i.includes('"user"')))continue;let o;try{o=JSON.parse(i)}catch{continue}if(o.type==="session_info"&&typeof o.name=="string"&&o.name.trim()){t=o.name.trim(),s=!0;continue}if(!t&&!s){const c=ve(o)?.replace(/\s+/g," ").trim();c&&(t=c)}}return t?X(t).slice(0,120):void 0}d(Oe,"Ke"),f(Oe,"titleFrom");function te(n){let e=n.trim();if(!e)return;const t=/^([^@/\s]+@)?([^:/\s]+):(?!\/)(.+)$/.exec(e);t&&!/^[a-z]+:\/\//i.test(e)&&(e=`ssh://${t[2]}/${t[3]}`);try{const s=new URL(e),i=s.pathname.replace(/\.git$/i,"").replace(/\/+$/,"");return!s.hostname||!i?void 0:`${s.hostname.toLowerCase()}${i.toLowerCase()}`}catch{return}}d(te,"Ge"),f(te,"normalizeRemote");function Ae(n){try{return Ie("git",["-C",n,"config","--get","remote.origin.url"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}d(Ae,"Ue"),f(Ae,"gitRemote");function W(n,e=K()){const t=We(e,n);return t===""?"~":t&&!t.startsWith("..")&&!Ue(t)?`~/${t}`:X(n)}d(W,"fe"),f(W,"cwdLabel");function ne(n,e=K()){const t=le(n)?Ae(n):void 0,s=t?te(t):void 0,i=Date.now();return s?{key:P(`git:${s}`).slice(0,32),name:s.split("/").pop()??null,at:i}:{key:P(`path:${W(n,e)}`).slice(0,32),name:Ce(n)||null,at:i}}d(ne,"We"),f(ne,"projectIdentity");function P(n){return de("sha256").update(n).digest("hex")}d(P,"W"),f(P,"sha");async function De(n,e,t,s){const i={uploaded:0,downloaded:0,updated:0,pendingBytes:0,quotaExceeded:!1,busy:!1},o=ze(n);if(!o)return{...i,busy:!0};try{return await ke(n,e,t,s,i)}finally{o()}}d(De,"ut"),f(De,"syncSessions");async function ke(n,e,t,s,i){const o=s.now??Date.now,c=o(),r=s.budget??Se,l=s.home??K(),g=F(n),m=g?.account===e?g:{account:e,sessions:{},projects:{},noticeShownAt:g?.noticeShownAt};let x=0,z=0;const v=f(()=>o()-c>r.ms,"overBudget"),R=f(()=>_(n,{...m,lastRun:new Date(o()).toISOString()}),"save"),M=f(p=>{const a=m.projects[p];if(a&&o()-a.at<Xe)return a;const u=ne(p,l);return m.projects[p]=u,u},"project"),h=Y(n),j=new Map(h.map(p=>[p.id,p]));for(const[p,a]of Object.entries(m.sessions))a.pendingDelete&&(await t.remove(p),a.pendingDelete=!1);for(const p of s.pullCwds??[]){if(v()||z>r.downloadBytes)break;if(Q(p,s.localOnlyRoots))continue;const{key:a}=M(V(p));if(!a)continue;const u=await t.list(a,Ve);for(const y of u){if(v()||z>r.downloadBytes)break;if(!xe.test(y.id)||y.nextSeq===0)continue;const b=m.sessions[y.id];if(b?.remoteDeleted)continue;const S=j.get(y.id);if(b&&S&&b.file===S.path){if(y.generation!==b.generation||y.nextSeq<=b.nextSeq||S.size!==b.offset)continue;const I=await Z(t,y.id,y.generation,b.nextSeq-1);if(!I)continue;z+=I.bytes;const C=oe(S.path,I.lines),$=L(S.path);Object.assign(b,{nextSeq:I.nextSeq,offset:$.size,tail:N(S.path,$.size),size:$.size,mtimeMs:$.mtimeMs}),C&&i.updated++;continue}if(S||b)continue;const D=await Z(t,y.id,y.generation,-1);if(!D)continue;z+=D.bytes;const O=$e(s.sessionDirFor(V(p)),V(p),y,D.lines),A=L(O);m.sessions[y.id]={file:O,generation:D.generation,nextSeq:D.nextSeq,offset:A.size,tail:N(O,A.size),size:A.size,mtimeMs:A.mtimeMs,title:y.title??void 0},j.set(y.id,{id:y.id,path:O,size:A.size,mtimeMs:A.mtimeMs}),i.downloaded++}R()}for(const p of h){let a;try{const w=L(p.path);a={id:p.id,path:p.path,size:w.size,mtimeMs:w.mtimeMs}}catch{continue}let u=m.sessions[a.id];if(u&&u.file===a.path&&u.size===a.size&&u.mtimeMs===a.mtimeMs&&(u.offset>=a.size||u.skipped||u.remoteDeleted))continue;if(u?.remoteDeleted){Object.assign(u,{file:a.path,size:a.size,mtimeMs:a.mtimeMs});continue}if(m.quotaExceeded||v()||x>r.uploadBytes){i.pendingBytes+=Math.max(0,a.size-(u?.file===a.path?u.offset:0));continue}const y=Me(a.path);if(!y||y.id!==a.id||Q(y.cwd,s.localOnlyRoots)){m.sessions[a.id]={file:a.path,generation:0,nextSeq:0,offset:0,tail:"",size:a.size,mtimeMs:a.mtimeMs,skipped:!0};continue}u?.skipped&&(u=void 0);let b=u?.generation??1,S=u?.offset??0,D=u?.nextSeq??0;u&&(u.file!==a.path||a.size<u.offset||N(a.path,u.offset)!==u.tail)&&(b=u.generation+1,S=0,D=0);const O=typeof y.cwd=="string"?y.cwd:"",A=O?M(O):{key:null,name:null,at:0},I=se(a.path,S,a.size,r.uploadBytes-x),C=E(a.path,S,I).toString("utf8"),$=C?C.slice(0,-1).split(`
6
+ `):[],re=Oe($,u?.title),ce={generation:b,title:re??null,projectKey:A.key,projectName:A.name,cwd:O?W(O,l):null,createdAt:typeof y.timestamp=="string"?y.timestamp:null,modifiedAt:new Date(a.mtimeMs).toISOString()},fe=P(JSON.stringify(ce)),q={file:a.path,generation:b,nextSeq:D,offset:S,tail:S>0?N(a.path,S):"",size:a.size,mtimeMs:a.mtimeMs,metaHash:u?.metaHash,title:re};if(m.sessions[a.id]=q,q.metaHash!==fe||!u){const w=await t.putMeta(a.id,ce,{create:!u||u.nextSeq===0});if(w.status==="missing"){q.remoteDeleted=!0;continue}if(w.status==="quota"){m.quotaExceeded=!0,i.quotaExceeded=!0;continue}if(w.status==="refused"){q.skipped=!0;continue}if(w.status==="conflict"||w.status==="ok"&&w.session.nextSeq!==q.nextSeq){const Be=w.status==="ok"?w.session.generation:w.generation,Le=w.status==="ok"?w.session.nextSeq:w.nextSeq,ue=await ae(t,a,q,Be,Le,i,l);if(x+=ue,ue<0)continue;q.metaHash=void 0;continue}q.metaHash=fe}const B=await ie(t,a,q,$,S,l);x+=B.bytes,B.chunks>0&&i.uploaded++,B.outcome==="conflict"?x+=Math.max(0,await ae(t,a,q,B.generation,B.nextSeq,i,l)):B.outcome==="missing"?(q.nextSeq>0||u)&&(q.remoteDeleted=!0):B.outcome==="quota"&&(m.quotaExceeded=!0,i.quotaExceeded=!0),q.offset<a.size&&(i.pendingBytes+=a.size-q.offset),R()}for(const[p,a]of Object.entries(m.sessions))j.has(p)||a.pendingDelete||a.deletedAt&&o()-Date.parse(a.deletedAt)<Ye||delete m.sessions[p];return R(),i}d(ke,"Xe"),f(ke,"run");function se(n,e,t,s){const i=Math.min(t,e+Math.max(s,he)),o=E(n,e,i).lastIndexOf(10);if(o>=0)return e+o+1;if(i<t){const c=E(n,e,t).indexOf(10);if(c>=0)return e+c+1}return e}d(se,"le"),f(se,"lastNewline");async function ie(n,e,t,s,i,o,c){let r=i,l=0,g=0,m=[],x=0,z=0;const v=f(async()=>{if(m.length===0){r+=z,z=0;return}const M=Ze(Buffer.from(`${m.join(`
7
+ `)}
8
+ `,"utf8")).toString("base64"),h=await n.append(e.id,{generation:t.generation,seq:t.nextSeq,data:M,modifiedAt:new Date(e.mtimeMs).toISOString()});if(h.status==="conflict")return{outcome:"conflict",bytes:l,chunks:g,generation:h.generation,nextSeq:h.nextSeq};if(h.status==="missing"||h.status==="quota")return{outcome:h.status,bytes:l,chunks:g};h.status==="ok"&&(t.nextSeq=h.nextSeq,g++),l+=x,r+=z,t.offset=r,t.tail=N(e.path,r),m=[],x=0,z=0},"flush");for(const M of s){if(z+=Buffer.byteLength(M,"utf8")+1,c&&!c(M))continue;const h=ee(M,o);if(h!==null&&(m.push(h),x+=Buffer.byteLength(h,"utf8")+1,x>=he)){const j=await v();if(j)return j}}return await v()||(t.offset=r,t.tail=r>0?N(e.path,r):"",{outcome:"done",bytes:l,chunks:g})}d(ie,"me"),f(ie,"sendLines");async function Z(n,e,t,s){const i=[];let o=0,c=s;for(;;){const r=await n.chunks(e,t,c);if(r.status!=="ok")return;for(const l of r.chunks){const g=Pe(Buffer.from(l.data,"base64")).toString("utf8");o+=g.length;for(const m of g.split(`
9
+ `))m&&i.push(m);c=l.seq}if(!r.more||r.chunks.length===0)return{lines:i,generation:r.generation,nextSeq:r.nextSeq,bytes:o}}}d(Z,"X"),f(Z,"fetchLines");function oe(n,e){const t=new Set;for(const i of pe(n,"utf8").split(`
10
+ `)){const o=i?T(i):void 0;o&&t.add(o)}const s=e.filter(i=>{const o=T(i);return o!==void 0&&!t.has(o)});return s.length&&Je(n,`${s.join(`
11
+ `)}
12
+ `),s.length}d(oe,"ge"),f(oe,"appendMissing");function Ne(n){return(n&&!Number.isNaN(Date.parse(n))?new Date(Date.parse(n)):new Date).toISOString().replace(/[:.]/g,"-")}d(Ne,"Ye"),f(Ne,"fileStamp");function $e(n,e,t,s){J(n,{recursive:!0});let i;const o=[];for(const g of s){if(!i)try{const m=JSON.parse(g);if(m.type==="session"){i=m;continue}}catch{}o.push(g)}const c={...i??{type:"session",version:3,id:t.id,timestamp:t.createdAt??new Date().toISOString()},id:t.id,cwd:e},r=k(n,`${Ne(typeof c.timestamp=="string"?c.timestamp:t.createdAt)}_${t.id}.jsonl`);ye(r,`${[JSON.stringify(c),...o].join(`
13
+ `)}
14
+ `);const l=t.modifiedAt?Date.parse(t.modifiedAt):Number.NaN;return Number.isNaN(l)||Te(r,new Date(l),new Date(l)),r}d($e,"Ze"),f($e,"writeDownloaded");async function ae(n,e,t,s,i,o,c){const r=s===t.generation&&t.nextSeq>0,l=await Z(n,e.id,s,r?t.nextSeq-1:-1);if(!l)return-1;const g=new Set(l.lines.map(T).filter(j=>j!==void 0)),m=L(e.path).size,x=r?t.offset:0,z=se(e.path,x,m,Number.MAX_SAFE_INTEGER),v=E(e.path,x,z).toString("utf8"),R=v?v.slice(0,-1).split(`
15
+ `):[];oe(e.path,l.lines)&&o.updated++,t.generation=l.generation,t.nextSeq=l.nextSeq;const M=await ie(n,e,t,R,x,c,f(j=>{const p=T(j);return p===void 0?l.nextSeq===0:!g.has(p)},"ownOnly"));if(M.outcome!=="done")return-1;M.chunks>0&&o.uploaded++;const h=L(e.path);return Object.assign(t,{offset:h.size,tail:N(e.path,h.size),size:h.size,mtimeMs:h.mtimeMs}),M.bytes}d(ae,"pe"),f(ae,"reconcile");export{Se as DEFAULT_RUN_BUDGET,ee as cleanLine,be as clearSessionsState,W as cwdLabel,Y as listLocalSessions,qe as markSessionDeleted,te as normalizeRemote,ne as projectIdentity,F as readSessionsState,U as sessionsStatePath,De as syncSessions,_ as writeSessionsState};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-telemetry",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -25,9 +25,9 @@
25
25
  ]
26
26
  },
27
27
  "dependencies": {
28
- "@dalcode/dal-learn": "1.0.54",
29
- "@dalcode/dal-pi-kit": "1.0.54",
30
- "@dalcode/deepailab": "1.0.54"
28
+ "@dalcode/dal-learn": "1.0.56",
29
+ "@dalcode/dal-pi-kit": "1.0.56",
30
+ "@dalcode/deepailab": "1.0.56"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@earendil-works/pi-coding-agent": "^1.0.9"