dal-code 1.0.38 → 1.0.39

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 (81) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dal-docs/settings.md +1 -1
  3. package/dist/core/agent-session.js +4 -4
  4. package/dist/core/compaction/compaction.js +31 -13
  5. package/dist/core/permissions/tool-policy.js +1 -1
  6. package/dist/core/project-facts.d.ts +16 -0
  7. package/dist/core/project-facts.js +2 -0
  8. package/dist/core/sandbox/policy.js +1 -1
  9. package/dist/core/sandbox/windows.js +1 -1
  10. package/dist/core/system-prompt.d.ts +1 -0
  11. package/dist/core/system-prompt.js +12 -12
  12. package/dist/core/workspace-lock.d.ts +29 -0
  13. package/dist/core/workspace-lock.js +3 -0
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +1 -1
  16. package/dist/main.js +3 -3
  17. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  18. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  19. package/dist/node_modules/@dalcode/dal-goal/package.json +2 -2
  20. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  21. package/dist/node_modules/@dalcode/dal-guard/src/attribution.js +1 -0
  22. package/dist/node_modules/@dalcode/dal-guard/src/credentials.js +1 -1
  23. package/dist/node_modules/@dalcode/dal-guard/src/index.js +1 -1
  24. package/dist/node_modules/@dalcode/dal-guard/src/package-manager.js +1 -0
  25. package/dist/node_modules/@dalcode/dal-guard/src/workspace.js +2 -0
  26. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  27. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  28. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  29. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  30. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  31. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  32. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -2
  33. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  34. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -2
  35. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  36. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  37. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  38. package/dist/node_modules/@dalcode/dal-router/package.json +5 -4
  39. package/dist/node_modules/@dalcode/dal-router/src/commands.js +7 -7
  40. package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +2 -0
  41. package/dist/node_modules/@dalcode/dal-router/src/config.js +2 -2
  42. package/dist/node_modules/@dalcode/dal-router/src/index.js +4 -4
  43. package/dist/node_modules/@dalcode/dal-router/src/subagent.js +1 -1
  44. package/dist/node_modules/@dalcode/dal-router/src/suggest.js +2 -0
  45. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  46. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  47. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +12 -12
  48. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  49. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  50. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  51. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  52. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  53. package/dist/node_modules/@dalcode/dal-workflow/src/completion-check.js +4 -0
  54. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  55. package/dist/node_modules/@dalcode/dal-workflow/src/ledger.js +3 -0
  56. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  57. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  58. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  59. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  60. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  61. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  62. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  63. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  64. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  65. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  66. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  67. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  68. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  69. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  70. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  71. package/dist/utils/version-check.d.ts +1 -0
  72. package/dist/utils/version-check.js +2 -2
  73. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  74. package/examples/extensions/gondolin/package-lock.json +2 -2
  75. package/examples/extensions/gondolin/package.json +1 -1
  76. package/examples/extensions/sandbox/package-lock.json +2 -2
  77. package/examples/extensions/sandbox/package.json +1 -1
  78. package/examples/extensions/with-deps/package-lock.json +2 -2
  79. package/examples/extensions/with-deps/package.json +1 -1
  80. package/npm-shrinkwrap.json +2 -2
  81. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-plugins",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -22,9 +22,9 @@
22
22
  ]
23
23
  },
24
24
  "dependencies": {
25
- "@dalcode/dal-pi-kit": "1.0.38",
26
- "@dalcode/dal-skills": "1.0.38",
27
- "@dalcode/deepailab": "1.0.38",
25
+ "@dalcode/dal-pi-kit": "1.0.39",
26
+ "@dalcode/dal-skills": "1.0.39",
27
+ "@dalcode/deepailab": "1.0.39",
28
28
  "typebox": "1.3.27"
29
29
  },
30
30
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-review",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
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.38",
23
- "@dalcode/dal-subagent": "1.0.38",
22
+ "@dalcode/dal-pi-kit": "1.0.39",
23
+ "@dalcode/dal-subagent": "1.0.39",
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.38",
3
+ "version": "1.0.39",
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.38"
24
+ "@dalcode/dal-pi-kit": "1.0.39"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@dalcode/dal-router",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
9
9
  "./subagent": "./src/subagent.js",
10
+ "./suggest": "./src/suggest.js",
10
11
  "./config": "./src/config.js",
11
12
  "./jev": "./src/jev.js",
12
13
  "./router": "./src/router.js",
@@ -25,9 +26,9 @@
25
26
  ]
26
27
  },
27
28
  "dependencies": {
28
- "@dalcode/dal-pi-kit": "1.0.38",
29
- "@dalcode/deepailab": "1.0.38",
30
- "@earendil-works/pi-tui": "^1.0.38"
29
+ "@dalcode/dal-pi-kit": "1.0.39",
30
+ "@dalcode/deepailab": "1.0.39",
31
+ "@earendil-works/pi-tui": "^1.0.39"
31
32
  },
