dal-code 1.0.23 → 1.0.24
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.
- package/CHANGELOG.md +8 -0
- package/dist/core/agent-session.js +6 -6
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/permission-surface.js +1 -1
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/tool-execution.js +1 -1
- package/dist/modes/interactive/interactive-mode.js +48 -48
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/commands.js +6 -6
- package/dist/node_modules/@dalcode/dal-router/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/runtime.js +1 -1
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-subagent/src/index.js +14 -8
- package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/chord/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/package.json +5 -5
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-plugins",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
]
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
25
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
26
26
|
"typebox": "1.3.27"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-rewind",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.24"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-router",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
29
|
-
"@dalcode/deepailab": "1.0.
|
|
30
|
-
"@earendil-works/pi-tui": "^1.0.
|
|
28
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
29
|
+
"@dalcode/deepailab": "1.0.24",
|
|
30
|
+
"@earendil-works/pi-tui": "^1.0.24"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@earendil-works/pi-coding-agent": "^1.0.0"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),"info")}i(
|
|
3
|
-
`):` ${u("\u6682\u65E0\u8DEF\u7531\u51B3\u7B56\u3002")}`;
|
|
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}
|
|
4
4
|
${o}
|
|
5
|
-
${s}`,"info");return}case"levels":{const e=
|
|
6
|
-
`),"info");return}case"pool":{if(!a||a.length===0){
|
|
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
7
|
${e.join(`
|
|
8
|
-
`)}`,"info");return}case"auto":{const e=
|
|
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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),!
|
|
3
|
-
`);const
|
|
4
|
-
`),
|
|
1
|
+
var q=Object.defineProperty;var v=(s,m)=>q(s,"name",{value:m,configurable:!0});var Z=Object.defineProperty,c=v((s,m)=>Z(s,"name",{value:m,configurable:!0}),"u");import{t as g}from"@dalcode/dal-pi-kit";import{getSupportedThinkingLevels as ee}from"@earendil-works/pi-ai";import{generateSummaryWithUsage as te}from"@earendil-works/pi-coding-agent";import{fuzzyFilter as se}from"@earendil-works/pi-tui";import{ASSIST_THINKING_LEVELS as oe,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 me,userPinnedModel as pe,userPinnedThinking as fe}from"./config.js";import{jevTimeoutMs as ge,noteJevProxyFailure as ve,resolveJevRoute as K,selectWithJev as ye,warmJevRoute as Ae}from"./jev.js";import{curatePool as he}from"./pool.js";import{autoRouteActive as R,candidates as O,candidatesStale as Fe,clearUnavailable as ke,config as h,configWarning as Ee,mainAutoRouteExplicit as W,markUnavailable as be,persistMainAutoRoute as N,pickCheapestAvailable as Ce,reloadConfig as De,resetThinkingAssist as we,router as Se,setAutoRouteRuntime as z,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 H(s){const m=[];return s.groups.length>0&&m.push(`${g("\u5DE5\u5177 ")}${s.groups.join("/")}`),s.skills.length>0&&m.push(`${g("\u6280\u80FD ")}${s.skills.map(F=>F.name).join("/")}`),s.thinking&&m.push(`${g("\u601D\u8003 ")}${s.thinking}`),m.join(" \xB7 ")}v(H,"Te"),c(H,"describeAssist");const U="deepailab";function B(s){const m=(s.modelRegistry?.getAvailable?.()??[]).filter(o=>o.provider===U&&!x().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})),F=he(m).map(({model:o})=>o).map(o=>{const y=o.cost,E=y&&typeof y.input=="number"&&typeof y.output=="number"?(y.input+y.output)/2:0;return{id:o.id,provider:U,contextWindow:o.contextWindow??128e3,maxTokens:o.maxTokens??8192,reasoning:!!o.reasoning,costPerMtok:E}});F.length!==0&&Re(F)}v(B,"B"),c(B,"buildCandidatesFrom");function G(s){let m=!1,F,o=0;const y=Te({config:h,enabled:P,credentials:c(()=>F,"credentials")});xe(y),s.on("session_start",async(t,e)=>{De(),ke(),F=e.modelRegistry,o=0;const n=Ee();n&&process.stderr.write(`dal-router: ${n}
|
|
2
|
+
`),!W()&&pe(e.cwd)&&z(!1),we(fe(e.cwd)),B(e);const r=h();r.enabled&&r.classifier.enabled&&K(r.classifier,e.modelRegistry).then(i=>i&&Ae(i))});function E(t){R()&&(W()&&h().mainAutoRoute?N(!1):z(!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(E,"h"),c(E,"stopAutoRoute"),s.on("model_select",async(t,e)=>{m||t.source==="restore"||E(e)}),s.registerModelPickerEntry("auto",{getState:c(()=>{const t=h();if(!(!t.enabled||!t.classifier.enabled||(O()?.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:c(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:c((t,e)=>E(e),"onModelChosen")}),s.on("before_agent_start",async(t,e)=>{if(!h().enabled)return;const n=w();!n.pinned&&n.last!==void 0&&s.getThinkingLevel()!==n.last&&T({pinned:!0});try{return await $(t,e)}finally{w().pinned||T({last:s.getThinkingLevel()})}});async function $(t,e){const n=h();let r=R();const i=me(n);if(!r&&!i)return;const a=await K(n.classifier,e.modelRegistry);if(!a)return;let l=[];r&&(B(e),l=(Fe()?[]:O()??[]).filter(p=>!x().has(p.id)),l.length===0&&(r=!1));const d=i?M(t.prompt,e):void 0,A=d&&!ue(d)?ie(d):{},b=Object.keys(A).length>0;if(!r&&!b)return;const Y=Date.now();let C;const _=c(async p=>{try{const f=await ye(t.prompt,a,ge(a,n.classifier.timeoutMs),p,A);return C=f.answers,f}catch(f){throw a.via==="deepailab"&&ve(f),f}},"ask");let u;if(r)u=await Se().route({prompt:t.prompt,candidates:l,currentModelId:e.model?.id,margin:n.affinity.margin,select:{run:c(async(p,f)=>{const{model:j,modelError:X}=await _(f);if(!j)throw X??new Error("jev returned no model");return j},"run")}});else try{await _(void 0)}catch{}const Q=Date.now()-Y;let S=!1;if(u){if(u.modelId&&u.provider&&u.modelId!==e.model?.id){const p=e.modelRegistry?.find(u.provider,u.modelId);if(p){m=!0;let f;try{f=await s.setModel(p)}finally{m=!1}f?S=!0:(be(u.modelId),e.ui.setStatus("factory",void 0))}}S&&e.ui.setStatus?.("factory",`\u2192 ${u.modelId} \xB7 ${u.reason}`)}const V=d&&C?ae(d,C,n.turnAssist.minConfidence):void 0,k=I(V,d,e),D=H(k);if(u&&u.source!=="degraded"){const p=typeof u.confidence=="number"?` \xB7 ${g("\u7F6E\u4FE1\u5EA6 ")}${Math.round(u.confidence*100)}%`:"";e.ui.notify?.(`${u.reason}${p}${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:u?{id:u.modelId,source:u.source,switched:S}:void 0,asked:Object.keys(A),answered:C!==void 0,groups:k.groups,skills:k.skills.map(p=>p.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($,"S"),c($,"routeTurn");function M(t,e){const n=h().turnAssist,r=n.tools?J()?.inactiveGroups()??[]:[];let i=[];if(n.skills)try{i=le()?.search(t,e.cwd,re)??[]}catch{i=[]}let a=[];if(n.thinking&&e.model?.reasoning&&!w().pinned){const l=new Set(ee(e.model));a=oe.filter(d=>l.has(d)),a.length<2&&(a=[])}return{groups:r,skills:i,thinkingLevels:a}}v(M,"_"),c(M,"planAssist");function I(t,e,n){const r=[],i=J();for(const l of t?.groups??[])i&&i.activate(l).length>0&&r.push(l);let a;if(e&&e.thinkingLevels.length>0&&n.model?.reasoning){const l=w(),d=s.getThinkingLevel(),A=l.base??d,b=t?.thinking??A;b!==d&&(s.setThinkingLevel(b),a=s.getThinkingLevel()),T({base:A})}return{groups:r,skills:t?.skills??[],thinking:a}}v(I,"z"),c(I,"applyAssist"),s.on("session_before_compact",async(t,e)=>{const n=h();if(P(n,"compactDefer")&&t.preparation){const a=await de({reason:t.reason,tokens:t.preparation.tokensBefore,contextWindow:e.model?.contextWindow,deferredSoFar:o,maxDefer:n.jevAssist.compactMaxDefer,entries:t.branchEntries,minConfidence:n.jevAssist.minConfidence,ask:c((l,d)=>y.ask("compactDefer",l,d,{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?.(`${g("\u6B63\u5904\u5728\u591A\u6B65\u64CD\u4F5C\u4E2D\uFF0C\u81EA\u52A8\u538B\u7F29\u63A8\u8FDF\u5230\u4E0B\u4E00\u8F6E")} (${o}/${n.jevAssist.compactMaxDefer})`,"info"),{cancel:!0}}if(!n.enabled||!n.auxRoute.compaction)return;const r=Ce(x()),i=t.preparation;if(!(!r||!i))try{const a=e.modelRegistry?.find(r.provider,r.id);if(!a)return;const l=e.modelRegistry?.getApiKeyAndHeaders?await e.modelRegistry.getApiKeyAndHeaders(a):void 0;if(l&&!l.ok)return;const{text:d,usage:A}=await te(i.messagesToSummarize,a,i.settings.reserveTokens,l?.apiKey,l?.headers,t.signal,t.customInstructions,i.previousSummary,"off");return{compaction:{summary:d,firstKeptEntryId:i.firstKeptEntryId,tokensBefore:i.tokensBefore,usage:A}}}catch{return}}),s.on("session_compact",async()=>{o=0}),s.registerCommand("factory",{description:g("\u67E5\u770B/\u914D\u7F6E\u6A21\u578B\u5DE5\u5382\uFF08status | auto on|off | levels | pool\uFF09"),getArgumentCompletions:c(t=>se([{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:c(async(t,e)=>ce(t,e),"handler")})}v(G,"xe"),c(G,"default");export{G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var w=Object.defineProperty;var t=(n,e)=>w(n,"name",{value:e,configurable:!0});var
|
|
1
|
+
var w=Object.defineProperty;var t=(n,e)=>w(n,"name",{value:e,configurable:!0});var y=Object.defineProperty,a=t((n,e)=>y(n,"name",{value:e,configurable:!0}),"e");import{loadFactoryConfig as c,saveFactoryConfig as B}from"./config.js";import{Router as L}from"./router.js";const l=Symbol.for("dalcode.router.runtime");function d(){const n=c();return{config:n.config,configWarning:n.warning,mainAutoRouteExplicit:n.mainAutoRouteExplicit,router:new L,candidates:void 0,unavailable:new Set,autoRouteRuntime:void 0,thinkingBase:void 0,thinkingLast:void 0,thinkingPinned:!1}}t(d,"g"),a(d,"freshState");const f=globalThis;f[l]??=d();const i=f[l];function g(){return i.config}t(g,"k"),a(g,"config");function v(){return i.configWarning}t(v,"v"),a(v,"configWarning");function u(){const{config:n,mainAutoRouteExplicit:e,warning:s}=c();i.config=n,i.configWarning=s,i.mainAutoRouteExplicit=e}t(u,"p"),a(u,"reloadConfig");function h(){return i.mainAutoRouteExplicit}t(h,"h"),a(h,"mainAutoRouteExplicit");function k(){return i.router}t(k,"A"),a(k,"router");function R(){return i.candidates}t(R,"C"),a(R,"candidates");function m(n){i.candidates=n}t(m,"S"),a(m,"setCandidates");function A(){return i.candidates===void 0}t(A,"M"),a(A,"candidatesStale");function b(n){i.unavailable.add(n)}t(b,"y"),a(b,"markUnavailable");function p(){i.unavailable.clear()}t(p,"P"),a(p,"clearUnavailable");function S(n){return i.unavailable.has(n)}t(S,"E"),a(S,"isUnavailable");function C(){return i.autoRouteRuntime??i.config.mainAutoRoute}t(C,"T"),a(C,"autoRouteActive");function P(n){i.autoRouteRuntime=n}t(P,"w"),a(P,"setAutoRouteRuntime");function x(n){B({...i.config,mainAutoRoute:n}),u(),i.autoRouteRuntime=n}t(x,"L"),a(x,"persistMainAutoRoute");function E(){return i.unavailable}t(E,"W"),a(E,"unavailableSet");function U(n){const e=i.candidates?.filter(o=>!n.has(o.id))??[],s=e.filter(o=>o.costPerMtok>0);return[...s.length>0?s:e].sort((o,r)=>o.costPerMtok-r.costPerMtok||o.id.localeCompare(r.id))[0]}t(U,"B"),a(U,"pickCheapestAvailable");function M(n){i.thinkingBase=void 0,i.thinkingLast=void 0,i.thinkingPinned=n}t(M,"F"),a(M,"resetThinkingAssist");function T(){return{base:i.thinkingBase,last:i.thinkingLast,pinned:i.thinkingPinned}}t(T,"U"),a(T,"thinkingAssistState");function W(n){"base"in n&&(i.thinkingBase=n.base),"last"in n&&(i.thinkingLast=n.last),n.pinned!==void 0&&(i.thinkingPinned=n.pinned)}t(W,"I"),a(W,"setThinkingAssistState");export{C as autoRouteActive,R as candidates,A as candidatesStale,p as clearUnavailable,g as config,v as configWarning,S as isUnavailable,h as mainAutoRouteExplicit,b as markUnavailable,x as persistMainAutoRoute,U as pickCheapestAvailable,u as reloadConfig,M as resetThinkingAssist,k as router,P as setAutoRouteRuntime,m as setCandidates,W as setThinkingAssistState,T as thinkingAssistState,E as unavailableSet};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-skills",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
-
"@dalcode/deepailab": "1.0.
|
|
22
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
23
|
+
"@dalcode/deepailab": "1.0.24",
|
|
24
24
|
"typebox": "1.3.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-subagent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
21
|
-
"@dalcode/dal-guard": "1.0.
|
|
22
|
-
"@earendil-works/pi-agent-core": "^1.0.
|
|
23
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
20
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
21
|
+
"@dalcode/dal-guard": "1.0.24",
|
|
22
|
+
"@earendil-works/pi-agent-core": "^1.0.24",
|
|
23
|
+
"@earendil-works/pi-ai": "^1.0.24",
|
|
24
24
|
"typebox": "1.3.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).trim();if(
|
|
1
|
+
var eu=Object.defineProperty;var F=(u,t)=>eu(u,"name",{value:t,configurable:!0});var nu=Object.defineProperty,s=F((u,t)=>nu(u,"name",{value:t,configurable:!0}),"r");import{randomUUID as ou}from"node:crypto";import{mkdirSync as ru,readFileSync as su,writeFileSync as au}from"node:fs";import{join as iu}from"node:path";import{t as n}from"@dalcode/dal-pi-kit";import{routeSubagentModel as Fu}from"@dalcode/dal-router/subagent";import{Type as c}from"typebox";import{formatAgentList as N,loadAgents as U,projectAgentsDir as Eu,READ_ONLY_TOOL_NAMES as L,userAgentsDir as cu}from"./agents.js";import{addUsage as gu,assistantUsage as lu,currentSubagentDepth as pu,emptyUsage as du,findSubagentSessionFile as q,finishedNormally as mu,MAX_SUBAGENT_DEPTH as Bu,pruneSubagentSessions as Du,runResumableSubagent as Au,subagentSessionDir as fu}from"./process-runner.js";import{pickRoleWithJev as Cu}from"./role-pick.js";export*from"./agents.js";export*from"./process-runner.js";export*from"./role-pick.js";const G=['When a request covers several separate items (modules, packages, repositories, documents, questions) and each needs real work (reading code, researching, reviewing, writing, fixing), dispatch one sub-agent per item with the task tool. Example: "review packages A, B and C" is three task calls',"Make those task calls in your first response, all at once: do not list, grep or read the items yourself first, each sub-agent explores its own item. There is no limit on how many","Do the job yourself only when it is a quick lookup or fits in one response of parallel reads or commands","When the sub-agents report back, build on their findings instead of re-checking each part yourself; verify only what the answer depends on and a report leaves in doubt","Sub-agents cannot see this conversation: each task prompt must state the goal, the exact paths or inputs, any constraints, and what to report back","Sub-agents running at the same time share the working tree: give each one different files to change, and let only one run commands that rewrite shared state (installs, builds, git)","Every task result names its sub-agent id. To follow up with the same sub-agent (it keeps its full context), call task with resume set to that id and a prompt holding only the new instruction; to continue one that failed, pass resume alone"],hu=c.Object({agent:c.Optional(c.String({description:n("\u8FD9\u4E00\u6B65\u4F7F\u7528\u7684\u89D2\u8272\u540D\uFF1B\u4E0D\u586B\u5219\u7528\u901A\u7528\u5B50 agent")})),prompt:c.String({description:n("\u8FD9\u4E00\u6B65\u7684\u4EFB\u52A1\u8BF4\u660E\uFF1B\u5176\u4E2D\u7684 {previous} \u4F1A\u66FF\u6362\u6210\u4E0A\u4E00\u6B65\u7684\u8F93\u51FA")})}),$u=c.Object({description:c.String({description:n("\u5B50\u4EFB\u52A1\u7684\u7B80\u77ED\u6807\u9898\uFF083-5 \u4E2A\u5B57\uFF0C\u7528\u4E8E\u5C55\u793A\u8FDB\u5EA6\uFF09")}),prompt:c.Optional(c.String({description:n("\u4EA4\u7ED9\u5B50 agent \u7684\u5B8C\u6574\u4EFB\u52A1\u8BF4\u660E\uFF0C\u9700\u81EA\u5305\u542B\uFF08\u5B50 agent \u770B\u4E0D\u5230\u7236\u5BF9\u8BDD\u5386\u53F2\uFF09")})),resume:c.Optional(c.String({description:n("\u7EE7\u7EED\u4E4B\u524D\u7684\u67D0\u4E2A\u5B50 agent\uFF1A\u586B\u5B83\u7ED3\u679C\u91CC\u7ED9\u51FA\u7684\u5B50 agent ID\u3002\u5B83\u4FDD\u7559\u5B8C\u6574\u4E0A\u4E0B\u6587\uFF0C\u6CBF\u7528\u539F\u6765\u7684\u89D2\u8272\u548C\u5DE5\u5177\uFF1Bprompt \u53EA\u5199\u65B0\u7684\u6307\u793A\uFF0C\u4E0D\u586B\u5219\u8BA9\u5B83\u4ECE\u4E2D\u65AD\u5904\u7EE7\u7EED")})),agent:c.Optional(c.String({description:n("\u4F7F\u7528\u7684\u89D2\u8272\u540D\uFF08\u89C1\u5DE5\u5177\u8BF4\u660E\u91CC\u7684\u89D2\u8272\u5217\u8868\uFF09\uFF1B\u4E0D\u586B\u5219\u7528\u901A\u7528\u5B50 agent")})),readOnly:c.Optional(c.Boolean({description:n("true \u65F6\u5B50 agent \u53EA\u62E5\u6709\u53EA\u8BFB\u5DE5\u5177\uFF08read/grep/find/ls\uFF09\uFF0C\u4E0D\u80FD\u5199\u6587\u4EF6\u6216\u8DD1 bash")})),chain:c.Optional(c.Array(hu,{description:n("\u4E32\u884C\u94FE\uFF1A\u6309\u987A\u5E8F\u9010\u6B65\u8FD0\u884C\uFF0C\u6BCF\u4E00\u6B65\u7684 {previous} \u66FF\u6362\u6210\u4E0A\u4E00\u6B65\u7684\u8F93\u51FA\uFF1B\u4E0E prompt \u4E8C\u9009\u4E00")}))});function w(u){return`${n("[\u5B50 agent ID\uFF1A")}${u}${n("\uFF0C\u53EF\u7528 resume \u53C2\u6570\u7EE7\u7EED]")}`}F(w,"T"),s(w,"subagentIdLine");function y(){return n("\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")}F(y,"D"),s(y,"continuePrompt");const J=s((u,t)=>iu(u,`${t}.meta.json`),"metaPath");function W(u,t){const e=s(()=>new Error(`${n("\u627E\u4E0D\u5230\u5B50 agent\uFF1A")}${t}${n("\uFF08ID \u4E0D\u5B58\u5728\uFF0C\u6216\u4F1A\u8BDD\u5DF2\u8FC7\u671F\u88AB\u6E05\u7406\uFF09")}`),"missing");if(!/^[A-Za-z0-9-]+$/.test(t)||!q(u,t))throw e();try{return JSON.parse(su(J(u,t),"utf8"))}catch{throw e()}}F(W,"le"),s(W,"loadSubagentMeta");function k(u){return`${n("[\u672A\u6307\u5B9A\u89D2\u8272\uFF0C\u5DF2\u81EA\u52A8\u9009\u62E9\uFF1A")}${u.agent.name}${n("\uFF0C\u7F6E\u4FE1\u5EA6 ")}${Math.round(u.confidence*100)}%]`}F(k,"ce"),s(k,"autoRoleNote");function v(u){for(let t=u.length-1;t>=0;t--){const e=u[t];if(e.role!=="assistant")continue;const r=e.content.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
2
|
+
`).trim();if(r)return r;if(e.errorMessage)return`${n("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${e.errorMessage}`}return n("\u5B50 agent \u6CA1\u6709\u4EA7\u751F\u4EFB\u4F55\u8F93\u51FA\u3002")}F(v,"ue"),s(v,"lastAssistantText");const wu=new Set(["write","edit","multi_edit","notebook_edit"]);function x(u){for(const t of["file_path","path","filePath"]){const e=u[t];if(typeof e=="string"&&e.length>0)return e}}F(x,"j"),s(x,"filePathFromInput");function z(u,t){const e=x(t);if(e)return`${u} ${e.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}F(z,"me"),s(z,"describeSubagentStep");function O(u){const t=n("\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")+n("\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}
|
|
4
|
+
${t}`:t}F(O,"fe"),s(O,"buildSubagentSystemPrompt");function H(u,t,e){const r=e?` \xB7 ${e}`:"";return`${u} \u2014 ${t} ${n("\u6B65")}${r}`}F(H,"he"),s(H,"progressLine");function T(u,t,e){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(e.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(`${n("\u627E\u4E0D\u5230\u89D2\u8272\u6307\u5B9A\u7684\u6A21\u578B\uFF1A")}${u}`)}F(T,"ye"),s(T,"resolveAgentModel");async function K(u,t){const e=t.model;if(!e)throw new Error(n("\u6CA1\u6709\u53EF\u7528\u7684\u5F53\u524D\u6A21\u578B\uFF0C\u65E0\u6CD5\u6D3E\u53D1\u5B50 agent\u3002"));let r=e;if(u.agent?.model)r=T(u.agent.model,t.modelRegistry,e);else try{const o=await Fu({taskText:u.prompt,credentials:t.modelRegistry});if(o?.modelId&&o.provider){const g=t.modelRegistry?.find(o.provider,o.modelId);g&&(r=g)}}catch{}const a=u.agent?.tools,i=u.readOnly?(a??L).filter(o=>L.includes(o)):a;return{cwd:t.cwd,model:`${r.provider}/${r.id}`,thinking:u.agent?.thinking??"off",...i?{tools:i}:{},appendSystemPrompt:O(u.agent),...u.agent?{agent:u.agent.name}:{}}}F(K,"we"),s(K,"newSubagentMeta");async function I(u,t,e,r){const a=fu();let i,o;u.resume?(i=u.resume.trim(),o=W(a,i)):(o=await K(u,t),i=ou(),ru(a,{recursive:!0}),Du(a),au(J(a,i),`${JSON.stringify(o)}
|
|
5
|
+
`));const g=[];let d=0;const D=s(E=>new Error(q(a,i)?`${E}
|
|
6
|
+
${w(i)}`:E),"failed"),B=await Au({cwd:o.cwd,prompt:u.prompt||y(),session:{dir:a,id:i},resumePrompt:y(),model:o.model,thinking:o.thinking,tools:o.tools,appendSystemPrompt:o.appendSystemPrompt,signal:t.signal,onResume:s(()=>r?.(`${u.description} \u2014 ${n("\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u7EED\u8DD1")}`),"onResume"),onEvent:s(E=>{const A=lu(E);if(A&&gu(e,A),E.type!=="tool_execution_start")return;const f=String(E.toolName),C=E.args??{};if(d+=1,r?.(H(u.description,d,z(f,C))),wu.has(f)){const h=x(C);h&&g.push(h)}},"onEvent")}).catch(E=>{throw t.signal?.aborted?E:D(`${n("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${E instanceof Error?E.message:String(E)}`)});if(B.idleTimedOut)throw D(n("\u5B50 agent \u8D85\u8FC7 10 \u5206\u949F\u6CA1\u6709\u4EFB\u4F55\u8FDB\u5C55\uFF0C\u5DF2\u505C\u6B62\u3002"));if(!mu(B)){const E=B.messages.at(-1),A=E?.role==="assistant"&&E.errorMessage||B.stderr.trim().split(`
|
|
5
7
|
`).slice(-3).join(`
|
|
6
|
-
`)||`exit ${
|
|
8
|
+
`)||`exit ${B.exitCode}`;throw D(`${n("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${A}`)}return{text:v(B.messages),changedFiles:[...new Set(g)],subagentId:i,...o.agent?{agent:o.agent}:{},autoResumed:B.autoResumed}}F(I,"U"),s(I,"runSubagent");function b(u){return U({cwd:u.cwd,projectTrusted:u.isProjectTrusted()})}F(b,"A"),s(b,"agentsFor");function P(u,t){if(t===void 0||t.trim()==="")return;const e=u.find(r=>r.name===t.trim());if(!e)throw new Error(`${n("\u672A\u77E5\u7684\u5B50 agent \u89D2\u8272\uFF1A")}${t}${n("\u3002\u53EF\u7528\u89D2\u8272\uFF1A")}${u.map(r=>r.name).join(", ")}`);return e}F(P,"C"),s(P,"findAgent");function j(u,t){return u.split("{previous}").join(t)}F(j,"Se"),s(j,"fillPrevious");function X(u){return n("\u6D3E\u53D1\u4E00\u4E2A\u72EC\u7ACB\u5B50 agent \u53BB\u5B8C\u6210\u6307\u5B9A\u5B50\u4EFB\u52A1\uFF0C\u53EF\u5728\u540C\u4E00\u8F6E\u591A\u6B21\u8C03\u7528\u4EE5\u5E76\u884C\u5904\u7406\u4E92\u4E0D\u4F9D\u8D56\u7684\u5B50\u4EFB\u52A1")+n("\uFF1B\u540C\u4E00\u8F6E\u6D3E\u51FA\u7684\u5B50 agent \u5168\u90E8\u540C\u65F6\u8FD0\u884C\uFF0C\u6570\u91CF\u4E0D\u8BBE\u4E0A\u9650\u3002\u5B50 agent \u9ED8\u8BA4\u4F7F\u7528\u5F53\u524D\u6A21\u578B\u548C\u5B8C\u6574\u5DE5\u5177\u96C6\uFF0C")+n("\u5176\u6BCF\u6B21\u5DE5\u5177\u8C03\u7528\u540C\u6837\u7ECF\u8FC7 dal-guard \u5BA1\u6279\uFF08\u65E0 UI \u573A\u666F\u4E00\u5F8B\u62D2\u7EDD\u98CE\u9669\u64CD\u4F5C\uFF09\u3002\u5B50 agent \u770B\u4E0D\u5230\u7236\u5BF9\u8BDD\u5386\u53F2\uFF0C")+n("prompt \u5FC5\u987B\u81EA\u5305\u542B\u6240\u6709\u5FC5\u8981\u4E0A\u4E0B\u6587\u3002")+`
|
|
7
9
|
|
|
8
10
|
`+n("\u53EF\u7528\u89D2\u8272\uFF08agent \u53C2\u6570\uFF09\uFF1A\u4FA6\u5BDF/\u6478\u5E95\u7528\u53EA\u8BFB\u89D2\u8272\uFF0C\u843D\u5730\u6539\u52A8\u7528\u53EF\u5199\u89D2\u8272\uFF0C\u6539\u5B8C\u540E\u53EF\u6D3E\u5BA1\u67E5\u89D2\u8272\u590D\u6838\uFF1A")+`
|
|
9
|
-
`+
|
|
11
|
+
`+N(u)+`
|
|
10
12
|
|
|
11
|
-
`+n("chain \u53C2\u6570\u6309\u987A\u5E8F\u4E32\u884C\u8FD0\u884C\u591A\u4E2A\u6B65\u9AA4\uFF08\u4F8B\u5982 scout \u2192 worker \u2192 reviewer\uFF09\uFF0C\u540E\u4E00\u6B65 prompt \u91CC\u7684 {previous} \u4F1A\u66FF\u6362\u6210\u524D\u4E00\u6B65\u7684\u8F93\u51FA\u3002")}
|
|
12
|
-
${
|
|
13
|
-
|
|
13
|
+
`+n("chain \u53C2\u6570\u6309\u987A\u5E8F\u4E32\u884C\u8FD0\u884C\u591A\u4E2A\u6B65\u9AA4\uFF08\u4F8B\u5982 scout \u2192 worker \u2192 reviewer\uFF09\uFF0C\u540E\u4E00\u6B65 prompt \u91CC\u7684 {previous} \u4F1A\u66FF\u6362\u6210\u524D\u4E00\u6B65\u7684\u8F93\u51FA\u3002")}F(X,"be"),s(X,"taskToolDescription");const R=new Map,Y=s(u=>u.totalTokens>0||u.cost.total>0,"hasUsage");function M(u,t){u.registerTool({name:"task",label:n("\u6D3E\u53D1\u5B50\u4EFB\u52A1"),description:X(t),promptSnippet:n("task - \u6D3E\u53D1\u5B50 agent \u5E76\u884C\u5904\u7406\u72EC\u7ACB\u5B50\u4EFB\u52A1"),promptGuidelines:G,parameters:$u,executionMode:"parallel",execute:s(async(e,r,a,i,o)=>{const g=du();try{return await Z(r,o,g,d=>{i?.({content:[{type:"text",text:d}],details:{description:r.description}})})}catch(d){throw Y(g)&&R.set(e,g),d}},"execute")})}F(M,"N"),s(M,"registerTaskTool");async function Z(u,t,e,r){const{agents:a}=b(t),i=Array.isArray(u.chain)&&u.chain.length>0,o=typeof u.prompt=="string"&&u.prompt.trim()!=="",g=u.resume?.trim();if(g&&i)throw new Error(n("resume \u4E0D\u80FD\u548C chain \u4E00\u8D77\u4F7F\u7528\u3002"));if(!g&&i===o)throw new Error(n("task \u9700\u8981\u4E14\u53EA\u80FD\u63D0\u4F9B prompt \u6216 chain \u5176\u4E2D\u4E4B\u4E00\u3002"));const d=s(()=>Y(e)?{usage:e}:{},"usage");if(!i){let p=g?void 0:P(a,u.agent);const m=!g&&p===void 0?await Cu(u.prompt??"",a,{credentials:t.modelRegistry}):void 0;m&&(p=m.agent);const l=await I({description:u.description,prompt:o?u.prompt??"":"",readOnly:u.readOnly===!0,agent:p,resume:g},t,e,r);return{content:[{type:"text",text:`${m?`${k(m)}
|
|
14
|
+
${l.text}`:l.text}
|
|
15
|
+
|
|
16
|
+
${w(l.subagentId)}`}],details:{description:u.description,...l.agent?{agent:l.agent}:{},subagentId:l.subagentId,...l.autoResumed?{autoResumed:!0}:{},...d(),...m?{autoAgent:{name:m.agent.name,confidence:m.confidence}}:{},...l.changedFiles.length>0?{changedFiles:l.changedFiles}:{}},...d()}}const D=u.chain??[],B=D.map(p=>P(a,p.agent??u.agent));let E="";const A=[],f=[];let C=!1;for(const[p,m]of D.entries()){const l=B[p],V=`${u.description} [${p+1}/${D.length}${l?` ${l.name}`:""}]`;try{const{text:$,changedFiles:S,subagentId:uu,autoResumed:tu}=await I({description:V,prompt:j(m.prompt,E),readOnly:u.readOnly===!0,agent:l},t,e,r);E=$,A.push(...S),f.push(uu),C||=tu}catch($){const S=$ instanceof Error?$.message:String($);throw new Error(`${n("\u4E32\u884C\u94FE\u5728\u7B2C")} ${p+1} ${n("\u6B65\u4E2D\u65AD\uFF1A")}${S}`)}}const h=[...new Set(A)],_=f[f.length-1]??"";return{content:[{type:"text",text:`${E}
|
|
17
|
+
|
|
18
|
+
${w(_)}`}],details:{description:u.description,subagentId:_,...C?{autoResumed:!0}:{},...d(),chain:B.map((p,m)=>({...p?{agent:p.name}:{},subagentId:f[m]})),...h.length>0?{changedFiles:h}:{}},...d()}}F(Z,"$e"),s(Z,"executeTask");function Q(u){pu()>=Bu||(M(u,U({cwd:process.cwd(),projectTrusted:!1}).agents),u.on("session_start",async(t,e)=>{M(u,b(e).agents)}),u.on("tool_result",t=>{const e=t.toolName==="task"&&t.isError?R.get(t.toolCallId):void 0;if(R.delete(t.toolCallId),!e)return;const r=t.input.description??"";return{usage:e,details:{description:r,usage:e}}}),u.registerCommand("agents",{description:n("\u5217\u51FA\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\u53CA\u5176\u6765\u6E90"),handler:s(async(t,e)=>{const{agents:r,diagnostics:a}=b(e),i=[n("\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\uFF1A"),N(r,!0),"",`${n("\u7528\u6237\u89D2\u8272\u76EE\u5F55\uFF1A")}${cu()}`,`${n("\u9879\u76EE\u89D2\u8272\u76EE\u5F55\uFF1A")}${Eu(e.cwd)}${e.isProjectTrusted()?"":n("\uFF08\u9879\u76EE\u672A\u4FE1\u4EFB\uFF0C\u672A\u8BFB\u53D6\uFF09")}`];a.length>0&&i.push("",n("\u4EE5\u4E0B\u89D2\u8272\u6587\u4EF6\u6709\u95EE\u9898\uFF1A"),...a.map(o=>`- ${o}`)),e.ui.notify(i.join(`
|
|
19
|
+
`),a.length>0?"warning":"info")},"handler")}))}F(Q,"ke"),s(Q,"default");export{G as TASK_TOOL_GUIDELINES,k as autoRoleNote,O as buildSubagentSystemPrompt,y as continuePrompt,Q as default,j as fillPrevious,v as lastAssistantText,T as resolveAgentModel,w as subagentIdLine};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);for(;
|
|
3
|
-
`)}),
|
|
1
|
+
var j=Object.defineProperty;var r=(e,t)=>j(e,"name",{value:t,configurable:!0});var B=Object.defineProperty,n=r((e,t)=>B(e,"name",{value:t,configurable:!0}),"s");import{spawn as C}from"node:child_process";import{existsSync as F,readdirSync as U,rmSync as H,statSync as X}from"node:fs";import{join as h}from"node:path";import{getAgentDir as V,getPackageDir as $}from"@earendil-works/pi-coding-agent";const J=2,E="DAL_SUBAGENT_DEPTH",O="DAL_SUBAGENT_COMMAND";function T(e=process.env){const t=Number.parseInt(e[E]??"0",10);return Number.isFinite(t)&&t>0?t:0}r(T,"k"),n(T,"currentSubagentDepth");const w=600*1e3;function v(e=process.env){const t=e[O];if(t){const[l,...g]=JSON.parse(t);return{command:l,args:g,env:{}}}if(process.versions.bun)return{command:process.execPath,args:[],env:{}};const a=$(),i=h(a,"dist","cli.js"),c=F(i)?i:h(a,"src","cli.ts"),o=process.versions.electron?{ELECTRON_RUN_AS_NODE:"1"}:{};return{command:process.execPath,args:[...process.execArgv,c],env:o}}r(v,"D"),n(v,"resolveDalCommand");function W(){return h(V(),"subagent-sessions")}r(W,"F"),n(W,"subagentSessionDir");const M=10080*60*1e3,P=200;function _(e,t){const a=`_${t}.jsonl`;try{const i=U(e).find(c=>c.endsWith(a));return i?h(e,i):void 0}catch{return}}r(_,"G"),n(_,"findSubagentSessionFile");function G(e,t=Date.now(),a=M,i=P){let c;try{c=U(e)}catch{return}const o=n(s=>{try{return X(h(e,s)).mtimeMs}catch{return t}},"mtime"),l=n(s=>H(h(e,s),{force:!0}),"remove"),g=c.filter(s=>s.endsWith(".jsonl")).map(s=>({name:s,id:s.slice(s.indexOf("_")+1,-6),mtime:o(s)})).sort((s,d)=>d.mtime-s.mtime),u=new Set;for(const[s,d]of g.entries()){if(s<i&&t-d.mtime<=a){u.add(d.id);continue}l(d.name),l(`${d.id}.meta.json`)}for(const s of c){if(!s.endsWith(".meta.json"))continue;const d=s.slice(0,-10);!u.has(d)&&t-o(s)>a&&l(s)}}r(G,"V"),n(G,"pruneSubagentSessions");function N(e){const t=["-p","--mode","json"];return e.session?t.push("--session-dir",e.session.dir,"--session-id",e.session.id):t.push("--no-session"),e.model&&t.push("--model",e.model),e.thinking&&t.push("--thinking",e.thinking),e.tools&&t.push("--tools",e.tools.join(",")),e.appendSystemPrompt&&t.push("--append-system-prompt",e.appendSystemPrompt),t}r(N,"L"),n(N,"buildSubagentArgs");function b(e){const t=v(),a=T()+1;return new Promise((i,c)=>{if(e.signal?.aborted){c(new Error("aborted"));return}const o=C(t.command,[...t.args,...N(e)],{cwd:e.cwd,env:{...process.env,...t.env,[E]:String(a)},stdio:["pipe","pipe","pipe"],windowsHide:!0}),l=[];let g="",u="",s,d=!1;const f=n(()=>{o.kill("SIGTERM"),s=setTimeout(()=>o.kill("SIGKILL"),5e3)},"stop"),y=e.idleTimeoutMs??w,D=n(()=>{d=!0,f()},"onIdle");let S=setTimeout(D,y);const R=n(m=>{if(!m.trim().startsWith("{"))return;let p;try{p=JSON.parse(m)}catch{return}p.type==="message_end"&&p.message&&l.push(p.message),e.onEvent?.(p)},"handleLine");o.stdout.setEncoding("utf8"),o.stdout.on("data",m=>{clearTimeout(S),S=setTimeout(D,y),u+=m;let p=u.indexOf(`
|
|
2
|
+
`);for(;p!==-1;)R(u.slice(0,p)),u=u.slice(p+1),p=u.indexOf(`
|
|
3
|
+
`)}),o.stderr.setEncoding("utf8"),o.stderr.on("data",m=>{g=(g+m).slice(-4e3)}),e.signal?.addEventListener("abort",f,{once:!0}),o.on("error",m=>{clearTimeout(S),e.signal?.removeEventListener("abort",f),c(m)}),o.on("close",m=>{clearTimeout(S),s&&clearTimeout(s),e.signal?.removeEventListener("abort",f),u&&R(u),e.signal?.aborted?c(new Error("aborted")):i({messages:l,exitCode:m,stderr:g,idleTimedOut:d})}),o.stdin.on("error",()=>{}),o.stdin.end(e.prompt)})}r(b,"T"),n(b,"runSubagentProcess");function L(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}r(L,"$"),n(L,"emptyUsage");function k(e,t){e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.totalTokens+=t.totalTokens,t.cacheWrite1h!==void 0&&(e.cacheWrite1h=(e.cacheWrite1h??0)+t.cacheWrite1h),t.reasoning!==void 0&&(e.reasoning=(e.reasoning??0)+t.reasoning),e.cost.input+=t.cost.input,e.cost.output+=t.cost.output,e.cost.cacheRead+=t.cost.cacheRead,e.cost.cacheWrite+=t.cost.cacheWrite,e.cost.total+=t.cost.total}r(k,"K"),n(k,"addUsage");function x(e){if(e.type!=="message_end")return;const t=e.message;return t?.role==="assistant"&&t.usage?.cost?t.usage:void 0}r(x,"q"),n(x,"assistantUsage");function A(e){if(e.idleTimedOut)return!1;const t=e.messages.at(-1);return t?.role==="assistant"&&t.stopReason!=="error"&&t.stopReason!=="aborted"&&t.stopReason!=="toolUse"}r(A,"I"),n(A,"finishedNormally");async function I(e){let t,a;try{t=await b(e)}catch(i){if(e.signal?.aborted)throw i;a=i}if(t&&A(t))return{...t,autoResumed:!1};if(!_(e.session.dir,e.session.id)){if(t)return{...t,autoResumed:!1};throw a}return e.onResume?.(),{...await b({...e,prompt:e.resumePrompt}),autoResumed:!0}}r(I,"z"),n(I,"runResumableSubagent");export{J as MAX_SUBAGENT_DEPTH,O as SUBAGENT_COMMAND_ENV,E as SUBAGENT_DEPTH_ENV,w as SUBAGENT_IDLE_TIMEOUT_MS,M as SUBAGENT_SESSION_MAX_AGE_MS,P as SUBAGENT_SESSION_MAX_COUNT,k as addUsage,x as assistantUsage,N as buildSubagentArgs,T as currentSubagentDepth,L as emptyUsage,_ as findSubagentSessionFile,A as finishedNormally,G as pruneSubagentSessions,v as resolveDalCommand,I as runResumableSubagent,b as runSubagentProcess,W as subagentSessionDir};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-telemetry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.24"
|
|
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-tool-catalog",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
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.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
27
|
-
"@dalcode/deepailab": "1.0.
|
|
26
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
27
|
+
"@dalcode/deepailab": "1.0.24",
|
|
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.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
20
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
21
21
|
"typebox": "1.3.27"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/deepailab",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
24
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.24",
|
|
24
|
+
"@earendil-works/pi-ai": "^1.0.24"
|
|
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/pi-agent-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"README.md"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@earendil-works/chord": "^1.0.
|
|
49
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
50
|
-
"@earendil-works/pi-telemetry": "^1.0.
|
|
48
|
+
"@earendil-works/chord": "^1.0.24",
|
|
49
|
+
"@earendil-works/pi-ai": "^1.0.24",
|
|
50
|
+
"@earendil-works/pi-telemetry": "^1.0.24",
|
|
51
51
|
"diff": "8.0.4",
|
|
52
52
|
"ignore": "7.0.8",
|
|
53
53
|
"typebox": "1.3.27",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":3,"generatedAt":"2026-09-
|
|
1
|
+
{"schemaVersion":3,"generatedAt":"2026-09-27T19:01:09.932Z","structureHash":"32bbffe1ea79587d61c7a9d8f364ac0a4b861436d06d9e7a263435e7743f63f2","files":{"amazon-bedrock.json":"a74475a5009f9e17aac850e49aaac66f470217fc4774ff5de6240b0926a94b20","ant-ling.json":"335137fb6dc428544ca56ab8fd52b300e7d0dcf97869fa10c1022669da8bfdeb","anthropic.json":"474a010cd96c759d60419a6ba745747d9a87f172276dc85b7568da9d072b4e75","azure-openai-responses.json":"c351c6af1882660ffa8a8598594b86671b45817106e45ac920535aaeac59fc96","baseten.json":"60001c0aa6c7c9112b00c2ed6f646b58baed196782fe4db6028074e9ccedc5e5","cerebras.json":"a7966788e6f2d64e0606a1d896f0aa65014a324e246d60b8bae9856700f13004","cloudflare-ai-gateway.json":"93c93baa234488fe8313216fbe70a9271da14a0e4f02bfe8f2798a0165125b0c","cloudflare-workers-ai.json":"486ba93373c1d0eba3b9cdfd6d6c2c70bd4bcf745f66b2bc467c969acdd61a96","deepseek.json":"549a7ddbdcfd4c59272f1ea9c7d6d9a70bbbfccad3df3a75fb16d6918ac54d0d","fireworks.json":"debcffe7bf7132cc01ac54c888817a98a8476e411229d55f812036928fa628ba","github-copilot.json":"b56f0748a4641b042814ffaed5a1e844cf9e4e581173e03b5e2eae39c62678dd","google-vertex.json":"3ec3898410d8759cf28eb04366d07800ccb1f92f4e8f8a4be9a0d6a3b527f553","google.json":"638cd3c9ab2cafe989d707e67c9f835f8a329ef698f9b3ef2fb04248aeea7136","groq.json":"f1d03e0d6cdaef643f8d3a854d7caba784b2a820619a928c4711d08b6688de41","huggingface.json":"2afa4769c606655cf6c36df332ad41a41ec43a19cf9bae4e337243b54f5c9349","kimi-coding.json":"9884f065fe5a0e68e3538590c28019476077712f0542198eef6fdb53b8edd2ee","meta.json":"1b650998c0f9b404246cde1d353105e6d825d8a7292d8f8c43e85dd3402dc130","minimax-cn.json":"f2cceac560f34245536aeb9c77a66ec4a6a3f275c6d348d87ae31916576df6e4","minimax.json":"1fe8b49f3035342d81fda9afaa1b84b21e7b005f97d4678e70312ecdd93cb489","mistral.json":"df70e9066f39ffd93734895530653d642e9491bf66dd4b6ab1138f0cb400ae65","moonshotai-cn.json":"ed98fdfb041c7a8256b1f084445ad1ccfd1c23cd5d26d700b458ef425a4833da","moonshotai.json":"24ad5d44e4db62b35471ef725753fa7b5b4dd5a07ac9160195b5fe486cd3b378","nvidia.json":"79452d78d25b41c9b1f16d645c9a6839c4721c4a29dd287513db796ad9763c84","openai-codex.json":"4bb30a26d1b40e1f67c9f24891fca0ce25b030bc4cbbb529be78608cd4466fdf","openai.json":"3c52c8587e7e4a1829ed98ec6e0e3d7bbb2baf47e8618556ed1e95a9c0362835","opencode-go.json":"a071959895c82e7e639f6b472bc47ab03a4f03d812369e70235b0ee7a349b79a","opencode.json":"a71ee92724cbab72cf33a8421bc2aa75d81f74d9037858eb0811409f6055160a","openrouter.json":"4131cfb767c7faa0c8a737dffa76b1f6a43261637a2625f3778a2df5f6a5a0b9","qwen-token-plan-cn.json":"1bb24ea68feaec83612940e7413bf953d1664a86a521c90750f4c93dd572d8ae","qwen-token-plan-individual.json":"895804dbf586401e61c372e3edef8ee2530878e36a942e12fccf2469167921de","qwen-token-plan.json":"b626dba49c60a28ac9e6a128fa3e5bde97b43c865c4314e64b9b2191eb8afefa","radius.json":"c9449fedcda937626ffd80628e00e1289a2d012e54be9fd0e638749c3d12b991","together.json":"a80433b772264b4b930bc69e4113f694ca1cf08a2574fe60056958ac65d1c40d","vercel-ai-gateway.json":"59db22d42dab1cc59c0aa58de7174616db1ca56b05f454dfbbd3e96c40ac0201","xai.json":"4798b621df20e84db3a48a629ef8054723ebcc8b24314064f6437eb05036405f","xiaomi-token-plan-ams.json":"754a2b6fb127091f569eabbbc84c50862b319bf4ffad434fd0b2f86fd36007f5","xiaomi-token-plan-cn.json":"bebafd818b8cc9452405b16599bb3b4e74dc7bd629ad5847ea5c6ce7000706f3","xiaomi-token-plan-sgp.json":"edec21ee8d3d8839c96013b94bfa6a55616fb7fd62290fa99db2f3eec61713af","xiaomi.json":"640f758f527639c6233d89e548797ffe8d97acc85d5d7dfd647dbb0d42efe146","zai-coding-cn.json":"761cd1c3480519c3be2eaed82cff821993f652620d0787d0e38d7bf18ce2ba41","zai.json":"8f5776b5eaba607d898fb26015d46d040a68217e85860173af3bfbab5f8a9eb1"}}
|