dal-code 1.0.32 → 1.0.33
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 +6 -0
- package/dist/core/sdk.js +1 -1
- package/dist/core/system-prompt.d.ts +3 -0
- package/dist/core/system-prompt.js +19 -13
- package/dist/core/tools/bash.d.ts +1 -1
- package/dist/core/tools/bash.js +15 -15
- package/dist/core/tools/powershell.d.ts +1 -1
- package/dist/core/tools/powershell.js +1 -1
- package/dist/modes/interactive/interactive-mode.js +13 -13
- 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-interactive/package.json +2 -2
- 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 +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +1 -1
- package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- 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-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 -13
- 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-terminal/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/@dalcode/deepailab/src/index.js +3 -3
- package/dist/node_modules/@earendil-works/chord/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- 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/dist/utils/retry.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +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-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/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.33",
|
|
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.33",
|
|
26
26
|
"typebox": "1.3.27"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-review",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
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.
|
|
23
|
-
"@dalcode/dal-subagent": "1.0.
|
|
22
|
+
"@dalcode/dal-pi-kit": "1.0.33",
|
|
23
|
+
"@dalcode/dal-subagent": "1.0.33",
|
|
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.
|
|
3
|
+
"version": "1.0.33",
|
|
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.33"
|
|
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.33",
|
|
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.33",
|
|
29
|
+
"@dalcode/deepailab": "1.0.33",
|
|
30
|
+
"@earendil-works/pi-tui": "^1.0.33"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@earendil-works/pi-coding-agent": "^1.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-skills",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
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
|
-
"@dalcode/deepailab": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.33",
|
|
24
|
+
"@dalcode/deepailab": "1.0.33",
|
|
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.
|
|
3
|
+
"version": "1.0.33",
|
|
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.33",
|
|
21
|
+
"@dalcode/dal-guard": "1.0.33",
|
|
22
|
+
"@earendil-works/pi-agent-core": "^1.0.33",
|
|
23
|
+
"@earendil-works/pi-ai": "^1.0.33",
|
|
24
24
|
"typebox": "1.3.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).trim();if(
|
|
1
|
+
var ou=Object.defineProperty;var F=(u,t)=>ou(u,"name",{value:t,configurable:!0});var iu=Object.defineProperty,o=F((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 Eu}from"node:fs";import{join as lu}from"node:path";import{t as e}from"@dalcode/dal-pi-kit";import{routeSubagentModel as gu}from"@dalcode/dal-router/subagent";import{Type as g}from"typebox";import{formatAgentList as q,loadAgents as G,projectAgentsDir as du,READ_ONLY_TOOL_NAMES as J,userAgentsDir as pu}from"./agents.js";import{addUsage as mu,assistantUsage as Du,currentSubagentDepth as Bu,emptyUsage as Au,endedOnAccountLimit as fu,findSubagentSessionFile as W,finishedNormally as Cu,MAX_SUBAGENT_DEPTH as hu,pruneSubagentSessions as wu,runResumableSubagent as $u,subagentSessionDir as yu}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 z=['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"],Su=g.Object({agent:g.Optional(g.String({description:e("\u8FD9\u4E00\u6B65\u4F7F\u7528\u7684\u89D2\u8272\u540D\uFF1B\u4E0D\u586B\u5219\u7528\u901A\u7528\u5B50 agent")})),prompt:g.String({description:e("\u8FD9\u4E00\u6B65\u7684\u4EFB\u52A1\u8BF4\u660E\uFF1B\u5176\u4E2D\u7684 {previous} \u4F1A\u66FF\u6362\u6210\u4E0A\u4E00\u6B65\u7684\u8F93\u51FA")})}),vu=g.Object({description:g.String({description:e("\u5B50\u4EFB\u52A1\u7684\u7B80\u77ED\u6807\u9898\uFF083-5 \u4E2A\u5B57\uFF0C\u7528\u4E8E\u5C55\u793A\u8FDB\u5EA6\uFF09")}),prompt:g.Optional(g.String({description:e("\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:g.Optional(g.String({description:e("\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:g.Optional(g.String({description:e("\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:g.Optional(g.Boolean({description:e("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:g.Optional(g.Array(Su,{description:e("\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 b(u){return`${e("[\u5B50 agent ID\uFF1A")}${u}${e("\uFF0C\u53EF\u7528 resume \u53C2\u6570\u7EE7\u7EED]")}`}F(b,"I"),o(b,"subagentIdLine");function v(){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")}F(v,"C"),o(v,"continuePrompt");const H=o((u,t)=>lu(u,`${t}.meta.json`),"metaPath");function K(u,t){const n=o(()=>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)||!W(u,t))throw n();try{return JSON.parse(cu(H(u,t),"utf8"))}catch{throw n()}}F(K,"fe"),o(K,"loadSubagentMeta");function T(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)}%]`}F(T,"me"),o(T,"autoRoleNote");function I(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")}F(I,"he"),o(I,"lastAssistantText");const ku=new Set(["write","edit","multi_edit","notebook_edit"]);function O(u){for(const t of["file_path","path","filePath"]){const n=u[t];if(typeof n=="string"&&n.length>0)return n}}F(O,"F"),o(O,"filePathFromInput");function X(u,t){const n=O(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 s=i.replace(/\s+/g," ").trim();return`${u} ${s.length>40?`${s.slice(0,39)}\u2026`:s}`}}return u}F(X,"we"),o(X,"describeSubagentStep");function P(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
|
-
${
|
|
5
|
-
`));const
|
|
6
|
-
|
|
4
|
+
${t}`:t}F(P,"be"),o(P,"buildSubagentSystemPrompt");function Y(u,t,n){const r=n?` \xB7 ${n}`:"";return`${u} \u2014 ${t} ${e("\u6B65")}${r}`}F(Y,"Se"),o(Y,"progressLine");function j(u,t,n){const r=u.indexOf("/");if(r>0){const s=t.find(u.slice(0,r),u.slice(r+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}`)}F(j,"$e"),o(j,"resolveAgentModel");async function Z(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 s=await gu({taskText:u.prompt,credentials:t.modelRegistry});if(s?.modelId&&s.provider){const E=t.modelRegistry?.find(s.provider,s.modelId);E&&(r=E)}}catch{}const a=u.agent?.tools,i=u.readOnly?(a??J).filter(s=>J.includes(s)):a;return{cwd:t.cwd,model:`${r.provider}/${r.id}`,thinking:u.agent?.thinking??"off",...i?{tools:i}:{},appendSystemPrompt:P(u.agent),...u.agent?{agent:u.agent.name}:{}}}F(Z,"ke"),o(Z,"newSubagentMeta");class Q{static{F(this,"Ae")}static{o(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 S(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")}`}F(S,"M"),o(S,"accountLimitMessage");async function M(u,t,n,r,a,i){if(i?.reason!==void 0)throw new Error(S(i.reason));const s=yu();let E,l;u.resume?(E=u.resume.trim(),l=K(s,E)):(l=await Z(u,t),E=au(),Fu(s,{recursive:!0}),wu(s),Eu(H(s,E),`${JSON.stringify(l)}
|
|
6
|
+
`));const p=[];let C=0;const f=o(c=>new Error(W(s,E)?`${c}
|
|
7
|
+
${b(E)}`:c),"failed"),m=await $u({cwd:l.cwd,prompt:u.prompt||v(),session:{dir:s,id:E},resumePrompt:v(),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:E,label:u.description},onResume:o(()=>r?.(`${u.description} \u2014 ${e("\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u7EED\u8DD1")}`),"onResume"),onEvent:o(c=>{const A=Du(c);if(A&&mu(n,A),c.type!=="tool_execution_start")return;const h=String(c.toolName),w=c.args??{};if(C+=1,r?.(Y(u.description,C,X(h,w))),ku.has(h)){const $=O(w);$&&p.push($)}},"onEvent")}).catch(c=>{throw t.signal?.aborted?c:i?.reason!==void 0?f(S(i.reason)):f(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${c instanceof Error?c.message:String(c)}`)});if(m.idleTimedOut)throw f(e("\u5B50 agent \u8D85\u8FC7 10 \u5206\u949F\u6CA1\u6709\u4EFB\u4F55\u8FDB\u5C55\uFF0C\u5DF2\u505C\u6B62\u3002"));if(fu(m)){const c=m.messages.at(-1),A=c?.role==="assistant"&&c.errorMessage||"account limit";throw i?.trip(A),f(S(A))}if(!Cu(m)){const c=m.messages.at(-1),A=c?.role==="assistant"&&c.errorMessage||m.stderr.trim().split(`
|
|
7
8
|
`).slice(-3).join(`
|
|
8
|
-
`)||`exit ${
|
|
9
|
+
`)||`exit ${m.exitCode}`;throw f(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${A}`)}return{text:I(m.messages),changedFiles:[...new Set(p)],subagentId:E,...l.agent?{agent:l.agent}:{},autoResumed:m.autoResumed}}F(M,"L"),o(M,"runSubagent");function k(u){return G({cwd:u.cwd,projectTrusted:u.isProjectTrusted()})}F(k,"E"),o(k,"agentsFor");function R(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}F(R,"N"),o(R,"findAgent");function _(u,t){return u.split("{previous}").join(t)}F(_,"xe"),o(_,"fillPrevious");function V(u){return e("\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")+e("\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")+e("\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")+e("prompt \u5FC5\u987B\u81EA\u5305\u542B\u6240\u6709\u5FC5\u8981\u4E0A\u4E0B\u6587\u3002")+`
|
|
9
10
|
|
|
10
|
-
`+
|
|
11
|
-
`+
|
|
11
|
+
`+e("\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")+`
|
|
12
|
+
`+q(u)+`
|
|
12
13
|
|
|
13
|
-
`+
|
|
14
|
-
${
|
|
14
|
+
`+e("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(V,"Te"),o(V,"taskToolDescription");const L=new Map,uu=o(u=>u.totalTokens>0||u.cost.total>0,"hasUsage");function N(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:z,parameters:vu,executionMode:"parallel",execute:o(async(r,a,i,s,E)=>{const l=Au();try{return await tu(a,E,l,p=>{s?.({content:[{type:"text",text:p}],details:{description:a.description}})},u.getToolDenylist?.(),n)}catch(p){throw uu(l)&&L.set(r,l),p}},"execute")})}F(N,"G"),o(N,"registerTaskTool");async function tu(u,t,n,r,a,i){const{agents:s}=k(t),E=Array.isArray(u.chain)&&u.chain.length>0,l=typeof u.prompt=="string"&&u.prompt.trim()!=="",p=u.resume?.trim();if(p&&E)throw new Error(e("resume \u4E0D\u80FD\u548C chain \u4E00\u8D77\u4F7F\u7528\u3002"));if(!p&&E===l)throw new Error(e("task \u9700\u8981\u4E14\u53EA\u80FD\u63D0\u4F9B prompt \u6216 chain \u5176\u4E2D\u4E4B\u4E00\u3002"));const C=o(()=>uu(n)?{usage:n}:{},"usage");if(!E){let D=p?void 0:R(s,u.agent);const B=!p&&D===void 0?await bu(u.prompt??"",s,{credentials:t.modelRegistry}):void 0;B&&(D=B.agent);const d=await M({description:u.description,prompt:l?u.prompt??"":"",readOnly:u.readOnly===!0,agent:D,resume:p},t,n,r,a,i);return{content:[{type:"text",text:`${B?`${T(B)}
|
|
15
|
+
${d.text}`:d.text}
|
|
15
16
|
|
|
16
|
-
${
|
|
17
|
+
${b(d.subagentId)}`}],details:{description:u.description,...d.agent?{agent:d.agent}:{},subagentId:d.subagentId,...d.autoResumed?{autoResumed:!0}:{},...C(),...B?{autoAgent:{name:B.agent.name,confidence:B.confidence}}:{},...d.changedFiles.length>0?{changedFiles:d.changedFiles}:{}},...C()}}const f=u.chain??[],m=f.map(D=>R(s,D.agent??u.agent));let c="";const A=[],h=[];let w=!1;for(const[D,B]of f.entries()){const d=m[D],nu=`${u.description} [${D+1}/${f.length}${d?` ${d.name}`:""}]`;try{const{text:y,changedFiles:x,subagentId:ru,autoResumed:su}=await M({description:nu,prompt:_(B.prompt,c),readOnly:u.readOnly===!0,agent:d},t,n,r,a,i);c=y,A.push(...x),h.push(ru),w||=su}catch(y){const x=y instanceof Error?y.message:String(y);throw new Error(`${e("\u4E32\u884C\u94FE\u5728\u7B2C")} ${D+1} ${e("\u6B65\u4E2D\u65AD\uFF1A")}${x}`)}}const $=[...new Set(A)],U=h[h.length-1]??"";return{content:[{type:"text",text:`${c}
|
|
17
18
|
|
|
18
|
-
${
|
|
19
|
-
`),i.length>0?"warning":"info")},"handler")})
|
|
19
|
+
${b(U)}`}],details:{description:u.description,subagentId:U,...w?{autoResumed:!0}:{},...C(),chain:m.map((D,B)=>({...D?{agent:D.name}:{},subagentId:h[B]})),...$.length>0?{changedFiles:$}:{}},...C()}}F(tu,"Ie"),o(tu,"executeTask");function eu(u){if(Bu()>=hu)return;const t=new Q;N(u,G({cwd:process.cwd(),projectTrusted:!1}).agents,t),u.on("session_start",async(n,r)=>{N(u,k(r).agents,t)}),u.on("agent_start",()=>{t.reset()}),u.on("tool_result",n=>{const r=n.toolName==="task"&&n.isError?L.get(n.toolCallId):void 0;if(L.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:o(async(n,r)=>{const{agents:a,diagnostics:i}=k(r),s=[e("\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\uFF1A"),q(a,!0),"",`${e("\u7528\u6237\u89D2\u8272\u76EE\u5F55\uFF1A")}${pu()}`,`${e("\u9879\u76EE\u89D2\u8272\u76EE\u5F55\uFF1A")}${du(r.cwd)}${r.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(E=>`- ${E}`)),r.ui.notify(s.join(`
|
|
20
|
+
`),i.length>0?"warning":"info")},"handler")})}F(eu,"Me"),o(eu,"default");export{Q as AccountLimitStop,z as TASK_TOOL_GUIDELINES,S as accountLimitMessage,T as autoRoleNote,P as buildSubagentSystemPrompt,v as continuePrompt,eu as default,_ as fillPrevious,I as lastAssistantText,j as resolveAgentModel,b as subagentIdLine};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);for(;l!==-1;)
|
|
3
|
-
`)}),r.stderr.setEncoding("utf8"),r.stderr.on("data",m=>{g=(g+m).slice(-4e3)}),e.signal?.addEventListener("abort",
|
|
1
|
+
var V=Object.defineProperty;var i=(e,s)=>V(e,"name",{value:s,configurable:!0});var $=Object.defineProperty,n=i((e,s)=>$(e,"name",{value:s,configurable:!0}),"n");import{spawn as q}from"node:child_process";import{existsSync as z,readdirSync as G,rmSync as Q,statSync as Y}from"node:fs";import{join as S}from"node:path";import{isAccountLimitAssistantError as Z}from"@earendil-works/pi-ai";import{getAgentDir as ee,getPackageDir as se}from"@earendil-works/pi-coding-agent";const te=2,A="DAL_SUBAGENT_DEPTH",W="DAL_SUBAGENT_COMMAND";function T(e=process.env){const s=Number.parseInt(e[A]??"0",10);return Number.isFinite(s)&&s>0?s:0}i(T,"G"),n(T,"currentSubagentDepth");const x=600*1e3;function _(e=process.env){const s=e[W];if(s){const[r,...p]=JSON.parse(s);return{command:r,args:p,env:{}}}if(process.versions.bun)return{command:process.execPath,args:[],env:{}};const a=se(),o=S(a,"dist","cli.js"),c=z(o)?o:S(a,"src","cli.ts"),u=process.versions.electron?{ELECTRON_RUN_AS_NODE:"1"}:{};return{command:process.execPath,args:[...process.execArgv,c],env:u}}i(_,"W"),n(_,"resolveDalCommand");function C(){return S(ee(),"subagent-sessions")}i(C,"ne"),n(C,"subagentSessionDir");const M=10080*60*1e3,j=200;function D(e,s){const a=`_${s}.jsonl`;try{const o=G(e).find(c=>c.endsWith(a));return o?S(e,o):void 0}catch{return}}i(D,"J"),n(D,"findSubagentSessionFile");function B(e,s=Date.now(),a=M,o=j){let c;try{c=G(e)}catch{return}const u=n(t=>{try{return Y(S(e,t)).mtimeMs}catch{return s}},"mtime"),r=n(t=>Q(S(e,t),{force:!0}),"remove"),p=c.filter(t=>t.endsWith(".jsonl")).map(t=>({name:t,id:t.slice(t.indexOf("_")+1,-6),mtime:u(t)})).sort((t,d)=>d.mtime-t.mtime),g=new Set;for(const[t,d]of p.entries()){if(t<o&&s-d.mtime<=a){g.add(d.id);continue}r(d.name),r(`${d.id}.meta.json`)}for(const t of c){if(!t.endsWith(".meta.json"))continue;const d=t.slice(0,-10);!g.has(d)&&s-u(t)>a&&r(t)}}i(B,"re"),n(B,"pruneSubagentSessions");const v="DALCODE_PARENT_SESSION_ID",N="DALCODE_PARENT_TASK_ID",E="DALCODE_SUBAGENT_ID",k="DALCODE_PARENT_SUBAGENT_ID",H="DALCODE_SUBAGENT_LABEL",ne="DALCODE_TASK_ID";function O(e,s=process.env){const a=s[v],o=!!(a&&s[E]),c=o?s[N]:s[ne],u={[v]:o?a:e.sessionId,[E]:e.subagentId};return c&&(u[N]=c),o&&(u[k]=s[E]),e.label&&(u[H]=e.label.slice(0,200)),u}i(O,"H"),n(O,"subagentAttributionEnv");const oe=[v,N,E,k,H];function L(e){const s=["-p","--mode","json"];return e.session?s.push("--session-dir",e.session.dir,"--session-id",e.session.id):s.push("--no-session"),e.projectTrusted!==void 0&&s.push(e.projectTrusted?"--approve":"--no-approve"),e.model&&s.push("--model",e.model),e.thinking&&s.push("--thinking",e.thinking),e.tools&&s.push("--tools",e.tools.join(",")),e.excludeTools&&e.excludeTools.length>0&&s.push("--exclude-tools",e.excludeTools.join(",")),e.appendSystemPrompt&&s.push("--append-system-prompt",e.appendSystemPrompt),s}i(L,"F"),n(L,"buildSubagentArgs");function b(e){const s=_(),a=T()+1;return new Promise((o,c)=>{if(e.signal?.aborted){c(new Error("aborted"));return}const u={...process.env};for(const m of oe)delete u[m];const r=q(s.command,[...s.args,...L(e)],{cwd:e.cwd,env:{...u,...s.env,...e.attribution?O(e.attribution):{},[A]:String(a),...e.env},stdio:["pipe","pipe","pipe"],windowsHide:!0}),p=[];let g="",t="",d,y=!1;const f=n(()=>{r.kill("SIGTERM"),d=setTimeout(()=>r.kill("SIGKILL"),5e3)},"stop"),I=e.idleTimeoutMs??x,P=n(()=>{y=!0,f()},"onIdle");let h=setTimeout(P,I);const w=n(m=>{if(!m.trim().startsWith("{"))return;let l;try{l=JSON.parse(m)}catch{return}l.type==="message_end"&&l.message&&p.push(l.message),e.onEvent?.(l)},"handleLine");r.stdout.setEncoding("utf8"),r.stdout.on("data",m=>{clearTimeout(h),h=setTimeout(P,I),t+=m;let l=t.indexOf(`
|
|
2
|
+
`);for(;l!==-1;)w(t.slice(0,l)),t=t.slice(l+1),l=t.indexOf(`
|
|
3
|
+
`)}),r.stderr.setEncoding("utf8"),r.stderr.on("data",m=>{g=(g+m).slice(-4e3)}),e.signal?.addEventListener("abort",f,{once:!0}),r.on("error",m=>{clearTimeout(h),e.signal?.removeEventListener("abort",f),c(m)}),r.on("close",m=>{clearTimeout(h),d&&clearTimeout(d),e.signal?.removeEventListener("abort",f),t&&w(t),e.signal?.aborted?c(new Error("aborted")):o({messages:p,exitCode:m,stderr:g,idleTimedOut:y})}),r.stdin.on("error",()=>{}),r.stdin.end(e.prompt)})}i(b,"v"),n(b,"runSubagentProcess");function F(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}i(F,"oe"),n(F,"emptyUsage");function K(e,s){e.input+=s.input,e.output+=s.output,e.cacheRead+=s.cacheRead,e.cacheWrite+=s.cacheWrite,e.totalTokens+=s.totalTokens,s.cacheWrite1h!==void 0&&(e.cacheWrite1h=(e.cacheWrite1h??0)+s.cacheWrite1h),s.reasoning!==void 0&&(e.reasoning=(e.reasoning??0)+s.reasoning),e.cost.input+=s.cost.input,e.cost.output+=s.cost.output,e.cost.cacheRead+=s.cost.cacheRead,e.cost.cacheWrite+=s.cost.cacheWrite,e.cost.total+=s.cost.total}i(K,"ie"),n(K,"addUsage");function X(e){if(e.type!=="message_end")return;const s=e.message;return s?.role==="assistant"&&s.usage?.cost?s.usage:void 0}i(X,"ce"),n(X,"assistantUsage");function R(e){if(e.idleTimedOut)return!1;const s=e.messages.at(-1);return s?.role==="assistant"&&s.stopReason!=="error"&&s.stopReason!=="aborted"&&s.stopReason!=="toolUse"}i(R,"$"),n(R,"finishedNormally");function U(e){const s=e.messages.at(-1);return s?.role==="assistant"&&Z(s)}i(U,"q"),n(U,"endedOnAccountLimit");async function J(e){let s,a;try{s=await b(e)}catch(o){if(e.signal?.aborted)throw o;a=o}if(s&&(R(s)||U(s)))return{...s,autoResumed:!1};if(!D(e.session.dir,e.session.id)){if(s)return{...s,autoResumed:!1};throw a}return e.onResume?.(),{...await b({...e,prompt:e.resumePrompt}),autoResumed:!0}}i(J,"ae"),n(J,"runResumableSubagent");export{te as MAX_SUBAGENT_DEPTH,W as SUBAGENT_COMMAND_ENV,A as SUBAGENT_DEPTH_ENV,x as SUBAGENT_IDLE_TIMEOUT_MS,M as SUBAGENT_SESSION_MAX_AGE_MS,j as SUBAGENT_SESSION_MAX_COUNT,K as addUsage,X as assistantUsage,L as buildSubagentArgs,T as currentSubagentDepth,F as emptyUsage,U as endedOnAccountLimit,D as findSubagentSessionFile,R as finishedNormally,B as pruneSubagentSessions,_ as resolveDalCommand,J as runResumableSubagent,b as runSubagentProcess,O as subagentAttributionEnv,C as subagentSessionDir};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-telemetry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
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.33"
|
|
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.
|
|
3
|
+
"version": "1.0.33",
|
|
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.
|
|
22
|
+
"@dalcode/dal-pi-kit": "1.0.33",
|
|
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.
|
|
3
|
+
"version": "1.0.33",
|
|
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.33",
|
|
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.33",
|
|
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.33",
|
|
27
|
+
"@dalcode/deepailab": "1.0.33",
|
|
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.33",
|
|
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.33",
|
|
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.33",
|
|
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.33",
|
|
24
|
+
"@earendil-works/pi-ai": "^1.0.33"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var J=Object.defineProperty;var p=(e,u)=>J(e,"name",{value:u,configurable:!0});var W=Object.defineProperty,i=p((e,u)=>W(e,"name",{value:u,configurable:!0}),"a");import{t as n}from"@dalcode/dal-pi-kit";import{getAgentDir as Y,SettingsManager as Q}from"@earendil-works/pi-coding-agent";import{accountTag as X,readCache as Z,writeCache as ee}from"./cache.js";import{gatewayModelDefaults as L,restoreCatalog as ue,toCatalogStoreEntry as te}from"./model-defaults.js";import{defaultConfig as
|
|
2
|
-
`))}),e.registerCommand("account",{description:n("\u67E5\u770B DeepAILab \u4F1A\u5458\u548C\u5957\u9910\u72B6\u6001"),handler:i(async(s,o)=>{const c=await o.modelRegistry.getApiKeyForProvider("deepailab");if(!c){o.ui.notify(n("\u5C1A\u672A\u767B\u5F55\u3002\u8BF7\u8FD0\u884C /login \u5E76\u9009\u62E9 DeepAILab\u3002"),"warning");return}try{const l=await re(u,String(D.current?.access??c)),
|
|
3
|
-
`)},"notify");e.on("after_provider_response",(s,o)=>{if(s.status<400||s.status===
|
|
1
|
+
var J=Object.defineProperty;var p=(e,u)=>J(e,"name",{value:u,configurable:!0});var W=Object.defineProperty,i=p((e,u)=>W(e,"name",{value:u,configurable:!0}),"a");import{t as n}from"@dalcode/dal-pi-kit";import{getAgentDir as Y,SettingsManager as Q}from"@earendil-works/pi-coding-agent";import{accountTag as X,readCache as Z,writeCache as ee}from"./cache.js";import{gatewayModelDefaults as L,restoreCatalog as ue,toCatalogStoreEntry as te}from"./model-defaults.js";import{defaultConfig as y,discover as S,fetchMembership as re,OAuthError as ae,pollDeviceToken as se,refresh as ne,startDeviceFlow as ie}from"./oidc.js";function v(e,u){return{access:e.accessToken,refresh:e.refreshToken??"",expires:u?e.expiresAt:0,vk:u}}p(v,"S"),i(v,"toCredentials");async function w(e,u){const t=await fetch(`${e}/portal/keys/lifecycle`,{method:"POST",headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"},body:JSON.stringify({operation:"create",name:"dal-cli",allowedModels:[]})});if(!t.ok)throw new Error(`Virtual key exchange failed (${t.status}): ${await t.text()}`);const a=(await t.json()).oneTimeCredential?.value;if(!a)throw new Error("Bridge did not return a virtual key secret.");return a}p(w,"E"),i(w,"createVirtualKey");async function x(e){const u=y(),t=await S(u.issuer),a=await ie(u,t);e.onAuth({url:a.verificationUriComplete,instructions:n("\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u786E\u8BA4\u767B\u5F55\u8BF7\u6C42\uFF0C\u4EE5\u8FDE\u63A5 DeepAILab\u3002")}),e.onDeviceCode({userCode:a.userCode,verificationUri:a.verificationUri,intervalSeconds:a.interval,expiresInSeconds:a.expiresIn});const r=await se(u,t,a,{signal:e.signal});r.refreshToken||e.onProgress?.(n("\u8B66\u544A\uFF1A\u672A\u7B7E\u53D1\u5237\u65B0\u4EE4\u724C \u2014 \u8BF7\u68C0\u67E5 offline_access \u6388\u6743\u8303\u56F4\u3002")),e.onProgress?.(n("\u6B63\u5728\u5F00\u901A DeepAILab \u8BBF\u95EE\u5BC6\u94A5\u2026"));let d="";for(let f=0;f<2&&!d;f++)try{d=await w(u.apiBase,r.accessToken)}catch(A){f===1&&e.onProgress?.(`${n("\u8BBF\u95EE\u5BC6\u94A5\u5F00\u901A\u5931\u8D25\uFF08")}${A instanceof Error?A.message:String(A)}${n("\uFF09\uFF0C\u4E0B\u6B21\u4F7F\u7528\u65F6\u5C06\u81EA\u52A8\u91CD\u8BD5\u3002")}`)}return v(r,d)}p(x,"N"),i(x,"loginDeepAILab");async function C(e,u){const t=new AbortController,a=setTimeout(()=>t.abort(),1e4);try{const r=await fetch(`${e}/portal/skills`,{headers:{"x-bf-vk":u,Accept:"application/json"},signal:t.signal});return r.status!==401&&r.status!==403}catch{return!0}finally{clearTimeout(a)}}p(C,"q"),i(C,"isVirtualKeyLive");const oe=1440*60*1e3;function P(e){if(typeof e!="object"||e===null)return!1;const u=e;return typeof u.issuer=="string"&&typeof u.tokenEndpoint=="string"}p(P,"z"),i(P,"isEndpoints");async function M(e){const u=`oidc-discovery-${X(e)}`,t=Z(u,P);if(t&&Date.now()-t.savedAt<oe)return t.value;const a=await S(e);try{ee(u,a)}catch{}return a}p(M,"J"),i(M,"discoverCached");const K=420*1e3;function b(e){return e instanceof ae?/^http_5\d\d$/.test(e.code)||e.code==="server_error"||e.code==="temporarily_unavailable":!0}p(b,"Q"),i(b,"isTransientRefreshFailure");async function k(e){const u=String(e.vk??"");try{return await R(e)}catch(t){if(u&&b(t))return{...e,expires:Date.now()+K};throw t}}p(k,"X"),i(k,"refreshDeepAILab");async function R(e){const u=y(),t=await M(u.issuer);let a=String(e.vk??"");const[r,d]=await Promise.all([ne(u,t,e.refresh),a?C(u.apiBase,a):Promise.resolve(!1)]);return d||(a=await w(u.apiBase,r.accessToken)),v(r,a)}p(R,"Z"),i(R,"renewDeepAILab");const j=[],ce=900*1e3;function U(e){if(e?.type==="oauth")return String(e.vk||e.access||"")||void 0;if(e?.type==="api_key")return e.key||void 0}p(U,"te"),i(U,"gatewayKey");async function V(e,u,t){let a;try{a=await fetch(`${e}/models`,{headers:{"x-bf-vk":u,Accept:"application/json"},signal:AbortSignal.any([t,AbortSignal.timeout(2e4)])})}catch(r){if(r instanceof Error&&(r.name==="AbortError"||r.name==="TimeoutError"))throw new Error(`${n("\u65E0\u6CD5\u83B7\u53D6\u6A21\u578B\u5217\u8868")}\uFF1A${n("\u8BF7\u6C42\u8D85\u65F6")}`);const d=r instanceof Error?r.cause:void 0,f=d?.code??d?.message;throw new Error(`${n("\u65E0\u6CD5\u83B7\u53D6\u6A21\u578B\u5217\u8868")}\uFF1A${n("\u65E0\u6CD5\u8FDE\u63A5 DeepAILab \u7F51\u5173")}${f?` (${f})`:""}`)}if(!a.ok)throw new Error(`${n("\u65E0\u6CD5\u83B7\u53D6\u6A21\u578B\u5217\u8868")}\uFF1A${n("\u7F51\u5173\u62D2\u7EDD\u4E86\u8BF7\u6C42")} (HTTP ${a.status})`);return((await a.json()).data??[]).filter(r=>typeof r.id=="string"&&r.id.length>0).map(r=>L(r.id,r.display_name??r.name,{contextWindow:r.context_window,maxTokens:r.max_output_tokens,capabilities:r.capabilities,reasoningEfforts:r.reasoning_efforts,pricing:r.pricing}))}p(V,"re"),i(V,"fetchGatewayCatalog");function N(){const e=Q.create(process.cwd(),Y(),{projectTrusted:!1}),u=e.getDefaultModel();return e.getDefaultProvider()!=="deepailab"||!u?[]:[L(u)]}p(N,"ne"),i(N,"configuredDefaultCatalog");const O=Symbol.for("dalcode.deepailab.credentials"),G=globalThis;G[O]??={};const D=G[O];function $(){const e=D.current?.access;return typeof e=="string"&&e.length>0?e:void 0}p($,"ie"),i($,"currentDeepAILabAccessToken");async function q(e){try{if(!await e.getApiKeyForProvider("deepailab"))return}catch{return}return $()}p(q,"fe"),i(q,"resolveDeepAILabAccessToken");function H(){return y().apiBase.replace(/\/+$/,"")}p(H,"pe"),i(H,"deepAILabApiBase");function z(e){const u=y();let t=j,a=0,r;const d=i(async(s,o)=>{const c=te("deepailab",s,u.apiBase);t=s,a=c.checkedAt??Date.now();let l=!1;try{l=await o({persist:c})}catch{}r=l?void 0:c},"persist");e.registerProvider("deepailab",{name:"DeepAILab",baseUrl:u.apiBase,apiKey:"$DAL_VK",api:"openai-completions",models:j,refreshModels:i(async({credential:s,allowNetwork:o,force:c,signal:l,stored:F,publish:g})=>{const B=U(s);if(!B)return t;if(r)try{await g({persist:r})&&(r=void 0)}catch{}const E=F?.checkedAt??0;if(E>a){const I=ue(F);I.length>0&&(t=I,a=E)}if(!o)return t.length===0&&(t=N()),t;if(!c&&a>0&&Date.now()-a<ce)return t;const T=await V(u.apiBase,B,l);return T.length>0&&await d(T,g),t},"refreshModels"),oauth:{name:"DeepAILab",login:x,refreshToken:k,getApiKey:i(s=>(D.current=s,s.vk?String(s.vk):String(s.access)),"getApiKey"),modifyModels:i((s,o)=>s.map(c=>({...c,headers:{...c.headers,"x-bf-vk":String(o.vk??"")}})),"modifyModels")}}),e.on("provider_authenticated",async(s,o)=>{if(s.providerId!=="deepailab")return;const c=await o.modelRegistry.refresh({providers:["deepailab"],force:!0,signal:AbortSignal.timeout(2e4)}),l=c.errors.get("deepailab"),F=l?l.message:c.aborted?`${n("\u65E0\u6CD5\u83B7\u53D6\u6A21\u578B\u5217\u8868")}\uFF1A${n("\u8BF7\u6C42\u8D85\u65F6")}`:void 0;F&&(o.hasUI?o.ui.notify(F,"error"):process.stderr.write(`${F}
|
|
2
|
+
`))}),e.registerCommand("account",{description:n("\u67E5\u770B DeepAILab \u4F1A\u5458\u548C\u5957\u9910\u72B6\u6001"),handler:i(async(s,o)=>{const c=await o.modelRegistry.getApiKeyForProvider("deepailab");if(!c){o.ui.notify(n("\u5C1A\u672A\u767B\u5F55\u3002\u8BF7\u8FD0\u884C /login \u5E76\u9009\u62E9 DeepAILab\u3002"),"warning");return}try{const l=await re(u,String(D.current?.access??c)),F=l.membership.plan??"free",g=l.membership.active?n("\u5DF2\u6FC0\u6D3B"):n("\u672A\u6FC0\u6D3B"),B=l.membership.expiresAt?` \xB7 ${n("\u81F3")} ${l.membership.expiresAt}`:"",E=l.principal?.email??l.principal?.username??"";o.ui.notify(`DeepAILab ${E} \u2014 ${F}\uFF08${g}\uFF09${B}`,"info")}catch(l){o.ui.notify(`${n("\u65E0\u6CD5\u52A0\u8F7D\u4F1A\u5458\u4FE1\u606F\uFF1A")}${l instanceof Error?l.message:String(l)}`,"error")}},"handler")});let f=0,A=0;const _=i((s,o)=>{s.hasUI?s.ui.notify(o.message,o.level):process.stderr.write(`${o.message}
|
|
3
|
+
`)},"notify");e.on("after_provider_response",(s,o)=>{if(s.status<400||s.status===f)return;if(f=s.status,s.status===401||s.status===402||s.status===403){A=s.status;return}const c=h(s.status,!!D.current?.vk);c&&_(o,c)}),e.on("message_end",(s,o)=>{if(!A)return;const c=s.message;if(c.role!=="assistant")return;const l=A;A=0;const F=h(l,!!D.current?.vk,c.errorMessage);F&&_(o,F)}),e.on("turn_start",()=>{f=0,A=0})}p(z,"se"),i(z,"default");function m(e){return e?/"type"\s*:\s*"api_key_(?:required|not_found|expired|revoked|disabled|invalid)"/i.test(e)||/x-bf-vk|virtual[ _-]?key/i.test(e)?"user":/authentication_error|invalid_api_key|incorrect api key|invalid api key|your api key[:\s]|api key[^"]{0,40}is invalid|insufficient[ _](?:balance|quota)|credit balance is too low|permission_error|account[^"]{0,40}(?:suspended|deactivated|disabled)/i.test(e)?"upstream":"unknown":"unknown"}p(m,"T"),i(m,"classifyGatewayAuthFailure");function h(e,u=!0,t){return e===401||e===403?m(t)==="upstream"?{message:n("\u8BE5\u6A21\u578B\u7684\u670D\u52A1\u901A\u9053\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7528 /model \u6362\u4E00\u4E2A\u6A21\u578B\uFF0C\u6216\u7A0D\u540E\u518D\u8BD5\u3002"),level:"error"}:u?{message:n("\u767B\u5F55\u72B6\u6001\u5DF2\u5931\u6548\uFF0C\u8BF7\u8FD0\u884C /login \u91CD\u65B0\u767B\u5F55 DeepAILab\u3002"),level:"error"}:{message:n("\u8D26\u6237\u7F3A\u5C11\u8BBF\u95EE\u5BC6\u94A5\uFF08\u4E0A\u6B21\u5F00\u901A\u672A\u6210\u529F\uFF09\u3002\u8FD0\u884C /login \u91CD\u65B0\u767B\u5F55\u5373\u53EF\u8865\u53D1\u3002"),level:"error"}:e===402?m(t)==="upstream"?{message:n("\u8BE5\u6A21\u578B\u7684\u4E0A\u6E38\u670D\u52A1\u901A\u9053\u4F59\u989D\u4E0D\u8DB3\uFF0C\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528\u3002\u8BF7\u7528 /model \u6362\u4E00\u4E2A\u6A21\u578B\uFF0C\u6216\u7A0D\u540E\u518D\u8BD5\u3002"),level:"error"}:{message:n("\u8D26\u6237\u4F59\u989D\u4E0D\u8DB3\uFF0C\u8BF7\u5145\u503C\u540E\u91CD\u8BD5\u3002\u8FD0\u884C /account \u67E5\u770B\u5957\u9910\uFF0C\u6216\u524D\u5F80 deepailab.ai \u5145\u503C\u3002"),level:"error"}:e===429?{message:n("\u8BF7\u6C42\u592A\u9891\u7E41\uFF0C\u7F51\u5173\u6B63\u5728\u9650\u6D41\u3002\u8BF7\u7A0D\u7B49\u51E0\u79D2\u518D\u8BD5\u3002"),level:"warning"}:e===404?{message:n("\u5F53\u524D\u6A21\u578B\u5728\u7F51\u5173\u4E0A\u4E0D\u53EF\u7528\uFF08\u53EF\u80FD\u672A\u7ED1\u5B9A\u5BC6\u94A5\uFF09\u3002\u7528 /model \u6362\u4E00\u4E2A\u6A21\u578B\u8BD5\u8BD5\u3002"),level:"warning"}:e>=500?{message:n("DeepAILab \u7F51\u5173\u6682\u65F6\u4E0D\u53EF\u7528\uFF08\u670D\u52A1\u7AEF\u9519\u8BEF\uFF09\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"),level:"error"}:null}p(h,"I"),i(h,"gatewayStatusNotice");export{K as REFRESH_RETRY_AFTER_MS,m as classifyGatewayAuthFailure,$ as currentDeepAILabAccessToken,H as deepAILabApiBase,z as default,h as gatewayStatusNotice,b as isTransientRefreshFailure,C as isVirtualKeyLive,k as refreshDeepAILab,q as resolveDeepAILabAccessToken};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@earendil-works/pi-agent-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
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.
|
|
20
|
+
"@earendil-works/pi-ai": "^1.0.33",
|
|
21
21
|
"typebox": "1.3.27"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":6,"generatedAt":"2026-10-15T06:
|
|
1
|
+
{"schemaVersion":6,"generatedAt":"2026-10-15T06:40:12.091Z","structureHash":"968477560e4be6629bd5d57dda1e989fd2dc03ea5a2f13e5c09f5432f9965f16","files":{"amazon-bedrock.json":"df227d426b678e44cd82deae1cf433855d6b27f36fedcff3ef4fb812fe882868","ant-ling.json":"628feab3ef6c7d80ce96f75999804e1d9f05fec3851e5302e30fff3b69db90f6","anthropic.json":"327ea610aca64889902458243e9b6a440eb678671f5993b88ad32ac6e827b587","azure.json":"46c4e25b84463c6475e706c581196d2735c35feb9612d2efca0ab932c917d727","baseten.json":"1fcdab8daf2881bd099eb08f9416f7df5bf39975937d2a63b841542bd032f2e6","cerebras.json":"3eccb58c5de3d0dc7ba49dc6e477ba29f00cb3150ce0a35cc90d59e6b5ab368e","cloudflare-ai-gateway.json":"388aefd2f1e5c5b0783673de1acda4a7ea8de853ebb5beeeede9646a90159a2a","cloudflare-workers-ai.json":"98b9c8cb412139ae3f5d2f5e49134f8412ed4e139a12bf6cb3aeba38aacc6bb3","deepseek.json":"10a296fb3e898f7715c80890c8af0af4f5fd58f22dbcd6612fdc5d762157ccdc","fireworks.json":"8db3c11f65a5d76260d5040a5dc5a9ef0f35b92de8505a30907c2355c2837b36","github-copilot.json":"1c7d77a4c320081bb0a80b2c8e185b34f07b73d38e67d20f3dcabcf72f2f8fcd","google-vertex.json":"564d692a4292ef12e98c8ec056a39948ea64e10851f5ddaaebcc37b585545231","google.json":"e13d3c51b13028d8253153165f7438ea2f3c3eaa8f209be952d3e9ded4494b5a","groq.json":"910952ad9dad07856983459d63fce0148dba1203edd7b10d801a77c5824f3405","huggingface.json":"6399e958790a9d90c21fb55d1cbef8569427a1ceb28de86dadeb3b4454ecfade","kimi-coding.json":"582250b920454d98940da3e7e99d30b807edbea28f2eb8ac15f658d2ef41e8fc","meta.json":"563f5ec07973f52ab8c3eb26ef91a36ad8a79e950b37174935666cdcb624bf35","minimax-cn.json":"1bbfbd11c3edbd141841d3cef027e12157218f1aec92477e15772116c1fabe7a","minimax.json":"a4b6864bd97eddf5749b2e117f643e751ec237408e8e24bec9e2f947782fa244","mistral.json":"27aa66c71a0504b53dc87ec194286fa7e70b99747fc8df9b709b23b3548afe50","moonshotai-cn.json":"79c9585dc84ee525ebaebbc78b3c55f3d369ec884d4f943488f1e0b14e3587f5","moonshotai.json":"1da2c4e34f22aef17a07c974d85bdee8e1b68b6dc712e3769c935b3f1e7dadca","nvidia.json":"cc7b418f706178f0aac2384324cd63f7641ff03656ef25551a1859e2c69381bc","openai-codex.json":"3cc35a7e122e5c77ee8ec30a9a3bd8bd59629997e85ba2cb3f9e0ed62e9a09c0","openai.json":"f4c1ac9f8f84cb9f2a952b0ceec51c90a38b31b4cdf33200e018ece9d408e95f","opencode-go.json":"dcb44624d15d90aff3c35d672dd2a94fa93d368f0040e3d50d836ccd11e5c51b","opencode.json":"0db59e2b739f4feea7f3e1b2982e3c0b53c63390e561acd6b1da56659049073b","openrouter.json":"a92cf1236366ed182fd455da3aa9882f6ad040253ee349b3a6f1282e6d5a9f9b","qwen-token-plan-cn.json":"2469a4091c474ec3db0a49a9962d8d2726c074ad9065b96bc4e0c87861c4c6c5","qwen-token-plan-individual.json":"0fb7cf64faf39d1a3b0a884210a86c87084b805eda15644f5f39293287b959dd","qwen-token-plan.json":"eff10620cb577142de4ec02698d5961a71fda2fe4f6ae7ea9432bad9d6844176","radius.json":"47c49f1ffaf2900c8e1e23ee61cb4cbe8c066ae59a4e2d01393c5c9772a1da04","together.json":"52293df62191c8e799ae3632f8ab1b3f52ee626aee0280677086627b32864bf7","typesafe.json":"a4429a2f696d5cc5273969af61a7310bda07d6bdcd27bf9ac9c76c534cc43716","vercel-ai-gateway.json":"bb62e8a267e0e94be31cdad7ea95dbdb1608adc1ab910341e8761144982940f0","xai.json":"879c49b78b663a52a220ac4ee013e726b10c4f50aaa03bc58ee53a4b54c76928","xiaomi-token-plan-ams.json":"ca65178f4525d9705bc8d085ed136cecbe149c4080e857ea6a64ae643d2ac00a","xiaomi-token-plan-cn.json":"b065326926681c2262084e59c1c19ebdaf146c07107b5242c76b456becf74db0","xiaomi-token-plan-sgp.json":"92c3d6d707f81fd9cd2b6d1fb57dc431d90ba51e10fe49d97bc8806035c23492","xiaomi.json":"b81d01a374f7b558728c78d81f4168efa9c8996e6e2b5618409a8094b083c759","zai-coding-cn.json":"ee5ee705fb6e413a6088db5e3616c27fce802a8ece6c355f1db35490d787f610","zai.json":"58e6642fdfb736f0b9a4a277c760c536a3cea66a030abbfb2615f7b2851d5c6f"}}
|