dal-code 1.0.58 → 1.0.59

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 (109) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/bundle/chunks/{anthropic-messages-FOIJU7LX.js → anthropic-messages-HVFHIIGX.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-7NBJZKX5.js → azure-openai-responses-RMWKIGFW.js} +1 -1
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  5. package/dist/bundle/chunks/{chunk-X7I3V6OA.js → chunk-BBNE2TWS.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-JK74OC6W.js → chunk-F52JQCLE.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-DVEPGKL5.js → chunk-GZJEAFRS.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-NYSVXLKF.js → chunk-IKSSB5ZJ.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-QFBU27TM.js → chunk-J6H2LYOZ.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-T5PI6B5P.js → chunk-KQRRELCF.js} +1 -1
  11. package/dist/bundle/chunks/chunk-KT7CXVDN.js +17 -0
  12. package/dist/bundle/chunks/{chunk-3QG7FIE4.js → chunk-MPLE6M5C.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-B7KZDIWA.js → chunk-TPOKZ2EU.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-5MF5GEDD.js → chunk-VDPDHGGJ.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-SCZEDPDC.js → chunk-WLQ33LIH.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-CCU76UL3.js → chunk-X63WCLSX.js} +4 -4
  17. package/dist/bundle/chunks/{chunk-LMZYTWXD.js → chunk-YOQ3KBG5.js} +1 -1
  18. package/dist/bundle/chunks/{cli-RY666QAD.js → cli-BFWJUYZ5.js} +1 -1
  19. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-CFGOMWWZ.js → cloudflare-workers-ai-system-one-RXFI2EBV.js} +1 -1
  20. package/dist/bundle/chunks/{google-generative-ai-ZA2RHPNE.js → google-generative-ai-5F5544G4.js} +1 -1
  21. package/dist/bundle/chunks/{google-vertex-Y2GRWOK7.js → google-vertex-4PSVELDG.js} +1 -1
  22. package/dist/bundle/chunks/{llama-cpp-classify-G2JDOFHY.js → llama-cpp-classify-IPNT4VOW.js} +1 -1
  23. package/dist/bundle/chunks/{mcp-45D7KCZZ.js → mcp-F3BQ6MQW.js} +1 -1
  24. package/dist/bundle/chunks/{mistral-conversations-MLV32BRV.js → mistral-conversations-RSYLYGE4.js} +1 -1
  25. package/dist/bundle/chunks/{openai-codex-responses-BDK3PY6G.js → openai-codex-responses-OKPZLYIS.js} +1 -1
  26. package/dist/bundle/chunks/{openai-completions-BLXHKAB3.js → openai-completions-BFCQZRZ2.js} +1 -1
  27. package/dist/bundle/chunks/{openai-decisions-IGVID576.js → openai-decisions-RJ4MH5XI.js} +1 -1
  28. package/dist/bundle/chunks/{openai-responses-KHZOEDF2.js → openai-responses-PT5MXG3Q.js} +1 -1
  29. package/dist/bundle/chunks/{openrouter-images-SA6PUASF.js → openrouter-images-ICCH2YHW.js} +1 -1
  30. package/dist/bundle/chunks/{pi-messages-3VAOLQ2Y.js → pi-messages-Z2XWHIYT.js} +1 -1
  31. package/dist/bundle/chunks/{review-RZXLHPUZ.js → review-WTYIVWYR.js} +1 -1
  32. package/dist/bundle/chunks/{router-YBVXODIL.js → router-V3EIAYOF.js} +1 -1
  33. package/dist/bundle/chunks/{sdk-X6RX7FNE.js → sdk-32L63XRF.js} +1 -1
  34. package/dist/bundle/chunks/sync-Z5USQ7AN.js +21 -0
  35. package/dist/bundle/chunks/{typesafe-system-one-ER3DLYNF.js → typesafe-system-one-6UYWINOZ.js} +1 -1
  36. package/dist/bundle/chunks/{usage-LMRFS2HV.js → usage-JODQIC2H.js} +1 -1
  37. package/dist/bundle/chunks/{virtual-modules-XIUNRFOZ.js → virtual-modules-ERCLFZEY.js} +1 -1
  38. package/dist/bundle/cli-runtime.js +1 -1
  39. package/dist/bundle/index.js +1 -1
  40. package/dist/bundle/rpc-entry.js +1 -1
  41. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  42. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  43. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  44. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  45. package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
  46. package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
  47. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  48. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  49. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  50. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  51. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  52. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  53. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  54. package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
  55. package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -4
  56. package/dist/node_modules/@dalcode/dal-learn/src/project-map.js +2 -2
  57. package/dist/node_modules/@dalcode/dal-learn/src/signals.js +6 -6
  58. package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
  59. package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
  60. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  61. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  62. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  63. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  64. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  65. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  66. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  67. package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
  68. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  69. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  70. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  71. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  72. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  73. package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
  74. package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
  75. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  76. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  77. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  78. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  79. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  80. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  81. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  82. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  83. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  84. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  85. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  86. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  87. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  88. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  89. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  90. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  91. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  92. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
  93. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
  94. package/dist/node_modules/@earendil-works/pi-ai/package.json +3 -3
  95. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  96. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  97. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  98. package/dist/node_modules/@earendil-works/pi-schema/package.json +1 -1
  99. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  100. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  101. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  102. package/examples/extensions/gondolin/package-lock.json +2 -2
  103. package/examples/extensions/gondolin/package.json +1 -1
  104. package/examples/extensions/with-deps/package-lock.json +2 -2
  105. package/examples/extensions/with-deps/package.json +1 -1
  106. package/npm-shrinkwrap.json +2 -2
  107. package/package.json +1 -1
  108. package/dist/bundle/chunks/chunk-JXAFVEE4.js +0 -17
  109. package/dist/bundle/chunks/sync-CRV6BXXC.js +0 -21
