dal-code 1.0.42 → 1.0.43
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 +7 -0
- package/dist/core/agent-session.js +9 -9
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/types.d.ts +17 -0
- package/dist/core/sandbox/shell-sandbox.js +7 -5
- package/dist/core/tools/bash.d.ts +1 -0
- package/dist/core/tools/bash.js +13 -13
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.js +1 -1
- package/dist/dal/manifest.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/main.js +3 -3
- package/dist/modes/rpc/approvals.js +1 -0
- package/dist/modes/rpc/message-meta.js +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +15 -1
- package/dist/modes/rpc/rpc-client.js +3 -3
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +55 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-guard/src/index.js +2 -1
- package/dist/node_modules/@dalcode/dal-guard/src/workspace.js +2 -2
- 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-learn/package.json +2 -2
- 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 +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-remote/package.json +32 -0
- package/dist/node_modules/@dalcode/dal-remote/src/cli.js +10 -0
- package/dist/node_modules/@dalcode/dal-remote/src/index.js +1 -0
- package/dist/node_modules/@dalcode/dal-remote/src/install.js +8 -0
- package/dist/node_modules/@dalcode/dal-remote/src/paths.js +1 -0
- package/dist/node_modules/@dalcode/dal-remote/src/service.js +8 -0
- package/dist/node_modules/@dalcode/dal-remote/src/spec.js +1 -0
- 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-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-subagent/src/background.js +8 -8
- package/dist/node_modules/@dalcode/dal-subagent/src/index.js +19 -19
- package/dist/node_modules/@dalcode/dal-subagent/src/progress.js +1 -0
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +3 -3
- 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-usage/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 +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/providers/data/vercel-ai-gateway.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-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-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.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
25
|
-
"@dalcode/dal-skills": "1.0.
|
|
26
|
-
"@dalcode/deepailab": "1.0.
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
25
|
+
"@dalcode/dal-skills": "1.0.43",
|
|
26
|
+
"@dalcode/deepailab": "1.0.43",
|
|
27
27
|
"typebox": "1.3.27"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-recall",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Search past sessions: a local full-text index of earlier conversations the model can query with session_search. Adapted from @henryqw/pi-session-recall 5.1.4 (MIT).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
24
24
|
"typebox": "1.3.27"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mario Zechner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dalcode/dal-remote",
|
|
3
|
+
"version": "1.0.43",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "`dal remote enable|disable|status|pair|logs`: installs the phone daemon (a pinned, integrity-checked npm package) and runs it as a systemd user service or a launchd agent, so the DAL Code phone app can reach this machine.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.js",
|
|
10
|
+
"./cli": "./src/cli.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"pi": {
|
|
17
|
+
"extensions": [
|
|
18
|
+
"./src/index.js"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@dalcode/dal-pi-kit": "1.0.43"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
26
|
+
},
|
|
27
|
+
"peerDependenciesMeta": {
|
|
28
|
+
"@earendil-works/pi-coding-agent": {
|
|
29
|
+
"optional": false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var U=Object.defineProperty;var i=(u,e)=>U(u,"name",{value:e,configurable:!0});var q=Object.defineProperty,s=i((u,e)=>q(u,"name",{value:e,configurable:!0}),"o");import{chmodSync as H,existsSync as p,mkdirSync as f,readFileSync as N,rmSync as K,writeFileSync as E}from"node:fs";import{homedir as Q,userInfo as V}from"node:os";import{dirname as X}from"node:path";import{t}from"@dalcode/dal-pi-kit";import{daemonBinPath as k,installDaemon as z,installedDaemonDir as O,runCommand as Y}from"./install.js";import{remotePaths as D}from"./paths.js";import{forgetService as Z,serviceDir as uu,serviceFileContent as eu,serviceFilePath as ru,serviceKind as B,serviceState as nu,startService as tu,stopService as au}from"./service.js";import{daemonPairArgs as su,daemonRunArgs as iu,ENV_ACCOUNT_TOKEN_FILE as Fu,resolveDaemonSpec as g}from"./spec.js";const P="DAL_CODING_AGENT_DIR";function d(u){try{return JSON.parse(N(u.stateFile,"utf8"))}catch{return}}i(d,"b"),s(d,"readState");function C(u,e){f(u.root,{recursive:!0}),E(u.stateFile,`${JSON.stringify(e,null,2)}
|
|
2
|
+
`)}i(C,"N"),s(C,"writeState");function h(u){return`'${u.replace(/'/g,"'\\''")}'`}i(h,"$"),s(h,"shellQuote");function v(u,e,r){const n={DAL_COMMAND:u.dalWrapper,[Fu]:u.accountTokenFile,HOME:r.home,PATH:[X(r.nodePath),"/usr/local/bin","/usr/bin","/bin"].join(":")},a=r.env[P]?.trim();return a&&(n[P]=a),{program:r.nodePath,args:[e,...iu(u.home)],env:n,workingDirectory:r.home,logFile:u.logFile}}i(v,"X"),s(v,"launchSpecFor");function A(u,e){return{kind:u,file:ru(u,e.home,e.env),run:e.run,uid:e.uid,user:e.user}}i(A,"S"),s(A,"serviceContext");function y(u){return u.err(t("dal remote \u76EE\u524D\u53EA\u652F\u6301 Linux\uFF08systemd\uFF09\u548C macOS\u3002")),1}i(y,"k"),s(y,"unsupported");function b(u){return u.out([t("\u7528\u6CD5\uFF1Adal remote <\u547D\u4EE4>"),"",t(" enable \u5B89\u88C5\u5E76\u542F\u52A8\u624B\u673A\u7AEF\u5B88\u62A4\u8FDB\u7A0B\uFF0C\u663E\u793A\u914D\u5BF9\u4FE1\u606F"),t(" disable \u505C\u6B62\u5E76\u79FB\u9664\u624B\u673A\u7AEF\u5B88\u62A4\u8FDB\u7A0B\u7684\u670D\u52A1\uFF08\u4FDD\u7559\u914D\u5BF9\u4FE1\u606F\uFF09"),t(" status \u67E5\u770B\u662F\u5426\u5F00\u542F\u3001\u662F\u5426\u5728\u8FD0\u884C\uFF08--json \u8F93\u51FA\u673A\u5668\u53EF\u8BFB\u7ED3\u679C\uFF09"),t(" pair \u518D\u6B21\u663E\u793A\u914D\u5BF9\u4FE1\u606F"),t(" logs \u67E5\u770B\u5B88\u62A4\u8FDB\u7A0B\u65E5\u5FD7\uFF08-n \u884C\u6570\uFF0C\u9ED8\u8BA4 50\uFF09"),"",t("\u9ED8\u8BA4\u4E0D\u5F00\u542F\uFF1B\u53EA\u6709\u8FD0\u884C dal remote enable \u540E\u624D\u4F1A\u5B89\u88C5\u548C\u542F\u52A8\u3002")].join(`
|
|
3
|
+
`)),0}i(b,"w"),s(b,"help");async function S(u,e,r){const n=await r.run(r.nodePath,[u,...su(e.home)],{env:r.env});if(n.code===0)try{const a=JSON.parse(n.stdout);return a.url?a:void 0}catch{return}}i(S,"x"),s(S,"fetchPairing");function $(u,e){e.out(t("\u5728\u624B\u673A\u4E0A\u6253\u5F00 DAL Code\uFF0C\u626B\u63CF\u4E0B\u9762\u7684\u4E8C\u7EF4\u7801\uFF0C\u6216\u6253\u5F00\u914D\u5BF9\u94FE\u63A5\uFF1A")),u.qr&&e.out(u.qr),u.url&&e.out(u.url)}i($,"F"),s($,"printPairing");function I(u,e){const r=O(u,e);return r?k(r,e):void 0}i(I,"z"),s(I,"installedBin");async function R(u){const e=B(u.platform);if(!e)return y(u);const r=D(u.agentDir);let n;try{n=g(u.env)}catch(F){return u.err(F instanceof Error?F.message:String(F)),1}let a;try{a=await z(r,n,{fetch:u.fetch,run:u.run,env:u.env,npm:u.npm,progress:s(F=>u.out(F),"progress")})}catch(F){return u.err(F instanceof Error?F.message:String(F)),1}const o=k(a,n);if(!o)return u.err(t("{pkg} \u91CC\u6CA1\u6709\u547D\u4EE4 {bin}\uFF0C\u65E0\u6CD5\u542F\u52A8\u3002").replace("{pkg}",n.packageName).replace("{bin}",n.bin)),1;for(const F of[r.home,r.logDir,r.binDir])f(F,{recursive:!0,mode:448});E(r.dalWrapper,`#!/bin/sh
|
|
4
|
+
exec ${h(u.nodePath)} ${h(u.dalEntry)} "$@"
|
|
5
|
+
`),H(r.dalWrapper,493);const c=A(e,u);f(uu(c.file),{recursive:!0}),E(c.file,eu(e,v(r,o,u)));let l;try{l=await tu(c)}catch(F){return u.err(`${t("\u670D\u52A1\u6CA1\u80FD\u542F\u52A8\uFF1A")}${F instanceof Error?F.message:String(F)}`),e==="systemd"&&u.err(t("\u5982\u679C\u662F\u901A\u8FC7 ssh \u767B\u5F55\u7684\u670D\u52A1\u5668\uFF0C\u786E\u8BA4\u6709\u7528\u6237\u4F1A\u8BDD\uFF08XDG_RUNTIME_DIR\uFF09\uFF0C\u6216\u5148\u8FD0\u884C loginctl enable-linger\u3002")),1}C(r,{packageName:n.packageName,version:n.version,...n.integrity?{integrity:n.integrity}:{},enabled:!0,kind:e,serviceFile:c.file,enabledAt:new Date().toISOString()}),u.out(t("\u624B\u673A\u7AEF\u8FDC\u7A0B\u5DF2\u5F00\u542F\uFF08{pkg}\uFF09\u3002").replace("{pkg}",`${n.packageName}@${n.version}`)),l.includes("linger-enabled")&&u.out(t("\u5DF2\u5F00\u542F lingering\uFF1A\u6CE8\u9500\u540E\u3001\u91CD\u542F\u540E\u5B88\u62A4\u8FDB\u7A0B\u4E5F\u4F1A\u8FD0\u884C\u3002")),l.includes("linger-failed")&&u.out(t("\u6CA1\u80FD\u5F00\u542F lingering\uFF1A\u6CE8\u9500\u540E\u5B88\u62A4\u8FDB\u7A0B\u4F1A\u505C\u6B62\u3002\u53EF\u8BF7\u7BA1\u7406\u5458\u8FD0\u884C sudo loginctl enable-linger {user}\u3002").replace("{user}",u.user));const m=u.sleep??(F=>new Promise(G=>setTimeout(G,F))),W=Date.now()+(u.pairWaitMs??3e4);for(;;){const F=await S(o,r,u);if(F)return $(F,u),0;if(Date.now()>=W)break;await m(1e3)}return u.out(t("\u5B88\u62A4\u8FDB\u7A0B\u5DF2\u542F\u52A8\uFF0C\u4F46\u8FD8\u62FF\u4E0D\u5230\u914D\u5BF9\u4FE1\u606F\u3002\u7A0D\u540E\u8FD0\u884C dal remote pair\uFF0C\u6216\u7528 dal remote logs \u67E5\u770B\u65E5\u5FD7\u3002")),0}i(R,"Y"),s(R,"enable");async function _(u){const e=B(u.platform);if(!e)return y(u);const r=D(u.agentDir),n=A(e,u),a=d(r);return!p(n.file)&&!a?.enabled?(u.out(t("\u624B\u673A\u7AEF\u8FDC\u7A0B\u672C\u6765\u5C31\u6CA1\u6709\u5F00\u542F\u3002")),0):(await au(n),K(n.file,{force:!0}),await Z(n),a&&C(r,{...a,enabled:!1,disabledAt:new Date().toISOString()}),u.out(t("\u624B\u673A\u7AEF\u8FDC\u7A0B\u5DF2\u5173\u95ED\u3002\u5B88\u62A4\u8FDB\u7A0B\u548C\u914D\u5BF9\u4FE1\u606F\u4ECD\u4FDD\u7559\u5728 {dir}\uFF0C\u518D\u6B21\u5F00\u542F\u65E0\u9700\u91CD\u65B0\u914D\u5BF9\u3002").replace("{dir}",r.root)),0)}i(_,"Z"),s(_,"disable");async function w(u){const e=D(u.agentDir),r=d(e);let n;try{n=g(u.env)}catch{n=void 0}const a=B(u.platform);let o=null;if(a){const c=A(a,u),l=p(c.file),m=l?await nu(c):{state:"not-installed"};o={kind:a,file:c.file,installed:l,...m}}return{enabled:!!(r?.enabled&&o?.installed),installed:n?O(e,n)!==void 0:!1,packageName:r?.packageName??n?.packageName??"",version:r?.version??n?.version??"",service:o,home:e.home,logFile:e.logFile}}i(w,"ee"),s(w,"remoteStatus");function j(u){switch(u){case"running":return t("\u8FD0\u884C\u4E2D");case"stopped":return t("\u5DF2\u505C\u6B62");case"failed":return t("\u51FA\u9519\u505C\u6B62\uFF08\u7528 dal remote logs \u67E5\u770B\u539F\u56E0\uFF09");case"not-installed":return t("\u672A\u5B89\u88C5");default:return t("\u672A\u77E5")}}i(j,"te"),s(j,"stateLabel");async function x(u,e){const r=await w(e);if(u.includes("--json"))return e.out(JSON.stringify(r,null,2)),0;const n=[`${t("\u624B\u673A\u7AEF\u8FDC\u7A0B\uFF1A")}${r.enabled?t("\u5DF2\u5F00\u542F"):t("\u672A\u5F00\u542F")}`,`${t("\u5B88\u62A4\u8FDB\u7A0B\uFF1A")}${r.packageName}@${r.version}\uFF08${r.installed?t("\u5DF2\u5B89\u88C5"):t("\u672A\u5B89\u88C5")}\uFF09`];return r.service?(n.push(`${t("\u670D\u52A1\uFF1A")}${r.service.kind==="systemd"?"systemd --user":"launchd"} \u2014 ${j(r.service.state)}${r.service.pid?` (pid ${r.service.pid})`:""}`),r.service.installed&&n.push(`${t("\u670D\u52A1\u6587\u4EF6\uFF1A")}${r.service.file}`)):n.push(t("dal remote \u76EE\u524D\u53EA\u652F\u6301 Linux\uFF08systemd\uFF09\u548C macOS\u3002")),n.push(`${t("\u65E5\u5FD7\uFF1A")}${r.logFile}`),r.enabled||n.push(t("\u5F00\u542F\uFF1Adal remote enable")),e.out(n.join(`
|
|
6
|
+
`)),0}i(x,"ne"),s(x,"status");async function L(u,e){const r=D(e.agentDir);let n;try{n=g(e.env)}catch(c){return e.err(c instanceof Error?c.message:String(c)),1}const a=I(r,n);if(!a||!d(r)?.enabled)return e.err(t("\u624B\u673A\u7AEF\u8FDC\u7A0B\u6CA1\u6709\u5F00\u542F\u3002\u5148\u8FD0\u884C dal remote enable\u3002")),1;const o=await S(a,r,e);return o?(u.includes("--json")?e.out(JSON.stringify(o,null,2)):$(o,e),0):(e.err(t("\u62FF\u4E0D\u5230\u914D\u5BF9\u4FE1\u606F\uFF1A\u5B88\u62A4\u8FDB\u7A0B\u53EF\u80FD\u6CA1\u6709\u5728\u8FD0\u884C\u3002\u7528 dal remote status \u548C dal remote logs \u67E5\u770B\u3002")),1)}i(L,"re"),s(L,"pair");function T(u,e){const r=D(e.agentDir),n=u.indexOf("-n"),a=n>=0?Number(u[n+1]):50;if(!Number.isInteger(a)||a<=0)return e.err(t("-n \u9700\u8981\u4E00\u4E2A\u6B63\u6574\u6570\u3002")),2;if(!p(r.logFile))return e.out(t("\u8FD8\u6CA1\u6709\u65E5\u5FD7\uFF1A{file}").replace("{file}",r.logFile)),0;const o=N(r.logFile,"utf8").split(`
|
|
7
|
+
`);return o.at(-1)===""&&o.pop(),e.out(o.slice(-a).join(`
|
|
8
|
+
`)),0}i(T,"ie"),s(T,"logs");function J(u){let e=process.env.USER??"";try{e=V().username}catch{}return{agentDir:u,home:Q(),env:process.env,platform:process.platform,uid:typeof process.getuid=="function"?process.getuid():0,user:e,nodePath:process.execPath,dalEntry:process.argv[1]??"",fetch:s((r,n)=>fetch(r,n),"fetch"),run:Y,npm:process.platform==="win32"?"npm.cmd":"npm",out:s(r=>process.stdout.write(`${r}
|
|
9
|
+
`),"out"),err:s(r=>process.stderr.write(`${r}
|
|
10
|
+
`),"err")}}i(J,"de"),s(J,"defaultRemoteDeps");async function M(u,e){const[r,...n]=u;switch(r){case"enable":return R(e);case"disable":return _(e);case"status":return x(n,e);case"pair":return L(n,e);case"logs":return T(n,e);case void 0:case"help":case"-h":case"--help":return b(e);default:return e.err(t("\u672A\u77E5\u7684\u5B50\u547D\u4EE4\uFF1A{name}").replace("{name}",r)),b(e),2}}i(M,"pe"),s(M,"runRemoteCommand");export{J as defaultRemoteDeps,v as launchSpecFor,w as remoteStatus,M as runRemoteCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var r=(u,a)=>i(u,"name",{value:a,configurable:!0});var d=Object.defineProperty,F=r((u,a)=>d(u,"name",{value:a,configurable:!0}),"n");import{t as e}from"@dalcode/dal-pi-kit";import{getAgentDir as l}from"@earendil-works/pi-coding-agent";import{defaultRemoteDeps as E,remoteStatus as A}from"./cli.js";import{defaultRemoteDeps as D,remoteStatus as f,runRemoteCommand as C}from"./cli.js";import{REMOTE_DAEMON as p}from"./spec.js";function n(u){u.registerCommand("remote",{description:e("\u67E5\u770B\u624B\u673A\u7AEF\u8FDC\u7A0B\u662F\u5426\u5F00\u542F\uFF08\u5F00\u542F\uFF1A\u5728\u7EC8\u7AEF\u8FD0\u884C dal remote enable\uFF09"),handler:F(async(a,m)=>{const t=await A(E(l())),o=t.service?.state,s=t.enabled?`${e("\u624B\u673A\u7AEF\u8FDC\u7A0B\u5DF2\u5F00\u542F")} \u2014 ${o==="running"?e("\u8FD0\u884C\u4E2D"):e("\u6CA1\u6709\u5728\u8FD0\u884C\uFF08\u7528 dal remote logs \u67E5\u770B\u539F\u56E0\uFF09")}`:e("\u624B\u673A\u7AEF\u8FDC\u7A0B\u672A\u5F00\u542F\u3002\u5728\u7EC8\u7AEF\u8FD0\u884C dal remote enable \u5F00\u542F\u3002");m.ui.notify(s,t.enabled&&o!=="running"?"warning":"info")},"handler")})}r(n,"u"),F(n,"default");export{p as REMOTE_DAEMON,n as default,D as defaultRemoteDeps,f as remoteStatus,C as runRemoteCommand};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var P=Object.defineProperty;var p=(e,u)=>P(e,"name",{value:u,configurable:!0});var j=Object.defineProperty,g=p((e,u)=>j(e,"name",{value:u,configurable:!0}),"d");import{spawn as L}from"node:child_process";import{createHash as O}from"node:crypto";import{existsSync as R,mkdirSync as A,readFileSync as C,realpathSync as x,renameSync as T,rmSync as m,writeFileSync as B}from"node:fs";import{join as F}from"node:path";import{t as i}from"@dalcode/dal-pi-kit";import{daemonInstallDir as h}from"./paths.js";const H=200*1024*1024,k=12e4,$=".dal-remote-installed";class l extends Error{static{p(this,"l")}static{g(this,"RemoteInstallError")}code;constructor(u,t){super(t),this.code=u}}const J=g((e,u,t)=>new Promise(o=>{let r="",s="",n;try{n=L(e,[...u],{cwd:t?.cwd,env:t?.env??process.env,stdio:["ignore","pipe","pipe"]})}catch(a){o({code:127,stdout:r,stderr:a instanceof Error?a.message:String(a)});return}n.stdout?.on("data",a=>{r+=String(a)}),n.stderr?.on("data",a=>{s+=String(a)}),n.on("error",a=>o({code:127,stdout:r,stderr:s||a.message})),n.on("close",a=>o({code:a??1,stdout:r,stderr:s}))}),"runCommand");function E(e){return`sha512-${O("sha512").update(e).digest("base64")}`}p(E,"F"),g(E,"sha512Integrity");function v(e){const u=(e.PI_OFFLINE??e.DAL_OFFLINE)?.toLowerCase();return u==="1"||u==="true"||u==="yes"}p(v,"L"),g(v,"offline");function y(e,u){const t=h(e,u.version);try{const o=JSON.parse(C(F(t,$),"utf8"));return o.name===u.packageName&&o.integrity===u.integrity?t:void 0}catch{return}}p(y,"T"),g(y,"installedDaemonDir");function w(e,u){const t=F(e,"node_modules",".bin",u.bin);if(R(t))try{return x(t)}catch{return}}p(w,"A"),g(w,"daemonBinPath");async function b(e,u){const t=[];let o=0;for(const r of e.registries){const s=`${r.replace(/\/+$/,"")}/${e.packageName}/${e.version}`;try{const n=await u(s,{signal:AbortSignal.timeout(k)});if(n.status===404){o++,await n.body?.cancel();continue}if(!n.ok){t.push(`${r}: HTTP ${n.status}`),await n.body?.cancel();continue}const a=await n.json(),c=typeof a.dist?.tarball=="string"?a.dist.tarball:void 0;if(!c){t.push(`${r}: ${i("\u6CA1\u6709\u4E0B\u8F7D\u5730\u5740")}`);continue}return{registry:r,tarball:c,integrity:typeof a.dist?.integrity=="string"?a.dist.integrity:void 0}}catch(n){t.push(`${r}: ${n instanceof Error?n.message:String(n)}`)}}throw o>0&&t.length===0?new l("not-published",i("\u624B\u673A\u7AEF\u5B88\u62A4\u8FDB\u7A0B {pkg} \u8FD8\u6CA1\u6709\u53D1\u5E03\uFF0C\u6682\u65F6\u65E0\u6CD5\u5F00\u542F\u3002\u53D1\u5E03\u540E\u5347\u7EA7 dal \u5373\u53EF\u4F7F\u7528\u3002").replace("{pkg}",`${e.packageName}@${e.version}`)):new l("network",`${i("\u65E0\u6CD5\u4ECE\u8F6F\u4EF6\u6E90\u83B7\u53D6\u624B\u673A\u7AEF\u5B88\u62A4\u8FDB\u7A0B\uFF1A")}
|
|
2
|
+
${t.map(r=>` ${r}`).join(`
|
|
3
|
+
`)}`)}p(b,"C"),g(b,"lookUp");async function S(e,u){const t=await u(e,{signal:AbortSignal.timeout(k)});if(!t.ok)throw await t.body?.cancel(),new l("network",`${e}: HTTP ${t.status}`);const o=t.body?.getReader();if(!o)throw new l("network",`${e}: ${i("\u54CD\u5E94\u6CA1\u6709\u5185\u5BB9")}`);const r=[];let s=0;for(;;){const{done:n,value:a}=await o.read();if(n)break;if(s+=a.byteLength,s>H)throw await o.cancel(),new l("network",i("\u5B88\u62A4\u8FDB\u7A0B\u5B89\u88C5\u5305\u8D85\u8FC7 200 MB\uFF0C\u5DF2\u505C\u6B62\u4E0B\u8F7D"));r.push(a)}return Buffer.concat(r)}p(S,"B"),g(S,"download");async function N(e,u,t){const o=y(e,u);if(o)return o;const r=`${u.packageName}@${u.version}`;let s,n;if(u.tarball)s=C(u.tarball);else{if(v(t.env))throw new l("offline",i("\u79BB\u7EBF\u6A21\u5F0F\u4E0B\u65E0\u6CD5\u4E0B\u8F7D\u624B\u673A\u7AEF\u5B88\u62A4\u8FDB\u7A0B\u3002"));t.progress?.(i("\u6B63\u5728\u67E5\u627E {pkg} \u2026").replace("{pkg}",r));const d=await b(u,t.fetch);if(!u.integrity)throw new l("not-pinned",i("\u8FD9\u4E2A\u7248\u672C\u7684 dal \u6CA1\u6709\u8BB0\u5F55 {pkg} \u7684\u6821\u9A8C\u503C\uFF0C\u4E0D\u80FD\u5B89\u88C5\u3002\u8BF7\u5347\u7EA7 dal \u540E\u518D\u8BD5\u3002").replace("{pkg}",r));if(d.integrity&&d.integrity!==u.integrity)throw new l("integrity",i("\u8F6F\u4EF6\u6E90\u4E0A\u7684 {pkg} \u4E0E dal \u8BB0\u5F55\u7684\u6821\u9A8C\u503C\u4E0D\u4E00\u81F4\uFF0C\u5DF2\u505C\u6B62\u5B89\u88C5\u3002").replace("{pkg}",r));n=d.registry,t.progress?.(i("\u6B63\u5728\u4E0B\u8F7D {pkg} \u2026").replace("{pkg}",r)),s=await S(d.tarball,t.fetch)}const a=E(s);if(a!==u.integrity)throw new l("integrity",i("\u4E0B\u8F7D\u5230\u7684 {pkg} \u6821\u9A8C\u503C\u4E0D\u7B26\uFF08{got}\uFF09\uFF0C\u5DF2\u4E22\u5F03\u3002").replace("{pkg}",r).replace("{got}",a.slice(0,20)));A(e.daemonRoot,{recursive:!0});const c=F(e.daemonRoot,`.stage-${process.pid}-${Date.now()}`);A(c,{recursive:!0});try{const d=F(c,"daemon.tgz");B(d,s),B(F(c,"package.json"),`${JSON.stringify({name:"dal-remote-host",private:!0})}
|
|
4
|
+
`),t.progress?.(i("\u6B63\u5728\u5B89\u88C5 {pkg} \u2026").replace("{pkg}",r));const D=await t.run(t.npm,["install","--prefix",c,"--no-audit","--no-fund","--ignore-scripts","--omit=dev",...n?["--registry",n]:[],d],{cwd:c,env:t.env});if(D.code!==0){const I=D.stderr.trim().split(`
|
|
5
|
+
`).slice(-8).join(`
|
|
6
|
+
`);throw new l("npm",`${i("npm \u5B89\u88C5\u624B\u673A\u7AEF\u5B88\u62A4\u8FDB\u7A0B\u5931\u8D25\uFF1A")}
|
|
7
|
+
${I}`)}if(!w(c,u))throw new l("bin",i("{pkg} \u91CC\u6CA1\u6709\u547D\u4EE4 {bin}\uFF0C\u65E0\u6CD5\u542F\u52A8\u3002").replace("{pkg}",r).replace("{bin}",u.bin));m(d,{force:!0}),B(F(c,$),`${JSON.stringify({name:u.packageName,version:u.version,integrity:u.integrity})}
|
|
8
|
+
`);const f=h(e,u.version);return m(f,{recursive:!0,force:!0}),T(c,f),f}finally{m(c,{recursive:!0,force:!0})}}p(N,"K"),g(N,"installDaemon");export{l as RemoteInstallError,w as daemonBinPath,N as installDaemon,y as installedDaemonDir,J as runCommand,E as sha512Integrity};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty;var t=(a,o)=>s(a,"name",{value:o,configurable:!0});var d=Object.defineProperty,l=t((a,o)=>d(a,"name",{value:o,configurable:!0}),"n");import{join as e}from"node:path";const c="dal-remote",u="com.deepailab.dal-remote";function m(a){const o=e(a,"remote"),n=e(o,"logs"),r=e(o,"bin");return{root:o,daemonRoot:e(o,"daemon"),home:e(o,"home"),binDir:r,dalWrapper:e(r,"dal"),logDir:n,logFile:e(n,"daemon.log"),stateFile:e(o,"state.json"),accountTokenFile:e(o,"account-token")}}t(m,"c"),l(m,"remotePaths");function i(a,o){return e(a.daemonRoot,o)}t(i,"d"),l(i,"daemonInstallDir");export{u as LAUNCHD_LABEL,c as SERVICE_NAME,i as daemonInstallDir,m as remotePaths};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var L=Object.defineProperty;var i=(e,t)=>L(e,"name",{value:t,configurable:!0});var P=Object.defineProperty,a=i((e,t)=>P(e,"name",{value:t,configurable:!0}),"i");import{dirname as j,join as d}from"node:path";import{LAUNCHD_LABEL as c,SERVICE_NAME as v}from"./paths.js";function k(e){if(e==="linux")return"systemd";if(e==="darwin")return"launchd"}i(k,"w"),a(k,"serviceKind");function $(e,t,r){if(e==="launchd")return d(t,"Library","LaunchAgents",`${c}.plist`);const n=r.XDG_CONFIG_HOME?.trim()||d(t,".config");return d(n,"systemd","user",`${v}.service`)}i($,"h"),a($,"serviceFilePath");function u(e,t=!1){const r=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/%/g,"%%");return`"${t?r.replace(/\$/g,"$$$$"):r}"`}i(u,"c"),a(u,"systemdQuote");function g(e){const t=[e.program,...e.args].map(n=>u(n,!0)).join(" "),r=Object.entries(e.env).map(([n,s])=>`Environment=${u(`${n}=${s}`)}`);return["# Written by `dal remote enable`; removed by `dal remote disable`.","[Unit]","Description=DAL Code remote daemon (phone app)","After=network-online.target","Wants=network-online.target","","[Service]","Type=simple",`ExecStart=${t}`,...r,`WorkingDirectory=${u(e.workingDirectory)}`,"Restart=on-failure","RestartSec=5",`StandardOutput=append:${e.logFile}`,`StandardError=append:${e.logFile}`,"","[Install]","WantedBy=default.target",""].join(`
|
|
2
|
+
`)}i(g,"v"),a(g,"systemdUnit");function o(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}i(o,"a"),a(o,"xml");function y(e){const t=a(n=>n.map(s=>` <string>${o(s)}</string>`).join(`
|
|
3
|
+
`),"strings"),r=Object.entries(e.env).map(([n,s])=>` <key>${o(n)}</key>
|
|
4
|
+
<string>${o(s)}</string>`).join(`
|
|
5
|
+
`);return['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',"<!-- Written by `dal remote enable`; removed by `dal remote disable`. -->",'<plist version="1.0">',"<dict>"," <key>Label</key>",` <string>${c}</string>`," <key>ProgramArguments</key>"," <array>",t([e.program,...e.args])," </array>"," <key>EnvironmentVariables</key>"," <dict>",r," </dict>"," <key>WorkingDirectory</key>",` <string>${o(e.workingDirectory)}</string>`," <key>RunAtLoad</key>"," <true/>"," <key>KeepAlive</key>"," <dict>"," <key>SuccessfulExit</key>"," <false/>"," </dict>"," <key>ThrottleInterval</key>"," <integer>5</integer>"," <key>ProcessType</key>"," <string>Background</string>"," <key>StandardOutPath</key>",` <string>${o(e.logFile)}</string>`," <key>StandardErrorPath</key>",` <string>${o(e.logFile)}</string>`,"</dict>","</plist>",""].join(`
|
|
6
|
+
`)}i(y,"k"),a(y,"launchdPlist");function b(e,t){return e==="systemd"?g(t):y(t)}i(b,"L"),a(b,"serviceFileContent");const p=`${v}.service`;function m(e){return(e.stderr.trim()||e.stdout.trim()).split(`
|
|
7
|
+
`).slice(-4).join(`
|
|
8
|
+
`)}i(m,"m"),a(m,"describe");async function w(e){const t=[];if(e.kind==="systemd"){for(const l of[["--user","daemon-reload"],["--user","enable","--now",p]]){const f=await e.run("systemctl",l);if(f.code!==0)throw new Error(`systemctl ${l.join(" ")}: ${m(f)}`)}const s=await e.run("loginctl",["show-user",e.user,"--property=Linger"]);if(!/Linger=yes/.test(s.stdout)){const l=await e.run("loginctl",["enable-linger",e.user]);t.push(l.code===0?"linger-enabled":"linger-failed")}return t}const r=`gui/${e.uid}`;await e.run("launchctl",["bootout",`${r}/${c}`]);const n=await e.run("launchctl",["bootstrap",r,e.file]);if(n.code!==0)throw new Error(`launchctl bootstrap ${r}: ${m(n)}`);return t}i(w,"E"),a(w,"startService");async function h(e){if(e.kind==="systemd"){await e.run("systemctl",["--user","disable","--now",p]);return}await e.run("launchctl",["bootout",`gui/${e.uid}/${c}`])}i(h,"P"),a(h,"stopService");async function S(e){e.kind==="systemd"&&await e.run("systemctl",["--user","daemon-reload"])}i(S,"D"),a(S,"forgetService");async function D(e){if(e.kind==="systemd"){const s=(await e.run("systemctl",["--user","is-active",p])).stdout.trim();return s==="active"||s==="activating"||s==="reloading"?{state:"running"}:s==="failed"?{state:"failed"}:s==="inactive"||s==="deactivating"?{state:"stopped"}:{state:"unknown"}}const t=await e.run("launchctl",["print",`gui/${e.uid}/${c}`]);if(t.code!==0)return{state:"stopped"};const r=/\bpid = (\d+)/.exec(t.stdout)?.[1];if(/\bstate = running\b/.test(t.stdout))return{state:"running",...r?{pid:Number(r)}:{}};const n=/last exit code = (\d+)/.exec(t.stdout)?.[1];return{state:n&&n!=="0"?"failed":"stopped"}}i(D,"C"),a(D,"serviceState");function E(e){return j(e)}i(E,"x"),a(E,"serviceDir");export{S as forgetService,y as launchdPlist,E as serviceDir,b as serviceFileContent,$ as serviceFilePath,k as serviceKind,D as serviceState,w as startService,h as stopService,g as systemdUnit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.defineProperty;var o=(e,r)=>p(e,"name",{value:r,configurable:!0});var u=Object.defineProperty,E=o((e,r)=>u(e,"name",{value:r,configurable:!0}),"o");const T={packageName:"@deepailab/dal-remote-daemon",version:"0.1.0",integrity:void 0,bin:"dal-remote-daemon"},O=["https://registry.npmmirror.com","https://registry.npmjs.org"],s="DAL_REMOTE_DAEMON_PACKAGE",i="DAL_REMOTE_DAEMON_TARBALL",m="DAL_REMOTE_DAEMON_INTEGRITY",c="DAL_REMOTE_DAEMON_REGISTRY",D="DAL_REMOTE_ACCOUNT_TOKEN_FILE";function g(e){return["daemon","run","--home",e]}o(g,"T"),E(g,"daemonRunArgs");function l(e){return["daemon","pair","--home",e,"--relay","--json"]}o(l,"D"),E(l,"daemonPairArgs");function d(e,r=T){const _=[e[c]?.trim(),...O].filter(n=>!!n),a=e[s]?.trim(),t=e[i]?.trim(),A=e[m]?.trim();if(!a&&!t)return{...r,registries:_};if(!A)throw new Error(`${s} / ${i} need ${m} (the sha512 SRI they must match)`);let N=r.packageName,R=r.version;if(a){const n=a.lastIndexOf("@");if(n<=0)throw new Error(`${s} must be name@version, got ${a}`);N=a.slice(0,n),R=a.slice(n+1)}return{...r,packageName:N,version:R,integrity:A,registries:_,...t?{tarball:t}:{}}}o(d,"O"),E(d,"resolveDaemonSpec");export{D as ENV_ACCOUNT_TOKEN_FILE,m as ENV_INTEGRITY,s as ENV_PACKAGE,c as ENV_REGISTRY,i as ENV_TARBALL,T as REMOTE_DAEMON,O as REMOTE_DAEMON_REGISTRIES,l as daemonPairArgs,g as daemonRunArgs,d as resolveDaemonSpec};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-review",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
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.43",
|
|
23
|
+
"@dalcode/dal-subagent": "1.0.43",
|
|
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.43",
|
|
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.43"
|
|
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.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
31
|
-
"@dalcode/deepailab": "1.0.
|
|
32
|
-
"@earendil-works/pi-tui": "^1.0.
|
|
30
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
31
|
+
"@dalcode/deepailab": "1.0.43",
|
|
32
|
+
"@earendil-works/pi-tui": "^1.0.43"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@earendil-works/pi-coding-agent": "^1.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-rtk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Uses rtk, when the user has installed it, to compress the output of shell commands the agent runs. Does nothing when rtk is not installed; never installs it.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.43"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-skills",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
25
|
-
"@dalcode/deepailab": "1.0.
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
25
|
+
"@dalcode/deepailab": "1.0.43",
|
|
26
26
|
"typebox": "1.3.7"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-statusline",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "A scriptable status line under the footer: a template or a command of the user's choosing. Grown from the status-line and custom-footer extension examples.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.43"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-structured",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "dal -p --output-schema: the final answer as JSON that matches a JSON Schema, with a non-zero exit when it does not. Grown from the structured-output extension example.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
22
22
|
"typebox": "1.3.27"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-subagent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
22
|
-
"@dalcode/dal-guard": "1.0.
|
|
23
|
-
"@earendil-works/pi-agent-core": "^1.0.
|
|
24
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.43",
|
|
22
|
+
"@dalcode/dal-guard": "1.0.43",
|
|
23
|
+
"@earendil-works/pi-agent-core": "^1.0.43",
|
|
24
|
+
"@earendil-works/pi-ai": "^1.0.43",
|
|
25
25
|
"typebox": "1.3.7"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var $=Object.defineProperty;var
|
|
2
|
-
`):typeof n=="string"?n:""}
|
|
3
|
-
${e("\u2026\u2026\uFF08\u62A5\u544A\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF09")}`}
|
|
4
|
-
${s}`};const
|
|
1
|
+
var $=Object.defineProperty;var c=(n,u)=>$(n,"name",{value:u,configurable:!0});var S=Object.defineProperty,a=c((n,u)=>S(n,"name",{value:u,configurable:!0}),"u");import{t as e}from"@dalcode/dal-pi-kit";import{SubagentProgress as v}from"./progress.js";const g="dal-subagent-result",h=6e3,B="subagents_status",E=5e3,F=500;function C(n){return Array.isArray(n)?n.filter(u=>u?.type==="text"&&typeof u.text=="string").map(u=>u.text).join(`
|
|
2
|
+
`):typeof n=="string"?n:""}c(C,"v"),a(C,"textOfContent");function f(n){const u=n.trim();return u.length<=F?u:`\u2026${u.slice(-(F-1))}`}c(f,"A"),a(f,"capOutput");const D=a(n=>n.totalTokens>0||n.cost.total>0,"hasUsage");function m(n){return n.length<=h?n:`${n.slice(0,h)}
|
|
3
|
+
${e("\u2026\u2026\uFF08\u62A5\u544A\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD\uFF09")}`}c(m,"y"),a(m,"capReport");function A(n,u){const t=a(l=>`[${e("\u540E\u53F0\u5B50\u52A9\u624B")} ${n.id.slice(0,8)} \xB7 ${n.description} \xB7 ${l}]`,"head"),s=`${e("[\u5B50 agent ID\uFF1A")}${n.id}${e("\uFF0C\u53EF\u7528 resume \u53C2\u6570\u7EE7\u7EED]")}`;if(u.stop==="aborted")return{status:"stopped",text:`${t(e("\u5DF2\u505C\u6B62"))}
|
|
4
|
+
${s}`};const r=[];u.stop==="idle"&&r.push(e("\u5B50 agent \u8D85\u8FC7 10 \u5206\u949F\u6CA1\u6709\u4EFB\u4F55\u8FDB\u5C55\uFF0C\u5DF2\u505C\u6B62\u3002")),u.stop==="turn-limit"&&r.push(e("\u8FBE\u5230\u8F6E\u6B21\u4E0A\u9650\u4ECD\u672A\u7ED9\u51FA\u7ED3\u679C\uFF0C\u5DF2\u505C\u6B62\u3002")),u.failure&&r.push(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${u.failure}`),u.toolErrors&&r.push(`${e("\u8FDE\u7EED\u5931\u8D25\u7684\u8C03\u7528\uFF1A")}
|
|
5
5
|
${u.toolErrors.map(l=>`- ${l}`).join(`
|
|
6
|
-
`)}`);const
|
|
6
|
+
`)}`);const i=u.stop!==void 0||u.failure!==void 0,d=m(u.text||e("\u5B50 agent \u6CA1\u6709\u4EA7\u751F\u4EFB\u4F55\u8F93\u51FA\u3002")),p=i?"failed":"done",o=i?e("\u672A\u5B8C\u6210"):u.toolErrors?e("\u53D7\u963B"):e("\u5DF2\u5B8C\u6210");return{status:p,text:[t(o),...r,d,s].join(`
|
|
7
7
|
|
|
8
|
-
`)}}
|
|
8
|
+
`)}}c(A,"$"),a(A,"backgroundReport");class T{static{c(this,"I")}static{a(this,"BackgroundSubagents")}pi;pool;runInProcess;records=new Map;closed=!1;lastSnapshot="";statusTimer;constructor(u,t,s){this.pi=u,this.pool=t,this.runInProcess=s}active(){return[...this.records.values()].filter(u=>u.status==="queued"||u.status==="running")}start(u){const t=new AbortController,s={id:u.id,description:u.description,...u.agent?{agent:u.agent}:{},status:"queued",startedAt:Date.now(),usage:{input:0,output:0,cost:0},controller:t,progress:new v(this.pi,{...u.parentToolCallId?{parentToolCallId:u.parentToolCallId}:{},description:u.description,background:!0})};s.progress?.start(s.id,{...u.agent?{agent:u.agent}:{},status:"queued"}),this.records.set(s.id,s),this.publishStatus();const r=u.signal?AbortSignal.any([t.signal,u.signal]):t.signal;return this.drive(s,u,r),s}async drive(u,t,s){let r;try{r=await this.pool.acquire(s)}catch{this.setStatus(u,"stopped"),this.report(u,"stopped",`[${e("\u540E\u53F0\u5B50\u52A9\u624B")} ${u.id.slice(0,8)} \xB7 ${u.description} \xB7 ${e("\u5DF2\u505C\u6B62")}]`);return}this.setStatus(u,"running");try{const i=await this.runInProcess({...t.run,signal:s,onEvent:a(o=>{t.run.onEvent?.(o),this.observe(u,o)},"onEvent"),onStarted:a(o=>{u.handle=o},"onStarted"),onBlocked:a(o=>{this.closed||t.parentIdle()||this.send({customType:g,content:`[${e("\u540E\u53F0\u5B50\u52A9\u624B")} ${u.id.slice(0,8)} \xB7 ${u.description} \xB7 ${e("\u53D7\u963B")}]
|
|
9
9
|
${o.map(l=>`- ${l}`).join(`
|
|
10
10
|
`)}
|
|
11
|
-
${e("\u5B83\u6B63\u5728\u505C\u4E0B\u6765\u6C47\u62A5\u539F\u56E0\uFF1B\u4E0D\u8981\u91CD\u590D\u6D3E\u53D1\u540C\u6837\u7684\u5B50\u4EFB\u52A1\u3002")}`,display:!0,details:{subagentId:u.id,description:u.description,status:"running"}},{deliverAs:"steer"})},"onBlocked")});u.handle=void 0,
|
|
11
|
+
${e("\u5B83\u6B63\u5728\u505C\u4E0B\u6765\u6C47\u62A5\u539F\u56E0\uFF1B\u4E0D\u8981\u91CD\u590D\u6D3E\u53D1\u540C\u6837\u7684\u5B50\u4EFB\u52A1\u3002")}`,display:!0,details:{subagentId:u.id,description:u.description,status:"running"}},{deliverAs:"steer"})},"onBlocked")});u.handle=void 0,D(i.usage)&&this.pi.appendUsage(i.usage,{kind:"subagent",provider:t.run.model.provider,model:t.run.model.id,note:u.description}),i.accountLimit&&t.onAccountLimit?.(i.failure??"account limit");const{status:d,text:p}=A(u,i);this.setStatus(u,d,i.failure??(i.text||void 0)),this.report(u,d,p,D(i.usage)?i.usage:void 0)}catch(i){u.handle=void 0;const d=i instanceof Error?i.message:String(i);this.setStatus(u,"failed",d),this.report(u,"failed",`[${e("\u540E\u53F0\u5B50\u52A9\u624B")} ${u.id.slice(0,8)} \xB7 ${u.description} \xB7 ${e("\u672A\u5B8C\u6210")}]
|
|
12
12
|
|
|
13
|
-
${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${
|
|
13
|
+
${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${d}`)}finally{r?.()}}observe(u,t){if(t.type==="tool_execution_start"){u.progress?.step(String(t.toolName),t.args);return}if(t.type!=="message_end"&&t.type!=="message_update")return;const s=t.message;if(s?.role!=="assistant")return;const r=C(s.content);r.trim()&&(u.lastOutput=f(r)),t.type==="message_end"&&s.usage?.cost&&(u.usage.input+=s.usage.input,u.usage.output+=s.usage.output,u.usage.cost+=s.usage.cost.total)}setStatus(u,t,s){u.status=t,t!=="queued"&&t!=="running"&&(u.endedAt=Date.now()),t==="running"?u.progress?.running():t!=="queued"&&u.progress?.finish(t,s??u.lastOutput),this.publishStatus()}snapshot(){return{subagents:[...this.records.values()].map(u=>({id:u.id,description:u.description,...u.agent?{agent:u.agent}:{},status:u.status,startedAt:u.startedAt,...u.endedAt!==void 0?{endedAt:u.endedAt}:{},usage:{...u.usage},...u.lastOutput?{lastOutput:u.lastOutput}:{}}))}}publishStatus(){if(this.closed)return;const u=this.snapshot(),t=JSON.stringify(u);if(t!==this.lastSnapshot){this.lastSnapshot=t;try{this.pi.emitHostEvent(B,u)}catch{}}const s=this.active().length>0;s&&!this.statusTimer?(this.statusTimer=setInterval(()=>this.publishStatus(),E),this.statusTimer.unref?.()):!s&&this.statusTimer&&(clearInterval(this.statusTimer),this.statusTimer=void 0)}report(u,t,s,r){this.closed||this.send({customType:g,content:s,display:!0,details:{subagentId:u.id,description:u.description,status:t,...r?{usage:r}:{}}},{deliverAs:"followUp",triggerTurn:!0})}send(u,t){try{this.pi.sendMessage(u,t)}catch{this.closed=!0}}find(u){const t=u.trim();if(!t)return;const s=this.records.get(t);if(s)return s;const r=[...this.records.values()].filter(i=>i.id.startsWith(t));return r.length===1?r[0]:void 0}async steer(u,t){const s=this.find(u);if(!s)return`${e("\u6CA1\u6709\u8FD9\u4E2A\u540E\u53F0\u5B50\u52A9\u624B\uFF1A")}${u}`;if(s.status==="queued")return e("\u8FD9\u4E2A\u540E\u53F0\u5B50\u52A9\u624B\u8FD8\u5728\u6392\u961F\uFF0C\u5C1A\u672A\u5F00\u59CB\uFF1B\u7A0D\u540E\u518D\u8C03\u6574\uFF0C\u6216\u505C\u6B62\u540E\u91CD\u65B0\u6D3E\u53D1\u3002");if(s.status!=="running"||!s.handle)return e("\u8FD9\u4E2A\u5B50\u52A9\u624B\u5DF2\u7ECF\u7ED3\u675F\uFF1B\u8981\u7EE7\u7EED\u5B83\uFF0C\u7528 resume \u53C2\u6570\u3002");await s.handle.steer(t)}stop(u){const t=this.find(u);return!t||t.status!=="queued"&&t.status!=="running"?!1:(t.controller.abort(),!0)}close(){this.closed=!0,this.statusTimer&&clearInterval(this.statusTimer),this.statusTimer=void 0;for(const u of this.active())u.controller.abort()}}export{g as BACKGROUND_RESULT_TYPE,T as BackgroundSubagents,h as MAX_BACKGROUND_REPORT_CHARS,F as MAX_STATUS_OUTPUT_CHARS,B as SUBAGENTS_STATUS_EVENT,E as SUBAGENTS_STATUS_INTERVAL_MS,A as backgroundReport};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).trim();if(
|
|
1
|
+
var $u=Object.defineProperty;var d=(u,t)=>$u(u,"name",{value:t,configurable:!0});var yu=Object.defineProperty,i=d((u,t)=>yu(u,"name",{value:t,configurable:!0}),"s");import{execFileSync as ku}from"node:child_process";import{randomUUID as uu}from"node:crypto";import{mkdirSync as tu,readFileSync as bu,writeFileSync as eu}from"node:fs";import{join as xu}from"node:path";import{t as e}from"@dalcode/dal-pi-kit";import{routeSubagentModel as Su,subagentModelPreference as Iu}from"@dalcode/dal-router/subagent";import{isAccountLimitAssistantError as vu}from"@earendil-works/pi-ai";import{Type as m}from"typebox";import{formatAgentList as nu,loadAgents as ru,projectAgentsDir as Tu,READ_ONLY_TOOL_NAMES as ou,userAgentsDir as Pu}from"./agents.js";import{BackgroundSubagents as su}from"./background.js";import{proxiedToolNames as Ou,runInProcessSubagent as ju}from"./inproc-runner.js";import{SubagentPool as Ru}from"./pool.js";import{addUsage as Mu,assistantUsage as Lu,currentSubagentDepth as _u,emptyUsage as Nu,endedOnAccountLimit as Uu,findSubagentSessionFile as iu,finishedNormally as Ju,MAX_SUBAGENT_DEPTH as qu,pruneSubagentSessions as au,runResumableSubagent as Gu,subagentSessionDir as Fu}from"./process-runner.js";import{describeSubagentStep as Wu,filePathFromInput as zu,SubagentProgress as cu}from"./progress.js";import{pickRoleWithJev as lu}from"./role-pick.js";import{readTmuxSetting as du,registerTmuxChild as Xu,runTmuxSubagent as Hu,saveTmuxSetting as Ku,tmuxLocation as Qu,tmuxPlacement as Yu}from"./tmux-runner.js";import{createWorktree as Zu,finishWorktree as Vu}from"./worktree.js";export*from"./agents.js";export*from"./background.js";export*from"./inproc-runner.js";export*from"./pool.js";export*from"./process-runner.js";export*from"./progress.js";export*from"./role-pick.js";export*from"./tmux-runner.js";export*from"./worktree.js";const U=50,J=new Map;function q(u){if(J.has(u))return J.get(u);let t;try{t=ku("git",["ls-files","-z","--cached","--others","--exclude-standard"],{cwd:u,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3,maxBuffer:67108864}).split("\0").filter(Boolean).length}catch{t=void 0}return J.set(u,t),t}d(q,"Fe"),i(q,"gitProjectFileCount");function Eu(u){const t=u.sessionManager?.getBranch?.()??[];for(let o=t.length-1;o>=0;o--){const r=t[o];if(r.type!=="message"||r.message.role!=="user")continue;const l=r.message.content,F=typeof l=="string"?l:l.map(n=>n.type==="text"?n.text:"").join(" ");return/sub-?agents?|subtasks?|in parallel|parallel(ly)?|子助手|子代理|子 ?agent|子任务|并行|派发/i.test(F)}return!1}d(Eu,"Ne"),i(Eu,"userAskedForSubagents");function G(u){const t=q(u.cwd);if(!(t===void 0||t>=U||Eu(u)))return`Not started: this project has ${t} files. Briefing a sub-agent costs more than reading them yourself; do the work directly (parallel reads in one response). Start sub-agents here only when the user asks for them.`}d(G,"Ue"),i(G,"smallProjectRefusal");const pu=['Several separate items (modules, packages, repositories, documents, questions) that each need real work: dispatch one sub-agent per item with task, in your first response, all at once, without reading the items yourself first; there is no limit on how many ("review A, B and C" is three calls). Quick lookups you do yourself',"Sub-agents cannot see this conversation: each prompt states the goal, exact paths or inputs, constraints, how the result will be checked, and what to report. Running together they share the working tree: give each different files, and let only one run installs, builds or git","Build on their reports; verify only what your answer depends on. Follow up with task resume=<the id in its result> and a prompt holding only the new instruction (resume alone continues one that failed)",`In a project of under ${U} files, do the work yourself unless the user asks for sub-agents`,"background=true for long work you can continue without: the call returns an id at once and the report arrives later as a message (never poll or sleep for it); task steer=<id> prompt=<instruction> redirects it while it runs. worktree=true gives a sub-agent that edits files its own git checkout; its changes come back on a branch for you to review and merge"],ut=m.Object({agent:m.Optional(m.String({description:e("\u8FD9\u4E00\u6B65\u7684\u89D2\u8272\u540D")})),prompt:m.String({description:e("\u8FD9\u4E00\u6B65\u7684\u4EFB\u52A1\uFF1B{previous} \u4E3A\u4E0A\u4E00\u6B65\u7684\u8F93\u51FA")})}),tt=m.Object({description:m.String({description:e("\u5B50\u4EFB\u52A1\u7684\u7B80\u77ED\u6807\u9898\uFF083-5 \u4E2A\u5B57\uFF0C\u7528\u4E8E\u5C55\u793A\u8FDB\u5EA6\uFF09")}),prompt:m.Optional(m.String({description:e("\u5B8C\u6574\u3001\u81EA\u5305\u542B\u7684\u4EFB\u52A1\u8BF4\u660E")})),resume:m.Optional(m.String({description:e("\u7EE7\u7EED\u67D0\u4E2A\u5B50 agent\uFF1A\u586B\u7ED3\u679C\u91CC\u7684\u5B50 agent ID\uFF1Bprompt \u53EA\u5199\u65B0\u6307\u793A\uFF0C\u4E0D\u586B\u5219\u4ECE\u4E2D\u65AD\u5904\u7EE7\u7EED")})),agent:m.Optional(m.String({description:e("\u89D2\u8272\u540D\uFF08\u89C1\u5DE5\u5177\u8BF4\u660E\uFF09\uFF1B\u4E0D\u586B\u4E3A\u901A\u7528\u5B50 agent")})),readOnly:m.Optional(m.Boolean({description:e("\u53EA\u7ED9\u53EA\u8BFB\u5DE5\u5177\uFF08read/grep/find/ls\uFF09")})),chain:m.Optional(m.Array(ut,{description:e("\u6309\u987A\u5E8F\u8FD0\u884C\u7684\u6B65\u9AA4\uFF1B\u4E0E prompt \u4E8C\u9009\u4E00")})),background:m.Optional(m.Boolean({description:e("\u5728\u540E\u53F0\u8FD0\u884C\uFF1A\u7ACB\u5373\u8FD4\u56DE ID\uFF0C\u5B8C\u6210\u540E\u7ED3\u679C\u4EE5\u6D88\u606F\u9001\u56DE\uFF1B\u4E0D\u7528\u7B49\u5F85\u6216\u8F6E\u8BE2")})),steer:m.Optional(m.String({description:e("\u8C03\u6574\u6B63\u5728\u540E\u53F0\u8FD0\u884C\u7684\u5B50 agent\uFF1A\u586B\u5B83\u7684 ID\uFF0Cprompt \u5199\u65B0\u7684\u6307\u793A")})),worktree:m.Optional(m.Boolean({description:e("\u5728\u72EC\u7ACB\u7684 git \u5DE5\u4F5C\u533A\u91CC\u8FD0\u884C\uFF0C\u6539\u52A8\u63D0\u4EA4\u5230\u4E00\u4E2A\u65B0\u5206\u652F\uFF0C\u4E0D\u5F71\u54CD\u5F53\u524D\u5DE5\u4F5C\u533A")}))});function S(u){return`${e("[\u5B50 agent ID\uFF1A")}${u}${e("\uFF0C\u53EF\u7528 resume \u53C2\u6570\u7EE7\u7EED]")}`}d(S,"M"),i(S,"subagentIdLine");function O(){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")}d(O,"ee"),i(O,"continuePrompt");const W=i((u,t)=>xu(u,`${t}.meta.json`),"metaPath");function gu(u,t){const o=i(()=>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)||!iu(u,t))throw o();try{return JSON.parse(bu(W(u,t),"utf8"))}catch{throw o()}}d(gu,"Ge"),i(gu,"loadSubagentMeta");function j(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)}%]`}d(j,"te"),i(j,"autoRoleNote");function z(u){for(let t=u.length-1;t>=0;t--){const o=u[t];if(o.role!=="assistant")continue;const r=o.content.filter(l=>l.type==="text").map(l=>l.text).join(`
|
|
2
|
+
`).trim();if(r)return r;if(o.errorMessage)return`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${o.errorMessage}`}return e("\u5B50 agent \u6CA1\u6709\u4EA7\u751F\u4EFB\u4F55\u8F93\u51FA\u3002")}d(z,"qe"),i(z,"lastAssistantText");const et=new Set(["write","edit","multi_edit","notebook_edit"]);function X(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")+e("\u4EFB\u52A1\u8FD8\u6CA1\u505A\u5B8C\u65F6\u5C31\u63A5\u7740\u8C03\u7528\u4E0B\u4E00\u4E2A\u5DE5\u5177\uFF0C\u4E0D\u8981\u4EE5\u8BA1\u5212\u3001\u627F\u8BFA\uFF08\u201C\u63A5\u4E0B\u6765\u6211\u4F1A\u2026\u201D\uFF09\u6216\u63D0\u95EE\u7ED3\u675F\uFF1B\u505A\u4E0D\u4E0B\u53BB\u65F6\u8BF4\u660E\u5361\u5728\u54EA\u91CC\u3001\u8BD5\u8FC7\u4EC0\u4E48\u3002");return u?.systemPrompt?`${u.systemPrompt}
|
|
3
3
|
|
|
4
|
-
${t}`:t}d(
|
|
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")}`}d(
|
|
6
|
-
`));let h;if(u.worktree&&(h=n?await
|
|
4
|
+
${t}`:t}d(X,"Xe"),i(X,"buildSubagentSystemPrompt");function mu(u,t,o){const r=o?` \xB7 ${o}`:"";return`${u} \u2014 ${t} ${e("\u6B65")}${r}`}d(mu,"He"),i(mu,"progressLine");function R(u){return u.keptPath?`${e("[\u6CA1\u80FD\u63D0\u4EA4\u72EC\u7ACB\u5DE5\u4F5C\u533A\u91CC\u7684\u6539\u52A8\uFF0C\u5DE5\u4F5C\u533A\u4FDD\u7559\u5728\uFF1A")}${u.keptPath}]`:u.branch?`${e("[\u6539\u52A8\u5DF2\u63D0\u4EA4\u5230\u5206\u652F ")}${u.branch}${e("\uFF1A")}${u.files.join(", ")}${e("\u3002\u5BA1\u9605\u540E\u7528 git merge \u6216 cherry-pick \u5408\u5E76]")}`:e("[\u72EC\u7ACB\u5DE5\u4F5C\u533A\u91CC\u6CA1\u6709\u6539\u52A8]")}d(R,"ne"),i(R,"worktreeLine");function M(u,t,o){const r=u.indexOf("/");if(r>0){const n=t.find(u.slice(0,r),u.slice(r+1));if(n)return n}const l=t.find(o.provider,u);if(l)return l;const F=t.getAll().filter(n=>n.id===u);if(F.length===1)return F[0];throw new Error(`${e("\u627E\u4E0D\u5230\u89D2\u8272\u6307\u5B9A\u7684\u6A21\u578B\uFF1A")}${u}`)}d(M,"oe"),i(M,"resolveAgentModel");async function H(u,t){const o=t.model;if(!o)throw new Error(e("\u6CA1\u6709\u53EF\u7528\u7684\u5F53\u524D\u6A21\u578B\uFF0C\u65E0\u6CD5\u6D3E\u53D1\u5B50 agent\u3002"));let r=o;const l=Iu();if(u.agent?.model)r=M(u.agent.model,t.modelRegistry,o);else if(l.kind==="model")r=M(l.spec,t.modelRegistry,o);else if(l.kind==="route")try{const c=await Su({taskText:u.prompt,credentials:t.modelRegistry});if(c?.modelId&&c.provider){const s=t.modelRegistry?.find(c.provider,c.modelId);s&&(r=s)}}catch{}const F=u.agent?.tools,n=u.readOnly?(F??ou).filter(c=>ou.includes(c)):F;return{cwd:t.cwd,model:`${r.provider}/${r.id}`,thinking:u.agent?.thinking??"off",...n?{tools:n}:{},appendSystemPrompt:X(u.agent),...u.agent?{agent:u.agent.name}:{}}}d(H,"re"),i(H,"newSubagentMeta");class Au{static{d(this,"Ke")}static{i(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 P(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")}`}d(P,"j"),i(P,"accountLimitMessage");async function K(u,t,o,r,l,F,n){if(F?.reason!==void 0)throw new Error(P(F.reason));if(u.worktree&&u.resume)throw new Error(e("worktree \u4E0D\u80FD\u548C resume \u4E00\u8D77\u4F7F\u7528\u3002"));const c=Fu();let s,a;u.resume?(s=u.resume.trim(),a=gu(c,s)):(a=await H(u,t),s=uu(),tu(c,{recursive:!0}),au(c),eu(W(c,s),`${JSON.stringify(a)}
|
|
6
|
+
`));let h;if(u.worktree&&(h=n?await Zu(n,t.cwd,s):void 0,!h))throw new Error(e("worktree \u9700\u8981\u4E00\u4E2A\u81F3\u5C11\u6709\u4E00\u6B21\u63D0\u4EA4\u7684 git \u4ED3\u5E93\u3002"));let D;const B=i(async()=>(h&&n&&!D&&(D=await Vu(n,t.cwd,h,u.description)),D),"finishTree");u.progress?.start(s,a.agent?{agent:a.agent}:{});try{const p=await E(),w=await B();return u.progress?.finish("done",p.text),w?{...p,text:`${p.text}
|
|
7
7
|
|
|
8
|
-
${R(w)}`,changedFiles:w.files,worktree:w}:
|
|
9
|
-
${R(w)}`)}async function
|
|
10
|
-
${
|
|
8
|
+
${R(w)}`,changedFiles:w.files,worktree:w}:p}catch(p){u.progress?.finish(t.signal?.aborted?"stopped":"failed",p instanceof Error?p.message:String(p));const w=await B();throw!w||!(p instanceof Error)?p:new Error(`${p.message}
|
|
9
|
+
${R(w)}`)}async function E(){const p=[];let w=0;const k=i(A=>new Error(iu(c,s)?`${A}
|
|
10
|
+
${S(s)}`:A),"failed"),$=await Gu({cwd:h?.workPath??a.cwd,prompt:u.prompt||O(),session:{dir:c,id:s},resumePrompt:O(),model:a.model,thinking:a.thinking,tools:a.tools,...l?{excludeTools:l}:{},appendSystemPrompt:a.appendSystemPrompt,projectTrusted:t.isProjectTrusted(),signal:F?t.signal?AbortSignal.any([t.signal,F.signal]):F.signal:t.signal,attribution:{sessionId:t.sessionManager.getSessionId(),subagentId:s,label:u.description},onResume:i(()=>r?.(`${u.description} \u2014 ${e("\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u7EED\u8DD1")}`),"onResume"),onEvent:i(A=>{const g=Lu(A);if(g&&Mu(o,g),A.type!=="tool_execution_start")return;const C=String(A.toolName),f=A.args??{};if(w+=1,u.progress?.step(C,f),r?.(mu(u.description,w,Wu(C,f))),et.has(C)){const b=zu(f);b&&p.push(b)}},"onEvent")}).catch(A=>{throw t.signal?.aborted?A:F?.reason!==void 0?k(P(F.reason)):k(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${A instanceof Error?A.message:String(A)}`)});if($.idleTimedOut)throw k(e("\u5B50 agent \u8D85\u8FC7 10 \u5206\u949F\u6CA1\u6709\u4EFB\u4F55\u8FDB\u5C55\uFF0C\u5DF2\u505C\u6B62\u3002"));if(Uu($)){const A=$.messages.at(-1),g=A?.role==="assistant"&&A.errorMessage||"account limit";throw F?.trip(g),k(P(g))}const y=$.messages.at(-1),I=y?.role==="assistant"&&y.stopReason==="length";if(!I&&!Ju($)){const A=y?.role==="assistant"&&y.errorMessage||$.stderr.trim().split(`
|
|
11
11
|
`).slice(-3).join(`
|
|
12
|
-
`)||`exit ${$.exitCode}`;throw k(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${A}`)}const
|
|
12
|
+
`)||`exit ${$.exitCode}`;throw k(`${e("\u5B50 agent \u8FD0\u884C\u51FA\u9519\uFF1A")}${A}`)}const v=z($.messages);return{text:I?`${v}
|
|
13
13
|
|
|
14
|
-
${e("\uFF08\u5B50 agent \u7684\u56DE\u7B54\u8FBE\u5230\u4E86\u6A21\u578B\u8F93\u51FA\u957F\u5EA6\u4E0A\u9650\uFF0C\u5185\u5BB9\u4E0D\u5B8C\u6574\u3002\uFF09")}`:
|
|
14
|
+
${e("\uFF08\u5B50 agent \u7684\u56DE\u7B54\u8FBE\u5230\u4E86\u6A21\u578B\u8F93\u51FA\u957F\u5EA6\u4E0A\u9650\uFF0C\u5185\u5BB9\u4E0D\u5B8C\u6574\u3002\uFF09")}`:v,changedFiles:[...new Set(p)],subagentId:s,...a.agent?{agent:a.agent}:{},autoResumed:$.autoResumed}}d(E,"f"),i(E,"runAndCheck")}d(K,"ie"),i(K,"runSubagent");function L(u){return ru({cwd:u.cwd,projectTrusted:u.isProjectTrusted()})}d(L,"_"),i(L,"agentsFor");function _(u,t){if(t===void 0||t.trim()==="")return;const o=u.find(r=>r.name===t.trim());if(!o)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 o}d(_,"F"),i(_,"findAgent");function Q(u,t){return u.split("{previous}").join(t)}d(Q,"Qe"),i(Q,"fillPrevious");function Du(u){return e("\u6D3E\u53D1\u4E00\u4E2A\u5B50 agent \u5B8C\u6210\u81EA\u5305\u542B\u7684\u5B50\u4EFB\u52A1\uFF1B\u540C\u4E00\u8F6E\u591A\u6B21\u8C03\u7528\u5373\u5E76\u884C\u8FD0\u884C\u3002\u5B50 agent \u7528\u5F53\u524D\u6A21\u578B\u548C\u5B8C\u6574\u5DE5\u5177\uFF08\u540C\u6837\u7ECF\u8FC7\u5B89\u5168\u5BA1\u6279\uFF09\uFF0C\u770B\u4E0D\u5230\u672C\u5BF9\u8BDD\u3002")+`
|
|
15
15
|
`+e("\u89D2\u8272\uFF08agent \u53C2\u6570\uFF09\uFF1A")+`
|
|
16
|
-
`+
|
|
17
|
-
`+e("chain\uFF1A\u6309\u987A\u5E8F\u8FD0\u884C\u591A\u6B65\uFF08\u5982 scout \u2192 worker \u2192 reviewer\uFF09\u3002")}d(
|
|
16
|
+
`+nu(u)+`
|
|
17
|
+
`+e("chain\uFF1A\u6309\u987A\u5E8F\u8FD0\u884C\u591A\u6B65\uFF08\u5982 scout \u2192 worker \u2192 reviewer\uFF09\u3002")}d(Du,"Ye"),i(Du,"taskToolDescription");const Y=new Map,N=i(u=>u.totalTokens>0||u.cost.total>0,"hasUsage");function Z(u,t,o){u.registerTool({name:"task",label:e("\u6D3E\u53D1\u5B50\u4EFB\u52A1"),description:Du(t),promptSnippet:e("task - \u6D3E\u53D1\u5B50 agent \u5E76\u884C\u5904\u7406\u72EC\u7ACB\u5B50\u4EFB\u52A1"),promptGuidelines:pu,parameters:tt,executionMode:"parallel",execute:i(async(r,l,F,n,c)=>{const s=Nu();try{return await Bu(l,c,s,a=>{n?.({content:[{type:"text",text:a}],details:{description:l.description}})},u.getToolDenylist?.(),o.accountStop,{pi:u,deps:o,toolCallId:r})}catch(a){const h=o.accountStop.reason;if(h!==void 0)return{content:[{type:"text",text:a instanceof Error?a.message:String(a)}],details:{description:l.description,accountLimit:{reason:h},...N(s)?{usage:s}:{}},...N(s)?{usage:s}:{},isError:!0,terminate:!0};throw N(s)&&Y.set(r,s),a}},"execute")})}d(Z,"se"),i(Z,"registerTaskTool");async function Bu(u,t,o,r,l,F,n){const c=u.steer?.trim();if(c){if(!n)throw new Error(e("\u8FD9\u4E2A\u4F1A\u8BDD\u4E0D\u652F\u6301\u540E\u53F0\u5B50\u52A9\u624B\u3002"));const g=u.prompt?.trim();if(!g)throw new Error(e("steer \u9700\u8981\u5728 prompt \u91CC\u5199\u65B0\u7684\u6307\u793A\u3002"));const C=await n.deps.background().steer(c,g);if(C)throw new Error(C);return{content:[{type:"text",text:e("\u5DF2\u628A\u65B0\u6307\u793A\u9001\u8FBE\u540E\u53F0\u5B50\u52A9\u624B\uFF1B\u5B83\u7684\u62A5\u544A\u5B8C\u6210\u540E\u4F1A\u4EE5\u6D88\u606F\u9001\u56DE\u3002")}],details:{description:u.description,subagentId:c,background:!0}}}const{agents:s}=L(t),a=Array.isArray(u.chain)&&u.chain.length>0,h=typeof u.prompt=="string"&&u.prompt.trim()!=="",D=u.resume?.trim();if(D&&a)throw new Error(e("resume \u4E0D\u80FD\u548C chain \u4E00\u8D77\u4F7F\u7528\u3002"));if(!D&&a===h)throw new Error(e("task \u9700\u8981\u4E14\u53EA\u80FD\u63D0\u4F9B prompt \u6216 chain \u5176\u4E2D\u4E4B\u4E00\u3002"));const B=i(()=>N(o)?{usage:o}:{},"usage"),E=D?void 0:G(t);if(E)throw new Error(E);if(u.background&&(a||D||u.worktree))throw new Error(e("background \u4E0D\u80FD\u548C chain\u3001resume \u6216 worktree \u4E00\u8D77\u4F7F\u7528\u3002"));if(u.worktree&&a)throw new Error(e("worktree \u4E0D\u80FD\u548C chain \u4E00\u8D77\u4F7F\u7528\u3002"));if(!D){const g=n?.deps.pool.admit();if(g)throw new Error(g)}if(u.background){if(!n)throw new Error(e("\u8FD9\u4E2A\u4F1A\u8BDD\u4E0D\u652F\u6301\u540E\u53F0\u5B50\u52A9\u624B\u3002"));if(t.mode==="print"||t.mode==="json")throw new Error(e("\u5355\u6B21\u8FD0\u884C\uFF08-p\uFF09\u7ED3\u675F\u540E\u6536\u4E0D\u5230\u540E\u53F0\u7ED3\u679C\uFF1A\u4E0D\u8981\u7528 background\uFF0C\u76F4\u63A5\u8FD0\u884C\u3002"));return fu(u,t,s,n,l,F)}if(!a){let g=D?void 0:_(s,u.agent);const C=!D&&g===void 0?await lu(u.prompt??"",s,{credentials:t.modelRegistry}):void 0;C&&(g=C.agent);const f=await K({description:u.description,prompt:h?u.prompt??"":"",readOnly:u.readOnly===!0,agent:g,resume:D,worktree:u.worktree===!0,...n?{progress:new cu(n.pi,{...n.toolCallId?{parentToolCallId:n.toolCallId}:{},description:u.description,background:!1})}:{}},t,o,r,l,F,u.worktree&&n?(b,x,T)=>n.pi.exec(b,x,T):void 0);return{content:[{type:"text",text:`${C?`${j(C)}
|
|
18
18
|
${f.text}`:f.text}
|
|
19
19
|
|
|
20
|
-
${
|
|
20
|
+
${S(f.subagentId)}`}],details:{description:u.description,...f.agent?{agent:f.agent}:{},subagentId:f.subagentId,...f.autoResumed?{autoResumed:!0}:{},...B(),...C?{autoAgent:{name:C.agent.name,confidence:C.confidence}}:{},...f.changedFiles.length>0?{changedFiles:f.changedFiles}:{},...f.worktree?{worktree:f.worktree}:{}},...B()}}const p=u.chain??[],w=p.map(g=>_(s,g.agent??u.agent));let k="";const $=[],y=[];let I=!1;for(const[g,C]of p.entries()){const f=w[g],b=`${u.description} [${g+1}/${p.length}${f?` ${f.name}`:""}]`;try{const{text:x,changedFiles:T,subagentId:hu,autoResumed:wu}=await K({description:b,prompt:Q(C.prompt,k),readOnly:u.readOnly===!0,agent:f,...n?{progress:new cu(n.pi,{...n.toolCallId?{parentToolCallId:n.toolCallId}:{},description:b,background:!1,chain:{index:g+1,total:p.length}})}:{}},t,o,r,l,F);k=x,$.push(...T),y.push(hu),I||=wu}catch(x){const T=x instanceof Error?x.message:String(x);throw new Error(`${e("\u4E32\u884C\u94FE\u5728\u7B2C")} ${g+1} ${e("\u6B65\u4E2D\u65AD\uFF1A")}${T}`)}}const v=[...new Set($)],A=y[y.length-1]??"";return{content:[{type:"text",text:`${k}
|
|
21
21
|
|
|
22
|
-
${
|
|
23
|
-
`);const
|
|
22
|
+
${S(A)}`}],details:{description:u.description,subagentId:A,...I?{autoResumed:!0}:{},...B(),chain:w.map((g,C)=>({...g?{agent:g.name}:{},subagentId:y[C]})),...v.length>0?{changedFiles:v}:{}},...B()}}d(Bu,"Ze"),i(Bu,"executeTask");async function fu(u,t,o,r,l,F){let n=_(o,u.agent);const c=n===void 0?await lu(u.prompt??"",o,{credentials:t.modelRegistry}):void 0;c&&(n=c.agent);const s={description:u.description,prompt:u.prompt??"",readOnly:u.readOnly===!0,agent:n},a=await H(s,t),h=a.model.indexOf("/"),D=t.modelRegistry.find(a.model.slice(0,h),a.model.slice(h+1));if(!D)throw new Error(`${e("\u627E\u4E0D\u5230\u89D2\u8272\u6307\u5B9A\u7684\u6A21\u578B\uFF1A")}${a.model}`);const B=uu(),E=Fu();tu(E,{recursive:!0}),au(E),eu(W(E,B),`${JSON.stringify(a)}
|
|
23
|
+
`);const p=await Yu(B,{mode:t.mode}),w=Ou(t.tools.map(y=>y.name),{...a.tools?{allow:a.tools}:{},...l?{exclude:l}:{}});r.deps.background().start({id:B,description:u.description,...r.toolCallId?{parentToolCallId:r.toolCallId}:{},...n?{agent:n.name}:{},run:{parent:t,toolNames:w,toolInfos:r.pi.getAllTools(),model:D,thinking:a.thinking,appendSystemPrompt:a.appendSystemPrompt,prompt:s.prompt,session:{dir:E,id:B},...p?{tmux:p}:{}},...F?{signal:F.signal}:{},parentIdle:i(()=>t.isIdle(),"parentIdle"),onAccountLimit:i(y=>F?.trip(y),"onAccountLimit")});const{running:k,queued:$}=r.deps.pool.stats;return{content:[{type:"text",text:`${c?`${j(c)}
|
|
24
24
|
`:""}${e("\u5DF2\u5728\u540E\u53F0\u542F\u52A8\uFF1B\u5B8C\u6210\u540E\u62A5\u544A\u4F1A\u4EE5\u6D88\u606F\u9001\u56DE\uFF0C\u4E0D\u7528\u7B49\u5F85\u6216\u8F6E\u8BE2\u3002")} (${e("\u8FD0\u884C\u4E2D")} ${k}, ${e("\u6392\u961F")} ${$})
|
|
25
|
-
${
|
|
26
|
-
`:""}${
|
|
27
|
-
${e("\u5F53\u524D\uFF1A")}${du()}`,"info");return}try{
|
|
28
|
-
`),D.length>0?"warning":"info")},"handler")})}d(
|
|
25
|
+
${p?`${Qu(p)}
|
|
26
|
+
`:""}${S(B)}`}],details:{description:u.description,subagentId:B,background:!0,...n?{agent:n.name}:{},...c?{autoAgent:{name:c.agent.name,confidence:c.confidence}}:{}}}}d(fu,"Ve"),i(fu,"startBackground");function V(u){const{tmux:t}=u;return t?Hu({...u,tmux:t}):ju(u)}d(V,"ae"),i(V,"runBackground");function Cu(u){if(Xu(u),_u()>=qu)return;const t=new Au,o=new Ru;let r=new su(u,o,V);const l={accountStop:t,pool:o,background:i(()=>r,"background")};Z(u,ru({cwd:process.cwd(),projectTrusted:!1}).agents,l),u.on("session_start",async(F,n)=>{r=new su(u,o,V),Z(u,L(n).agents,l)}),u.on("session_shutdown",()=>{r.close()}),u.on("message_end",F=>{const n=F.message;n.role==="assistant"&&vu(n)&&t.trip(n.errorMessage??"account limit")}),u.on("agent_start",()=>{t.reset(),o.resetRun()}),u.on("tool_result",F=>{const n=F.toolName==="task"&&F.isError?Y.get(F.toolCallId):void 0;if(Y.delete(F.toolCallId),!n)return;const c=F.input.description??"";return{usage:n,details:{description:c,usage:n}}}),u.registerCommand("agents",{description:e("\u5217\u51FA\u5B50 agent \u89D2\u8272\u548C\u6B63\u5728\u540E\u53F0\u8FD0\u884C\u7684\u5B50\u52A9\u624B\uFF1B/agents steer <ID> <\u6307\u793A> \u8C03\u6574\u65B9\u5411\uFF0C/agents stop <ID> \u505C\u6B62\u4E00\u4E2A\uFF0C/agents tmux on|off \u5207\u6362 tmux \u7A97\u53E3"),handler:i(async(F,n)=>{const[c,s]=F.trim().split(/\s+/);if(c==="tmux"){if(s!=="on"&&s!=="off"){n.ui.notify(`${e("\u7528\u6CD5\uFF1A/agents tmux on|off\uFF08\u540E\u53F0\u5B50\u52A9\u624B\u662F\u5426\u5728\u72EC\u7ACB\u7684 tmux \u7A97\u53E3\u8FD0\u884C\uFF09")}
|
|
27
|
+
${e("\u5F53\u524D\uFF1A")}${du()}`,"info");return}try{Ku(s)}catch(E){n.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${E instanceof Error?E.message:String(E)}`,"error");return}n.ui.notify(s==="on"?e("\u5DF2\u5F00\u542F\uFF1A\u4E4B\u540E\u7684\u540E\u53F0\u5B50\u52A9\u624B\u5728\u72EC\u7ACB\u7684 tmux \u7A97\u53E3\u8FD0\u884C\uFF0C\u7B49\u4F60\u786E\u8BA4\u65F6\u4F1A\u5728\u8FD9\u91CC\u63D0\u793A\u7A97\u53E3\u53F7"):e("\u5DF2\u5173\u95ED\uFF1A\u540E\u53F0\u5B50\u52A9\u624B\u56DE\u5230\u5F53\u524D\u8FDB\u7A0B\u91CC\u8FD0\u884C"),"info");return}if(c==="steer"){const E=F.trim().replace(/^steer\s+\S+\s*/,"").trim();if(!s||!E){n.ui.notify(e("\u7528\u6CD5\uFF1A/agents steer <ID> <\u65B0\u7684\u6307\u793A>\uFF08ID \u89C1 /agents \u5217\u8868\uFF09"),"warning");return}const p=await r.steer(s,E);n.ui.notify(p??e("\u5DF2\u628A\u65B0\u6307\u793A\u9001\u8FBE\u540E\u53F0\u5B50\u52A9\u624B\u3002"),p?"warning":"info");return}if(c==="stop"){const E=s?r.stop(s):!1;n.ui.notify(E?e("\u5DF2\u505C\u6B62\u8BE5\u540E\u53F0\u5B50\u52A9\u624B\u3002"):e("\u7528\u6CD5\uFF1A/agents stop <ID>\uFF08ID \u89C1 /agents \u5217\u8868\uFF09"),E?"info":"warning");return}const a=r.active(),{agents:h,diagnostics:D}=L(n),B=[e("\u53EF\u7528\u7684\u5B50 agent \u89D2\u8272\uFF1A"),nu(h,!0),"",`${e("\u7528\u6237\u89D2\u8272\u76EE\u5F55\uFF1A")}${Pu()}`,`${e("\u9879\u76EE\u89D2\u8272\u76EE\u5F55\uFF1A")}${Tu(n.cwd)}${n.isProjectTrusted()?"":e("\uFF08\u9879\u76EE\u672A\u4FE1\u4EFB\uFF0C\u672A\u8BFB\u53D6\uFF09")}`];a.length>0&&B.unshift(e("\u540E\u53F0\u5B50\u52A9\u624B\uFF1A"),...a.map(E=>`- ${E.id.slice(0,8)} ${E.description} \xB7 ${E.status==="queued"?e("\u6392\u961F"):e("\u8FD0\u884C\u4E2D")} ${Math.round((Date.now()-E.startedAt)/1e3)}s`),""),D.length>0&&B.push("",e("\u4EE5\u4E0B\u89D2\u8272\u6587\u4EF6\u6709\u95EE\u9898\uFF1A"),...D.map(E=>`- ${E}`)),process.env.TMUX&&du()==="off"&&B.push("",e("\u4F60\u5728 tmux \u91CC\uFF1A/agents tmux on \u53EF\u8BA9\u540E\u53F0\u5B50\u52A9\u624B\u5728\u72EC\u7ACB\u7A97\u53E3\u8FD0\u884C\uFF0C\u4FBF\u4E8E\u67E5\u770B\u548C\u63A5\u7BA1\u3002")),n.ui.notify(B.join(`
|
|
28
|
+
`),D.length>0?"warning":"info")},"handler")})}d(Cu,"et"),i(Cu,"default");export{Au as AccountLimitStop,U as SMALL_PROJECT_FILES,pu as TASK_TOOL_GUIDELINES,P as accountLimitMessage,j as autoRoleNote,X as buildSubagentSystemPrompt,O as continuePrompt,Cu as default,Q as fillPrevious,q as gitProjectFileCount,z as lastAssistantText,M as resolveAgentModel,G as smallProjectRefusal,S as subagentIdLine,R as worktreeLine};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.defineProperty;var i=(e,t)=>g(e,"name",{value:t,configurable:!0});var b=Object.defineProperty,n=i((e,t)=>b(e,"name",{value:t,configurable:!0}),"s");const p="subagent_progress",d=300;function h(e){for(const t of["file_path","path","filePath"]){const s=e[t];if(typeof s=="string"&&s.length>0)return s}}i(h,"g"),n(h,"filePathFromInput");function u(e,t){const s=h(t??{});if(s)return`${e} ${s.split("/").slice(-2).join("/")}`;const a=t??{};for(const l of["command","pattern","query"]){const r=a[l];if(typeof r=="string"&&r.trim()){const o=r.replace(/\s+/g," ").trim();return`${e} ${o.length>40?`${o.slice(0,39)}\u2026`:o}`}}return e}i(u,"c"),n(u,"describeSubagentStep");function c(e){const t=e.replace(/\s+/g," ").trim();if(t)return t.length<=300?t:`${t.slice(0,299)}\u2026`}i(c,"p"),n(c,"progressSummary");class f{static{i(this,"b")}static{n(this,"SubagentProgress")}pi;state;base;constructor(t,s){this.pi=t,this.base=s}start(t,s={}){this.state={subagentId:t,...this.base.parentToolCallId?{parentToolCallId:this.base.parentToolCallId}:{},description:this.base.description,...s.agent?{agent:s.agent}:{},background:this.base.background,status:s.status??"running",steps:0,...this.base.chain?{chain:this.base.chain}:{},startedAt:Date.now()},this.publish()}running(){!this.state||this.state.status==="running"||(this.state.status="running",this.publish())}step(t,s){!this.state||this.state.endedAt!==void 0||(this.state.status="running",this.state.steps+=1,this.state.currentStep=u(t,s),this.publish())}finish(t,s){if(!this.state||this.state.endedAt!==void 0)return;this.state.status=t,this.state.endedAt=Date.now();const a=s?c(s):void 0;a&&(this.state.summary=a),this.publish()}publish(){if(!this.state)return;const t={...this.state,updatedAt:Date.now()};try{this.pi.emitHostEvent(p,t)}catch{}}}export{d as MAX_PROGRESS_SUMMARY_CHARS,p as SUBAGENT_PROGRESS_EVENT,f as SubagentProgress,u as describeSubagentStep,h as filePathFromInput,c as progressSummary};
|