32
33
  "peerDependencies": {
33
34
  "@earendil-works/pi-coding-agent": "^1.0.0"
@@ -1,8 +1,8 @@
1
- var C=Object.defineProperty;var i=(n,F)=>C(n,"name",{value:F,configurable:!0});var $=Object.defineProperty,D=i((n,F)=>$(n,"name",{value:F,configurable:!0}),"f");import{t as u}from"@dalcode/dal-pi-kit";import{resolveJevRequestConfig as y}from"./jev.js";import{autoRouteActive as m,candidates as p,config as g,configWarning as v,persistMainAutoRoute as M,router as A}from"./runtime.js";function E(n){n.ui.notify([u("\u7528\u6CD5\uFF1A/factory [status]"),u("\u7528\u6CD5\uFF1A/factory auto on|off \u2014 \u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5F00\u5173"),u("\u7528\u6CD5\uFF1A/factory levels \u2014 \u6700\u8FD1\u51B3\u7B56\u4F9D\u636E"),u("\u7528\u6CD5\uFF1A/factory pool \u2014 \u5019\u9009\u6A21\u578B\u6C60")].join(`
2
- `),"info")}i(E,"w"),D(E,"usage");async function B(n,F){const[d,...l]=n.trim().split(/\s+/).filter(Boolean),f=v();f&&F.ui.notify(f,"warning");const r=g(),a=p();switch(d??"status"){case"status":{const e=r.enabled?m()?u("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5F00\u542F"):u("\u4EC5\u8F85\u52A9\u4EFB\u52A1\u8DEF\u7531\uFF08\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5173\u95ED\uFF0C/factory auto on \u5F00\u542F\uFF09"):u("\u5DF2\u7981\u7528"),o=r.classifier.enabled?y(r.classifier)?u("\u5206\u7C7B\u5668\uFF1Ajev\uFF08\u672C\u673A Key\uFF09"):u("\u5206\u7C7B\u5668\uFF1Ajev\uFF08\u7ECF DeepAILab \u8D26\u53F7\uFF1B\u4E0D\u53EF\u7528\u65F6\u4FDD\u6301\u9ED8\u8BA4\u6A21\u578B\uFF09"):u("\u5206\u7C7B\u5668\uFF1A\u5DF2\u5173\u95ED"),t=A().decisionLog().slice(-5).reverse(),s=t.length?t.map(c=>` \u2192 ${c.modelId??"?"} \u2014 ${c.reason}`).join(`
3
- `):` ${u("\u6682\u65E0\u8DEF\u7531\u51B3\u7B56\u3002")}`;F.ui.notify(`${u("\u6A21\u578B\u5DE5\u5382\uFF1A")}${e}
1
+ var y=Object.defineProperty;var i=(e,t)=>y(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,D=i((e,t)=>d(e,"name",{value:t,configurable:!0}),"c");import{t as u}from"@dalcode/dal-pi-kit";import{patchFactoryConfig as g}from"./config.js";import{resolveJevRequestConfig as m}from"./jev.js";import{autoRouteActive as $,candidates as p,config as v,configWarning as M,persistMainAutoRoute as h,reloadConfig as j,router as E}from"./runtime.js";function B(e){e.ui.notify([u("\u7528\u6CD5\uFF1A/factory [status]"),u("\u7528\u6CD5\uFF1A/factory auto on|off \u2014 \u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5F00\u5173"),u("\u7528\u6CD5\uFF1A/factory levels \u2014 \u6700\u8FD1\u51B3\u7B56\u4F9D\u636E"),u("\u7528\u6CD5\uFF1A/factory pool \u2014 \u5019\u9009\u6A21\u578B\u6C60"),u("\u7528\u6CD5\uFF1A/factory suggest on|off \u2014 \u590D\u6742\u4EFB\u52A1\u65F6\u63D0\u793A\u6539\u7528\u81EA\u52A8")].join(`
2
+ `),"info")}i(B,"k"),D(B,"usage");async function l(e,t){const[C,...f]=e.trim().split(/\s+/).filter(Boolean),c=M();c&&t.ui.notify(c,"warning");const r=v(),s=p();switch(C??"status"){case"status":{const F=r.enabled?$()?u("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5F00\u542F"):u("\u4EC5\u8F85\u52A9\u4EFB\u52A1\u8DEF\u7531\uFF08\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5173\u95ED\uFF0C/factory auto on \u5F00\u542F\uFF09"):u("\u5DF2\u7981\u7528"),o=r.classifier.enabled?m(r.classifier)?u("\u5206\u7C7B\u5668\uFF1Ajev\uFF08\u672C\u673A Key\uFF09"):u("\u5206\u7C7B\u5668\uFF1Ajev\uFF08\u7ECF DeepAILab \u8D26\u53F7\uFF1B\u4E0D\u53EF\u7528\u65F6\u4FDD\u6301\u9ED8\u8BA4\u6A21\u578B\uFF09"):u("\u5206\u7C7B\u5668\uFF1A\u5DF2\u5173\u95ED"),n=E().decisionLog().slice(-5).reverse(),a=n.length?n.map(A=>` \u2192 ${A.modelId??"?"} \u2014 ${A.reason}`).join(`
3
+ `):` ${u("\u6682\u65E0\u8DEF\u7531\u51B3\u7B56\u3002")}`;t.ui.notify(`${u("\u6A21\u578B\u5DE5\u5382\uFF1A")}${F}
4
4
  ${o}
5
- ${s}`,"info");return}case"levels":{const e=A().decisionLog().slice(-8).reverse();if(e.length===0){F.ui.notify(u("\u6682\u65E0\u8DEF\u7531\u51B3\u7B56\u3002"),"info");return}F.ui.notify(e.map(o=>{const t=o.source==="jev"&&typeof o.confidence=="number"?`\uFF08${u("\u7F6E\u4FE1\u5EA6 ")}${Math.round(o.confidence*100)}%\uFF09`:"";return`\u2192 ${o.modelId??"?"} \u2014 ${o.reason}${t}`}).join(`
6
- `),"info");return}case"pool":{if(!a||a.length===0){F.ui.notify(u("\u5019\u9009\u6C60\u5C1A\u672A\u6784\u5EFA\uFF08\u7B49\u5F85\u4F1A\u8BDD\u542F\u52A8\uFF09\u3002"),"info");return}const e=[...a].sort((o,t)=>o.costPerMtok-t.costPerMtok||o.id.localeCompare(t.id)).map(o=>{const t=o.contextWindow>=1e6?"1M":`${Math.round(o.contextWindow/1e3)}K`,s=o.costPerMtok>0?`~$${o.costPerMtok.toFixed(2)}/Mtok`:u("\u4EF7\u683C\u672A\u77E5");return` ${o.id} (${t}${o.reasoning?`, ${u("\u63A8\u7406")}`:""}, ${s})`});F.ui.notify(`${u("\u5019\u9009\u6A21\u578B\u6C60\uFF1A")}
7
- ${e.join(`
8
- `)}`,"info");return}case"auto":{const e=l[0];if(e!=="on"&&e!=="off"){F.ui.notify(u("\u7528\u6CD5\uFF1A/factory auto on|off"),"info");return}M(e==="on"),F.ui.notify(e==="on"?u("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5F00\u542F\uFF08\u5168\u5C40\u6301\u4E45\u5316\uFF09\u3002"):u("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5173\u95ED\uFF08\u5168\u5C40\u6301\u4E45\u5316\uFF09\u3002"),"info");return}default:E(F)}}i(B,"b"),D(B,"runFactoryCommand");export{B as runFactoryCommand};
5
+ ${a}`,"info");return}case"levels":{const F=E().decisionLog().slice(-8).reverse();if(F.length===0){t.ui.notify(u("\u6682\u65E0\u8DEF\u7531\u51B3\u7B56\u3002"),"info");return}t.ui.notify(F.map(o=>{const n=o.source==="jev"&&typeof o.confidence=="number"?`\uFF08${u("\u7F6E\u4FE1\u5EA6 ")}${Math.round(o.confidence*100)}%\uFF09`:"";return`\u2192 ${o.modelId??"?"} \u2014 ${o.reason}${n}`}).join(`
6
+ `),"info");return}case"pool":{if(!s||s.length===0){t.ui.notify(u("\u5019\u9009\u6C60\u5C1A\u672A\u6784\u5EFA\uFF08\u7B49\u5F85\u4F1A\u8BDD\u542F\u52A8\uFF09\u3002"),"info");return}const F=[...s].sort((o,n)=>o.costPerMtok-n.costPerMtok||o.id.localeCompare(n.id)).map(o=>{const n=o.contextWindow>=1e6?"1M":`${Math.round(o.contextWindow/1e3)}K`,a=o.costPerMtok>0?`~$${o.costPerMtok.toFixed(2)}/Mtok`:u("\u4EF7\u683C\u672A\u77E5");return` ${o.id} (${n}${o.reasoning?`, ${u("\u63A8\u7406")}`:""}, ${a})`});t.ui.notify(`${u("\u5019\u9009\u6A21\u578B\u6C60\uFF1A")}
7
+ ${F.join(`
8
+ `)}`,"info");return}case"auto":{const F=f[0];if(F!=="on"&&F!=="off"){t.ui.notify(u("\u7528\u6CD5\uFF1A/factory auto on|off"),"info");return}h(F==="on"),t.ui.notify(F==="on"?u("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5F00\u542F\uFF08\u5168\u5C40\u6301\u4E45\u5316\uFF09\u3002"):u("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5173\u95ED\uFF08\u5168\u5C40\u6301\u4E45\u5316\uFF09\u3002"),"info");return}case"suggest":{const F=f[0];if(F!=="on"&&F!=="off"){t.ui.notify(u("\u7528\u6CD5\uFF1A/factory suggest on|off \u2014 \u590D\u6742\u4EFB\u52A1\u65F6\u63D0\u793A\u6539\u7528\u81EA\u52A8"),"info");return}try{g({suggestAuto:F==="on"}),j()}catch(o){t.ui.notify(o instanceof Error?o.message:String(o),"error");return}t.ui.notify(F==="on"?u("\u590D\u6742\u4EFB\u52A1\u65F6\u4F1A\u63D0\u793A\u6539\u7528\u81EA\u52A8\u3002"):u("\u4E0D\u518D\u63D0\u793A\u6539\u7528\u81EA\u52A8\u3002"),"info");return}default:B(t)}}i(l,"W"),D(l,"runFactoryCommand");export{l as runFactoryCommand};
@@ -15,6 +15,8 @@ export interface FactoryConfig {
15
15
  subagent: boolean;
16
16
  compaction: boolean;
17
17
  };
18
+ subagentModel: string;
19
+ suggestAuto: boolean;
18
20
  classifier: ClassifierConfig;
19
21
  affinity: {
20
22
  margin: number;
@@ -1,2 +1,2 @@
1
- var k=Object.defineProperty;var o=(t,e)=>k(t,"name",{value:e,configurable:!0});var x=Object.defineProperty,s=o((t,e)=>x(t,"name",{value:e,configurable:!0}),"i");import{existsSync as A,readFileSync as g}from"node:fs";import{join as f}from"node:path";import{t as m,withFileLockSync as M,writeFileAtomicSync as _}from"@dalcode/dal-pi-kit";import{CONFIG_DIR_NAME as E,getAgentDir as b}from"@earendil-works/pi-coding-agent";const N={pluginRank:"DAL_JEV_PLUGIN_RANK",subagentRole:"DAL_JEV_SUBAGENT_ROLE",compactDefer:"DAL_JEV_COMPACT_DEFER",guardReview:"DAL_JEV_GUARD_REVIEW"};function R(t,e,n=process.env){if(!t.enabled||!t.classifier.enabled)return!1;const i=n[N[e]]?.trim().toLowerCase();return i==="off"||i==="0"||i==="false"?!1:i==="on"||i==="1"||i==="true"?!0:t.jevAssist[e]}o(R,"S"),s(R,"jevFeatureEnabled");const l={enabled:!0,mainAutoRoute:!0,auxRoute:{subagent:!0,compaction:!0},classifier:{enabled:!0,timeoutMs:2500,jev:{baseUrl:"https://api.typesafe.ai",model:"jev-latest",apiKey:""}},affinity:{margin:.15},turnAssist:{enabled:!0,tools:!0,skills:!0,thinking:!0,minConfidence:.7},jevAssist:{pluginRank:!0,subagentRole:!0,compactDefer:!1,guardReview:!0,minConfidence:.7,compactMaxDefer:3}};function d(){return f(b(),"factory.json")}o(d,"R"),s(d,"factoryConfigPath");function u(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}o(u,"s"),s(u,"isRecord");function c(t,e,n){return typeof t=="number"&&Number.isFinite(t)&&t>=e&&t<=n?t:void 0}o(c,"f"),s(c,"numberInRange");function v(t,e){const n={...t};if(typeof e.enabled=="boolean"&&(n.enabled=e.enabled),typeof e.mainAutoRoute=="boolean"&&(n.mainAutoRoute=e.mainAutoRoute),u(e.auxRoute)&&(n.auxRoute={subagent:typeof e.auxRoute.subagent=="boolean"?e.auxRoute.subagent:t.auxRoute.subagent,compaction:typeof e.auxRoute.compaction=="boolean"?e.auxRoute.compaction:t.auxRoute.compaction}),u(e.classifier)){const i=u(e.classifier.jev)?e.classifier.jev:{};n.classifier={enabled:typeof e.classifier.enabled=="boolean"?e.classifier.enabled:t.classifier.enabled,timeoutMs:c(e.classifier.timeoutMs,100,1e4)??t.classifier.timeoutMs,jev:{baseUrl:typeof i.baseUrl=="string"?i.baseUrl:t.classifier.jev.baseUrl,model:typeof i.model=="string"?i.model:t.classifier.jev.model,apiKey:typeof i.apiKey=="string"?i.apiKey:t.classifier.jev.apiKey}}}if(u(e.affinity)&&(n.affinity={margin:c(e.affinity.margin,0,.45)??t.affinity.margin}),u(e.turnAssist)){const i=e.turnAssist,a=s(r=>typeof i[r]=="boolean"?i[r]:t.turnAssist[r],"flag");n.turnAssist={enabled:a("enabled"),tools:a("tools"),skills:a("skills"),thinking:a("thinking"),minConfidence:c(i.minConfidence,.5,1)??t.turnAssist.minConfidence}}if(u(e.jevAssist)){const i=e.jevAssist,a=s(p=>typeof i[p]=="boolean"?i[p]:t.jevAssist[p],"flag"),r=c(i.compactMaxDefer,0,10);n.jevAssist={pluginRank:a("pluginRank"),subagentRole:a("subagentRole"),compactDefer:a("compactDefer"),guardReview:a("guardReview"),minConfidence:c(i.minConfidence,.7,1)??t.jevAssist.minConfidence,compactMaxDefer:r===void 0?t.jevAssist.compactMaxDefer:Math.floor(r)}}return n}o(v,"k"),s(v,"mergeConfig");function F(t,e=process.env){const n=e.DAL_FACTORY_ASSIST?.trim().toLowerCase();return n==="off"||n==="0"||n==="false"?!1:n==="on"||n==="1"||n==="true"?!0:t.turnAssist.enabled}o(F,"_"),s(F,"turnAssistEnabled");function D(){const t=d();if(!A(t))return{config:l,mainAutoRouteExplicit:!1};try{const e=JSON.parse(g(t,"utf8"));return u(e)?{config:v(l,e),mainAutoRouteExplicit:typeof e.mainAutoRoute=="boolean"}:{config:l,mainAutoRouteExplicit:!1,warning:m(`${t}: \u9876\u5C42\u4E0D\u662F JSON \u5BF9\u8C61\uFF0C\u5DF2\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\u3002`)}}catch(e){const n=e instanceof Error?e.message:String(e);return{config:l,mainAutoRouteExplicit:!1,warning:`${t}: ${m("JSON \u89E3\u6790\u5931\u8D25\uFF0C\u5DF2\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\u3002")}${n}`}}}o(D,"N"),s(D,"loadFactoryConfig");function C(t){const e=d();M(e,()=>{let n={};if(A(e)){let i;try{i=JSON.parse(g(e,"utf8"))}catch(a){const r=a instanceof Error?a.message:String(a);throw new Error(`${e}: ${m("JSON \u89E3\u6790\u5931\u8D25\uFF0C\u62D2\u7EDD\u4FEE\u6539\u4EE5\u907F\u514D\u8986\u76D6\u73B0\u6709\u914D\u7F6E\u3002")}${r}`)}if(!u(i))throw new Error(`${e}: ${m("\u9876\u5C42\u4E0D\u662F JSON \u5BF9\u8C61\uFF0C\u62D2\u7EDD\u4FEE\u6539\u3002")}`);n=i}_(e,`${JSON.stringify({...n,...t},null,2)}
2
- `)})}o(C,"M"),s(C,"patchFactoryConfig");function y(t){try{const e=JSON.parse(g(t,"utf8"));return u(e)&&typeof e.defaultModel=="string"&&e.defaultModel.length>0?e.defaultModel:void 0}catch{return}}o(y,"y"),s(y,"readDefaultModel");function h(t){try{const e=JSON.parse(g(t,"utf8"));return u(e)?e:void 0}catch{return}}o(h,"E"),s(h,"readSettings");function j(t,e=process.argv){return e.some(n=>n==="--thinking"||n.startsWith("--thinking="))?!0:[f(b(),"settings.json"),f(t,E,"settings.json")].some(n=>{const i=h(n);return i?typeof i.defaultThinkingLevel=="string"?!0:u(i.modelThinkingLevels)&&Object.keys(i.modelThinkingLevels).length>0:!1})}o(j,"O"),s(j,"userPinnedThinking");function S(t,e=process.argv){return e.some(n=>n==="--model"||n==="--models"||n.startsWith("--model="))?!0:y(f(b(),"settings.json"))!==void 0||y(f(t,E,"settings.json"))!==void 0}o(S,"L"),s(S,"userPinnedModel");export{l as DEFAULT_CONFIG,d as factoryConfigPath,R as jevFeatureEnabled,D as loadFactoryConfig,C as patchFactoryConfig,F as turnAssistEnabled,S as userPinnedModel,j as userPinnedThinking};
1
+ var S=Object.defineProperty;var i=(t,e)=>S(t,"name",{value:e,configurable:!0});var k=Object.defineProperty,s=i((t,e)=>k(t,"name",{value:e,configurable:!0}),"i");import{existsSync as y,readFileSync as g}from"node:fs";import{join as f}from"node:path";import{t as m,withFileLockSync as x,writeFileAtomicSync as _}from"@dalcode/dal-pi-kit";import{CONFIG_DIR_NAME as E,getAgentDir as b}from"@earendil-works/pi-coding-agent";const N={pluginRank:"DAL_JEV_PLUGIN_RANK",subagentRole:"DAL_JEV_SUBAGENT_ROLE",compactDefer:"DAL_JEV_COMPACT_DEFER",guardReview:"DAL_JEV_GUARD_REVIEW"};function R(t,e,o=process.env){if(!t.enabled||!t.classifier.enabled)return!1;const n=o[N[e]]?.trim().toLowerCase();return n==="off"||n==="0"||n==="false"?!1:n==="on"||n==="1"||n==="true"?!0:t.jevAssist[e]}i(R,"J"),s(R,"jevFeatureEnabled");const l={enabled:!0,mainAutoRoute:!0,auxRoute:{subagent:!0,compaction:!0},subagentModel:"route",suggestAuto:!0,classifier:{enabled:!0,timeoutMs:2500,jev:{baseUrl:"https://api.typesafe.ai",model:"jev-latest",apiKey:""}},affinity:{margin:.15},turnAssist:{enabled:!0,tools:!0,skills:!0,thinking:!0,minConfidence:.7},jevAssist:{pluginRank:!0,subagentRole:!0,compactDefer:!1,guardReview:!0,minConfidence:.7,compactMaxDefer:3}};function d(){return f(b(),"factory.json")}i(d,"y"),s(d,"factoryConfigPath");function u(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}i(u,"s"),s(u,"isRecord");function c(t,e,o){return typeof t=="number"&&Number.isFinite(t)&&t>=e&&t<=o?t:void 0}i(c,"f"),s(c,"numberInRange");function v(t,e){const o={...t};if(typeof e.enabled=="boolean"&&(o.enabled=e.enabled),typeof e.mainAutoRoute=="boolean"&&(o.mainAutoRoute=e.mainAutoRoute),u(e.auxRoute)&&(o.auxRoute={subagent:typeof e.auxRoute.subagent=="boolean"?e.auxRoute.subagent:t.auxRoute.subagent,compaction:typeof e.auxRoute.compaction=="boolean"?e.auxRoute.compaction:t.auxRoute.compaction}),typeof e.subagentModel=="string"&&e.subagentModel.trim()&&(o.subagentModel=e.subagentModel.trim()),typeof e.suggestAuto=="boolean"&&(o.suggestAuto=e.suggestAuto),u(e.classifier)){const n=u(e.classifier.jev)?e.classifier.jev:{};o.classifier={enabled:typeof e.classifier.enabled=="boolean"?e.classifier.enabled:t.classifier.enabled,timeoutMs:c(e.classifier.timeoutMs,100,1e4)??t.classifier.timeoutMs,jev:{baseUrl:typeof n.baseUrl=="string"?n.baseUrl:t.classifier.jev.baseUrl,model:typeof n.model=="string"?n.model:t.classifier.jev.model,apiKey:typeof n.apiKey=="string"?n.apiKey:t.classifier.jev.apiKey}}}if(u(e.affinity)&&(o.affinity={margin:c(e.affinity.margin,0,.45)??t.affinity.margin}),u(e.turnAssist)){const n=e.turnAssist,a=s(r=>typeof n[r]=="boolean"?n[r]:t.turnAssist[r],"flag");o.turnAssist={enabled:a("enabled"),tools:a("tools"),skills:a("skills"),thinking:a("thinking"),minConfidence:c(n.minConfidence,.5,1)??t.turnAssist.minConfidence}}if(u(e.jevAssist)){const n=e.jevAssist,a=s(p=>typeof n[p]=="boolean"?n[p]:t.jevAssist[p],"flag"),r=c(n.compactMaxDefer,0,10);o.jevAssist={pluginRank:a("pluginRank"),subagentRole:a("subagentRole"),compactDefer:a("compactDefer"),guardReview:a("guardReview"),minConfidence:c(n.minConfidence,.7,1)??t.jevAssist.minConfidence,compactMaxDefer:r===void 0?t.jevAssist.compactMaxDefer:Math.floor(r)}}return o}i(v,"k"),s(v,"mergeConfig");function F(t,e=process.env){const o=e.DAL_FACTORY_ASSIST?.trim().toLowerCase();return o==="off"||o==="0"||o==="false"?!1:o==="on"||o==="1"||o==="true"?!0:t.turnAssist.enabled}i(F,"S"),s(F,"turnAssistEnabled");function D(){const t=d();if(!y(t))return{config:l,mainAutoRouteExplicit:!1};try{const e=JSON.parse(g(t,"utf8"));return u(e)?{config:v(l,e),mainAutoRouteExplicit:typeof e.mainAutoRoute=="boolean"}:{config:l,mainAutoRouteExplicit:!1,warning:m(`${t}: \u9876\u5C42\u4E0D\u662F JSON \u5BF9\u8C61\uFF0C\u5DF2\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\u3002`)}}catch(e){const o=e instanceof Error?e.message:String(e);return{config:l,mainAutoRouteExplicit:!1,warning:`${t}: ${m("JSON \u89E3\u6790\u5931\u8D25\uFF0C\u5DF2\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\u3002")}${o}`}}}i(D,"_"),s(D,"loadFactoryConfig");function C(t){const e=d();x(e,()=>{let o={};if(y(e)){let n;try{n=JSON.parse(g(e,"utf8"))}catch(a){const r=a instanceof Error?a.message:String(a);throw new Error(`${e}: ${m("JSON \u89E3\u6790\u5931\u8D25\uFF0C\u62D2\u7EDD\u4FEE\u6539\u4EE5\u907F\u514D\u8986\u76D6\u73B0\u6709\u914D\u7F6E\u3002")}${r}`)}if(!u(n))throw new Error(`${e}: ${m("\u9876\u5C42\u4E0D\u662F JSON \u5BF9\u8C61\uFF0C\u62D2\u7EDD\u4FEE\u6539\u3002")}`);o=n}_(e,`${JSON.stringify({...o,...t},null,2)}
2
+ `)})}i(C,"N"),s(C,"patchFactoryConfig");function A(t){try{const e=JSON.parse(g(t,"utf8"));return u(e)&&typeof e.defaultModel=="string"&&e.defaultModel.length>0?e.defaultModel:void 0}catch{return}}i(A,"R"),s(A,"readDefaultModel");function h(t){try{const e=JSON.parse(g(t,"utf8"));return u(e)?e:void 0}catch{return}}i(h,"E"),s(h,"readSettings");function j(t,e=process.argv){return e.some(o=>o==="--thinking"||o.startsWith("--thinking="))?!0:[f(b(),"settings.json"),f(t,E,"settings.json")].some(o=>{const n=h(o);return n?typeof n.defaultThinkingLevel=="string"?!0:u(n.modelThinkingLevels)&&Object.keys(n.modelThinkingLevels).length>0:!1})}i(j,"O"),s(j,"userPinnedThinking");function M(t,e=process.argv){return e.some(o=>o==="--model"||o==="--models"||o.startsWith("--model="))?!0:A(f(b(),"settings.json"))!==void 0||A(f(t,E,"settings.json"))!==void 0}i(M,"L"),s(M,"userPinnedModel");export{l as DEFAULT_CONFIG,d as factoryConfigPath,R as jevFeatureEnabled,D as loadFactoryConfig,C as patchFactoryConfig,F as turnAssistEnabled,M as userPinnedModel,j as userPinnedThinking};
@@ -1,4 +1,4 @@
1
- var q=Object.defineProperty;var v=(o,d)=>q(o,"name",{value:d,configurable:!0});var Z=Object.defineProperty,l=v((o,d)=>Z(o,"name",{value:d,configurable:!0}),"d");import{t as g}from"@dalcode/dal-pi-kit";import{getSupportedThinkingLevels as ee}from"@earendil-works/pi-ai";import{compact as te}from"@earendil-works/pi-coding-agent";import{fuzzyFilter as oe}from"@earendil-works/pi-tui";import{ASSIST_THINKING_LEVELS as se,assistMessage as ne,buildAssistQuestions as ie,interpretAssist as ae,MAX_SKILL_CANDIDATES as re,planIsEmpty as ue,skillSearchApi as le,toolCatalogApi as J}from"./assist.js";import{runFactoryCommand as ce}from"./commands.js";import{decideCompactionDeferral as de}from"./compact-defer.js";import{jevFeatureEnabled as P,turnAssistEnabled as pe,userPinnedModel as me,userPinnedThinking as fe}from"./config.js";import{jevTimeoutMs as ge,noteJevProxyFailure as ve,resolveJevRoute as O,selectWithJev as ye,warmJevRoute as Ae}from"./jev.js";import{curatePool as he}from"./pool.js";import{autoRouteActive as R,candidates as W,candidatesStale as Fe,clearUnavailable as ke,config as A,configWarning as be,mainAutoRouteExplicit as K,markUnavailable as Ee,persistMainAutoRoute as N,pickCheapestAvailable as Ce,reloadConfig as De,resetThinkingAssist as we,router as Se,setAutoRouteRuntime as H,setCandidates as Re,setThinkingAssistState as T,thinkingAssistState as w,unavailableSet as x}from"./runtime.js";import{createJevService as Te,publishJevService as xe}from"./services.js";function z(o){const d=[];return o.groups.length>0&&d.push(`${g("\u5DE5\u5177 ")}${o.groups.join("/")}`),o.skills.length>0&&d.push(`${g("\u6280\u80FD ")}${o.skills.map(h=>h.name).join("/")}`),o.thinking&&d.push(`${g("\u601D\u8003 ")}${o.thinking}`),d.join(" \xB7 ")}v(z,"Me"),l(z,"describeAssist");const G="deepailab",$e="auto";function $(o){const d=(o.modelRegistry?.getAvailable?.()??[]).filter(s=>s.provider===G&&s.id!==$e&&!x().has(s.id)).map(s=>({model:s,id:s.id,name:s.name,costPerMtok:s.cost&&typeof s.cost.input=="number"&&typeof s.cost.output=="number"?(s.cost.input+s.cost.output)/2:0})),h=he(d).map(({model:s})=>s).map(s=>{const y=s.cost,b=y&&typeof y.input=="number"&&typeof y.output=="number"?(y.input+y.output)/2:0;return{id:s.id,provider:G,contextWindow:s.contextWindow??128e3,maxTokens:s.maxTokens??8192,reasoning:!!s.reasoning,costPerMtok:b}});h.length!==0&&Re(h)}v($,"G"),l($,"buildCandidatesFrom");function U(o){let d=!1,h,s=0;const y=Te({config:A,enabled:P,credentials:l(()=>h,"credentials")});xe(y),o.on("session_start",async(t,e)=>{De(),ke(),h=e.modelRegistry,s=0;const n=be();n&&process.stderr.write(`dal-router: ${n}
2
- `),!K()&&me(e.cwd)&&H(!1),we(fe(e.cwd)),$(e);const a=A();a.enabled&&a.classifier.enabled&&O(a.classifier,e.modelRegistry).then(c=>c&&Ae(c))});function b(t){R()&&(K()&&A().mainAutoRoute?N(!1):H(!1),t.ui.setStatus?.("factory",void 0),t.ui.notify?.(g("\u5DF2\u5207\u6362\u5230\u4F60\u9009\u7684\u6A21\u578B\uFF0C\u4E0D\u518D\u81EA\u52A8\u8DEF\u7531\uFF08\u5728 /model \u91CC\u9009\u201C\u81EA\u52A8\u201D\u53EF\u6062\u590D\uFF09"),"info"))}v(b,"A"),l(b,"stopAutoRoute"),o.on("model_select",async(t,e)=>{d||t.source==="restore"||b(e)}),o.registerModelPickerEntry("auto",{getState:l(()=>{const t=A();if(!(!t.enabled||!t.classifier.enabled||(W()?.length??0)===0))return{label:g("\u81EA\u52A8\uFF08\u667A\u80FD\u8DEF\u7531\uFF09"),description:g("\u6BCF\u8F6E\u6309\u4EFB\u52A1\u4ECE\u6A21\u578B\u6C60\u91CC\u6311\u9009\u5408\u9002\u7684\u6A21\u578B"),current:R()}},"getState"),onSelect:l(t=>{N(!0),t.ui.notify(g("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5F00\u542F\uFF08\u5168\u5C40\u6301\u4E45\u5316\uFF09\u3002"),"info")},"onSelect"),onModelChosen:l((t,e)=>b(e),"onModelChosen")}),o.on("before_agent_start",async(t,e)=>{if(t.messageType!=="user"||!A().enabled)return;const n=w();!n.pinned&&n.last!==void 0&&o.getThinkingLevel()!==n.last&&T({pinned:!0});try{return await B(t,e)}finally{w().pinned||T({last:o.getThinkingLevel()})}});async function B(t,e){const n=A();let a=R();const c=pe(n);if(!a&&!c)return;const i=await O(n.classifier,e.modelRegistry);if(!i)return;let u=[];a&&($(e),u=(Fe()?[]:W()??[]).filter(m=>!x().has(m.id)),u.length===0&&(a=!1));const p=c?M(t.prompt,e):void 0,F=p&&!ue(p)?ie(p):{},E=Object.keys(F).length>0;if(!a&&!E)return;const Y=Date.now();let C;const I=l(async m=>{try{const f=await ye(t.prompt,i,ge(i,n.classifier.timeoutMs),m,F);return C=f.answers,f}catch(f){throw i.via==="deepailab"&&ve(f),f}},"ask");let r;if(a)r=await Se().route({prompt:t.prompt,candidates:u,currentModelId:e.model?.id,margin:n.affinity.margin,select:{run:l(async(m,f)=>{const{model:j,modelError:X}=await I(f);if(!j)throw X??new Error("jev returned no model");return j},"run")}});else try{await I(void 0)}catch{}const Q=Date.now()-Y;let S=!1;if(r){if(r.modelId&&r.provider&&r.modelId!==e.model?.id){const m=e.modelRegistry?.find(r.provider,r.modelId);if(m){d=!0;let f;try{f=await o.setModel(m)}finally{d=!1}f?S=!0:(Ee(r.modelId),e.ui.setStatus("factory",void 0))}}S&&e.ui.setStatus?.("factory",`\u2192 ${r.modelId} \xB7 ${r.reason}`)}const V=p&&C?ae(p,C,n.turnAssist.minConfidence):void 0,k=_(V,p,e),D=z(k);if(r&&r.source!=="degraded"){const m=typeof r.confidence=="number"?` \xB7 ${g("\u7F6E\u4FE1\u5EA6 ")}${Math.round(r.confidence*100)}%`:"";e.ui.notify?.(`${r.reason}${m}${D?` \xB7 ${D}`:""}`,"info")}else D&&e.ui.notify?.(D,"info");process.env.DAL_FACTORY_TRACE==="1"&&process.stderr.write(`dal-router trace ${JSON.stringify({jevMs:Q,model:r?{id:r.modelId,source:r.source,switched:S}:void 0,asked:Object.keys(F),answered:C!==void 0,groups:k.groups,skills:k.skills.map(m=>m.name),thinking:k.thinking})}
3
- `);const L=ne(k.groups,k.skills);if(L)return{message:{customType:"dal-router-assist",content:[{type:"text",text:L}],display:!1}}}v(B,"T"),l(B,"routeTurn");function M(t,e){const n=A().turnAssist,a=n.tools?J()?.inactiveGroups()??[]:[];let c=[];if(n.skills)try{c=le()?.search(t,e.cwd,re)??[]}catch{c=[]}let i=[];if(n.thinking&&e.model?.reasoning&&!w().pinned){const u=new Set(ee(e.model));i=se.filter(p=>u.has(p)),i.length<2&&(i=[])}return{groups:a,skills:c,thinkingLevels:i}}v(M,"$"),l(M,"planAssist");function _(t,e,n){const a=[],c=J();for(const u of t?.groups??[])c&&c.activate(u).length>0&&a.push(u);let i;if(e&&e.thinkingLevels.length>0&&n.model?.reasoning){const u=w(),p=o.getThinkingLevel(),F=u.base??p,E=t?.thinking??F;E!==p&&(o.setThinkingLevel(E),i=o.getThinkingLevel()),T({base:F})}return{groups:a,skills:t?.skills??[],thinking:i}}v(_,"Y"),l(_,"applyAssist"),o.on("session_before_compact",async(t,e)=>{const n=A();if(P(n,"compactDefer")&&t.preparation){const i=await de({reason:t.reason,tokens:t.preparation.tokensBefore,contextWindow:e.model?.contextWindow,deferredSoFar:s,maxDefer:n.jevAssist.compactMaxDefer,entries:t.branchEntries,minConfidence:n.jevAssist.minConfidence,ask:l((u,p)=>y.ask("compactDefer",u,p,{credentials:e.modelRegistry}),"ask")});if(process.env.DAL_FACTORY_TRACE==="1"&&process.stderr.write(`dal-router trace ${JSON.stringify({compactDefer:{...i,deferredSoFar:s}})}
4
- `),i.defer)return s+=1,e.ui.notify?.(`${g("\u6B63\u5904\u5728\u591A\u6B65\u64CD\u4F5C\u4E2D\uFF0C\u81EA\u52A8\u538B\u7F29\u63A8\u8FDF\u5230\u4E0B\u4E00\u8F6E")} (${s}/${n.jevAssist.compactMaxDefer})`,"info"),{cancel:!0}}if(!n.enabled||!n.auxRoute.compaction||o.getSettings().compaction?.summaryModel)return;const a=Ce(x()),c=t.preparation;if(!(!a||!c))try{const i=e.modelRegistry?.find(a.provider,a.id);if(!i)return;const u=e.modelRegistry?.getApiKeyAndHeaders?await e.modelRegistry.getApiKeyAndHeaders(i):void 0;return u&&!u.ok?void 0:{compaction:await te(c,i,u?.apiKey,u?.headers,t.customInstructions,t.signal,"off")}}catch{return}}),o.on("session_compact",async()=>{s=0}),o.registerCommand("factory",{description:g("\u67E5\u770B/\u914D\u7F6E\u6A21\u578B\u5DE5\u5382\uFF08status | auto on|off | levels | pool\uFF09"),getArgumentCompletions:l(t=>oe([{value:"status",label:"status"},{value:"auto on",label:"auto on"},{value:"levels",label:"levels"},{value:"pool",label:"pool"}],t,e=>e.value).map(e=>({value:e.value,label:e.label})),"getArgumentCompletions"),handler:l(async(t,e)=>ce(t,e),"handler")})}v(U,"xe"),l(U,"default");export{U as default};
1
+ var ee=Object.defineProperty;var g=(n,d)=>ee(n,"name",{value:d,configurable:!0});var te=Object.defineProperty,l=g((n,d)=>te(n,"name",{value:d,configurable:!0}),"l");import{t as v}from"@dalcode/dal-pi-kit";import{getSupportedThinkingLevels as se}from"@earendil-works/pi-ai";import{compact as ne}from"@earendil-works/pi-coding-agent";import{fuzzyFilter as oe}from"@earendil-works/pi-tui";import{ASSIST_THINKING_LEVELS as ie,assistMessage as ae,buildAssistQuestions as re,interpretAssist as ue,MAX_SKILL_CANDIDATES as le,planIsEmpty as ce,skillSearchApi as de,toolCatalogApi as W}from"./assist.js";import{runFactoryCommand as pe}from"./commands.js";import{decideCompactionDeferral as me}from"./compact-defer.js";import{jevFeatureEnabled as K,turnAssistEnabled as fe,userPinnedModel as ge,userPinnedThinking as ve}from"./config.js";import{jevTimeoutMs as ye,noteJevProxyFailure as Ae,resolveJevRoute as N,selectWithJev as he,warmJevRoute as Fe}from"./jev.js";import{curatePool as ke}from"./pool.js";import{autoRouteActive as w,candidates as x,candidatesStale as be,clearUnavailable as Ee,config as A,configWarning as Ce,mainAutoRouteExplicit as H,markUnavailable as De,persistMainAutoRoute as z,pickCheapestAvailable as we,reloadConfig as Se,resetThinkingAssist as Re,router as Te,setAutoRouteRuntime as G,setCandidates as xe,setThinkingAssistState as $,thinkingAssistState as S,unavailableSet as M}from"./runtime.js";import{createJevService as $e,publishJevService as Me}from"./services.js";import{autoSuggestionText as Be,isLightModel as Le,looksComplex as _e}from"./suggest.js";function U(n){const d=[];return n.groups.length>0&&d.push(`${v("\u5DE5\u5177 ")}${n.groups.join("/")}`),n.skills.length>0&&d.push(`${v("\u6280\u80FD ")}${n.skills.map(h=>h.name).join("/")}`),n.thinking&&d.push(`${v("\u601D\u8003 ")}${n.thinking}`),d.join(" \xB7 ")}g(U,"Ie"),l(U,"describeAssist");const Y="deepailab",Ie="auto";function B(n){const d=(n.modelRegistry?.getAvailable?.()??[]).filter(o=>o.provider===Y&&o.id!==Ie&&!M().has(o.id)).map(o=>({model:o,id:o.id,name:o.name,costPerMtok:o.cost&&typeof o.cost.input=="number"&&typeof o.cost.output=="number"?(o.cost.input+o.cost.output)/2:0})),h=ke(d).map(({model:o})=>o).map(o=>{const y=o.cost,b=y&&typeof y.input=="number"&&typeof y.output=="number"?(y.input+y.output)/2:0;return{id:o.id,provider:Y,contextWindow:o.contextWindow??128e3,maxTokens:o.maxTokens??8192,reasoning:!!o.reasoning,costPerMtok:b}});h.length!==0&&xe(h)}g(B,"G"),l(B,"buildCandidatesFrom");function Q(n){let d=!1,h,o=0,y=!1;const b=$e({config:A,enabled:K,credentials:l(()=>h,"credentials")});Me(b),n.on("session_start",async(t,e)=>{Se(),Ee(),h=e.modelRegistry,o=0,y=!1;const s=Ce();s&&process.stderr.write(`dal-router: ${s}
2
+ `),!H()&&ge(e.cwd)&&G(!1),Re(ve(e.cwd)),B(e);const i=A();i.enabled&&i.classifier.enabled&&N(i.classifier,e.modelRegistry).then(c=>c&&Fe(c))});function R(t){w()&&(H()&&A().mainAutoRoute?z(!1):G(!1),t.ui.setStatus?.("factory",void 0),t.ui.notify?.(v("\u5DF2\u5207\u6362\u5230\u4F60\u9009\u7684\u6A21\u578B\uFF0C\u4E0D\u518D\u81EA\u52A8\u8DEF\u7531\uFF08\u5728 /model \u91CC\u9009\u201C\u81EA\u52A8\u201D\u53EF\u6062\u590D\uFF09"),"info"))}g(R,"C"),l(R,"stopAutoRoute"),n.on("model_select",async(t,e)=>{d||t.source==="restore"||R(e)}),n.registerModelPickerEntry("auto",{getState:l(()=>{const t=A();if(!(!t.enabled||!t.classifier.enabled||(x()?.length??0)===0))return{label:v("\u81EA\u52A8\uFF08\u667A\u80FD\u8DEF\u7531\uFF09"),description:v("\u6BCF\u8F6E\u6309\u4EFB\u52A1\u4ECE\u6A21\u578B\u6C60\u91CC\u6311\u9009\u5408\u9002\u7684\u6A21\u578B"),current:w()}},"getState"),onSelect:l(t=>{z(!0),t.ui.notify(v("\u4E3B\u5BF9\u8BDD\u81EA\u52A8\u8DEF\u7531\u5DF2\u5F00\u542F\uFF08\u5168\u5C40\u6301\u4E45\u5316\uFF09\u3002"),"info")},"onSelect"),onModelChosen:l((t,e)=>R(e),"onModelChosen")}),n.on("before_agent_start",async(t,e)=>{if(t.messageType!=="user"||!A().enabled)return;L(t.prompt,e);const s=S();!s.pinned&&s.last!==void 0&&n.getThinkingLevel()!==s.last&&$({pinned:!0});try{return await _(t,e)}finally{S().pinned||$({last:n.getThinkingLevel()})}});function L(t,e){const s=A();if(y||!s.suggestAuto||w()||!s.classifier.enabled||(x()?.length??0)===0)return;const i=e.model?.id;!i||!Le(i)||!_e(t)||(y=!0,e.ui.notify?.(Be(i),"info"))}g(L,"I"),l(L,"maybeSuggestAuto");async function _(t,e){const s=A();let i=w();const c=fe(s);if(!i&&!c)return;const a=await N(s.classifier,e.modelRegistry);if(!a)return;let u=[];i&&(B(e),u=(be()?[]:x()??[]).filter(m=>!M().has(m.id)),u.length===0&&(i=!1));const p=c?I(t.prompt,e):void 0,F=p&&!ce(p)?re(p):{},E=Object.keys(F).length>0;if(!i&&!E)return;const V=Date.now();let C;const J=l(async m=>{try{const f=await he(t.prompt,a,ye(a,s.classifier.timeoutMs),m,F);return C=f.answers,f}catch(f){throw a.via==="deepailab"&&Ae(f),f}},"ask");let r;if(i)r=await Te().route({prompt:t.prompt,candidates:u,currentModelId:e.model?.id,margin:s.affinity.margin,select:{run:l(async(m,f)=>{const{model:O,modelError:Z}=await J(f);if(!O)throw Z??new Error("jev returned no model");return O},"run")}});else try{await J(void 0)}catch{}const X=Date.now()-V;let T=!1;if(r){if(r.modelId&&r.provider&&r.modelId!==e.model?.id){const m=e.modelRegistry?.find(r.provider,r.modelId);if(m){d=!0;let f;try{f=await n.setModel(m)}finally{d=!1}f?T=!0:(De(r.modelId),e.ui.setStatus("factory",void 0))}}T&&e.ui.setStatus?.("factory",`\u2192 ${r.modelId} \xB7 ${r.reason}`)}const q=p&&C?ue(p,C,s.turnAssist.minConfidence):void 0,k=j(q,p,e),D=U(k);if(r&&r.source!=="degraded"){const m=typeof r.confidence=="number"?` \xB7 ${v("\u7F6E\u4FE1\u5EA6 ")}${Math.round(r.confidence*100)}%`:"";e.ui.notify?.(`${r.reason}${m}${D?` \xB7 ${D}`:""}`,"info")}else D&&e.ui.notify?.(D,"info");process.env.DAL_FACTORY_TRACE==="1"&&process.stderr.write(`dal-router trace ${JSON.stringify({jevMs:X,model:r?{id:r.modelId,source:r.source,switched:T}:void 0,asked:Object.keys(F),answered:C!==void 0,groups:k.groups,skills:k.skills.map(m=>m.name),thinking:k.thinking})}
3
+ `);const P=ae(k.groups,k.skills);if(P)return{message:{customType:"dal-router-assist",content:[{type:"text",text:P}],display:!1}}}g(_,"Y"),l(_,"routeTurn");function I(t,e){const s=A().turnAssist,i=s.tools?W()?.inactiveGroups()??[]:[];let c=[];if(s.skills)try{c=de()?.search(t,e.cwd,le)??[]}catch{c=[]}let a=[];if(s.thinking&&e.model?.reasoning&&!S().pinned){const u=new Set(se(e.model));a=ie.filter(p=>u.has(p)),a.length<2&&(a=[])}return{groups:i,skills:c,thinkingLevels:a}}g(I,"H"),l(I,"planAssist");function j(t,e,s){const i=[],c=W();for(const u of t?.groups??[])c&&c.activate(u).length>0&&i.push(u);let a;if(e&&e.thinkingLevels.length>0&&s.model?.reasoning){const u=S(),p=n.getThinkingLevel(),F=u.base??p,E=t?.thinking??F;E!==p&&(n.setThinkingLevel(E),a=n.getThinkingLevel()),$({base:F})}return{groups:i,skills:t?.skills??[],thinking:a}}g(j,"U"),l(j,"applyAssist"),n.on("session_before_compact",async(t,e)=>{const s=A();if(K(s,"compactDefer")&&t.preparation){const a=await me({reason:t.reason,tokens:t.preparation.tokensBefore,contextWindow:e.model?.contextWindow,deferredSoFar:o,maxDefer:s.jevAssist.compactMaxDefer,entries:t.branchEntries,minConfidence:s.jevAssist.minConfidence,ask:l((u,p)=>b.ask("compactDefer",u,p,{credentials:e.modelRegistry}),"ask")});if(process.env.DAL_FACTORY_TRACE==="1"&&process.stderr.write(`dal-router trace ${JSON.stringify({compactDefer:{...a,deferredSoFar:o}})}
4
+ `),a.defer)return o+=1,e.ui.notify?.(`${v("\u6B63\u5904\u5728\u591A\u6B65\u64CD\u4F5C\u4E2D\uFF0C\u81EA\u52A8\u538B\u7F29\u63A8\u8FDF\u5230\u4E0B\u4E00\u8F6E")} (${o}/${s.jevAssist.compactMaxDefer})`,"info"),{cancel:!0}}if(!s.enabled||!s.auxRoute.compaction||n.getSettings().compaction?.summaryModel)return;const i=we(M()),c=t.preparation;if(!(!i||!c))try{const a=e.modelRegistry?.find(i.provider,i.id);if(!a)return;const u=e.modelRegistry?.getApiKeyAndHeaders?await e.modelRegistry.getApiKeyAndHeaders(a):void 0;return u&&!u.ok?void 0:{compaction:await ne(c,a,u?.apiKey,u?.headers,t.customInstructions,t.signal,"off")}}catch{return}}),n.on("session_compact",async()=>{o=0}),n.registerCommand("factory",{description:v("\u67E5\u770B/\u914D\u7F6E\u6A21\u578B\u5DE5\u5382\uFF08status | auto on|off | levels | pool\uFF09"),getArgumentCompletions:l(t=>oe([{value:"status",label:"status"},{value:"auto on",label:"auto on"},{value:"levels",label:"levels"},{value:"pool",label:"pool"},{value:"suggest off",label:"suggest off"}],t,e=>e.value).map(e=>({value:e.value,label:e.label})),"getArgumentCompletions"),handler:l(async(t,e)=>pe(t,e),"handler")})}g(Q,"De"),l(Q,"default");export{Q as default};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var n=(t,e)=>f(t,"name",{value:e,configurable:!0});var m=Object.defineProperty,v=n((t,e)=>m(t,"name",{value:e,configurable:!0}),"s");import{t as p}from"@dalcode/dal-pi-kit";import{applyDomesticPreference as b,jevTimeoutMs as g,noteJevProxyFailure as y,resolveJevRoute as M,selectModelWithJev as x}from"./jev.js";import{candidates as h,config as F,unavailableSet as B}from"./runtime.js";async function c(t,e={}){const r=F();if(!r.enabled||!r.auxRoute.subagent)return;const u=t.taskText?.trim();if(!u)return;const a=e.request?{...e.request,via:"direct"}:await M(r.classifier,t.credentials);if(!a)return;const o=e.pool??h()?.filter(i=>!B().has(i.id))??[];if(o.length!==0)try{const i=await x(u.slice(0,8e3),a,g(a,r.classifier.timeoutMs),o,e),l=o.find(d=>d.id===i.modelId);if(!l)return;const s=b(l.id,i.probabilities,o,r.affinity.margin);return{modelId:s.id,provider:s.provider,reason:`${p("\u6309\u5B50\u4EFB\u52A1\u5224\u578B\uFF1A")}${s.id}`}}catch(i){a.via==="deepailab"&&y(i);return}}n(c,"M"),v(c,"routeSubagentModel");export{c as routeSubagentModel};
1
+ var p=Object.defineProperty;var o=(e,r)=>p(e,"name",{value:r,configurable:!0});var v=Object.defineProperty,l=o((e,r)=>v(e,"name",{value:r,configurable:!0}),"d");import{t as g}from"@dalcode/dal-pi-kit";import{applyDomesticPreference as M,jevTimeoutMs as h,noteJevProxyFailure as y,resolveJevRoute as P,selectModelWithJev as k}from"./jev.js";import{candidates as x,config as c,unavailableSet as F}from"./runtime.js";async function f(e,r={}){const i=c();if(!i.enabled||!i.auxRoute.subagent)return;const u=e.taskText?.trim();if(!u)return;const a=r.request?{...r.request,via:"direct"}:await P(i.classifier,e.credentials);if(!a)return;const n=r.pool??x()?.filter(t=>!F().has(t.id))??[];if(n.length!==0)try{const t=await k(u.slice(0,8e3),a,h(a,i.classifier.timeoutMs),n,r),d=n.find(b=>b.id===t.modelId);if(!d)return;const s=M(d.id,t.probabilities,n,i.affinity.margin);return{modelId:s.id,provider:s.provider,reason:`${g("\u6309\u5B50\u4EFB\u52A1\u5224\u578B\uFF1A")}${s.id}`}}catch(t){a.via==="deepailab"&&y(t);return}}o(f,"P"),l(f,"routeSubagentModel");function m(){const e=c().subagentModel.trim();return e===""||e==="route"?{kind:"route"}:e==="inherit"?{kind:"inherit"}:{kind:"model",spec:e}}o(m,"q"),l(m,"subagentModelPreference");export{f as routeSubagentModel,m as subagentModelPreference};
@@ -0,0 +1,2 @@
1
+ var a=Object.defineProperty;var e=(u,t)=>a(u,"name",{value:t,configurable:!0});var r=Object.defineProperty,o=e((u,t)=>r(u,"name",{value:t,configurable:!0}),"n");import{t as f}from"@dalcode/dal-pi-kit";const g=/(?:^|[-_/.:])(?:flash|mini|lite|nano|haiku|small|air|tiny|instant)(?:$|[-_/.:\d])/i;function s(u){return typeof u=="string"&&g.test(u)}e(s,"c"),o(s,"isLightModel");const A=/全部(?:都)?(?:做|完成|弄|搞|处理|修)|都(?:要)?(?:做好|做完|完成|修好|搞定)|每一(?:项|个|条)都|逐条做完|一次(?:性)?(?:做|搞)完|\ball of (?:them|it|these)\b|\beverything\b|\beach of (?:them|these)\b/i,h=/^\s*(?:\(?\d{1,2}[.、))]|[-*•]\s)/;function i(u){const t=u.trim(),n=t.split(`
2
+ `).filter(F=>h.test(F)).length;return n>=4||t.length>=1500?!0:A.test(t)&&(n>=2||t.length>=300)}e(i,"h"),o(i,"looksComplex");function l(u){return f("\u8FD9\u9879\u4EFB\u52A1\u8F83\u5927\uFF08\u591A\u9879\u3001\u591A\u6761\u7EBF\uFF09\uFF0C\u5F53\u524D\u56FA\u5B9A\u5728 {model} \u4E0A\u3002\u53EF\u4EE5\u5728 /model \u9009\u300C\u81EA\u52A8\u300D\uFF0C\u8BA9\u6BCF\u8F6E\u6309\u4EFB\u52A1\u6311\u6A21\u578B\uFF1B\u5B50\u4EFB\u52A1\u6A21\u578B\u53EF\u5728 factory.json \u7684 subagentModel \u8BBE\u7F6E\u3002\u4E0D\u518D\u63D0\u793A\uFF1A/factory suggest off").replace("{model}",u)}e(l,"m"),o(l,"autoSuggestionText");export{l as autoSuggestionText,s as isLightModel,i as looksComplex};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-skills",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -20,8 +20,8 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.38",
24
- "@dalcode/deepailab": "1.0.38",
23
+ "@dalcode/dal-pi-kit": "1.0.39",
24
+ "@dalcode/deepailab": "1.0.39",
25
25
  "typebox": "1.3.7"
26
26
  },