@@ -1,21 +0,0 @@
1
- var pt=Object.defineProperty;var a=(e,t)=>pt(e,"name",{value:t,configurable:!0});import{createRequire as mt}from"node:module";const Ts=mt(import.meta.url);import{getDefaultSessionDir as ht}from"./chunk-QFBU27TM.js";import"./chunk-LMZYTWXD.js";import"./chunk-NJDCSLWK.js";import"./chunk-4BOWD7PQ.js";import"./chunk-G5AMLGXC.js";import"./chunk-R47JBGS3.js";import{DATA_FORMAT_KEY as yt,declaredDataFormat as ee,reportNewerDataFormat as xe,t as z,withFileLockSync as te,writeFileAtomicSync as B}from"./chunk-QU2VEHMW.js";import"./chunk-IEBK4HQA.js";import"./chunk-723ZGEZ2.js";import"./chunk-ZG74NES2.js";import"./chunk-7DDKXS2Q.js";import"./chunk-FFMDRXC4.js";import"./chunk-5MF5GEDD.js";import"./chunk-4LDEEFCY.js";import"./chunk-JK74OC6W.js";import"./chunk-JXWJOIH4.js";import{existsSync as gt,readFileSync as bt}from"node:fs";import{join as St}from"node:path";import{createHash as Et,randomBytes as wt}from"node:crypto";import{existsSync as _e,mkdirSync as ne,readdirSync as At,readFileSync as je,rmSync as vt,statSync as kt}from"node:fs";import{join as R}from"node:path";import{join as xt}from"node:path";import{homedir as _t}from"node:os";var jt=[[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,"<private-key>"],[/\b(?:sk|pk|rk)-[A-Za-z0-9_-]{8,}/g,"<secret>"],[/\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/gi,"Bearer <secret>"],[/\beyJ[A-Za-z0-9._-]{16,}/g,"<secret>"],[/\b(?:ghp|gho|ghu|ghs|ghr|github_pat)_[A-Za-z0-9_]{8,}/g,"<secret>"],[/\bglpat-[A-Za-z0-9_-]{8,}/g,"<secret>"],[/\bAKIA[0-9A-Z]{12,}/g,"<secret>"],[/\bxox[abposr]-[A-Za-z0-9-]{8,}/g,"<secret>"],[/\bnpm_[A-Za-z0-9]{20,}/g,"<secret>"],[/\b([A-Za-z0-9_.-]*(?:token|secret|password|passwd|api[_-]?key|access[_-]?key|private[_-]?key|auth|cookie|session)[A-Za-z0-9_.-]*)(["']?\s*[:=]\s*["']?)([^\s"',;]{4,})/gi,"$1$2<secret>"],[/(\b[a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/gi,"$1<secret>@"],[/[A-Za-z0-9+/_-]{40,}={0,2}/g,"<opaque>"]];function U(e){let t=e;for(let[i,s]of jt)t=t.replace(i,s);let n=_t();return n&&n.length>1&&(t=t.split(n).join("~")),t=t.replace(/(?:\/Users\/|\/home\/|[A-Za-z]:\\Users\\)[^\s/\\]+/g,"~"),t}a(U,"redact");var Nt=[{reason:"weakens_safety",pattern:/\b(?:skip|bypass|disable|ignore|override|turn off|circumvent)\b[^\n]{0,40}\b(?:approvals?|permissions?|sandbox(?:es)?|safety|guards?|confirmations?|hooks?|polic(?:y|ies)|protections?)\b/i},{reason:"weakens_safety",pattern:/(?:跳过|绕过|关闭|禁用|忽略|无视)[^。\n]{0,12}(?:审批|权限|确认|沙箱|安全|保护|钩子|拦截)/u},{reason:"weakens_safety",pattern:/(?:不要|不必|无需)(?![^。\n]{0,6}未经)[^。\n]{0,6}(?:审批|确认|沙箱)/u},{reason:"weakens_safety",pattern:/\b(?:skip|disable)\b[^\n]{0,20}\btests?\b|--no-verify\b/i},{reason:"weakens_safety",pattern:/--dangerously|\byolo\b|bypassPermissions|\bsudo\b|chmod\s+777|rm\s+-rf\s+[/~]/i},{reason:"exfiltrates",pattern:/\b(?:curl|wget|scp|rsync|nc|upload|send|post|exfiltrate|share)\b[^\n]{0,60}\b(?:tokens?|keys?|secrets?|passwords?|credentials?|cookies?|env|\.ssh|sessions?)\b/i},{reason:"exfiltrates",pattern:/(?:上传|发送|发到|外发|分享|传到)[^。\n]{0,20}(?:密钥|令牌|密码|凭据|凭证|cookie|环境变量|私钥)/iu},{reason:"installs",pattern:/\b(?:npm|pnpm|bun)\s+(?:i|install|add)\b[^\n]*?(?:\s-g\b|--global\b)|\byarn\s+global\s+add\b/i},{reason:"installs",pattern:/\b(?:brew|apt(?:-get)?|yum|dnf|pacman|apk|choco|winget|scoop|snap|cargo|gem|pipx)\s+(?:install|add)\b|\bgo\s+install\b|\buv\s+tool\s+install\b/i},{reason:"installs",pattern:/\b(?:npm\s+(?:i|install)|pnpm\s+(?:add|i|install)|yarn\s+add|bun\s+add)\s+(?!(?:in|at|from|first|before|after|then|and|again|once|for|inside|to|with|when|so|instead|works|fails|succeeds)\b)[@a-z][\w@./-]*/i},{reason:"installs",pattern:/\|\s*(?:sudo\s+)?(?:ba|z)?sh\b|\binstall(?:er)?\s+script\b/i},{reason:"installs",pattern:/\b(?:npx|npm\s+exec)\b[^\n`]*?\s(?:-y|--yes)\b|\bnpx\s+(?:-\S+\s+)*@?[a-z][\w./-]*@[\w.^~*-]+|\b(?:pnpm|yarn)\s+dlx\b|\bbunx\b|\buvx\b|\bpipx\s+run\b/i},{reason:"installs",pattern:/全局安装|从[^。\n]{1,30}下载|下载(?:并|后)?(?:运行|执行|安装)/u},{reason:"concrete_value",pattern:/\bhttps?:\/\/|\bwww\./i},{reason:"concrete_value",pattern:/<(?:secret|opaque|private-key)>/},{reason:"concrete_value",pattern:/[A-Za-z0-9+/=_-]{40,}/},{reason:"concrete_value",pattern:/\b\d{1,3}(?:\.\d{1,3}){3}\b/},{reason:"concrete_value",pattern:/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/},{reason:"concrete_value",pattern:/(?:\/Users\/|\/home\/|[A-Za-z]:\\Users\\)[^\s/\\]+/}];function It(e){let t=[e.content,e.rootCause??"",e.note??""].join(`
2
- `);for(let{reason:i,pattern:s}of Nt)if(s.test(t))return i;let n=e.content.trim().length;if(n<6||n>320)return"length"}a(It,"rejectLesson");var Ot=[{category:"deletion",pattern:/\b(?:rm|rmdir|del|unlink|truncate|shred)\b|\bdelet(?:e|es|ed|ing)\b|\bremov(?:e|es|ed|ing)\b|\bdrop\s+(?:table|database|schema)\b|\bgit\s+(?:clean|reset\s+--hard|push\s+[^\n]*--force|branch\s+-D)\b|\bwip(?:e|ing)\b|\bpurge\b|删除|删掉|清空|清除|覆盖(?!率)|重置/iu},{category:"permissions",pattern:/\b(?:chmod|chown|sudo|setfacl|icacls)\b|\bpermissions?\b|\bapprov(?:al|e)s?\b|\bsandbox\b|\bguard\b|\bescalat\w*|权限|审批|放行|沙箱|提权/iu},{category:"credentials",pattern:/\b(?:tokens?|secrets?|passwords?|passwd|credentials?|api[\s_-]?keys?|private\s+keys?|ssh\s+keys?|auth(?:\.json)?|login|cookies?|\.env)\b|凭据|凭证|密钥|密码|令牌|登录|私钥/iu},{category:"network",pattern:/\b(?:curl|wget|http|https|proxy|download|upload|dns|ssh|scp|rsync|webhook)\b|联网|下载|上传|代理|外网/iu},{category:"publishing",pattern:/\b(?:publish|release|deploy|push|git\s+tag|merge\s+to\s+main)\b|发布|发版|上线|部署|推送|合并到主/iu}],se=String.raw`(?:package\.json|package-lock\.json|lock\s?files?|pnpm-lock|yarn\.lock|requirements[\w.-]*\.txt|pyproject\.toml|Cargo\.toml|go\.mod|\.github\/workflows[\w./-]*|CI\s+config(?:uration)?)`,Ne=/\b(?:npm|pnpm|yarn|bun)[ \t]+(?:i|install|add)[ \t]+(?:-{1,2}[\w-]+[ \t]+)*[@a-z][\w@./-]*|\bpip3?[ \t]+install[ \t]+(?!-r\b)[a-z]|--save-dev\b|\binstall(?:ing)?\s+(?:the\s+|a\s+|an\s+|it\s+)?(?:missing\s+)?(?:tool|package|module|librar\w*|runner|linter|dependenc\w*)|as\s+a\s+dev-?dependency|(?:安装|装上|装一下|补装)\s*(?:缺少的|缺失的)?\s*(?:工具|依赖|包|插件|运行器)|装依赖/iu,Tt=new RegExp(String.raw`\b(?:fix|edit|change|modify|update|rewrite|patch|add\b[^.;\n]{0,40}?\bto)\b[^.;\n]{0,40}?${se}|\b(?:fix|edit|change|modify|update|rewrite|patch)\b[^.;\n]{0,12}?\b(?:the\s+)?(?:npm\s+|test\s+|lint\s+|build\s+)?scripts?\b|(?:改|修改|改写|修复)[^。;;\n]{0,6}?(?:测试|npm|lint|构建)?\s*脚本|${se}[^.;\n]{0,20}?\b(?:should|must)\s+be\s+(?:changed|edited|updated|fixed)|(?:改|修改|编辑|调整|修复|补上|加到|写进)[^。;;\n]{0,12}?${se}`,"iu"),Ie=/\b(?:before|instead\s+of|rather\s+than|don'?t|do\s+not|never|avoid|without)\b[^.;\n]{0,24}$|(?:不要|别|不许|先别|而不是|避免|不用)[^。;;\n]{0,8}$/iu;function Rt(e){if(Ne.test(e)){let n=e.search(Ne);if(!Ie.test(e.slice(Math.max(0,n-30),n)))return!0}let t=Tt.exec(e);return!!(t&&!Ie.test(e.slice(Math.max(0,t.index-30),t.index)))}a(Rt,"prescribesDependencyChange");function $t(e){let t=Ot.filter(({pattern:n})=>Lt(e,n)).map(({category:n})=>n);return Rt(e)?[...t,"dependencies"]:t}a($t,"riskOf");var Ct=/[。;;,,!?!?\n]|\.(?=\s|$)/u,Ft=/\b(?:don'?t|do\s+not|never|avoid|stop|instead\s+of|rather\s+than|refuse|no\s+longer)\b|不要|不得|不能|不应|不该|(?<![区分类级识特个差告])别(?![的处人名])|切勿|勿|禁止|避免|停止|不再|而不是|而非|拒绝|不可|严禁|防止/iu,Dt=/^\s*(?:当|如果|若|假如|一旦|万一|when\b|if\b|once\b|whenever\b)/iu,Oe=/就|则|便|\bthen\b/iu,Mt=/(?:时|之后|以后|的时候)\s*$/u;function qt(e){return Dt.test(e)?Oe.test(e)?[e]:[]:Mt.test(e)&&!Oe.test(e)?[]:[e]}a(qt,"prescriptiveParts");function Lt(e,t){let n=new RegExp(t.source,t.flags.includes("g")?t.flags:`${t.flags}g`);for(let i of e.split(Ct))for(let s of qt(i))for(let r of s.matchAll(n))if(!Ft.test(s.slice(0,r.index)))return!0;return!1}a(Lt,"prescribedIn");var zt=[["typecheck",/\btsc\b(?!.*--build)|\bmypy\b|\bpyright\b|\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:typecheck|type-check|check-types)\b/],["test",/\b(?:vitest|jest|mocha|ava|pytest|tox|rspec|phpunit)\b|\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test\b|\bnode\s+--test\b|\b(?:go|cargo|dotnet|mix|deno)\s+test\b|\bmake\s+test\b|\bgradlew?\s+test\b|\bmvn\s+test\b/],["lint",/\b(?:eslint|biome|ruff|flake8|pylint|golangci-lint|clippy|prettier\s+--check)\b|\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:lint|check)\b/],["build",/\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?build\b|\b(?:cargo|go|dotnet|swift)\s+build\b|\bmake\b(?!\s+test)|\bgradlew?\s+(?:build|assemble)\b|\bmvn\s+(?:package|install)\b|\btsc\s+--build\b|\bvite\s+build\b|\bwebpack\b/],["install",/^(?:npm\s+(?:ci|install|i)|pnpm\s+(?:install|i)|yarn(?:\s+install)?|bun\s+install|pip3?\s+install\s+(?:-r|-e|\.)|poetry\s+install|uv\s+sync|bundle\s+install|composer\s+install|go\s+mod\s+download)(?:\s|$)/]],Bt=/^(?:tail|head|grep|egrep|fgrep|cat|less|more|tee|wc|sort|uniq|cut|column|sed|awk|nl)\b/,Ut=/^(?:head|grep|egrep|fgrep|cut|sed|awk)\b/,Pt=/^(?:echo|printf|cat|ls|pwd|true|false|:|#|sed|awk|grep|rg|head|tail|wc|find|git\s+(?:diff|status|log|show|stash|add)|set|export|printenv|which|whereis|type|command\s+-v|test\s|\[|stat|file|(?:node|npm|pnpm|yarn|bun|npx)\s+(?:-v|--version)|(?:npm|pnpm|yarn)\s+(?:ls|list|view|info|bin|root|config|why))(?:\b|(?=\s|$))/;function Jt(e){let t=e.replace(/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n[ \t]*\2[ \t]*(?=\n|$)/g,"<<$2$3").replace(/\s*\d*>&\d+/g,""),n=[],i=[],s="",r,o=a(()=>{i.push(s.trim()),s=""},"endStage"),c=a(()=>{o();let f=i.filter(Boolean);f.length&&n.push(f),i=[]},"endStatement");for(let f=0;f<t.length;f++){let y=t[f];if(r){if(y==="\\"&&r==='"'){s+=y+(t[f+1]??""),f++;continue}y===r&&(r=void 0),s+=y;continue}y==="'"||y==='"'?(r=y,s+=y):y==="\\"?(s+=y+(t[f+1]??""),f++):y===";"||y===`
3
- `?c():(y==="&"||y==="|")&&t[f+1]===y?(c(),f++):y==="&"?c():y==="|"?o():s+=y}return c(),n}a(Jt,"splitStatements");function Ht(e){let t=[],n=!1;for(let i of Jt(e)){let s=[...i],r=!1;for(;s.length>1&&Bt.test(s.at(-1));)Ut.test(s.at(-1))&&(r=!0),s.pop();let o=s.join(" | ").replace(/\s+/g," ");/^cd\s/.test(o)?t.push(o):!Pt.test(o)&&ie(o)&&(t.push(o),r&&(n=!0))}for(;t.length&&/^cd\s/.test(t.at(-1));)t.pop();return{statements:t,selected:n}}a(Ht,"checkParts");function ie(e){for(let[t,n]of zt)if(n.test(e))return t}a(ie,"intentOf");var Te=120,Re=/^(?:at\s|\S+\s\(\S+:\d+:\d+\)$|(?:file:\/\/)?\S+\.(?:[cm]?[jt]sx?|py|go|rs|rb|java|kt|php)(?::\d+){1,2}$|.*\bnode:internal\/|Node\.js v\d)/,$e=/^(?:>?\s*\d+\s*\|.*|[\s|]*\^+[\s^~]*|(?:if|else|for|while|switch|const|let|var|return|function|class|import|export|async|await|def|try|catch)\b.*|\}.*)$|\bthrow new\b|=>|[;{]$/,Ce=/^(?:(?:duration_ms|type|location|failureType|code|stack|operator|expected|actual|generatedMessage|name):|\.{3}$|-{3}$|TAP version|Subtest:|1\.\.\d+$|(?:tests|suites|pass|fail|cancelled|skipped|todo|duration_ms)\s+\d|Command exited with code)/,Kt=/^(?:E\s+)?(?:Uncaught\s+)?(?:[A-Z][\w.]*(?:Error|Exception)|Error|error(?: TS\d+|\[E\d+\])?)(?:\s*\[[\w-]+\])?:\s*\S|\berror TS\d+:\s*\S/,Gt=/^(?:expected\b.*\b(?:received|to (?:be|equal)|but got)\b|(?:Expected|Received)(?: value)?:\s*\S|.+\s!==?\s.+)/i,Zt=/^(?:FAIL(?:ED)?\b|not ok \d+|[✖×✗]\s|--- FAIL:?)/,Wt=/not found|no such|cannot|can't|unable|error|fail|missing|denied|unknown|invalid|找不到|不存在|失败|错误/i;function Yt(e){let t=e.trim().replace(/^#\s?/,"").trim();return t!==""&&(Re.test(t)||$e.test(t)||Ce.test(t))}a(Yt,"isUntellingReason");function Xt(e){let t=e.findIndex(s=>Gt.test(s));if(t<0)return;let n=e[t],i=/^Expected(?: value)?:/i.test(n)?e.slice(t+1,t+4).find(s=>/^Received(?: value)?:/i.test(s)):void 0;return i?`${n}, ${i}`:n}a(Xt,"comparison");function Vt(e){let t=U(e).replace(/\s+/g," ").trim();return t.length>Te?`${t.slice(0,Te-1)}\u2026`:t}a(Vt,"clipReason");function Qt(e){let t=[];for(let n=0;n<e.length;n++){let i=/^error:\s*(.*)$/.exec(e[n]);if(!i)continue;let s=i[1].replace(/^'(.*)'$/,"$1").replace(/^"(.*)"$/,"$1");if(/^\|-?$/.test(s)){let o=[];for(let c=n+1;c<e.length&&o.length<2&&!/^[a-z_]+:\s/i.test(e[c]);c++)o.push(e[c]);s=o.join(" ")}if(!s||s==="test failed")continue;let r="";for(let o=n+1;o<Math.min(e.length,n+12)&&!/^(?:\.{3}|not ok|ok)\b/.test(e[o]);o++){let c=/^name:\s*'?([\w.]+)'?$/.exec(e[o]);if(c){r=c[1];break}}t.push(r&&!s.startsWith(r)?`${r}: ${s}`:s)}return t}a(Qt,"tapErrors");function en(e){let t=e.split(/\r?\n/).map(s=>s.trim().replace(/^#\s?/,"").trim()).filter(Boolean),n=t.filter(s=>!Re.test(s)&&!$e.test(s)&&!Ce.test(s)),i=Qt(t)[0]??n.find(s=>Kt.test(s))??Xt(n)??n.find(s=>Zt.test(s))??n.find(s=>Wt.test(s))??"";return Vt(i)}a(en,"failureReason");function Fe(e){let t="",n=[];for(let i of Ht(e).statements){let s=/^cd\s+("[^"]+"|'[^']+'|\S+)$/.exec(i);if(s){let o=s[1].replace(/^["']|["']$/g,"");t=t&&!o.startsWith("/")?`${t}/${o}`:o;continue}let r=i.replace(/\s+/g," ").trim();n.some(o=>o.dir===t&&o.check===r)||n.push({dir:t,check:r,...ie(r)?{intent:ie(r)}:{}})}return n}a(Fe,"segmentsOf");function tn(e,t){return e===t||` ${e} `.includes(` ${t} `)||` ${t} `.includes(` ${e} `)}a(tn,"overlaps");function nn(e,t){let n=Fe(e),i=Fe(t),s=a((d,p)=>d.dir===p.dir&&d.check===p.check,"same"),r=n.filter(d=>!i.some(p=>s(d,p)));if(r.length===0)return;let o=new Set(r.map(d=>d.intent)),c=i.filter(d=>!n.some(p=>s(d,p))||o.has(d.intent)),f=r.filter(d=>c.some(p=>p.intent===d.intent));if(f.length===0||c.length===0||[...f,...c].some(d=>/^(?:\/|~|\$)/.test(d.dir))||f.some(d=>c.some(p=>p.dir===d.dir&&tn(d.check,p.check))))return;let y=a(d=>{let p=d[0].dir;if(d.some(l=>l.dir!==p))return;let u=d.map(l=>l.check).join(" && ");return p?`cd ${p} && ${u}`:u},"joined"),b=y(f),m=y(c);if(!(!b||!m||b===m))return{bad:b,good:m}}a(nn,"fixCommands");var sn=/command not found|: not found|is not (?:set|defined)|Missing script|Cannot find (?:module|package)|ERR_MODULE_NOT_FOUND|ENOENT|No such file|unknown (?:option|command|script|flag)|not recognized as|No test files|No tests found|permission denied|EACCES|找不到|未设置|不存在|未找到/i,rn=/AssertionError|^\s*(?:Expected|Received)(?: value)?:|\bexpected\b.*\b(?:received|to (?:be|equal)|but got)\b|\s!==?\s|^not ok \d+|^#\s*fail\s+[1-9]|^\s*\d+ (?:failing|failed)\b|Tests?:\s+\d+ failed|\berror TS\d+:|\d+ problems? \(\d+ errors?/im;function an(e){return rn.test(e)&&!sn.test(e)}a(an,"codeFailed");import{mkdirSync as on,readFileSync as un}from"node:fs";import{dirname as cn}from"node:path";var re=1;function De(e){let t;try{t=un(e,"utf8")}catch{return}try{let n=JSON.parse(t);return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}catch{return}}a(De,"readRaw");function ln(e,t){let n=De(e),i=n!==void 0&&ee(n)>re;return i&&xe(e),{value:t(n),readOnly:i}}a(ln,"readDoc");function dn(e,t,n){return on(cn(e),{recursive:!0,mode:448}),te(e,()=>{let i=De(e);if(i!==void 0&&ee(i)>re){xe(e);return}let s=n(t(i));if(s===void 0)return;let r={...i??{},...s,[yt]:re};return B(e,`${JSON.stringify(r,null," ")}
4
- `,{mode:384}),s})}a(dn,"updateDoc");function w(e,t){return typeof e=="string"?e.trim().slice(0,t):""}a(w,"str");function D(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):0}a(D,"num");function ae(e,t,n){return Array.isArray(e)?e.filter(i=>typeof i=="string"&&i.length>0).map(i=>i.slice(0,n)).slice(-t):[]}a(ae,"strList");function oe(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&!Array.isArray(t)):[]}a(oe,"records");var li=10080*60*1e3,fn=["harmful","ineffective","unused","user","malformed","outdated"],pn=6,mn=12,hn=20,yn=["candidate","active","awaiting_user","retired","undone","expired"],gn=["failure_then_fix","user_correction","repeated_detour","guard_denial","success_workflow","imported"],bn=["helpful","harmful","neutral"],Sn=["deletion","permissions","credentials","network","publishing","dependencies"];function Me(e){return xt(e,"lessons.json")}a(Me,"lessonsPath");function En(e){let t=w(e.id,16),n=w(e.content,400);if(!/^[lu]-\d{4,6}$/.test(t)||!n)return;let i=yn.includes(e.status)?e.status:"candidate",s=e.fix,r=e.proof,o=e.origin;return{...e,id:t,scope:e.scope==="user"?"user":"project",section:w(e.section,40)||"general",content:n,rootCause:w(e.rootCause,400),...w(e.signature,300)?{signature:w(e.signature,300)}:{},...s&&typeof s.good=="string"?{fix:{intent:w(s.intent,20),bad:w(s.bad,200),good:w(s.good,200),...w(s.dir,200)?{dir:w(s.dir,200)}:{}}}:{},status:i,risk:ae(e.risk,5,20).filter(c=>Sn.includes(c)),sessions:ae(e.sessions,mn,80),evidence:oe(e.evidence).map(c=>({sessionId:w(c.sessionId,80),at:w(c.at,32),signal:gn.includes(c.signal)?c.signal:"user_correction",note:w(c.note,300)})).slice(-pn),...r&&typeof r.at=="string"?{proof:{kind:r.kind==="outcome"?"outcome":"test",at:w(r.at,32),sessionId:w(r.sessionId,80),note:w(r.note,300)}}:{},helpful:D(e.helpful),harmful:D(e.harmful),...D(e.neutral)>0?{neutral:D(e.neutral)}:{},...D(e.injections)>0?{injections:D(e.injections)}:{},...w(e.lastInjectedAt,32)?{lastInjectedAt:w(e.lastInjectedAt,32)}:{},feedback:oe(e.feedback).filter(c=>bn.includes(c.tag)).map(c=>({sessionId:w(c.sessionId,80),tag:c.tag,at:w(c.at,32),why:w(c.why,200)})).slice(-hn),created:w(e.created,32),updated:w(e.updated,32),...w(e.activatedAt,32)?{activatedAt:w(e.activatedAt,32)}:{},...["sessions","proof","user","import","trial"].includes(e.activatedBy)?{activatedBy:e.activatedBy}:{},...w(e.lastHelpfulAt,32)?{lastHelpfulAt:w(e.lastHelpfulAt,32)}:{},...w(e.retiredAt,32)?{retiredAt:w(e.retiredAt,32)}:{},...fn.includes(e.retiredReason)?{retiredReason:e.retiredReason}:{},...o&&o.kind==="desktop"?{origin:{kind:"desktop",projectId:w(o.projectId,32),ruleId:w(o.ruleId,16)}}:{}}}a(En,"parseLesson");var Z=a(e=>e.replace(/\s+/g," ").trim(),"fold");function wn(e){if(!e.fix||!e.signature?.startsWith("fix:")||e.activatedBy==="user"||e.activatedBy==="import")return!1;let t=nn(e.fix.bad,e.fix.good);return!t||Z(t.bad)!==Z(e.fix.bad)||Z(t.good)!==Z(e.fix.good)||Yt(e.rootCause)||e.rootCause.trim()&&!en(e.rootCause)||an(e.rootCause)?!0:It({content:e.content})!==void 0}a(wn,"isMalformed");var An=["candidate","active","awaiting_user"];function vn(e){return!An.includes(e.status)||!wn(e)?e:{...e,status:"retired",retiredAt:e.updated||e.created,retiredReason:"malformed"}}a(vn,"retireMalformed");function kn(e){if(e.activatedBy==="user"||e.activatedBy==="import")return e;let t=$t(e.fix?`${e.fix.good}
5
- ${e.rootCause??""}`:e.content);return t.length===e.risk.length&&t.every(n=>e.risk.includes(n))?e:t.some(n=>!e.risk.includes(n))&&e.status==="active"?{...e,risk:t,status:"awaiting_user"}:t.length===0&&e.status==="awaiting_user"?{...e,risk:t,status:"candidate"}:{...e,risk:t}}a(kn,"recheckRisk");function qe(e){let t=oe(e?.lessons).map(En).filter(r=>r!==void 0).map(vn).map(kn),n=t.reduce((r,o)=>Math.max(r,Number(o.id.slice(2))),0),i={},s=e?.imported;if(s&&typeof s=="object"&&!Array.isArray(s))for(let[r,o]of Object.entries(s))i[r]=ae(o,1e3,16);return{nextId:Math.max(D(e?.nextId),n+1,1),lessons:t,imported:i}}a(qe,"parseLessonsDoc");function Le(e){return ln(Me(e),qe).value}a(Le,"readLessons");function ze(e,t){return dn(Me(e),qe,t)}a(ze,"updateLessons");var di=new Set("the and for with this that these those from into when then than before after instead only each every use used using run runs running ran make makes made keep edit edits editing file files project projects here there what which while where your you our are was were has have had not but all any its one two fails fail failed failing passes pass passed should must can will just also more most first last same src lib test tests js mjs cjs ts tsx jsx json md py go rs txt yaml yml".split(" ")),fi=new Set("\u672C\u9879 \u9879\u76EE \u76EE\u91CC \u6539\u7528 \u4F1A\u5931 \u5931\u8D25 \u4F7F\u7528 \u65F6\u5019 \u4E4B\u524D \u4E4B\u540E \u6587\u4EF6 \u8FD0\u884C \u4E00\u4E0B \u8FD9\u4E2A \u90A3\u4E2A \u53EF\u4EE5 \u9700\u8981 \u4E0D\u8981 \u5982\u679C \u7136\u540E \u73B0\u5728 \u5DF2\u7ECF \u6211\u4EEC \u4F60\u7684 \u4E00\u4E2A \u4EC0\u4E48 \u600E\u4E48 \u4E3A\u4EC0\u4E48 \u5E2E\u6211 \u770B\u770B \u95EE\u9898 \u4EE3\u7801".split(" ")),xn=256*1024,Be=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Ue=1,N=class extends Error{static{a(this,"SyncHttpError")}status;constructor(e){super(`dal sync request failed (${e})`),this.status=e}},ue=a(e=>R(e,"skills"),"skillsDir"),Pe=a(e=>R(e,"learned","user"),"userLessonsDir"),ce=a(e=>R(e,"sync","state.json"),"statePath");function le(e){return Array.isArray(e)?`[${e.map(le).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[n])=>t<n?-1:t>n?1:0).map(([t,n])=>`${JSON.stringify(t)}:${le(n)}`).join(",")}}`:JSON.stringify(e)}a(le,"stable");function W(e){return Et("sha256").update(le(e)).digest("hex")}a(W,"contentHash");function de(e){return typeof e=="string"?U(e):Array.isArray(e)?e.map(de):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,de(n)])):e}a(de,"redactDeep");var Je=["section","content","rootCause","signature","fix","status","risk","helpful","harmful","neutral","injections","lastInjectedAt","created","updated","activatedAt","activatedBy","lastHelpfulAt","retiredAt","retiredReason"],_n=["helpful","harmful","neutral","injections"],jn=["lastInjectedAt","lastHelpfulAt"];function Nn(e,t){let n={...t};for(let i of _n){let s=e[i]??0,r=typeof t[i]=="number"?t[i]:0;s>r&&(n[i]=s)}for(let i of jn){let s=e[i],r=typeof t[i]=="string"?t[i]:void 0;s&&(!r||Date.parse(s)>Date.parse(r))&&(n[i]=s)}return n}a(Nn,"mergeLesson");function In(e){let t={};for(let n of Je)e[n]!==void 0&&(t[n]=e[n]);return de(t)}a(In,"lessonContent");function On(e){let t=ue(e);if(!_e(t))return[];let n=[];for(let i of At(t)){if(!Be.test(i)||i.length>64)continue;let s=R(t,i,"SKILL.md"),r,o;try{let f=kt(s);if(!f.isFile())continue;r=je(s,"utf8"),o=f.mtimeMs}catch{continue}let c={name:i,body:U(r)};n.push({id:`skill.${i}`,kind:"skill",content:c,hash:W(c),updatedAt:o})}return n}a(On,"readSkills");function Tn(e){let t=Pe(e);return _e(R(t,"lessons.json"))?(Le(t).lessons.some(n=>n.scope==="user"&&!n.syncId)&&ze(t,n=>({...n,lessons:n.lessons.map(i=>i.scope==="user"&&!i.syncId?{...i,syncId:Rn()}:i)})),Le(t).lessons.filter(n=>n.scope==="user"&&typeof n.syncId=="string").map(n=>{let i=In(n);return{id:`lesson.${n.syncId}`,kind:"lesson",content:i,hash:W(i),updatedAt:Date.parse(n.updated)||0}})):[]}a(Tn,"readLessonItems");function Rn(){return wt(8).toString("hex")}a(Rn,"newSyncId");function He(e){return[...On(e),...Tn(e)]}a(He,"readLocalItems");function $n(e,t,n,i=()=>!1){if(t.startsWith("skill.")){let f=t.slice(6);if(!Be.test(f)||typeof n.body!="string")return;ne(R(ue(e),f),{recursive:!0}),B(R(ue(e),f,"SKILL.md"),n.body);return}if(!t.startsWith("lesson."))return;let s=t.slice(7),r={};for(let f of Je)n[f]!==void 0&&(r[f]=n[f]);let o=r.content;if(typeof o!="string"||!o)return;let c=Pe(e);ne(c,{recursive:!0,mode:448}),ze(c,f=>{let y=f.lessons,b=y.find(p=>p.syncId===s)??y.find(p=>p.scope==="user"&&(!p.syncId||i(p.syncId))&&p.content===r.content);if(b)return{...f,lessons:y.map(p=>p===b?{...p,...Nn(p,r),syncId:s}:p)};let m=new Date().toISOString(),d={id:`u-${String(f.nextId).padStart(4,"0")}`,scope:"user",section:"general",rootCause:"",status:"candidate",risk:[],sessions:[],evidence:[],helpful:0,harmful:0,feedback:[],created:m,updated:m,...r,content:o,syncId:s};return{...f,nextId:f.nextId+1,lessons:[...y,d]}})}a($n,"applyRemoteItem");function fe(e){try{let t=JSON.parse(je(ce(e),"utf8"));if(t.formatVersion!==Ue||typeof t.account!="string")return;let n=t.items&&typeof t.items=="object"?t.items:{};return{account:t.account,items:n,lastRun:typeof t.lastRun=="string"?t.lastRun:void 0,lastError:typeof t.lastError=="string"?t.lastError:void 0,lastErrorStatus:typeof t.lastErrorStatus=="number"?t.lastErrorStatus:void 0}}catch{return}}a(fe,"readState");function Ke(e,t){let n=ce(e);ne(R(e,"sync"),{recursive:!0,mode:448}),te(n,()=>B(n,`${JSON.stringify({formatVersion:Ue,...t},null," ")}
6
- `,{mode:384}))}a(Ke,"writeState");function Cn(e){vt(ce(e),{force:!0})}a(Cn,"clearState");async function Fn(e,t,n){let i=fe(e),s={account:t,items:i?.account===t?{...i.items}:{}},r={uploaded:0,downloaded:0,deletedRemote:0,conflicts:0,refused:[]},o=a(()=>Ke(e,{...s,lastRun:new Date().toISOString()}),"save"),c=new Map((await n.manifest()).map(u=>[u.id,u])),f=new Map(He(e).map(u=>[u.id,u])),y=a(u=>{let l=`lesson.${u}`;return!s.items[l]&&!c.has(l)},"neverSynced"),b=new Set,m=a((u,l)=>{$n(e,u,l.content,y),s.items[u]={version:l.version,hash:W(l.content)},b.add(u),r.downloaded++},"apply"),d=a(async u=>{let l=await n.get(u);return l?(m(u,l),!0):!1},"download"),p=a(async(u,l)=>{let g=s.items[u.id];if(g?.refused===u.hash)return;if(Buffer.byteLength(JSON.stringify(u.content))>xn){s.items[u.id]={version:g?.version??0,hash:g?.hash??"",refused:u.hash},r.refused.push(u.id);return}let E=await n.put(u.id,u.kind,l,u.content);E.status==="written"?(s.items[u.id]={version:E.version,hash:u.hash},r.uploaded++):E.status==="conflict"?r.conflicts++:(s.items[u.id]={version:g?.version??0,hash:g?.hash??"",refused:u.hash},r.refused.push(u.id))},"upload");for(let u of c.values()){let l=s.items[u.id]?.remoteDeleted?void 0:s.items[u.id],g=f.get(u.id);if(!g){if(l&&l.version===u.version){await n.remove(u.id)&&r.deletedRemote++,delete s.items[u.id];continue}await d(u.id);continue}if(l&&l.version===u.version)continue;if(l&&g.hash===l.hash){await d(u.id);continue}let E=await n.get(u.id);if(!E)continue;let A=W(E.content);if(A===g.hash){s.items[u.id]={version:E.version,hash:A};continue}r.conflicts++,Date.parse(u.updatedAt)>g.updatedAt?m(u.id,E):await p(g,E.version)}f=new Map(He(e).map(u=>[u.id,u]));for(let u of b){let l=f.get(u);l&&s.items[u]&&(s.items[u].hash=l.hash)}for(let u of f.values()){let l=s.items[u.id],g=c.get(u.id);if(g){l&&l.version===g.version&&u.hash!==l.hash&&await p(u,g.version);continue}if(l&&u.hash===l.hash){!l.remoteDeleted&&l.version>0&&(s.items[u.id]={...l,remoteDeleted:!0});continue}await p(u,0)}for(let u of Object.keys(s.items))!f.has(u)&&!c.has(u)&&delete s.items[u];return o(),r}a(Fn,"runSync");function Dn(e){let t=`${e.apiBase.replace(/\/+$/,"")}/portal/dal-sync`,n=e.fetch??fetch;async function i(m,d,p,u){let l=await e.token();if(!l)throw new N(401);let g=await n(`${t}${d}`,{method:m,headers:{Authorization:`Bearer ${l}`,Accept:"application/json",...p===void 0?{}:{"Content-Type":"application/json"}},body:p===void 0?void 0:JSON.stringify(p),signal:AbortSignal.timeout(u??e.timeoutMs??2e4)}),E=await g.json().catch(()=>null);return{status:g.status,data:E}}a(i,"call");let s=a(m=>m&&typeof m=="object"&&!Array.isArray(m)?m:{},"record"),r=a(m=>`/items/${encodeURIComponent(m)}`,"item"),o=a(m=>Number(m)||0,"num2"),c=a(m=>typeof m=="string"&&m?m:null,"strOrNull"),f=a(m=>{let d=s(m);if(typeof d.id=="string")return{id:d.id,generation:o(d.generation),nextSeq:o(d.nextSeq),title:c(d.title),projectKey:c(d.projectKey),projectName:c(d.projectName),cwd:c(d.cwd),device:c(d.device),entries:o(d.entries),createdAt:c(d.createdAt),modifiedAt:c(d.modifiedAt)}},"toSession"),y=a(m=>`/sessions/${encodeURIComponent(m)}`,"session"),b=12e4;return{sessions:{async list(m,d=200){let p=new URLSearchParams({limit:String(d)});m&&p.set("project",m);let{status:u,data:l}=await i("GET",`/sessions?${p}`);if(u!==200)throw new N(u);let g=s(l).sessions;return(Array.isArray(g)?g:[]).flatMap(E=>f(E)??[])},async putMeta(m,d,p){let{status:u,data:l}=await i("PUT",y(m),{...d,device:e.device.slice(0,64),...p?.create===!1?{create:!1}:{}});if(u===404)return{status:"missing"};if(u===200){let g=f(l);if(g)return{status:"ok",session:g}}if(u===409)return{status:"conflict",generation:o(s(l).generation),nextSeq:o(s(l).nextSeq)};if(u===413)return{status:"quota"};if(u===400)return{status:"refused",reason:String(s(l).error??u)};throw new N(u)},async append(m,d){let{status:p,data:u}=await i("POST",`${y(m)}/chunks`,d,b),l=s(u);if(p===200)return{status:"ok",nextSeq:o(l.nextSeq)};if(p===409)return{status:"conflict",generation:o(l.generation),nextSeq:o(l.nextSeq)};if(p===404)return{status:"missing"};if(p===413&&l.error==="account_quota_exceeded")return{status:"quota"};if(p===413||p===400)return{status:"refused",reason:String(l.error??p)};throw new N(p)},async chunks(m,d,p){let u=new URLSearchParams({generation:String(d),after:String(p)}),{status:l,data:g}=await i("GET",`${y(m)}/chunks?${u}`,void 0,b),E=s(g);if(l===200){let A=Array.isArray(E.chunks)?E.chunks:[];return{status:"ok",generation:o(E.generation),nextSeq:o(E.nextSeq),more:E.more===!0,chunks:A.flatMap(h=>{let S=s(h);return typeof S.data=="string"?[{seq:o(S.seq),data:S.data}]:[]})}}if(l===409)return{status:"conflict",generation:o(E.generation),nextSeq:o(E.nextSeq)};if(l===404)return{status:"missing"};throw new N(l)},async remove(m){let{status:d}=await i("DELETE",y(m));if(d===200)return!0;if(d===404)return!1;throw new N(d)}},async manifest(){let{status:m,data:d}=await i("GET","/manifest");if(m!==200)throw new N(m);let p=s(d).items;return(Array.isArray(p)?p:[]).flatMap(u=>{let l=s(u);return typeof l.id!="string"||l.kind!=="skill"&&l.kind!=="lesson"?[]:[{id:l.id,kind:l.kind,version:Number(l.version)||0,updatedAt:typeof l.updatedAt=="string"?l.updatedAt:new Date(0).toISOString()}]})},async get(m){let{status:d,data:p}=await i("GET",r(m));if(d===404)return;if(d!==200)throw new N(d);let u=s(p);return{version:Number(u.version)||0,content:s(u.content)}},async put(m,d,p,u){let{status:l,data:g}=await i("PUT",r(m),{kind:d,baseVersion:p,content:u,device:e.device.slice(0,64)});if(l===200)return{status:"written",version:Number(s(g).version)||0};if(l===409)return{status:"conflict"};if(l===413||l===422||l===400)return{status:"refused",reason:String(s(g).error??l)};throw new N(l)},async remove(m){let{status:d}=await i("DELETE",r(m));if(d===200)return!0;if(d===404)return!1;throw new N(d)},async removeAll(){let{status:m,data:d}=await i("DELETE","");if(m!==200)throw new N(m);return Number(s(d).removed)||0}}}a(Dn,"createHttpRemote");import{execFileSync as Mn}from"node:child_process";import{createHash as Ge}from"node:crypto";import{appendFileSync as qn,closeSync as Ln,existsSync as Ze,mkdirSync as J,openSync as zn,readdirSync as We,readFileSync as Ye,readSync as Bn,rmSync as pe,statSync as M,utimesSync as Un}from"node:fs";import{homedir as me}from"node:os";import{basename as Pn,isAbsolute as Jn,join as $,relative as Hn,resolve as he}from"node:path";import{gunzipSync as Kn,gzipSync as Gn}from"node:zlib";var Xe=2*1024*1024,Ve=3*1024*1024,Zn=2e5,Wn=2e4,Yn={uploadBytes:48*1024*1024,downloadBytes:64*1024*1024,ms:9e4},Xn=50,Vn=1440*60*1e3,Qn=2160*60*60*1e3,Qe=1,es=4096,ts=600*1e3,et=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,ns=["/tmp/","/private/tmp/","/var/folders/","/private/var/folders/"],ye=a(e=>$(e,"sync","sessions.json"),"sessionsStatePath");function H(e){try{let t=JSON.parse(Ye(ye(e),"utf8"));return t.formatVersion!==Qe||typeof t.account!="string"?void 0:{account:t.account,sessions:t.sessions&&typeof t.sessions=="object"?t.sessions:{},projects:t.projects&&typeof t.projects=="object"?t.projects:{},lastRun:typeof t.lastRun=="string"?t.lastRun:void 0,quotaExceeded:t.quotaExceeded===!0,noticeShownAt:typeof t.noticeShownAt=="string"?t.noticeShownAt:void 0}}catch{return}}a(H,"readSessionsState");function Y(e,t){J($(e,"sync"),{recursive:!0,mode:448}),B(ye(e),`${JSON.stringify({formatVersion:Qe,...t})}
7
- `,{mode:384})}a(Y,"writeSessionsState");function tt(e,t,n,i){let s=H(e),r=s?.account===t,o=r?s.sessions:{},c=o[n];o[n]={file:c?.file??"",generation:c?.generation??0,nextSeq:c?.nextSeq??0,offset:c?.offset??0,tail:c?.tail??"",size:c?.size??0,mtimeMs:c?.mtimeMs??0,remoteDeleted:!0,pendingDelete:i,deletedAt:new Date().toISOString()},Y(e,{account:t,sessions:o,projects:r?s.projects:{},noticeShownAt:s?.noticeShownAt,...r&&s.quotaExceeded?{quotaExceeded:!0}:{}})}a(tt,"markSessionDeleted");function ss(e){let t=H(e);pe(ye(e),{force:!0}),t?.noticeShownAt&&Y(e,{account:t.account,sessions:{},projects:{},noticeShownAt:t.noticeShownAt})}a(ss,"clearSessionsState");function is(e){let t=$(e,"sync","sessions.lock");J($(e,"sync"),{recursive:!0,mode:448});try{J(t)}catch{try{if(Date.now()-M(t).mtimeMs<ts)return;pe(t,{recursive:!0,force:!0}),J(t)}catch{return}}return()=>pe(t,{recursive:!0,force:!0})}a(is,"tryLock");function rs(e){let t=$(e,"sessions");if(!Ze(t))return[];let n=[];for(let i of We(t,{withFileTypes:!0})){if(!i.isDirectory())continue;let s;try{s=We($(t,i.name))}catch{continue}for(let r of s){if(!r.endsWith(".jsonl"))continue;let o=r.slice(r.indexOf("_")+1,-6);if(!et.test(o)||o.length>128)continue;let c=$(t,i.name,r);try{let f=M(c);f.isFile()&&f.size>0&&n.push({id:o,path:c,size:f.size,mtimeMs:f.mtimeMs})}catch{}}}return n.sort((i,s)=>s.mtimeMs-i.mtimeMs)}a(rs,"listLocalSessions");function P(e,t,n){let i=Math.max(0,n-t),s=Buffer.alloc(i);if(i===0)return s;let r=zn(e,"r");try{let o=0;for(;o<i;){let c=Bn(r,s,o,i-o,t+o);if(c===0)break;o+=c}return s.subarray(0,o)}finally{Ln(r)}}a(P,"readRange");function q(e,t){return Ge("sha256").update(P(e,Math.max(0,t-es),t)).digest("hex")}a(q,"tailHash");function as(e){let t=P(e,0,1048576).toString("utf8"),n=t.slice(0,t.indexOf(`
8
- `)>=0?t.indexOf(`
9
- `):t.length);try{let i=JSON.parse(n);return i?.type==="session"&&typeof i.id=="string"?i:void 0}catch{return}}a(as,"readHeader");function nt(e,t=ns){if(!e)return!1;let n=e.endsWith("/")?e:`${e}/`;return t.some(i=>n.startsWith(i))}a(nt,"isTemporary");function os(e,t){return e.length<=t?e:`${e.slice(0,t)}
10
- [\u2026 ${e.length-t} characters not synced]`}a(os,"truncate");function X(e,t,n){if(typeof e=="string"){let i=os(e,t);return U(n&&n.length>1?i.split(n).join("~"):i)}if(Array.isArray(e))return e.map(i=>X(i,t,n));if(e&&typeof e=="object"){let i=e;if(i.type==="image"&&(typeof i.data=="string"||typeof i.source=="object"))return{type:"text",text:"[image not synced]"};let s={};for(let[r,o]of Object.entries(i))s[r]=X(o,t,n);return s}return e}a(X,"clean");function us(e,t){let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!="object"||typeof n.type!="string")return null;let i=JSON.stringify(X(n,Zn,t));if(Buffer.byteLength(i)>Ve&&(i=JSON.stringify(X(n,Wn,t))),Buffer.byteLength(i)>Ve){let s={type:n.type,id:n.id,parentId:n.parentId,timestamp:n.timestamp},r=n.message;r&&typeof r=="object"&&(s.message={role:r.role,content:[{type:"text",text:"[content too large, not synced]"}]}),i=JSON.stringify(s)}return i}a(us,"cleanLine");function V(e){try{let t=JSON.parse(e);return t.type!=="session"&&typeof t.id=="string"?t.id:void 0}catch{return}}a(V,"entryId");function cs(e){if(e.type!=="message")return;let t=e.message;if(t?.role!=="user")return;let n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){let i=n.find(s=>s.type==="text");return typeof i?.text=="string"?i.text:void 0}}a(cs,"userText");function ls(e,t){let n=t,i=!1;for(let s of e){if(!s.includes('"session_info"')&&(n||!s.includes('"user"')))continue;let r;try{r=JSON.parse(s)}catch{continue}if(r.type==="session_info"&&typeof r.name=="string"&&r.name.trim()){n=r.name.trim(),i=!0;continue}if(!n&&!i){let o=cs(r)?.replace(/\s+/g," ").trim();o&&(n=o)}}return n?U(n).slice(0,120):void 0}a(ls,"titleFrom");function ds(e){let t=e.trim();if(!t)return;let n=/^([^@/\s]+@)?([^:/\s]+):(?!\/)(.+)$/.exec(t);n&&!/^[a-z]+:\/\//i.test(t)&&(t=`ssh://${n[2]}/${n[3]}`);try{let i=new URL(t),s=i.pathname.replace(/\.git$/i,"").replace(/\/+$/,"");return!i.hostname||!s?void 0:`${i.hostname.toLowerCase()}${s.toLowerCase()}`}catch{return}}a(ds,"normalizeRemote");function fs(e){try{return Mn("git",["-C",e,"config","--get","remote.origin.url"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).trim()}catch{return}}a(fs,"gitRemote");function st(e,t=me()){let n=Hn(t,e);return n===""?"~":n&&!n.startsWith("..")&&!Jn(n)?`~/${n}`:U(e)}a(st,"cwdLabel");function ps(e,t=me()){let n=Ze(e)?fs(e):void 0,i=n?ds(n):void 0,s=Date.now();return i?{key:ge(`git:${i}`).slice(0,32),name:i.split("/").pop()??null,at:s}:{key:ge(`path:${st(e,t)}`).slice(0,32),name:Pn(e)||null,at:s}}a(ps,"projectIdentity");function ge(e){return Ge("sha256").update(e).digest("hex")}a(ge,"sha");async function ms(e,t,n,i){let s={uploaded:0,downloaded:0,updated:0,pendingBytes:0,quotaExceeded:!1,busy:!1},r=is(e);if(!r)return{...s,busy:!0};try{return await hs(e,t,n,i,s)}finally{r()}}a(ms,"syncSessions");async function hs(e,t,n,i,s){let r=i.now??Date.now,o=r(),c=i.budget??Yn,f=i.home??me(),y=H(e),b=y?.account===t?y:{account:t,sessions:{},projects:{},noticeShownAt:y?.noticeShownAt},m=0,d=0,p=a(()=>r()-o>c.ms,"overBudget"),u=a(()=>Y(e,{...b,lastRun:new Date(r()).toISOString()}),"save"),l=a(A=>{let h=b.projects[A];if(h&&r()-h.at<Vn)return h;let S=ps(A,f);return b.projects[A]=S,S},"project"),g=rs(e),E=new Map(g.map(A=>[A.id,A]));for(let[A,h]of Object.entries(b.sessions))h.pendingDelete&&(await n.remove(A),h.pendingDelete=!1);for(let A of i.pullCwds??[]){if(p()||d>c.downloadBytes)break;if(nt(A,i.localOnlyRoots))continue;let{key:h}=l(he(A));if(!h)continue;let S=await n.list(h,Xn);for(let v of S){if(p()||d>c.downloadBytes)break;if(!et.test(v.id)||v.nextSeq===0)continue;let j=b.sessions[v.id];if(j?.remoteDeleted)continue;let k=E.get(v.id);if(j&&k&&j.file===k.path){if(v.generation!==j.generation||v.nextSeq<=j.nextSeq||k.size!==j.offset)continue;let L=await be(n,v.id,v.generation,j.nextSeq-1);if(!L)continue;d+=L.bytes;let G=at(k.path,L.lines),C=M(k.path);Object.assign(j,{nextSeq:L.nextSeq,offset:C.size,tail:q(k.path,C.size),size:C.size,mtimeMs:C.mtimeMs}),G&&s.updated++;continue}if(k||j)continue;let T=await be(n,v.id,v.generation,-1);if(!T)continue;d+=T.bytes;let I=gs(i.sessionDirFor(he(A)),he(A),v,T.lines),O=M(I);b.sessions[v.id]={file:I,generation:T.generation,nextSeq:T.nextSeq,offset:O.size,tail:q(I,O.size),size:O.size,mtimeMs:O.mtimeMs,title:v.title??void 0},E.set(v.id,{id:v.id,path:I,size:O.size,mtimeMs:O.mtimeMs}),s.downloaded++}u()}for(let A of g){let h;try{let x=M(A.path);h={id:A.id,path:A.path,size:x.size,mtimeMs:x.mtimeMs}}catch{continue}let S=b.sessions[h.id];if(S&&S.file===h.path&&S.size===h.size&&S.mtimeMs===h.mtimeMs&&(S.offset>=h.size||S.skipped||S.remoteDeleted))continue;if(S?.remoteDeleted){Object.assign(S,{file:h.path,size:h.size,mtimeMs:h.mtimeMs});continue}if(b.quotaExceeded||p()||m>c.uploadBytes){s.pendingBytes+=Math.max(0,h.size-(S?.file===h.path?S.offset:0));continue}let v=as(h.path);if(!v||v.id!==h.id||nt(v.cwd,i.localOnlyRoots)){b.sessions[h.id]={file:h.path,generation:0,nextSeq:0,offset:0,tail:"",size:h.size,mtimeMs:h.mtimeMs,skipped:!0};continue}S?.skipped&&(S=void 0);let j=S?.generation??1,k=S?.offset??0,T=S?.nextSeq??0;S&&(S.file!==h.path||h.size<S.offset||q(h.path,S.offset)!==S.tail)&&(j=S.generation+1,k=0,T=0);let I=typeof v.cwd=="string"?v.cwd:"",O=I?l(I):{key:null,name:null,at:0},L=it(h.path,k,h.size,c.uploadBytes-m),G=P(h.path,k,L).toString("utf8"),C=G?G.slice(0,-1).split(`
11
- `):[],we=ls(C,S?.title),Ae={generation:j,title:we??null,projectKey:O.key,projectName:O.name,cwd:I?st(I,f):null,createdAt:typeof v.timestamp=="string"?v.timestamp:null,modifiedAt:new Date(h.mtimeMs).toISOString()},ve=ge(JSON.stringify(Ae)),_={file:h.path,generation:j,nextSeq:T,offset:k,tail:k>0?q(h.path,k):"",size:h.size,mtimeMs:h.mtimeMs,metaHash:S?.metaHash,title:we};if(b.sessions[h.id]=_,_.metaHash!==ve||!S){let x=await n.putMeta(h.id,Ae,{create:!S||S.nextSeq===0});if(x.status==="missing"){_.remoteDeleted=!0;continue}if(x.status==="quota"){b.quotaExceeded=!0,s.quotaExceeded=!0;continue}if(x.status==="refused"){_.skipped=!0;continue}if(x.status==="conflict"||x.status==="ok"&&x.session.nextSeq!==_.nextSeq){let dt=x.status==="ok"?x.session.generation:x.generation,ft=x.status==="ok"?x.session.nextSeq:x.nextSeq,ke=await ot(n,h,_,dt,ft,s,f);if(m+=ke,ke<0)continue;_.metaHash=void 0;continue}_.metaHash=ve}let F=await rt(n,h,_,C,k,f);m+=F.bytes,F.chunks>0&&s.uploaded++,F.outcome==="conflict"?m+=Math.max(0,await ot(n,h,_,F.generation,F.nextSeq,s,f)):F.outcome==="missing"?(_.nextSeq>0||S)&&(_.remoteDeleted=!0):F.outcome==="quota"&&(b.quotaExceeded=!0,s.quotaExceeded=!0),_.offset<h.size&&(s.pendingBytes+=h.size-_.offset),u()}for(let[A,h]of Object.entries(b.sessions))E.has(A)||h.pendingDelete||h.deletedAt&&r()-Date.parse(h.deletedAt)<Qn||delete b.sessions[A];return u(),s}a(hs,"run");function it(e,t,n,i){let s=Math.min(n,t+Math.max(i,Xe)),r=P(e,t,s).lastIndexOf(10);if(r>=0)return t+r+1;if(s<n){let o=P(e,t,n).indexOf(10);if(o>=0)return t+o+1}return t}a(it,"lastNewline");async function rt(e,t,n,i,s,r,o){let c=s,f=0,y=0,b=[],m=0,d=0,p=a(async()=>{if(b.length===0){c+=d,d=0;return}let l=Gn(Buffer.from(`${b.join(`
12
- `)}
13
- `,"utf8")).toString("base64"),g=await e.append(t.id,{generation:n.generation,seq:n.nextSeq,data:l,modifiedAt:new Date(t.mtimeMs).toISOString()});if(g.status==="conflict")return{outcome:"conflict",bytes:f,chunks:y,generation:g.generation,nextSeq:g.nextSeq};if(g.status==="missing"||g.status==="quota")return{outcome:g.status,bytes:f,chunks:y};g.status==="ok"&&(n.nextSeq=g.nextSeq,y++),f+=m,c+=d,n.offset=c,n.tail=q(t.path,c),b=[],m=0,d=0},"flush");for(let l of i){if(d+=Buffer.byteLength(l,"utf8")+1,o&&!o(l))continue;let g=us(l,r);if(g!==null&&(b.push(g),m+=Buffer.byteLength(g,"utf8")+1,m>=Xe)){let E=await p();if(E)return E}}return await p()||(n.offset=c,n.tail=c>0?q(t.path,c):"",{outcome:"done",bytes:f,chunks:y})}a(rt,"sendLines");async function be(e,t,n,i){let s=[],r=0,o=i;for(;;){let c=await e.chunks(t,n,o);if(c.status!=="ok")return;for(let f of c.chunks){let y=Kn(Buffer.from(f.data,"base64")).toString("utf8");r+=y.length;for(let b of y.split(`
14
- `))b&&s.push(b);o=f.seq}if(!c.more||c.chunks.length===0)return{lines:s,generation:c.generation,nextSeq:c.nextSeq,bytes:r}}}a(be,"fetchLines");function at(e,t){let n=new Set;for(let s of Ye(e,"utf8").split(`
15
- `)){let r=s?V(s):void 0;r&&n.add(r)}let i=t.filter(s=>{let r=V(s);return r!==void 0&&!n.has(r)});return i.length&&qn(e,`${i.join(`
16
- `)}
17
- `),i.length}a(at,"appendMissing");function ys(e){return(e&&!Number.isNaN(Date.parse(e))?new Date(Date.parse(e)):new Date).toISOString().replace(/[:.]/g,"-")}a(ys,"fileStamp");function gs(e,t,n,i){J(e,{recursive:!0});let s,r=[];for(let y of i){if(!s)try{let b=JSON.parse(y);if(b.type==="session"){s=b;continue}}catch{}r.push(y)}let o={...s??{type:"session",version:3,id:n.id,timestamp:n.createdAt??new Date().toISOString()},id:n.id,cwd:t},c=$(e,`${ys(typeof o.timestamp=="string"?o.timestamp:n.createdAt)}_${n.id}.jsonl`);B(c,`${[JSON.stringify(o),...r].join(`
18
- `)}
19
- `);let f=n.modifiedAt?Date.parse(n.modifiedAt):Number.NaN;return Number.isNaN(f)||Un(c,new Date(f),new Date(f)),c}a(gs,"writeDownloaded");async function ot(e,t,n,i,s,r,o){let c=i===n.generation&&n.nextSeq>0,f=await be(e,t.id,i,c?n.nextSeq-1:-1);if(!f)return-1;let y=new Set(f.lines.map(V).filter(E=>E!==void 0)),b=M(t.path).size,m=c?n.offset:0,d=it(t.path,m,b,Number.MAX_SAFE_INTEGER),p=P(t.path,m,d).toString("utf8"),u=p?p.slice(0,-1).split(`
20
- `):[];at(t.path,f.lines)&&r.updated++,n.generation=f.generation,n.nextSeq=f.nextSeq;let l=await rt(e,t,n,u,m,o,E=>{let A=V(E);return A===void 0?f.nextSeq===0:!y.has(A)});if(l.outcome!=="done")return-1;l.chunks>0&&r.uploaded++;let g=M(t.path);return Object.assign(n,{offset:g.size,tail:q(t.path,g.size),size:g.size,mtimeMs:g.mtimeMs}),l.bytes}a(ot,"reconcile");var K="dalSync",bs="https://deepailab.ai/dal-sync",Se=a(e=>St(e,"settings.json"),"settingsPath");function Q(e){try{let t=JSON.parse(bt(e,"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}a(Q,"readJson");function ut(e){return process.env.DAL_SYNC==="0"?!1:Q(Se(e))?.[K]?.enabled!==!1}a(ut,"syncEnabled");function ct(e){return typeof Q(Se(e))?.[K]?.enabled=="boolean"}a(ct,"syncChosen");function Ss(e,t){if(ct(e))return!1;let n=H(e);if(n?.noticeShownAt)return!1;let i=n?.account===t?n:{account:t,sessions:{},projects:{}};return Y(e,{...i,noticeShownAt:new Date().toISOString()}),!0}a(Ss,"takeSyncNotice");function Es(e,t){let n=Se(e);te(n,()=>{if(gt(n)&&Q(n)===void 0)throw new Error(`${n} is not valid JSON; not overwriting it`);let i=Q(n)??{};if(ee(i)>1)throw new Error(`${n} was written by a newer DAL; not overwriting it`);let s=i[K]??{};i[K]={...s,enabled:t},B(n,`${JSON.stringify(i,null,2)}
21
- `)})}a(Es,"saveSyncEnabled");function lt(e,t){return e.replace(/\{(\w+)\}/g,(n,i)=>i in t?String(t[i]):n)}a(lt,"fill");function ws(e){return e instanceof Error?e.name==="TimeoutError"||e.name==="AbortError"?!0:e instanceof TypeError&&/fetch failed|network|socket|ECONN|ENOTFOUND|ETIMEDOUT|EAI_AGAIN/i.test(`${e.message} ${String(e.cause??"")}`):!1}a(ws,"isNetworkFailure");function Ee(e){return e instanceof N?e.status:ws(e)?0:-1}a(Ee,"syncErrorStatus");function As(e){let t=Ee(e);if(t===401)return z("\u672A\u767B\u5F55 DeepAILab\uFF0C\u6216\u767B\u5F55\u5DF2\u8FC7\u671F\uFF1B\u767B\u5F55\u540E\u4F1A\u81EA\u52A8\u7EE7\u7EED\u540C\u6B65\u3002");if(t===404)return z("\u540C\u6B65\u670D\u52A1\u5C1A\u672A\u5F00\u653E\uFF0C\u5F00\u653E\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\u3002");if(t===503)return z("\u540C\u6B65\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002");if(t===-1){let n=e instanceof Error?e.message:String(e);return lt(z("\u540C\u6B65\u51FA\u9519\uFF08{detail}\uFF09\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002"),{detail:n.slice(0,200)})}return t?lt(z("\u540C\u6B65\u8BF7\u6C42\u5931\u8D25\uFF08{status}\uFF09\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002"),{status:t}):z("\u7F51\u7EDC\u4E0D\u53EF\u7528\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002")}a(As,"syncErrorText");function vs(e){let t=fe(e),n=t?Object.values(t.items).filter(r=>!r.remoteDeleted&&r.version>0).length:0,i=H(e),s=i?Object.values(i.sessions).filter(r=>!r.remoteDeleted&&!r.skipped&&r.nextSeq>0):[];return{enabled:ut(e),synced:n,sessions:s.length,sessionsPendingBytes:i?Object.values(i.sessions).filter(r=>!r.remoteDeleted&&!r.skipped).reduce((r,o)=>r+Math.max(0,o.size-o.offset),0):0,sessionsQuotaExceeded:i?.quotaExceeded===!0,...t?.lastRun?{lastRun:t.lastRun}:{},...t?.lastError?{lastError:t.lastError}:{},...t?.lastError&&t.lastErrorStatus!==void 0?{lastErrorStatus:t.lastErrorStatus}:{}}}a(vs,"syncStatus");function ks(e){return Dn(e)}a(ks,"syncRemote");async function xs(e,t,n,i){try{let s=await Fn(e,t,n);return i?{...s,sessions:await ms(e,t,n.sessions,i)}:s}catch(s){let r=fe(e),o=r?.account===t;throw Ke(e,{account:t,items:o?r.items:{},lastRun:o?r.lastRun:void 0,lastError:As(s),lastErrorStatus:Ee(s)}),s}}a(xs,"syncOnce");async function _s(e,t){let n=await t.removeAll();return Cn(e),ss(e),n}a(_s,"removeCloudCopies");async function js(e,t,n,i){tt(e,t,i,!0);let s=await n.sessions.remove(i);return tt(e,t,i,!1),s}a(js,"deleteCloudSession");function Ns(e,t,n,i={}){return xs(e,t,n,{sessionDirFor:a(s=>ht(s,e),"sessionDirFor"),pullCwds:i.pullCwds??[]})}a(Ns,"syncOnce2");export{K as SETTINGS_KEY,bs as SYNC_CONSOLE_URL,js as deleteCloudSession,_s as removeCloudCopies,Es as saveSyncEnabled,ct as syncChosen,ut as syncEnabled,Ee as syncErrorStatus,Ns as syncOnce,ks as syncRemote,vs as syncStatus,Ss as takeSyncNotice};