27
27
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-subagent",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,10 +17,10 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.38",
21
- "@dalcode/dal-guard": "1.0.38",
22
- "@earendil-works/pi-agent-core": "^1.0.38",
23
- "@earendil-works/pi-ai": "^1.0.38",
20
+ "@dalcode/dal-pi-kit": "1.0.39",
21
+ "@dalcode/dal-guard": "1.0.39",
22
+ "@earendil-works/pi-agent-core": "^1.0.39",
23
+ "@earendil-works/pi-ai": "^1.0.39",
24
24
  "typebox": "1.3.7"
25
25
  },
26
26
  "peerDependencies": {
@@ -1,20 +1,20 @@
1
- var su=Object.defineProperty;var c=(u,t)=>su(u,"name",{value:t,configurable:!0});var iu=Object.defineProperty,s=c((u,t)=>iu(u,"name",{value:t,configurable:!0}),"s");import{randomUUID as au}from"node:crypto";import{mkdirSync as cu,readFileSync as Fu,writeFileSync as lu}from"node:fs";import{join as du}from"node:path";import{t as e}from"@dalcode/dal-pi-kit";import{routeSubagentModel as Eu}from"@dalcode/dal-router/subagent";import{Type as E}from"typebox";import{formatAgentList as G,loadAgents as J,projectAgentsDir as gu,READ_ONLY_TOOL_NAMES as q,userAgentsDir as pu}from"./agents.js";import{addUsage as mu,assistantUsage as Au,currentSubagentDepth as Du,emptyUsage as Bu,endedOnAccountLimit as fu,findSubagentSessionFile as z,finishedNormally as hu,MAX_SUBAGENT_DEPTH as Cu,pruneSubagentSessions as $u,runResumableSubagent as wu,subagentSessionDir as yu}from"./process-runner.js";import{pickRoleWithJev as Su}from"./role-pick.js";export*from"./agents.js";export*from"./process-runner.js";export*from"./role-pick.js";const H=['Several separate items (modules, packages, repositories, documents, questions) that each need real work: dispatch one sub-agent per item with task, in your first response, all at once, without reading the items yourself first; there is no limit on how many ("review A, B and C" is three calls). Quick lookups you do yourself',"Sub-agents cannot see this conversation: each prompt states the goal, exact paths or inputs, constraints and what to report. Running together they share the working tree: give each different files, and let only one run installs, builds or git","Build on their reports; verify only what your answer depends on. Follow up with task resume=<the id in its result> and a prompt holding only the new instruction (resume alone continues one that failed)"],bu=E.Object({agent:E.Optional(E.String({description:e("\u8FD9\u4E00\u6B65\u7684\u89D2\u8272\u540D")})),prompt:E.String({description:e("\u8FD9\u4E00\u6B65\u7684\u4EFB\u52A1\uFF1B{previous} \u4E3A\u4E0A\u4E00\u6B65\u7684\u8F93\u51FA")})}),vu=E.Object({description:E.String({description:e("\u5B50\u4EFB\u52A1\u7684\u7B80\u77ED\u6807\u9898\uFF083-5 \u4E2A\u5B57\uFF0C\u7528\u4E8E\u5C55\u793A\u8FDB\u5EA6\uFF09")}),prompt:E.Optional(E.String({description:e("\u5B8C\u6574\u3001\u81EA\u5305\u542B\u7684\u4EFB\u52A1\u8BF4\u660E")})),resume:E.Optional(E.String({description:e("\u7EE7\u7EED\u67D0\u4E2A\u5B50 agent\uFF1A\u586B\u7ED3\u679C\u91CC\u7684\u5B50 agent ID\uFF1Bprompt \u53EA\u5199\u65B0\u6307\u793A\uFF0C\u4E0D\u586B\u5219\u4ECE\u4E2D\u65AD\u5904\u7EE7\u7EED")})),agent:E.Optional(E.String({description:e("\u89D2\u8272\u540D\uFF08\u89C1\u5DE5\u5177\u8BF4\u660E\uFF09\uFF1B\u4E0D\u586B\u4E3A\u901A\u7528\u5B50 agent")})),readOnly:E.Optional(E.Boolean({description:e("\u53EA\u7ED9\u53EA\u8BFB\u5DE5\u5177\uFF08read/grep/find/ls\uFF09")})),chain:E.Optional(E.Array(bu,{description:e("\u6309\u987A\u5E8F\u8FD0\u884C\u7684\u6B65\u9AA4\uFF1B\u4E0E prompt \u4E8C\u9009\u4E00")}))});function b(u){return`${e("[\u5B50 agent ID\uFF1A")}${u}${e("\uFF0C\u53EF\u7528 resume \u53C2\u6570\u7EE7\u7EED]")}`}c(b,"M"),s(b,"subagentIdLine");function x(){return e("\u4E0A\u4E00\u6B21\u8FD0\u884C\u4E2D\u65AD\u4E86\u3002\u8BF7\u4ECE\u4E2D\u65AD\u5904\u7EE7\u7EED\u5B8C\u6210\u539F\u6765\u7684\u4EFB\u52A1\uFF0C\u4E0D\u8981\u91CD\u590D\u5DF2\u7ECF\u5B8C\u6210\u7684\u6B65\u9AA4\uFF0C\u5B8C\u6210\u540E\u7ED9\u51FA\u6700\u7EC8\u7ED3\u679C\u3002")}c(x,"C"),s(x,"continuePrompt");const K=s((u,t)=>du(u,`${t}.meta.json`),"metaPath");function Q(u,t){const n=s(()=>new Error(`${e("\u627E\u4E0D\u5230\u5B50 agent\uFF1A")}${t}${e("\uFF08ID \u4E0D\u5B58\u5728\uFF0C\u6216\u4F1A\u8BDD\u5DF2\u8FC7\u671F\u88AB\u6E05\u7406\uFF09")}`),"missing");if(!/^[A-Za-z0-9-]+$/.test(t)||!z(u,t))throw n();try{return JSON.parse(Fu(K(u,t),"utf8"))}catch{throw n()}}c(Q,"fe"),s(Q,"loadSubagentMeta");function I(u){return`${e("[\u672A\u6307\u5B9A\u89D2\u8272\uFF0C\u5DF2\u81EA\u52A8\u9009\u62E9\uFF1A")}${u.agent.name}${e("\uFF0C\u7F6E\u4FE1\u5EA6 ")}${Math.round(u.confidence*100)}%]`}c(I,"me"),s(I,"autoRoleNote");function O(u){for(let t=u.length-1;t>=0;t--){const n=u[t];if(n.role!=="assistant")continue;const r=n.content.filter(a=>a.type==="text").map(a=>a.text).join(`
2
- `).trim();if(r)return r;if(n.errorMessage)return`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${n.errorMessage}`}return e("\u5B50 agent \u6CA1\u6709\u4EA7\u751F\u4EFB\u4F55\u8F93\u51FA\u3002")}c(O,"he"),s(O,"lastAssistantText");const xu=new Set(["write","edit","multi_edit","notebook_edit"]);function P(u){for(const t of["file_path","path","filePath"]){const n=u[t];if(typeof n=="string"&&n.length>0)return n}}c(P,"U"),s(P,"filePathFromInput");function W(u,t){const n=P(t);if(n)return`${u} ${n.split("/").slice(-2).join("/")}`;const r=t??{};for(const a of["command","pattern","query"]){const i=r[a];if(typeof i=="string"&&i.trim()){const o=i.replace(/\s+/g," ").trim();return`${u} ${o.length>40?`${o.slice(0,39)}\u2026`:o}`}}return u}c(W,"we"),s(W,"describeSubagentStep");function R(u){const t=e("\u4F60\u662F\u4E00\u4E2A\u4E13\u6CE8\u7684\u5B50 agent\uFF0C\u8D1F\u8D23\u5B8C\u6210\u7236\u4EFB\u52A1\u6D3E\u53D1\u7ED9\u4F60\u7684\u4E00\u4E2A\u72EC\u7ACB\u5B50\u4EFB\u52A1\u3002")+e("\u5B8C\u6210\u540E\u7528\u7B80\u6D01\u7684\u4E2D\u6587\u6587\u5B57\u7ED9\u51FA\u6700\u7EC8\u7ED3\u679C\uFF0C\u4E0D\u8981\u53CD\u95EE\uFF0C\u4E0D\u8981\u5F81\u6C42\u786E\u8BA4\u3002");return u?.systemPrompt?`${u.systemPrompt}
1
+ var su=Object.defineProperty;var c=(u,t)=>su(u,"name",{value:t,configurable:!0});var iu=Object.defineProperty,r=c((u,t)=>iu(u,"name",{value:t,configurable:!0}),"r");import{randomUUID as au}from"node:crypto";import{mkdirSync as Fu,readFileSync as cu,writeFileSync as lu}from"node:fs";import{join as du}from"node:path";import{t as e}from"@dalcode/dal-pi-kit";import{routeSubagentModel as Eu,subagentModelPreference as gu}from"@dalcode/dal-router/subagent";import{Type as E}from"typebox";import{formatAgentList as G,loadAgents as J,projectAgentsDir as pu,READ_ONLY_TOOL_NAMES as q,userAgentsDir as mu}from"./agents.js";import{addUsage as Au,assistantUsage as Du,currentSubagentDepth as Bu,emptyUsage as fu,endedOnAccountLimit as hu,findSubagentSessionFile as z,finishedNormally as Cu,MAX_SUBAGENT_DEPTH as $u,pruneSubagentSessions as wu,runResumableSubagent as yu,subagentSessionDir as Su}from"./process-runner.js";import{pickRoleWithJev as bu}from"./role-pick.js";export*from"./agents.js";export*from"./process-runner.js";export*from"./role-pick.js";const H=['Several separate items (modules, packages, repositories, documents, questions) that each need real work: dispatch one sub-agent per item with task, in your first response, all at once, without reading the items yourself first; there is no limit on how many ("review A, B and C" is three calls). Quick lookups you do yourself',"Sub-agents cannot see this conversation: each prompt states the goal, exact paths or inputs, constraints and what to report. Running together they share the working tree: give each different files, and let only one run installs, builds or git","Build on their reports; verify only what your answer depends on. Follow up with task resume=<the id in its result> and a prompt holding only the new instruction (resume alone continues one that failed)"],vu=E.Object({agent:E.Optional(E.String({description:e("\u8FD9\u4E00\u6B65\u7684\u89D2\u8272\u540D")})),prompt:E.String({description:e("\u8FD9\u4E00\u6B65\u7684\u4EFB\u52A1\uFF1B{previous} \u4E3A\u4E0A\u4E00\u6B65\u7684\u8F93\u51FA")})}),xu=E.Object({description:E.String({description:e("\u5B50\u4EFB\u52A1\u7684\u7B80\u77ED\u6807\u9898\uFF083-5 \u4E2A\u5B57\uFF0C\u7528\u4E8E\u5C55\u793A\u8FDB\u5EA6\uFF09")}),prompt:E.Optional(E.String({description:e("\u5B8C\u6574\u3001\u81EA\u5305\u542B\u7684\u4EFB\u52A1\u8BF4\u660E")})),resume:E.Optional(E.String({description:e("\u7EE7\u7EED\u67D0\u4E2A\u5B50 agent\uFF1A\u586B\u7ED3\u679C\u91CC\u7684\u5B50 agent ID\uFF1Bprompt \u53EA\u5199\u65B0\u6307\u793A\uFF0C\u4E0D\u586B\u5219\u4ECE\u4E2D\u65AD\u5904\u7EE7\u7EED")})),agent:E.Optional(E.String({description:e("\u89D2\u8272\u540D\uFF08\u89C1\u5DE5\u5177\u8BF4\u660E\uFF09\uFF1B\u4E0D\u586B\u4E3A\u901A\u7528\u5B50 agent")})),readOnly:E.Optional(E.Boolean({description:e("\u53EA\u7ED9\u53EA\u8BFB\u5DE5\u5177\uFF08read/grep/find/ls\uFF09")})),chain:E.Optional(E.Array(vu,{description:e("\u6309\u987A\u5E8F\u8FD0\u884C\u7684\u6B65\u9AA4\uFF1B\u4E0E prompt \u4E8C\u9009\u4E00")}))});function b(u){return`${e("[\u5B50 agent ID\uFF1A")}${u}${e("\uFF0C\u53EF\u7528 resume \u53C2\u6570\u7EE7\u7EED]")}`}c(b,"M"),r(b,"subagentIdLine");function x(){return e("\u4E0A\u4E00\u6B21\u8FD0\u884C\u4E2D\u65AD\u4E86\u3002\u8BF7\u4ECE\u4E2D\u65AD\u5904\u7EE7\u7EED\u5B8C\u6210\u539F\u6765\u7684\u4EFB\u52A1\uFF0C\u4E0D\u8981\u91CD\u590D\u5DF2\u7ECF\u5B8C\u6210\u7684\u6B65\u9AA4\uFF0C\u5B8C\u6210\u540E\u7ED9\u51FA\u6700\u7EC8\u7ED3\u679C\u3002")}c(x,"C"),r(x,"continuePrompt");const K=r((u,t)=>du(u,`${t}.meta.json`),"metaPath");function Q(u,t){const n=r(()=>new Error(`${e("\u627E\u4E0D\u5230\u5B50 agent\uFF1A")}${t}${e("\uFF08ID \u4E0D\u5B58\u5728\uFF0C\u6216\u4F1A\u8BDD\u5DF2\u8FC7\u671F\u88AB\u6E05\u7406\uFF09")}`),"missing");if(!/^[A-Za-z0-9-]+$/.test(t)||!z(u,t))throw n();try{return JSON.parse(cu(K(u,t),"utf8"))}catch{throw n()}}c(Q,"he"),r(Q,"loadSubagentMeta");function O(u){return`${e("[\u672A\u6307\u5B9A\u89D2\u8272\uFF0C\u5DF2\u81EA\u52A8\u9009\u62E9\uFF1A")}${u.agent.name}${e("\uFF0C\u7F6E\u4FE1\u5EA6 ")}${Math.round(u.confidence*100)}%]`}c(O,"ye"),r(O,"autoRoleNote");function P(u){for(let t=u.length-1;t>=0;t--){const n=u[t];if(n.role!=="assistant")continue;const o=n.content.filter(a=>a.type==="text").map(a=>a.text).join(`
2
+ `).trim();if(o)return o;if(n.errorMessage)return`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${n.errorMessage}`}return e("\u5B50 agent \u6CA1\u6709\u4EA7\u751F\u4EFB\u4F55\u8F93\u51FA\u3002")}c(P,"we"),r(P,"lastAssistantText");const ku=new Set(["write","edit","multi_edit","notebook_edit"]);function R(u){for(const t of["file_path","path","filePath"]){const n=u[t];if(typeof n=="string"&&n.length>0)return n}}c(R,"U"),r(R,"filePathFromInput");function W(u,t){const n=R(t);if(n)return`${u} ${n.split("/").slice(-2).join("/")}`;const o=t??{};for(const a of["command","pattern","query"]){const i=o[a];if(typeof i=="string"&&i.trim()){const s=i.replace(/\s+/g," ").trim();return`${u} ${s.length>40?`${s.slice(0,39)}\u2026`:s}`}}return u}c(W,"$e"),r(W,"describeSubagentStep");function M(u){const t=e("\u4F60\u662F\u4E00\u4E2A\u4E13\u6CE8\u7684\u5B50 agent\uFF0C\u8D1F\u8D23\u5B8C\u6210\u7236\u4EFB\u52A1\u6D3E\u53D1\u7ED9\u4F60\u7684\u4E00\u4E2A\u72EC\u7ACB\u5B50\u4EFB\u52A1\u3002")+e("\u5B8C\u6210\u540E\u7528\u7B80\u6D01\u7684\u4E2D\u6587\u6587\u5B57\u7ED9\u51FA\u6700\u7EC8\u7ED3\u679C\uFF0C\u4E0D\u8981\u53CD\u95EE\uFF0C\u4E0D\u8981\u5F81\u6C42\u786E\u8BA4\u3002");return u?.systemPrompt?`${u.systemPrompt}
3
3
 
4
- ${t}`:t}c(R,"Se"),s(R,"buildSubagentSystemPrompt");function X(u,t,n){const r=n?` \xB7 ${n}`:"";return`${u} \u2014 ${t} ${e("\u6B65")}${r}`}c(X,"$e"),s(X,"progressLine");function j(u,t,n){const r=u.indexOf("/");if(r>0){const o=t.find(u.slice(0,r),u.slice(r+1));if(o)return o}const a=t.find(n.provider,u);if(a)return a;const i=t.getAll().filter(o=>o.id===u);if(i.length===1)return i[0];throw new Error(`${e("\u627E\u4E0D\u5230\u89D2\u8272\u6307\u5B9A\u7684\u6A21\u578B\uFF1A")}${u}`)}c(j,"be"),s(j,"resolveAgentModel");async function Y(u,t){const n=t.model;if(!n)throw new Error(e("\u6CA1\u6709\u53EF\u7528\u7684\u5F53\u524D\u6A21\u578B\uFF0C\u65E0\u6CD5\u6D3E\u53D1\u5B50 agent\u3002"));let r=n;if(u.agent?.model)r=j(u.agent.model,t.modelRegistry,n);else try{const o=await Eu({taskText:u.prompt,credentials:t.modelRegistry});if(o?.modelId&&o.provider){const F=t.modelRegistry?.find(o.provider,o.modelId);F&&(r=F)}}catch{}const a=u.agent?.tools,i=u.readOnly?(a??q).filter(o=>q.includes(o)):a;return{cwd:t.cwd,model:`${r.provider}/${r.id}`,thinking:u.agent?.thinking??"off",...i?{tools:i}:{},appendSystemPrompt:R(u.agent),...u.agent?{agent:u.agent.name}:{}}}c(Y,"ke"),s(Y,"newSubagentMeta");class Z{static{c(this,"Ae")}static{s(this,"AccountLimitStop")}controller=new AbortController;tripped;get signal(){return this.controller.signal}get reason(){return this.tripped}trip(t){this.tripped===void 0&&(this.tripped=t,this.controller.abort())}reset(){this.tripped=void 0,this.controller=new AbortController}}function v(u){return`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${u}
5
- ${e("\u8D26\u6237\u6216\u6A21\u578B\u901A\u9053\u4F59\u989D\u4E0D\u8DB3\uFF0C\u5DF2\u505C\u6B62\u672C\u8F6E\u5168\u90E8\u5B50 agent\u3002\u4F59\u989D\u6062\u590D\u524D\u4E0D\u8981\u518D\u6D3E\u53D1\u5B50\u4EFB\u52A1\u6216\u91CD\u8BD5\u3002")}`}c(v,"P"),s(v,"accountLimitMessage");async function M(u,t,n,r,a,i){if(i?.reason!==void 0)throw new Error(v(i.reason));const o=yu();let F,d;u.resume?(F=u.resume.trim(),d=Q(o,F)):(d=await Y(u,t),F=au(),cu(o,{recursive:!0}),$u(o),lu(K(o,F),`${JSON.stringify(d)}
6
- `));const A=[];let C=0;const B=s(l=>new Error(z(o,F)?`${l}
7
- ${b(F)}`:l),"failed"),D=await wu({cwd:d.cwd,prompt:u.prompt||x(),session:{dir:o,id:F},resumePrompt:x(),model:d.model,thinking:d.thinking,tools:d.tools,...a?{excludeTools:a}:{},appendSystemPrompt:d.appendSystemPrompt,projectTrusted:t.isProjectTrusted(),signal:i?t.signal?AbortSignal.any([t.signal,i.signal]):i.signal:t.signal,attribution:{sessionId:t.sessionManager.getSessionId(),subagentId:F,label:u.description},onResume:s(()=>r?.(`${u.description} \u2014 ${e("\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u7EED\u8DD1")}`),"onResume"),onEvent:s(l=>{const h=Au(l);if(h&&mu(n,h),l.type!=="tool_execution_start")return;const y=String(l.toolName),g=l.args??{};if(C+=1,r?.(X(u.description,C,W(y,g))),xu.has(y)){const p=P(g);p&&A.push(p)}},"onEvent")}).catch(l=>{throw t.signal?.aborted?l:i?.reason!==void 0?B(v(i.reason)):B(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${l instanceof Error?l.message:String(l)}`)});if(D.idleTimedOut)throw B(e("\u5B50 agent \u8D85\u8FC7 10 \u5206\u949F\u6CA1\u6709\u4EFB\u4F55\u8FDB\u5C55\uFF0C\u5DF2\u505C\u6B62\u3002"));if(fu(D)){const l=D.messages.at(-1),h=l?.role==="assistant"&&l.errorMessage||"account limit";throw i?.trip(h),B(v(h))}const f=D.messages.at(-1),w=f?.role==="assistant"&&f.stopReason==="length";if(!w&&!hu(D)){const l=f?.role==="assistant"&&f.errorMessage||D.stderr.trim().split(`
4
+ ${t}`:t}c(M,"be"),r(M,"buildSubagentSystemPrompt");function X(u,t,n){const o=n?` \xB7 ${n}`:"";return`${u} \u2014 ${t} ${e("\u6B65")}${o}`}c(X,"ke"),r(X,"progressLine");function k(u,t,n){const o=u.indexOf("/");if(o>0){const s=t.find(u.slice(0,o),u.slice(o+1));if(s)return s}const a=t.find(n.provider,u);if(a)return a;const i=t.getAll().filter(s=>s.id===u);if(i.length===1)return i[0];throw new Error(`${e("\u627E\u4E0D\u5230\u89D2\u8272\u6307\u5B9A\u7684\u6A21\u578B\uFF1A")}${u}`)}c(k,"L"),r(k,"resolveAgentModel");async function Y(u,t){const n=t.model;if(!n)throw new Error(e("\u6CA1\u6709\u53EF\u7528\u7684\u5F53\u524D\u6A21\u578B\uFF0C\u65E0\u6CD5\u6D3E\u53D1\u5B50 agent\u3002"));let o=n;const a=gu();if(u.agent?.model)o=k(u.agent.model,t.modelRegistry,n);else if(a.kind==="model")o=k(a.spec,t.modelRegistry,n);else if(a.kind==="route")try{const F=await Eu({taskText:u.prompt,credentials:t.modelRegistry});if(F?.modelId&&F.provider){const l=t.modelRegistry?.find(F.provider,F.modelId);l&&(o=l)}}catch{}const i=u.agent?.tools,s=u.readOnly?(i??q).filter(F=>q.includes(F)):i;return{cwd:t.cwd,model:`${o.provider}/${o.id}`,thinking:u.agent?.thinking??"off",...s?{tools:s}:{},appendSystemPrompt:M(u.agent),...u.agent?{agent:u.agent.name}:{}}}c(Y,"Ae"),r(Y,"newSubagentMeta");class Z{static{c(this,"xe")}static{r(this,"AccountLimitStop")}controller=new AbortController;tripped;get signal(){return this.controller.signal}get reason(){return this.tripped}trip(t){this.tripped===void 0&&(this.tripped=t,this.controller.abort())}reset(){this.tripped=void 0,this.controller=new AbortController}}function v(u){return`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${u}
5
+ ${e("\u8D26\u6237\u6216\u6A21\u578B\u901A\u9053\u4F59\u989D\u4E0D\u8DB3\uFF0C\u5DF2\u505C\u6B62\u672C\u8F6E\u5168\u90E8\u5B50 agent\u3002\u4F59\u989D\u6062\u590D\u524D\u4E0D\u8981\u518D\u6D3E\u53D1\u5B50\u4EFB\u52A1\u6216\u91CD\u8BD5\u3002")}`}c(v,"P"),r(v,"accountLimitMessage");async function j(u,t,n,o,a,i){if(i?.reason!==void 0)throw new Error(v(i.reason));const s=Su();let F,l;u.resume?(F=u.resume.trim(),l=Q(s,F)):(l=await Y(u,t),F=au(),Fu(s,{recursive:!0}),wu(s),lu(K(s,F),`${JSON.stringify(l)}
6
+ `));const A=[];let C=0;const B=r(d=>new Error(z(s,F)?`${d}
7
+ ${b(F)}`:d),"failed"),D=await yu({cwd:l.cwd,prompt:u.prompt||x(),session:{dir:s,id:F},resumePrompt:x(),model:l.model,thinking:l.thinking,tools:l.tools,...a?{excludeTools:a}:{},appendSystemPrompt:l.appendSystemPrompt,projectTrusted:t.isProjectTrusted(),signal:i?t.signal?AbortSignal.any([t.signal,i.signal]):i.signal:t.signal,attribution:{sessionId:t.sessionManager.getSessionId(),subagentId:F,label:u.description},onResume:r(()=>o?.(`${u.description} \u2014 ${e("\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u7EED\u8DD1")}`),"onResume"),onEvent:r(d=>{const h=Du(d);if(h&&Au(n,h),d.type!=="tool_execution_start")return;const y=String(d.toolName),g=d.args??{};if(C+=1,o?.(X(u.description,C,W(y,g))),ku.has(y)){const p=R(g);p&&A.push(p)}},"onEvent")}).catch(d=>{throw t.signal?.aborted?d:i?.reason!==void 0?B(v(i.reason)):B(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${d instanceof Error?d.message:String(d)}`)});if(D.idleTimedOut)throw B(e("\u5B50 agent \u8D85\u8FC7 10 \u5206\u949F\u6CA1\u6709\u4EFB\u4F55\u8FDB\u5C55\uFF0C\u5DF2\u505C\u6B62\u3002"));if(hu(D)){const d=D.messages.at(-1),h=d?.role==="assistant"&&d.errorMessage||"account limit";throw i?.trip(h),B(v(h))}const f=D.messages.at(-1),w=f?.role==="assistant"&&f.stopReason==="length";if(!w&&!Cu(D)){const d=f?.role==="assistant"&&f.errorMessage||D.stderr.trim().split(`
8
8
  `).slice(-3).join(`
9
- `)||`exit ${D.exitCode}`;throw B(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${l}`)}const $=O(D.messages);return{text:w?`${$}
9
+ `)||`exit ${D.exitCode}`;throw B(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${d}`)}const $=P(D.messages);return{text:w?`${$}
10
10
 
11
- ${e("\uFF08\u5B50 agent \u7684\u56DE\u7B54\u8FBE\u5230\u4E86\u6A21\u578B\u8F93\u51FA\u957F\u5EA6\u4E0A\u9650\uFF0C\u5185\u5BB9\u4E0D\u5B8C\u6574\u3002\uFF09")}`:$,changedFiles:[...new Set(A)],subagentId:F,...d.agent?{agent:d.agent}:{},autoResumed:D.autoResumed}}c(M,"L"),s(M,"runSubagent");function k(u){return J({cwd:u.cwd,projectTrusted:u.isProjectTrusted()})}c(k,"R"),s(k,"agentsFor");function _(u,t){if(t===void 0||t.trim()==="")return;const n=u.find(r=>r.name===t.trim());if(!n)throw new Error(`${e("\u672A\u77E5\u7684\u5B50 agent \u89D2\u8272\uFF1A")}${t}${e("\u3002\u53EF\u7528\u89D2\u8272\uFF1A")}${u.map(r=>r.name).join(", ")}`);return n}c(_,"N"),s(_,"findAgent");function L(u,t){return u.split("{previous}").join(t)}c(L,"xe"),s(L,"fillPrevious");function V(u){return e("\u6D3E\u53D1\u4E00\u4E2A\u5B50 agent \u5B8C\u6210\u81EA\u5305\u542B\u7684\u5B50\u4EFB\u52A1\uFF1B\u540C\u4E00\u8F6E\u591A\u6B21\u8C03\u7528\u5373\u5E76\u884C\u8FD0\u884C\u3002\u5B50 agent \u7528\u5F53\u524D\u6A21\u578B\u548C\u5B8C\u6574\u5DE5\u5177\uFF08\u540C\u6837\u7ECF\u8FC7\u5B89\u5168\u5BA1\u6279\uFF09\uFF0C\u770B\u4E0D\u5230\u672C\u5BF9\u8BDD\u3002")+`
11
+ ${e("\uFF08\u5B50 agent \u7684\u56DE\u7B54\u8FBE\u5230\u4E86\u6A21\u578B\u8F93\u51FA\u957F\u5EA6\u4E0A\u9650\uFF0C\u5185\u5BB9\u4E0D\u5B8C\u6574\u3002\uFF09")}`:$,changedFiles:[...new Set(A)],subagentId:F,...l.agent?{agent:l.agent}:{},autoResumed:D.autoResumed}}c(j,"N"),r(j,"runSubagent");function T(u){return J({cwd:u.cwd,projectTrusted:u.isProjectTrusted()})}c(T,"R"),r(T,"agentsFor");function _(u,t){if(t===void 0||t.trim()==="")return;const n=u.find(o=>o.name===t.trim());if(!n)throw new Error(`${e("\u672A\u77E5\u7684\u5B50 agent \u89D2\u8272\uFF1A")}${t}${e("\u3002\u53EF\u7528\u89D2\u8272\uFF1A")}${u.map(o=>o.name).join(", ")}`);return n}c(_,"B"),r(_,"findAgent");function L(u,t){return u.split("{previous}").join(t)}c(L,"Te"),r(L,"fillPrevious");function V(u){return e("\u6D3E\u53D1\u4E00\u4E2A\u5B50 agent \u5B8C\u6210\u81EA\u5305\u542B\u7684\u5B50\u4EFB\u52A1\uFF1B\u540C\u4E00\u8F6E\u591A\u6B21\u8C03\u7528\u5373\u5E76\u884C\u8FD0\u884C\u3002\u5B50 agent \u7528\u5F53\u524D\u6A21\u578B\u548C\u5B8C\u6574\u5DE5\u5177\uFF08\u540C\u6837\u7ECF\u8FC7\u5B89\u5168\u5BA1\u6279\uFF09\uFF0C\u770B\u4E0D\u5230\u672C\u5BF9\u8BDD\u3002")+`
12
12
  `+e("\u89D2\u8272\uFF08agent \u53C2\u6570\uFF09\uFF1A")+`
13
13
  `+G(u)+`
14
- `+e("chain\uFF1A\u6309\u987A\u5E8F\u8FD0\u884C\u591A\u6B65\uFF08\u5982 scout \u2192 worker \u2192 reviewer\uFF09\u3002")}c(V,"Te"),s(V,"taskToolDescription");const N=new Map,uu=s(u=>u.totalTokens>0||u.cost.total>0,"hasUsage");function U(u,t,n){u.registerTool({name:"task",label:e("\u6D3E\u53D1\u5B50\u4EFB\u52A1"),description:V(t),promptSnippet:e("task - \u6D3E\u53D1\u5B50 agent \u5E76\u884C\u5904\u7406\u72EC\u7ACB\u5B50\u4EFB\u52A1"),promptGuidelines:H,parameters:vu,executionMode:"parallel",execute:s(async(r,a,i,o,F)=>{const d=Bu();try{return await tu(a,F,d,A=>{o?.({content:[{type:"text",text:A}],details:{description:a.description}})},u.getToolDenylist?.(),n)}catch(A){throw uu(d)&&N.set(r,d),A}},"execute")})}c(U,"G"),s(U,"registerTaskTool");async function tu(u,t,n,r,a,i){const{agents:o}=k(t),F=Array.isArray(u.chain)&&u.chain.length>0,d=typeof u.prompt=="string"&&u.prompt.trim()!=="",A=u.resume?.trim();if(A&&F)throw new Error(e("resume \u4E0D\u80FD\u548C chain \u4E00\u8D77\u4F7F\u7528\u3002"));if(!A&&F===d)throw new Error(e("task \u9700\u8981\u4E14\u53EA\u80FD\u63D0\u4F9B prompt \u6216 chain \u5176\u4E2D\u4E4B\u4E00\u3002"));const C=s(()=>uu(n)?{usage:n}:{},"usage");if(!F){let g=A?void 0:_(o,u.agent);const p=!A&&g===void 0?await Su(u.prompt??"",o,{credentials:t.modelRegistry}):void 0;p&&(g=p.agent);const m=await M({description:u.description,prompt:d?u.prompt??"":"",readOnly:u.readOnly===!0,agent:g,resume:A},t,n,r,a,i);return{content:[{type:"text",text:`${p?`${I(p)}
14
+ `+e("chain\uFF1A\u6309\u987A\u5E8F\u8FD0\u884C\u591A\u6B65\uFF08\u5982 scout \u2192 worker \u2192 reviewer\uFF09\u3002")}c(V,"Ie"),r(V,"taskToolDescription");const N=new Map,uu=r(u=>u.totalTokens>0||u.cost.total>0,"hasUsage");function U(u,t,n){u.registerTool({name:"task",label:e("\u6D3E\u53D1\u5B50\u4EFB\u52A1"),description:V(t),promptSnippet:e("task - \u6D3E\u53D1\u5B50 agent \u5E76\u884C\u5904\u7406\u72EC\u7ACB\u5B50\u4EFB\u52A1"),promptGuidelines:H,parameters:xu,executionMode:"parallel",execute:r(async(o,a,i,s,F)=>{const l=fu();try{return await tu(a,F,l,A=>{s?.({content:[{type:"text",text:A}],details:{description:a.description}})},u.getToolDenylist?.(),n)}catch(A){throw uu(l)&&N.set(o,l),A}},"execute")})}c(U,"J"),r(U,"registerTaskTool");async function tu(u,t,n,o,a,i){const{agents:s}=T(t),F=Array.isArray(u.chain)&&u.chain.length>0,l=typeof u.prompt=="string"&&u.prompt.trim()!=="",A=u.resume?.trim();if(A&&F)throw new Error(e("resume \u4E0D\u80FD\u548C chain \u4E00\u8D77\u4F7F\u7528\u3002"));if(!A&&F===l)throw new Error(e("task \u9700\u8981\u4E14\u53EA\u80FD\u63D0\u4F9B prompt \u6216 chain \u5176\u4E2D\u4E4B\u4E00\u3002"));const C=r(()=>uu(n)?{usage:n}:{},"usage");if(!F){let g=A?void 0:_(s,u.agent);const p=!A&&g===void 0?await bu(u.prompt??"",s,{credentials:t.modelRegistry}):void 0;p&&(g=p.agent);const m=await j({description:u.description,prompt:l?u.prompt??"":"",readOnly:u.readOnly===!0,agent:g,resume:A},t,n,o,a,i);return{content:[{type:"text",text:`${p?`${O(p)}
15
15
  ${m.text}`:m.text}
16
16
 
17
- ${b(m.subagentId)}`}],details:{description:u.description,...m.agent?{agent:m.agent}:{},subagentId:m.subagentId,...m.autoResumed?{autoResumed:!0}:{},...C(),...p?{autoAgent:{name:p.agent.name,confidence:p.confidence}}:{},...m.changedFiles.length>0?{changedFiles:m.changedFiles}:{}},...C()}}const B=u.chain??[],D=B.map(g=>_(o,g.agent??u.agent));let f="";const w=[],$=[];let l=!1;for(const[g,p]of B.entries()){const m=D[g],nu=`${u.description} [${g+1}/${B.length}${m?` ${m.name}`:""}]`;try{const{text:S,changedFiles:T,subagentId:ru,autoResumed:ou}=await M({description:nu,prompt:L(p.prompt,f),readOnly:u.readOnly===!0,agent:m},t,n,r,a,i);f=S,w.push(...T),$.push(ru),l||=ou}catch(S){const T=S instanceof Error?S.message:String(S);throw new Error(`${e("\u4E32\u884C\u94FE\u5728\u7B2C")} ${g+1} ${e("\u6B65\u4E2D\u65AD\uFF1A")}${T}`)}}const h=[...new Set(w)],y=$[$.length-1]??"";return{content:[{type:"text",text:`${f}
17
+ ${b(m.subagentId)}`}],details:{description:u.description,...m.agent?{agent:m.agent}:{},subagentId:m.subagentId,...m.autoResumed?{autoResumed:!0}:{},...C(),...p?{autoAgent:{name:p.agent.name,confidence:p.confidence}}:{},...m.changedFiles.length>0?{changedFiles:m.changedFiles}:{}},...C()}}const B=u.chain??[],D=B.map(g=>_(s,g.agent??u.agent));let f="";const w=[],$=[];let d=!1;for(const[g,p]of B.entries()){const m=D[g],nu=`${u.description} [${g+1}/${B.length}${m?` ${m.name}`:""}]`;try{const{text:S,changedFiles:I,subagentId:ou,autoResumed:ru}=await j({description:nu,prompt:L(p.prompt,f),readOnly:u.readOnly===!0,agent:m},t,n,o,a,i);f=S,w.push(...I),$.push(ou),d||=ru}catch(S){const I=S instanceof Error?S.message:String(S);throw new Error(`${e("\u4E32\u884C\u94FE\u5728\u7B2C")} ${g+1} ${e("\u6B65\u4E2D\u65AD\uFF1A")}${I}`)}}const h=[...new Set(w)],y=$[$.length-1]??"";return{content:[{type:"text",text:`${f}
18
18
 
19
- ${b(y)}`}],details:{description:u.description,subagentId:y,...l?{autoResumed:!0}:{},...C(),chain:D.map((g,p)=>({...g?{agent:g.name}:{},subagentId:$[p]})),...h.length>0?{changedFiles:h}:{}},...C()}}c(tu,"Ie"),s(tu,"executeTask");function eu(u){if(Du()>=Cu)return;const t=new Z;U(u,J({cwd:process.cwd(),projectTrusted:!1}).agents,t),u.on("session_start",async(n,r)=>{U(u,k(r).agents,t)}),u.on("agent_start",()=>{t.reset()}),u.on("tool_result",n=>{const r=n.toolName==="task"&&n.isError?N.get(n.toolCallId):void 0;if(N.delete(n.toolCallId),!r)return;const a=n.input.description??"";return{usage:r,details:{description:a,usage:r}}}),u.registerCommand("agents",{description:e("\u5217\u51FA\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\u53CA\u5176\u6765\u6E90"),handler:s(async(n,r)=>{const{agents:a,diagnostics:i}=k(r),o=[e("\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\uFF1A"),G(a,!0),"",`${e("\u7528\u6237\u89D2\u8272\u76EE\u5F55\uFF1A")}${pu()}`,`${e("\u9879\u76EE\u89D2\u8272\u76EE\u5F55\uFF1A")}${gu(r.cwd)}${r.isProjectTrusted()?"":e("\uFF08\u9879\u76EE\u672A\u4FE1\u4EFB\uFF0C\u672A\u8BFB\u53D6\uFF09")}`];i.length>0&&o.push("",e("\u4EE5\u4E0B\u89D2\u8272\u6587\u4EF6\u6709\u95EE\u9898\uFF1A"),...i.map(F=>`- ${F}`)),r.ui.notify(o.join(`
20
- `),i.length>0?"warning":"info")},"handler")})}c(eu,"Me"),s(eu,"default");export{Z as AccountLimitStop,H as TASK_TOOL_GUIDELINES,v as accountLimitMessage,I as autoRoleNote,R as buildSubagentSystemPrompt,x as continuePrompt,eu as default,L as fillPrevious,O as lastAssistantText,j as resolveAgentModel,b as subagentIdLine};
19
+ ${b(y)}`}],details:{description:u.description,subagentId:y,...d?{autoResumed:!0}:{},...C(),chain:D.map((g,p)=>({...g?{agent:g.name}:{},subagentId:$[p]})),...h.length>0?{changedFiles:h}:{}},...C()}}c(tu,"Me"),r(tu,"executeTask");function eu(u){if(Bu()>=$u)return;const t=new Z;U(u,J({cwd:process.cwd(),projectTrusted:!1}).agents,t),u.on("session_start",async(n,o)=>{U(u,T(o).agents,t)}),u.on("agent_start",()=>{t.reset()}),u.on("tool_result",n=>{const o=n.toolName==="task"&&n.isError?N.get(n.toolCallId):void 0;if(N.delete(n.toolCallId),!o)return;const a=n.input.description??"";return{usage:o,details:{description:a,usage:o}}}),u.registerCommand("agents",{description:e("\u5217\u51FA\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\u53CA\u5176\u6765\u6E90"),handler:r(async(n,o)=>{const{agents:a,diagnostics:i}=T(o),s=[e("\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\uFF1A"),G(a,!0),"",`${e("\u7528\u6237\u89D2\u8272\u76EE\u5F55\uFF1A")}${mu()}`,`${e("\u9879\u76EE\u89D2\u8272\u76EE\u5F55\uFF1A")}${pu(o.cwd)}${o.isProjectTrusted()?"":e("\uFF08\u9879\u76EE\u672A\u4FE1\u4EFB\uFF0C\u672A\u8BFB\u53D6\uFF09")}`];i.length>0&&s.push("",e("\u4EE5\u4E0B\u89D2\u8272\u6587\u4EF6\u6709\u95EE\u9898\uFF1A"),...i.map(F=>`- ${F}`)),o.ui.notify(s.join(`
20
+ `),i.length>0?"warning":"info")},"handler")})}c(eu,"Pe"),r(eu,"default");export{Z as AccountLimitStop,H as TASK_TOOL_GUIDELINES,v as accountLimitMessage,O as autoRoleNote,M as buildSubagentSystemPrompt,x as continuePrompt,eu as default,L as fillPrevious,P as lastAssistantText,k as resolveAgentModel,b as subagentIdLine};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-telemetry",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -20,7 +20,7 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.38"
23
+ "@dalcode/dal-pi-kit": "1.0.39"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-terminal",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "description": "Host terminal context: a terminal_read tool and @terminal mentions, registered only when the embedding host advertises the terminal capability.",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  ]
20
20
  },
21
21
  "dependencies": {
22
- "@dalcode/dal-pi-kit": "1.0.38",
22
+ "@dalcode/dal-pi-kit": "1.0.39",
23
23
  "typebox": "1.3.7"
24
24
  },
25
25
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-tool-catalog",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.38",
21
+ "@dalcode/dal-pi-kit": "1.0.39",
22
22
  "typebox": "1.3.7"
23
23
  },
24
24
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-web",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -23,8 +23,8 @@
23
23
  ]
24
24
  },
25
25
  "dependencies": {
26
- "@dalcode/dal-pi-kit": "1.0.38",
27
- "@dalcode/deepailab": "1.0.38",
26
+ "@dalcode/dal-pi-kit": "1.0.39",
27
+ "@dalcode/deepailab": "1.0.39",
28
28
  "typebox": "1.3.27"
29
29
  },
30
30
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-workflow",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.38",
20
+ "@dalcode/dal-pi-kit": "1.0.39",
21
21
  "typebox": "1.3.27"
22
22
  },
23
23
  "peerDependencies": {
@@ -0,0 +1,4 @@
1
+ var l=Object.defineProperty;var n=(u,e)=>l(u,"name",{value:e,configurable:!0});var B=Object.defineProperty,o=n((u,e)=>B(u,"name",{value:e,configurable:!0}),"o");import{t as m}from"@dalcode/dal-pi-kit";import{assistantText as p,fill as A,isAssistantMessage as f}from"./shared.js";import{formatTodo as D}from"./todo.js";const c="dal-completion-check",d=new RegExp(["(?:\u5168\u90E8|\u90FD|\u5747|\u7EDF\u7EDF|\u6240\u6709(?:\u7684)?[^\u3002\\n]{0,12}?)(?:\u5DF2\u7ECF?|\u5DF2)?(?:\u5B8C\u6210|\u505A\u5B8C|\u505A\u597D|\u641E\u5B9A|\u5BA1\u67E5\u5B8C|\u5BA1\u5B8C|\u5904\u7406\u5B8C|\u4FEE\u5B8C|\u6539\u5B8C|\u5F04\u597D|\u7ED3\u675F)","\u5DF2(?:\u5168\u90E8|\u7ECF\u5168\u90E8)(?:\u5B8C\u6210|\u505A\u5B8C|\u5904\u7406|\u4FEE\u590D)","\\ball (?:\\w+ )?(?:done|complete|completed|finished|fixed|reviewed)\\b","\\beverything (?:is |has been )?(?:done|complete|finished)\\b","\\bfully (?:done|complete|completed|reviewed)\\b"].join("|"),"i");function i(u){return d.test(u)}n(i,"m"),o(i,"claimsAllDone");function F(u){return u.filter(e=>e.status!=="done")}n(F,"g"),o(F,"openTodos");function E(u){return A(m(`[\u5B8C\u6210\u6838\u5BF9] \u4F60\u521A\u624D\u8BF4\u5168\u90E8\u5B8C\u6210\uFF0C\u4F46\u5F85\u529E\u91CC\u8FD8\u6709 {count} \u9879\u6CA1\u6709\u6807\u4E3A\u5B8C\u6210\uFF1A
2
+ {items}
3
+ \u4E0D\u8981\u8BF4\u5168\u90E8\u5B8C\u6210\u3002\u9010\u9879\u5BF9\u7167\u7528\u6237\u8981\u6C42\u7684\u6BCF\u4E00\u9879\uFF1A\u5DF2\u5B8C\u6210\u7684\u5199\u51FA\u8BC1\u636E\uFF08\u547D\u4EE4\u8F93\u51FA\u3001\u6D4B\u8BD5\u3001\u6587\u4EF6\uFF09\uFF0C\u6CA1\u505A\u7684\u5199\u201C\u672A\u505A\u201D\uFF0C\u53EA\u505A\u4E86\u4E00\u90E8\u5206\u7684\u5199\u201C\u90E8\u5206\u5B8C\u6210\u201D\u5E76\u8BF4\u660E\u5DEE\u4EC0\u4E48\uFF1B\u7136\u540E\u7528 todo \u628A\u72B6\u6001\u6539\u5BF9\u3002`),{count:u.length,items:u.map(D).join(`
4
+ `)})}n(E,"x"),o(E,"completionCheckText");function a(u){for(let e=u.length-1;e>=0;e--){const t=u[e];if(f(t))return p(t);if(t.role==="user")return""}return""}n(a,"y"),o(a,"lastAssistantText");function C(u,e){let t=!1;u.on("agent_start",async()=>{t=!1}),u.on("agent_before_settle",async s=>{if(t||s.outcome!=="completed"||s.context.pendingMessages.length>0)return;const r=F(e());if(r.length!==0&&i(a(s.context.contextMessages)))return t=!0,{entries:[{type:"custom_message",customType:c,content:E(r),display:!1}],continue:!0}})}n(C,"E"),o(C,"registerCompletionCheck");export{c as COMPLETION_CHECK_MESSAGE,i as claimsAllDone,E as completionCheckText,F as openTodos,C as registerCompletionCheck};
@@ -1,5 +1,5 @@
1
- var c=Object.defineProperty;var l=(u,o)=>c(u,"name",{value:o,configurable:!0});var f=Object.defineProperty,i=l((u,o)=>f(u,"name",{value:o,configurable:!0}),"m");import{t}from"@dalcode/dal-pi-kit";import{registerCheckIn as C}from"./check-in.js";import{registerNotify as A}from"./notify.js";import{registerPlanMode as F}from"./plan-mode.js";import{formatTodo as g,registerTodo as h}from"./todo.js";import{CHECK_IN_AFTER as B,CHECK_IN_MESSAGE as $,checkInText as R,silentToolRounds as S}from"./check-in.js";import{planModeBlockReason as k}from"./plan-mode.js";import{extractPlanSteps as x,isReadOnlyCommand as D,markCompletedSteps as T}from"./plan-utils.js";function m(u){const o=F(u),p=h(u);A(u),C(u),u.registerCommand("todos",{description:t("\u67E5\u770B\u5F53\u524D\u7684\u5F85\u529E\u6E05\u5355\u548C\u8BA1\u5212\u8FDB\u5EA6"),handler:i(async(_,d)=>{const a=[],s=o.executingSteps();if(s.length>0){const r=s.filter(e=>e.completed).length;a.push([`${t("\u6267\u884C\u8BA1\u5212")} ${r}/${s.length}`,...s.map(e=>`${e.completed?"\u2713":"\u25CB"} ${e.step}. ${e.text}`)].join(`
2
- `))}const n=p.todos();if(n.length>0){const r=n.filter(e=>e.status==="done").length;a.push([`${t("\u5F85\u529E")} ${r}/${n.length}`,...n.map(g)].join(`
3
- `))}const E=o.available?t("\u8FD8\u6CA1\u6709\u5F85\u529E\u3002\u53EF\u4EE5\u8BA9 DAL \u5148\u5217\u4E2A\u8BA1\u5212\uFF0C\u6216\u7528 /plan \u8FDB\u5165\u8BA1\u5212\u6A21\u5F0F\u3002"):t("\u8FD8\u6CA1\u6709\u5F85\u529E\u3002\u53EF\u4EE5\u8BA9 DAL \u5148\u5217\u4E2A\u8BA1\u5212\u3002");d.ui.notify(a.length>0?a.join(`
1
+ var d=Object.defineProperty;var l=(e,s)=>d(e,"name",{value:s,configurable:!0});var C=Object.defineProperty,m=l((e,s)=>C(e,"name",{value:s,configurable:!0}),"d");import{t}from"@dalcode/dal-pi-kit";import{registerCheckIn as A}from"./check-in.js";import{registerCompletionCheck as f}from"./completion-check.js";import{registerTaskLedger as g}from"./ledger.js";import{registerNotify as S}from"./notify.js";import{registerPlanMode as h}from"./plan-mode.js";import{formatTodo as F,registerTodo as T}from"./todo.js";import{CHECK_IN_AFTER as _,CHECK_IN_MESSAGE as k,checkInText as B,silentToolRounds as x}from"./check-in.js";import{COMPLETION_CHECK_MESSAGE as D,claimsAllDone as M,completionCheckText as R}from"./completion-check.js";import{TASK_LEDGER_MESSAGE as G,taskLedgerText as I}from"./ledger.js";import{planModeBlockReason as K}from"./plan-mode.js";import{extractPlanSteps as L,isReadOnlyCommand as $,markCompletedSteps as N}from"./plan-utils.js";function E(e){const s=h(e),n=T(e);S(e),A(e),f(e,()=>n.todos()),g(e,()=>n.todos()),e.registerCommand("todos",{description:t("\u67E5\u770B\u5F53\u524D\u7684\u5F85\u529E\u6E05\u5355\u548C\u8BA1\u5212\u8FDB\u5EA6"),handler:m(async(O,p)=>{const a=[],u=s.executingSteps();if(u.length>0){const i=u.filter(o=>o.completed).length;a.push([`${t("\u6267\u884C\u8BA1\u5212")} ${i}/${u.length}`,...u.map(o=>`${o.completed?"\u2713":"\u25CB"} ${o.step}. ${o.text}`)].join(`
2
+ `))}const r=n.todos();if(r.length>0){const i=r.filter(o=>o.status==="done").length;a.push([`${t("\u5F85\u529E")} ${i}/${r.length}`,...r.map(F)].join(`
3
+ `))}const c=s.available?t("\u8FD8\u6CA1\u6709\u5F85\u529E\u3002\u53EF\u4EE5\u8BA9 DAL \u5148\u5217\u4E2A\u8BA1\u5212\uFF0C\u6216\u7528 /plan \u8FDB\u5165\u8BA1\u5212\u6A21\u5F0F\u3002"):t("\u8FD8\u6CA1\u6709\u5F85\u529E\u3002\u53EF\u4EE5\u8BA9 DAL \u5148\u5217\u4E2A\u8BA1\u5212\u3002");p.ui.notify(a.length>0?a.join(`
4
4
 
5
- `):E,"info")},"handler")})}l(m,"u"),i(m,"dalWorkflow");export{B as CHECK_IN_AFTER,$ as CHECK_IN_MESSAGE,R as checkInText,m as default,x as extractPlanSteps,D as isReadOnlyCommand,T as markCompletedSteps,k as planModeBlockReason,S as silentToolRounds};
5
+ `):c,"info")},"handler")})}l(E,"A"),m(E,"dalWorkflow");export{_ as CHECK_IN_AFTER,k as CHECK_IN_MESSAGE,D as COMPLETION_CHECK_MESSAGE,G as TASK_LEDGER_MESSAGE,B as checkInText,M as claimsAllDone,R as completionCheckText,E as default,L as extractPlanSteps,$ as isReadOnlyCommand,N as markCompletedSteps,K as planModeBlockReason,x as silentToolRounds,I as taskLedgerText};
@@ -0,0 +1,3 @@
1
+ var D=Object.defineProperty;var n=(e,u)=>D(e,"name",{value:u,configurable:!0});var y=Object.defineProperty,i=n((e,u)=>y(e,"name",{value:u,configurable:!0}),"i");import{execFileSync as f}from"node:child_process";import{dirname as B,resolve as w}from"node:path";import{t as a}from"@dalcode/dal-pi-kit";import{gitDirOf as C,shellCommandDirectory as k}from"@earendil-works/pi-coding-agent";import{fill as b}from"./shared.js";import{formatTodo as T}from"./todo.js";const h="dal-task-ledger",v=8,L=25;function E(e){const u=[];for(const s of e)if(!(s.type!=="message"||s.message?.role!=="assistant"||!Array.isArray(s.message.content)))for(const t of s.message.content)t.type==="toolCall"&&typeof t.name=="string"&&t.arguments&&typeof t.arguments=="object"&&u.push({name:t.name,arguments:t.arguments});return u}n(E,"x"),i(E,"branchToolCalls");function F(e){const u=[],s=[],t=new Set,o=new Set;for(const r of[...e.calls].reverse()){let c;if(r.name==="write"||r.name==="edit"){const l=r.arguments.path??r.arguments.file_path;if(typeof l=="string"&&l){const m=w(e.cwd,l);o.has(m)||(o.add(m),s.push(m)),c=B(m)}}else(r.name==="bash"||r.name==="powershell")&&typeof r.arguments.command=="string"&&(c=k(r.arguments.command,e.cwd));if(!c||u.length>=v)continue;const g=C(c)?.worktree;g&&!t.has(g)&&(t.add(g),u.push(g))}return{repositories:u,files:s.slice(0,L)}}n(F,"A"),i(F,"workedIn");function p(e){try{const u=f("git",["-C",e,"status","--porcelain=v1","--branch"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:3e3}).split(`
2
+ `),s=(u[0]??"").replace(/^## /,"").trim(),t=u.slice(1).filter(r=>r.trim()).length,o=f("git",["-C",e,"log","-1","--format=%h %s"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:3e3}).trim();return b(a("{worktree} \u2014 \u5206\u652F {branch}\uFF0C\u6700\u65B0\u63D0\u4EA4 {head}\uFF0C\u672A\u63D0\u4EA4\u6539\u52A8 {changed} \u4E2A\u6587\u4EF6"),{worktree:e,branch:s||"?",head:o||"?",changed:t})}catch{return`${e} \u2014 ${a("\u8BFB\u53D6 git \u72B6\u6001\u5931\u8D25")}`}}n(p,"C"),i(p,"describeRepository");function d(e){const{repositories:u,files:s}=F(e);if(e.todos.length===0&&u.length===0&&s.length===0)return;const t=[a("[\u4EFB\u52A1\u53F0\u8D26] \u4E0A\u4E0B\u6587\u521A\u88AB\u538B\u7F29\u3002\u4E0B\u9762\u662F\u538B\u7F29\u65F6\u7684\u51C6\u786E\u72B6\u6001\uFF08\u5F85\u529E\u539F\u6837\u3001git \u72B6\u6001\u662F\u521A\u8BFB\u53D6\u7684\uFF09\uFF0C\u4EE5\u5B83\u4E3A\u51C6\u63A5\u7740\u505A\uFF0C\u4E0D\u9700\u8981\u518D\u8DD1 git status / git log / git worktree list \u6765\u91CD\u65B0\u786E\u8BA4\uFF1A")];return e.todos.length>0&&t.push("",a("\u5F85\u529E\uFF1A"),...e.todos.map(T)),u.length>0&&t.push("",a("\u5DE5\u4F5C\u7684\u4ED3\u5E93\uFF1A"),...u.map(o=>`- ${p(o)}`)),s.length>0&&t.push("",a("\u6539\u8FC7\u7684\u6587\u4EF6\uFF08\u6700\u8FD1\u7684\u5728\u524D\uFF09\uFF1A"),...s.map(o=>`- ${o}`)),t.join(`
3
+ `)}n(d,"E"),i(d,"taskLedgerText");function A(e,u){e.on("session_compact",async(s,t)=>{const o=d({todos:u(),calls:E(t.sessionManager.getBranch()),cwd:t.cwd});o&&e.sendMessage({customType:h,content:o,display:!1},{triggerTurn:!1})})}n(A,"D"),i(A,"registerTaskLedger");export{h as TASK_LEDGER_MESSAGE,p as describeRepository,A as registerTaskLedger,d as taskLedgerText,F as workedIn};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/deepailab",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -20,8 +20,8 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.38",
24
- "@earendil-works/pi-ai": "^1.0.38"
23
+ "@dalcode/dal-pi-kit": "1.0.39",
24
+ "@earendil-works/pi-ai": "^1.0.39"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/chord",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "Application composition runtime for services, replicated state, RPC, and plugins",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-agent-core",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "README.md"
18
18
  ],
19
19
  "dependencies": {
20
- "@earendil-works/pi-ai": "^1.0.38",
20
+ "@earendil-works/pi-ai": "^1.0.39",
21
21
  "typebox": "1.3.27"
22
22
  },
23
23
  "keywords": [